diff --git a/include/dsn/tool-api/command_manager.h b/include/dsn/tool-api/command_manager.h index 83cb3b8245..7694905456 100644 --- a/include/dsn/tool-api/command_manager.h +++ b/include/dsn/tool-api/command_manager.h @@ -47,10 +47,6 @@ class command_manager : public ::dsn::utils::singleton const std::string &help_long, command_handler handler); - dsn_handle_t register_app_command(const std::vector &commands, - const std::string &help_one_line, - const std::string &help_long, - command_handler handler); void deregister_command(dsn_handle_t handle); bool run_command(const std::string &cmd, diff --git a/include/dsn/tool-api/global_config.h b/include/dsn/tool-api/global_config.h index b6741384d1..ff0975068d 100644 --- a/include/dsn/tool-api/global_config.h +++ b/include/dsn/tool-api/global_config.h @@ -157,7 +157,6 @@ struct service_spec std::string lock_nr_factory_name; std::string rwlock_nr_factory_name; std::string semaphore_factory_name; - std::string nfs_factory_name; std::string logging_factory_name; network_client_configs network_default_client_cfs; // default network configed by tools @@ -193,7 +192,6 @@ CONFIG_FLD_STRING(lock_factory_name, "", "recursive exclusive lock provider") CONFIG_FLD_STRING(lock_nr_factory_name, "", "non-recurisve exclusive lock provider") CONFIG_FLD_STRING(rwlock_nr_factory_name, "", "non-recurisve rwlock provider") CONFIG_FLD_STRING(semaphore_factory_name, "", "semaphore provider") -CONFIG_FLD_STRING(nfs_factory_name, "", "nfs provider") CONFIG_FLD_STRING(logging_factory_name, "", "logging provider") CONFIG_END diff --git a/src/core/core/command_manager.cpp b/src/core/core/command_manager.cpp index 37277cad7f..2975cb5278 100644 --- a/src/core/core/command_manager.cpp +++ b/src/core/core/command_manager.cpp @@ -29,26 +29,10 @@ #include #include -#include #include namespace dsn { -dsn_handle_t command_manager::register_app_command(const std::vector &commands, - const std::string &help_one_line, - const std::string &help_long, - command_handler handler) -{ - std::string app_tag = std::string(service_app::current_service_app_info().full_name) + "."; - std::vector commands_with_app_tag; - commands_with_app_tag.reserve(commands.size()); - for (const std::string &c : commands) { - commands_with_app_tag.push_back(app_tag + c); - } - return register_command( - commands_with_app_tag, app_tag + help_one_line, app_tag + help_long, handler); -} - dsn_handle_t command_manager::register_command(const std::vector &commands, const std::string &help_one_line, const std::string &help_long, diff --git a/src/core/tools/common/nativerun.cpp b/src/core/tools/common/nativerun.cpp index 5359fe8ceb..d6c3bb29da 100644 --- a/src/core/tools/common/nativerun.cpp +++ b/src/core/tools/common/nativerun.cpp @@ -93,9 +93,6 @@ void nativerun::install(service_spec &spec) if (spec.semaphore_factory_name == "") spec.semaphore_factory_name = ("dsn::tools::std_semaphore_provider"); - if (spec.nfs_factory_name == "") - spec.nfs_factory_name = "dsn::service::nfs_node_simple"; - for (auto it = spec.threadpool_specs.begin(); it != spec.threadpool_specs.end(); ++it) { threadpool_spec &tspec = *it; diff --git a/src/core/tools/simulator/simulator.cpp b/src/core/tools/simulator/simulator.cpp index 6a3e295831..06e12f0ef1 100644 --- a/src/core/tools/simulator/simulator.cpp +++ b/src/core/tools/simulator/simulator.cpp @@ -104,9 +104,6 @@ void simulator::install(service_spec &spec) if (spec.semaphore_factory_name == "") spec.semaphore_factory_name = ("dsn::tools::sim_semaphore_provider"); - if (spec.nfs_factory_name == "") - spec.nfs_factory_name = "dsn::service::nfs_node_simple"; - for (auto it = spec.threadpool_specs.begin(); it != spec.threadpool_specs.end(); ++it) { threadpool_spec &tspec = *it; diff --git a/src/dist/failure_detector/failure_detector.cpp b/src/dist/failure_detector/failure_detector.cpp index 105b2c3f0c..0e73afdac6 100644 --- a/src/dist/failure_detector/failure_detector.cpp +++ b/src/dist/failure_detector/failure_detector.cpp @@ -58,11 +58,14 @@ failure_detector::failure_detector() void failure_detector::register_ctrl_commands() { - _get_allow_list = dsn::command_manager::instance().register_app_command( - {"fd.allow_list"}, - "fd.allow_list", - "show allow list of replica", - [this](const std::vector &args) { return get_allow_list(args); }); + static std::once_flag flag; + std::call_once(flag, [&]() { + _get_allow_list = dsn::command_manager::instance().register_command( + {"fd.allow_list"}, + "fd.allow_list", + "show allow list of failure detector", + [this](const std::vector &args) { return get_allow_list(args); }); + }); } void failure_detector::unregister_ctrl_commands() { UNREGISTER_VALID_HANDLER(_get_allow_list); } diff --git a/src/dist/nfs/nfs_client_impl.cpp b/src/dist/nfs/nfs_client_impl.cpp index 7ad1a8ab7c..72ddacfad2 100644 --- a/src/dist/nfs/nfs_client_impl.cpp +++ b/src/dist/nfs/nfs_client_impl.cpp @@ -110,7 +110,6 @@ nfs_client_impl::nfs_client_impl() dassert(max_copy_rate_bytes > FLAGS_nfs_copy_block_bytes, "max_copy_rate_bytes should be greater than nfs_copy_block_bytes"); _copy_token_bucket.reset(new TokenBucket(max_copy_rate_bytes, 1.5 * max_copy_rate_bytes)); - FLAGS_max_copy_rate_megabytes = FLAGS_max_copy_rate_megabytes; register_cli_commands(); } @@ -557,40 +556,44 @@ void nfs_client_impl::handle_completion(const user_request_ptr &req, error_code void nfs_client_impl::register_cli_commands() { - dsn::command_manager::instance().register_app_command( - {"nfs.max_copy_rate_megabytes"}, - "nfs.max_copy_rate_megabytes [num | DEFAULT]", - "control the max rate(MB/s) to copy file from remote node", - [this](const std::vector &args) { - std::string result("OK"); - - if (args.empty()) { - return std::to_string(FLAGS_max_copy_rate_megabytes); - } - if (args[0] == "DEFAULT") { - uint32_t max_copy_rate_bytes = FLAGS_max_copy_rate_megabytes << 20; - _copy_token_bucket->reset(max_copy_rate_bytes, 1.5 * max_copy_rate_bytes); - FLAGS_max_copy_rate_megabytes = FLAGS_max_copy_rate_megabytes; - return result; - } + static std::once_flag flag; + std::call_once(flag, [&]() { + dsn::command_manager::instance().register_command( + {"nfs.max_copy_rate_megabytes"}, + "nfs.max_copy_rate_megabytes [num | DEFAULT]", + "control the max rate(MB/s) to copy file from remote node", + [this](const std::vector &args) { + std::string result("OK"); + + if (args.empty()) { + return std::to_string(FLAGS_max_copy_rate_megabytes); + } - int32_t max_copy_rate_megabytes = 0; - if (!dsn::buf2int32(args[0], max_copy_rate_megabytes) || max_copy_rate_megabytes <= 0) { - return std::string("ERR: invalid arguments"); - } + if (args[0] == "DEFAULT") { + uint32_t max_copy_rate_bytes = FLAGS_max_copy_rate_megabytes << 20; + _copy_token_bucket->reset(max_copy_rate_bytes, 1.5 * max_copy_rate_bytes); + return result; + } + + int32_t max_copy_rate_megabytes = 0; + if (!dsn::buf2int32(args[0], max_copy_rate_megabytes) || + max_copy_rate_megabytes <= 0) { + return std::string("ERR: invalid arguments"); + } - uint32_t max_copy_rate_bytes = max_copy_rate_megabytes << 20; - if (max_copy_rate_bytes <= FLAGS_nfs_copy_block_bytes) { - result = std::string("ERR: max_copy_rate_bytes(max_copy_rate_megabytes << 20) " - "should be greater than nfs_copy_block_bytes:") - .append(std::to_string(FLAGS_nfs_copy_block_bytes)); + uint32_t max_copy_rate_bytes = max_copy_rate_megabytes << 20; + if (max_copy_rate_bytes <= FLAGS_nfs_copy_block_bytes) { + result = std::string("ERR: max_copy_rate_bytes(max_copy_rate_megabytes << 20) " + "should be greater than nfs_copy_block_bytes:") + .append(std::to_string(FLAGS_nfs_copy_block_bytes)); + return result; + } + _copy_token_bucket->reset(max_copy_rate_bytes, 1.5 * max_copy_rate_bytes); + FLAGS_max_copy_rate_megabytes = max_copy_rate_megabytes; return result; - } - _copy_token_bucket->reset(max_copy_rate_bytes, 1.5 * max_copy_rate_bytes); - FLAGS_max_copy_rate_megabytes = max_copy_rate_megabytes; - return result; - }); + }); + }); } } // namespace service } // namespace dsn diff --git a/src/dist/replication/lib/replica_stub.cpp b/src/dist/replication/lib/replica_stub.cpp index 8cb198efb3..b7cd69fafa 100644 --- a/src/dist/replication/lib/replica_stub.cpp +++ b/src/dist/replication/lib/replica_stub.cpp @@ -2082,182 +2082,198 @@ void replica_stub::open_service() register_rpc_handler_with_rpc_holder( RPC_GROUP_BULK_LOAD, "group_bulk_load", &replica_stub::on_group_bulk_load); - _kill_partition_command = ::dsn::command_manager::instance().register_app_command( - {"kill_partition"}, - "kill_partition [app_id [partition_index]]", - "kill_partition: kill partitions by (all, one app, one partition)", - [this](const std::vector &args) { - dsn::gpid pid; - if (args.size() == 0) { - pid.set_app_id(-1); - pid.set_partition_index(-1); - } else if (args.size() == 1) { - pid.set_app_id(atoi(args[0].c_str())); - pid.set_partition_index(-1); - } else if (args.size() == 2) { - pid.set_app_id(atoi(args[0].c_str())); - pid.set_partition_index(atoi(args[1].c_str())); - } else { - return std::string(ERR_INVALID_PARAMETERS.to_string()); - } - dsn::error_code e = this->on_kill_replica(pid); - return std::string(e.to_string()); - }); + register_ctrl_command(); +} - _deny_client_command = ::dsn::command_manager::instance().register_app_command( - {"deny-client"}, - "deny-client ", - "deny-client - control if deny client read & write request", - [this](const std::vector &args) { - return remote_command_set_bool_flag(_deny_client, "deny-client", args); - }); +void replica_stub::register_ctrl_command() +{ + /// In simple_kv test, three replica apps are created, which means that three replica_stubs are + /// initialized in simple_kv test. If we don't use std::call_once, these command are registered + /// for three times. And in command_manager, one same command is not allowed to be registered + /// more than twice times. That is why we use std::call_once here. Same situation in + /// failure_detector::register_ctrl_commands and nfs_client_impl::register_cli_commands + static std::once_flag flag; + std::call_once(flag, [&]() { + _kill_partition_command = ::dsn::command_manager::instance().register_command( + {"replica.kill_partition"}, + "kill_partition [app_id [partition_index]]", + "kill_partition: kill partitions by (all, one app, one partition)", + [this](const std::vector &args) { + dsn::gpid pid; + if (args.size() == 0) { + pid.set_app_id(-1); + pid.set_partition_index(-1); + } else if (args.size() == 1) { + pid.set_app_id(atoi(args[0].c_str())); + pid.set_partition_index(-1); + } else if (args.size() == 2) { + pid.set_app_id(atoi(args[0].c_str())); + pid.set_partition_index(atoi(args[1].c_str())); + } else { + return std::string(ERR_INVALID_PARAMETERS.to_string()); + } + dsn::error_code e = this->on_kill_replica(pid); + return std::string(e.to_string()); + }); - _verbose_client_log_command = ::dsn::command_manager::instance().register_app_command( - {"verbose-client-log"}, - "verbose-client-log ", - "verbose-client-log - control if print verbose error log when reply read & write request", - [this](const std::vector &args) { - return remote_command_set_bool_flag(_verbose_client_log, "verbose-client-log", args); - }); + _deny_client_command = ::dsn::command_manager::instance().register_command( + {"replica.deny-client"}, + "deny-client ", + "deny-client - control if deny client read & write request", + [this](const std::vector &args) { + return remote_command_set_bool_flag(_deny_client, "deny-client", args); + }); - _verbose_commit_log_command = ::dsn::command_manager::instance().register_app_command( - {"verbose-commit-log"}, - "verbose-commit-log ", - "verbose-commit-log - control if print verbose log when commit mutation", - [this](const std::vector &args) { - return remote_command_set_bool_flag(_verbose_commit_log, "verbose-commit-log", args); - }); + _verbose_client_log_command = ::dsn::command_manager::instance().register_command( + {"replica.verbose-client-log"}, + "verbose-client-log ", + "verbose-client-log - control if print verbose error log when reply read & write " + "request", + [this](const std::vector &args) { + return remote_command_set_bool_flag( + _verbose_client_log, "verbose-client-log", args); + }); - _trigger_chkpt_command = ::dsn::command_manager::instance().register_app_command( - {"trigger-checkpoint"}, - "trigger-checkpoint [id1,id2,...] (where id is 'app_id' or 'app_id.partition_id')", - "trigger-checkpoint - trigger replicas to do checkpoint", - [this](const std::vector &args) { - return exec_command_on_replica(args, true, [this](const replica_ptr &rep) { - tasking::enqueue(LPC_PER_REPLICA_CHECKPOINT_TIMER, - rep->tracker(), - std::bind(&replica_stub::trigger_checkpoint, this, rep, true), - rep->get_gpid().thread_hash()); - return std::string("triggered"); + _verbose_commit_log_command = ::dsn::command_manager::instance().register_command( + {"replica.verbose-commit-log"}, + "verbose-commit-log ", + "verbose-commit-log - control if print verbose log when commit mutation", + [this](const std::vector &args) { + return remote_command_set_bool_flag( + _verbose_commit_log, "verbose-commit-log", args); }); - }); - _query_compact_command = ::dsn::command_manager::instance().register_app_command( - {"query-compact"}, - "query-compact [id1,id2,...] (where id is 'app_id' or 'app_id.partition_id')", - "query-compact - query full compact status on the underlying storage engine", - [this](const std::vector &args) { - return exec_command_on_replica( - args, true, [](const replica_ptr &rep) { return rep->query_compact_state(); }); - }); + _trigger_chkpt_command = ::dsn::command_manager::instance().register_command( + {"replica.trigger-checkpoint"}, + "trigger-checkpoint [id1,id2,...] (where id is 'app_id' or 'app_id.partition_id')", + "trigger-checkpoint - trigger replicas to do checkpoint", + [this](const std::vector &args) { + return exec_command_on_replica(args, true, [this](const replica_ptr &rep) { + tasking::enqueue(LPC_PER_REPLICA_CHECKPOINT_TIMER, + rep->tracker(), + std::bind(&replica_stub::trigger_checkpoint, this, rep, true), + rep->get_gpid().thread_hash()); + return std::string("triggered"); + }); + }); - _query_app_envs_command = ::dsn::command_manager::instance().register_app_command( - {"query-app-envs"}, - "query-app-envs [id1,id2,...] (where id is 'app_id' or 'app_id.partition_id')", - "query-app-envs - query app envs on the underlying storage engine", - [this](const std::vector &args) { - return exec_command_on_replica(args, true, [](const replica_ptr &rep) { - std::map kv_map; - rep->query_app_envs(kv_map); - return dsn::utils::kv_map_to_string(kv_map, ',', '='); + _query_compact_command = ::dsn::command_manager::instance().register_command( + {"replica.query-compact"}, + "query-compact [id1,id2,...] (where id is 'app_id' or 'app_id.partition_id')", + "query-compact - query full compact status on the underlying storage engine", + [this](const std::vector &args) { + return exec_command_on_replica( + args, true, [](const replica_ptr &rep) { return rep->query_compact_state(); }); }); - }); - _useless_dir_reserve_seconds_command = dsn::command_manager::instance().register_app_command( - {"useless-dir-reserve-seconds"}, - "useless-dir-reserve-seconds [num | DEFAULT]", - "control gc_disk_error_replica_interval_seconds and " - "gc_disk_garbage_replica_interval_seconds", - [this](const std::vector &args) { - std::string result("OK"); - if (args.empty()) { - result = "error_dir_reserve_seconds=" + - std::to_string(_gc_disk_error_replica_interval_seconds) + - ",garbage_dir_reserve_seconds=" + - std::to_string(_gc_disk_garbage_replica_interval_seconds); - } else { - if (args[0] == "DEFAULT") { - _gc_disk_error_replica_interval_seconds = - _options.gc_disk_error_replica_interval_seconds; - _gc_disk_garbage_replica_interval_seconds = - _options.gc_disk_garbage_replica_interval_seconds; + _query_app_envs_command = ::dsn::command_manager::instance().register_command( + {"replica.query-app-envs"}, + "query-app-envs [id1,id2,...] (where id is 'app_id' or 'app_id.partition_id')", + "query-app-envs - query app envs on the underlying storage engine", + [this](const std::vector &args) { + return exec_command_on_replica(args, true, [](const replica_ptr &rep) { + std::map kv_map; + rep->query_app_envs(kv_map); + return dsn::utils::kv_map_to_string(kv_map, ',', '='); + }); + }); + + _useless_dir_reserve_seconds_command = dsn::command_manager::instance().register_command( + {"replica.useless-dir-reserve-seconds"}, + "useless-dir-reserve-seconds [num | DEFAULT]", + "control gc_disk_error_replica_interval_seconds and " + "gc_disk_garbage_replica_interval_seconds", + [this](const std::vector &args) { + std::string result("OK"); + if (args.empty()) { + result = "error_dir_reserve_seconds=" + + std::to_string(_gc_disk_error_replica_interval_seconds) + + ",garbage_dir_reserve_seconds=" + + std::to_string(_gc_disk_garbage_replica_interval_seconds); } else { - int32_t seconds = 0; - if (!dsn::buf2int32(args[0], seconds) || seconds < 0) { - result = std::string("ERR: invalid arguments"); + if (args[0] == "DEFAULT") { + _gc_disk_error_replica_interval_seconds = + _options.gc_disk_error_replica_interval_seconds; + _gc_disk_garbage_replica_interval_seconds = + _options.gc_disk_garbage_replica_interval_seconds; } else { - _gc_disk_error_replica_interval_seconds = seconds; - _gc_disk_garbage_replica_interval_seconds = seconds; + int32_t seconds = 0; + if (!dsn::buf2int32(args[0], seconds) || seconds < 0) { + result = std::string("ERR: invalid arguments"); + } else { + _gc_disk_error_replica_interval_seconds = seconds; + _gc_disk_garbage_replica_interval_seconds = seconds; + } } } - } - return result; - }); + return result; + }); #ifdef DSN_ENABLE_GPERF - _release_tcmalloc_memory_command = ::dsn::command_manager::instance().register_app_command( - {"release-tcmalloc-memory"}, - "release-tcmalloc-memory ", - "release-tcmalloc-memory - control if try to release tcmalloc memory", - [this](const std::vector &args) { - return remote_command_set_bool_flag( - _release_tcmalloc_memory, "release-tcmalloc-memory", args); - }); + _release_tcmalloc_memory_command = ::dsn::command_manager::instance().register_command( + {"replica.release-tcmalloc-memory"}, + "release-tcmalloc-memory ", + "release-tcmalloc-memory - control if try to release tcmalloc memory", + [this](const std::vector &args) { + return remote_command_set_bool_flag( + _release_tcmalloc_memory, "release-tcmalloc-memory", args); + }); - _max_reserved_memory_percentage_command = dsn::command_manager::instance().register_app_command( - {"mem-release-max-reserved-percentage"}, - "mem-release-max-reserved-percentage [num | DEFAULT]", - "control tcmalloc max reserved but not-used memory percentage", - [this](const std::vector &args) { - std::string result("OK"); - if (args.empty()) { - // show current value - result = "mem-release-max-reserved-percentage = " + - std::to_string(_mem_release_max_reserved_mem_percentage); - return result; - } - if (args[0] == "DEFAULT") { - // set to default value - _mem_release_max_reserved_mem_percentage = - _options.mem_release_max_reserved_mem_percentage; - return result; - } - int32_t percentage = 0; - if (!dsn::buf2int32(args[0], percentage) || percentage <= 0 || percentage > 100) { - result = std::string("ERR: invalid arguments"); - } else { - _mem_release_max_reserved_mem_percentage = percentage; - } - return result; - }); -#endif - _max_concurrent_bulk_load_downloading_count_command = - dsn::command_manager::instance().register_app_command( - {"max-concurrent-bulk-load-downloading-count"}, - "max-concurrent-bulk-load-downloading-count [num | DEFAULT]", - "control stub max_concurrent_bulk_load_downloading_count", + _max_reserved_memory_percentage_command = dsn::command_manager::instance().register_command( + {"replica.mem-release-max-reserved-percentage"}, + "mem-release-max-reserved-percentage [num | DEFAULT]", + "control tcmalloc max reserved but not-used memory percentage", [this](const std::vector &args) { std::string result("OK"); if (args.empty()) { - result = "max_concurrent_bulk_load_downloading_count=" + - std::to_string(_max_concurrent_bulk_load_downloading_count); + // show current value + result = "mem-release-max-reserved-percentage = " + + std::to_string(_mem_release_max_reserved_mem_percentage); return result; } - if (args[0] == "DEFAULT") { - _max_concurrent_bulk_load_downloading_count = - _options.max_concurrent_bulk_load_downloading_count; + // set to default value + _mem_release_max_reserved_mem_percentage = + _options.mem_release_max_reserved_mem_percentage; return result; } - - int32_t count = 0; - if (!dsn::buf2int32(args[0], count) || count <= 0) { + int32_t percentage = 0; + if (!dsn::buf2int32(args[0], percentage) || percentage <= 0 || percentage > 100) { result = std::string("ERR: invalid arguments"); } else { - _max_concurrent_bulk_load_downloading_count = count; + _mem_release_max_reserved_mem_percentage = percentage; } return result; }); +#endif + _max_concurrent_bulk_load_downloading_count_command = + dsn::command_manager::instance().register_command( + {"replica.max-concurrent-bulk-load-downloading-count"}, + "max-concurrent-bulk-load-downloading-count [num | DEFAULT]", + "control stub max_concurrent_bulk_load_downloading_count", + [this](const std::vector &args) { + std::string result("OK"); + if (args.empty()) { + result = "max_concurrent_bulk_load_downloading_count=" + + std::to_string(_max_concurrent_bulk_load_downloading_count); + return result; + } + + if (args[0] == "DEFAULT") { + _max_concurrent_bulk_load_downloading_count = + _options.max_concurrent_bulk_load_downloading_count; + return result; + } + + int32_t count = 0; + if (!dsn::buf2int32(args[0], count) || count <= 0) { + result = std::string("ERR: invalid arguments"); + } else { + _max_concurrent_bulk_load_downloading_count = count; + } + return result; + }); + }); } std::string diff --git a/src/dist/replication/lib/replica_stub.h b/src/dist/replication/lib/replica_stub.h index f7b3eb54df..1746c4b5de 100644 --- a/src/dist/replication/lib/replica_stub.h +++ b/src/dist/replication/lib/replica_stub.h @@ -260,6 +260,8 @@ class replica_stub : public serverlet, public ref_counter error_code error); void update_disk_holding_replicas(); + void register_ctrl_command(); + int get_app_id_from_replicas(std::string app_name) { for (const auto &replica : _replicas) { diff --git a/src/dist/replication/meta_server/greedy_load_balancer.cpp b/src/dist/replication/meta_server/greedy_load_balancer.cpp index 5c83cba440..b769a82d84 100644 --- a/src/dist/replication/meta_server/greedy_load_balancer.cpp +++ b/src/dist/replication/meta_server/greedy_load_balancer.cpp @@ -90,16 +90,16 @@ void greedy_load_balancer::register_ctrl_commands() // register command that belong to simple_load_balancer simple_load_balancer::register_ctrl_commands(); - _ctrl_balancer_in_turn = dsn::command_manager::instance().register_app_command( - {"lb.balancer_in_turn"}, + _ctrl_balancer_in_turn = dsn::command_manager::instance().register_command( + {"meta.lb.balancer_in_turn"}, "lb.balancer_in_turn ", "control whether do app balancer in turn", [this](const std::vector &args) { return remote_command_set_bool_flag(_balancer_in_turn, "lb.balancer_in_turn", args); }); - _ctrl_only_primary_balancer = dsn::command_manager::instance().register_app_command( - {"lb.only_primary_balancer"}, + _ctrl_only_primary_balancer = dsn::command_manager::instance().register_command( + {"meta.lb.only_primary_balancer"}, "lb.only_primary_balancer ", "control whether do only primary balancer", [this](const std::vector &args) { @@ -107,22 +107,22 @@ void greedy_load_balancer::register_ctrl_commands() _only_primary_balancer, "lb.only_primary_balancer", args); }); - _ctrl_only_move_primary = dsn::command_manager::instance().register_app_command( - {"lb.only_move_primary"}, + _ctrl_only_move_primary = dsn::command_manager::instance().register_command( + {"meta.lb.only_move_primary"}, "lb.only_move_primary ", "control whether only move primary in balancer", [this](const std::vector &args) { return remote_command_set_bool_flag(_only_move_primary, "lb.only_move_primary", args); }); - _get_balance_operation_count = dsn::command_manager::instance().register_app_command( - {"lb.get_balance_operation_count"}, + _get_balance_operation_count = dsn::command_manager::instance().register_command( + {"meta.lb.get_balance_operation_count"}, "lb.get_balance_operation_count [total | move_pri | copy_pri | copy_sec | detail]", "get balance operation count", [this](const std::vector &args) { return get_balance_operation_count(args); }); - _ctrl_balancer_ignored_apps = dsn::command_manager::instance().register_app_command( - {"lb.ignored_app_list"}, + _ctrl_balancer_ignored_apps = dsn::command_manager::instance().register_command( + {"meta.lb.ignored_app_list"}, "lb.ignored_app_list [app_id1,app_id2..]", "get, set and clear balancer ignored_app_list", [this](const std::vector &args) { diff --git a/src/dist/replication/meta_server/meta_service.cpp b/src/dist/replication/meta_server/meta_service.cpp index 03bcae35f0..b1c2a994a7 100644 --- a/src/dist/replication/meta_server/meta_service.cpp +++ b/src/dist/replication/meta_server/meta_service.cpp @@ -214,8 +214,8 @@ void meta_service::balancer_run() { _state->check_all_partitions(); } void meta_service::register_ctrl_commands() { _ctrl_node_live_percentage_threshold_for_update = - dsn::command_manager::instance().register_app_command( - {"live_percentage"}, + dsn::command_manager::instance().register_command( + {"meta.live_percentage"}, "live_percentage [num | DEFAULT]", "node live percentage threshold for update", [this](const std::vector &args) { diff --git a/src/dist/replication/meta_server/server_load_balancer.cpp b/src/dist/replication/meta_server/server_load_balancer.cpp index 3193502eec..b0113e8544 100644 --- a/src/dist/replication/meta_server/server_load_balancer.cpp +++ b/src/dist/replication/meta_server/server_load_balancer.cpp @@ -854,14 +854,14 @@ void simple_load_balancer::register_ctrl_commands() { server_load_balancer::register_ctrl_commands(); - _ctrl_assign_delay_ms = dsn::command_manager::instance().register_app_command( - {"lb.assign_delay_ms"}, + _ctrl_assign_delay_ms = dsn::command_manager::instance().register_command( + {"meta.lb.assign_delay_ms"}, "lb.assign_delay_ms [num | DEFAULT]", "control the replica_assign_delay_ms_for_dropouts config", [this](const std::vector &args) { return ctrl_assign_delay_ms(args); }); - _ctrl_assign_secondary_black_list = dsn::command_manager::instance().register_app_command( - {"lb.assign_secondary_black_list"}, + _ctrl_assign_secondary_black_list = dsn::command_manager::instance().register_command( + {"meta.lb.assign_secondary_black_list"}, "lb.assign_secondary_black_list [|clear]", "control the assign secondary black list", [this](const std::vector &args) { diff --git a/src/dist/replication/meta_server/server_state.cpp b/src/dist/replication/meta_server/server_state.cpp index 0101ea9553..03a4de4c22 100644 --- a/src/dist/replication/meta_server/server_state.cpp +++ b/src/dist/replication/meta_server/server_state.cpp @@ -88,8 +88,8 @@ server_state::~server_state() void server_state::register_cli_commands() { - _cli_dump_handle = dsn::command_manager::instance().register_app_command( - {"dump"}, + _cli_dump_handle = dsn::command_manager::instance().register_command( + {"meta.dump"}, "dump: dump app_states of meta server to local file", "dump -t|--target target_file", [this](const std::vector &args) { @@ -113,8 +113,8 @@ void server_state::register_cli_commands() }); dassert(_cli_dump_handle != nullptr, "register cli handler failed"); - _ctrl_add_secondary_enable_flow_control = dsn::command_manager::instance().register_app_command( - {"lb.add_secondary_enable_flow_control"}, + _ctrl_add_secondary_enable_flow_control = dsn::command_manager::instance().register_command( + {"meta.lb.add_secondary_enable_flow_control"}, "lb.add_secondary_enable_flow_control ", "control whether enable add secondary flow control", [this](const std::vector &args) { @@ -123,30 +123,29 @@ void server_state::register_cli_commands() }); dassert(_ctrl_add_secondary_enable_flow_control, "register cli handler failed"); - _ctrl_add_secondary_max_count_for_one_node = - dsn::command_manager::instance().register_app_command( - {"lb.add_secondary_max_count_for_one_node"}, - "lb.add_secondary_max_count_for_one_node [num | DEFAULT]", - "control the max count to add secondary for one node", - [this](const std::vector &args) { - std::string result("OK"); - if (args.empty()) { - result = std::to_string(_add_secondary_max_count_for_one_node); + _ctrl_add_secondary_max_count_for_one_node = dsn::command_manager::instance().register_command( + {"meta.lb.add_secondary_max_count_for_one_node"}, + "lb.add_secondary_max_count_for_one_node [num | DEFAULT]", + "control the max count to add secondary for one node", + [this](const std::vector &args) { + std::string result("OK"); + if (args.empty()) { + result = std::to_string(_add_secondary_max_count_for_one_node); + } else { + if (args[0] == "DEFAULT") { + _add_secondary_max_count_for_one_node = + _meta_svc->get_meta_options().add_secondary_max_count_for_one_node; } else { - if (args[0] == "DEFAULT") { - _add_secondary_max_count_for_one_node = - _meta_svc->get_meta_options().add_secondary_max_count_for_one_node; + int32_t v = 0; + if (!dsn::buf2int32(args[0], v) || v < 0) { + result = std::string("ERR: invalid arguments"); } else { - int32_t v = 0; - if (!dsn::buf2int32(args[0], v) || v < 0) { - result = std::string("ERR: invalid arguments"); - } else { - _add_secondary_max_count_for_one_node = v; - } + _add_secondary_max_count_for_one_node = v; } } - return result; - }); + } + return result; + }); dassert(_ctrl_add_secondary_max_count_for_one_node, "register cli handler failed"); }