jiajunwang commented on a change in pull request #1167:
URL: https://github.com/apache/helix/pull/1167#discussion_r458959403
##########
File path:
helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/WagedRebalancer.java
##########
@@ -643,23 +643,28 @@ private void validateInput(ResourceControllerDataProvider
clusterData,
private Map<String, ResourceAssignment> getBaselineAssignment(
AssignmentMetadataStore assignmentMetadataStore, CurrentStateOutput
currentStateOutput,
Set<String> resources) throws HelixRebalanceException {
- Map<String, ResourceAssignment> currentBaseline = Collections.emptyMap();
+ Map<String, ResourceAssignment> currentBaseline = new HashMap<>();
if (assignmentMetadataStore != null) {
try {
_stateReadLatency.startMeasuringLatency();
- currentBaseline = assignmentMetadataStore.getBaseline();
+ currentBaseline = new HashMap<>(assignmentMetadataStore.getBaseline());
_stateReadLatency.endMeasuringLatency();
} catch (Exception ex) {
throw new HelixRebalanceException(
"Failed to get the current baseline assignment because of
unexpected error.",
HelixRebalanceException.Type.INVALID_REBALANCER_STATUS, ex);
}
}
- if (currentBaseline.isEmpty()) {
+ currentBaseline.keySet().retainAll(resources);
+ if (!currentBaseline.keySet().containsAll(resources)) {
LOG.warn("The current baseline assignment record is empty. Use the
current states instead.");
- currentBaseline = currentStateOutput.getAssignment(resources);
+ for (Map.Entry<String, ResourceAssignment> entry :
currentStateOutput.getAssignment(resources)
Review comment:
Better to do:
1. find all the missing resources
2. call getAssignment() to get the corresponding assignment
3. add assignments to the return map.
----------------------------------------------------------------
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]