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 2021/04/02 04:19:02 UTC

[GitHub] [helix] NealSun96 commented on a change in pull request #1689: Add option to force all checks for stoppable api

NealSun96 commented on a change in pull request #1689:
URL: https://github.com/apache/helix/pull/1689#discussion_r606063605



##########
File path: helix-rest/src/main/java/org/apache/helix/rest/server/service/InstanceServiceImpl.java
##########
@@ -206,14 +216,27 @@ public StoppableCheck getInstanceStoppableCheck(String clusterId, String instanc
           instancesForCustomPartitionLevelChecks, restConfig, customPayLoads);
       for (Map.Entry<String, StoppableCheck> instancePartitionStoppableCheckEntry : instancePartitionLevelChecks
           .entrySet()) {
-        finalStoppableChecks.put(instancePartitionStoppableCheckEntry.getKey(),
-            instancePartitionStoppableCheckEntry.getValue());
+        String instance = instancePartitionStoppableCheckEntry.getKey();
+        StoppableCheck stoppableCheck = instancePartitionStoppableCheckEntry.getValue();
+        addStoppableCheck(finalStoppableChecks, instance, stoppableCheck);
       }
     }
 
     return finalStoppableChecks;
   }
 
+  private void addStoppableCheck(Map<String, StoppableCheck> stoppableChecks, String instance,
+      StoppableCheck stoppableCheck) {
+    if (!stoppableChecks.containsKey(instance)) {
+      stoppableChecks.put(instance, stoppableCheck);
+    } else {
+      // Merge two checks
+      StoppableCheck existedCheck = stoppableChecks.get(instance);
+      existedCheck.add(stoppableCheck);
+      stoppableChecks.put(instance, existedCheck);
+    }

Review comment:
       Sorry, not `computeIfAbsent`, but `compute`. Do you think this would work?
   `stoppableChecks.compute(instance, (k, v) -> v == null ? stoppableCheck : v.add(stoppableCheck)`




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



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