Author: clebert.suconic(a)jboss.com
Date: 2011-07-11 21:58:04 -0400 (Mon, 11 Jul 2011)
New Revision: 10965
Modified:
branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/client/impl/Topology.java
branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/server/cluster/impl/ClusterConnectionImpl.java
branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/server/cluster/impl/ClusterManagerImpl.java
branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java
branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/distribution/SimpleSymmetricClusterTest.java
branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/failover/FailBackAutoTest.java
branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/failover/FailoverTestBase.java
Log:
Fixing FailBackAutoTest
Modified:
branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/client/impl/Topology.java
===================================================================
---
branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/client/impl/Topology.java 2011-07-08
17:30:48 UTC (rev 10964)
+++
branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/client/impl/Topology.java 2011-07-12
01:58:04 UTC (rev 10965)
@@ -70,8 +70,7 @@
if (debug)
{
log.debug(this + "::adding = " + nodeId + ":" +
member.getConnector(), new Exception ("trace"));
- log.debug("before----------------------------------");
- log.debug(describe());
+ log.debug(describe("Before:"));
}
if(currentMember == null)
{
@@ -103,7 +102,7 @@
if(debug)
{
log.debug(this + "::Topology updated=" + replaced);
- log.debug(describe());
+ log.debug(describe("After:"));
}
return replaced;
}
@@ -163,11 +162,15 @@
}
return count;
}
-
public synchronized String describe()
{
+ return describe("");
+ }
- String desc = "";
+ public synchronized String describe(String text)
+ {
+
+ String desc = text + "\n";
for (Entry<String, TopologyMember> entry : new HashMap<String,
TopologyMember>(topology).entrySet())
{
desc += "\t" + entry.getKey() + " => " + entry.getValue()
+ "\n";
Modified:
branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/server/cluster/impl/ClusterConnectionImpl.java
===================================================================
---
branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/server/cluster/impl/ClusterConnectionImpl.java 2011-07-08
17:30:48 UTC (rev 10964)
+++
branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/server/cluster/impl/ClusterConnectionImpl.java 2011-07-12
01:58:04 UTC (rev 10965)
@@ -1174,7 +1174,14 @@
@Override
public String toString()
{
- return "ClusterConnectionImpl [nodeUUID=" + nodeUUID + ",
connector=" + connector + ", address=" + address + "]";
+ return "ClusterConnectionImpl [nodeUUID=" + nodeUUID +
+ ", connector=" +
+ connector +
+ ", address=" +
+ address +
+ ", server=" +
+ server +
+ "]";
}
public String describe()
@@ -1215,6 +1222,10 @@
{
if(tcConfigs != null && tcConfigs.length > 0)
{
+ if (log.isDebugEnabled())
+ {
+ log.debug(ClusterConnectionImpl.this + "Creating a serverLocator for
" + Arrays.toString(tcConfigs));
+ }
return (ServerLocatorInternal)
HornetQClient.createServerLocatorWithHA(tcConfigs);
}
else
Modified:
branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/server/cluster/impl/ClusterManagerImpl.java
===================================================================
---
branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/server/cluster/impl/ClusterManagerImpl.java 2011-07-08
17:30:48 UTC (rev 10964)
+++
branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/server/cluster/impl/ClusterManagerImpl.java 2011-07-12
01:58:04 UTC (rev 10965)
@@ -152,7 +152,7 @@
out.println("Information on " + this);
out.println("*******************************************************");
- out.println("Topology: " + topology.describe());
+ out.println("Topology: " + topology.describe("Toopology on " +
this));
for (ClusterConnection conn : this.clusterConnections.values())
{
@@ -166,7 +166,7 @@
public String toString()
{
- return "ClusterManagerImpl[server=" + server + "]";
+ return "ClusterManagerImpl[server=" + server + "]@" +
System.identityHashCode(this);
}
public synchronized void start() throws Exception
@@ -282,6 +282,11 @@
{
TopologyMember member = new TopologyMember(connectorPair);
boolean updated = topology.addMember(nodeID, member);
+
+ if (log.isDebugEnabled())
+ {
+ log.debug(this + "::NodeUp " + nodeID + connectorPair);
+ }
if (!updated)
{
@@ -887,6 +892,10 @@
{
try
{
+ if (log.isDebugEnabled())
+ {
+ log.debug(ClusterManagerImpl.this + ":: announcing " +
connector + " to " + backupServerLocator);
+ }
ClientSessionFactory backupSessionFactory =
backupServerLocator.connect();
if (backupSessionFactory != null)
{
Modified:
branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java
===================================================================
---
branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java 2011-07-08
17:30:48 UTC (rev 10964)
+++
branches/Branch_2_2_EAP_cluster_clean2/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java 2011-07-12
01:58:04 UTC (rev 10965)
@@ -444,8 +444,13 @@
{
try
{
+ log.debug(HornetQServerImpl.this + "::Stopping
live node in favor of failback");
stop(true);
+ // We need to wait some time before we start the
backup again
+ // otherwise we may eventually start before the live
had a chance to get it
+ Thread.sleep(configuration.getFailbackDelay());
configuration.setBackup(true);
+ log.debug(HornetQServerImpl.this + "::Starting
backup node now after failback");
start();
}
catch (Exception e)
@@ -601,7 +606,7 @@
}
started = true;
- HornetQServerImpl.log.info("HornetQ Server version " +
getVersion().getFullVersion() + " [" + nodeManager.getNodeId() + "]
started");
+ HornetQServerImpl.log.info("HornetQ Server version " +
getVersion().getFullVersion() + " [" + nodeManager.getNodeId() + "]" +
(this.identity != null ? " (" + identity : ")") + "
started");
}
Modified:
branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/distribution/SimpleSymmetricClusterTest.java
===================================================================
---
branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/distribution/SimpleSymmetricClusterTest.java 2011-07-08
17:30:48 UTC (rev 10964)
+++
branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/distribution/SimpleSymmetricClusterTest.java 2011-07-12
01:58:04 UTC (rev 10965)
@@ -278,6 +278,8 @@
public void testSimpleRoundRobbin() throws Exception
{
+
+ //TODO make this test to crash a node
setupServer(0, true, isNetty());
setupServer(1, true, isNetty());
setupServer(2, true, isNetty());
@@ -361,6 +363,7 @@
public void testSimpleRoundRobbinNoFailure() throws Exception
{
+ //TODO make this test to crash a node
setupServer(0, true, isNetty());
setupServer(1, true, isNetty());
setupServer(2, true, isNetty());
Modified:
branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/failover/FailBackAutoTest.java
===================================================================
---
branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/failover/FailBackAutoTest.java 2011-07-08
17:30:48 UTC (rev 10964)
+++
branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/failover/FailBackAutoTest.java 2011-07-12
01:58:04 UTC (rev 10965)
@@ -13,23 +13,29 @@
package org.hornetq.tests.integration.cluster.failover;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
import junit.framework.Assert;
+
import org.hornetq.api.core.HornetQException;
import org.hornetq.api.core.SimpleString;
import org.hornetq.api.core.TransportConfiguration;
-import org.hornetq.api.core.client.*;
+import org.hornetq.api.core.client.ClientConsumer;
+import org.hornetq.api.core.client.ClientMessage;
+import org.hornetq.api.core.client.ClientProducer;
+import org.hornetq.api.core.client.ClientSession;
+import org.hornetq.api.core.client.ClientSessionFactory;
+import org.hornetq.api.core.client.SessionFailureListener;
import org.hornetq.core.client.impl.ClientSessionFactoryInternal;
import org.hornetq.core.client.impl.ServerLocatorInternal;
import org.hornetq.core.config.ClusterConnectionConfiguration;
+import org.hornetq.core.logging.Logger;
import org.hornetq.core.server.impl.InVMNodeManager;
import org.hornetq.jms.client.HornetQTextMessage;
-import org.hornetq.utils.ReusableLatch;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
/**
* @author <a href="mailto:andy.taylor@jboss.com">Andy Taylor</a>
* Date: Dec 21, 2010
@@ -37,6 +43,7 @@
*/
public class FailBackAutoTest extends FailoverTestBase
{
+ Logger log = Logger.getLogger(FailBackAutoTest.class);
private ServerLocatorInternal locator;
@Override
@@ -62,7 +69,7 @@
}
super.tearDown();
}
-
+
public void testAutoFailback() throws Exception
{
locator.setBlockOnNonDurableSend(true);
@@ -78,12 +85,8 @@
session.addFailureListener(listener);
- backupServer.stop();
-
liveServer.crash();
- backupServer.start();
-
assertTrue(latch.await(5, TimeUnit.SECONDS));
ClientProducer producer = session.createProducer(FailoverTestBase.ADDRESS);
@@ -102,6 +105,7 @@
session.addFailureListener(listener);
+ log.info("******* starting live server back");
liveServer.start();
assertTrue(latch2.await(5, TimeUnit.SECONDS));
@@ -136,12 +140,8 @@
session.addFailureListener(listener);
- backupServer.stop();
-
liveServer.crash();
- backupServer.start();
-
assertTrue(latch.await(5, TimeUnit.SECONDS));
ClientProducer producer = session.createProducer(FailoverTestBase.ADDRESS);
@@ -160,8 +160,9 @@
session.addFailureListener(listener);
+ log.info("restarting live node now");
liveServer.start();
-
+
assertTrue(latch2.await(5, TimeUnit.SECONDS));
message = session.createMessage(true);
@@ -178,7 +179,7 @@
session.addFailureListener(listener);
- waitForBackup(sf, 5);
+ waitForBackup(sf, 10);
liveServer.crash();
@@ -204,6 +205,7 @@
backupConfig.setSharedStore(true);
backupConfig.setBackup(true);
backupConfig.setClustered(true);
+ backupConfig.setFailbackDelay(1000);
TransportConfiguration liveConnector = getConnectorTransportConfiguration(true);
TransportConfiguration backupConnector =
getConnectorTransportConfiguration(false);
backupConfig.getConnectorConfigurations().put(liveConnector.getName(),
liveConnector);
@@ -220,6 +222,7 @@
liveConfig.getAcceptorConfigurations().add(getAcceptorTransportConfiguration(true));
liveConfig.setSecurityEnabled(false);
liveConfig.setSharedStore(true);
+ liveConfig.setFailbackDelay(1000);
liveConfig.setClustered(true);
List<String> pairs = new ArrayList<String>();
pairs.add(backupConnector.getName());
Modified:
branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/failover/FailoverTestBase.java
===================================================================
---
branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/failover/FailoverTestBase.java 2011-07-08
17:30:48 UTC (rev 10964)
+++
branches/Branch_2_2_EAP_cluster_clean2/tests/src/org/hornetq/tests/integration/cluster/failover/FailoverTestBase.java 2011-07-12
01:58:04 UTC (rev 10965)
@@ -97,11 +97,14 @@
super.setUp();
clearData();
createConfigs();
+
+ liveServer.getServer().setIdentity(this.getClass().getSimpleName() +
"/liveServer");
liveServer.start();
if (backupServer != null)
{
+ backupServer.getServer().setIdentity(this.getClass().getSimpleName() +
"/backupServer");
backupServer.start();
}
}