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/01 20:57:40 UTC

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

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



##########
File path: helix-rest/src/main/java/org/apache/helix/rest/server/service/InstanceServiceImpl.java
##########
@@ -225,9 +248,11 @@ public StoppableCheck getInstanceStoppableCheck(String clusterId, String instanc
         StoppableCheck stoppableCheck = entry.getValue().get();
         if (!stoppableCheck.isStoppable()) {
           // put the check result of the failed-to-stop instances
-          finalStoppableCheckByInstance.put(instance, stoppableCheck);
-        } else {
-          // instance passed this around of check will be checked in the next round
+          addStoppableCheck(finalStoppableCheckByInstance, instance, stoppableCheck);
+        }
+        if (stoppableCheck.isStoppable() || _allChecks){
+          // instance passed this around of check or mandatory all checks
+          // will be checked in the next round
           instancesForNextCheck.add(instance);
         }

Review comment:
       Agreed. This was also something I would do to make it cleaner when working on the code. But it should be fine for now as one stoppable call does not have too many instances, so StoppableCheck objects won't be too many for the life cycle of a call. It'll need some refactoring work. An issue is created track it: #1692 .

##########
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:
       I thought about both `putIfAbsent` and `computeIfAbsent` but neither of them fit in the logic.




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