You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@helix.apache.org by GitBox <gi...@apache.org> on 2020/07/14 21:24:24 UTC

[GitHub] [helix] NealSun96 opened a new pull request #1151: Fix enableWagedRebalance by respecting resource names argument

NealSun96 opened a new pull request #1151:
URL: https://github.com/apache/helix/pull/1151


   ### Issues
   
   - [x] My PR addresses the following Helix issues and references them in the PR description:
   
   Fixes #1150 
   
   ### Description
   
   - [x] Here are some details about my PR, including screenshots of any UI changes:
   
   enableWagedRebalance() is not currently respecting the resource names that are passed to it - it's enabling waged for all resources, which isn't correct. The fix is to only enable waged for the provided resource names.
   
   ### Tests
   
   - [x] The following is the result of the "mvn test" command on the appropriate module:
   ```
   [ERROR] Tests run: 1153, Failures: 5, Errors: 0, Skipped: 1, Time elapsed: 4,361.463 s <<< FAILURE! - in TestSuite
   [ERROR] testLackEnoughLiveInstances(org.apache.helix.integration.rebalancer.CrushRebalancers.TestCrushAutoRebalanceTopoplogyAwareDisabled)  Time elapsed: 0.599 s  <<< FAILURE!
   java.lang.AssertionError: expected:<2> but was:<1>
           at org.apache.helix.integration.rebalancer.CrushRebalancers.TestCrushAutoRebalanceTopoplogyAwareDisabled.testLackEnoughLiveInstances(TestCrushAutoRebalanceTopoplogyAwareDisabled.java:79)
   
   [ERROR] testResourceSubset(org.apache.helix.tools.TestClusterStateVerifier)  Time elapsed: 1.025 s  <<< FAILURE!
   org.apache.helix.HelixException: Failed to create pause signal
           at org.apache.helix.tools.TestClusterStateVerifier.testResourceSubset(TestClusterStateVerifier.java:115)
   
   [ERROR] afterMethod(org.apache.helix.tools.TestClusterStateVerifier)  Time elapsed: 1.068 s  <<< FAILURE!
   java.lang.IllegalStateException: ZkClient already closed!
           at org.apache.helix.tools.TestClusterStateVerifier.afterMethod(TestClusterStateVerifier.java:98)
   
   [ERROR] testFixedTargetTaskAndEnabledRebalanceAndNodeAdded(org.apache.helix.integration.task.TestRebalanceRunningTask)  Time elapsed: 10.352 s  <<< FAILURE!
   java.lang.AssertionError: expected:<true> but was:<false>
           at org.apache.helix.integration.task.TestRebalanceRunningTask.testFixedTargetTaskAndEnabledRebalanceAndNodeAdded(TestRebalanceRunningTask.java:330)
   
   [ERROR] testEnableCompressionResource(org.apache.helix.integration.TestEnableCompression)  Time elapsed: 151.829 s  <<< FAILURE!
   java.lang.AssertionError: expected:<true> but was:<false>
           at org.apache.helix.integration.TestEnableCompression.testEnableCompressionResource(TestEnableCompression.java:117)
   
   [INFO] 
   [INFO] Results:
   [INFO] 
   [ERROR] Failures: 
   [ERROR]   TestEnableCompression.testEnableCompressionResource:117 expected:<true> but was:<false>
   [ERROR] org.apache.helix.integration.rebalancer.CrushRebalancers.TestCrushAutoRebalanceTopoplogyAwareDisabled.testLackEnoughLiveInstances(org.apache.helix.integration.rebalancer.CrushRebalancers.TestCrushAutoRebalanceTopoplogyAwareDisable
   d)
   [ERROR]   Run 1: TestCrushAutoRebalanceTopoplogyAwareDisabled.testLackEnoughLiveInstances:79->TestCrushAutoRebalanceNonRack.testLackEnoughLiveInstances:233->TestCrushAutoRebalanceNonRack.validateIsolation:313 expected:<2> but was:<1>
   [INFO]   Run 2: PASS
   [INFO] 
   [ERROR]   TestRebalanceRunningTask.testFixedTargetTaskAndEnabledRebalanceAndNodeAdded:330 expected:<true> but was:<false>
   [ERROR]   TestClusterStateVerifier.afterMethod:98 » IllegalState ZkClient already closed...
   [ERROR]   TestClusterStateVerifier.testResourceSubset:115 » Helix Failed to create pause...
   [INFO] 
   [ERROR] Tests run: 1152, Failures: 5, Errors: 0, Skipped: 1
   [INFO] 
   [INFO] ------------------------------------------------------------------------
   [INFO] BUILD FAILURE
   [INFO] ------------------------------------------------------------------------
   [INFO] Total time:  01:12 h
   [INFO] Finished at: 2020-07-14T12:35:34-07:00
   [INFO] ------------------------------------------------------------------------
   ```
   Rerun
   ```
   [INFO] Tests run: 8, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 50.657 s - in TestSuite
   [INFO] 
   [INFO] Results:
   [INFO] 
   [INFO] Tests run: 8, Failures: 0, Errors: 0, Skipped: 0
   [INFO] 
   [INFO] ------------------------------------------------------------------------
   [INFO] BUILD SUCCESS
   [INFO] ------------------------------------------------------------------------
   [INFO] Total time:  55.640 s
   [INFO] Finished at: 2020-07-14T13:18:26-07:00
   [INFO] ------------------------------------------------------------------------
   ```
   
   ### Commits
   
   - [x] My commits all reference appropriate Apache Helix GitHub issues in their subject lines. In addition, my commits follow the guidelines from "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)":
     1. Subject is separated from body by a blank line
     1. Subject is limited to 50 characters (not including Jira issue reference)
     1. Subject does not end with a period
     1. Subject uses the imperative mood ("add", not "adding")
     1. Body wraps at 72 characters
     1. Body explains "what" and "why", not "how"
   
   ### Code Quality
   
   - [x] My diff has been formatted using helix-style.xml 
   (helix-style-intellij.xml if IntelliJ IDE is used)
   


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] NealSun96 commented on a change in pull request #1151: Fix enableWagedRebalance by respecting resource names argument

Posted by GitBox <gi...@apache.org>.
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] jiajunwang commented on a change in pull request #1151: Fix enableWagedRebalance by respecting resource names argument

Posted by GitBox <gi...@apache.org>.
jiajunwang commented on a change in pull request #1151:
URL: https://github.com/apache/helix/pull/1151#discussion_r454664554



##########
File path: helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java
##########
@@ -1861,23 +1861,25 @@ public boolean enableWagedRebalance(String clusterName, List<String> resourceNam
     HelixDataAccessor accessor =
         new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<>(_zkClient));
     PropertyKey.Builder keyBuilder = accessor.keyBuilder();
-    List<IdealState> idealStates = accessor.getChildValues(keyBuilder.idealStates(), true);
+    List<IdealState> idealStates = new ArrayList<>();
+    List<PropertyKey> idealStateKeys = new ArrayList<>();
     List<String> nullIdealStates = new ArrayList<>();

Review comment:
       I don't think we need this list, just throw the exception on the first null IS.

##########
File path: helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java
##########
@@ -1861,23 +1861,25 @@ public boolean enableWagedRebalance(String clusterName, List<String> resourceNam
     HelixDataAccessor accessor =
         new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<>(_zkClient));
     PropertyKey.Builder keyBuilder = accessor.keyBuilder();
-    List<IdealState> idealStates = accessor.getChildValues(keyBuilder.idealStates(), true);
+    List<IdealState> idealStates = new ArrayList<>();
+    List<PropertyKey> idealStateKeys = new ArrayList<>();
     List<String> nullIdealStates = new ArrayList<>();
-    for (int i = 0; i < idealStates.size(); i++) {
-      if (idealStates.get(i) == null) {
-        nullIdealStates.add(resourceNames.get(i));
+    for (String resourceName : resourceNames) {
+      PropertyKey key = keyBuilder.idealStates(resourceName);
+      IdealState idealState = accessor.getProperty(key);

Review comment:
       The original batch call is more efficient. Why do we want to change it?
   You can still iterate the returned IS list but filter by the resourceNames list. Then check if any item in the resourceNames but not in the returned IS list.




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] NealSun96 commented on a change in pull request #1151: Fix enableWagedRebalance by respecting resource names argument

Posted by GitBox <gi...@apache.org>.
NealSun96 commented on a change in pull request #1151:
URL: https://github.com/apache/helix/pull/1151#discussion_r454670893



##########
File path: helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java
##########
@@ -1861,23 +1861,25 @@ public boolean enableWagedRebalance(String clusterName, List<String> resourceNam
     HelixDataAccessor accessor =
         new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<>(_zkClient));
     PropertyKey.Builder keyBuilder = accessor.keyBuilder();
-    List<IdealState> idealStates = accessor.getChildValues(keyBuilder.idealStates(), true);
+    List<IdealState> idealStates = new ArrayList<>();
+    List<PropertyKey> idealStateKeys = new ArrayList<>();
     List<String> nullIdealStates = new ArrayList<>();
-    for (int i = 0; i < idealStates.size(); i++) {
-      if (idealStates.get(i) == null) {
-        nullIdealStates.add(resourceNames.get(i));
+    for (String resourceName : resourceNames) {
+      PropertyKey key = keyBuilder.idealStates(resourceName);
+      IdealState idealState = accessor.getProperty(key);

Review comment:
       I agree, okay. 




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] jiajunwang commented on a change in pull request #1151: Fix enableWagedRebalance by respecting resource names argument

Posted by GitBox <gi...@apache.org>.
jiajunwang commented on a change in pull request #1151:
URL: https://github.com/apache/helix/pull/1151#discussion_r454690430



##########
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<>();

Review comment:
       nit, use Set so the contains check is faster.

##########
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:
       if (!enabledResourceNames.containsAll(resourceNames)) {
   throw
   }




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] jiajunwang commented on a change in pull request #1151: Fix enableWagedRebalance by respecting resource names argument

Posted by GitBox <gi...@apache.org>.
jiajunwang commented on a change in pull request #1151:
URL: https://github.com/apache/helix/pull/1151#discussion_r455238816



##########
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:
       Make sense.




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] NealSun96 commented on pull request #1151: Fix enableWagedRebalance by respecting resource names argument

Posted by GitBox <gi...@apache.org>.
NealSun96 commented on pull request #1151:
URL: https://github.com/apache/helix/pull/1151#issuecomment-658927619


   This PR is ready to be merged, approved by @jiajunwang   
   Final commit message:
   ## Fix enableWagedRebalance by respecting resource names argument ##
   enableWagedRebalance() is not currently respecting the resource names that are passed to it - it's enabling waged for all resources, which isn't correct. The fix is to only enable waged for the provided resource names.


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] jiajunwang merged pull request #1151: Fix enableWagedRebalance by respecting resource names argument

Posted by GitBox <gi...@apache.org>.
jiajunwang merged pull request #1151:
URL: https://github.com/apache/helix/pull/1151


   


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org