jiajunwang commented on a change in pull request #632: Asynchronously
calculating the Baseline
URL: https://github.com/apache/helix/pull/632#discussion_r360548657
##########
File path:
helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/WagedRebalancer.java
##########
@@ -413,28 +435,57 @@ private void
globalRebalance(ResourceControllerDataProvider clusterData,
HelixRebalanceException.Type.INVALID_CLUSTER_STATUS, ex);
}
- calculateAndUpdateBaseline(clusterModel, algorithm);
+ final boolean waitForGlobalRebalance = !_asyncGlobalRebalance;
+ final String clusterName = clusterData.getClusterName();
+ // Calculate the Baseline assignment for global rebalance.
+ Future<Boolean> result = _baselineCalculateExecutor.submit(() -> {
+ try {
+ // Note that we should schedule a new partial rebalance if the
following calculation does
+ // not wait until the new baseline is calculated.
+ // So set doSchedulePartialRebalance to be !waitForGlobalRebalance
+ calculateAndUpdateBaseline(clusterModel, algorithm,
!waitForGlobalRebalance, clusterName);
+ } catch (HelixRebalanceException e) {
+ LOG.error("Failed to calculate baseline assignment!", e);
+ return false;
+ }
+ return true;
+ });
+ if (waitForGlobalRebalance) {
+ try {
+ if (!result.get()) {
+ throw new HelixRebalanceException("Failed to calculate for the new
Baseline.",
+ HelixRebalanceException.Type.FAILED_TO_CALCULATE);
+ }
+ } catch (InterruptedException | ExecutionException e) {
+ throw new HelixRebalanceException("Failed to execute new Baseline
calculation.",
+ HelixRebalanceException.Type.FAILED_TO_CALCULATE, e);
+ }
+ }
}
}
/**
* Calculate and update the Baseline assignment
* @param clusterModel
- * @param algorithm
+ * @param doSchedulePartialRebalance True if the call should trigger a
following partial rebalance
+ * so the new Baseline could be applied to
cluster.
+ * @param clusterName
* @throws HelixRebalanceException
*/
- private void calculateAndUpdateBaseline(ClusterModel clusterModel,
RebalanceAlgorithm algorithm)
+ private void calculateAndUpdateBaseline(ClusterModel clusterModel,
RebalanceAlgorithm algorithm,
+ boolean doSchedulePartialRebalance, String clusterName)
throws HelixRebalanceException {
LOG.info("Start calculating the new baseline.");
- _globalBaselineCalcCounter.increment(1L);
- _globalBaselineCalcLatency.startMeasuringLatency();
+ _baselineCalcCounter.increment(1L);
+ _baselineCalcLatency.startMeasuringLatency();
+ boolean isbaselineUpdated = false;
Review comment:
How about isBaselineChanged?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]