mgao0 commented on a change in pull request #1187:
URL: https://github.com/apache/helix/pull/1187#discussion_r470358623



##########
File path: 
helix-core/src/main/java/org/apache/helix/controller/stages/CustomizedViewAggregationStage.java
##########
@@ -152,6 +162,68 @@ private void computeCustomizedStateView(final Resource 
resource, final String st
     if (curCustomizedView == null || 
!curCustomizedView.getRecord().equals(view.getRecord())) {
       // Add customized view to the list which will be written to ZK later.
       updatedCustomizedViews.add(view);
+      updatedStartTimestamps.put(resourceName,
+          customizedStateOutput.getResourceStartTimeMap(stateType, 
resourceName));
+    }
+  }
+
+  private void reportLatency(ClusterEvent event, List<CustomizedView> 
updatedCustomizedViews,
+      Map<String, CustomizedView> curCustomizedViews,
+      Map<String, Map<Partition, Map<String, Long>>> updatedStartTimestamps,
+      boolean[] updateSuccess) {
+    ClusterStatusMonitor clusterStatusMonitor =
+        event.getAttribute(AttributeName.clusterStatusMonitor.name());
+    if (clusterStatusMonitor == null) {
+      return;
+    }
+    long curTime = System.currentTimeMillis();
+    String clusterName = event.getClusterName();
+    CustomizedViewMonitor customizedViewMonitor =
+        clusterStatusMonitor.getOrCreateCustomizedViewMonitor(clusterName);
+
+    for (int i = 0; i < updatedCustomizedViews.size(); i++) {
+      CustomizedView newCV = updatedCustomizedViews.get(i);
+      String resourceName = newCV.getResourceName();
+
+      if (!updateSuccess[i]) {
+        LOG.warn("Customized views are not updated successfully for resource 
{} on cluster {}",
+            resourceName, clusterName);
+        continue;
+      }
+
+      CustomizedView oldCV =

Review comment:
       If the resource is newly created, the oldCV won't have the object, 
that's why I initialize an empty CustomizedView object here, otherwise it will 
return a null and will complicate the following comparisons.
   Yes, we decided not to put a start timestamp when deleting a state, thus 
there's no need to check for a removed resource too.




----------------------------------------------------------------
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:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to