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
-
Constructor Summary
Constructors Constructor Description TrackedSeekableByteChannel(FileHandleFactory.FileToHandleFunction fileHandleCreator, File file)
Make a channel for a "local" file. -
Method Summary
Modifier and Type Method Description void
close()
boolean
isOpen()
long
position()
SeekableByteChannel
position(long newPosition)
int
read(ByteBuffer destination)
long
size()
SeekableByteChannel
truncate(long size)
int
write(ByteBuffer source)
-
Constructor Details
-
TrackedSeekableByteChannel
public TrackedSeekableByteChannel(@NotNull FileHandleFactory.FileToHandleFunction fileHandleCreator, @NotNull File file) throws IOExceptionMake 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
-