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 voidclose()final booleanisOpen()final longposition()final SeekableByteChannelposition(long newPosition) final intread(ByteBuffer destination) final longsize()final SeekableByteChanneltruncate(long size) final intwrite(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:
readin interfaceReadableByteChannel- Specified by:
readin interfaceSeekableByteChannel- Throws:
IOException
-
write
- Specified by:
writein interfaceSeekableByteChannel- Specified by:
writein interfaceWritableByteChannel- Throws:
IOException
-
position
- Specified by:
positionin interfaceSeekableByteChannel- Throws:
IOException
-
position
- Specified by:
positionin interfaceSeekableByteChannel- Throws:
IOException
-
size
- Specified by:
sizein interfaceSeekableByteChannel- Throws:
IOException
-
truncate
- Specified by:
truncatein interfaceSeekableByteChannel- Throws:
IOException
-
isOpen
public final boolean isOpen() -
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceChannel- Specified by:
closein interfaceCloseable- Throws:
IOException
-