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 2022/04/11 22:46:36 UTC

[GitHub] [helix] qqu0127 opened a new pull request, #2032: Code refactor and cleanup on instance validation

qqu0127 opened a new pull request, #2032:
URL: https://github.com/apache/helix/pull/2032

   ### Issues
   
   - [X] My PR addresses the following Helix issues and references them in the PR description:
   https://github.com/apache/helix/issues/2022 
   
   ### Description
   
   - [X] Here are some details about my PR, including screenshots of any UI changes:
   Cleanup the usage in checking instance enable/disable using InstanceValidationUtil
   
   ### Tests
   
   - [ ] The following tests are written for this issue:
   
   (List the names of added unit/integration tests)
   
   - The following is the result of the "mvn test" command on the appropriate module:
   
   (If CI test fails due to known issue, please specify the issue and test PR locally. Then copy & paste the result of "mvn test" to here.)
   
   ### Changes that Break Backward Compatibility (Optional)
   
   - My PR contains changes that break backward compatibility or previous assumptions for certain methods or API. They include:
   
   (Consider including all behavior changes for public methods or API. Also include these changes in merge description so that other developers are aware of these changes. This allows them to make relevant code changes in feature branches accounting for the new method/API behavior.)
   
   ### Documentation (Optional)
   
   - In case of new functionality, my PR adds documentation in the following wiki page:
   
   (Link the GitHub wiki you added)
   
   ### Commits
   
   - 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
   
   - 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.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

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] qqu0127 commented on a diff in pull request #2032: Code refactor and cleanup on instance validation

Posted by GitBox <gi...@apache.org>.
qqu0127 commented on code in PR #2032:
URL: https://github.com/apache/helix/pull/2032#discussion_r848841908


##########
helix-core/src/main/java/org/apache/helix/controller/dataproviders/BaseControllerDataProvider.java:
##########
@@ -798,25 +799,18 @@ private void updateDisabledInstances(Collection<InstanceConfig> instanceConfigs,
     _disabledInstanceSet.clear();
     for (InstanceConfig config : instanceConfigs) {
       Map<String, List<String>> disabledPartitionMap = config.getDisabledPartitionsMap();
-      if (!config.getInstanceEnabled()) {
+      if (!InstanceValidationUtil.isInstanceEnabled(config, clusterConfig)) {

Review Comment:
   I think it's cleaner to have a unified way to do such check.



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

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] xyuanlu commented on a diff in pull request #2032: Code refactor and cleanup on instance validation

Posted by GitBox <gi...@apache.org>.
xyuanlu commented on code in PR #2032:
URL: https://github.com/apache/helix/pull/2032#discussion_r848946412


##########
helix-core/src/main/java/org/apache/helix/controller/rebalancer/util/DelayedRebalanceUtil.java:
##########
@@ -137,14 +138,13 @@ private static long getInactiveTime(String instance, Set<String> liveInstances,
     }
 
     // check the time instance got disabled.
-    if (!instanceConfig.getInstanceEnabled() || (clusterConfig.getDisabledInstances() != null
-        && clusterConfig.getDisabledInstances().containsKey(instance))) {
+    if (!InstanceValidationUtil.isInstanceEnabled(instanceConfig, clusterConfig)) {
       long disabledTime = instanceConfig.getInstanceEnabledTime();
-      if (clusterConfig.getDisabledInstances() != null && clusterConfig.getDisabledInstances()
-          .containsKey(instance)) {
+      Map<String, String> disabledInstances = clusterConfig.getDisabledInstances();
+      if (disabledInstances.containsKey(instance)) {

Review Comment:
   Here we read from clusterConfig to get getDisabledInstances and parse target instance's disabled info to get timestamp. 
   There is a getter in clusterConfig to get disabled time (getInstanceHelixDisabledTimeStamp). We could use that directly. 



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

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] narendly commented on a diff in pull request #2032: Code refactor and cleanup on instance validation

Posted by GitBox <gi...@apache.org>.
narendly commented on code in PR #2032:
URL: https://github.com/apache/helix/pull/2032#discussion_r848711246


##########
helix-core/src/main/java/org/apache/helix/controller/dataproviders/BaseControllerDataProvider.java:
##########
@@ -798,25 +799,18 @@ private void updateDisabledInstances(Collection<InstanceConfig> instanceConfigs,
     _disabledInstanceSet.clear();
     for (InstanceConfig config : instanceConfigs) {
       Map<String, List<String>> disabledPartitionMap = config.getDisabledPartitionsMap();
-      if (!config.getInstanceEnabled()) {
+      if (!InstanceValidationUtil.isInstanceEnabled(config, clusterConfig)) {
         _disabledInstanceSet.add(config.getInstanceName());
       }
       for (String resource : disabledPartitionMap.keySet()) {
-        if (!_disabledInstanceForPartitionMap.containsKey(resource)) {
-          _disabledInstanceForPartitionMap.put(resource, new HashMap<>());
-        }
+        _disabledInstanceForPartitionMap.putIfAbsent(resource, new HashMap<>());
         for (String partition : disabledPartitionMap.get(resource)) {
-          if (!_disabledInstanceForPartitionMap.get(resource).containsKey(partition)) {
-            _disabledInstanceForPartitionMap.get(resource).put(partition, new HashSet<>());
-          }
-          _disabledInstanceForPartitionMap.get(resource).get(partition)
+          _disabledInstanceForPartitionMap.get(resource)
+              .computeIfAbsent(partition, key -> new HashSet<>())
               .add(config.getInstanceName());
         }
       }
     }
-    if (clusterConfig != null && clusterConfig.getDisabledInstances() != null) {
-      _disabledInstanceSet.addAll(clusterConfig.getDisabledInstances().keySet());
-    }

Review Comment:
   Is this no longer needed?



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

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] qqu0127 commented on a diff in pull request #2032: Code refactor and cleanup on instance validation

Posted by GitBox <gi...@apache.org>.
qqu0127 commented on code in PR #2032:
URL: https://github.com/apache/helix/pull/2032#discussion_r848893664


##########
helix-core/src/main/java/org/apache/helix/controller/rebalancer/util/DelayedRebalanceUtil.java:
##########
@@ -137,14 +138,13 @@ private static long getInactiveTime(String instance, Set<String> liveInstances,
     }
 
     // check the time instance got disabled.
-    if (!instanceConfig.getInstanceEnabled() || (clusterConfig.getDisabledInstances() != null
-        && clusterConfig.getDisabledInstances().containsKey(instance))) {
+    if (!InstanceValidationUtil.isInstanceEnabled(instanceConfig, clusterConfig)) {
       long disabledTime = instanceConfig.getInstanceEnabledTime();
-      if (clusterConfig.getDisabledInstances() != null && clusterConfig.getDisabledInstances()
-          .containsKey(instance)) {
+      Map<String, String> disabledInstances = clusterConfig.getDisabledInstances();
+      if (disabledInstances.containsKey(instance)) {

Review Comment:
   Could you please elaborate? What specifically are you proposing to change?



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

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] narendly commented on a diff in pull request #2032: Code refactor and cleanup on instance validation

Posted by GitBox <gi...@apache.org>.
narendly commented on code in PR #2032:
URL: https://github.com/apache/helix/pull/2032#discussion_r848701300


##########
helix-core/src/main/java/org/apache/helix/util/InstanceValidationUtil.java:
##########
@@ -138,12 +149,10 @@ public static boolean isAlive(HelixDataAccessor dataAccessor, String instanceNam
    * Method to check if the instance is assigned at least 1 resource, not in a idle state;
    * Independent of the instance alive/enabled status
    * @param dataAccessor
-   * @param clusterId
    * @param instanceName
    * @return
    */
-  public static boolean hasResourceAssigned(HelixDataAccessor dataAccessor, String clusterId,
-      String instanceName) {
+  public static boolean hasResourceAssigned(HelixDataAccessor dataAccessor, String instanceName) {

Review Comment:
   Since this is a public method, can we consider deprecating it and re-creating the version without `clusterId` as an argument?
   
   Also, I suggest fixing up the method name to `hasResourceBeenAssigned()`?



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

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] narendly commented on a diff in pull request #2032: Code refactor and cleanup on instance validation

Posted by GitBox <gi...@apache.org>.
narendly commented on code in PR #2032:
URL: https://github.com/apache/helix/pull/2032#discussion_r848701300


##########
helix-core/src/main/java/org/apache/helix/util/InstanceValidationUtil.java:
##########
@@ -138,12 +149,10 @@ public static boolean isAlive(HelixDataAccessor dataAccessor, String instanceNam
    * Method to check if the instance is assigned at least 1 resource, not in a idle state;
    * Independent of the instance alive/enabled status
    * @param dataAccessor
-   * @param clusterId
    * @param instanceName
    * @return
    */
-  public static boolean hasResourceAssigned(HelixDataAccessor dataAccessor, String clusterId,
-      String instanceName) {
+  public static boolean hasResourceAssigned(HelixDataAccessor dataAccessor, String instanceName) {

Review Comment:
   Since this is a public method, can we consider deprecating it and re-creating the version without `clusterId` as an argument?



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

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] qqu0127 commented on a diff in pull request #2032: Code refactor and cleanup on instance validation

Posted by GitBox <gi...@apache.org>.
qqu0127 commented on code in PR #2032:
URL: https://github.com/apache/helix/pull/2032#discussion_r848963453


##########
helix-core/src/main/java/org/apache/helix/controller/rebalancer/util/DelayedRebalanceUtil.java:
##########
@@ -137,14 +138,13 @@ private static long getInactiveTime(String instance, Set<String> liveInstances,
     }
 
     // check the time instance got disabled.
-    if (!instanceConfig.getInstanceEnabled() || (clusterConfig.getDisabledInstances() != null
-        && clusterConfig.getDisabledInstances().containsKey(instance))) {
+    if (!InstanceValidationUtil.isInstanceEnabled(instanceConfig, clusterConfig)) {
       long disabledTime = instanceConfig.getInstanceEnabledTime();
-      if (clusterConfig.getDisabledInstances() != null && clusterConfig.getDisabledInstances()
-          .containsKey(instance)) {
+      Map<String, String> disabledInstances = clusterConfig.getDisabledInstances();
+      if (disabledInstances.containsKey(instance)) {

Review Comment:
   Thanks, updated



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

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] qqu0127 commented on a diff in pull request #2032: Code refactor and cleanup on instance validation

Posted by GitBox <gi...@apache.org>.
qqu0127 commented on code in PR #2032:
URL: https://github.com/apache/helix/pull/2032#discussion_r848842667


##########
helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java:
##########
@@ -1928,10 +1928,7 @@ public ZNRecord update(ZNRecord currentData) {
         }
 
         ClusterConfig clusterConfig = new ClusterConfig(currentData);
-        Map<String, String> disabledInstances = new TreeMap<>();
-        if (clusterConfig.getDisabledInstances() != null) {
-          disabledInstances.putAll(clusterConfig.getDisabledInstances());
-        }

Review Comment:
   Could you clarify? I don't think any logic is removed from here.



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

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] narendly commented on a diff in pull request #2032: Code refactor and cleanup on instance validation

Posted by GitBox <gi...@apache.org>.
narendly commented on code in PR #2032:
URL: https://github.com/apache/helix/pull/2032#discussion_r848701300


##########
helix-core/src/main/java/org/apache/helix/util/InstanceValidationUtil.java:
##########
@@ -138,12 +149,10 @@ public static boolean isAlive(HelixDataAccessor dataAccessor, String instanceNam
    * Method to check if the instance is assigned at least 1 resource, not in a idle state;
    * Independent of the instance alive/enabled status
    * @param dataAccessor
-   * @param clusterId
    * @param instanceName
    * @return
    */
-  public static boolean hasResourceAssigned(HelixDataAccessor dataAccessor, String clusterId,
-      String instanceName) {
+  public static boolean hasResourceAssigned(HelixDataAccessor dataAccessor, String instanceName) {

Review Comment:
   Since this is a public method, can we consider deprecating it and re-creating the version without `clusterId` as an argument?
   
   Also, I suggest fixing up the method name to `hasResourceBeenAssigned()` or `isResourceAssigned()`?



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

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] narendly merged pull request #2032: Code refactor and cleanup on instance validation

Posted by GitBox <gi...@apache.org>.
narendly merged PR #2032:
URL: https://github.com/apache/helix/pull/2032


-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

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] junkaixue commented on a diff in pull request #2032: Code refactor and cleanup on instance validation

Posted by GitBox <gi...@apache.org>.
junkaixue commented on code in PR #2032:
URL: https://github.com/apache/helix/pull/2032#discussion_r848838290


##########
helix-core/src/main/java/org/apache/helix/controller/dataproviders/BaseControllerDataProvider.java:
##########
@@ -798,25 +799,18 @@ private void updateDisabledInstances(Collection<InstanceConfig> instanceConfigs,
     _disabledInstanceSet.clear();
     for (InstanceConfig config : instanceConfigs) {
       Map<String, List<String>> disabledPartitionMap = config.getDisabledPartitionsMap();
-      if (!config.getInstanceEnabled()) {
+      if (!InstanceValidationUtil.isInstanceEnabled(config, clusterConfig)) {

Review Comment:
   Why we need to move the logic to the Util?



##########
helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java:
##########
@@ -1928,10 +1928,7 @@ public ZNRecord update(ZNRecord currentData) {
         }
 
         ClusterConfig clusterConfig = new ClusterConfig(currentData);
-        Map<String, String> disabledInstances = new TreeMap<>();
-        if (clusterConfig.getDisabledInstances() != null) {
-          disabledInstances.putAll(clusterConfig.getDisabledInstances());
-        }

Review Comment:
   If we remove this logic, we may lose the meaning of using updater.



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

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] qqu0127 commented on a diff in pull request #2032: Code refactor and cleanup on instance validation

Posted by GitBox <gi...@apache.org>.
qqu0127 commented on code in PR #2032:
URL: https://github.com/apache/helix/pull/2032#discussion_r849990457


##########
helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java:
##########
@@ -1928,10 +1928,7 @@ public ZNRecord update(ZNRecord currentData) {
         }
 
         ClusterConfig clusterConfig = new ClusterConfig(currentData);
-        Map<String, String> disabledInstances = new TreeMap<>();
-        if (clusterConfig.getDisabledInstances() != null) {
-          disabledInstances.putAll(clusterConfig.getDisabledInstances());
-        }

Review Comment:
   It's properly handled, see https://github.com/apache/helix/pull/2032/files#diff-8af2a416d09c30beedc9f110edd51472c0331df5c3c46225fdd3901b3cdf6f5e, it's changed to non-null.



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

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] qqu0127 commented on pull request #2032: Code refactor and cleanup on instance validation

Posted by GitBox <gi...@apache.org>.
qqu0127 commented on PR #2032:
URL: https://github.com/apache/helix/pull/2032#issuecomment-1100235308

   This PR is ready to merge, approved by @junkaixue 
   Commit message:
   
   Code refactor and cleanup on instance validation
   Unify the usage of checking instance enable/disable using InstanceValidationUtil


-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

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] qqu0127 commented on a diff in pull request #2032: Code refactor and cleanup on instance validation

Posted by GitBox <gi...@apache.org>.
qqu0127 commented on code in PR #2032:
URL: https://github.com/apache/helix/pull/2032#discussion_r848770399


##########
helix-core/src/main/java/org/apache/helix/controller/dataproviders/BaseControllerDataProvider.java:
##########
@@ -798,25 +799,18 @@ private void updateDisabledInstances(Collection<InstanceConfig> instanceConfigs,
     _disabledInstanceSet.clear();
     for (InstanceConfig config : instanceConfigs) {
       Map<String, List<String>> disabledPartitionMap = config.getDisabledPartitionsMap();
-      if (!config.getInstanceEnabled()) {
+      if (!InstanceValidationUtil.isInstanceEnabled(config, clusterConfig)) {
         _disabledInstanceSet.add(config.getInstanceName());
       }
       for (String resource : disabledPartitionMap.keySet()) {
-        if (!_disabledInstanceForPartitionMap.containsKey(resource)) {
-          _disabledInstanceForPartitionMap.put(resource, new HashMap<>());
-        }
+        _disabledInstanceForPartitionMap.putIfAbsent(resource, new HashMap<>());
         for (String partition : disabledPartitionMap.get(resource)) {
-          if (!_disabledInstanceForPartitionMap.get(resource).containsKey(partition)) {
-            _disabledInstanceForPartitionMap.get(resource).put(partition, new HashSet<>());
-          }
-          _disabledInstanceForPartitionMap.get(resource).get(partition)
+          _disabledInstanceForPartitionMap.get(resource)
+              .computeIfAbsent(partition, key -> new HashSet<>())
               .add(config.getInstanceName());
         }
       }
     }
-    if (clusterConfig != null && clusterConfig.getDisabledInstances() != null) {
-      _disabledInstanceSet.addAll(clusterConfig.getDisabledInstances().keySet());
-    }

Review Comment:
   No longer needed. Everything related to instance disable is integrated into `InstanceValidationUtil.isInstanceEnabled`. It's done in a few lines above.



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

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] qqu0127 commented on a diff in pull request #2032: Code refactor and cleanup on instance validation

Posted by GitBox <gi...@apache.org>.
qqu0127 commented on code in PR #2032:
URL: https://github.com/apache/helix/pull/2032#discussion_r848770555


##########
helix-core/src/main/java/org/apache/helix/util/InstanceValidationUtil.java:
##########
@@ -138,12 +149,10 @@ public static boolean isAlive(HelixDataAccessor dataAccessor, String instanceNam
    * Method to check if the instance is assigned at least 1 resource, not in a idle state;
    * Independent of the instance alive/enabled status
    * @param dataAccessor
-   * @param clusterId
    * @param instanceName
    * @return
    */
-  public static boolean hasResourceAssigned(HelixDataAccessor dataAccessor, String clusterId,
-      String instanceName) {
+  public static boolean hasResourceAssigned(HelixDataAccessor dataAccessor, String instanceName) {

Review Comment:
   Good point, updated. Thanks.



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

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] qqu0127 commented on pull request #2032: Code refactor and cleanup on instance validation

Posted by GitBox <gi...@apache.org>.
qqu0127 commented on PR #2032:
URL: https://github.com/apache/helix/pull/2032#issuecomment-1096958055

   The change should be backward compatible, except for https://github.com/apache/helix/pull/2032/files#diff-ef5352bf131875871d12d83626aa897b49458df3eff2fd81638bc66e54deaea1, where previously didn't consider instance disabled in cluster config (batch disable). 


-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

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] junkaixue commented on a diff in pull request #2032: Code refactor and cleanup on instance validation

Posted by GitBox <gi...@apache.org>.
junkaixue commented on code in PR #2032:
URL: https://github.com/apache/helix/pull/2032#discussion_r848891055


##########
helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java:
##########
@@ -1928,10 +1928,7 @@ public ZNRecord update(ZNRecord currentData) {
         }
 
         ClusterConfig clusterConfig = new ClusterConfig(currentData);
-        Map<String, String> disabledInstances = new TreeMap<>();
-        if (clusterConfig.getDisabledInstances() != null) {
-          disabledInstances.putAll(clusterConfig.getDisabledInstances());
-        }

Review Comment:
   Sorry. I think I looked at wrong line. But what if getDisabledInstances() is null. Will this cause any exception for that?



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

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] xyuanlu commented on a diff in pull request #2032: Code refactor and cleanup on instance validation

Posted by GitBox <gi...@apache.org>.
xyuanlu commented on code in PR #2032:
URL: https://github.com/apache/helix/pull/2032#discussion_r848888358


##########
helix-core/src/main/java/org/apache/helix/controller/rebalancer/util/DelayedRebalanceUtil.java:
##########
@@ -137,14 +138,13 @@ private static long getInactiveTime(String instance, Set<String> liveInstances,
     }
 
     // check the time instance got disabled.
-    if (!instanceConfig.getInstanceEnabled() || (clusterConfig.getDisabledInstances() != null
-        && clusterConfig.getDisabledInstances().containsKey(instance))) {
+    if (!InstanceValidationUtil.isInstanceEnabled(instanceConfig, clusterConfig)) {
       long disabledTime = instanceConfig.getInstanceEnabledTime();
-      if (clusterConfig.getDisabledInstances() != null && clusterConfig.getDisabledInstances()
-          .containsKey(instance)) {
+      Map<String, String> disabledInstances = clusterConfig.getDisabledInstances();
+      if (disabledInstances.containsKey(instance)) {

Review Comment:
   We could use clusterConfig.getInstanceHelixDisabledTimeStamp() ?



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

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