You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pegasus.apache.org by wa...@apache.org on 2023/06/21 04:24:19 UTC
[incubator-pegasus] 06/38: feat(new_metrics): migrate replica-level metrics for replica class (#1397)
This is an automated email from the ASF dual-hosted git repository.
wangdan pushed a commit to branch migrate-metrics-dev
in repository https://gitbox.apache.org/repos/asf/incubator-pegasus.git
commit 3ec8c2cf807bef7b323b13a4853fe5d12bd9a520
Author: Dan Wang <wa...@apache.org>
AuthorDate: Wed Mar 22 12:32:24 2023 +0800
feat(new_metrics): migrate replica-level metrics for replica class (#1397)
https://github.com/apache/incubator-pegasus/issues/1342
Migrate replica-level metrics in `replica` class to new framework, including the size of
private log, the number of backup requests, the number of read/write/backup requests
that are delayed/rejected due to throttling, the number of read/write requests that are
rejected due to splitting, the number of write requests that are rejected due to bulk load
ingestion, the number of non-idempotent write requests that are rejected due to duplication.
Note that the old metrics for the number of backup requests, the number of delayed/rejected
backup requests due to throttling and the number of rejected non-idempotent write requests
are table-level, which have been changed to replica-level in new metrics, since they could
be aggregated to table-level if necessary.
---
src/perf_counter/test/perf_counter_test.cpp | 1 +
src/replica/replica.cpp | 133 ++++++++++++++++-----------
src/replica/replica.h | 38 ++++----
src/replica/replica_2pc.cpp | 7 +-
src/replica/replica_base.cpp | 2 +
src/replica/replica_base.h | 3 +
src/replica/replica_chkpt.cpp | 8 +-
src/replica/replica_throttle.cpp | 11 +--
src/replica/test/mutation_log_test.cpp | 1 +
src/replica/test/replica_test.cpp | 13 +--
src/server/capacity_unit_calculator.cpp | 7 +-
src/server/capacity_unit_calculator.h | 3 +-
src/server/pegasus_server_impl.cpp | 1 +
src/server/pegasus_server_impl.h | 5 +-
src/server/pegasus_server_impl_init.cpp | 9 +-
src/server/pegasus_server_write.cpp | 2 +
src/server/pegasus_server_write.h | 1 +
src/server/pegasus_write_service.cpp | 11 ++-
src/server/pegasus_write_service.h | 3 +-
src/server/rocksdb_wrapper.cpp | 3 +-
src/server/rocksdb_wrapper.h | 5 +-
src/server/test/pegasus_server_impl_test.cpp | 4 +-
src/utils/clock.cpp | 1 +
23 files changed, 154 insertions(+), 118 deletions(-)
diff --git a/src/perf_counter/test/perf_counter_test.cpp b/src/perf_counter/test/perf_counter_test.cpp
index f83679bd4..0758ef807 100644
--- a/src/perf_counter/test/perf_counter_test.cpp
+++ b/src/perf_counter/test/perf_counter_test.cpp
@@ -38,6 +38,7 @@
// IWYU pragma: no_include <gtest/gtest-test-part.h>
#include <gtest/gtest.h>
#include <stdlib.h>
+#include <algorithm>
#include <chrono>
#include <functional>
#include <memory>
diff --git a/src/replica/replica.cpp b/src/replica/replica.cpp
index be2a0177b..ebbdf05e5 100644
--- a/src/replica/replica.cpp
+++ b/src/replica/replica.cpp
@@ -48,6 +48,7 @@
#include "mutation.h"
#include "mutation_log.h"
#include "perf_counter/perf_counter.h"
+#include "perf_counter/perf_counter_wrapper.h"
#include "perf_counter/perf_counters.h"
#include "replica/prepare_list.h"
#include "replica/replica_context.h"
@@ -67,6 +68,66 @@
#include "utils/rand.h"
#include "utils/string_view.h"
+METRIC_DEFINE_gauge_int64(replica,
+ private_log_size_mb,
+ dsn::metric_unit::kMegaBytes,
+ "The size of private log in MB");
+
+METRIC_DEFINE_counter(replica,
+ throttling_delayed_write_requests,
+ dsn::metric_unit::kRequests,
+ "The number of delayed write requests by throttling");
+
+METRIC_DEFINE_counter(replica,
+ throttling_rejected_write_requests,
+ dsn::metric_unit::kRequests,
+ "The number of rejected write requests by throttling");
+
+METRIC_DEFINE_counter(replica,
+ throttling_delayed_read_requests,
+ dsn::metric_unit::kRequests,
+ "The number of delayed read requests by throttling");
+
+METRIC_DEFINE_counter(replica,
+ throttling_rejected_read_requests,
+ dsn::metric_unit::kRequests,
+ "The number of rejected read requests by throttling");
+
+METRIC_DEFINE_counter(replica,
+ backup_requests,
+ dsn::metric_unit::kRequests,
+ "The number of backup requests");
+
+METRIC_DEFINE_counter(replica,
+ throttling_delayed_backup_requests,
+ dsn::metric_unit::kRequests,
+ "The number of delayed backup requests by throttling");
+
+METRIC_DEFINE_counter(replica,
+ throttling_rejected_backup_requests,
+ dsn::metric_unit::kRequests,
+ "The number of rejected backup requests by throttling");
+
+METRIC_DEFINE_counter(replica,
+ splitting_rejected_write_requests,
+ dsn::metric_unit::kRequests,
+ "The number of rejected write requests by splitting");
+
+METRIC_DEFINE_counter(replica,
+ splitting_rejected_read_requests,
+ dsn::metric_unit::kRequests,
+ "The number of rejected read requests by splitting");
+
+METRIC_DEFINE_counter(replica,
+ bulk_load_ingestion_rejected_write_requests,
+ dsn::metric_unit::kRequests,
+ "The number of rejected write requests by bulk load ingestion");
+
+METRIC_DEFINE_counter(replica,
+ dup_rejected_non_idempotent_write_requests,
+ dsn::metric_unit::kRequests,
+ "The number of rejected non-idempotent write requests by duplication");
+
namespace dsn {
namespace replication {
@@ -119,7 +180,19 @@ replica::replica(replica_stub *stub,
// todo(jiashuo1): app.duplicating need rename
_is_duplication_master(app.duplicating),
_is_duplication_follower(is_duplication_follower),
- _backup_mgr(new replica_backup_manager(this))
+ _backup_mgr(new replica_backup_manager(this)),
+ METRIC_VAR_INIT_replica(private_log_size_mb),
+ METRIC_VAR_INIT_replica(throttling_delayed_write_requests),
+ METRIC_VAR_INIT_replica(throttling_rejected_write_requests),
+ METRIC_VAR_INIT_replica(throttling_delayed_read_requests),
+ METRIC_VAR_INIT_replica(throttling_rejected_read_requests),
+ METRIC_VAR_INIT_replica(backup_requests),
+ METRIC_VAR_INIT_replica(throttling_delayed_backup_requests),
+ METRIC_VAR_INIT_replica(throttling_rejected_backup_requests),
+ METRIC_VAR_INIT_replica(splitting_rejected_write_requests),
+ METRIC_VAR_INIT_replica(splitting_rejected_read_requests),
+ METRIC_VAR_INIT_replica(bulk_load_ingestion_rejected_write_requests),
+ METRIC_VAR_INIT_replica(dup_rejected_non_idempotent_write_requests)
{
CHECK(!_app_info.app_type.empty(), "");
CHECK_NOTNULL(stub, "");
@@ -135,59 +208,9 @@ replica::replica(replica_stub *stub,
_disk_migrator = std::make_unique<replica_disk_migrator>(this);
_replica_follower = std::make_unique<replica_follower>(this);
- std::string counter_str = fmt::format("private.log.size(MB)@{}", gpid);
- _counter_private_log_size.init_app_counter(
- "eon.replica", counter_str.c_str(), COUNTER_TYPE_NUMBER, counter_str.c_str());
-
- counter_str = fmt::format("recent.write.throttling.delay.count@{}", gpid);
- _counter_recent_write_throttling_delay_count.init_app_counter(
- "eon.replica", counter_str.c_str(), COUNTER_TYPE_VOLATILE_NUMBER, counter_str.c_str());
-
- counter_str = fmt::format("recent.write.throttling.reject.count@{}", gpid);
- _counter_recent_write_throttling_reject_count.init_app_counter(
- "eon.replica", counter_str.c_str(), COUNTER_TYPE_VOLATILE_NUMBER, counter_str.c_str());
-
- counter_str = fmt::format("recent.read.throttling.delay.count@{}", gpid);
- _counter_recent_read_throttling_delay_count.init_app_counter(
- "eon.replica", counter_str.c_str(), COUNTER_TYPE_VOLATILE_NUMBER, counter_str.c_str());
-
- counter_str = fmt::format("recent.read.throttling.reject.count@{}", gpid);
- _counter_recent_read_throttling_reject_count.init_app_counter(
- "eon.replica", counter_str.c_str(), COUNTER_TYPE_VOLATILE_NUMBER, counter_str.c_str());
-
- counter_str =
- fmt::format("recent.backup.request.throttling.delay.count@{}", _app_info.app_name);
- _counter_recent_backup_request_throttling_delay_count.init_app_counter(
- "eon.replica", counter_str.c_str(), COUNTER_TYPE_VOLATILE_NUMBER, counter_str.c_str());
-
- counter_str =
- fmt::format("recent.backup.request.throttling.reject.count@{}", _app_info.app_name);
- _counter_recent_backup_request_throttling_reject_count.init_app_counter(
- "eon.replica", counter_str.c_str(), COUNTER_TYPE_VOLATILE_NUMBER, counter_str.c_str());
-
- counter_str = fmt::format("dup.disabled_non_idempotent_write_count@{}", _app_info.app_name);
- _counter_dup_disabled_non_idempotent_write_count.init_app_counter(
- "eon.replica", counter_str.c_str(), COUNTER_TYPE_VOLATILE_NUMBER, counter_str.c_str());
-
- counter_str = fmt::format("recent.read.splitting.reject.count@{}", gpid);
- _counter_recent_read_splitting_reject_count.init_app_counter(
- "eon.replica", counter_str.c_str(), COUNTER_TYPE_VOLATILE_NUMBER, counter_str.c_str());
-
- counter_str = fmt::format("recent.write.splitting.reject.count@{}", gpid);
- _counter_recent_write_splitting_reject_count.init_app_counter(
- "eon.replica", counter_str.c_str(), COUNTER_TYPE_VOLATILE_NUMBER, counter_str.c_str());
-
- counter_str = fmt::format("recent.write.bulk.load.ingestion.reject.count@{}", gpid);
- _counter_recent_write_bulk_load_ingestion_reject_count.init_app_counter(
- "eon.replica", counter_str.c_str(), COUNTER_TYPE_VOLATILE_NUMBER, counter_str.c_str());
-
// init table level latency perf counters
init_table_level_latency_counters();
- counter_str = fmt::format("backup_request_qps@{}", _app_info.app_name);
- _counter_backup_request_qps.init_app_counter(
- "eon.replica", counter_str.c_str(), COUNTER_TYPE_RATE, counter_str.c_str());
-
if (need_restore) {
// add an extra env for restore
_extra_envs.insert(
@@ -263,7 +286,7 @@ void replica::on_client_read(dsn::message_ex *request, bool ignore_throttling)
return;
}
- CHECK_REQUEST_IF_SPLITTING(read)
+ CHECK_REQUEST_IF_SPLITTING(read);
if (status() == partition_status::PS_INACTIVE ||
status() == partition_status::PS_POTENTIAL_SECONDARY) {
@@ -296,7 +319,7 @@ void replica::on_client_read(dsn::message_ex *request, bool ignore_throttling)
if (!ignore_throttling && throttle_backup_request(request)) {
return;
}
- _counter_backup_request_qps->increment();
+ METRIC_VAR_INCREMENT(backup_requests);
}
uint64_t start_time_ns = dsn_now_ns();
@@ -530,8 +553,6 @@ void replica::close()
_disk_migrator.reset();
}
- _counter_private_log_size.clear();
-
// duplication_impl may have ongoing tasks.
// release it before release replica.
_duplication_mgr.reset();
@@ -610,5 +631,7 @@ bool replica::access_controller_allowed(message_ex *msg, const ranger::access_ty
return !_access_controller->is_enable_ranger_acl() || _access_controller->allowed(msg, ac_type);
}
+int64_t replica::get_backup_request_count() const { return METRIC_VAR_VALUE(backup_requests); }
+
} // namespace replication
} // namespace dsn
diff --git a/src/replica/replica.h b/src/replica/replica.h
index 3933784da..62845469c 100644
--- a/src/replica/replica.h
+++ b/src/replica/replica.h
@@ -58,7 +58,6 @@
#include "metadata_types.h"
#include "mutation.h"
#include "mutation_log.h"
-#include "perf_counter/perf_counter_wrapper.h"
#include "prepare_list.h"
#include "replica/backup/cold_backup_context.h"
#include "replica/replica_base.h"
@@ -72,6 +71,7 @@
#include "utils/autoref_ptr.h"
#include "utils/error_code.h"
#include "utils/flags.h"
+#include "utils/metrics.h"
#include "utils/thread_access_checker.h"
#include "utils/throttling_controller.h"
#include "utils/uniq_timestamp_us.h"
@@ -129,10 +129,13 @@ class test_checker;
}
#define CHECK_REQUEST_IF_SPLITTING(op_type) \
- if (_validate_partition_hash) { \
+ do { \
+ if (!_validate_partition_hash) { \
+ break; \
+ } \
if (_split_mgr->should_reject_request()) { \
response_client_##op_type(request, ERR_SPLITTING); \
- _counter_recent_##op_type##_splitting_reject_count->increment(); \
+ METRIC_VAR_INCREMENT(splitting_rejected_##op_type##_requests); \
return; \
} \
if (!_split_mgr->check_partition_hash( \
@@ -140,7 +143,7 @@ class test_checker;
response_client_##op_type(request, ERR_PARENT_PARTITION_MISUSED); \
return; \
} \
- }
+ } while (0)
DSN_DECLARE_bool(reject_write_when_disk_insufficient);
@@ -532,6 +535,9 @@ private:
// use Apache Ranger for replica access control
bool access_controller_allowed(message_ex *msg, const ranger::access_type &ac_type) const;
+ // Currently only used for unit test to get the count of backup requests.
+ int64_t get_backup_request_count() const;
+
private:
friend class ::dsn::replication::test::test_checker;
friend class ::dsn::replication::mutation_queue;
@@ -653,19 +659,19 @@ private:
std::unique_ptr<replica_follower> _replica_follower;
// perf counters
- perf_counter_wrapper _counter_private_log_size;
- perf_counter_wrapper _counter_recent_write_throttling_delay_count;
- perf_counter_wrapper _counter_recent_write_throttling_reject_count;
- perf_counter_wrapper _counter_recent_read_throttling_delay_count;
- perf_counter_wrapper _counter_recent_read_throttling_reject_count;
- perf_counter_wrapper _counter_recent_backup_request_throttling_delay_count;
- perf_counter_wrapper _counter_recent_backup_request_throttling_reject_count;
- perf_counter_wrapper _counter_recent_write_splitting_reject_count;
- perf_counter_wrapper _counter_recent_read_splitting_reject_count;
- perf_counter_wrapper _counter_recent_write_bulk_load_ingestion_reject_count;
+ METRIC_VAR_DECLARE_gauge_int64(private_log_size_mb);
+ METRIC_VAR_DECLARE_counter(throttling_delayed_write_requests);
+ METRIC_VAR_DECLARE_counter(throttling_rejected_write_requests);
+ METRIC_VAR_DECLARE_counter(throttling_delayed_read_requests);
+ METRIC_VAR_DECLARE_counter(throttling_rejected_read_requests);
+ METRIC_VAR_DECLARE_counter(backup_requests);
+ METRIC_VAR_DECLARE_counter(throttling_delayed_backup_requests);
+ METRIC_VAR_DECLARE_counter(throttling_rejected_backup_requests);
+ METRIC_VAR_DECLARE_counter(splitting_rejected_write_requests);
+ METRIC_VAR_DECLARE_counter(splitting_rejected_read_requests);
+ METRIC_VAR_DECLARE_counter(bulk_load_ingestion_rejected_write_requests);
+ METRIC_VAR_DECLARE_counter(dup_rejected_non_idempotent_write_requests);
std::vector<perf_counter *> _counters_table_level_latency;
- perf_counter_wrapper _counter_dup_disabled_non_idempotent_write_count;
- perf_counter_wrapper _counter_backup_request_qps;
dsn::task_tracker _tracker;
// the thread access checker
diff --git a/src/replica/replica_2pc.cpp b/src/replica/replica_2pc.cpp
index e0cff3868..3d07d48aa 100644
--- a/src/replica/replica_2pc.cpp
+++ b/src/replica/replica_2pc.cpp
@@ -75,6 +75,7 @@
#include "utils/flags.h"
#include "utils/fmt_logging.h"
#include "utils/latency_tracer.h"
+#include "utils/metrics.h"
#include "utils/ports.h"
#include "utils/thread_access_checker.h"
#include "utils/uniq_timestamp_us.h"
@@ -167,12 +168,12 @@ void replica::on_client_write(dsn::message_ex *request, bool ignore_throttling)
if (is_duplication_master() && !spec->rpc_request_is_write_idempotent) {
// Ignore non-idempotent write, because duplication provides no guarantee of atomicity to
// make this write produce the same result on multiple clusters.
- _counter_dup_disabled_non_idempotent_write_count->increment();
+ METRIC_VAR_INCREMENT(dup_rejected_non_idempotent_write_requests);
response_client_write(request, ERR_OPERATION_DISABLED);
return;
}
- CHECK_REQUEST_IF_SPLITTING(write)
+ CHECK_REQUEST_IF_SPLITTING(write);
if (partition_status::PS_PRIMARY != status()) {
response_client_write(request, ERR_INVALID_STATE);
@@ -188,7 +189,7 @@ void replica::on_client_write(dsn::message_ex *request, bool ignore_throttling)
if (_is_bulk_load_ingestion) {
if (request->rpc_code() != dsn::apps::RPC_RRDB_RRDB_BULK_LOAD) {
// reject write requests during ingestion
- _counter_recent_write_bulk_load_ingestion_reject_count->increment();
+ METRIC_VAR_INCREMENT(bulk_load_ingestion_rejected_write_requests);
response_client_write(request, ERR_OPERATION_DISABLED);
} else {
response_client_write(request, ERR_NO_NEED_OPERATE);
diff --git a/src/replica/replica_base.cpp b/src/replica/replica_base.cpp
index 11e08ae05..3168ad651 100644
--- a/src/replica/replica_base.cpp
+++ b/src/replica/replica_base.cpp
@@ -18,6 +18,8 @@
#include "replica_base.h"
#include <fmt/core.h>
+#include <fmt/ostream.h>
+#include <iosfwd>
METRIC_DEFINE_entity(replica);
diff --git a/src/replica/replica_base.h b/src/replica/replica_base.h
index 7c5b7747e..ccb39b914 100644
--- a/src/replica/replica_base.h
+++ b/src/replica/replica_base.h
@@ -26,7 +26,10 @@
#pragma once
+#include <string>
+
#include "common/gpid.h"
+#include "utils/fmt_logging.h"
#include "utils/metrics.h"
#include "utils/string_view.h"
diff --git a/src/replica/replica_chkpt.cpp b/src/replica/replica_chkpt.cpp
index b24f11157..5985e5d8d 100644
--- a/src/replica/replica_chkpt.cpp
+++ b/src/replica/replica_chkpt.cpp
@@ -70,6 +70,7 @@
#include "utils/filesystem.h"
#include "utils/flags.h"
#include "utils/fmt_logging.h"
+#include "utils/metrics.h"
#include "utils/thread_access_checker.h"
namespace dsn {
@@ -168,9 +169,10 @@ void replica::on_checkpoint_timer()
valid_start_offset,
(int64_t)FLAGS_log_private_reserve_max_size_mb * 1024 * 1024,
(int64_t)FLAGS_log_private_reserve_max_time_seconds);
- if (status() == partition_status::PS_PRIMARY)
- _counter_private_log_size->set(_private_log->total_size() /
- 1000000);
+ if (status() == partition_status::PS_PRIMARY) {
+ METRIC_VAR_SET(private_log_size_mb,
+ _private_log->total_size() >> 20);
+ }
});
}
}
diff --git a/src/replica/replica_throttle.cpp b/src/replica/replica_throttle.cpp
index 6a1a294b9..ed6bd1cce 100644
--- a/src/replica/replica_throttle.cpp
+++ b/src/replica/replica_throttle.cpp
@@ -25,14 +25,13 @@
#include "common/replica_envs.h"
#include "common/replication.codes.h"
#include "dsn.layer2_types.h"
-#include "perf_counter/perf_counter.h"
-#include "perf_counter/perf_counter_wrapper.h"
#include "replica.h"
#include "runtime/rpc/rpc_message.h"
#include "runtime/task/async_calls.h"
#include "utils/autoref_ptr.h"
#include "utils/error_code.h"
#include "utils/fmt_logging.h"
+#include "utils/metrics.h"
#include "utils/throttling_controller.h"
namespace dsn {
@@ -51,7 +50,7 @@ namespace replication {
[ this, req = message_ptr(request) ]() { on_client_##op_type(req, true); }, \
get_gpid().thread_hash(), \
std::chrono::milliseconds(delay_ms)); \
- _counter_recent_##op_type##_throttling_delay_count->increment(); \
+ METRIC_VAR_INCREMENT(throttling_delayed_##op_type##_requests); \
} else { /** type == throttling_controller::REJECT **/ \
if (delay_ms > 0) { \
tasking::enqueue(LPC_##op_type##_THROTTLING_DELAY, \
@@ -64,7 +63,7 @@ namespace replication {
} else { \
response_client_##op_type(request, ERR_BUSY); \
} \
- _counter_recent_##op_type##_throttling_reject_count->increment(); \
+ METRIC_VAR_INCREMENT(throttling_rejected_##op_type##_requests); \
} \
return true; \
} \
@@ -95,9 +94,9 @@ bool replica::throttle_backup_request(message_ex *request)
[ this, req = message_ptr(request) ]() { on_client_read(req, true); },
get_gpid().thread_hash(),
std::chrono::milliseconds(delay_ms));
- _counter_recent_backup_request_throttling_delay_count->increment();
+ METRIC_VAR_INCREMENT(throttling_delayed_backup_requests);
} else { /** type == throttling_controller::REJECT **/
- _counter_recent_backup_request_throttling_reject_count->increment();
+ METRIC_VAR_INCREMENT(throttling_rejected_backup_requests);
}
return true;
}
diff --git a/src/replica/test/mutation_log_test.cpp b/src/replica/test/mutation_log_test.cpp
index 6bca13336..350f8956e 100644
--- a/src/replica/test/mutation_log_test.cpp
+++ b/src/replica/test/mutation_log_test.cpp
@@ -26,6 +26,7 @@
#include "replica/mutation_log.h"
+#include <fcntl.h>
// IWYU pragma: no_include <gtest/gtest-message.h>
// IWYU pragma: no_include <gtest/gtest-test-part.h>
#include <gtest/gtest.h>
diff --git a/src/replica/test/replica_test.cpp b/src/replica/test/replica_test.cpp
index f1ff0acc9..37020bcb1 100644
--- a/src/replica/test/replica_test.cpp
+++ b/src/replica/test/replica_test.cpp
@@ -104,10 +104,7 @@ public:
return stub->_counter_recent_write_size_exceed_threshold_count->get_value();
}
- int get_table_level_backup_request_qps()
- {
- return _mock_replica->_counter_backup_request_qps->get_integer_value();
- }
+ int64_t get_backup_request_count() const { return _mock_replica->get_backup_request_count(); }
bool get_validate_partition_hash() const { return _mock_replica->_validate_partition_hash; }
@@ -288,7 +285,7 @@ TEST_F(replica_test, write_size_limited)
ASSERT_EQ(get_write_size_exceed_threshold_count(), count);
}
-TEST_F(replica_test, backup_request_qps)
+TEST_F(replica_test, backup_request_count)
{
// create backup request
struct dsn::message_header header;
@@ -300,11 +297,7 @@ TEST_F(replica_test, backup_request_qps)
backup_request->io_session = sim_net->create_client_session(rpc_address());
_mock_replica->on_client_read(backup_request);
-
- // We have to sleep >= 0.1s, or the value this perf-counter will be 0, according to the
- // implementation of perf-counter which type is COUNTER_TYPE_RATE.
- usleep(1e5);
- ASSERT_GT(get_table_level_backup_request_qps(), 0);
+ ASSERT_EQ(get_backup_request_count(), 1);
}
TEST_F(replica_test, query_data_version_test)
diff --git a/src/server/capacity_unit_calculator.cpp b/src/server/capacity_unit_calculator.cpp
index 7a62b3d56..55b9d104c 100644
--- a/src/server/capacity_unit_calculator.cpp
+++ b/src/server/capacity_unit_calculator.cpp
@@ -20,19 +20,18 @@
#include "capacity_unit_calculator.h"
#include <rocksdb/status.h>
-#include <stdio.h>
#include <sys/param.h>
#include <cmath>
-#include <string>
+#include <cstdint>
-#include "common/gpid.h"
#include "hotkey_collector.h"
-#include "perf_counter/perf_counter.h"
#include "rrdb/rrdb_types.h"
#include "runtime/rpc/rpc_message.h"
+#include "utils/autoref_ptr.h"
#include "utils/blob.h"
#include "utils/flags.h"
#include "utils/fmt_logging.h"
+#include "utils/string_view.h"
#include "utils/token_bucket_throttling_controller.h"
METRIC_DEFINE_counter(replica,
diff --git a/src/server/capacity_unit_calculator.h b/src/server/capacity_unit_calculator.h
index 6d30a07ef..d69e3394b 100644
--- a/src/server/capacity_unit_calculator.h
+++ b/src/server/capacity_unit_calculator.h
@@ -23,12 +23,13 @@
#include <memory>
#include <vector>
-#include "perf_counter/perf_counter_wrapper.h"
#include "replica/replica_base.h"
+#include "utils/metrics.h"
namespace dsn {
class blob;
class message_ex;
+
namespace apps {
class full_data;
class key_value;
diff --git a/src/server/pegasus_server_impl.cpp b/src/server/pegasus_server_impl.cpp
index 7d0dad595..c8d3ed601 100644
--- a/src/server/pegasus_server_impl.cpp
+++ b/src/server/pegasus_server_impl.cpp
@@ -57,6 +57,7 @@
#include "pegasus_rpc_types.h"
#include "pegasus_server_write.h"
#include "perf_counter/perf_counter.h"
+#include "perf_counter/perf_counter_wrapper.h"
#include "replica_admin_types.h"
#include "rrdb/rrdb.code.definition.h"
#include "rrdb/rrdb_types.h"
diff --git a/src/server/pegasus_server_impl.h b/src/server/pegasus_server_impl.h
index c107089af..6a7817017 100644
--- a/src/server/pegasus_server_impl.h
+++ b/src/server/pegasus_server_impl.h
@@ -42,13 +42,13 @@
#include "pegasus_scan_context.h"
#include "pegasus_utils.h"
#include "pegasus_value_schema.h"
-#include "perf_counter/perf_counter_wrapper.h"
#include "range_read_limiter.h"
#include "replica/replication_app_base.h"
#include "runtime/task/task.h"
#include "runtime/task/task_tracker.h"
#include "utils/error_code.h"
#include "utils/flags.h"
+#include "utils/metrics.h"
#include "utils/rand.h"
#include "utils/synchronize.h"
@@ -69,6 +69,9 @@ class WriteBufferManager;
namespace dsn {
class blob;
class message_ex;
+class perf_counter_wrapper;
+class rpc_address;
+
namespace replication {
class detect_hotkey_request;
class detect_hotkey_response;
diff --git a/src/server/pegasus_server_impl_init.cpp b/src/server/pegasus_server_impl_init.cpp
index 0840c094b..cd51f0575 100644
--- a/src/server/pegasus_server_impl_init.cpp
+++ b/src/server/pegasus_server_impl_init.cpp
@@ -17,7 +17,6 @@
* under the License.
*/
-#include <fmt/core.h>
#include <rocksdb/cache.h>
#include <rocksdb/filter_policy.h>
#include <rocksdb/options.h>
@@ -29,6 +28,7 @@
#include <cstdint>
#include <memory>
#include <mutex>
+#include <set>
#include <string>
#include <unordered_map>
#include <utility>
@@ -53,6 +53,8 @@
#include "server/range_read_limiter.h"
#include "utils/flags.h"
#include "utils/fmt_logging.h"
+#include "utils/metrics.h"
+#include "utils/string_view.h"
#include "utils/strings.h"
#include "utils/token_bucket_throttling_controller.h"
@@ -117,10 +119,7 @@ METRIC_DEFINE_counter(replica,
dsn::metric_unit::kRequests,
"The number of abnormal read requests");
-METRIC_DEFINE_counter(replica,
- throttling_rejected_read_requests,
- dsn::metric_unit::kRequests,
- "The number of rejected read requests by throttling");
+METRIC_DECLARE_counter(throttling_rejected_read_requests);
METRIC_DEFINE_gauge_int64(replica,
rdb_total_sst_files,
diff --git a/src/server/pegasus_server_write.cpp b/src/server/pegasus_server_write.cpp
index e6cb5331d..9f8db6ca0 100644
--- a/src/server/pegasus_server_write.cpp
+++ b/src/server/pegasus_server_write.cpp
@@ -36,10 +36,12 @@
#include "runtime/rpc/rpc_holder.h"
#include "runtime/rpc/rpc_message.h"
#include "server/pegasus_write_service.h"
+#include "utils/autoref_ptr.h"
#include "utils/blob.h"
#include "utils/flags.h"
#include "utils/fmt_logging.h"
#include "utils/ports.h"
+#include "utils/string_view.h"
METRIC_DEFINE_counter(replica,
corrupt_writes,
diff --git a/src/server/pegasus_server_write.h b/src/server/pegasus_server_write.h
index d8a358164..2329ec586 100644
--- a/src/server/pegasus_server_write.h
+++ b/src/server/pegasus_server_write.h
@@ -30,6 +30,7 @@
#include "replica/replica_base.h"
#include "rrdb/rrdb_types.h"
#include "runtime/task/task_code.h"
+#include "utils/metrics.h"
namespace dsn {
class blob;
diff --git a/src/server/pegasus_write_service.cpp b/src/server/pegasus_write_service.cpp
index 969e7d141..22c0fc1fe 100644
--- a/src/server/pegasus_write_service.cpp
+++ b/src/server/pegasus_write_service.cpp
@@ -20,21 +20,21 @@
#include <fmt/core.h>
#include <fmt/ostream.h>
#include <rocksdb/status.h>
-#include <algorithm>
+#include <stddef.h>
+#include <functional>
#include <iosfwd>
-#include <string>
+#include <set>
+#include <vector>
#include "base/pegasus_rpc_types.h"
#include "bulk_load_types.h"
#include "capacity_unit_calculator.h"
#include "common/duplication_common.h"
-#include "common/gpid.h"
#include "common/replication.codes.h"
#include "duplication_internal_types.h"
#include "pegasus_value_schema.h"
#include "pegasus_write_service.h"
#include "pegasus_write_service_impl.h"
-#include "perf_counter/perf_counter.h"
#include "rrdb/rrdb.code.definition.h"
#include "rrdb/rrdb_types.h"
#include "runtime/api_layer1.h"
@@ -42,10 +42,11 @@
#include "runtime/task/async_calls.h"
#include "runtime/task/task_code.h"
#include "server/pegasus_server_impl.h"
-#include "utils/defer.h"
+#include "utils/autoref_ptr.h"
#include "utils/error_code.h"
#include "utils/flags.h"
#include "utils/fmt_logging.h"
+#include "utils/string_view.h"
namespace dsn {
class blob;
diff --git a/src/server/pegasus_write_service.h b/src/server/pegasus_write_service.h
index 9e79f9122..6c63c42d1 100644
--- a/src/server/pegasus_write_service.h
+++ b/src/server/pegasus_write_service.h
@@ -21,15 +21,16 @@
#include <cstdint>
#include <memory>
-#include <vector>
#include "common//duplication_common.h"
#include "common/common.h"
#include "replica/replica_base.h"
#include "utils/errors.h"
+#include "utils/metrics.h"
namespace dsn {
class blob;
+
namespace apps {
class check_and_mutate_request;
class check_and_mutate_response;
diff --git a/src/server/rocksdb_wrapper.cpp b/src/server/rocksdb_wrapper.cpp
index 08fe8aeca..1465211a4 100644
--- a/src/server/rocksdb_wrapper.cpp
+++ b/src/server/rocksdb_wrapper.cpp
@@ -27,12 +27,11 @@
#include "pegasus_key_schema.h"
#include "pegasus_utils.h"
#include "pegasus_write_service_impl.h"
-#include "perf_counter/perf_counter.h"
-#include "perf_counter/perf_counter_wrapper.h"
#include "server/logging_utils.h"
#include "server/meta_store.h"
#include "server/pegasus_server_impl.h"
#include "server/pegasus_write_service.h"
+#include "utils/autoref_ptr.h"
#include "utils/blob.h"
#include "utils/fail_point.h"
#include "utils/flags.h"
diff --git a/src/server/rocksdb_wrapper.h b/src/server/rocksdb_wrapper.h
index fef30a629..e3eb600db 100644
--- a/src/server/rocksdb_wrapper.h
+++ b/src/server/rocksdb_wrapper.h
@@ -29,6 +29,7 @@
#include "pegasus_value_schema.h"
#include "replica/replica_base.h"
+#include "utils/metrics.h"
#include "utils/string_view.h"
namespace rocksdb {
@@ -36,10 +37,6 @@ class ColumnFamilyHandle;
class DB;
} // namespace rocksdb
-namespace dsn {
-class perf_counter_wrapper;
-} // namespace dsn
-
namespace pegasus {
namespace server {
diff --git a/src/server/test/pegasus_server_impl_test.cpp b/src/server/test/pegasus_server_impl_test.cpp
index 075193fef..880eeb403 100644
--- a/src/server/test/pegasus_server_impl_test.cpp
+++ b/src/server/test/pegasus_server_impl_test.cpp
@@ -33,15 +33,15 @@
#include "pegasus_const.h"
#include "pegasus_server_test_base.h"
-#include "perf_counter/perf_counter.h"
-#include "perf_counter/perf_counter_wrapper.h"
#include "rrdb/rrdb.code.definition.h"
#include "rrdb/rrdb_types.h"
#include "runtime/serverlet.h"
#include "server/pegasus_read_service.h"
+#include "utils/autoref_ptr.h"
#include "utils/blob.h"
#include "utils/error_code.h"
#include "utils/filesystem.h"
+#include "utils/metrics.h"
namespace pegasus {
namespace server {
diff --git a/src/utils/clock.cpp b/src/utils/clock.cpp
index 84764e908..cb1fd400c 100644
--- a/src/utils/clock.cpp
+++ b/src/utils/clock.cpp
@@ -17,6 +17,7 @@
#include "clock.h"
+#include "runtime/api_layer1.h"
#include "time_utils.h"
uint64_t dsn_now_ns() { return dsn::utils::clock::instance()->now_ns(); }
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pegasus.apache.org
For additional commands, e-mail: commits-help@pegasus.apache.org