diff --git a/src/storage/event_listener.cc b/src/storage/event_listener.cc index 8bc204f76b8..a32f8b70300 100644 --- a/src/storage/event_listener.cc +++ b/src/storage/event_listener.cc @@ -75,9 +75,19 @@ bool IsDiskQuotaExceeded(const rocksdb::Status &bg_error) { return err_msg.find(exceeded_quota_str) != std::string::npos; } +void EventListener::OnCompactionBegin(rocksdb::DB *db, const rocksdb::CompactionJobInfo &ci) { + LOG(INFO) << "[event_listener/compaction_begin] column family: " << ci.cf_name << ", job_id: " << ci.job_id + << ", compaction reason: " << rocksdb::GetCompactionReasonString(ci.compaction_reason) + << ", output compression type: " << CompressType2String(ci.compression) + << ", base input level(files): " << ci.base_input_level << "(" << ci.input_files.size() << ")" + << ", output level(files): " << ci.output_level << "(" << ci.output_files.size() << ")" + << ", input bytes: " << ci.stats.total_input_bytes << ", output bytes:" << ci.stats.total_output_bytes + << ", is_manual_compaction:" << (ci.stats.is_manual_compaction ? "yes" : "no"); +} + void EventListener::OnCompactionCompleted(rocksdb::DB *db, const rocksdb::CompactionJobInfo &ci) { LOG(INFO) << "[event_listener/compaction_completed] column family: " << ci.cf_name << ", job_id: " << ci.job_id - << ", compaction reason: " << static_cast(ci.compaction_reason) + << ", compaction reason: " << rocksdb::GetCompactionReasonString(ci.compaction_reason) << ", output compression type: " << CompressType2String(ci.compression) << ", base input level(files): " << ci.base_input_level << "(" << ci.input_files.size() << ")" << ", output level(files): " << ci.output_level << "(" << ci.output_files.size() << ")" @@ -88,9 +98,25 @@ void EventListener::OnCompactionCompleted(rocksdb::DB *db, const rocksdb::Compac storage_->CheckDBSizeLimit(); } +void EventListener::OnSubcompactionBegin(const rocksdb::SubcompactionJobInfo &si) { + LOG(INFO) << "[event_listener/subcompaction_begin] column family: " << si.cf_name << ", job_id: " << si.job_id + << ", compaction reason: " << rocksdb::GetCompactionReasonString(si.compaction_reason) + << ", output compression type: " << CompressType2String(si.compression); +} + +void EventListener::OnSubcompactionCompleted(const rocksdb::SubcompactionJobInfo &si) { + LOG(INFO) << "[event_listener/subcompaction_completed] column family: " << si.cf_name << ", job_id: " << si.job_id + << ", compaction reason: " << rocksdb::GetCompactionReasonString(si.compaction_reason) + << ", output compression type: " << CompressType2String(si.compression) + << ", base input level(files): " << si.base_input_level << ", output level(files): " << si.output_level + << ", input bytes: " << si.stats.total_input_bytes << ", output bytes:" << si.stats.total_output_bytes + << ", is_manual_compaction:" << (si.stats.is_manual_compaction ? "yes" : "no") + << ", elapsed(micro): " << si.stats.elapsed_micros; +} + void EventListener::OnFlushBegin(rocksdb::DB *db, const rocksdb::FlushJobInfo &fi) { LOG(INFO) << "[event_listener/flush_begin] column family: " << fi.cf_name << ", thread_id: " << fi.thread_id - << ", job_id: " << fi.job_id << ", reason: " << static_cast(fi.flush_reason); + << ", job_id: " << fi.job_id << ", reason: " << rocksdb::GetFlushReasonString(fi.flush_reason); } void EventListener::OnFlushCompleted(rocksdb::DB *db, const rocksdb::FlushJobInfo &fi) { diff --git a/src/storage/event_listener.h b/src/storage/event_listener.h index 4cd1606f3d1..3e978c23841 100644 --- a/src/storage/event_listener.h +++ b/src/storage/event_listener.h @@ -31,7 +31,11 @@ class EventListener : public rocksdb::EventListener { ~EventListener() override = default; void OnFlushBegin(rocksdb::DB *db, const rocksdb::FlushJobInfo &fi) override; void OnFlushCompleted(rocksdb::DB *db, const rocksdb::FlushJobInfo &fi) override; + void OnCompactionBegin(rocksdb::DB *db, const rocksdb::CompactionJobInfo &ci) override; void OnCompactionCompleted(rocksdb::DB *db, const rocksdb::CompactionJobInfo &ci) override; + void OnSubcompactionBegin(const rocksdb::SubcompactionJobInfo &si) override; + void OnSubcompactionCompleted(const rocksdb::SubcompactionJobInfo &si) override; + void OnBackgroundError(rocksdb::BackgroundErrorReason reason, rocksdb::Status *status) override; void OnTableFileDeleted(const rocksdb::TableFileDeletionInfo &info) override; void OnStallConditionsChanged(const rocksdb::WriteStallInfo &info) override;