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

Commit

Permalink
feat: add an env to enable or disable block cache of an app (#865)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhongChaoqiang authored Jul 29, 2021
1 parent 6de2430 commit e3e24f7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/dsn/dist/replication/replica_envs.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class replica_envs
static const std::string ROCKSDB_CHECKPOINT_RESERVE_MIN_COUNT;
static const std::string ROCKSDB_CHECKPOINT_RESERVE_TIME_SECONDS;
static const std::string ROCKSDB_ITERATION_THRESHOLD_TIME_MS;
static const std::string ROCKSDB_BLOCK_CACHE_ENABLED;
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;
Expand Down
1 change: 1 addition & 0 deletions src/common/replication_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,7 @@ const std::string replica_envs::ROCKSDB_CHECKPOINT_RESERVE_TIME_SECONDS(
"rocksdb.checkpoint.reserve_time_seconds");
const std::string replica_envs::ROCKSDB_ITERATION_THRESHOLD_TIME_MS(
"replica.rocksdb_iteration_threshold_time_ms");
const std::string replica_envs::ROCKSDB_BLOCK_CACHE_ENABLED("replica.rocksdb_block_cache_enabled");
const std::string replica_envs::BUSINESS_INFO("business.info");
const std::string replica_envs::REPLICA_ACCESS_CONTROLLER_ALLOWED_USERS(
"replica_access_controller.allowed_users");
Expand Down
13 changes: 13 additions & 0 deletions src/meta/app_env_validator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,16 @@ bool check_split_validation(const std::string &env_value, std::string &hint_mess
return true;
}

bool check_rocksdb_block_cache_enabled(const std::string &env_value, std::string &hint_message)
{
bool result = false;
if (!dsn::buf2bool(env_value, result)) {
hint_message = fmt::format("invalid string {}, should be \"true\" or \"false\"", env_value);
return false;
}
return true;
}

bool app_env_validator::validate_app_env(const std::string &env_name,
const std::string &env_value,
std::string &hint_message)
Expand Down Expand Up @@ -154,6 +164,9 @@ void app_env_validator::register_all_validators()
std::bind(&check_throttling, std::placeholders::_1, std::placeholders::_2)},
{replica_envs::ROCKSDB_ITERATION_THRESHOLD_TIME_MS,
std::bind(&check_rocksdb_iteration, std::placeholders::_1, std::placeholders::_2)},
{replica_envs::ROCKSDB_BLOCK_CACHE_ENABLED,
std::bind(
&check_rocksdb_block_cache_enabled, std::placeholders::_1, std::placeholders::_2)},
// TODO(zhaoliwei): not implemented
{replica_envs::BUSINESS_INFO, nullptr},
{replica_envs::DENY_CLIENT_WRITE, nullptr},
Expand Down

0 comments on commit e3e24f7

Please sign in to comment.