helix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ka...@apache.org
Subject [1/3] git commit: [HELIX-394] Make cluster event thread a daemon thread
Date Fri, 07 Mar 2014 02:09:03 GMT
Repository: helix
Updated Branches:
  refs/heads/helix-0.6.2-release 304995e75 -> 24eacbc92


[HELIX-394] Make cluster event thread a daemon thread


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

Branch: refs/heads/helix-0.6.2-release
Commit: 44c6736fe257dfd9219152c9235bff9e3ecf8a84
Parents: 304995e
Author: Kanak Biscuitwala <kanak@apache.org>
Authored: Thu Mar 6 11:19:09 2014 -0800
Committer: Kanak Biscuitwala <kanak@apache.org>
Committed: Thu Mar 6 17:50:34 2014 -0800

----------------------------------------------------------------------
 .../apache/helix/controller/GenericHelixController.java |  5 +++--
 .../integration/TestReelectedPipelineCorrectness.java   | 12 ++++++++++++
 2 files changed, 15 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/helix/blob/44c6736f/helix-core/src/main/java/org/apache/helix/controller/GenericHelixController.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/controller/GenericHelixController.java
b/helix-core/src/main/java/org/apache/helix/controller/GenericHelixController.java
index 4ff47fb..99a1172 100644
--- a/helix-core/src/main/java/org/apache/helix/controller/GenericHelixController.java
+++ b/helix-core/src/main/java/org/apache/helix/controller/GenericHelixController.java
@@ -89,7 +89,7 @@ import org.apache.log4j.Logger;
 public class GenericHelixController implements ConfigChangeListener, IdealStateChangeListener,
     LiveInstanceChangeListener, MessageListener, CurrentStateChangeListener,
     ExternalViewChangeListener, ControllerChangeListener, HealthStateChangeListener,
-    InstanceConfigChangeListener{
+    InstanceConfigChangeListener {
   private static final Logger logger = Logger.getLogger(GenericHelixController.class.getName());
   volatile boolean init = false;
   private final PipelineRegistry _registry;
@@ -245,6 +245,7 @@ public class GenericHelixController implements ConfigChangeListener, IdealStateC
     _lastSeenSessions = new AtomicReference<Map<String, LiveInstance>>();
     _eventQueue = new ClusterEventBlockingQueue();
     _eventThread = new ClusterEventProcessor();
+    _eventThread.setDaemon(true);
     _eventThread.start();
     _cache = new ClusterDataCache();
   }
@@ -476,7 +477,7 @@ public class GenericHelixController implements ConfigChangeListener, IdealStateC
 
   @Override
   public void onInstanceConfigChange(List<InstanceConfig> instanceConfigs,
-      NotificationContext changeContext){
+      NotificationContext changeContext) {
     logger.info("START: GenericClusterController.onInstanceConfigChange()");
     onConfigChange(instanceConfigs, changeContext);
     logger.info("END: GenericClusterController.onInstanceConfigChange()");

http://git-wip-us.apache.org/repos/asf/helix/blob/44c6736f/helix-core/src/test/java/org/apache/helix/integration/TestReelectedPipelineCorrectness.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestReelectedPipelineCorrectness.java
b/helix-core/src/test/java/org/apache/helix/integration/TestReelectedPipelineCorrectness.java
index 78927f9..a1f1868 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestReelectedPipelineCorrectness.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestReelectedPipelineCorrectness.java
@@ -42,6 +42,9 @@ import org.testng.annotations.Test;
  * to ensure that the controller can verify its cache. That's what this test is for.
  */
 public class TestReelectedPipelineCorrectness extends ZkUnitTestBase {
+  private static final int CHECK_INTERVAL = 50;
+  private static final int CHECK_TIMEOUT = 10000;
+
   @Test
   public void testReelection() throws Exception {
     final int NUM_CONTROLLERS = 2;
@@ -100,6 +103,15 @@ public class TestReelectedPipelineCorrectness extends ZkUnitTestBase
{
     // Disable the leader, resulting in a leader election
     HelixDataAccessor accessor = participants[0].getHelixDataAccessor();
     LiveInstance leader = accessor.getProperty(accessor.keyBuilder().controllerLeader());
+    int totalWait = 0;
+    while (leader == null && totalWait < CHECK_TIMEOUT) {
+      Thread.sleep(CHECK_INTERVAL);
+      totalWait += CHECK_INTERVAL;
+      leader = accessor.getProperty(accessor.keyBuilder().controllerLeader());
+    }
+    if (totalWait >= CHECK_TIMEOUT) {
+      Assert.fail("No leader was ever elected!");
+    }
     String leaderId = leader.getId();
     String standbyId = (leaderId.equals("controller_0")) ? "controller_1" : "controller_0";
     HelixAdmin admin = setupTool.getClusterManagementTool();


Mime
View raw message