Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaoliwei committed Jan 21, 2020
1 parent e334e57 commit b4c95d1
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 24 deletions.
59 changes: 59 additions & 0 deletions include/dsn/env/replica_envs.h
Original file line number Diff line number Diff line change
@@ -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 <cstdint>
#include <string>

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
1 change: 1 addition & 0 deletions src/dist/replication/common/replication_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "replication_common.h"
#include <dsn/utility/filesystem.h>
#include <fstream>
#include <dsn/env/replica_envs.h>

namespace dsn {
namespace replication {
Expand Down
23 changes: 0 additions & 23 deletions src/dist/replication/common/replication_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/dist/replication/lib/replica_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include <dsn/dist/fmt_logging.h>
#include <dsn/dist/replication/replication_app_base.h>
#include <dsn/utility/string_conv.h>
#include <dsn/env/replica_envs.h>

namespace dsn {
namespace replication {
Expand Down
1 change: 1 addition & 0 deletions src/dist/replication/lib/replica_throttle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include <dsn/dist/replication/replication_app_base.h>
#include <dsn/dist/fmt_logging.h>
#include <dsn/env/replica_envs.h>

namespace dsn {
namespace replication {
Expand Down
3 changes: 2 additions & 1 deletion src/dist/replication/meta_server/app_env_validator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <fmt/format.h>
#include <dsn/utility/string_conv.h>
#include <dsn/dist/fmt_logging.h>
#include <dsn/env/replica_envs.h>
#include "app_env_validator.h"

namespace dsn {
Expand Down Expand Up @@ -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<std::string> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
* THE SOFTWARE.
*/

#include <dsn/env/replica_envs.h>
#include "meta_test_base.h"

namespace dsn {
Expand Down Expand Up @@ -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"},
Expand Down

0 comments on commit b4c95d1

Please sign in to comment.