helix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zzh...@apache.org
Subject helix git commit: [HELIX-587] Fix NPE in ClusterStateVerifier, rb=32344
Date Sat, 21 Mar 2015 04:31:00 GMT
Repository: helix
Updated Branches:
  refs/heads/helix-0.6.x e924a4c4e -> 516faa0c5


[HELIX-587] Fix NPE in ClusterStateVerifier, rb=32344


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

Branch: refs/heads/helix-0.6.x
Commit: 516faa0c504c807bbc9133694998f227e8e0d114
Parents: e924a4c
Author: zzhang <zzhang@apache.org>
Authored: Fri Mar 20 21:30:48 2015 -0700
Committer: zzhang <zzhang@apache.org>
Committed: Fri Mar 20 21:30:48 2015 -0700

----------------------------------------------------------------------
 .../apache/helix/tools/ClusterStateVerifier.java    | 16 ++++++++++++----
 .../task/TestTaskRebalancerStopResume.java          | 14 ++++++++++----
 2 files changed, 22 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/helix/blob/516faa0c/helix-core/src/main/java/org/apache/helix/tools/ClusterStateVerifier.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/tools/ClusterStateVerifier.java b/helix-core/src/main/java/org/apache/helix/tools/ClusterStateVerifier.java
index 1428896..473a4df 100644
--- a/helix-core/src/main/java/org/apache/helix/tools/ClusterStateVerifier.java
+++ b/helix-core/src/main/java/org/apache/helix/tools/ClusterStateVerifier.java
@@ -61,6 +61,7 @@ import org.apache.helix.model.ExternalView;
 import org.apache.helix.model.IdealState;
 import org.apache.helix.model.Partition;
 import org.apache.helix.model.Resource;
+import org.apache.helix.task.TaskConstants;
 import org.apache.helix.util.ZKClientPool;
 import org.apache.log4j.Logger;
 
@@ -255,15 +256,22 @@ public class ClusterStateVerifier {
       cache.refresh(accessor);
 
       Map<String, IdealState> idealStates = cache.getIdealStates();
-      if (idealStates == null) // || idealStates.isEmpty())
-      {
+      if (idealStates == null) {
         // ideal state is null because ideal state is dropped
         idealStates = Collections.emptyMap();
       }
 
+      // filter out all resources that use Task state model
+      Iterator it = idealStates.entrySet().iterator();
+      while (it.hasNext()) {
+        Map.Entry<String, IdealState> pair = (Map.Entry<String, IdealState>)it.next();
+        if (pair.getValue().getStateModelDefRef().equals(TaskConstants.STATE_MODEL_NAME))
{
+          it.remove();
+        }
+      }
+
       Map<String, ExternalView> extViews = accessor.getChildValuesMap(keyBuilder.externalViews());
-      if (extViews == null) // || extViews.isEmpty())
-      {
+      if (extViews == null) {
         extViews = Collections.emptyMap();
       }
 

http://git-wip-us.apache.org/repos/asf/helix/blob/516faa0c/helix-core/src/test/java/org/apache/helix/integration/task/TestTaskRebalancerStopResume.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/task/TestTaskRebalancerStopResume.java
b/helix-core/src/test/java/org/apache/helix/integration/task/TestTaskRebalancerStopResume.java
index e75e2c9..aed4088 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/task/TestTaskRebalancerStopResume.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/task/TestTaskRebalancerStopResume.java
@@ -373,8 +373,7 @@ public class TestTaskRebalancerStopResume extends ZkIntegrationTestBase
{
   {
     Map<String, String> cfgMap = new HashMap<String, String>();
     cfgMap.put(WorkflowConfig.EXPIRY, String.valueOf(50000));
-    cfgMap.put(WorkflowConfig.START_TIME, WorkflowConfig.getDefaultDateFormat().format(
-        Calendar.getInstance().getTime()));
+    cfgMap.put(WorkflowConfig.START_TIME, WorkflowConfig.getDefaultDateFormat().format(Calendar.getInstance().getTime()));
     cfgMap.put(WorkflowConfig.RECURRENCE_INTERVAL, String.valueOf(60));
     cfgMap.put(WorkflowConfig.RECURRENCE_UNIT, "SECONDS");
     return (new JobQueue.Builder(jobQueueName).fromMap(cfgMap)).build();
@@ -503,12 +502,19 @@ public class TestTaskRebalancerStopResume extends ZkIntegrationTestBase
{
     String namespacedJob2 = String.format("%s_%s", queueName,  job2Name);
     TestUtil.pollForJobState(_manager, queueName, namespacedJob2, TaskState.COMPLETED);
 
-    // Stop and delete queue
+    // Stop queue
     _driver.stop(queueName);
+
+    boolean result =
+        ClusterStateVerifier.verifyByPolling(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(
+            ZK_ADDR, CLUSTER_NAME));
+    Assert.assertTrue(result);
+
+    // Delete queue
     _driver.delete(queueName);
 
     // Wait until all status are cleaned up
-    boolean result = TestHelper.verify(new TestHelper.Verifier() {
+    result = TestHelper.verify(new TestHelper.Verifier() {
       @Override public boolean verify() throws Exception {
         HelixDataAccessor accessor = _manager.getHelixDataAccessor();
         PropertyKey.Builder keyBuilder = accessor.keyBuilder();


Mime
View raw message