Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -336,16 +336,15 @@ protected Map<String, String> computeBestPossibleStateForPartition(Set<String> l
&& numReplicas + numExtraReplicas - currentInstances.size() > 0) {
int subListSize = numReplicas + numExtraReplicas - currentInstances.size();
combinedPreferenceList.addAll(instanceToAdd
.subList(0, subListSize <= instanceToAdd.size() ? subListSize : instanceToAdd.size()));
.subList(0, Math.min(subListSize, instanceToAdd.size())));
}

// Make all initial state instance not in preference list to be dropped.
Map<String, String> currentMapWithPreferenceList = new HashMap<>(currentStateMap);
currentMapWithPreferenceList.keySet().retainAll(preferenceList);

combinedPreferenceList.addAll(currentInstances);
Collections.sort(combinedPreferenceList,
new PreferenceListNodeComparator(currentStateMap, stateModelDef, preferenceList));
combinedPreferenceList.sort(new PreferenceListNodeComparator(currentStateMap, stateModelDef, preferenceList));

// Assign states to instances with the combined preference list.
Map<String, String> bestPossibleStateMap =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,7 @@ private Map<String, IdealState> computeBestPossibleStates(
// Note the user-defined list is intentionally applied to the final mapping after calculation.
// This is to avoid persisting it into the assignment store, which impacts the long term
// assignment evenness and partition movements.
newIdealStates.entrySet().stream().forEach(idealStateEntry -> applyUserDefinedPreferenceList(
clusterData.getResourceConfig(idealStateEntry.getKey()), idealStateEntry.getValue()));
newIdealStates.forEach((key, value) -> applyUserDefinedPreferenceList(clusterData.getResourceConfig(key), value));

return newIdealStates;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,18 +325,16 @@ private Map<String, Resource> computeResourceBestPossibleStateWithWagedRebalance
"Skip rebalancing using the WAGED rebalancer since it is not configured in the rebalance pipeline.");
}

Iterator<Resource> itr = wagedRebalancedResourceMap.values().iterator();
while (itr.hasNext()) {
Resource resource = itr.next();
for (Resource resource : wagedRebalancedResourceMap.values()) {
IdealState is = newIdealStates.get(resource.getResourceName());
// Check if the WAGED rebalancer has calculated the result for this resource or not.
if (is != null && checkBestPossibleStateCalculation(is)) {
// The WAGED rebalancer calculates a valid result, record in the output
updateBestPossibleStateOutput(output, resource, is);
} else {
failureResources.add(resource.getResourceName());
LogUtil.logWarn(logger, _eventId, String
.format("The calculated best possible states for %s is empty or invalid.",
LogUtil.logWarn(logger, _eventId,
String.format("The calculated best possible states for %s is empty or invalid.",
resource.getResourceName()));
}
}
Expand Down Expand Up @@ -387,7 +385,7 @@ private boolean computeSingleResourceBestPossibleState(ClusterEvent event,
MappingCalculator<ResourceControllerDataProvider> mappingCalculator =
getMappingCalculator(rebalancer, resourceName);

if (rebalancer == null || mappingCalculator == null) {
if (rebalancer == null) {
LogUtil.logError(logger, _eventId, "Error computing assignment for resource " + resourceName
+ ". no rebalancer found. rebalancer: " + rebalancer + " mappingCalculator: "
+ mappingCalculator);
Expand Down