NealSun96 commented on a change in pull request #1151:
URL: https://github.com/apache/helix/pull/1151#discussion_r454703877
##########
File path:
helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java
##########
@@ -1861,24 +1861,28 @@ public boolean enableWagedRebalance(String clusterName,
List<String> resourceNam
HelixDataAccessor accessor =
new ZKHelixDataAccessor(clusterName, new
ZkBaseDataAccessor<>(_zkClient));
PropertyKey.Builder keyBuilder = accessor.keyBuilder();
+ List<IdealState> enabledIdealStates = new ArrayList<>();
+ List<PropertyKey> enabledIdealStateKeys = new ArrayList<>();
+ List<String> enabledResourceNames = new ArrayList<>();
+
List<IdealState> idealStates =
accessor.getChildValues(keyBuilder.idealStates(), true);
- List<String> nullIdealStates = new ArrayList<>();
- for (int i = 0; i < idealStates.size(); i++) {
- if (idealStates.get(i) == null) {
- nullIdealStates.add(resourceNames.get(i));
- } else {
-
idealStates.get(i).setRebalancerClassName(WagedRebalancer.class.getName());
- idealStates.get(i).setRebalanceMode(RebalanceMode.FULL_AUTO);
+ for (IdealState idealState : idealStates) {
+ if (idealState != null &&
resourceNames.contains(idealState.getResourceName())) {
+ idealState.setRebalancerClassName(WagedRebalancer.class.getName());
+ idealState.setRebalanceMode(RebalanceMode.FULL_AUTO);
+ enabledIdealStates.add(idealState);
+
enabledIdealStateKeys.add(keyBuilder.idealStates(idealState.getResourceName()));
+ enabledResourceNames.add(idealState.getResourceName());
}
}
- if (!nullIdealStates.isEmpty()) {
+ List<String> resourcesNotFound =
+ resourceNames.stream().filter(resourceName ->
!enabledResourceNames.contains(resourceName))
+ .collect(Collectors.toList());
+ if (!resourcesNotFound.isEmpty()) {
Review comment:
I want to show what resources don't have idealStates, otherwise I don't
think it's informative enough.
----------------------------------------------------------------
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]