2013-10-16 21:59:46 +00:00
|
|
|
// Copyright (c) 2013, Facebook, Inc. All rights reserved.
|
|
|
|
// This source code is licensed under the BSD-style license found in the
|
|
|
|
// LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
// of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
//
|
2012-05-30 06:18:16 +00:00
|
|
|
// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file. See the AUTHORS file for names of contributors.
|
|
|
|
|
2013-10-05 05:32:05 +00:00
|
|
|
#pragma once
|
2012-11-03 04:02:40 +00:00
|
|
|
#include <cassert>
|
2012-05-30 06:18:16 +00:00
|
|
|
#include <stdlib.h>
|
2012-11-03 04:02:40 +00:00
|
|
|
#include <vector>
|
2013-05-23 18:34:58 +00:00
|
|
|
#include <memory>
|
2012-11-03 04:02:40 +00:00
|
|
|
|
2013-08-23 15:38:13 +00:00
|
|
|
#include "rocksdb/statistics.h"
|
2013-02-15 19:53:17 +00:00
|
|
|
#include "util/histogram.h"
|
2012-05-30 06:18:16 +00:00
|
|
|
#include "port/port.h"
|
|
|
|
#include "util/mutexlock.h"
|
2013-02-15 19:53:17 +00:00
|
|
|
|
|
|
|
|
2013-10-04 04:49:15 +00:00
|
|
|
namespace rocksdb {
|
2012-05-30 06:18:16 +00:00
|
|
|
|
|
|
|
class DBStatistics: public Statistics {
|
|
|
|
public:
|
2013-02-15 19:53:17 +00:00
|
|
|
DBStatistics() : allTickers_(TICKER_ENUM_MAX),
|
|
|
|
allHistograms_(HISTOGRAM_ENUM_MAX) { }
|
2012-05-30 06:18:16 +00:00
|
|
|
|
2013-02-15 19:53:17 +00:00
|
|
|
virtual ~DBStatistics() {}
|
|
|
|
|
|
|
|
virtual long getTickerCount(Tickers tickerType) {
|
2012-11-11 08:20:40 +00:00
|
|
|
assert(tickerType < TICKER_ENUM_MAX);
|
2012-11-03 04:02:40 +00:00
|
|
|
return allTickers_[tickerType].getCount();
|
|
|
|
}
|
|
|
|
|
2013-08-16 05:06:26 +00:00
|
|
|
virtual void setTickerCount(Tickers tickerType, uint64_t count) {
|
|
|
|
assert(tickerType < TICKER_ENUM_MAX);
|
|
|
|
allTickers_[tickerType].setTickerCount(count);
|
|
|
|
}
|
|
|
|
|
2013-02-15 19:53:17 +00:00
|
|
|
virtual void recordTick(Tickers tickerType, uint64_t count) {
|
2012-11-11 08:20:40 +00:00
|
|
|
assert(tickerType < TICKER_ENUM_MAX);
|
2013-01-16 00:48:22 +00:00
|
|
|
allTickers_[tickerType].recordTick(count);
|
2012-11-03 04:02:40 +00:00
|
|
|
}
|
|
|
|
|
2013-02-15 19:53:17 +00:00
|
|
|
virtual void measureTime(Histograms histogramType, uint64_t value) {
|
|
|
|
assert(histogramType < HISTOGRAM_ENUM_MAX);
|
|
|
|
allHistograms_[histogramType].Add(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void histogramData(Histograms histogramType,
|
|
|
|
HistogramData * const data) {
|
|
|
|
assert(histogramType < HISTOGRAM_ENUM_MAX);
|
|
|
|
allHistograms_[histogramType].Data(data);
|
|
|
|
}
|
|
|
|
|
2012-11-03 04:02:40 +00:00
|
|
|
std::vector<Ticker> allTickers_;
|
2013-02-15 19:53:17 +00:00
|
|
|
std::vector<HistogramImpl> allHistograms_;
|
2012-05-30 06:18:16 +00:00
|
|
|
};
|
2013-05-23 18:34:58 +00:00
|
|
|
|
2013-12-06 06:29:03 +00:00
|
|
|
std::shared_ptr<Statistics> CreateDBStatistics();
|
2013-05-23 18:34:58 +00:00
|
|
|
|
2013-10-04 04:49:15 +00:00
|
|
|
} // namespace rocksdb
|