jiajunwang commented on a change in pull request #490: Add latency metric 
components for WAGED rebalancer
URL: https://github.com/apache/helix/pull/490#discussion_r329775047
 
 

 ##########
 File path: 
helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/WagedRebalancer.java
 ##########
 @@ -226,16 +247,25 @@ private void 
refreshBaseline(ResourceControllerDataProvider clusterData,
       Map<HelixConstants.ChangeType, Set<String>> clusterChanges, Map<String, 
Resource> resourceMap,
       final CurrentStateOutput currentStateOutput) throws 
HelixRebalanceException {
     LOG.info("Start calculating the new baseline.");
+
+    // Read the baseline from metadata store
+    
_metricCollector.getMetric(WagedRebalancerMetricNames.GlobalStateReadLatencyGauge.name(),
+        LatencyMetric.class).startMeasuringLatency();
     Map<String, ResourceAssignment> currentBaseline =
         getBaselineAssignment(_assignmentMetadataStore, currentStateOutput, 
resourceMap.keySet());
+    
_metricCollector.getMetric(WagedRebalancerMetricNames.GlobalStateReadLatencyGauge.name(),
+        LatencyMetric.class).endMeasuringLatency();
+
     // For baseline calculation
     // 1. Ignore node status (disable/offline).
     // 2. Use the baseline as the previous best possible assignment since 
there is no "baseline" for
     // the baseline.
-    Map<String, ResourceAssignment> newBaseline =
-        calculateAssignment(clusterData, clusterChanges, resourceMap, 
clusterData.getAllInstances(),
-            Collections.emptyMap(), currentBaseline);
+    Map<String, ResourceAssignment> newBaseline = 
calculateAssignment(clusterData, clusterChanges,
+        resourceMap, clusterData.getAllInstances(), Collections.emptyMap(), 
currentBaseline);
 
+    // Write the new baseline to metadata store
+    
_metricCollector.getMetric(WagedRebalancerMetricNames.GlobalStateWriteLatencyGauge.name(),
+        LatencyMetric.class).startMeasuringLatency();
     if (_assignmentMetadataStore != null) {
       try {
         _assignmentMetadataStore.persistBaseline(newBaseline);
 
 Review comment:
   Will it be better if the AssignmentMetadataStore.persistBaseline takes a 
metric object as the input?
   The main goal is to minimize the metric code footprint.
   Or it will hurt the code's readability.

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

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

Reply via email to