You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@helix.apache.org by GitBox <gi...@apache.org> on 2019/12/03 22:00:06 UTC

[GitHub] [helix] i3wangyi commented on a change in pull request #636: Simply and enhance the RebalanceLatencyGauge so it can be used in multi-threads.

i3wangyi commented on a change in pull request #636: Simply and enhance the RebalanceLatencyGauge so it can be used in multi-threads.
URL: https://github.com/apache/helix/pull/636#discussion_r353444635
 
 

 ##########
 File path: helix-core/src/main/java/org/apache/helix/monitoring/metrics/implementation/RebalanceLatencyGauge.java
 ##########
 @@ -30,6 +31,8 @@
   private static final Logger LOG = LoggerFactory.getLogger(RebalanceLatencyGauge.class);
   private static final long VALUE_NOT_SET = -1;
   private long _lastEmittedMetricValue = VALUE_NOT_SET;
+  // Use threadlocal here so the start time can be updated and recorded in multi-threads.
+  private final ThreadLocal<Long> _startTime;
 
 Review comment:
   Wouldn't it be easier for each thread creating a new instance of RebalanceLatencyGauge, that you don't need to handle the concurrency complexities? It's more error-prone as we all know 
   But I do see the usage pattern is the one single instance RebalanceLatencyGauge will be long-lived in the memory - if it's desired, can we make sure the class usage always follows the singleton pattern? 
   

----------------------------------------------------------------
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


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org