helix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l...@apache.org
Subject [36/38] helix git commit: Fix a bug in BestPossibleExternalViewVerifier.
Date Wed, 08 Feb 2017 18:00:11 GMT
Fix a bug in BestPossibleExternalViewVerifier.


Project: http://git-wip-us.apache.org/repos/asf/helix/repo
Commit: http://git-wip-us.apache.org/repos/asf/helix/commit/df215edb
Tree: http://git-wip-us.apache.org/repos/asf/helix/tree/df215edb
Diff: http://git-wip-us.apache.org/repos/asf/helix/diff/df215edb

Branch: refs/heads/helix-0.6.x
Commit: df215edb63551b24a73a4995dfc0579a800ea757
Parents: 65cb316
Author: Lei Xia <lxia@linkedin.com>
Authored: Thu Nov 3 14:13:42 2016 -0700
Committer: Lei Xia <lxia@linkedin.com>
Committed: Wed Feb 8 09:57:59 2017 -0800

----------------------------------------------------------------------
 .../BestPossibleExternalViewVerifier.java          | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/helix/blob/df215edb/helix-core/src/main/java/org/apache/helix/tools/ClusterStateVerifier/BestPossibleExternalViewVerifier.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/tools/ClusterStateVerifier/BestPossibleExternalViewVerifier.java
b/helix-core/src/main/java/org/apache/helix/tools/ClusterStateVerifier/BestPossibleExternalViewVerifier.java
index 970973c..e1d660c 100644
--- a/helix-core/src/main/java/org/apache/helix/tools/ClusterStateVerifier/BestPossibleExternalViewVerifier.java
+++ b/helix-core/src/main/java/org/apache/helix/tools/ClusterStateVerifier/BestPossibleExternalViewVerifier.java
@@ -20,6 +20,7 @@ package org.apache.helix.tools.ClusterStateVerifier;
  */
 
 import org.apache.helix.HelixDefinedState;
+import org.apache.helix.HelixException;
 import org.apache.helix.PropertyKey;
 import org.apache.helix.controller.pipeline.Stage;
 import org.apache.helix.controller.pipeline.StageContext;
@@ -31,7 +32,6 @@ import org.apache.helix.controller.stages.ClusterEvent;
 import org.apache.helix.controller.stages.CurrentStateComputationStage;
 import org.apache.helix.controller.stages.ResourceComputationStage;
 import org.apache.helix.manager.zk.ZkClient;
-import org.apache.helix.model.BuiltInStateModelDefinitions;
 import org.apache.helix.model.ExternalView;
 import org.apache.helix.model.IdealState;
 import org.apache.helix.model.Partition;
@@ -269,7 +269,14 @@ public class BestPossibleExternalViewVerifier extends ZkHelixClusterVerifier
{
         Map<Partition, Map<String, String>> bpStateMap =
             bestPossOutput.getResourceMap(resourceName);
 
-        boolean result = verifyExternalView(is, extView, bpStateMap);
+        StateModelDefinition stateModelDef = cache.getStateModelDef(is.getStateModelDefRef());
+        if (stateModelDef == null) {
+          throw new HelixException(
+              "State model definition " + is.getStateModelDefRef() + " for resource not found!"
+ is
+                  .getResourceName());
+        }
+
+        boolean result = verifyExternalView(is, extView, bpStateMap, stateModelDef);
         if (!result) {
           LOG.debug("verifyExternalView fails! ExternalView: " + extView + " BestPossibleState:
"
               + bpStateMap);
@@ -284,11 +291,7 @@ public class BestPossibleExternalViewVerifier extends ZkHelixClusterVerifier
{
   }
 
   private boolean verifyExternalView(IdealState idealState, ExternalView externalView,
-      Map<Partition, Map<String, String>> bestPossibleState) {
-
-    StateModelDefinition stateModelDef =
-        BuiltInStateModelDefinitions.valueOf(idealState.getStateModelDefRef())
-            .getStateModelDefinition();
+      Map<Partition, Map<String, String>> bestPossibleState, StateModelDefinition
stateModelDef) {
     Set<String> ignoreStaes = new HashSet<String>(
         Arrays.asList(stateModelDef.getInitialState(), HelixDefinedState.DROPPED.toString()));
 


Mime
View raw message