JBoss hornetq SVN: r11564 - in branches/Branch_2_2_EAP/src/main/org/hornetq/core: server/cluster/impl and 1 other directory.
by do-not-reply@jboss.org
Author: clebert.suconic
Date: 2011-10-19 17:03:14 -0400 (Wed, 19 Oct 2011)
New Revision: 11564
Modified:
branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/ServerLocatorImpl.java
branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/cluster/impl/ClusterConnectionImpl.java
Log:
JBPAPP-7273 - Committing changes suggested by Andy Taylor
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/ServerLocatorImpl.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/ServerLocatorImpl.java 2011-10-18 15:58:28 UTC (rev 11563)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/ServerLocatorImpl.java 2011-10-19 21:03:14 UTC (rev 11564)
@@ -1288,32 +1288,31 @@
log.debug("nodeDown " + this + " nodeID=" + nodeID + " as being down", new Exception("trace"));
}
- if (topology.removeMember(eventTime, nodeID))
+ topology.removeMember(eventTime, nodeID);
+
+ if (clusterConnection)
{
- if (clusterConnection)
+ updateArraysAndPairs();
+ }
+ else
+ {
+ synchronized (this)
{
- updateArraysAndPairs();
- }
- else
- {
- synchronized (this)
+ if (topology.isEmpty())
{
- if (topology.isEmpty())
+ // Resetting the topology to its original condition as it was brand new
+ receivedTopology = false;
+ topologyArray = null;
+ }
+ else
+ {
+ updateArraysAndPairs();
+
+ if (topology.nodes() == 1 && topology.getMember(this.nodeID) != null)
{
// Resetting the topology to its original condition as it was brand new
receivedTopology = false;
- topologyArray = null;
}
- else
- {
- updateArraysAndPairs();
-
- if (topology.nodes() == 1 && topology.getMember(this.nodeID) != null)
- {
- // Resetting the topology to its original condition as it was brand new
- receivedTopology = false;
- }
- }
}
}
}
@@ -1338,23 +1337,21 @@
TopologyMember member = new TopologyMember(connectorPair.getA(), connectorPair.getB());
- if (topology.updateMember(uniqueEventID, nodeID, member))
- {
+ topology.updateMember(uniqueEventID, nodeID, member);
- TopologyMember actMember = topology.getMember(nodeID);
+ TopologyMember actMember = topology.getMember(nodeID);
- if (actMember != null && actMember.getConnector().getA() != null && actMember.getConnector().getB() != null)
+ if (actMember != null && actMember.getConnector().getA() != null && actMember.getConnector().getB() != null)
+ {
+ for (ClientSessionFactory factory : factories)
{
- for (ClientSessionFactory factory : factories)
- {
- ((ClientSessionFactoryInternal)factory).setBackupConnector(actMember.getConnector().getA(),
- actMember.getConnector().getB());
- }
+ ((ClientSessionFactoryInternal)factory).setBackupConnector(actMember.getConnector().getA(),
+ actMember.getConnector().getB());
}
-
- updateArraysAndPairs();
}
+ updateArraysAndPairs();
+
if (last)
{
synchronized (this)
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/cluster/impl/ClusterConnectionImpl.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/cluster/impl/ClusterConnectionImpl.java 2011-10-18 15:58:28 UTC (rev 11563)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/cluster/impl/ClusterConnectionImpl.java 2011-10-19 21:03:14 UTC (rev 11564)
@@ -348,7 +348,7 @@
clusterConnector = new DiscoveryClusterConnector(dg);
- backupServerLocator = clusterConnector.createServerLocator(false);
+ backupServerLocator = clusterConnector.createServerLocator(true);
if (backupServerLocator != null)
{
@@ -470,29 +470,33 @@
{
public void run()
{
- try
- {
- if (log.isDebugEnabled())
- {
- log.debug(ClusterConnectionImpl.this + ":: announcing " + connector + " to " + backupServerLocator);
- }
- ClientSessionFactory backupSessionFactory = backupServerLocator.connect();
- if (backupSessionFactory != null)
- {
- backupSessionFactory.getConnection()
- .getChannel(0, -1)
- .send(new NodeAnnounceMessage(System.currentTimeMillis(),
- nodeUUID.toString(),
- true,
- connector,
- null));
- log.info("backup announced");
- }
- }
- catch (Exception e)
- {
- log.warn("Unable to announce backup, retrying", e);
- }
+ while (true)
+ {
+ try
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug(ClusterConnectionImpl.this + ":: announcing " + connector + " to " + backupServerLocator);
+ }
+ ClientSessionFactory backupSessionFactory = backupServerLocator.connect();
+ if (backupSessionFactory != null)
+ {
+ backupSessionFactory.getConnection()
+ .getChannel(0, -1)
+ .send(new NodeAnnounceMessage(System.currentTimeMillis(),
+ nodeUUID.toString(),
+ true,
+ connector,
+ null));
+ log.info("backup announced");
+ break;
+ }
+ }
+ catch (Exception e)
+ {
+ log.warn("Unable to announce backup, retrying", e);
+ }
+ }
}
});
}
13 years, 2 months
JBoss hornetq SVN: r11563 - branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2011-10-18 11:58:28 -0400 (Tue, 18 Oct 2011)
New Revision: 11563
Modified:
branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/ServerLocatorImpl.java
Log:
it's not necessary to reset topologyArray to null on ServerLocators used at clusterConnections
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/ServerLocatorImpl.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/ServerLocatorImpl.java 2011-10-18 04:05:30 UTC (rev 11562)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/ServerLocatorImpl.java 2011-10-18 15:58:28 UTC (rev 11563)
@@ -1290,23 +1290,30 @@
if (topology.removeMember(eventTime, nodeID))
{
- synchronized (this)
+ if (clusterConnection)
{
- if (topology.isEmpty())
+ updateArraysAndPairs();
+ }
+ else
+ {
+ synchronized (this)
{
- // Resetting the topology to its original condition as it was brand new
- receivedTopology = false;
- topologyArray = null;
- }
- else
- {
- updateArraysAndPairs();
-
- if (topology.nodes() == 1 && topology.getMember(this.nodeID) != null)
+ if (topology.isEmpty())
{
// Resetting the topology to its original condition as it was brand new
receivedTopology = false;
+ topologyArray = null;
}
+ else
+ {
+ updateArraysAndPairs();
+
+ if (topology.nodes() == 1 && topology.getMember(this.nodeID) != null)
+ {
+ // Resetting the topology to its original condition as it was brand new
+ receivedTopology = false;
+ }
+ }
}
}
}
13 years, 2 months
JBoss hornetq SVN: r11562 - branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2011-10-18 00:05:30 -0400 (Tue, 18 Oct 2011)
New Revision: 11562
Modified:
branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/ServerLocatorImpl.java
Log:
fixing tests
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/ServerLocatorImpl.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/ServerLocatorImpl.java 2011-10-18 02:38:12 UTC (rev 11561)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/ServerLocatorImpl.java 2011-10-18 04:05:30 UTC (rev 11562)
@@ -1300,7 +1300,7 @@
}
else
{
- updateArraysAndPairs(false);
+ updateArraysAndPairs();
if (topology.nodes() == 1 && topology.getMember(this.nodeID) != null)
{
@@ -1345,8 +1345,18 @@
}
}
- updateArraysAndPairs(last);
+ updateArraysAndPairs();
}
+
+ if (last)
+ {
+ synchronized (this)
+ {
+ receivedTopology = true;
+ // Notify if waiting on getting topology
+ notifyAll();
+ }
+ }
}
/* (non-Javadoc)
@@ -1373,7 +1383,7 @@
}
}
- private synchronized void updateArraysAndPairs(final boolean updateReceived)
+ private synchronized void updateArraysAndPairs()
{
Collection<TopologyMember> membersCopy = topology.getMembers();
@@ -1385,12 +1395,6 @@
{
topologyArray[count++] = pair.getConnector();
}
-
- if (updateReceived)
- {
- receivedTopology = true;
- notifyAll();
- }
}
public synchronized void connectorsChanged()
13 years, 2 months
JBoss hornetq SVN: r11561 - in branches/Branch_2_2_EAP: src/main/org/hornetq/core/postoffice/impl and 2 other directories.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2011-10-17 22:38:12 -0400 (Mon, 17 Oct 2011)
New Revision: 11561
Modified:
branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/ServerLocatorImpl.java
branches/Branch_2_2_EAP/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java
branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/cluster/impl/ClusterConnectionImpl.java
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/cluster/distribution/MessageRedistributionTest.java
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/cluster/distribution/TwoWayTwoNodeClusterTest.java
Log:
fixing tests
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/ServerLocatorImpl.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/ServerLocatorImpl.java 2011-10-17 19:18:17 UTC (rev 11560)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/ServerLocatorImpl.java 2011-10-18 02:38:12 UTC (rev 11561)
@@ -79,9 +79,9 @@
private final Topology topology;
- private Pair<TransportConfiguration, TransportConfiguration>[] topologyArray;
+ private volatile Pair<TransportConfiguration, TransportConfiguration>[] topologyArray;
- private boolean receivedTopology;
+ private volatile boolean receivedTopology;
private boolean compressLargeMessage;
@@ -505,7 +505,7 @@
this(topology, useHA, null, transportConfigs);
}
- private TransportConfiguration selectConnector()
+ private synchronized TransportConfiguration selectConnector()
{
if (receivedTopology)
{
@@ -1290,23 +1290,23 @@
if (topology.removeMember(eventTime, nodeID))
{
- if (topology.isEmpty())
+ synchronized (this)
{
- // Resetting the topology to its original condition as it was brand new
- synchronized (this)
+ if (topology.isEmpty())
{
- topologyArray = null;
+ // Resetting the topology to its original condition as it was brand new
receivedTopology = false;
+ topologyArray = null;
}
- }
- else
- {
- updateArraysAndPairs();
-
- if (topology.nodes() == 1 && topology.getMember(this.nodeID) != null)
+ else
{
- // Resetting the topology to its original condition as it was brand new
- receivedTopology = false;
+ updateArraysAndPairs(false);
+
+ if (topology.nodes() == 1 && topology.getMember(this.nodeID) != null)
+ {
+ // Resetting the topology to its original condition as it was brand new
+ receivedTopology = false;
+ }
}
}
}
@@ -1345,18 +1345,8 @@
}
}
- updateArraysAndPairs();
+ updateArraysAndPairs(last);
}
-
- if (last)
- {
- synchronized (this)
- {
- receivedTopology = true;
- // Notify if waiting on getting topology
- notifyAll();
- }
- }
}
/* (non-Javadoc)
@@ -1383,7 +1373,7 @@
}
}
- private synchronized void updateArraysAndPairs()
+ private synchronized void updateArraysAndPairs(final boolean updateReceived)
{
Collection<TopologyMember> membersCopy = topology.getMembers();
@@ -1395,6 +1385,12 @@
{
topologyArray[count++] = pair.getConnector();
}
+
+ if (updateReceived)
+ {
+ receivedTopology = true;
+ notifyAll();
+ }
}
public synchronized void connectorsChanged()
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java 2011-10-17 19:18:17 UTC (rev 11560)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java 2011-10-18 02:38:12 UTC (rev 11561)
@@ -473,9 +473,9 @@
String uid = UUIDGenerator.getInstance().generateStringUUID();
- if (isTrace)
+ if (log.isDebugEnabled())
{
- log.trace("Sending notification for addBinding " + binding + " from server " + server);
+ log.debug("ClusterCommunication::Sending notification for addBinding " + binding + " from server " + server);
}
managementService.sendNotification(new Notification(uid, NotificationType.BINDING_ADDED, props));
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/cluster/impl/ClusterConnectionImpl.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/cluster/impl/ClusterConnectionImpl.java 2011-10-17 19:18:17 UTC (rev 11560)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/cluster/impl/ClusterConnectionImpl.java 2011-10-18 02:38:12 UTC (rev 11561)
@@ -1135,9 +1135,9 @@
public synchronized void onMessage(final ClientMessage message)
{
- if (isTrace)
+ if (log.isDebugEnabled())
{
- log.trace("Flow record on " + clusterConnector + " Receiving message " + message);
+ log.debug("ClusterCommunication::Flow record on " + clusterConnector + " Receiving message " + message);
}
try
{
Modified: branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/cluster/distribution/MessageRedistributionTest.java
===================================================================
--- branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/cluster/distribution/MessageRedistributionTest.java 2011-10-17 19:18:17 UTC (rev 11560)
+++ branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/cluster/distribution/MessageRedistributionTest.java 2011-10-18 02:38:12 UTC (rev 11561)
@@ -494,10 +494,11 @@
{
for (int i = 0; i < 10; i++)
{
+ log.info("#test " + i);
setupCluster(false);
startServers(0, 1, 2);
-
+
setupSessionFactory(0, isNetty());
setupSessionFactory(1, isNetty());
setupSessionFactory(2, isNetty());
Modified: branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/cluster/distribution/TwoWayTwoNodeClusterTest.java
===================================================================
--- branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/cluster/distribution/TwoWayTwoNodeClusterTest.java 2011-10-17 19:18:17 UTC (rev 11560)
+++ branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/cluster/distribution/TwoWayTwoNodeClusterTest.java 2011-10-18 02:38:12 UTC (rev 11561)
@@ -141,7 +141,6 @@
for (int i = 0; i < 10; i++)
{
- Thread.sleep(10);
log.info("Sleep #test " + i);
log.info("#stop #test #" + i);
stopServers(1);
13 years, 2 months
JBoss hornetq SVN: r11560 - branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/cluster/impl.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2011-10-17 15:18:17 -0400 (Mon, 17 Oct 2011)
New Revision: 11560
Modified:
branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/cluster/impl/ClusterConnectionImpl.java
Log:
Andy Taylor's fix to clusterconnection (to fix some tests)
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/cluster/impl/ClusterConnectionImpl.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/cluster/impl/ClusterConnectionImpl.java 2011-10-17 15:33:57 UTC (rev 11559)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/cluster/impl/ClusterConnectionImpl.java 2011-10-17 19:18:17 UTC (rev 11560)
@@ -241,6 +241,14 @@
clusterConnector = new StaticClusterConnector(tcConfigs);
+ backupServerLocator = clusterConnector.createServerLocator(false);
+
+ if (backupServerLocator != null)
+ {
+ backupServerLocator.setReconnectAttempts(-1);
+ backupServerLocator.setInitialConnectAttempts(-1);
+ }
+
if (tcConfigs != null && tcConfigs.length > 0)
{
// a cluster connection will connect to other nodes only if they are directly connected
@@ -340,6 +348,14 @@
clusterConnector = new DiscoveryClusterConnector(dg);
+ backupServerLocator = clusterConnector.createServerLocator(false);
+
+ if (backupServerLocator != null)
+ {
+ backupServerLocator.setReconnectAttempts(-1);
+ backupServerLocator.setInitialConnectAttempts(-1);
+ }
+
this.manager = manager;
}
@@ -450,12 +466,6 @@
public void announceBackup()
{
- this.backupServerLocator = clusterConnector.createServerLocator(false);
-
- backupServerLocator.setReconnectAttempts(-1);
- backupServerLocator.setInitialConnectAttempts(-1);
-
-
executor.execute(new Runnable()
{
public void run()
13 years, 2 months
JBoss hornetq SVN: r11559 - in trunk/hornetq-core/src/main/java/org/hornetq/core: server/impl and 1 other directory.
by do-not-reply@jboss.org
Author: borges
Date: 2011-10-17 11:33:57 -0400 (Mon, 17 Oct 2011)
New Revision: 11559
Modified:
trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/CoreProtocolManager.java
trunk/hornetq-core/src/main/java/org/hornetq/core/server/impl/HornetQServerImpl.java
Log:
HORNETQ-720 Merge activation classes
Modified: trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/CoreProtocolManager.java
===================================================================
--- trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/CoreProtocolManager.java 2011-10-17 15:33:40 UTC (rev 11558)
+++ trunk/hornetq-core/src/main/java/org/hornetq/core/protocol/core/impl/CoreProtocolManager.java 2011-10-17 15:33:57 UTC (rev 11559)
@@ -51,8 +51,6 @@
* A CoreProtocolManager
*
* @author Tim Fox
- *
- *
*/
public class CoreProtocolManager implements ProtocolManager
{
@@ -216,8 +214,8 @@
* HORNETQ-720 Instantiate a new server locator to call notifyNodeUp(...)? Or send
* a CLUSTER_TOPOLOGY(_2?) message?
*/
-// server.getClusterManager().notifyNodeUp(msg.getNodeID(), getPair(msg.getConnector(), true), true,
-// true);
+ acceptorUsed.getClusterConnection().nodeAnnounced(System.currentTimeMillis(), msg.getNodeID(),
+ getPair(msg.getConnector(), true), true);
}
}
}
Modified: trunk/hornetq-core/src/main/java/org/hornetq/core/server/impl/HornetQServerImpl.java
===================================================================
--- trunk/hornetq-core/src/main/java/org/hornetq/core/server/impl/HornetQServerImpl.java 2011-10-17 15:33:40 UTC (rev 11558)
+++ trunk/hornetq-core/src/main/java/org/hornetq/core/server/impl/HornetQServerImpl.java 2011-10-17 15:33:57 UTC (rev 11559)
@@ -40,8 +40,12 @@
import org.hornetq.api.core.HornetQException;
import org.hornetq.api.core.Pair;
import org.hornetq.api.core.SimpleString;
+import org.hornetq.api.core.TransportConfiguration;
+import org.hornetq.api.core.client.ClientSessionFactory;
+import org.hornetq.api.core.client.HornetQClient;
import org.hornetq.core.asyncio.impl.AsynchronousFileImpl;
import org.hornetq.core.client.impl.ClientSessionFactoryImpl;
+import org.hornetq.core.client.impl.ServerLocatorInternal;
import org.hornetq.core.config.BridgeConfiguration;
import org.hornetq.core.config.Configuration;
import org.hornetq.core.config.CoreQueueConfiguration;
@@ -83,6 +87,7 @@
import org.hornetq.core.postoffice.impl.PostOfficeImpl;
import org.hornetq.core.protocol.core.Channel;
import org.hornetq.core.protocol.core.CoreRemotingConnection;
+import org.hornetq.core.protocol.core.impl.ChannelImpl.CHANNEL_ID;
import org.hornetq.core.remoting.server.RemotingService;
import org.hornetq.core.remoting.server.impl.RemotingServiceImpl;
import org.hornetq.core.replication.ReplicationEndpoint;
@@ -362,17 +367,14 @@
if (configuration.isSharedStore() && configuration.isPersistenceEnabled())
{
activation = new SharedStoreLiveActivation();
-
- // This should block until the lock is got
-
- activation.run();
}
else
{
activation = new NoSharedStoreLiveActivation();
+ }
- activation.run();
- }
+ activation.run();
+
started = true;
HornetQServerImpl.log.info("HornetQ Server version " + getVersion().getFullVersion() +
@@ -1862,7 +1864,7 @@
}
}
- private class SharedStoreLiveActivation implements Activation
+ private final class SharedStoreLiveActivation implements Activation
{
public void run()
{
@@ -1923,7 +1925,7 @@
}
}
- private class SharedStoreBackupActivation implements Activation
+ private final class SharedStoreBackupActivation implements Activation
{
public void run()
{
@@ -1984,9 +1986,6 @@
}
}
- /**
- *
- */
public void close(boolean permanently) throws Exception
{
if (configuration.isBackup())
@@ -2029,7 +2028,7 @@
}
}
- private class ShutdownOnCriticalErrorListener implements IOCriticalErrorListener
+ private final class ShutdownOnCriticalErrorListener implements IOCriticalErrorListener
{
boolean failedAlready = false;
@@ -2065,30 +2064,143 @@
void close(boolean permanently) throws Exception;
}
- private class SharedNothingBackupActivation implements Activation
+ private final class SharedNothingBackupActivation implements Activation
{
+ private ServerLocatorInternal serverLocator;
+
public void run()
{
try
{
- // TODO
+ nodeManager.startBackup();
- // Try-Connect to live server using live-connector-ref
+ initialisePart1();
- // sit in loop and try and connect, if server is not live then it will return NOT_LIVE
+ final String liveConnectorName = configuration.getLiveConnectorName();
+ if (liveConnectorName == null)
+ {
+ throw new IllegalArgumentException(
+ "Cannot have a replicated backup without configuring its live-server!");
+ }
+ clusterManager.start();
+
+ final TransportConfiguration config = configuration.getConnectorConfigurations().get(liveConnectorName);
+ serverLocator = (ServerLocatorInternal)HornetQClient.createServerLocatorWithHA(config);
+ final QuorumManager quorumManager = new QuorumManager(serverLocator, nodeManager.getNodeId().toString());
+
+ serverLocator.setReconnectAttempts(-1);
+
+ threadPool.execute(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ try
+ {
+ final ClientSessionFactory liveServerSessionFactory = serverLocator.connect();
+ if (liveServerSessionFactory == null)
+ {
+ // XXX HORNETQ-768
+ throw new RuntimeException("Need to retry?");
+ }
+ CoreRemotingConnection liveConnection = liveServerSessionFactory.getConnection();
+ Channel pingChannel = liveConnection.getChannel(CHANNEL_ID.PING.id, -1);
+ Channel replicationChannel = liveConnection.getChannel(CHANNEL_ID.REPLICATION.id, -1);
+
+ connectToReplicationEndpoint(replicationChannel);
+ replicationEndpoint.start();
+ clusterManager.announceReplicatingBackup(pingChannel);
+ }
+ catch (Exception e)
+ {
+ log.warn("Unable to announce backup for replication.", e);
+ }
+ }
+ });
+
+ log.info("HornetQ Backup Server version " + getVersion().getFullVersion() + " [" + nodeManager.getNodeId() +
+ "] started, waiting live to fail before it gets active");
+ started = true;
+
+ // Server node (i.e. Life node) is not running, now the backup takes over.
+ // we must remember to close stuff we don't need any more
+ while (true)
+ {
+ nodeManager.awaitLiveNode();
+ if (quorumManager.isNodeDown())
+ {
+ break;
+ }
+ }
+
+ serverLocator.close();
+ replicationEndpoint.stop();
+
+ if (!isRemoteBackupUpToDate())
+ {
+ /*
+ * XXX HORNETQ-768 Live is down, and this server was not in sync. Perhaps we should
+ * first try to wait a little longer to see if the 'live' comes back?
+ */
+ throw new HornetQException(HornetQException.ILLEGAL_STATE, "Backup Server was not yet in sync with live");
+ }
+
+ configuration.setBackup(false);
+ synchronized (startUpLock)
+ {
+ if (!started)
+ return;
+ storageManager.start();
+ initialisePart2();
+ clusterManager.activate();
+ }
+
}
catch (Exception e)
{
+ if ((e instanceof InterruptedException || e instanceof IllegalStateException) && !started)
+ // do not log these errors if the server is being stopped.
+ return;
log.error("Failure in initialisation", e);
+ e.printStackTrace();
}
}
- public void close(boolean permanently) throws Exception
+ public void close(final boolean permanently) throws Exception
{
+ if (serverLocator != null)
+ {
+ serverLocator.close();
+ serverLocator = null;
+ }
+
+ if (configuration.isBackup())
+ {
+
+ long timeout = 30000;
+
+ long start = System.currentTimeMillis();
+
+ while (backupActivationThread.isAlive() && System.currentTimeMillis() - start < timeout)
+ {
+ nodeManager.interrupt();
+
+ backupActivationThread.interrupt();
+
+ Thread.sleep(1000);
+ }
+
+ if (System.currentTimeMillis() - start >= timeout)
+ {
+ log.warn("Timed out waiting for backup activation to exit");
+ }
+
+ nodeManager.stopBackup();
+ }
}
}
- private class NoSharedStoreLiveActivation implements Activation
+ private final class NoSharedStoreLiveActivation implements Activation
{
public void run()
{
@@ -2115,7 +2227,14 @@
public void close(boolean permanently) throws Exception
{
-
+ if (permanently)
+ {
+ nodeManager.crashLiveServer();
+ }
+ else
+ {
+ nodeManager.pauseLiveServer();
+ }
}
}
13 years, 2 months
JBoss hornetq SVN: r11558 - in trunk: tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover and 1 other directory.
by do-not-reply@jboss.org
Author: borges
Date: 2011-10-17 11:33:40 -0400 (Mon, 17 Oct 2011)
New Revision: 11558
Modified:
trunk/hornetq-core/src/test/java/org/hornetq/tests/util/UnitTestCase.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/BackupSyncJournalTest.java
Log:
clean-up
Modified: trunk/hornetq-core/src/test/java/org/hornetq/tests/util/UnitTestCase.java
===================================================================
--- trunk/hornetq-core/src/test/java/org/hornetq/tests/util/UnitTestCase.java 2011-10-17 11:51:04 UTC (rev 11557)
+++ trunk/hornetq-core/src/test/java/org/hornetq/tests/util/UnitTestCase.java 2011-10-17 15:33:40 UTC (rev 11558)
@@ -76,7 +76,11 @@
import org.hornetq.core.postoffice.PostOffice;
import org.hornetq.core.postoffice.QueueBinding;
import org.hornetq.core.postoffice.impl.LocalQueueBinding;
+import org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory;
+import org.hornetq.core.remoting.impl.invm.InVMConnectorFactory;
import org.hornetq.core.remoting.impl.invm.InVMRegistry;
+import org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory;
+import org.hornetq.core.remoting.impl.netty.NettyConnectorFactory;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.JournalType;
import org.hornetq.core.server.MessageReference;
@@ -87,9 +91,10 @@
import org.hornetq.utils.UUIDGenerator;
/**
- *
- * Helper base class for our unit tests
- *
+ * Helper base class for our unit tests.
+ * <p>
+ * See {@code org.hornetq.tests.util.ServiceTestBase} for a test case with server set-up.
+ * @see Service
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
* @author <a href="mailto:csuconic@redhat.com">Clebert</a>
*
@@ -100,15 +105,15 @@
private static final Logger log = Logger.getLogger(UnitTestCase.class);
- private static final Logger logInstance = Logger.getLogger(UnitTestCase.class);
+ public static final String INVM_ACCEPTOR_FACTORY = InVMAcceptorFactory.class.getCanonicalName();
- public static final String INVM_ACCEPTOR_FACTORY = "org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory";
+ public static final String INVM_CONNECTOR_FACTORY = InVMConnectorFactory.class.getCanonicalName();
- public static final String INVM_CONNECTOR_FACTORY = "org.hornetq.core.remoting.impl.invm.InVMConnectorFactory";
+ public static final String NETTY_ACCEPTOR_FACTORY = NettyAcceptorFactory.class.getCanonicalName();
- public static final String NETTY_ACCEPTOR_FACTORY = "org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory";
+ public static final String NETTY_CONNECTOR_FACTORY = NettyConnectorFactory.class.getCanonicalName();
- public static final String NETTY_CONNECTOR_FACTORY = "org.hornetq.core.remoting.impl.netty.NettyConnectorFactory";
+ protected static final String CLUSTER_PASSWORD = "UnitTestsClusterPassword";
// Attributes ----------------------------------------------------
@@ -143,7 +148,7 @@
}
}
- protected Configuration createClusteredDefaultConfig(final int index,
+ protected static Configuration createClusteredDefaultConfig(final int index,
final Map<String, Object> params,
final String... acceptors)
{
@@ -154,9 +159,9 @@
return config;
}
- protected Configuration createDefaultConfig(final int index,
- final Map<String, Object> params,
- final String... acceptors)
+ protected static Configuration createDefaultConfig(final int index,
+ final Map<String, Object> params,
+ final String... acceptors)
{
Configuration configuration = createBasicConfig(index);
@@ -171,7 +176,7 @@
return configuration;
}
- protected ConfigurationImpl createBasicConfig()
+ protected static ConfigurationImpl createBasicConfig()
{
return createBasicConfig(0);
}
@@ -180,7 +185,7 @@
* @param serverID
* @return
*/
- protected ConfigurationImpl createBasicConfig(final int serverID)
+ protected static ConfigurationImpl createBasicConfig(final int serverID)
{
ConfigurationImpl configuration = new ConfigurationImpl();
configuration.setSecurityEnabled(false);
@@ -193,10 +198,11 @@
configuration.setLargeMessagesDirectory(getLargeMessagesDir(serverID, false));
configuration.setJournalCompactMinFiles(0);
configuration.setJournalCompactPercentage(0);
+ configuration.setClusterPassword(CLUSTER_PASSWORD);
return configuration;
}
- protected Configuration createDefaultConfig(final Map<String, Object> params, final String... acceptors)
+ protected static Configuration createDefaultConfig(final Map<String, Object> params, final String... acceptors)
{
Configuration configuration = new ConfigurationImpl();
configuration.setSecurityEnabled(false);
@@ -221,16 +227,16 @@
TransportConfiguration transportConfig = new TransportConfiguration(acceptor, params);
configuration.getAcceptorConfigurations().add(transportConfig);
}
-
+ configuration.setClusterPassword(CLUSTER_PASSWORD);
return configuration;
}
- protected String getUDPDiscoveryAddress()
+ protected static String getUDPDiscoveryAddress()
{
return System.getProperty("TEST-UDP-ADDRESS", "230.1.2.3");
}
- protected String getUDPDiscoveryAddress(int variant)
+ protected static String getUDPDiscoveryAddress(final int variant)
{
String value = getUDPDiscoveryAddress();
@@ -241,12 +247,12 @@
return value.substring(0, posPoint + 1) + (last + variant);
}
- public int getUDPDiscoveryPort()
+ public static int getUDPDiscoveryPort()
{
return Integer.parseInt(System.getProperty("TEST-UDP-PORT", "6750"));
}
- public int getUDPDiscoveryPort(final int variant)
+ public static int getUDPDiscoveryPort(final int variant)
{
return getUDPDiscoveryPort() + variant;
}
@@ -278,7 +284,7 @@
public static void forceGC()
{
- logInstance.info("#test forceGC");
+ log.info("#test forceGC");
WeakReference<Object> dumbReference = new WeakReference<Object>(new Object());
// A loop that will wait GC, using the minimal time as possible
while (dumbReference.get() != null)
@@ -292,10 +298,10 @@
{
}
}
- logInstance.info("#test forceGC Done");
+ log.info("#test forceGC Done");
}
- public static void forceGC(Reference<?> ref, long timeout)
+ public static void forceGC(final Reference<?> ref, final long timeout)
{
long waitUntil = System.currentTimeMillis() + timeout;
// A loop that will wait GC, using the minimal time as possible
@@ -635,17 +641,17 @@
/**
* @return the journalDir
*/
- public String getJournalDir()
+ public static String getJournalDir()
{
return getJournalDir(getTestDir());
}
- protected String getJournalDir(final String testDir)
+ protected static String getJournalDir(final String testDir)
{
return testDir + "/journal";
}
- protected String getJournalDir(final int index, final boolean backup)
+ protected static String getJournalDir(final int index, final boolean backup)
{
String dir = getJournalDir(getTestDir()) + index + "-" + (backup ? "B" : "L");
@@ -655,7 +661,7 @@
/**
* @return the bindingsDir
*/
- protected String getBindingsDir()
+ protected static String getBindingsDir()
{
return getBindingsDir(getTestDir());
}
@@ -663,7 +669,7 @@
/**
* @return the bindingsDir
*/
- protected String getBindingsDir(final String testDir)
+ protected static String getBindingsDir(final String testDir)
{
return testDir + "/bindings";
}
@@ -671,7 +677,7 @@
/**
* @return the bindingsDir
*/
- protected String getBindingsDir(final int index, final boolean backup)
+ protected static String getBindingsDir(final int index, final boolean backup)
{
return getBindingsDir(getTestDir()) + index + "-" + (backup ? "B" : "L");
}
@@ -692,7 +698,7 @@
return testDir + "/page";
}
- protected String getPageDir(final int index, final boolean backup)
+ protected static String getPageDir(final int index, final boolean backup)
{
return getPageDir(getTestDir()) + index + "-" + (backup ? "B" : "L");
}
@@ -700,7 +706,7 @@
/**
* @return the largeMessagesDir
*/
- protected String getLargeMessagesDir()
+ protected static String getLargeMessagesDir()
{
return getLargeMessagesDir(getTestDir());
}
@@ -708,12 +714,12 @@
/**
* @return the largeMessagesDir
*/
- protected String getLargeMessagesDir(final String testDir)
+ protected static String getLargeMessagesDir(final String testDir)
{
return testDir + "/large-msg";
}
- protected String getLargeMessagesDir(final int index, final boolean backup)
+ protected static String getLargeMessagesDir(final int index, final boolean backup)
{
return getLargeMessagesDir(getTestDir()) + index + "-" + (backup ? "B" : "L");
}
Modified: trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/BackupSyncJournalTest.java
===================================================================
--- trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/BackupSyncJournalTest.java 2011-10-17 11:51:04 UTC (rev 11557)
+++ trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/BackupSyncJournalTest.java 2011-10-17 15:33:40 UTC (rev 11558)
@@ -231,6 +231,8 @@
sessionFactory.close();
if (session != null)
session.close();
+ if (producer != null)
+ producer.close();
closeServerLocator(locator);
super.tearDown();
13 years, 2 months
JBoss hornetq SVN: r11557 - trunk/tests/jms-tests/src/test/java/org/hornetq/jms/tests.
by do-not-reply@jboss.org
Author: borges
Date: 2011-10-17 07:51:04 -0400 (Mon, 17 Oct 2011)
New Revision: 11557
Modified:
trunk/tests/jms-tests/src/test/java/org/hornetq/jms/tests/HornetQServerTestCase.java
Log:
Make HornetQServerTestCase abstract to avoid "No tests found" error.
Modified: trunk/tests/jms-tests/src/test/java/org/hornetq/jms/tests/HornetQServerTestCase.java
===================================================================
--- trunk/tests/jms-tests/src/test/java/org/hornetq/jms/tests/HornetQServerTestCase.java 2011-10-17 11:31:41 UTC (rev 11556)
+++ trunk/tests/jms-tests/src/test/java/org/hornetq/jms/tests/HornetQServerTestCase.java 2011-10-17 11:51:04 UTC (rev 11557)
@@ -35,7 +35,6 @@
import com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionManagerImple;
-import org.hornetq.api.core.TransportConfiguration;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.security.Role;
import org.hornetq.core.server.HornetQServer;
@@ -51,7 +50,7 @@
* @author <a href="ataylor(a)redhat.com">Andy Taylor</a>
* @author <a href="mailto:jmesnil@redhat.com">Jeff Mesnil</a>
*/
-public class HornetQServerTestCase extends ProxyAssertSupport
+public abstract class HornetQServerTestCase extends ProxyAssertSupport
{
// Constants -----------------------------------------------------
@@ -62,7 +61,7 @@
protected final Logger log = Logger.getLogger(getClass());
// Static --------------------------------------------------------
-
+
/** Some testcases are time sensitive, and we need to make sure a GC would happen before certain scenarios*/
public static void forceGC()
{
13 years, 2 months
JBoss hornetq SVN: r11556 - trunk/hornetq-core/src/test/java/org/hornetq/tests/util.
by do-not-reply@jboss.org
Author: borges
Date: 2011-10-17 07:31:41 -0400 (Mon, 17 Oct 2011)
New Revision: 11556
Modified:
trunk/hornetq-core/src/test/java/org/hornetq/tests/util/UnitTestCase.java
Log:
Make UnitTestCase abstract to avoid "No tests found" error.
Modified: trunk/hornetq-core/src/test/java/org/hornetq/tests/util/UnitTestCase.java
===================================================================
--- trunk/hornetq-core/src/test/java/org/hornetq/tests/util/UnitTestCase.java 2011-10-17 11:07:47 UTC (rev 11555)
+++ trunk/hornetq-core/src/test/java/org/hornetq/tests/util/UnitTestCase.java 2011-10-17 11:31:41 UTC (rev 11556)
@@ -94,7 +94,7 @@
* @author <a href="mailto:csuconic@redhat.com">Clebert</a>
*
*/
-public class UnitTestCase extends TestCase
+public abstract class UnitTestCase extends TestCase
{
// Constants -----------------------------------------------------
13 years, 2 months
JBoss hornetq SVN: r11555 - trunk/tests/integration-tests.
by do-not-reply@jboss.org
Author: borges
Date: 2011-10-17 07:07:47 -0400 (Mon, 17 Oct 2011)
New Revision: 11555
Modified:
trunk/tests/integration-tests/pom.xml
Log:
Delete duplicate declaration of hornetq-commons
Modified: trunk/tests/integration-tests/pom.xml
===================================================================
--- trunk/tests/integration-tests/pom.xml 2011-10-17 11:07:39 UTC (rev 11554)
+++ trunk/tests/integration-tests/pom.xml 2011-10-17 11:07:47 UTC (rev 11555)
@@ -65,11 +65,6 @@
</dependency>
<dependency>
<groupId>org.hornetq</groupId>
- <artifactId>hornetq-commons</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.hornetq</groupId>
<artifactId>hornetq-journal</artifactId>
<version>${project.version}</version>
</dependency>
13 years, 2 months