diff --git a/include/dsn/env/replica_envs.h b/include/dsn/env/replica_envs.h new file mode 100644 index 0000000000..464427ec45 --- /dev/null +++ b/include/dsn/env/replica_envs.h @@ -0,0 +1,59 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2015 Microsoft Corporation + * + * -=- Robust Distributed System Nucleus (rDSN) -=- + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#pragma once + +#include +#include + +namespace dsn { +namespace replication { + +class replica_envs +{ +public: + static const std::string DENY_CLIENT_WRITE; + static const std::string WRITE_QPS_THROTTLING; + static const std::string WRITE_SIZE_THROTTLING; + static const uint64_t MIN_SLOW_QUERY_THRESHOLD_MS; + static const std::string SLOW_QUERY_THRESHOLD; + static const std::string TABLE_LEVEL_DEFAULT_TTL; + static const std::string ROCKSDB_USAGE_SCENARIO; + static const std::string ROCKSDB_CHECKPOINT_RESERVE_MIN_COUNT; + static const std::string ROCKSDB_CHECKPOINT_RESERVE_TIME_SECONDS; + static const std::string MANUAL_COMPACT_DISABLED; + static const std::string MANUAL_COMPACT_MAX_CONCURRENT_RUNNING_COUNT; + static const std::string MANUAL_COMPACT_ONCE_TRIGGER_TIME; + static const std::string MANUAL_COMPACT_ONCE_TARGET_LEVEL; + static const std::string MANUAL_COMPACT_ONCE_BOTTOMMOST_LEVEL_COMPACTION; + static const std::string MANUAL_COMPACT_PERIODIC_TRIGGER_TIME; + static const std::string MANUAL_COMPACT_PERIODIC_TARGET_LEVEL; + static const std::string MANUAL_COMPACT_PERIODIC_BOTTOMMOST_LEVEL_COMPACTION; + static const std::string BUSINESS_INFO; +}; + +} // namespace replication +} // namespace dsn diff --git a/src/dist/replication/common/replication_common.cpp b/src/dist/replication/common/replication_common.cpp index 039876db8c..82f670acb3 100644 --- a/src/dist/replication/common/replication_common.cpp +++ b/src/dist/replication/common/replication_common.cpp @@ -27,6 +27,7 @@ #include "replication_common.h" #include #include +#include namespace dsn { namespace replication { diff --git a/src/dist/replication/common/replication_common.h b/src/dist/replication/common/replication_common.h index 692cd79f6e..148a6f149f 100644 --- a/src/dist/replication/common/replication_common.h +++ b/src/dist/replication/common/replication_common.h @@ -149,29 +149,6 @@ class backup_restore_constant static const std::string SKIP_BAD_PARTITION; }; -class replica_envs -{ -public: - static const std::string DENY_CLIENT_WRITE; - static const std::string WRITE_QPS_THROTTLING; - static const std::string WRITE_SIZE_THROTTLING; - static const uint64_t MIN_SLOW_QUERY_THRESHOLD_MS; - static const std::string SLOW_QUERY_THRESHOLD; - static const std::string TABLE_LEVEL_DEFAULT_TTL; - static const std::string ROCKSDB_USAGE_SCENARIO; - static const std::string ROCKSDB_CHECKPOINT_RESERVE_MIN_COUNT; - static const std::string ROCKSDB_CHECKPOINT_RESERVE_TIME_SECONDS; - static const std::string MANUAL_COMPACT_DISABLED; - static const std::string MANUAL_COMPACT_MAX_CONCURRENT_RUNNING_COUNT; - static const std::string MANUAL_COMPACT_ONCE_TRIGGER_TIME; - static const std::string MANUAL_COMPACT_ONCE_TARGET_LEVEL; - static const std::string MANUAL_COMPACT_ONCE_BOTTOMMOST_LEVEL_COMPACTION; - static const std::string MANUAL_COMPACT_PERIODIC_TRIGGER_TIME; - static const std::string MANUAL_COMPACT_PERIODIC_TARGET_LEVEL; - static const std::string MANUAL_COMPACT_PERIODIC_BOTTOMMOST_LEVEL_COMPACTION; - static const std::string BUSINESS_INFO; -}; - namespace cold_backup { // // Attention: when compose the path on block service, we use appname_appid, because appname_appid diff --git a/src/dist/replication/lib/replica_config.cpp b/src/dist/replication/lib/replica_config.cpp index df1381daed..d89fbfe67d 100644 --- a/src/dist/replication/lib/replica_config.cpp +++ b/src/dist/replication/lib/replica_config.cpp @@ -41,6 +41,7 @@ #include #include #include +#include namespace dsn { namespace replication { diff --git a/src/dist/replication/lib/replica_throttle.cpp b/src/dist/replication/lib/replica_throttle.cpp index 0ba6dc84e6..6352a99e93 100644 --- a/src/dist/replication/lib/replica_throttle.cpp +++ b/src/dist/replication/lib/replica_throttle.cpp @@ -9,6 +9,7 @@ #include #include +#include namespace dsn { namespace replication { diff --git a/src/dist/replication/meta_server/app_env_validator.cpp b/src/dist/replication/meta_server/app_env_validator.cpp index baed94a176..6435011fe5 100644 --- a/src/dist/replication/meta_server/app_env_validator.cpp +++ b/src/dist/replication/meta_server/app_env_validator.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include "app_env_validator.h" namespace dsn { @@ -59,7 +60,7 @@ bool check_write_throttling(const std::string &env_value, std::string &hint_mess // example for sarg: 100K*delay*100 / 100M*reject*100 for (std::string &sarg : sargs) { std::vector sub_sargs; - utils::split_args(sarg.c_str(), sub_sargs, '*'); + utils::split_args(sarg.c_str(), sub_sargs, '*', true); if (sub_sargs.size() != 3) { hint_message = fmt::format("The field count of {} should be 3", sarg); return false; diff --git a/src/dist/replication/test/meta_test/unit_test/meta_app_envs_test.cpp b/src/dist/replication/test/meta_test/unit_test/meta_app_envs_test.cpp index ed6cb4fd81..dd53044053 100644 --- a/src/dist/replication/test/meta_test/unit_test/meta_app_envs_test.cpp +++ b/src/dist/replication/test/meta_test/unit_test/meta_app_envs_test.cpp @@ -24,6 +24,7 @@ * THE SOFTWARE. */ +#include #include "meta_test_base.h" namespace dsn { @@ -87,6 +88,16 @@ TEST_F(meta_app_envs_test, update_app_envs_test) ERR_INVALID_PARAMETERS, "-100 should be non-negative int", "20M*delay*100"}, + {replica_envs::WRITE_QPS_THROTTLING, + "2K**delay*100", + ERR_INVALID_PARAMETERS, + "The field count of 2K**delay*100 should be 3", + "20M*delay*100"}, + {replica_envs::WRITE_QPS_THROTTLING, + "2K*delay**100", + ERR_INVALID_PARAMETERS, + "The field count of 2K*delay**100 should be 3", + "20M*delay*100"}, {replica_envs::WRITE_QPS_THROTTLING, "20M*reject*100", ERR_OK, "", "20M*reject*100"}, {replica_envs::WRITE_SIZE_THROTTLING, "300*delay*100", ERR_OK, "", "300*delay*100"}, {replica_envs::SLOW_QUERY_THRESHOLD, "30", ERR_OK, "", "30"},