jiajunwang commented on a change in pull request #851: Add customized view 
computation and modify Helix generic controller to include new stage
URL: https://github.com/apache/helix/pull/851#discussion_r388620151
 
 

 ##########
 File path: 
helix-core/src/main/java/org/apache/helix/controller/GenericHelixController.java
 ##########
 @@ -899,6 +937,48 @@ public void onResourceConfigChange(
         .info("END: GenericClusterController.onResourceConfigChange() for 
cluster " + _clusterName);
   }
 
+  @Override
+  @PreFetch(enabled = false)
+  public void onCustomizedStateAggregationConfigChange(
+      CustomizedStateAggregationConfig customizedStateAggregationConfig,
+      NotificationContext context) {
+    HelixManager helixManager = context.getManager();
+    // add customized state listeners for existing instances
+    List<String> customizedStates = new ArrayList<>();
+
+    if (helixManager.getConfigAccessor()
+        .getCustomizedStateAggregationConfig(_clusterName) != null) {
+      customizedStates = helixManager.getConfigAccessor()
+          
.getCustomizedStateAggregationConfig(_clusterName).getAggregationEnabledTypes();
+    }
+
+    Map<String, LiveInstance> liveInstanceMap = 
helixManager.getHelixDataAccessor()
+        
.getChildValuesMap(helixManager.getHelixDataAccessor().keyBuilder().liveInstances());
+    List<String> liveInstances = liveInstanceMap.values().stream()
+        .map(liveInstance -> 
liveInstance.getInstanceName()).collect(Collectors.toList());
+
+    for (String customizedState : customizedStates) {
+      for (String instance : liveInstances) {
+        try {
+          helixManager.addCustomizedStateChangeListener(this, instance, 
customizedState);
 
 Review comment:
   Can these logic be pushed to the event handling section?
   1. Any error here will break the ZK thread. There will be a very ugly 
exception output.
   2. The extended latency will impact the whole controller performance.

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


With regards,
Apache Git Services

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

Reply via email to