Package com.illumon.iris.db.util.file
Class TrackedSeekableByteChannel
java.lang.Object
com.illumon.iris.db.util.file.FileHandleAccessor
com.illumon.iris.db.util.file.TrackedSeekableByteChannel
- All Implemented Interfaces:
Closeable
,AutoCloseable
,ByteChannel
,Channel
,ReadableByteChannel
,SeekableByteChannel
,WritableByteChannel
public final class TrackedSeekableByteChannel
extends FileHandleAccessor
implements SeekableByteChannel
SeekableByteChannel
wrapper around FileHandle
with support for re-opening the handle in case it
has been closed asynchronously.
Note the applications must be sure to use read(ByteBuffer)
, write(ByteBuffer)
, and
position(long)
in a thread safe manner, using external synchronization or other means.
-
Field Summary
Fields inherited from class com.illumon.iris.db.util.file.FileHandleAccessor
file, fileHandle
-
Constructor Summary
ConstructorsConstructorDescriptionTrackedSeekableByteChannel
(FileHandleFactory.FileToHandleFunction fileHandleCreator, File file) Make a channel for a "local" file. -
Method Summary
Modifier and TypeMethodDescriptionfinal void
close()
final boolean
isOpen()
final long
position()
final SeekableByteChannel
position
(long newPosition) final int
read
(ByteBuffer destination) final long
size()
final SeekableByteChannel
truncate
(long size) final int
write
(ByteBuffer source) Methods inherited from class com.illumon.iris.db.util.file.FileHandleAccessor
refreshFileHandle
-
Constructor Details
-
TrackedSeekableByteChannel
public TrackedSeekableByteChannel(@NotNull FileHandleFactory.FileToHandleFunction fileHandleCreator, @NotNull File file) throws IOException Make a channel for a "local" file.- Parameters:
fileHandleCreator
- The function used to make file handlesfile
- The abstract path name to wrap access to- Throws:
IOException
-
-
Method Details
-
read
- Specified by:
read
in interfaceReadableByteChannel
- Specified by:
read
in interfaceSeekableByteChannel
- Throws:
IOException
-
write
- Specified by:
write
in interfaceSeekableByteChannel
- Specified by:
write
in interfaceWritableByteChannel
- Throws:
IOException
-
position
- Specified by:
position
in interfaceSeekableByteChannel
- Throws:
IOException
-
position
- Specified by:
position
in interfaceSeekableByteChannel
- Throws:
IOException
-
size
- Specified by:
size
in interfaceSeekableByteChannel
- Throws:
IOException
-
truncate
- Specified by:
truncate
in interfaceSeekableByteChannel
- Throws:
IOException
-
isOpen
public final boolean isOpen() -
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceChannel
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-