helix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hu...@apache.org
Subject [helix] 13/44: Fix faulty logic in BestPossibleExternalViewVerifier
Date Sat, 25 May 2019 01:19:47 GMT
This is an automated email from the ASF dual-hosted git repository.

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

commit 4e5884d9e88ad55eeecbeb2db9830cef0539e082
Author: Hunter Lee <hulee@linkedin.com>
AuthorDate: Wed Apr 3 17:12:56 2019 -0700

    Fix faulty logic in BestPossibleExternalViewVerifier
    
    removeEntryWithIgnoredStates() was not really doing what it was supposed to do. This diff
fixes this.
    Also, a small delay added to make TestDrop more stable.
    
    RB=1619153
    G=helix-reviewers
    A=jxue
    
    Signed-off-by: Hunter Lee <hulee@linkedin.com>
---
 .../BestPossibleExternalViewVerifier.java               | 17 ++++++++---------
 .../java/org/apache/helix/integration/TestDrop.java     |  3 ++-
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/helix-core/src/main/java/org/apache/helix/tools/ClusterVerifiers/BestPossibleExternalViewVerifier.java
b/helix-core/src/main/java/org/apache/helix/tools/ClusterVerifiers/BestPossibleExternalViewVerifier.java
index 77cbcca..74b9b3c 100644
--- a/helix-core/src/main/java/org/apache/helix/tools/ClusterVerifiers/BestPossibleExternalViewVerifier.java
+++ b/helix-core/src/main/java/org/apache/helix/tools/ClusterVerifiers/BestPossibleExternalViewVerifier.java
@@ -330,17 +330,16 @@ public class BestPossibleExternalViewVerifier extends ZkHelixClusterVerifier
{
     while (partitionInstanceStateMapIter.hasNext()) {
       Map.Entry<String, Map<String, String>> entry = partitionInstanceStateMapIter.next();
       Map<String, String> instanceStateMap = entry.getValue();
+      // remove instances with DROPPED and OFFLINE state
+      Iterator<Map.Entry<String, String>> insIter = instanceStateMap.entrySet().iterator();
+      while (insIter.hasNext()) {
+        String state = insIter.next().getValue();
+        if (ignoredStates.contains(state)) {
+          insIter.remove();
+        }
+      }
       if (instanceStateMap.isEmpty()) {
         partitionInstanceStateMapIter.remove();
-      } else {
-        // remove instances with DROPPED and OFFLINE state
-        Iterator<Map.Entry<String, String>> insIter = instanceStateMap.entrySet().iterator();
-        while (insIter.hasNext()) {
-          String state = insIter.next().getValue();
-          if (ignoredStates.contains(state)) {
-            insIter.remove();
-          }
-        }
       }
     }
   }
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestDrop.java b/helix-core/src/test/java/org/apache/helix/integration/TestDrop.java
index 54515af..7d4972d 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestDrop.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestDrop.java
@@ -262,7 +262,8 @@ public class TestDrop extends ZkTestBase {
     Assert.assertEquals(disabledPartitions.size(), 1, "TestDB0_4 should be disabled");
     Assert.assertEquals(disabledPartitions.get(0), "TestDB0_4");
 
-    // ExteranlView should have TestDB0_4->localhost_12918_>ERROR
+    // ExternalView should have TestDB0_4->localhost_12918_>ERROR
+    Thread.sleep(100L);
     ExternalView ev = accessor.getProperty(keyBuilder.externalView("TestDB0"));
     Set<String> partitions = ev.getPartitionSet();
     Assert.assertEquals(partitions.size(), 1, "Should have TestDB0_4->localhost_12918->ERROR");


Mime
View raw message