hycdong commented on a change in pull request #601: URL: https://github.com/apache/incubator-pegasus/pull/601#discussion_r488438185
########## File path: src/server/hotspot_partition_calculator.h ########## @@ -24,6 +24,18 @@ namespace pegasus { namespace server { +enum class hotkey_detect_type Review comment: I suggest adding some comments to explain what is `hotkey_detect_type` and `hotkey_detect_action` usage. ########## File path: src/server/hotspot_partition_calculator.cpp ########## @@ -98,5 +104,54 @@ void hotspot_partition_calculator::data_analyse() } } +/*static*/ void +hotspot_partition_calculator::send_hotkey_detect_request(const std::string &app_name, + const int partition_index, + const hotkey_detect_type hotkey_type, + const hotkey_detect_action action) +{ + ::dsn::apps::hotkey_detect_request request; + request.type = (hotkey_type == hotkey_detect_type::WRITE_HOTKEY_DETECT) + ? dsn::apps::hotkey_type::WRITE + : dsn::apps::hotkey_type::READ; + request.action = (action == hotkey_detect_action::STOP_HOTKEY_DETECT) + ? dsn::apps::hotkey_detect_action::STOP + : dsn::apps::hotkey_detect_action::START; + ddebug_f("{} {} hotkey detection", + (action == hotkey_detect_action::STOP_HOTKEY_DETECT) ? "Stop" : "Start", + (hotkey_type == hotkey_detect_type::WRITE_HOTKEY_DETECT) ? "write" : "read"); Review comment: I think adding `app_name` and `partition_index` in this debug log is more helpful. ########## File path: src/server/hotspot_partition_calculator.cpp ########## @@ -98,5 +104,54 @@ void hotspot_partition_calculator::data_analyse() } } +/*static*/ void +hotspot_partition_calculator::send_hotkey_detect_request(const std::string &app_name, + const int partition_index, + const hotkey_detect_type hotkey_type, + const hotkey_detect_action action) +{ + ::dsn::apps::hotkey_detect_request request; + request.type = (hotkey_type == hotkey_detect_type::WRITE_HOTKEY_DETECT) + ? dsn::apps::hotkey_type::WRITE + : dsn::apps::hotkey_type::READ; + request.action = (action == hotkey_detect_action::STOP_HOTKEY_DETECT) + ? dsn::apps::hotkey_detect_action::STOP + : dsn::apps::hotkey_detect_action::START; + ddebug_f("{} {} hotkey detection", + (action == hotkey_detect_action::STOP_HOTKEY_DETECT) ? "Stop" : "Start", + (hotkey_type == hotkey_detect_type::WRITE_HOTKEY_DETECT) ? "write" : "read"); + dsn::rpc_address meta_server; + meta_server.assign_group("meta-servers"); + std::vector<dsn::rpc_address> meta_servers; + replica_helper::load_meta_servers(meta_servers); + for (auto &address : meta_servers) { + meta_server.group_address()->add(address); + } + auto cluster_name = dsn::replication::get_current_cluster_name(); + auto resolver = partition_resolver::get_resolver(cluster_name, meta_servers, app_name.c_str()); + dsn::task_tracker tracker; + resolver->call_op(RPC_DETECT_HOTKEY, Review comment: I notice that `send_hotkey_detect_request` is a static function, each time it is called, it should get `resolver` repeatly, besides, `info_collector` class has already got `_resolver`, how about use it directly rather than get it every time sending hotkey detect rpc ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@pegasus.apache.org For additional commands, e-mail: dev-h...@pegasus.apache.org