Author: borges
Date: 2011-10-04 10:30:50 -0400 (Tue, 04 Oct 2011)
New Revision: 11467
Added:
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/QuorumFailOverTest.java
Modified:
branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/server/impl/QuorumManager.java
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/ClusterWithBackupFailoverTestBase.java
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/StaticClusterWithBackupFailoverTest.java
Log:
HORNETQ-720 HORNETQ-776 Attempt of testing quorum voting (but backup does not get correct
topology)
Modified:
branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/server/impl/QuorumManager.java
===================================================================
---
branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/server/impl/QuorumManager.java 2011-10-04
13:35:44 UTC (rev 11466)
+++
branches/HORNETQ-720_Replication/hornetq-core/src/main/java/org/hornetq/core/server/impl/QuorumManager.java 2011-10-04
14:30:50 UTC (rev 11467)
@@ -67,10 +67,7 @@
// decide to wake backup
clusterManager.removeClusterTopologyListener(this, true);
}
- else
- {
- nodes.remove(nodeID);
- }
+ nodes.remove(nodeID);
}
public boolean isNodeDown()
Modified:
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/ClusterWithBackupFailoverTestBase.java
===================================================================
---
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/ClusterWithBackupFailoverTestBase.java 2011-10-04
13:35:44 UTC (rev 11466)
+++
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/ClusterWithBackupFailoverTestBase.java 2011-10-04
14:30:50 UTC (rev 11467)
@@ -41,13 +41,11 @@
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
*
* Created 9 Mar 2009 16:31:21
- *
- *
*/
public abstract class ClusterWithBackupFailoverTestBase extends ClusterTestBase
{
- private static final String QUEUE_NAME = "queue0";
- private static final String QUEUES_TESTADDRESS = "queues.testaddress";
+ protected static final String QUEUE_NAME = "queue0";
+ protected static final String QUEUES_TESTADDRESS = "queues.testaddress";
private static final Logger log =
Logger.getLogger(ClusterWithBackupFailoverTestBase.class);
protected abstract void setupCluster(final boolean forwardWhenNoConsumers) throws
Exception;
@@ -251,8 +249,6 @@
send(2, QUEUES_TESTADDRESS, 10, false, null);
verifyReceiveRoundRobinInSomeOrder(true, 10, 0, 1, 2);
-
-
removeConsumer(0);
removeConsumer(1);
removeConsumer(2);
Added:
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/QuorumFailOverTest.java
===================================================================
---
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/QuorumFailOverTest.java
(rev 0)
+++
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/QuorumFailOverTest.java 2011-10-04
14:30:50 UTC (rev 11467)
@@ -0,0 +1,77 @@
+package org.hornetq.tests.integration.cluster.failover;
+
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+import org.hornetq.api.core.Pair;
+import org.hornetq.api.core.TransportConfiguration;
+import org.hornetq.api.core.client.ClusterTopologyListener;
+
+public class QuorumFailOverTest extends StaticClusterWithBackupFailoverTest
+{
+
+ public void testQuorumVoting() throws Exception
+ {
+ setupCluster();
+ startServers(0, 1, 2, 3, 4, 5);
+
+ final TopologyListener liveTopologyListener = new
TopologyListener("LIVE-1");
+ servers[0].getClusterManager().addClusterTopologyListener(liveTopologyListener,
true);
+
+ final TopologyListener backupTopologyListener = new
TopologyListener("BACKUP-3");
+ servers[3].getClusterManager().addClusterTopologyListener(backupTopologyListener,
true);
+
+ assertTrue("we assume 3 is a backup",
servers[3].getConfiguration().isBackup());
+ assertFalse("no shared storage",
servers[3].getConfiguration().isSharedStore());
+
+ setupSessionFactory(0, 3, isNetty(), false);
+ setupSessionFactory(1, 4, isNetty(), false);
+ setupSessionFactory(2, 5, isNetty(), false);
+
+ assertEquals(liveTopologyListener.toString(), 6,
liveTopologyListener.nodes.size());
+ assertEquals(backupTopologyListener.toString(), 6,
backupTopologyListener.nodes.size());
+
+ failNode(0);
+ }
+
+ @Override
+ protected boolean isSharedStorage()
+ {
+ return false;
+ }
+
+
+ private static class TopologyListener implements ClusterTopologyListener
+ {
+ final String prefix;
+ final ConcurrentMap<String, Pair<TransportConfiguration,
TransportConfiguration>> nodes =
+ new ConcurrentHashMap<String, Pair<TransportConfiguration,
TransportConfiguration>>();
+ public TopologyListener(String string)
+ {
+ prefix = string;
+ }
+
+ @Override
+ public
+ void nodeUP(String nodeID,
+ Pair<TransportConfiguration, TransportConfiguration>
connectorPair,
+ boolean last)
+ {
+ nodes.put(nodeID, connectorPair);
+ System.out.println(prefix + " UP: " + nodeID);
+ }
+
+ @Override
+ public void nodeDown(String nodeID)
+ {
+ nodes.remove(nodeID);
+ System.out.println(prefix + " DOWN: " + nodeID);
+ }
+
+ @Override
+ public String toString()
+ {
+ return "TopologyListener(" + prefix + ", #=" + nodes.size()
+ ")";
+ }
+ }
+}
Modified:
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/StaticClusterWithBackupFailoverTest.java
===================================================================
---
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/StaticClusterWithBackupFailoverTest.java 2011-10-04
13:35:44 UTC (rev 11466)
+++
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/StaticClusterWithBackupFailoverTest.java 2011-10-04
14:30:50 UTC (rev 11467)
@@ -84,19 +84,25 @@
new int[] { 0, 1 });
}
+ protected boolean isSharedStorage()
+ {
+ return true;
+ }
+
@Override
protected void setupServers() throws Exception
{
// The backups
- setupBackupServer(3, 0, isFileStorage(), true, isNetty());
- setupBackupServer(4, 1, isFileStorage(), true, isNetty());
- setupBackupServer(5, 2, isFileStorage(), true, isNetty());
+ setupBackupServer(3, 0, isFileStorage(), isSharedStorage(), isNetty());
+ setupBackupServer(4, 1, isFileStorage(), isSharedStorage(), isNetty());
+ setupBackupServer(5, 2, isFileStorage(), isSharedStorage(), isNetty());
// The lives
- setupLiveServer(0, isFileStorage(), true, isNetty());
- setupLiveServer(1, isFileStorage(), true, isNetty());
- setupLiveServer(2, isFileStorage(), true, isNetty());
+ setupLiveServer(0, isFileStorage(), isSharedStorage(), isNetty());
+ setupLiveServer(1, isFileStorage(), isSharedStorage(), isNetty());
+ setupLiveServer(2, isFileStorage(), isSharedStorage(), isNetty());
}
+
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------