From baa8a467ec7fd1d32305e488f29a61692386ffd9 Mon Sep 17 00:00:00 2001 From: Smilencer <527646889@qq.com> Date: Mon, 1 Nov 2021 11:20:18 +0800 Subject: [PATCH] feat: add new codes in env to support `READ_SIZE_THROTTLING` (#948) --- include/dsn/dist/replication/replica_envs.h | 1 + src/common/replication_common.cpp | 1 + src/meta/app_env_validator.cpp | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/include/dsn/dist/replication/replica_envs.h b/include/dsn/dist/replication/replica_envs.h index 21446597c4..0ecb8ca7fc 100644 --- a/include/dsn/dist/replication/replica_envs.h +++ b/include/dsn/dist/replication/replica_envs.h @@ -57,6 +57,7 @@ class replica_envs static const std::string BUSINESS_INFO; static const std::string REPLICA_ACCESS_CONTROLLER_ALLOWED_USERS; static const std::string READ_QPS_THROTTLING; + static const std::string READ_SIZE_THROTTLING; static const std::string BACKUP_REQUEST_QPS_THROTTLING; static const std::string SPLIT_VALIDATE_PARTITION_HASH; static const std::string USER_SPECIFIED_COMPACTION; diff --git a/src/common/replication_common.cpp b/src/common/replication_common.cpp index 8f9989f1fd..012e6690d1 100644 --- a/src/common/replication_common.cpp +++ b/src/common/replication_common.cpp @@ -656,6 +656,7 @@ const std::string replica_envs::BUSINESS_INFO("business.info"); const std::string replica_envs::REPLICA_ACCESS_CONTROLLER_ALLOWED_USERS( "replica_access_controller.allowed_users"); const std::string replica_envs::READ_QPS_THROTTLING("replica.read_throttling"); +const std::string replica_envs::READ_SIZE_THROTTLING("replica.read_throttling_by_size"); const std::string replica_envs::SPLIT_VALIDATE_PARTITION_HASH("replica.split.validate_partition_hash"); const std::string replica_envs::USER_SPECIFIED_COMPACTION("user_specified_compaction"); diff --git a/src/meta/app_env_validator.cpp b/src/meta/app_env_validator.cpp index c9bf3dbbc8..8ba1835b73 100644 --- a/src/meta/app_env_validator.cpp +++ b/src/meta/app_env_validator.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include "app_env_validator.h" namespace dsn { @@ -185,6 +186,10 @@ void app_env_validator::register_all_validators() {replica_envs::REPLICA_ACCESS_CONTROLLER_ALLOWED_USERS, nullptr}, {replica_envs::READ_QPS_THROTTLING, std::bind(&check_throttling, std::placeholders::_1, std::placeholders::_2)}, + {replica_envs::READ_SIZE_THROTTLING, + std::bind(&utils::token_bucket_throttling_controller::validate, + std::placeholders::_1, + std::placeholders::_2)}, {replica_envs::SPLIT_VALIDATE_PARTITION_HASH, std::bind(&check_split_validation, std::placeholders::_1, std::placeholders::_2)}, {replica_envs::USER_SPECIFIED_COMPACTION, nullptr},