Package com.illumon.iris.db.util.file
Class TrackedFileHandleFactory
java.lang.Object
com.illumon.iris.db.util.file.TrackedFileHandleFactory
- All Implemented Interfaces:
FileHandleFactory
Simple least-recently-opened "cache" for FileHandles, to avoid running up against ulimits.
Will probably not achieve satisfactory results if the number of file handles concurrently in active use
exceeds capacity.
Note that returned FileHandles may be closed asynchronously by the factory.
TODO: Consider adding a lookup to enable handle sharing. Not necessary for current usage.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.illumon.iris.db.util.file.FileHandleFactory
FileHandleFactory.FileToHandleFunction, FileHandleFactory.OpenOptionsHelper
-
Field Summary
FieldsModifier and TypeFieldDescription -
Constructor Summary
ConstructorsConstructorDescriptionTrackedFileHandleFactory
(io.deephaven.enterprise.niowrapper.sched.Scheduler scheduler, int capacity) Constructor with default target usage ratio of 0.9 (90%) and cleanup attempts every 60 seconds.TrackedFileHandleFactory
(io.deephaven.enterprise.niowrapper.sched.Scheduler scheduler, int capacity, double targetUsageRatio, long cleanupIntervalMillis) Full constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
closeAll()
int
static TrackedFileHandleFactory
io.deephaven.enterprise.niowrapper.sched.Scheduler
int
getSize()
double
int
final FileHandle
makeHandle
(File file, OpenOption[] openOptions) Create a newFileHandle
with the specified set ofOpenOption
s.
-
Field Details
-
readOnlyHandleCreator
-
readWriteCreateHandleCreator
-
writeAppendCreateHandleCreator
-
writeTruncateCreateHandleCreator
-
-
Constructor Details
-
TrackedFileHandleFactory
public TrackedFileHandleFactory(@NotNull io.deephaven.enterprise.niowrapper.sched.Scheduler scheduler, int capacity, double targetUsageRatio, long cleanupIntervalMillis) Full constructor.- Parameters:
scheduler
- The scheduler to use for cleanupcapacity
- The total number of file handles to allow outstandingtargetUsageRatio
- The target usage threshold as a ratio of capacity, in [0.1, 0.9]cleanupIntervalMillis
- The interval for asynchronous cleanup attempts
-
TrackedFileHandleFactory
public TrackedFileHandleFactory(@NotNull io.deephaven.enterprise.niowrapper.sched.Scheduler scheduler, int capacity) Constructor with default target usage ratio of 0.9 (90%) and cleanup attempts every 60 seconds.- Parameters:
scheduler
- The scheduler to use for cleanupcapacity
- The total number of file handles to allow outstanding
-
-
Method Details
-
getInstance
-
getScheduler
public io.deephaven.enterprise.niowrapper.sched.Scheduler getScheduler() -
getCapacity
public int getCapacity() -
getTargetUsageRatio
public double getTargetUsageRatio() -
getTargetUsageThreshold
public int getTargetUsageThreshold() -
getSize
public int getSize() -
makeHandle
@NotNull public final FileHandle makeHandle(@NotNull File file, @NotNull OpenOption[] openOptions) throws IOException Description copied from interface:FileHandleFactory
Create a newFileHandle
with the specified set ofOpenOption
s.- Specified by:
makeHandle
in interfaceFileHandleFactory
- Parameters:
file
- TheFile
to openopenOptions
- TheOpenOption
s to use- Returns:
- The new file handle
- Throws:
IOException
-
closeAll
public void closeAll()
-