You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2018/05/09 02:10:59 UTC

[1/3] activemq-artemis git commit: NO-JIRA Improvements on ReplicatedMultipleServerFailoverExtraBackupsTest

Repository: activemq-artemis
Updated Branches:
  refs/heads/master 845f03dce -> 512d67504


NO-JIRA Improvements on ReplicatedMultipleServerFailoverExtraBackupsTest


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/69ca1894
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/69ca1894
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/69ca1894

Branch: refs/heads/master
Commit: 69ca189439d15e70e35da737982f8469ab33f8cb
Parents: eaf935e
Author: Clebert Suconic <cl...@apache.org>
Authored: Tue May 8 18:42:16 2018 -0400
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue May 8 18:55:59 2018 -0400

----------------------------------------------------------------------
 .../artemis/tests/util/ActiveMQTestBase.java    |  1 -
 .../MultipleServerFailoverTestBase.java         | 16 ++-----------
 ...dMultipleServerFailoverExtraBackupsTest.java | 24 ++++++++++++++++----
 3 files changed, 22 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/69ca1894/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java
index 673e023..530c399 100644
--- a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java
+++ b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java
@@ -1137,7 +1137,6 @@ public abstract class ActiveMQTestBase extends Assert {
          for (TopologyMemberImpl member : topology.getMembers()) {
             if (member.getLive() != null) {
                liveNodesCount++;
-               ActiveMQServerLogger.LOGGER.info("Found live server connected to " + server.getNodeID());
             }
             if (member.getBackup() != null) {
                backupNodesCount++;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/69ca1894/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/MultipleServerFailoverTestBase.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/MultipleServerFailoverTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/MultipleServerFailoverTestBase.java
index 8c34667..0775e08 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/MultipleServerFailoverTestBase.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/MultipleServerFailoverTestBase.java
@@ -35,6 +35,7 @@ import org.apache.activemq.artemis.core.server.ActiveMQServer;
 import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
 import org.apache.activemq.artemis.core.server.NodeManager;
 import org.apache.activemq.artemis.core.server.Queue;
+import org.apache.activemq.artemis.junit.Wait;
 import org.apache.activemq.artemis.tests.integration.cluster.util.SameProcessActiveMQServer;
 import org.apache.activemq.artemis.tests.integration.cluster.util.TestableServer;
 import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
@@ -226,22 +227,9 @@ public abstract class MultipleServerFailoverTestBase extends ActiveMQTestBase {
    protected void waitForDistribution(SimpleString address, ActiveMQServer server, int messageCount) throws Exception {
       ActiveMQServerLogger.LOGGER.debug("waiting for distribution of messages on server " + server);
 
-      long start = System.currentTimeMillis();
-
-      long timeout = 5000;
-
       Queue q = (Queue) server.getPostOffice().getBinding(address).getBindable();
 
-      do {
-
-         if (getMessageCount(q) >= messageCount) {
-            return;
-         }
-
-         Thread.sleep(10);
-      }
-      while (System.currentTimeMillis() - start < timeout);
+      Wait.waitFor(() -> getMessageCount(q) >= messageCount);
 
-      throw new Exception();
    }
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/69ca1894/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/ReplicatedMultipleServerFailoverExtraBackupsTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/ReplicatedMultipleServerFailoverExtraBackupsTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/ReplicatedMultipleServerFailoverExtraBackupsTest.java
index 62dd384..1a1d75c 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/ReplicatedMultipleServerFailoverExtraBackupsTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/ReplicatedMultipleServerFailoverExtraBackupsTest.java
@@ -18,19 +18,29 @@ package org.apache.activemq.artemis.tests.integration.cluster.failover;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
 
 import org.apache.activemq.artemis.api.core.client.ClientConsumer;
 import org.apache.activemq.artemis.api.core.client.ClientMessage;
 import org.apache.activemq.artemis.api.core.client.ClientProducer;
 import org.apache.activemq.artemis.api.core.client.ClientSession;
 import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
+import org.apache.activemq.artemis.api.core.client.FailoverEventType;
 import org.apache.activemq.artemis.api.core.client.ServerLocator;
 import org.apache.activemq.artemis.core.config.ha.ReplicaPolicyConfiguration;
+import org.apache.activemq.artemis.core.server.ActiveMQServer;
+import org.apache.activemq.artemis.junit.Wait;
 import org.apache.activemq.artemis.tests.integration.cluster.util.TestableServer;
+import org.junit.Assert;
 import org.junit.Test;
 
 public class ReplicatedMultipleServerFailoverExtraBackupsTest extends ReplicatedMultipleServerFailoverTest {
 
+   private void waitForSync(ActiveMQServer server) throws Exception {
+      Wait.waitFor(server::isReplicaSync);
+   }
+
    @Override
    @Test
    public void testStartLiveFirst() throws Exception {
@@ -40,8 +50,8 @@ public class ReplicatedMultipleServerFailoverExtraBackupsTest extends Replicated
       startServers(liveServers);
       backupServers.get(0).start();
       backupServers.get(1).start();
-      waitForRemoteBackupSynchronization(backupServers.get(0).getServer());
-      waitForRemoteBackupSynchronization(backupServers.get(1).getServer());
+      waitForSync(backupServers.get(0).getServer());
+      waitForSync(backupServers.get(1).getServer());
 
       // wait to start the other 2 backups so the first 2 can sync with the 2 live servers
       backupServers.get(2).start();
@@ -112,10 +122,16 @@ public class ReplicatedMultipleServerFailoverExtraBackupsTest extends Replicated
          }
       }
 
+      CountDownLatch failoverHappened = new CountDownLatch(1);
+
+      session0.addFailoverListener((FailoverEventType type) -> failoverHappened.countDown());
+
       for (TestableServer testableServer : toCrash) {
-         testableServer.crash();
+         testableServer.crash().await(10, TimeUnit.SECONDS);
       }
 
+      Assert.assertTrue(failoverHappened.await(10, TimeUnit.SECONDS));
+
       ClientConsumer consumer0 = session0.createConsumer(ADDRESS);
       ClientConsumer consumer1 = session1.createConsumer(ADDRESS);
       session0.start();
@@ -125,7 +141,7 @@ public class ReplicatedMultipleServerFailoverExtraBackupsTest extends Replicated
          ClientMessage message = consumer0.receive(1000);
          assertNotNull("expecting durable msg " + i, message);
          message.acknowledge();
-         consumer1.receive(1000);
+         message = consumer1.receive(1000);
          assertNotNull("expecting durable msg " + i, message);
          message.acknowledge();
 


[2/3] activemq-artemis git commit: NO-JIRA avoiding possible NPE on SharedNothingBackupActivation

Posted by cl...@apache.org.
NO-JIRA avoiding possible NPE on SharedNothingBackupActivation


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

Branch: refs/heads/master
Commit: eaf935ecec96e821f2e6f24a1329d933a21665d8
Parents: 845f03d
Author: Clebert Suconic <cl...@apache.org>
Authored: Tue May 8 18:40:49 2018 -0400
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue May 8 18:55:59 2018 -0400

----------------------------------------------------------------------
 .../artemis/core/server/impl/SharedNothingBackupActivation.java  | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/eaf935ec/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedNothingBackupActivation.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedNothingBackupActivation.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedNothingBackupActivation.java
index 58742de..5ca6fda 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedNothingBackupActivation.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedNothingBackupActivation.java
@@ -220,12 +220,14 @@ public final class SharedNothingBackupActivation extends Activation {
                clusterControl = clusterController.connectToNodeInReplicatedCluster(possibleLive.getA());
             } catch (Exception e) {
                logger.debug(e.getMessage(), e);
-               if (possibleLive.getB() != null) {
+               if (possibleLive != null && possibleLive.getB() != null) {
                   try {
                      clusterControl = clusterController.connectToNodeInReplicatedCluster(possibleLive.getB());
                   } catch (Exception e1) {
                      clusterControl = null;
                   }
+               } else {
+                  clusterControl = null;
                }
             }
             if (clusterControl == null) {


[3/3] activemq-artemis git commit: This closes #2078

Posted by cl...@apache.org.
This closes #2078


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/512d6750
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/512d6750
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/512d6750

Branch: refs/heads/master
Commit: 512d675049698f58120c7444d0d10687a0d5fcc8
Parents: 845f03d 69ca189
Author: Clebert Suconic <cl...@apache.org>
Authored: Tue May 8 22:10:52 2018 -0400
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue May 8 22:10:52 2018 -0400

----------------------------------------------------------------------
 .../impl/SharedNothingBackupActivation.java     |  4 +++-
 .../artemis/tests/util/ActiveMQTestBase.java    |  1 -
 .../MultipleServerFailoverTestBase.java         | 16 ++-----------
 ...dMultipleServerFailoverExtraBackupsTest.java | 24 ++++++++++++++++----
 4 files changed, 25 insertions(+), 20 deletions(-)
----------------------------------------------------------------------