kaisun2000 commented on a change in pull request #365: Fix RoutingTableProvider 
statePropagationLatency metric reporting bug
URL: https://github.com/apache/helix/pull/365#discussion_r308503841
 
 

 ##########
 File path: 
helix-core/src/main/java/org/apache/helix/spectator/RoutingTableProvider.java
 ##########
 @@ -558,23 +558,28 @@ protected void refresh(Map<String, Map<String, 
Map<String, CurrentState>>> curre
 
   private void resetRoutingTableAndNotify(long startTime, RoutingTable 
newRoutingTable) {
     _routingTableRef.set(newRoutingTable);
-    logger.info("Refresh the RoutingTable for cluster {}, takes {} ms.",
-        (_helixManager != null ? _helixManager.getClusterName() : null),
+    String clusterName = _helixManager != null ? 
_helixManager.getClusterName() : null;
+    logger.info("Refresh the RoutingTable for cluster {}, takes {} ms.", 
clusterName,
         (System.currentTimeMillis() - startTime));
-    notifyRoutingTableChange();
+
+    notifyRoutingTableChange(_helixManager != null ? 
_helixManager.getClusterName() : null);
 
 Review comment:
   I think you mean write the following code. Thus, notifyRoutingTableChange() 
does not need to take any parameter, right?
   ```
   private void notifyRoutingTableChange() 
       notifyRoutingTableChange(_helixManager != null ? 
_helixManager.getClusterName() : null);
       logger.info("Refresh the RoutingTable for cluster {}, takes {} ms.", 
clusterName,
           (System.currentTimeMillis() - startTime));
       for (Map.Entry<RoutingTableChangeListener, ListenerContext> entry : 
_routingTableChangeListenerMap.entrySet()) {
   ...
   ```
   
   The thing is that if later you move this notifyRoutingTableChange() to 
another thread. The logging for "Refresh the RoutingTable for Cluster {} .." 
time is not accurate, right?
   
   Fundamentally, notifyRoutingTableChange is for calling user callback, 
resetRoutingTableAndNotify() (better to called resetRoutingTable() ) is for 
Helix logic. This two funtionality ideally should be separated. The time spent 
should also be logged separately.

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


With regards,
Apache Git Services

Reply via email to