Source:
private void refreshBaseline(ResourceControllerDataProvider clusterData, Map<HelixConstants.ChangeType, Set<String>> clusterChanges, Map<String, Resource> resourceMap, final CurrentStateOutput currentStateOutput) throws HelixRebalanceException { LOG.info("Start calculating the new baseline."); CountMetric globalBaselineCalcCounter = _metricCollector.getMetric( WagedRebalancerMetricCollector.WagedRebalancerMetricNames.GlobalBaselineCalcCounter.name(), CountMetric.class); globalBaselineCalcCounter.increaseCount(REBALANCE_COUNTER_INCREMENT); LatencyMetric globalBaselineCalcLatency = _metricCollector.getMetric( WagedRebalancerMetricCollector.WagedRebalancerMetricNames.GlobalBaselineCalcLatencyGauge .name(), LatencyMetric.class); globalBaselineCalcLatency.startMeasuringLatency(); Map<String, ResourceAssignment> currentBaseline = getBaselineAssignment(_assignmentMetadataStore, currentStateOutput, resourceMap.keySet()); Map<String, ResourceAssignment> newBaseline = calculateAssignment(clusterData, clusterChanges, resourceMap, clusterData.getAllInstances(), Collections.emptyMap(), currentBaseline); if (_assignmentMetadataStore != null) { try { LatencyMetric writeLatency = _metricCollector.getMetric( WagedRebalancerMetricCollector.WagedRebalancerMetricNames.StateWriteLatencyGauge.name(), LatencyMetric.class); writeLatency.startMeasuringLatency(); _assignmentMetadataStore.persistBaseline(newBaseline); writeLatency.endMeasuringLatency(); } catch (Exception ex) { throw new HelixRebalanceException("Failed to persist the new baseline assignment.", HelixRebalanceException.Type.INVALID_REBALANCER_STATUS, ex); } } else { LOG.debug("Assignment Metadata Store is empty. Skip persist the baseline assignment."); } globalBaselineCalcLatency.endMeasuringLatency(); LOG.info("Finish calculating the new baseline."); }

Target:
private void refreshBaseline(ResourceControllerDataProvider clusterData, Map<HelixConstants.ChangeType, Set<String>> clusterChanges, Map<String, Resource> resourceMap, final CurrentStateOutput currentStateOutput) throws HelixRebalanceException { LOG.info("Start calculating the new baseline."); CountMetric globalBaselineCalcCounter = _metricCollector.getMetric( WagedRebalancerMetricCollector.WagedRebalancerMetricNames.GlobalBaselineCalcCounter.name(), CountMetric.class); globalBaselineCalcCounter.increaseCount(1L); LatencyMetric globalBaselineCalcLatency = _metricCollector.getMetric( WagedRebalancerMetricCollector.WagedRebalancerMetricNames.GlobalBaselineCalcLatencyGauge .name(), LatencyMetric.class); globalBaselineCalcLatency.startMeasuringLatency(); Map<String, ResourceAssignment> currentBaseline = getBaselineAssignment(_assignmentMetadataStore, currentStateOutput, resourceMap.keySet()); Map<String, ResourceAssignment> newBaseline = calculateAssignment(clusterData, clusterChanges, resourceMap, clusterData.getAllInstances(), Collections.emptyMap(), currentBaseline); if (_assignmentMetadataStore != null) { try { LatencyMetric writeLatency = _metricCollector.getMetric( WagedRebalancerMetricCollector.WagedRebalancerMetricNames.StateWriteLatencyGauge.name(), LatencyMetric.class); writeLatency.startMeasuringLatency(); _assignmentMetadataStore.persistBaseline(newBaseline); writeLatency.endMeasuringLatency(); } catch (Exception ex) { throw new HelixRebalanceException("Failed to persist the new baseline assignment.", HelixRebalanceException.Type.INVALID_REBALANCER_STATUS, ex); } } else { LOG.debug("Assignment Metadata Store is empty. Skip persist the baseline assignment."); } globalBaselineCalcLatency.endMeasuringLatency(); LOG.info("Finish calculating the new baseline."); }