You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pegasus.apache.org by GitBox <gi...@apache.org> on 2020/10/20 11:33:34 UTC

[GitHub] [incubator-pegasus] levy5307 commented on a change in pull request #625: feat(hotkey): collector can be terminated by timeout

levy5307 commented on a change in pull request #625:
URL: https://github.com/apache/incubator-pegasus/pull/625#discussion_r508425970



##########
File path: src/server/hotkey_collector.cpp
##########
@@ -105,13 +118,30 @@ void hotkey_collector::on_start_detect(dsn::replication::detect_hotkey_response
 
 void hotkey_collector::on_stop_detect(dsn::replication::detect_hotkey_response &resp)
 {
-    _state.store(hotkey_collector_state::STOPPED);
-    _internal_collector.reset();
+    terminate_colletor();
     resp.err = dsn::ERR_OK;
     std::string hint =
         fmt::format("{} hotkey stopped, cache cleared", dsn::enum_to_string(_hotkey_type));
     ddebug_replica(hint);
 }
 
+void hotkey_collector::terminate_colletor()
+{
+    _state.store(hotkey_collector_state::STOPPED);
+    _internal_collector.reset();
+    _collector_start_time = 0;
+}
+
+void hotkey_collector::terminate_by_timeout()
+{
+    if (_collector_start_time == 0)
+        return;
+    if (dsn_now_s() - _collector_start_time >= FLAGS_hotkey_collector_max_work_time) {

Review comment:
       I think ` if (dsn_now_s() >= FLAGS_hotkey_collector_max_work_time) +  _collector_start_time` is better 




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pegasus.apache.org
For additional commands, e-mail: dev-help@pegasus.apache.org