Package io.deephaven.engine.util.file
Class TrackedSeekableByteChannel
java.lang.Object
io.deephaven.engine.util.file.FileHandleAccessor
io.deephaven.engine.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 io.deephaven.engine.util.file.FileHandleAccessor
file, fileHandle
-
Constructor Summary
ConstructorDescriptionTrackedSeekableByteChannel
(FileHandleFactory.FileToHandleFunction fileHandleCreator, @NotNull 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
(@NotNull ByteBuffer destination) final long
size()
final SeekableByteChannel
truncate
(long size) final int
write
(@NotNull ByteBuffer source) Methods inherited from class io.deephaven.engine.util.file.FileHandleAccessor
refreshFileHandle, toString
-
Constructor Details
-
TrackedSeekableByteChannel
public TrackedSeekableByteChannel(@NotNull FileHandleFactory.FileToHandleFunction fileHandleCreator, @NotNull @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
-