Package org.rocksdb
Class AbstractEventListener
- java.lang.Object
-
- org.rocksdb.AbstractNativeReference
-
- org.rocksdb.AbstractImmutableNativeReference
-
- org.rocksdb.RocksCallbackObject
-
- org.rocksdb.AbstractEventListener
-
- All Implemented Interfaces:
java.lang.AutoCloseable,EventListener
public abstract class AbstractEventListener extends RocksCallbackObject implements EventListener
Base class for Event Listeners.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAbstractEventListener.EnabledEventCallback
-
Field Summary
-
Fields inherited from class org.rocksdb.RocksCallbackObject
nativeHandle_
-
Fields inherited from class org.rocksdb.AbstractImmutableNativeReference
owningHandle_
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractEventListener()Creates an Event Listener that will received all callbacks from C++.protectedAbstractEventListener(AbstractEventListener.EnabledEventCallback... enabledEventCallbacks)Creates an Event Listener that will receive only certain callbacks from C++.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddisposeInternal()Deletes underlying C++ native callback object pointerprotected longinitializeNative(long... nativeParameterHandles)Construct the Native C++ object which will callback to our object methodsvoidonBackgroundError(BackgroundErrorReason backgroundErrorReason, Status backgroundError)A callback function for RocksDB which will be called before setting the background error status to a non-OK value.voidonColumnFamilyHandleDeletionStarted(ColumnFamilyHandle columnFamilyHandle)A callback function for RocksDB which will be called before a column family handle is deleted.voidonCompactionBegin(RocksDB db, CompactionJobInfo compactionJobInfo)A callback function to RocksDB which will be called before a RocksDB starts to compact.voidonCompactionCompleted(RocksDB db, CompactionJobInfo compactionJobInfo)A callback function for RocksDB which will be called whenever a registered RocksDB compacts a file.booleanonErrorRecoveryBegin(BackgroundErrorReason backgroundErrorReason, Status backgroundError)A callback function for RocksDB which will be called just before starting the automatic recovery process for recoverable background errors, such as NoSpace().voidonErrorRecoveryCompleted(Status oldBackgroundError)A callback function for RocksDB which will be called once the database is recovered from read-only mode after an error.voidonExternalFileIngested(RocksDB db, ExternalFileIngestionInfo externalFileIngestionInfo)A callback function for RocksDB which will be called after an external file is ingested using IngestExternalFile.voidonFileCloseFinish(FileOperationInfo fileOperationInfo)A callback function for RocksDB which will be called whenever a file close operation finishes.voidonFileFlushFinish(FileOperationInfo fileOperationInfo)A callback function for RocksDB which will be called whenever a file flush operation finishes.voidonFileRangeSyncFinish(FileOperationInfo fileOperationInfo)A callback function for RocksDB which will be called whenever a file rangeSync operation finishes.voidonFileReadFinish(FileOperationInfo fileOperationInfo)A callback function for RocksDB which will be called whenever a file read operation finishes.voidonFileSyncFinish(FileOperationInfo fileOperationInfo)A callback function for RocksDB which will be called whenever a file sync operation finishes.voidonFileTruncateFinish(FileOperationInfo fileOperationInfo)A callback function for RocksDB which will be called whenever a file truncate operation finishes.voidonFileWriteFinish(FileOperationInfo fileOperationInfo)A callback function for RocksDB which will be called whenever a file write operation finishes.voidonFlushBegin(RocksDB db, FlushJobInfo flushJobInfo)A callback function to RocksDB which will be called before a RocksDB starts to flush memtables.voidonFlushCompleted(RocksDB db, FlushJobInfo flushJobInfo)callback function to RocksDB which will be called whenever a registered RocksDB flushes a file.voidonMemTableSealed(MemTableInfo memTableInfo)A callback function for RocksDB which will be called before a memtable is made immutable.voidonStallConditionsChanged(WriteStallInfo writeStallInfo)A callback function for RocksDB which will be called whenever a change of superversion triggers a change of the stall conditions.voidonTableFileCreated(TableFileCreationInfo tableFileCreationInfo)A callback function for RocksDB which will be called whenever a SST file is created.voidonTableFileCreationStarted(TableFileCreationBriefInfo tableFileCreationBriefInfo)A callback function for RocksDB which will be called before a SST file is being created.voidonTableFileDeleted(TableFileDeletionInfo tableFileDeletionInfo)A callback function for RocksDB which will be called whenever a SST file is deleted.booleanshouldBeNotifiedOnFileIO()If true, theEventListener.onFileReadFinish(FileOperationInfo)andEventListener.onFileWriteFinish(FileOperationInfo)will be called.-
Methods inherited from class org.rocksdb.AbstractImmutableNativeReference
close, disOwnNativeHandle, isOwningHandle
-
Methods inherited from class org.rocksdb.AbstractNativeReference
dispose, finalize
-
-
-
-
Constructor Detail
-
AbstractEventListener
protected AbstractEventListener()
Creates an Event Listener that will received all callbacks from C++. If you don't need all callbacks, it is much more efficient to just register for the ones you need by callingAbstractEventListener(EnabledEventCallback...)instead.
-
AbstractEventListener
protected AbstractEventListener(AbstractEventListener.EnabledEventCallback... enabledEventCallbacks)
Creates an Event Listener that will receive only certain callbacks from C++.- Parameters:
enabledEventCallbacks- callbacks to enable in Java.
-
-
Method Detail
-
onFlushCompleted
public void onFlushCompleted(RocksDB db, FlushJobInfo flushJobInfo)
Description copied from interface:EventListenercallback function to RocksDB which will be called whenever a registered RocksDB flushes a file. Note that the this function must be implemented in a way such that it should not run for an extended period of time before the function returns. Otherwise, RocksDB may be blocked.- Specified by:
onFlushCompletedin interfaceEventListener- Parameters:
db- the databaseflushJobInfo- the flush job info, contains data copied from respective native structure.
-
onFlushBegin
public void onFlushBegin(RocksDB db, FlushJobInfo flushJobInfo)
Description copied from interface:EventListenerA callback function to RocksDB which will be called before a RocksDB starts to flush memtables. Note that the this function must be implemented in a way such that it should not run for an extended period of time before the function returns. Otherwise, RocksDB may be blocked.- Specified by:
onFlushBeginin interfaceEventListener- Parameters:
db- the databaseflushJobInfo- the flush job info, contains data copied from respective native structure.
-
onTableFileDeleted
public void onTableFileDeleted(TableFileDeletionInfo tableFileDeletionInfo)
Description copied from interface:EventListenerA callback function for RocksDB which will be called whenever a SST file is deleted. Different fromEventListener.onCompactionCompleted(RocksDB, CompactionJobInfo)andEventListener.onFlushCompleted(RocksDB, FlushJobInfo), this callback is designed for external logging service and thus only provide string parameters instead of a pointer to DB. Applications that build logic basic based on file creations and deletions is suggested to implementEventListener.onFlushCompleted(RocksDB, FlushJobInfo)andEventListener.onCompactionCompleted(RocksDB, CompactionJobInfo). Note that if applications would like to use the passed reference outside this function call, they should make copies from the returned value.- Specified by:
onTableFileDeletedin interfaceEventListener- Parameters:
tableFileDeletionInfo- the table file deletion info, contains data copied from respective native structure.
-
onCompactionBegin
public void onCompactionBegin(RocksDB db, CompactionJobInfo compactionJobInfo)
Description copied from interface:EventListenerA callback function to RocksDB which will be called before a RocksDB starts to compact. The default implementation is no-op. Note that the this function must be implemented in a way such that it should not run for an extended period of time before the function returns. Otherwise, RocksDB may be blocked.- Specified by:
onCompactionBeginin interfaceEventListener- Parameters:
db- a pointer to the rocksdb instance which just compacted a file.compactionJobInfo- a reference to a native CompactionJobInfo struct, which is released after this function is returned, and must be copied if it is needed outside of this function.
-
onCompactionCompleted
public void onCompactionCompleted(RocksDB db, CompactionJobInfo compactionJobInfo)
Description copied from interface:EventListenerA callback function for RocksDB which will be called whenever a registered RocksDB compacts a file. The default implementation is a no-op. Note that this function must be implemented in a way such that it should not run for an extended period of time before the function returns. Otherwise, RocksDB may be blocked.- Specified by:
onCompactionCompletedin interfaceEventListener- Parameters:
db- a pointer to the rocksdb instance which just compacted a file.compactionJobInfo- a reference to a native CompactionJobInfo struct, which is released after this function is returned, and must be copied if it is needed outside of this function.
-
onTableFileCreated
public void onTableFileCreated(TableFileCreationInfo tableFileCreationInfo)
Description copied from interface:EventListenerA callback function for RocksDB which will be called whenever a SST file is created. Different from OnCompactionCompleted and OnFlushCompleted, this callback is designed for external logging service and thus only provide string parameters instead of a pointer to DB. Applications that build logic basic based on file creations and deletions is suggested to implement OnFlushCompleted and OnCompactionCompleted. Historically it will only be called if the file is successfully created. Now it will also be called on failure case. User can check info.status to see if it succeeded or not. Note that if applications would like to use the passed reference outside this function call, they should make copies from these returned value.- Specified by:
onTableFileCreatedin interfaceEventListener- Parameters:
tableFileCreationInfo- the table file creation info, contains data copied from respective native structure.
-
onTableFileCreationStarted
public void onTableFileCreationStarted(TableFileCreationBriefInfo tableFileCreationBriefInfo)
Description copied from interface:EventListenerA callback function for RocksDB which will be called before a SST file is being created. It will follow by OnTableFileCreated after the creation finishes. Note that if applications would like to use the passed reference outside this function call, they should make copies from these returned value.- Specified by:
onTableFileCreationStartedin interfaceEventListener- Parameters:
tableFileCreationBriefInfo- the table file creation brief info, contains data copied from respective native structure.
-
onMemTableSealed
public void onMemTableSealed(MemTableInfo memTableInfo)
Description copied from interface:EventListenerA callback function for RocksDB which will be called before a memtable is made immutable. Note that the this function must be implemented in a way such that it should not run for an extended period of time before the function returns. Otherwise, RocksDB may be blocked. Note that if applications would like to use the passed reference outside this function call, they should make copies from these returned value.- Specified by:
onMemTableSealedin interfaceEventListener- Parameters:
memTableInfo- the mem table info, contains data copied from respective native structure.
-
onColumnFamilyHandleDeletionStarted
public void onColumnFamilyHandleDeletionStarted(ColumnFamilyHandle columnFamilyHandle)
Description copied from interface:EventListenerA callback function for RocksDB which will be called before a column family handle is deleted. Note that the this function must be implemented in a way such that it should not run for an extended period of time before the function returns. Otherwise, RocksDB may be blocked.- Specified by:
onColumnFamilyHandleDeletionStartedin interfaceEventListener- Parameters:
columnFamilyHandle- is a pointer to the column family handle to be deleted which will become a dangling pointer after the deletion.
-
onExternalFileIngested
public void onExternalFileIngested(RocksDB db, ExternalFileIngestionInfo externalFileIngestionInfo)
Description copied from interface:EventListenerA callback function for RocksDB which will be called after an external file is ingested using IngestExternalFile. Note that the this function will run on the same thread as IngestExternalFile(), if this function is blocked, IngestExternalFile() will be blocked from finishing.- Specified by:
onExternalFileIngestedin interfaceEventListener- Parameters:
db- the databaseexternalFileIngestionInfo- the external file ingestion info, contains data copied from respective native structure.
-
onBackgroundError
public void onBackgroundError(BackgroundErrorReason backgroundErrorReason, Status backgroundError)
Description copied from interface:EventListenerA callback function for RocksDB which will be called before setting the background error status to a non-OK value. The new background error status is provided in `bg_error` and can be modified by the callback. E.g., a callback can suppress errors by resetting it to Status::OK(), thus preventing the database from entering read-only mode. We do not provide any guarantee when failed flushes/compactions will be rescheduled if the user suppresses an error. Note that this function can run on the same threads as flush, compaction, and user writes. So, it is extremely important not to perform heavy computations or blocking calls in this function.- Specified by:
onBackgroundErrorin interfaceEventListener- Parameters:
backgroundErrorReason- background error reason codebackgroundError- background error codes
-
onStallConditionsChanged
public void onStallConditionsChanged(WriteStallInfo writeStallInfo)
Description copied from interface:EventListenerA callback function for RocksDB which will be called whenever a change of superversion triggers a change of the stall conditions. Note that the this function must be implemented in a way such that it should not run for an extended period of time before the function returns. Otherwise, RocksDB may be blocked.- Specified by:
onStallConditionsChangedin interfaceEventListener- Parameters:
writeStallInfo- write stall info, contains data copied from respective native structure.
-
onFileReadFinish
public void onFileReadFinish(FileOperationInfo fileOperationInfo)
Description copied from interface:EventListenerA callback function for RocksDB which will be called whenever a file read operation finishes.- Specified by:
onFileReadFinishin interfaceEventListener- Parameters:
fileOperationInfo- file operation info, contains data copied from respective native structure.
-
onFileWriteFinish
public void onFileWriteFinish(FileOperationInfo fileOperationInfo)
Description copied from interface:EventListenerA callback function for RocksDB which will be called whenever a file write operation finishes.- Specified by:
onFileWriteFinishin interfaceEventListener- Parameters:
fileOperationInfo- file operation info, contains data copied from respective native structure.
-
onFileFlushFinish
public void onFileFlushFinish(FileOperationInfo fileOperationInfo)
Description copied from interface:EventListenerA callback function for RocksDB which will be called whenever a file flush operation finishes.- Specified by:
onFileFlushFinishin interfaceEventListener- Parameters:
fileOperationInfo- file operation info, contains data copied from respective native structure.
-
onFileSyncFinish
public void onFileSyncFinish(FileOperationInfo fileOperationInfo)
Description copied from interface:EventListenerA callback function for RocksDB which will be called whenever a file sync operation finishes.- Specified by:
onFileSyncFinishin interfaceEventListener- Parameters:
fileOperationInfo- file operation info, contains data copied from respective native structure.
-
onFileRangeSyncFinish
public void onFileRangeSyncFinish(FileOperationInfo fileOperationInfo)
Description copied from interface:EventListenerA callback function for RocksDB which will be called whenever a file rangeSync operation finishes.- Specified by:
onFileRangeSyncFinishin interfaceEventListener- Parameters:
fileOperationInfo- file operation info, contains data copied from respective native structure.
-
onFileTruncateFinish
public void onFileTruncateFinish(FileOperationInfo fileOperationInfo)
Description copied from interface:EventListenerA callback function for RocksDB which will be called whenever a file truncate operation finishes.- Specified by:
onFileTruncateFinishin interfaceEventListener- Parameters:
fileOperationInfo- file operation info, contains data copied from respective native structure.
-
onFileCloseFinish
public void onFileCloseFinish(FileOperationInfo fileOperationInfo)
Description copied from interface:EventListenerA callback function for RocksDB which will be called whenever a file close operation finishes.- Specified by:
onFileCloseFinishin interfaceEventListener- Parameters:
fileOperationInfo- file operation info, contains data copied from respective native structure.
-
shouldBeNotifiedOnFileIO
public boolean shouldBeNotifiedOnFileIO()
Description copied from interface:EventListenerIf true, theEventListener.onFileReadFinish(FileOperationInfo)andEventListener.onFileWriteFinish(FileOperationInfo)will be called. If false, then they won't be called. Default: false- Specified by:
shouldBeNotifiedOnFileIOin interfaceEventListener
-
onErrorRecoveryBegin
public boolean onErrorRecoveryBegin(BackgroundErrorReason backgroundErrorReason, Status backgroundError)
Description copied from interface:EventListenerA callback function for RocksDB which will be called just before starting the automatic recovery process for recoverable background errors, such as NoSpace(). The callback can suppress the automatic recovery by setting returning false. The database will then have to be transitioned out of read-only mode by calling RocksDB#resume().- Specified by:
onErrorRecoveryBeginin interfaceEventListener- Parameters:
backgroundErrorReason- background error reason codebackgroundError- background error codes
-
onErrorRecoveryCompleted
public void onErrorRecoveryCompleted(Status oldBackgroundError)
Description copied from interface:EventListenerA callback function for RocksDB which will be called once the database is recovered from read-only mode after an error. When this is called, it means normal writes to the database can be issued and the user can initiate any further recovery actions needed- Specified by:
onErrorRecoveryCompletedin interfaceEventListener- Parameters:
oldBackgroundError- old background error codes
-
initializeNative
protected long initializeNative(long... nativeParameterHandles)
Description copied from class:RocksCallbackObjectConstruct the Native C++ object which will callback to our object methods- Specified by:
initializeNativein classRocksCallbackObject- Parameters:
nativeParameterHandles- An array of native handles for any parameter objects that are needed during construction- Returns:
- The native handle of the C++ object which will callback to us
-
disposeInternal
protected void disposeInternal()
Deletes underlying C++ native callback object pointer- Overrides:
disposeInternalin classRocksCallbackObject
-
-