This is an automated email from the ASF dual-hosted git repository.

jxue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/helix.git


The following commit(s) were added to refs/heads/master by this push:
     new 0740cac  Exclude ANY_INSTANCE for customized sibling checks
0740cac is described below

commit 0740cac595148fbf2f64adb461f7721422bcff9a
Author: Junkai Xue <[email protected]>
AuthorDate: Tue Jul 9 16:38:10 2019 -0700

    Exclude ANY_INSTANCE for customized sibling checks
    
    Current Helix HealthCheck API checks the ANY_INSTANCE resources, which is 
not necessary. Since ANY_INSTANCE resources only have single partition with 1 
replica, there is no need to check sibling health status.
    
    This commit fixes issue #328
---
 .../src/main/java/org/apache/helix/model/ExternalView.java    | 11 ++++++++++-
 .../java/org/apache/helix/util/InstanceValidationUtil.java    |  8 ++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/helix-core/src/main/java/org/apache/helix/model/ExternalView.java 
b/helix-core/src/main/java/org/apache/helix/model/ExternalView.java
index aba8d85..efe6b4d 100644
--- a/helix-core/src/main/java/org/apache/helix/model/ExternalView.java
+++ b/helix-core/src/main/java/org/apache/helix/model/ExternalView.java
@@ -40,7 +40,8 @@ public class ExternalView extends HelixProperty {
     RESOURCE_GROUP_NAME,
     GROUP_ROUTING_ENABLED,
     MIN_ACTIVE_REPLICAS,
-    STATE_MODEL_DEF_REF
+    STATE_MODEL_DEF_REF,
+    REPLICAS
   }
 
   /**
@@ -150,6 +151,14 @@ public class ExternalView extends HelixProperty {
     return 
_record.getSimpleField(ExternalViewProperty.STATE_MODEL_DEF_REF.toString());
   }
 
+  /**
+   * Get the number of replicas for each partition of this resource
+   * @return number of replicas (as a string)
+   */
+  public String getReplicas() {
+    return _record.getSimpleField(ExternalViewProperty.REPLICAS.name());
+  }
+
   @Override
   public boolean isValid() {
     return true;
diff --git 
a/helix-core/src/main/java/org/apache/helix/util/InstanceValidationUtil.java 
b/helix-core/src/main/java/org/apache/helix/util/InstanceValidationUtil.java
index dfc775d..30b733d 100644
--- a/helix-core/src/main/java/org/apache/helix/util/InstanceValidationUtil.java
+++ b/helix-core/src/main/java/org/apache/helix/util/InstanceValidationUtil.java
@@ -35,6 +35,7 @@ import org.apache.helix.model.ExternalView;
 import org.apache.helix.model.IdealState;
 import org.apache.helix.model.InstanceConfig;
 import org.apache.helix.model.LiveInstance;
+import org.apache.helix.model.ResourceConfig;
 import org.apache.helix.model.StateModelDefinition;
 import org.apache.helix.task.TaskConstants;
 import org.slf4j.Logger;
@@ -210,6 +211,13 @@ public class InstanceValidationUtil {
     List<String> unhealthyPartitions = new ArrayList<>();
 
     for (ExternalView externalView : externalViews) {
+      // Skip ANY_LIVEINSTANCES resources check, since ANY_LIVEINSTANCES 
resources have single partition
+      // with 1 replica. There is no need to check sibiling replicas.
+      if (ResourceConfig.ResourceConfigConstants.ANY_LIVEINSTANCE.name()
+          .equals(externalView.getReplicas())) {
+        continue;
+      }
+
       StateModelDefinition stateModelDefinition = dataAccessor
           
.getProperty(dataAccessor.keyBuilder().stateModelDef(externalView.getStateModelDefRef()));
       for (String partition : externalView.getPartitionSet()) {

Reply via email to