Package org.rocksdb
Class SstFileManager
java.lang.Object
org.rocksdb.AbstractNativeReference
org.rocksdb.AbstractImmutableNativeReference
org.rocksdb.RocksObject
org.rocksdb.SstFileManager
- All Implemented Interfaces:
AutoCloseable
SstFileManager is used to track SST files in the DB and control their
deletion rate.
All SstFileManager public functions are thread-safe.
SstFileManager is not extensible.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longstatic final booleanstatic final doublestatic final longFields inherited from class org.rocksdb.RocksObject
nativeHandle_Fields inherited from class org.rocksdb.AbstractImmutableNativeReference
owningHandle_ -
Constructor Summary
ConstructorsConstructorDescriptionSstFileManager(Env env) Create a new SstFileManager that can be shared among multiple RocksDB instances to track SST file and control there deletion rate.SstFileManager(Env env, Logger logger) Create a new SstFileManager that can be shared among multiple RocksDB instances to track SST file and control there deletion rate.SstFileManager(Env env, Logger logger, long rateBytesPerSec) Create a new SstFileManager that can be shared among multiple RocksDB instances to track SST file and control there deletion rate.SstFileManager(Env env, Logger logger, long rateBytesPerSec, double maxTrashDbRatio) Create a new SstFileManager that can be shared among multiple RocksDB instances to track SST file and control there deletion rate.SstFileManager(Env env, Logger logger, long rateBytesPerSec, double maxTrashDbRatio, long bytesMaxDeleteChunk) Create a new SstFileManager that can be shared among multiple RocksDB instances to track SST file and control there deletion rate. -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddisposeInternal(long handle) longGets the delete rate limit.doubleGet the trash/DB size ratio where new files will be deleted immediately.longGet the total size of all tracked files.Gets all tracked files and their corresponding sizes.booleanDetermines if the total size of SST files exceeded the maximum allowed space usage.booleanDetermines if the total size of SST files as well as estimated size of ongoing compactions exceeds the maximums allowed space usage.voidsetCompactionBufferSize(long compactionBufferSize) Set the amount of buffer room each compaction should be able to leave.voidsetDeleteRateBytesPerSecond(long deleteRate) Set the delete rate limit.voidsetMaxAllowedSpaceUsage(long maxAllowedSpace) Update the maximum allowed space that should be used by RocksDB, if the total size of the SST files exceedsmaxAllowedSpace, writes to RocksDB will fail.voidsetMaxTrashDBRatio(double ratio) Set the trash/DB size ratio where new files will be deleted immediately.Methods inherited from class org.rocksdb.RocksObject
disposeInternal, getNativeHandleMethods inherited from class org.rocksdb.AbstractImmutableNativeReference
close, disOwnNativeHandle, isOwningHandle
-
Field Details
-
RATE_BYTES_PER_SEC_DEFAULT
public static final long RATE_BYTES_PER_SEC_DEFAULT- See Also:
-
DELETE_EXISTING_TRASH_DEFAULT
public static final boolean DELETE_EXISTING_TRASH_DEFAULT- See Also:
-
MAX_TRASH_DB_RATION_DEFAULT
public static final double MAX_TRASH_DB_RATION_DEFAULT- See Also:
-
BYTES_MAX_DELETE_CHUNK_DEFAULT
public static final long BYTES_MAX_DELETE_CHUNK_DEFAULT- See Also:
-
-
Constructor Details
-
SstFileManager
Create a new SstFileManager that can be shared among multiple RocksDB instances to track SST file and control there deletion rate.- Parameters:
env- the environment.- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
SstFileManager
Create a new SstFileManager that can be shared among multiple RocksDB instances to track SST file and control there deletion rate.- Parameters:
env- the environment.logger- if not null, the logger will be used to log errors.- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
SstFileManager
Create a new SstFileManager that can be shared among multiple RocksDB instances to track SST file and control there deletion rate.- Parameters:
env- the environment.logger- if not null, the logger will be used to log errors.== Deletion rate limiting specific arguments ==
rateBytesPerSec- how many bytes should be deleted per second, If this value is set to 1024 (1 Kb / sec) and we deleted a file of size 4 Kb in 1 second, we will wait for another 3 seconds before we delete other files, Set to 0 to disable deletion rate limiting.- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
SstFileManager
public SstFileManager(Env env, Logger logger, long rateBytesPerSec, double maxTrashDbRatio) throws RocksDBException Create a new SstFileManager that can be shared among multiple RocksDB instances to track SST file and control there deletion rate.- Parameters:
env- the environment.logger- if not null, the logger will be used to log errors.== Deletion rate limiting specific arguments ==
rateBytesPerSec- how many bytes should be deleted per second, If this value is set to 1024 (1 Kb / sec) and we deleted a file of size 4 Kb in 1 second, we will wait for another 3 seconds before we delete other files, Set to 0 to disable deletion rate limiting.maxTrashDbRatio- if the trash size constitutes for more than this fraction of the total DB size we will start deleting new files passed to DeleteScheduler immediately.- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
SstFileManager
public SstFileManager(Env env, Logger logger, long rateBytesPerSec, double maxTrashDbRatio, long bytesMaxDeleteChunk) throws RocksDBException Create a new SstFileManager that can be shared among multiple RocksDB instances to track SST file and control there deletion rate.- Parameters:
env- the environment.logger- if not null, the logger will be used to log errors.== Deletion rate limiting specific arguments ==
rateBytesPerSec- how many bytes should be deleted per second, If this value is set to 1024 (1 Kb / sec) and we deleted a file of size 4 Kb in 1 second, we will wait for another 3 seconds before we delete other files, Set to 0 to disable deletion rate limiting.maxTrashDbRatio- if the trash size constitutes for more than this fraction of the total DB size we will start deleting new files passed to DeleteScheduler immediately.bytesMaxDeleteChunk- if a single file is larger than delete chunk, ftruncate the file by this size each time, rather than dropping the whole file. 0 means to always delete the whole file.- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
-
Method Details
-
setMaxAllowedSpaceUsage
public void setMaxAllowedSpaceUsage(long maxAllowedSpace) Update the maximum allowed space that should be used by RocksDB, if the total size of the SST files exceedsmaxAllowedSpace, writes to RocksDB will fail.Setting
maxAllowedSpaceto 0 will disable this feature; maximum allowed space will be infinite (Default value).- Parameters:
maxAllowedSpace- the maximum allowed space that should be used by RocksDB.
-
setCompactionBufferSize
public void setCompactionBufferSize(long compactionBufferSize) Set the amount of buffer room each compaction should be able to leave. In other words, at its maximum disk space consumption, the compaction should still leavecompactionBufferSizeavailable on the disk so that other background functions may continue, such as logging and flushing.- Parameters:
compactionBufferSize- the amount of buffer room each compaction should be able to leave.
-
isMaxAllowedSpaceReached
public boolean isMaxAllowedSpaceReached()Determines if the total size of SST files exceeded the maximum allowed space usage.- Returns:
- true when the maximum allows space usage has been exceeded.
-
isMaxAllowedSpaceReachedIncludingCompactions
public boolean isMaxAllowedSpaceReachedIncludingCompactions()Determines if the total size of SST files as well as estimated size of ongoing compactions exceeds the maximums allowed space usage.- Returns:
- true when the total size of SST files as well as estimated size of ongoing compactions exceeds the maximums allowed space usage.
-
getTotalSize
public long getTotalSize()Get the total size of all tracked files.- Returns:
- the total size of all tracked files.
-
getTrackedFiles
Gets all tracked files and their corresponding sizes.- Returns:
- a map containing all tracked files and there corresponding sizes.
-
getDeleteRateBytesPerSecond
public long getDeleteRateBytesPerSecond()Gets the delete rate limit.- Returns:
- the delete rate limit (in bytes per second).
-
setDeleteRateBytesPerSecond
public void setDeleteRateBytesPerSecond(long deleteRate) Set the delete rate limit.Zero means disable delete rate limiting and delete files immediately.
- Parameters:
deleteRate- the delete rate limit (in bytes per second).
-
getMaxTrashDBRatio
public double getMaxTrashDBRatio()Get the trash/DB size ratio where new files will be deleted immediately.- Returns:
- the trash/DB size ratio.
-
setMaxTrashDBRatio
public void setMaxTrashDBRatio(double ratio) Set the trash/DB size ratio where new files will be deleted immediately.- Parameters:
ratio- the trash/DB size ratio.
-
disposeInternal
protected void disposeInternal(long handle) - Specified by:
disposeInternalin classRocksObject
-