xyuanlu commented on code in PR #2993: URL: https://github.com/apache/helix/pull/2993#discussion_r1919630971
########## helix-rest/src/main/java/org/apache/helix/rest/clusterMaintenanceService/MaintenanceManagementService.java: ########## @@ -560,6 +569,40 @@ private List<String> batchCustomInstanceStoppableCheck(String clusterId, List<St return instancesForCustomPartitionLevelChecks; } + /** + * Helper Methods + * <p> + * If users set skipCustomCheckIfInstanceNotAlive to true, filter out dead instances + * to avoid running custom checks on them. + * + * @param instanceIds the list of instances + * @return either the original list or a filtered list of only live instances + */ + private List<String> filterOutDeadInstancesIfNeeded(List<String> instanceIds) { + if (!_skipCustomChecksIfNoLiveness) { + // We are not skipping the not-alive check, so just return all instances. + return instanceIds; + } + + // Retrieve the set of currently live instances + PropertyKey.Builder keyBuilder = _dataAccessor.keyBuilder(); + List<String> liveNodes = _dataAccessor.getChildNames(keyBuilder.liveInstances()); + + // Filter out instances that are not in the live list + List<String> filtered = instanceIds.stream() Review Comment: We can iterate the instanceIds once. If liveNodes.contains(id), add it to filtered, else, add to skipped. And log outside. -- 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. To unsubscribe, e-mail: reviews-unsubscr...@helix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@helix.apache.org For additional commands, e-mail: reviews-h...@helix.apache.org