Source:
<code>public Map<String, Map<String, Boolean>> getAllPartitionsHealthOnLiveInstance(RESTConfig restConfig, Map<String, String> customPayLoads) { List<String> liveInstances = getChildNames(keyBuilder().liveInstances()); List<HelixProperty> zkHealthReports = getProperty(liveInstances.stream() .map(instance -> keyBuilder().healthReport(instance, PARTITION_HEALTH_KEY)) .collect(Collectors.toList()), false); Map<String, Future<Map<String, Boolean>>> parallelTasks = new HashMap<>(); for (int i = 0; i < liveInstances.size(); i++) { String liveInstance = liveInstances.get(i); <START> Optional<ZNRecord> maybeHealthRecord = zkHealthReports != null && zkHealthReports.size() > i <END> ? Optional.ofNullable(zkHealthReports.get(i).getRecord()) : Optional.empty(); parallelTasks.put(liveInstance, POOL.submit(() -> maybeHealthRecord .map(record -> getPartitionsHealth(liveInstance, record, restConfig, customPayLoads)) .orElseGet(() -> getHealthStatusFromRest(liveInstance, Collections.emptyList(), restConfig, customPayLoads)))); } Map<String, Map<String, Boolean>> result = new HashMap<>(); for (Map.Entry<String, Future<Map<String, Boolean>>> instanceToFuturePartitionHealth : parallelTasks .entrySet()) { String instance = instanceToFuturePartitionHealth.getKey(); try { result.put(instance, instanceToFuturePartitionHealth.getValue().get()); } catch (InterruptedException | ExecutionException e) { LOG.error("Failed to get partition health for instance {}", instance, e); result.put(instance, Collections.emptyMap()); } } return result; }</code><technical_language>If Helix return complete list, this is efficient way. dont is missed array list. totally mess result. For example, 6 instances get 3 ZNRecords for 3 ones. logic, fill 3 ZNRecords threes health report querying next ones. Please refer Java doc of get in BaseDataAccessor interface. getProperty get() return list of HelixProperty: <LINK_0></technical_language>

Target:
public Map<String, Map<String, Boolean>> getAllPartitionsHealthOnLiveInstance( RESTConfig restConfig, Map<String, String> customPayLoads) { List<String> liveInstances = getChildNames(keyBuilder().liveInstances()); List<HelixProperty> zkHealthReports = getProperty(liveInstances.stream() .map(instance -> keyBuilder().healthReport(instance, PARTITION_HEALTH_KEY)) .collect(Collectors.toList()), false); Map<String, Future<Map<String, Boolean>>> parallelTasks = new HashMap<>(); for (int i = 0; i < liveInstances.size(); i++) { String liveInstance = liveInstances.get(i); Optional<ZNRecord> maybeHealthRecord = Optional.ofNullable(zkHealthReports.get(i)).map(HelixProperty::getRecord); parallelTasks.put(liveInstance, POOL.submit(() -> maybeHealthRecord .map(record -> getPartitionsHealth(liveInstance, record, restConfig, customPayLoads)) .orElseGet(() -> getHealthStatusFromRest(liveInstance, Collections.emptyList(), restConfig, customPayLoads)))); } Map<String, Map<String, Boolean>> result = new HashMap<>(); for (Map.Entry<String, Future<Map<String, Boolean>>> instanceToFuturePartitionHealth : parallelTasks .entrySet()) { String instance = instanceToFuturePartitionHealth.getKey(); try { result.put(instance, instanceToFuturePartitionHealth.getValue().get()); } catch (InterruptedException | ExecutionException e) { LOG.error("Failed to get partition health for instance {}", instance, e); result.put(instance, Collections.emptyMap()); } } return result; }