|
|
@ -12,8 +12,20 @@ |
|
|
|
|
|
|
|
|
|
|
|
namespace rocksdb { |
|
|
|
namespace rocksdb { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// InMemoryStatsHistoryIterator can be used to access stats history that was
|
|
|
|
|
|
|
|
// stored by an in-memory two level std::map(DBImpl::stats_history_). It keeps
|
|
|
|
|
|
|
|
// a copy of the stats snapshot (in stats_map_) that is currently being pointed
|
|
|
|
|
|
|
|
// to, which allows the iterator to access the stats snapshot even when
|
|
|
|
|
|
|
|
// the background garbage collecting thread purges it from the source of truth
|
|
|
|
|
|
|
|
// (`DBImpl::stats_history_`). In that case, the iterator will continue to be
|
|
|
|
|
|
|
|
// valid until a call to `Next()` returns no result and invalidates it. In
|
|
|
|
|
|
|
|
// some extreme cases, the iterator may also return fragmented segments of
|
|
|
|
|
|
|
|
// stats snapshots due to long gaps between `Next()` calls and interleaved
|
|
|
|
|
|
|
|
// garbage collection.
|
|
|
|
class InMemoryStatsHistoryIterator final : public StatsHistoryIterator { |
|
|
|
class InMemoryStatsHistoryIterator final : public StatsHistoryIterator { |
|
|
|
public: |
|
|
|
public: |
|
|
|
|
|
|
|
// Setup InMemoryStatsHistoryIterator to return stats snapshots between
|
|
|
|
|
|
|
|
// microsecond timestamps [start_time, end_time)
|
|
|
|
InMemoryStatsHistoryIterator(uint64_t start_time, uint64_t end_time, |
|
|
|
InMemoryStatsHistoryIterator(uint64_t start_time, uint64_t end_time, |
|
|
|
DBImpl* db_impl) |
|
|
|
DBImpl* db_impl) |
|
|
|
: start_time_(start_time), |
|
|
|
: start_time_(start_time), |
|
|
@ -26,9 +38,16 @@ class InMemoryStatsHistoryIterator final : public StatsHistoryIterator { |
|
|
|
bool Valid() const override; |
|
|
|
bool Valid() const override; |
|
|
|
Status status() const override; |
|
|
|
Status status() const override; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Move to the next stats snapshot currently available
|
|
|
|
|
|
|
|
// This function may invalidate the iterator
|
|
|
|
|
|
|
|
// REQUIRES: Valid()
|
|
|
|
void Next() override; |
|
|
|
void Next() override; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// REQUIRES: Valid()
|
|
|
|
uint64_t GetStatsTime() const override; |
|
|
|
uint64_t GetStatsTime() const override; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// This function is idempotent
|
|
|
|
|
|
|
|
// REQUIRES: Valid()
|
|
|
|
const std::map<std::string, uint64_t>& GetStatsMap() const override; |
|
|
|
const std::map<std::string, uint64_t>& GetStatsMap() const override; |
|
|
|
|
|
|
|
|
|
|
|
private: |
|
|
|
private: |
|
|
|