@ -230,12 +230,12 @@ struct ExternalFileIngestionInfo {
TableProperties table_properties ;
TableProperties table_properties ;
} ;
} ;
// EventListener class contains a set of call- back functions that will
// EventListener class contains a set of callback functions that will
// be called when specific RocksDB event happens such as flush. It can
// be called when specific RocksDB event happens such as flush. It can
// be used as a building block for developing custom features such as
// be used as a building block for developing custom features such as
// stats-collector or external compaction algorithm.
// stats-collector or external compaction algorithm.
//
//
// Note that call- back functions should not run for an extended period of
// Note that callback functions should not run for an extended period of
// time before the function returns, otherwise RocksDB may be blocked.
// time before the function returns, otherwise RocksDB may be blocked.
// For example, it is not suggested to do DB::CompactFiles() (as it may
// For example, it is not suggested to do DB::CompactFiles() (as it may
// run for a long while) or issue many of DB::Put() (as Put may be blocked
// run for a long while) or issue many of DB::Put() (as Put may be blocked
@ -251,17 +251,10 @@ struct ExternalFileIngestionInfo {
// [Locking] All EventListener callbacks are designed to be called without
// [Locking] All EventListener callbacks are designed to be called without
// the current thread holding any DB mutex. This is to prevent potential
// the current thread holding any DB mutex. This is to prevent potential
// deadlock and performance issue when using EventListener callback
// deadlock and performance issue when using EventListener callback
// in a complex way. However, all EventListener call-back functions
// in a complex way.
// should not run for an extended period of time before the function
// returns, otherwise RocksDB may be blocked. For example, it is not
// suggested to do DB::CompactFiles() (as it may run for a long while)
// or issue many of DB::Put() (as Put may be blocked in certain cases)
// in the same thread in the EventListener callback. However, doing
// DB::CompactFiles() and DB::Put() in a thread other than the
// EventListener callback thread is considered safe.
class EventListener {
class EventListener {
public :
public :
// A call- back function to RocksDB which will be called whenever a
// A callback function to RocksDB which will be called whenever a
// registered RocksDB flushes a file. The default implementation is
// registered RocksDB flushes a file. The default implementation is
// no-op.
// no-op.
//
//
@ -271,7 +264,7 @@ class EventListener {
virtual void OnFlushCompleted ( DB * /*db*/ ,
virtual void OnFlushCompleted ( DB * /*db*/ ,
const FlushJobInfo & /*flush_job_info*/ ) { }
const FlushJobInfo & /*flush_job_info*/ ) { }
// A call- back function to RocksDB which will be called before a
// A callback function to RocksDB which will be called before a
// RocksDB starts to flush memtables. The default implementation is
// RocksDB starts to flush memtables. The default implementation is
// no-op.
// no-op.
//
//
@ -281,9 +274,9 @@ class EventListener {
virtual void OnFlushBegin ( DB * /*db*/ ,
virtual void OnFlushBegin ( DB * /*db*/ ,
const FlushJobInfo & /*flush_job_info*/ ) { }
const FlushJobInfo & /*flush_job_info*/ ) { }
// A call- back function for RocksDB which will be called whenever
// A callback function for RocksDB which will be called whenever
// a SST file is deleted. Different from OnCompactionCompleted and
// a SST file is deleted. Different from OnCompactionCompleted and
// OnFlushCompleted, this call- back is designed for external logging
// OnFlushCompleted, this callback is designed for external logging
// service and thus only provide string parameters instead
// service and thus only provide string parameters instead
// of a pointer to DB. Applications that build logic basic based
// of a pointer to DB. Applications that build logic basic based
// on file creations and deletions is suggested to implement
// on file creations and deletions is suggested to implement
@ -294,7 +287,7 @@ class EventListener {
// returned value.
// returned value.
virtual void OnTableFileDeleted ( const TableFileDeletionInfo & /*info*/ ) { }
virtual void OnTableFileDeleted ( const TableFileDeletionInfo & /*info*/ ) { }
// A call- back function for RocksDB which will be called whenever
// A callback function for RocksDB which will be called whenever
// a registered RocksDB compacts a file. The default implementation
// a registered RocksDB compacts a file. The default implementation
// is a no-op.
// is a no-op.
//
//
@ -310,9 +303,9 @@ class EventListener {
virtual void OnCompactionCompleted ( DB * /*db*/ ,
virtual void OnCompactionCompleted ( DB * /*db*/ ,
const CompactionJobInfo & /*ci*/ ) { }
const CompactionJobInfo & /*ci*/ ) { }
// A call- back function for RocksDB which will be called whenever
// A callback function for RocksDB which will be called whenever
// a SST file is created. Different from OnCompactionCompleted and
// a SST file is created. Different from OnCompactionCompleted and
// OnFlushCompleted, this call- back is designed for external logging
// OnFlushCompleted, this callback is designed for external logging
// service and thus only provide string parameters instead
// service and thus only provide string parameters instead
// of a pointer to DB. Applications that build logic basic based
// of a pointer to DB. Applications that build logic basic based
// on file creations and deletions is suggested to implement
// on file creations and deletions is suggested to implement
@ -327,7 +320,7 @@ class EventListener {
// returned value.
// returned value.
virtual void OnTableFileCreated ( const TableFileCreationInfo & /*info*/ ) { }
virtual void OnTableFileCreated ( const TableFileCreationInfo & /*info*/ ) { }
// A call- back function for RocksDB which will be called before
// A callback function for RocksDB which will be called before
// a SST file is being created. It will follow by OnTableFileCreated after
// a SST file is being created. It will follow by OnTableFileCreated after
// the creation finishes.
// the creation finishes.
//
//
@ -337,7 +330,7 @@ class EventListener {
virtual void OnTableFileCreationStarted (
virtual void OnTableFileCreationStarted (
const TableFileCreationBriefInfo & /*info*/ ) { }
const TableFileCreationBriefInfo & /*info*/ ) { }
// A call- back function for RocksDB which will be called before
// A callback function for RocksDB which will be called before
// a memtable is made immutable.
// a memtable is made immutable.
//
//
// Note that the this function must be implemented in a way such that
// Note that the this function must be implemented in a way such that
@ -350,7 +343,7 @@ class EventListener {
virtual void OnMemTableSealed (
virtual void OnMemTableSealed (
const MemTableInfo & /*info*/ ) { }
const MemTableInfo & /*info*/ ) { }
// A call- back function for RocksDB which will be called before
// A callback function for RocksDB which will be called before
// a column family handle is deleted.
// a column family handle is deleted.
//
//
// Note that the this function must be implemented in a way such that
// Note that the this function must be implemented in a way such that
@ -361,7 +354,7 @@ class EventListener {
virtual void OnColumnFamilyHandleDeletionStarted (
virtual void OnColumnFamilyHandleDeletionStarted (
ColumnFamilyHandle * /*handle*/ ) { }
ColumnFamilyHandle * /*handle*/ ) { }
// A call- back function for RocksDB which will be called after an external
// A callback function for RocksDB which will be called after an external
// file is ingested using IngestExternalFile.
// file is ingested using IngestExternalFile.
//
//
// Note that the this function will run on the same thread as
// Note that the this function will run on the same thread as
@ -370,7 +363,7 @@ class EventListener {
virtual void OnExternalFileIngested (
virtual void OnExternalFileIngested (
DB * /*db*/ , const ExternalFileIngestionInfo & /*info*/ ) { }
DB * /*db*/ , const ExternalFileIngestionInfo & /*info*/ ) { }
// A call- back function for RocksDB which will be called before setting the
// A callback function for RocksDB which will be called before setting the
// background error status to a non-OK value. The new background error status
// 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
// 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
// callback can suppress errors by resetting it to Status::OK(), thus
@ -384,7 +377,7 @@ class EventListener {
virtual void OnBackgroundError ( BackgroundErrorReason /* reason */ ,
virtual void OnBackgroundError ( BackgroundErrorReason /* reason */ ,
Status * /* bg_error */ ) { }
Status * /* bg_error */ ) { }
// A call- back function for RocksDB which will be called whenever a change
// A callback function for RocksDB which will be called whenever a change
// of superversion triggers a change of the stall conditions.
// of superversion triggers a change of the stall conditions.
//
//
// Note that the this function must be implemented in a way such that
// Note that the this function must be implemented in a way such that