github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/c-deps/libroach/eventlistener.h (about)

     1  // Copyright 2016 The Cockroach Authors.
     2  //
     3  // Use of this software is governed by the Business Source License
     4  // included in the file licenses/BSL.txt.
     5  //
     6  // As of the Change Date specified in that file, in accordance with
     7  // the Business Source License, use of this software will be governed
     8  // by the Apache License, Version 2.0, included in the file
     9  // licenses/APL.txt.
    10  
    11  #pragma once
    12  
    13  #include <atomic>
    14  
    15  #include <rocksdb/db.h>
    16  
    17  // DBEventListener is an implementation of RocksDB's EventListener interface
    18  // used to collect information on RocksDB events that could be of interest
    19  // to CockroachDB users.
    20  class DBEventListener : public rocksdb::EventListener {
    21   public:
    22    DBEventListener();
    23    virtual ~DBEventListener() {}
    24  
    25    uint64_t GetFlushes() const;
    26    uint64_t GetCompactions() const;
    27  
    28    // EventListener methods.
    29    virtual void OnFlushCompleted(rocksdb::DB* db,
    30                                  const rocksdb::FlushJobInfo& flush_job_info) override;
    31    virtual void OnCompactionCompleted(rocksdb::DB* db,
    32                                       const rocksdb::CompactionJobInfo& ci) override;
    33  
    34   private:
    35    std::atomic<uint64_t> flushes_;
    36    std::atomic<uint64_t> compactions_;
    37  };