Skip to content

Commit

Permalink
Use human readable string instead of the integer when printing flush/…
Browse files Browse the repository at this point in the history
…compaction reason (apache#1962)

Co-authored-by: Twice <twice@apache.org>
  • Loading branch information
2 people authored and JoverZhang committed Feb 24, 2024
1 parent ab26561 commit d309c54
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
30 changes: 28 additions & 2 deletions src/storage/event_listener.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(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() << ")"
Expand All @@ -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<int>(fi.flush_reason);
<< ", job_id: " << fi.job_id << ", reason: " << rocksdb::GetFlushReasonString(fi.flush_reason);
}

void EventListener::OnFlushCompleted(rocksdb::DB *db, const rocksdb::FlushJobInfo &fi) {
Expand Down
4 changes: 4 additions & 0 deletions src/storage/event_listener.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d309c54

Please sign in to comment.