NealSun96 commented on code in PR #2189:
URL: https://github.com/apache/helix/pull/2189#discussion_r1025722862
##########
helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/WagedRebalancer.java:
##########
@@ -469,27 +467,40 @@ private void
globalRebalance(ResourceControllerDataProvider clusterData,
/**
* Calculate and update the Baseline assignment
- * @param clusterModel
- * @param algorithm
- * @param shouldSchedulePartialRebalance True if the call should trigger a
following partial rebalance
+ * @param shouldTriggerMainPipeline True if the call should trigger a
following main pipeline rebalance
* so the new Baseline could be applied to
cluster.
- * @param clusterName
- * @throws HelixRebalanceException
*/
- private void calculateAndUpdateBaseline(ClusterModel clusterModel,
RebalanceAlgorithm algorithm,
- boolean shouldSchedulePartialRebalance, String clusterName)
- throws HelixRebalanceException {
+ private void doGlobalRebalance(ResourceControllerDataProvider clusterData,
Map<String, Resource> resourceMap,
+ RebalanceAlgorithm algorithm, CurrentStateOutput currentStateOutput,
boolean shouldTriggerMainPipeline,
+ Map<HelixConstants.ChangeType, Set<String>> clusterChanges) throws
HelixRebalanceException {
LOG.info("Start calculating the new baseline.");
_baselineCalcCounter.increment(1L);
_baselineCalcLatency.startMeasuringLatency();
- boolean isBaselineChanged = false;
+ // Build the cluster model for rebalance calculation.
+ // Note, for a Baseline calculation,
+ // 1. Ignore node status (disable/offline).
+ // 2. Use the previous Baseline as the only parameter about the previous
assignment.
+ Map<String, ResourceAssignment> currentBaseline =
+ getBaselineAssignment(_assignmentMetadataStore, currentStateOutput,
resourceMap.keySet());
+ ClusterModel clusterModel;
+ try {
+ clusterModel =
+ ClusterModelProvider.generateClusterModelForBaseline(clusterData,
resourceMap, clusterData.getAllInstances(),
+ clusterChanges, currentBaseline);
+ } catch (Exception ex) {
+ throw new HelixRebalanceException("Failed to generate cluster model for
global rebalance.",
+ HelixRebalanceException.Type.INVALID_CLUSTER_STATUS, ex);
+ }
+
Map<String, ResourceAssignment> newBaseline =
calculateAssignment(clusterModel, algorithm);
+ boolean isBaselineChanged =
+ _assignmentMetadataStore != null &&
!_assignmentMetadataStore.compareBaseline(newBaseline);
Review Comment:
I made similar changes like this - the logic has not changed: if the
assignment is the same, do not persist. However, I want to compare result
outside of the persistX function for 2 reasons:
1. The async persist function (in partial rebalance) can return a boolean
that indicates stale assignment for metric purpose (otherwise, I cannot
differentiate between stale data and same assignment, since both return false).
2. The write latency metric is now correctly measuring writes only, instead
of including data points for early returns due to same assignments.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]