Source:
public TaskResult run() { try { HelixDataAccessor helixDataAccessor = manager.getHelixDataAccessor(); List<String> instanceNames = manager.getClusterManagmentTool().getInstancesInCluster(manager.getClusterName()); Map<String, String> statsWrappersJSON = new HashMap<>(); for (String instanceName : instanceNames) { PropertyKey.Builder keyBuilder = helixDataAccessor.keyBuilder(); HelixProperty record = helixDataAccessor.getProperty(keyBuilder.healthReport(instanceName, healthReportName)); if (record != null && record.getRecord() != null) { statsWrappersJSON.put(instanceName, record.getRecord().getSimpleField(statsFieldName)); } } ObjectMapper mapper = new ObjectMapper(); Pair<StatsSnapshot, StatsSnapshot> results = clusterAggregator.doWork(statsWrappersJSON, statsReportType); String resultId = String.format("Aggregated_%s", healthReportName); ZNRecord znRecord = new ZNRecord(resultId); znRecord.setSimpleField(RAW_VALID_SIZE_FIELD_NAME, mapper.writeValueAsString(results.getFirst())); znRecord.setSimpleField(VALID_SIZE_FIELD_NAME, mapper.writeValueAsString(results.getSecond())); znRecord.setSimpleField(TIMESTAMP_FIELD_NAME, String.valueOf(SystemTime.getInstance().milliseconds())); znRecord.setListField(ERROR_OCCURRED_INSTANCES_FIELD_NAME, clusterAggregator.getExceptionOccurredInstances(statsReportType)); String path = String.format("/%s", resultId); manager.getHelixPropertyStore().set(path, znRecord, AccessOption.PERSISTENT); if (statsReportType.equals(StatsReportType.ACCOUNT_REPORT)) { accountService.selectInvalidContainersAndMarkInZK(results.getFirst()); } return new TaskResult(TaskResult.Status.COMPLETED, "Aggregation success"); } catch (Exception e) { logger.error("Exception thrown while aggregating stats from health reports across all nodes ", e); return new TaskResult(TaskResult.Status.FAILED, "Exception thrown"); } }

Target:
public TaskResult run() { Pair<StatsSnapshot, StatsSnapshot> results = null; Exception exception = null; try { HelixDataAccessor helixDataAccessor = manager.getHelixDataAccessor(); List<String> instanceNames = manager.getClusterManagmentTool().getInstancesInCluster(manager.getClusterName()); Map<String, String> statsWrappersJSON = new HashMap<>(); for (String instanceName : instanceNames) { PropertyKey.Builder keyBuilder = helixDataAccessor.keyBuilder(); HelixProperty record = helixDataAccessor.getProperty(keyBuilder.healthReport(instanceName, healthReportName)); if (record != null && record.getRecord() != null) { statsWrappersJSON.put(instanceName, record.getRecord().getSimpleField(statsFieldName)); } } ObjectMapper mapper = new ObjectMapper(); results = clusterAggregator.doWork(statsWrappersJSON, statsReportType); String resultId = String.format("Aggregated_%s", healthReportName); ZNRecord znRecord = new ZNRecord(resultId); znRecord.setSimpleField(RAW_VALID_SIZE_FIELD_NAME, mapper.writeValueAsString(results.getFirst())); znRecord.setSimpleField(VALID_SIZE_FIELD_NAME, mapper.writeValueAsString(results.getSecond())); znRecord.setSimpleField(TIMESTAMP_FIELD_NAME, String.valueOf(SystemTime.getInstance().milliseconds())); znRecord.setListField(ERROR_OCCURRED_INSTANCES_FIELD_NAME, clusterAggregator.getExceptionOccurredInstances(statsReportType)); String path = String.format("/%s", resultId); manager.getHelixPropertyStore().set(path, znRecord, AccessOption.PERSISTENT); return new TaskResult(TaskResult.Status.COMPLETED, "Aggregation success"); } catch (Exception e) { logger.error("Exception thrown while aggregating stats from health reports across all nodes ", e); exception = e; return new TaskResult(TaskResult.Status.FAILED, "Exception thrown"); } finally { if (clusterMapConfig.clustermapEnableContainerDeletionAggregation && callback != null && results != null && statsReportType.equals(StatsReportType.ACCOUNT_REPORT)) { callback.onCompletion(results.getFirst(), exception); } } }