You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@helix.apache.org by ka...@apache.org on 2014/07/16 20:28:03 UTC

[1/2] git commit: [HELIX-473] Make TestLocalContainerProvider less flaky

Repository: helix
Updated Branches:
  refs/heads/master 974f947b7 -> 6159d8fb4


[HELIX-473] Make TestLocalContainerProvider less flaky


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

Branch: refs/heads/master
Commit: 3c9697c4b8fa7748a8ffe2d798bc3effd72f0740
Parents: a9e96ea
Author: Kanak Biscuitwala <ka...@apache.org>
Authored: Tue Jul 15 14:15:23 2014 -0700
Committer: Kanak Biscuitwala <ka...@apache.org>
Committed: Tue Jul 15 14:15:23 2014 -0700

----------------------------------------------------------------------
 .../integration/TestLocalContainerProvider.java | 29 ++++++++++++--------
 1 file changed, 17 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/helix/blob/3c9697c4/helix-core/src/test/java/org/apache/helix/integration/TestLocalContainerProvider.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestLocalContainerProvider.java b/helix-core/src/test/java/org/apache/helix/integration/TestLocalContainerProvider.java
index f27ce79..111c921 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestLocalContainerProvider.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestLocalContainerProvider.java
@@ -59,6 +59,7 @@ import org.apache.helix.controller.serializer.StringSerializer;
 import org.apache.helix.manager.zk.ZkHelixConnection;
 import org.apache.helix.model.StateModelDefinition;
 import org.apache.helix.tools.StateModelConfigGenerator;
+import org.apache.log4j.Logger;
 import org.codehaus.jackson.annotate.JsonProperty;
 import org.testng.Assert;
 import org.testng.annotations.Test;
@@ -70,13 +71,15 @@ import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.SettableFuture;
 
 public class TestLocalContainerProvider extends ZkUnitTestBase {
-  private static final int MAX_PARTICIPANTS = 10;
+  private static final Logger LOG = Logger.getLogger(TestLocalContainerProvider.class);
+
+  private static final int MAX_PARTICIPANTS = 4;
   static String clusterName = null;
   static String resourceName = null;
-  static int allocated = 0;
-  static int started = 0;
-  static int stopped = 0;
-  static int deallocated = 0;
+  static volatile int allocated = 0;
+  static volatile int started = 0;
+  static volatile int stopped = 0;
+  static volatile int deallocated = 0;
   static HelixConnection connection = null;
   static CountDownLatch latch = new CountDownLatch(MAX_PARTICIPANTS);
 
@@ -122,7 +125,7 @@ public class TestLocalContainerProvider extends ZkUnitTestBase {
     HelixController controller = connection.createController(clusterId, controllerId);
     controller.start();
 
-    latch.await(10000, TimeUnit.MILLISECONDS);
+    latch.await(30000, TimeUnit.MILLISECONDS);
 
     // clean up
     controller.stop();
@@ -232,6 +235,7 @@ public class TestLocalContainerProvider extends ZkUnitTestBase {
       _states.put(containerId, ContainerState.ACQUIRED);
       _containerParticipants.put(containerId, spec.getParticipantId());
       allocated++;
+      LOG.info(String.format("ALLOC: %d %d %d %d", allocated, started, stopped, deallocated));
       SettableFuture<ContainerId> future = SettableFuture.create();
       future.set(containerId);
       return future;
@@ -242,6 +246,7 @@ public class TestLocalContainerProvider extends ZkUnitTestBase {
       // deallocation is a no-op
       _states.put(containerId, ContainerState.FINALIZED);
       deallocated++;
+      LOG.info(String.format("DEALLOC: %d %d %d %d", allocated, started, stopped, deallocated));
       latch.countDown();
       SettableFuture<Boolean> future = SettableFuture.create();
       future.set(true);
@@ -257,6 +262,7 @@ public class TestLocalContainerProvider extends ZkUnitTestBase {
       _participants.put(containerId, participantService);
       _states.put(containerId, ContainerState.CONNECTED);
       started++;
+      LOG.info(String.format("START: %d %d %d %d", allocated, started, stopped, deallocated));
       SettableFuture<Boolean> future = SettableFuture.create();
       future.set(true);
       return future;
@@ -269,6 +275,7 @@ public class TestLocalContainerProvider extends ZkUnitTestBase {
       participant.awaitTerminated();
       _states.put(containerId, ContainerState.HALTED);
       stopped++;
+      LOG.info(String.format("STOP: %d %d %d %d", allocated, started, stopped, deallocated));
       SettableFuture<Boolean> future = SettableFuture.create();
       future.set(true);
       return future;
@@ -278,13 +285,11 @@ public class TestLocalContainerProvider extends ZkUnitTestBase {
     public TargetProviderResponse evaluateExistingContainers(Cluster cluster,
         ResourceId resourceId, Collection<Participant> participants) {
       TargetProviderResponse response = new TargetProviderResponse();
-      // ask for two containers at a time
+      // ask for one container at a time
       List<ContainerSpec> containersToAcquire = Lists.newArrayList();
       boolean asked = false;
       if (_askCount < MAX_PARTICIPANTS) {
         containersToAcquire.add(new ContainerSpec(ParticipantId.from("container" + _askCount)));
-        containersToAcquire
-            .add(new ContainerSpec(ParticipantId.from("container" + (_askCount + 1))));
         asked = true;
       }
       List<Participant> containersToStart = Lists.newArrayList();
@@ -301,8 +306,8 @@ public class TestLocalContainerProvider extends ZkUnitTestBase {
             containersToStart.add(participant);
             break;
           case CONNECTED:
-            // stop at most two active at a time, wait for everything to be up first
-            if (stopCount < 2 && _askCount >= MAX_PARTICIPANTS) {
+            // stop at most one active at a time, wait for everything to be up first
+            if (stopCount < 1 && _askCount >= MAX_PARTICIPANTS) {
               containersToStop.add(participant);
               stopCount++;
             }
@@ -323,7 +328,7 @@ public class TestLocalContainerProvider extends ZkUnitTestBase {
       }
       // update acquire request count
       if (asked) {
-        _askCount += 2;
+        _askCount++;
       }
       // set the response
       response.setContainersToAcquire(containersToAcquire);


[2/2] git commit: Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/helix

Posted by ka...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/helix


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

Branch: refs/heads/master
Commit: 6159d8fb407e04e6a4af89438982e96f0685fdd6
Parents: 3c9697c 974f947
Author: Kanak Biscuitwala <ka...@apache.org>
Authored: Wed Jul 16 11:17:43 2014 -0700
Committer: Kanak Biscuitwala <ka...@apache.org>
Committed: Wed Jul 16 11:17:43 2014 -0700

----------------------------------------------------------------------
 .../main/java/org/apache/helix/GroupCommit.java |  40 +++---
 .../stages/ExternalViewComputeStage.java        |   1 +
 .../stages/ResourceComputationStage.java        |   5 +
 .../helix/manager/zk/ZKHelixDataAccessor.java   |   2 +-
 .../org/apache/helix/integration/TestDrop.java  | 124 +++++++++++++++++--
 5 files changed, 133 insertions(+), 39 deletions(-)
----------------------------------------------------------------------