Skip to content

Commit

Permalink
Fix BestPossibleExternalViewVerifier for WAGED resource
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkGaox committed Oct 7, 2024
1 parent 9b339b5 commit 04ed543
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

import org.apache.helix.HelixDefinedState;
import org.apache.helix.PropertyKey;
import org.apache.helix.controller.common.PartitionStateMap;
import org.apache.helix.controller.dataproviders.ResourceControllerDataProvider;
import org.apache.helix.controller.rebalancer.util.WagedValidationUtil;
import org.apache.helix.controller.rebalancer.waged.ReadOnlyWagedRebalancer;
import org.apache.helix.controller.stages.AttributeName;
import org.apache.helix.controller.stages.BestPossibleStateCalcStage;
Expand Down Expand Up @@ -274,8 +276,18 @@ protected synchronized boolean verifyState() {

// Filter resources if requested
if (_resources != null && !_resources.isEmpty()) {
idealStates.keySet().retainAll(_resources);
extViews.keySet().retainAll(_resources);
Set<String> wagedResource = _resources.stream().filter(
resourceEntry -> WagedValidationUtil.isWagedEnabled(idealStates.get(resourceEntry)))
.collect(Collectors.toSet());
if (wagedResource.isEmpty()) {
// If no waged-enabled resources are found, retain only the provided resources
idealStates.keySet().retainAll(_resources);
extViews.keySet().retainAll(_resources);
} else {
// If any of the resources is a waged resource, we need to verify all resources
// because the best possible state calculation is done for all resources
_resources.clear();
}
}

// if externalView is not empty and idealState doesn't exist
Expand Down

0 comments on commit 04ed543

Please sign in to comment.