[jboss-cvs] JBoss Messaging SVN: r1804 - in trunk: src/main/org/jboss/jms/client/container src/main/org/jboss/jms/client/delegate src/main/org/jboss/jms/client/state src/main/org/jboss/jms/server src/main/org/jboss/jms/server/endpoint src/main/org/jboss/jms/tx src/main/org/jboss/messaging/core/plugin/postoffice src/main/org/jboss/messaging/core/plugin/postoffice/cluster tests tests/bin tests/src/org/jboss/test/messaging/core/plugin/postoffice tests/src/org/jboss/test/messaging/jms/clustering tests/src/org/jboss/test/messaging/jms/clustering/base tests/src/org/jboss/test/messaging/tools tests/src/org/jboss/test/messaging/tools/jmx/rmi tests/src/org/jboss/test/messaging/tools/jndi tests/src/org/jboss/test/messaging/util
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Dec 15 23:28:02 EST 2006
Author: ovidiu.feodorov at jboss.com
Date: 2006-12-15 23:27:46 -0500 (Fri, 15 Dec 2006)
New Revision: 1804
Added:
trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterEventNotificationListener.java
trunk/tests/src/org/jboss/test/messaging/jms/clustering/LargeClusterTest.java
trunk/tests/src/org/jboss/test/messaging/jms/clustering/ServerManagementTest.java
Removed:
trunk/tests/src/org/jboss/test/messaging/jms/clustering/SimpleClusteringTest.java
trunk/tests/src/org/jboss/test/messaging/util/ServerManagementTest.java
Modified:
trunk/src/main/org/jboss/jms/client/container/HAAspect.java
trunk/src/main/org/jboss/jms/client/delegate/ClientConnectionDelegate.java
trunk/src/main/org/jboss/jms/client/delegate/ClientConnectionFactoryDelegate.java
trunk/src/main/org/jboss/jms/client/state/SessionState.java
trunk/src/main/org/jboss/jms/server/ServerPeer.java
trunk/src/main/org/jboss/jms/server/endpoint/DeliveryInfo.java
trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionFactoryEndpoint.java
trunk/src/main/org/jboss/jms/server/endpoint/ServerConsumerEndpoint.java
trunk/src/main/org/jboss/jms/server/endpoint/ServerSessionEndpoint.java
trunk/src/main/org/jboss/jms/server/endpoint/SessionEndpoint.java
trunk/src/main/org/jboss/jms/tx/ClientTransaction.java
trunk/src/main/org/jboss/messaging/core/plugin/postoffice/Binding.java
trunk/src/main/org/jboss/messaging/core/plugin/postoffice/DefaultBinding.java
trunk/src/main/org/jboss/messaging/core/plugin/postoffice/DefaultPostOffice.java
trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/DefaultClusteredBindings.java
trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/DefaultClusteredPostOffice.java
trunk/tests/bin/runtest
trunk/tests/build.xml
trunk/tests/src/org/jboss/test/messaging/core/plugin/postoffice/DefaultPostOfficeTest.java
trunk/tests/src/org/jboss/test/messaging/jms/clustering/FailoverTest.java
trunk/tests/src/org/jboss/test/messaging/jms/clustering/GroupManagementTest.java
trunk/tests/src/org/jboss/test/messaging/jms/clustering/HATest.java
trunk/tests/src/org/jboss/test/messaging/jms/clustering/base/ClusteringTestBase.java
trunk/tests/src/org/jboss/test/messaging/tools/ServerManagement.java
trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/LocalTestServer.java
trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/RMITestServer.java
trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/Server.java
trunk/tests/src/org/jboss/test/messaging/tools/jndi/RemoteContext.java
Log:
Various tweaks to get clustering tests pass in one go.
If they don't then there's a race condition (or more) I haven't managed to catch.
Modified: trunk/src/main/org/jboss/jms/client/container/HAAspect.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/container/HAAspect.java 2006-12-15 22:00:01 UTC (rev 1803)
+++ trunk/src/main/org/jboss/jms/client/container/HAAspect.java 2006-12-16 04:27:46 UTC (rev 1804)
@@ -328,7 +328,8 @@
}
private void performClientSideFailover(ClientConnectionDelegate failedConnDelegate,
- ClientConnectionDelegate newConnDelegate) throws Exception
+ ClientConnectionDelegate newConnDelegate)
+ throws Exception
{
log.debug(this + " performing client side failover");
@@ -345,17 +346,17 @@
CallbackManager oldCallbackManager = failedState.getRemotingConnection().getCallbackManager();
- //We need to update some of the attributes on the state
+ // We need to update some of the attributes on the state
failedState.copyState(newState);
- //Map of old session id to new session state
+ // Map of old session ID to new session state
Map oldNewSessionStateMap = new HashMap();
for(Iterator i = failedState.getChildren().iterator(); i.hasNext(); )
{
SessionState failedSessionState = (SessionState)i.next();
- int oldSessionId = failedSessionState.getSessionId();
+ int oldSessionID = failedSessionState.getSessionId();
ClientSessionDelegate failedSessionDelegate =
(ClientSessionDelegate)failedSessionState.getDelegate();
@@ -367,17 +368,15 @@
SessionState newSessionState = (SessionState)newSessionDelegate.getState();
- if (trace) { log.trace("New session state has " + newSessionState.getClientAckList().size() + " deliveries"); }
+ if (trace) { log.trace("new session state has " + newSessionState.getClientAckList().size() + " deliveries"); }
- oldNewSessionStateMap.put(new Integer(oldSessionId), failedSessionState);
+ oldNewSessionStateMap.put(new Integer(oldSessionID), failedSessionState);
failedSessionDelegate.copyAttributes(newSessionDelegate);
- //We need to update some of the attributes on the state
+ // We need to update some of the attributes on the state
failedSessionState.copyState(newSessionState);
- if (trace) { log.trace("replacing session (" + failedSessionDelegate + ") with a new failover session " + newSessionDelegate); }
-
List children = new ArrayList();
// TODO Why is this clone necessary?
@@ -393,10 +392,8 @@
}
else if (sessionChild instanceof ConsumerState)
{
- handleFailoverOnConsumer(failedConnDelegate,
- (ConsumerState)sessionChild,
- failedSessionDelegate,
- oldCallbackManager);
+ handleFailoverOnConsumer(failedConnDelegate, (ConsumerState)sessionChild,
+ failedSessionDelegate, oldCallbackManager);
}
else if (sessionChild instanceof BrowserState)
{
@@ -405,46 +402,38 @@
}
}
- //First we must tell the resource manager to substitute old session id for new session id
- //Note we MUST submit the entire mapping in one operation since there may be overlap between
- //old and new session id, and we don't want to overwrite keys in the map
+ // First we must tell the resource manager to substitute old session ID for new session ID.
+ // Note we MUST submit the entire mapping in one operation since there may be overlap between
+ // old and new session ID, and we don't want to overwrite keys in the map.
failedState.getResourceManager().handleFailover(oldNewSessionStateMap);
- Iterator iter = oldNewSessionStateMap.values().iterator();
-
- while (iter.hasNext())
+ for(Iterator i = oldNewSessionStateMap.values().iterator(); i.hasNext(); )
{
- SessionState state = (SessionState)iter.next();
-
- List ackInfos = null;
-
+ List ackInfos = Collections.EMPTY_LIST;
+
+ SessionState state = (SessionState)i.next();
+
if (!state.isTransacted() ||
(state.isXA() && state.getCurrentTxId() == null))
{
- //Non transacted session or an XA session with no transaction set (it falls back to auto_ack)
+ // Non transacted session or an XA session with no transaction set (it falls back
+ // to auto_ack)
- if (trace) { log.trace("Session is not transacted (or XA with no tx set), retrieving deliveries from session state"); }
+ if (trace) { log.trace(state + " is not transacted (or XA with no tx set), retrieving deliveries from session state"); }
+ // We remove any unacked non-persistent messages - this is because we don't want to ack
+ // them since the server won't know about them and will get confused
- //we remove any unacked np messages - this is because we don't want to ack them
- //since the server won't know about them and will barf
-
if (state.getAcknowledgeMode() == Session.CLIENT_ACKNOWLEDGE)
{
- Iterator iter2 = state.getClientAckList().iterator();
-
- if (trace) { log.trace("Removing any np deliveries"); }
-
- while (iter2.hasNext())
+ for(Iterator j = state.getClientAckList().iterator(); j.hasNext(); )
{
- DeliveryInfo info = (DeliveryInfo)iter2.next();
-
+ DeliveryInfo info = (DeliveryInfo)j.next();
if (!info.getMessageProxy().getMessage().isReliable())
{
- iter2.remove();
-
- if (trace) { log.trace("Removed np delivery: " + info.getDeliveryId()); }
+ j.remove();
+ if (trace) { log.trace("removed non persistent delivery " + info); }
}
}
@@ -457,27 +446,26 @@
{
if (!autoAck.getMessageProxy().getMessage().isReliable())
{
- //unreliable
+ // unreliable, discard
state.setAutoAckInfo(null);
- ackInfos = Collections.EMPTY_LIST;
}
else
{
- //reliable
+ // reliable
ackInfos = new ArrayList();
ackInfos.add(autoAck);
}
}
}
- if (trace) { log.trace("Retrieved " + ackInfos.size() + " deliveries"); }
+ if (trace) { log.trace(this + " retrieved " + ackInfos.size() + " deliveries"); }
}
else
{
- //Transacted session - we need to get the acks from the resource manager
- //btw we have kept the old resource manager
- ResourceManager rm = failedState.getResourceManager();
+ // Transacted session - we need to get the acks from the resource manager. BTW we have
+ // kept the old resource manager
+ ResourceManager rm = failedState.getResourceManager();
ackInfos = rm.getDeliveriesForSession(state.getSessionId());
}
Modified: trunk/src/main/org/jboss/jms/client/delegate/ClientConnectionDelegate.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/delegate/ClientConnectionDelegate.java 2006-12-15 22:00:01 UTC (rev 1803)
+++ trunk/src/main/org/jboss/jms/client/delegate/ClientConnectionDelegate.java 2006-12-16 04:27:46 UTC (rev 1804)
@@ -217,7 +217,7 @@
public String toString()
{
- return "ConnectionDelegate[id:" + id + ", serverid:" + serverID + "]";
+ return "ConnectionDelegate[" + id + ", SID=" + serverID + "]";
}
public void init()
Modified: trunk/src/main/org/jboss/jms/client/delegate/ClientConnectionFactoryDelegate.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/delegate/ClientConnectionFactoryDelegate.java 2006-12-15 22:00:01 UTC (rev 1803)
+++ trunk/src/main/org/jboss/jms/client/delegate/ClientConnectionFactoryDelegate.java 2006-12-16 04:27:46 UTC (rev 1804)
@@ -294,7 +294,7 @@
public String toString()
{
- return "ConnectionFactoryDelegate[" + id + ", " + serverID + "]";
+ return "ConnectionFactoryDelegate[" + id + ", SID=" + serverID + "]";
}
public String getServerLocatorURI()
Modified: trunk/src/main/org/jboss/jms/client/state/SessionState.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/state/SessionState.java 2006-12-15 22:00:01 UTC (rev 1803)
+++ trunk/src/main/org/jboss/jms/client/state/SessionState.java 2006-12-16 04:27:46 UTC (rev 1804)
@@ -70,7 +70,7 @@
private boolean recoverCalled;
// List<DeliveryInfo>
- private List ClientAckList;
+ private List clientAckList;
private DeliveryInfo autoAckInfo;
@@ -109,7 +109,7 @@
executor = new QueuedExecutor(new LinkedQueue());
- ClientAckList = new ArrayList();
+ clientAckList = new ArrayList();
// TODO could optimise this to use the same map of callbackmanagers (which holds refs
// to callbackhandlers) in the connection, instead of maintaining another map
@@ -142,7 +142,7 @@
*/
public List getClientAckList()
{
- return ClientAckList;
+ return clientAckList;
}
public DeliveryInfo getAutoAckInfo()
Modified: trunk/src/main/org/jboss/jms/server/ServerPeer.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/ServerPeer.java 2006-12-15 22:00:01 UTC (rev 1803)
+++ trunk/src/main/org/jboss/jms/server/ServerPeer.java 2006-12-16 04:27:46 UTC (rev 1804)
@@ -727,84 +727,79 @@
}
/*
- * Wait for failover from the specified node to complete
+ * Wait for failover from the specified node to complete.
*/
- public int waitForFailover(int failedNodeId) throws Exception
+ public int waitForFailover(int failedNodeID) throws Exception
{
- //This node may be failing over for another node - in which case we must wait for that to be complete
+ // This node may be failing over for another node - in which case we must wait for that to be
+ // complete.
- log.info(this + " waiting for server-side failover from failed node " + failedNodeId);
+ log.info(this + " waiting for server-side failover for failed node " + failedNodeID + " to complete");
Replicator replicator = getReplicator();
-
- // Failover
long startToWait = failoverStartTimeout;
-
long completeToWait = failoverCompleteTimeout;
- //Must lock here
+ // Must lock here
synchronized (failoverStatusLock)
{
while (true)
{
//TODO we shouldn't have a dependency on DefaultClusteredPostOffice - where should we put the constants?
+
Map replicants = replicator.get(DefaultClusteredPostOffice.FAILED_OVER_FOR_KEY);
boolean foundEntry = false;
if (replicants != null)
{
- Iterator iter = replicants.entrySet().iterator();
-
- while (iter.hasNext())
+ for(Iterator i = replicants.entrySet().iterator(); i.hasNext(); )
{
- Map.Entry entry = (Map.Entry)iter.next();
-
+ Map.Entry entry = (Map.Entry)i.next();
Integer nid = (Integer)entry.getKey();
-
FailoverStatus status = (FailoverStatus)entry.getValue();
- if (status.isFailedOverForNode(failedNodeId))
+ if (status.isFailedOverForNode(failedNodeID))
{
- log.info("Fail over is complete on node " + nid);
- //Got the node - failover has completed
- return nid.intValue();
+ log.info(this + ": failover is complete on node " + nid);
+ return nid.intValue();
}
- else if (status.isFailingOverForNode(failedNodeId))
+ else if (status.isFailingOverForNode(failedNodeID))
{
- log.info("Fail over is in progress on node " + nid);
+ log.info(this + ": fail over is in progress on node " + nid);
- //A server has started failing over for the failed node, but not completed
- //if it's not this node then we immediately return so the connection can be redirected to
- //another node
+ // A server has started failing over for the failed node, but not completed.
+ // If it's not this node then we immediately return so the connection can be
+ // redirected to another node.
if (nid.intValue() != this.getServerPeerID())
{
return nid.intValue();
}
- //Otherwise we wait for failover to complete
+ // Otherwise we wait for failover to complete
if (completeToWait <= 0)
{
- //Give up now
- log.info("Already waited long enough for failover to complete, giving up");
+ // Give up now
+ log.info(this + " already waited long enough for failover to complete, giving up");
return -1;
}
- //Note - we have to count the time since other unrelated nodes may fail and wake
- //up the lock - in this case we don't want to give up too early
- long start = System.currentTimeMillis();
+ // Note - we have to count the time since other unrelated nodes may fail and
+ // wake up the lock - in this case we don't want to give up too early.
+ long start = System.currentTimeMillis();
+
try
{
- log.info("Waiting for failover to complete");
+ log.debug(this + " blocking on the failover lock, waiting for failover to complete");
failoverStatusLock.wait(completeToWait);
+ log.debug(this + " releasing the failover lock, checking again whether failover completed ...");
}
catch (InterruptedException ignore)
{
}
completeToWait -= System.currentTimeMillis() - start;
-
foundEntry = true;
}
}
@@ -812,29 +807,29 @@
if (!foundEntry)
{
- //No trace of failover happening
- //so we wait a maximum of FAILOVER_START_TIMEOUT for some replicated data to arrive
- //This should arrive fairly quickly since this is added at the beginning of the failover process
- //If it doesn't arrive it would imply that no failover has actually happened on the server
- //or the timeout is too short.
- //It is possible that no failover has actually happened on the server, if for example there
- //is a problem with the client side network but the server side network is ok.
+ // No trace of failover happening so we wait a maximum of FAILOVER_START_TIMEOUT for
+ // some replicated data to arrive. This should arrive fairly quickly since this is
+ // added at the beginning of the failover process. If it doesn't arrive it would
+ // imply that no failover has actually happened on the server or the timeout is too
+ // short. It is possible that no failover has actually happened on the server, if for
+ // example there is a problem with the client side network but the server side
+ // network is ok.
if (startToWait <= 0)
{
- //Don't want to wait again
- log.info("Already waited long enough for failover to start, giving up");
+ // Don't want to wait again
+ log.info(this + " already waited long enough for failover to start, giving up");
return -1;
}
- //Note - we have to count the time since other unrelated nodes may fail and wake
- //up the lock - in this case we don't want to give up too early
+ // Note - we have to count the time since other unrelated nodes may fail and wake
+ // up the lock - in this case we don't want to give up too early.
long start = System.currentTimeMillis();
try
{
- log.info("Waiting for failover to start");
+ log.debug(this + " blocking on the failover lock, waiting for failover to start");
failoverStatusLock.wait(startToWait);
- log.info("Finished waiting for failover to start");
+ log.debug(this + " releasing the failover lock, checking again whether failover started ...");
}
catch (InterruptedException ignore)
{
@@ -847,7 +842,7 @@
public String toString()
{
- return "ServerPeer [" + getServerPeerID() + "]";
+ return "ServerPeer[" + getServerPeerID() + "]";
}
// Package protected ---------------------------------------------
Modified: trunk/src/main/org/jboss/jms/server/endpoint/DeliveryInfo.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/DeliveryInfo.java 2006-12-15 22:00:01 UTC (rev 1803)
+++ trunk/src/main/org/jboss/jms/server/endpoint/DeliveryInfo.java 2006-12-16 04:27:46 UTC (rev 1804)
@@ -95,8 +95,12 @@
{
return connectionConsumerSession;
}
-
+ public String toString()
+ {
+ return "Delivery[" + msg + "]";
+ }
+
// Ack Implementation -------------------------------------------
public long getDeliveryId()
Modified: trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionFactoryEndpoint.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionFactoryEndpoint.java 2006-12-15 22:00:01 UTC (rev 1803)
+++ trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionFactoryEndpoint.java 2006-12-16 04:27:46 UTC (rev 1804)
@@ -108,8 +108,8 @@
}
else
{
- log.debug(this + " creating a failover connection " +
- "to replace connection to failed node " + failedNodeID);
+ log.debug(this + " received client-side failover request. Creating failover "+
+ "connection to replace connection to failed node " + failedNodeID);
// Wait for server side failover to complete
int failoverNodeID = serverPeer.waitForFailover(failedNodeID);
Modified: trunk/src/main/org/jboss/jms/server/endpoint/ServerConsumerEndpoint.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/ServerConsumerEndpoint.java 2006-12-15 22:00:01 UTC (rev 1803)
+++ trunk/src/main/org/jboss/jms/server/endpoint/ServerConsumerEndpoint.java 2006-12-16 04:27:46 UTC (rev 1804)
@@ -254,8 +254,9 @@
{
try
{
- if (trace) { log.trace(this + " scheduling a new Deliverer"); }
- this.executor.execute(new Deliverer());
+ Deliverer deliverer = new Deliverer();
+ if (trace) { log.trace(this + " scheduling a new " + deliverer); }
+ this.executor.execute(deliverer);
}
catch (InterruptedException e)
{
Modified: trunk/src/main/org/jboss/jms/server/endpoint/ServerSessionEndpoint.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/ServerSessionEndpoint.java 2006-12-15 22:00:01 UTC (rev 1803)
+++ trunk/src/main/org/jboss/jms/server/endpoint/ServerSessionEndpoint.java 2006-12-16 04:27:46 UTC (rev 1804)
@@ -822,7 +822,7 @@
deliveries.put(new Long(deliveryId), del);
- if (trace) { log.trace(this + " Added delivery: " + deliveryId + ", " + del); }
+ if (trace) { log.trace(this + " added delivery " + deliveryId + ": " + del); }
return deliveryId;
}
Modified: trunk/src/main/org/jboss/jms/server/endpoint/SessionEndpoint.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/SessionEndpoint.java 2006-12-15 22:00:01 UTC (rev 1803)
+++ trunk/src/main/org/jboss/jms/server/endpoint/SessionEndpoint.java 2006-12-16 04:27:46 UTC (rev 1804)
@@ -69,21 +69,18 @@
/**
* Acknowledge a list of deliveries
- * @param ackInfos
* @throws JMSException
*/
void acknowledgeDeliveries(List deliveryIds) throws JMSException;
/**
* Acknowledge a delivery
- * @param deliveryId
* @throws JMSException
*/
void acknowledgeDelivery(Ack ack) throws JMSException;
/**
* Cancel a list of deliveries.
- * @param ackInfos
*/
void cancelDeliveries(List cancelInfos) throws JMSException;
Modified: trunk/src/main/org/jboss/jms/tx/ClientTransaction.java
===================================================================
--- trunk/src/main/org/jboss/jms/tx/ClientTransaction.java 2006-12-15 22:00:01 UTC (rev 1803)
+++ trunk/src/main/org/jboss/jms/tx/ClientTransaction.java 2006-12-16 04:27:46 UTC (rev 1804)
@@ -140,7 +140,7 @@
}
else
{
- return sessionStatesMap == null ? Collections.emptySet() : sessionStatesMap.values();
+ return sessionStatesMap == null ? Collections.EMPTY_SET : sessionStatesMap.values();
}
}
Modified: trunk/src/main/org/jboss/messaging/core/plugin/postoffice/Binding.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/plugin/postoffice/Binding.java 2006-12-15 22:00:01 UTC (rev 1803)
+++ trunk/src/main/org/jboss/messaging/core/plugin/postoffice/Binding.java 2006-12-16 04:27:46 UTC (rev 1804)
@@ -35,7 +35,7 @@
*/
public interface Binding
{
- public int getNodeId();
+ public int getNodeID();
public Condition getCondition();
Modified: trunk/src/main/org/jboss/messaging/core/plugin/postoffice/DefaultBinding.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/plugin/postoffice/DefaultBinding.java 2006-12-15 22:00:01 UTC (rev 1803)
+++ trunk/src/main/org/jboss/messaging/core/plugin/postoffice/DefaultBinding.java 2006-12-16 04:27:46 UTC (rev 1804)
@@ -36,32 +36,42 @@
*/
public class DefaultBinding implements Binding
{
- private int nodeId;
-
+ // Constants -----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ private int nodeID;
+
private Condition condition;
-
+
private Queue queue;
private boolean failed;
+ // this only works if we keep DefautlBinding immutable
+ private String toString;
+
+ // Constructors --------------------------------------------------
+
public DefaultBinding()
{
}
- public DefaultBinding(int nodeId, Condition condition, Queue queue, boolean failed)
+ public DefaultBinding(int nodeID, Condition condition, Queue queue, boolean failed)
{
- this.nodeId = nodeId;
-
+ this.nodeID = nodeID;
this.condition = condition;
-
this.queue = queue;
-
this.failed = failed;
}
- public int getNodeId()
+ // Binding implementation ----------------------------------------
+
+ public int getNodeID()
{
- return nodeId;
+ return nodeID;
}
public Condition getCondition()
@@ -84,9 +94,36 @@
this.failed = failed;
}
+ // Public --------------------------------------------------------
+
public String toString()
{
- return "Node" + nodeId + " condition=" + condition + " queue=" + queue + " queueClass=" + queue.getClass().getName();
+ if (toString == null)
+ {
+ StringBuffer sb = new StringBuffer("Binding[");
+
+ sb.append(nodeID).append(',');
+ sb.append(queue).append('(');
+ sb.append(queue.getClass().getName()).append(')');
+
+ if (condition != null)
+ {
+ sb.append(", condition: ").append(condition);
+ }
+ sb.append("]");
+ toString = sb.toString();
+ }
+
+ return toString;
}
-
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+
}
Modified: trunk/src/main/org/jboss/messaging/core/plugin/postoffice/DefaultPostOffice.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/plugin/postoffice/DefaultPostOffice.java 2006-12-15 22:00:01 UTC (rev 1803)
+++ trunk/src/main/org/jboss/messaging/core/plugin/postoffice/DefaultPostOffice.java 2006-12-16 04:27:46 UTC (rev 1804)
@@ -91,10 +91,10 @@
protected int currentNodeId;
- //Map <node id, Map < queue name, binding > >
+ // Map <NodeID, Map<queueName, Binding>>
protected Map nameMaps;
- //Map <condition, List <binding> >
+ // Map <condition, List<Binding>>
protected Map conditionMap;
protected FilterFactory filterFactory;
@@ -352,7 +352,7 @@
Binding binding = (Binding)iter.next();
//Sanity check
- if (binding.getNodeId() != this.currentNodeId)
+ if (binding.getNodeID() != this.currentNodeId)
{
throw new IllegalStateException("Local post office has foreign bindings!");
}
@@ -420,7 +420,7 @@
{
Binding binding = (Binding)iter.next();
- if (!localOnly || (binding.getNodeId() == this.currentNodeId))
+ if (!localOnly || (binding.getNodeID() == this.currentNodeId))
{
list.add(binding);
}
@@ -696,7 +696,6 @@
protected void addBinding(Binding binding)
{
addToNameMap(binding);
-
addToConditionMap(binding);
}
@@ -711,16 +710,18 @@
protected void addToNameMap(Binding binding)
{
- Map nameMap = (Map)nameMaps.get(new Integer(binding.getNodeId()));
+ Integer nodeID = new Integer(binding.getNodeID());
+ Map nameMap = (Map)nameMaps.get(nodeID);
if (nameMap == null)
{
nameMap = new LinkedHashMap();
-
- nameMaps.put(new Integer(binding.getNodeId()), nameMap);
+ nameMaps.put(nodeID, nameMap);
}
nameMap.put(binding.getQueue().getName(), binding);
+
+ if (trace) { log.trace(this + " added " + binding + " to name map"); }
}
protected void addToConditionMap(Binding binding)
@@ -737,6 +738,8 @@
}
bindings.addBinding(binding);
+
+ if (trace) { log.trace(this + " added " + binding + " to condition map"); }
}
protected Binding removeFromNameMap(int nodeId, String queueName)
Modified: trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/DefaultClusteredBindings.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/DefaultClusteredBindings.java 2006-12-15 22:00:01 UTC (rev 1803)
+++ trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/DefaultClusteredBindings.java 2006-12-16 04:27:46 UTC (rev 1804)
@@ -61,7 +61,7 @@
{
super.addBinding(binding);
- if (binding.getNodeId() == thisNode && binding.getQueue().isRecoverable())
+ if (binding.getNodeID() == thisNode && binding.getQueue().isRecoverable())
{
localDurableCount++;
}
@@ -76,7 +76,7 @@
return false;
}
- if (binding.getNodeId() == thisNode && binding.getQueue().isRecoverable())
+ if (binding.getNodeID() == thisNode && binding.getQueue().isRecoverable())
{
localDurableCount--;
}
Modified: trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/DefaultClusteredPostOffice.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/DefaultClusteredPostOffice.java 2006-12-15 22:00:01 UTC (rev 1803)
+++ trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/DefaultClusteredPostOffice.java 2006-12-16 04:27:46 UTC (rev 1804)
@@ -549,11 +549,8 @@
{
lock.writeLock().acquire();
- if (trace)
- {
- log.info(this.currentNodeId + " adding binding from node: " + nodeId +
- " queue: " + queueName + " with condition: " + conditionText);
- }
+ log.debug(this + " adding binding from node " + nodeId + ", queue " + queueName +
+ " with condition " + conditionText);
Condition condition = conditionFactory.createCondition(conditionText);
@@ -578,12 +575,12 @@
if (binding != null && failed)
{
- throw new IllegalArgumentException(this.currentNodeId +
- " Binding already exists for node Id " + nodeId + " queue name " + queueName);
+ throw new IllegalArgumentException(this + " has already this binding for node " +
+ nodeId + ", queue " + queueName);
}
- binding = this.createBinding(nodeId, condition, queueName, channelID, filterString,
- durable, failed);
+ binding =
+ createBinding(nodeId, condition, queueName, channelID, filterString, durable, failed);
addBinding(binding);
}
@@ -591,8 +588,6 @@
{
lock.writeLock().release();
}
-
- log.info("****** binding added");
}
/*
@@ -723,7 +718,7 @@
{
Binding binding = (Binding)iter.next();
- if (binding.getNodeId() == this.currentNodeId)
+ if (binding.getNodeID() == this.currentNodeId)
{
boolean handle = true;
@@ -1847,7 +1842,7 @@
Queue queue = binding.getQueue();
- BindingInfo info = new BindingInfo(binding.getNodeId(), queue.getName(),
+ BindingInfo info = new BindingInfo(binding.getNodeID(), queue.getName(),
binding.getCondition().toText(),
queue.getFilter() == null ? null : queue.getFilter().getFilterString(),
queue.getChannelID(),
@@ -1898,7 +1893,7 @@
Binding binding = this.createBinding(info.getNodeId(), condition, info.getQueueName(), info.getChannelId(),
info.getFilterString(), info.isDurable(),info.isFailed());
- if (binding.getNodeId() == this.currentNodeId)
+ if (binding.getNodeID() == this.currentNodeId)
{
//We deactivate if this is one of our own bindings - it can only
//be one of our own durable bindings - and since state is retrieved before we are fully started
@@ -2112,10 +2107,9 @@
}
else
{
- // Compile a list of the queue names to remove.
- // Note that any non durable bindings will already have been removed (in
- // removeDataForNode()) when the node leave was detected, so if there are any non durable
- // bindings left here then this is an error.
+ // Compile a list of the queue names to remove. Note that any non durable bindings will
+ // already have been removed (in removeDataForNode()) when the node leave was detected,
+ // so if there are any non durable bindings left here then this is an error.
// We iterate through twice to avoid ConcurrentModificationException
@@ -2129,8 +2123,8 @@
// Sanity check
if (!binding.getQueue().isRecoverable())
{
- throw new IllegalStateException("Found non recoverable queue in map, " +
- "these should have been removed!");
+ throw new IllegalStateException("Found non recoverable queue " +
+ binding.getQueue().getName() + "in map, these should have been removed!");
}
// Sanity check
@@ -2247,13 +2241,13 @@
private void addIntoFailedMaps(Binding binding)
{
- Map channelMap = (Map)failedBindings.get(new Integer(binding.getNodeId()));
+ Map channelMap = (Map)failedBindings.get(new Integer(binding.getNodeID()));
if (channelMap == null)
{
channelMap = new LinkedHashMap();
- failedBindings.put(new Integer(binding.getNodeId()), channelMap);
+ failedBindings.put(new Integer(binding.getNodeID()), channelMap);
}
channelMap.put(new Long(binding.getQueue().getChannelID()), binding);
Modified: trunk/tests/bin/runtest
===================================================================
--- trunk/tests/bin/runtest 2006-12-15 22:00:01 UTC (rev 1803)
+++ trunk/tests/bin/runtest 2006-12-16 04:27:46 UTC (rev 1804)
@@ -48,8 +48,6 @@
TEST_REMOTING=$ENV_TEST_REMOTING
fi
-TEST_DATABASE=mysql
-
#
# We should use the same test execution classpath as the ant <junit> task, so we run ant to get
# it from there.
@@ -95,21 +93,33 @@
fi
JAVA_OPTS="$DEBUG_OPTS"
fi
+ shift
+ continue;
fi
if [ "$1" = "-remote" ]; then
isRemote=true;
REMOTE_TEST="-Dremote=true"
+ shift
+ continue;
fi
if [ "$1" = "-remotedebug" ]; then
remote_debug=true
+ shift
+ continue;
fi
if [ "$1" = "0" -o "$1" = "1" -o "$1" = "2" ]; then
remote_debug_index=$1
+ shift
+ continue;
fi
if [ "$1" = "-clustered" ]; then
TEST_CLUSTERED=true
+ shift
+ continue;
+ else
+ echo "Error, unknown switch: $1"
+ exit 1
fi
- shift
done
JAVA_OPTS="-Xmx1024M $JAVA_OPTS -Dmodule.output=$reldir/../output $REMOTE_TEST -Dtest.database=$TEST_DATABASE -Dtest.serialization=$TEST_SERIALIZATION -Dtest.clustered=$TEST_CLUSTERED -Dtest.remoting=$TEST_REMOTING -Dbuild.lib=../../output/lib"
Modified: trunk/tests/build.xml
===================================================================
--- trunk/tests/build.xml 2006-12-15 22:00:01 UTC (rev 1803)
+++ trunk/tests/build.xml 2006-12-16 04:27:46 UTC (rev 1804)
@@ -756,8 +756,7 @@
<fileset dir="${build.tests.classes}">
<!--
- <include name="**/jms/clustering/*Test.class"/>
- <include name="org/jboss/test/messaging/util/ServerManagementTest.class"/>
+ <include name="**/jms/clustering/FailoverTest.class"/>
-->
<include name="**/jms/clustering/*Test.class"/>
</fileset>
Modified: trunk/tests/src/org/jboss/test/messaging/core/plugin/postoffice/DefaultPostOfficeTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/core/plugin/postoffice/DefaultPostOfficeTest.java 2006-12-15 22:00:01 UTC (rev 1803)
+++ trunk/tests/src/org/jboss/test/messaging/core/plugin/postoffice/DefaultPostOfficeTest.java 2006-12-16 04:27:46 UTC (rev 1804)
@@ -1084,7 +1084,7 @@
protected void assertEquivalent(Binding binding1, Binding binding2)
{
- assertEquals(binding1.getNodeId(), binding2.getNodeId());
+ assertEquals(binding1.getNodeID(), binding2.getNodeID());
assertEquals(binding1.getQueue().getName(), binding2.getQueue().getName());
String selector1 = binding1.getQueue().getFilter() != null ? binding1.getQueue().getFilter().getFilterString() : null;
String selector2 = binding2.getQueue().getFilter() != null ? binding2.getQueue().getFilter().getFilterString() : null;
Added: trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterEventNotificationListener.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterEventNotificationListener.java 2006-12-15 22:00:01 UTC (rev 1803)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterEventNotificationListener.java 2006-12-16 04:27:46 UTC (rev 1804)
@@ -0,0 +1,111 @@
+/**
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.test.messaging.jms.clustering;
+
+import EDU.oswego.cs.dl.util.concurrent.Slot;
+
+import javax.management.NotificationListener;
+import javax.management.Notification;
+
+import org.jboss.messaging.core.plugin.contract.ClusteredPostOffice;
+import org.jboss.logging.Logger;
+
+/**
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
+ * @version <tt>$Revision$</tt>
+ * $Id$
+ */
+class ClusterEventNotificationListener implements NotificationListener
+{
+ // Constants -----------------------------------------------------
+
+ private static final Logger log = Logger.getLogger(ClusterEventNotificationListener.class);
+
+ // Static --------------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ private Slot viewChange;
+ private Slot failoverCompleted;
+
+ // Constructors --------------------------------------------------
+
+ ClusterEventNotificationListener()
+ {
+ viewChange = new Slot();
+ failoverCompleted = new Slot();
+ }
+
+ // NotificationListener implementation ---------------------------
+
+ public void handleNotification(Notification notification, Object object)
+ {
+ String type = notification.getType();
+
+ log.info("received " + type + " notification");
+
+ if (ClusteredPostOffice.VIEW_CHANGED_NOTIFICATION.equals(type))
+ {
+ try
+ {
+ viewChange.put(Boolean.TRUE);
+ }
+ catch(InterruptedException e)
+ {
+ log.error(e);
+ }
+ }
+ else if (ClusteredPostOffice.FAILOVER_COMPLETED_NOTIFICATION.equals(type))
+ {
+ try
+ {
+ failoverCompleted.put(Boolean.TRUE);
+ }
+ catch(InterruptedException e)
+ {
+ log.error(e);
+ }
+ }
+ else
+ {
+ log.info("Ignoring notification " + type);
+ }
+ }
+
+ public boolean viewChanged(long timeout) throws InterruptedException
+ {
+ Boolean result = (Boolean)viewChange.poll(timeout);
+ if (result == null)
+ {
+ return false;
+ }
+ return result.booleanValue();
+ }
+
+ public boolean failoverCompleted(long timeout) throws InterruptedException
+ {
+ Boolean result = (Boolean)failoverCompleted.poll(timeout);
+ if (result == null)
+ {
+ return false;
+ }
+ return result.booleanValue();
+ }
+
+ // Public --------------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
+
+
+
Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/FailoverTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/FailoverTest.java 2006-12-15 22:00:01 UTC (rev 1803)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/FailoverTest.java 2006-12-16 04:27:46 UTC (rev 1804)
@@ -85,8 +85,8 @@
log.info("########");
// TODO - this shouldn't be necessary if we have the client valve in place
- log.info("Sleeping for 1 min");
- Thread.sleep(15000);
+ log.info("Sleeping for 60 sec");
+ Thread.sleep(60000);
// we must receive the message
Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/GroupManagementTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/GroupManagementTest.java 2006-12-15 22:00:01 UTC (rev 1803)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/GroupManagementTest.java 2006-12-16 04:27:46 UTC (rev 1804)
@@ -8,15 +8,9 @@
import org.jboss.test.messaging.MessagingTestCase;
import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.messaging.core.plugin.contract.ClusteredPostOffice;
-
-import javax.management.NotificationListener;
-import javax.management.Notification;
import javax.management.ObjectName;
import java.util.Set;
-import EDU.oswego.cs.dl.util.concurrent.Slot;
-
/**
* @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
* @version <tt>$Revision$</tt>
@@ -47,7 +41,6 @@
ServerManagement.start(0, "all");
Set view = ServerManagement.getServer(0).getNodeIDView();
-
assertEquals(1, view.size());
assertTrue(view.contains(new Integer(0)));
}
@@ -66,12 +59,8 @@
{
ServerManagement.start(0, "all");
- log.info("Server 0 started");
-
ServerManagement.addNotificationListener(0, postOfficeObjectName, listener);
- log.info("NotificationListener added to server 0");
-
ServerManagement.start(1, "all");
log.info("Blocking to receive notification ...");
@@ -82,7 +71,6 @@
}
Set view = ServerManagement.getServer(1).getNodeIDView();
-
assertEquals(2, view.size());
assertTrue(view.contains(new Integer(0)));
assertTrue(view.contains(new Integer(1)));
@@ -102,14 +90,12 @@
ServerManagement.start(0, "all");
Set view = ServerManagement.getServer(0).getNodeIDView();
-
assertEquals(1, view.size());
assertTrue(view.contains(new Integer(0)));
ServerManagement.start(1, "all");
view = ServerManagement.getServer(0).getNodeIDView();
-
assertEquals(2, view.size());
assertTrue(view.contains(new Integer(0)));
assertTrue(view.contains(new Integer(1)));
@@ -119,8 +105,6 @@
assertEquals(2, view.size());
assertTrue(view.contains(new Integer(0)));
assertTrue(view.contains(new Integer(1)));
-
- log.info("testTwoNodesCluster sucessful");
}
finally
{
@@ -136,20 +120,17 @@
ServerManagement.start(0, "all");
Set view = ServerManagement.getServer(0).getNodeIDView();
-
assertEquals(1, view.size());
assertTrue(view.contains(new Integer(0)));
ServerManagement.start(1, "all");
view = ServerManagement.getServer(0).getNodeIDView();
-
assertEquals(2, view.size());
assertTrue(view.contains(new Integer(0)));
assertTrue(view.contains(new Integer(1)));
view = ServerManagement.getServer(1).getNodeIDView();
-
assertEquals(2, view.size());
assertTrue(view.contains(new Integer(0)));
assertTrue(view.contains(new Integer(1)));
@@ -157,27 +138,22 @@
ServerManagement.start(3, "all");
view = ServerManagement.getServer(0).getNodeIDView();
-
assertEquals(3, view.size());
assertTrue(view.contains(new Integer(0)));
assertTrue(view.contains(new Integer(1)));
assertTrue(view.contains(new Integer(3)));
view = ServerManagement.getServer(1).getNodeIDView();
-
assertEquals(3, view.size());
assertTrue(view.contains(new Integer(0)));
assertTrue(view.contains(new Integer(1)));
assertTrue(view.contains(new Integer(3)));
view = ServerManagement.getServer(3).getNodeIDView();
-
assertEquals(3, view.size());
assertTrue(view.contains(new Integer(0)));
assertTrue(view.contains(new Integer(1)));
assertTrue(view.contains(new Integer(3)));
-
- log.info("testThreeNodesCluster sucessful");
}
finally
{
@@ -192,14 +168,11 @@
{
try
{
- // Start with a 3 node cluster
-
ServerManagement.start(0, "all");
ServerManagement.start(1, "all");
ServerManagement.start(2, "all");
Set view = ServerManagement.getServer(0).getNodeIDView();
-
assertEquals(3, view.size());
assertTrue(view.contains(new Integer(0)));
assertTrue(view.contains(new Integer(1)));
@@ -210,7 +183,6 @@
ServerManagement.stop(0);
view = ServerManagement.getServer(1).getNodeIDView();
-
assertEquals(2, view.size());
assertTrue(view.contains(new Integer(1)));
assertTrue(view.contains(new Integer(2)));
@@ -220,7 +192,6 @@
ServerManagement.stop(2);
view = ServerManagement.getServer(1).getNodeIDView();
-
assertEquals(1, view.size());
assertTrue(view.contains(new Integer(1)));
@@ -229,7 +200,6 @@
ServerManagement.start(0, "all");
view = ServerManagement.getServer(0).getNodeIDView();
-
assertEquals(2, view.size());
assertTrue(view.contains(new Integer(0)));
assertTrue(view.contains(new Integer(1)));
@@ -237,10 +207,9 @@
// Reuse the "hollow" RMI server 2 to start another cluster node
- ServerManagement.start(1, "all");
+ ServerManagement.start(2, "all");
view = ServerManagement.getServer(2).getNodeIDView();
-
assertEquals(3, view.size());
assertTrue(view.contains(new Integer(0)));
assertTrue(view.contains(new Integer(1)));
@@ -268,7 +237,6 @@
ServerManagement.start(1, "all");
Set view = ServerManagement.getServer(0).getNodeIDView();
-
assertEquals(2, view.size());
assertTrue(view.contains(new Integer(0)));
assertTrue(view.contains(new Integer(1)));
@@ -291,14 +259,12 @@
}
view = ServerManagement.getServer(0).getNodeIDView();
-
assertEquals(1, view.size());
assertTrue(view.contains(new Integer(0)));
}
finally
{
ServerManagement.removeNotificationListener(0, postOfficeObjectName, clusterEvent);
-
ServerManagement.stop(1);
ServerManagement.stop(0);
}
@@ -318,7 +284,6 @@
ServerManagement.start(2, "all");
Set view = ServerManagement.getServer(0).getNodeIDView();
-
assertEquals(3, view.size());
assertTrue(view.contains(new Integer(0)));
assertTrue(view.contains(new Integer(1)));
@@ -344,7 +309,6 @@
log.info("received FAILOVER_COMPLETED");
view = ServerManagement.getServer(1).getNodeIDView();
-
assertEquals(2, view.size());
assertTrue(view.contains(new Integer(0)));
assertTrue(view.contains(new Integer(1)));
@@ -367,10 +331,8 @@
log.info("received FAILOVER_COMPLETED");
view = ServerManagement.getServer(0).getNodeIDView();
-
assertEquals(1, view.size());
assertTrue(view.contains(new Integer(0)));
-
}
finally
{
@@ -395,38 +357,36 @@
ServerManagement.start(0, "all");
Set view = ServerManagement.getServer(0).getNodeIDView();
-
assertEquals(1, view.size());
assertTrue(view.contains(new Integer(0)));
ServerManagement.addNotificationListener(0, postOfficeObjectName, clusterEvent);
- ServerManagement.start(10, "all");
+ // start the ninth node, as there is no chance to be started by scripts
+ ServerManagement.start(9, "all");
if (!clusterEvent.viewChanged(120000))
{
fail("Did not receive a VIEW_CHANGED event after spawning new server!");
}
- view = ServerManagement.getServer(1).getNodeIDView();
+ view = ServerManagement.getServer(9).getNodeIDView();
assertEquals(2, view.size());
assertTrue(view.contains(new Integer(0)));
- assertTrue(view.contains(new Integer(10)));
+ assertTrue(view.contains(new Integer(9)));
- //ServerManagement.kill(10);
}
finally
{
ServerManagement.removeNotificationListener(0, postOfficeObjectName, clusterEvent);
ServerManagement.stop(0);
+ ServerManagement.kill(9);
}
}
-
-
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
@@ -445,71 +405,4 @@
// Inner classes -------------------------------------------------
- private class ClusterEventNotificationListener implements NotificationListener
- {
- private Slot viewChange;
- private Slot failoverCompleted;
-
- ClusterEventNotificationListener()
- {
- viewChange = new Slot();
- failoverCompleted = new Slot();
- }
-
- public void handleNotification(Notification notification, Object object)
- {
- String type = notification.getType();
-
- log.info("received " + type + " notification");
-
- if (ClusteredPostOffice.VIEW_CHANGED_NOTIFICATION.equals(type))
- {
- try
- {
- viewChange.put(Boolean.TRUE);
- }
- catch(InterruptedException e)
- {
- log.error(e);
- }
- }
- else if (ClusteredPostOffice.FAILOVER_COMPLETED_NOTIFICATION.equals(type))
- {
- try
- {
- failoverCompleted.put(Boolean.TRUE);
- }
- catch(InterruptedException e)
- {
- log.error(e);
- }
- }
- else
- {
- log.info("Ignoring notification " + type);
- }
- }
-
- public boolean viewChanged(long timeout) throws InterruptedException
- {
- Boolean result = (Boolean)viewChange.poll(timeout);
- if (result == null)
- {
- return false;
- }
- return result.booleanValue();
- }
-
- public boolean failoverCompleted(long timeout) throws InterruptedException
- {
- Boolean result = (Boolean)failoverCompleted.poll(timeout);
- if (result == null)
- {
- return false;
- }
- return result.booleanValue();
- }
-
- }
-
}
Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/HATest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/HATest.java 2006-12-15 22:00:01 UTC (rev 1803)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/HATest.java 2006-12-16 04:27:46 UTC (rev 1804)
@@ -506,10 +506,13 @@
ServerManagement.kill(1);
- log.info("killed server, now waiting");
+ long sleepTime = 60;
- Thread.sleep(5000);
+ log.info("killed server, now waiting for " + sleepTime + " seconds");
+ // NOTE: the sleep time needs to be longer than the Remoting connector's lease period
+ Thread.sleep(sleepTime * 1000);
+
log.info("done wait");
state = (ConnectionState)del.getState();
@@ -666,10 +669,13 @@
killed = true;
- log.info("killed server, now waiting");
+ long sleepTime = 60;
- Thread.sleep(5000);
+ log.info("killed server, now waiting for " + sleepTime + " seconds");
+ // NOTE: the sleep time needs to be longer than the Remoting connector's lease period
+ Thread.sleep(sleepTime * 1000);
+
log.info("done wait");
state = (ConnectionState)del.getState();
@@ -696,7 +702,7 @@
assertNotNull(tm);
- log.info("message is " + tm.getText());
+ log.debug("message is " + tm.getText());
assertEquals("message:" + i, tm.getText());
}
@@ -854,8 +860,13 @@
log.info("killed server, now waiting");
- Thread.sleep(5000);
+ long sleepTime = 60;
+ log.info("killed server, now waiting for " + sleepTime + " seconds");
+
+ // NOTE: the sleep time needs to be longer than the Remoting connector's lease period
+ Thread.sleep(sleepTime * 1000);
+
log.info("done wait");
state = (ConnectionState)del.getState();
@@ -880,7 +891,7 @@
{
tm = (TextMessage)cons.receive(500);
- log.info("message is " + tm.getText());
+ log.debug("message is " + tm.getText());
assertNotNull(tm);
Copied: trunk/tests/src/org/jboss/test/messaging/jms/clustering/LargeClusterTest.java (from rev 1803, trunk/tests/src/org/jboss/test/messaging/jms/clustering/SimpleClusteringTest.java)
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/SimpleClusteringTest.java 2006-12-15 22:00:01 UTC (rev 1803)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/LargeClusterTest.java 2006-12-16 04:27:46 UTC (rev 1804)
@@ -0,0 +1,464 @@
+/**
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.test.messaging.jms.clustering;
+
+import org.jboss.test.messaging.jms.clustering.base.ClusteringTestBase;
+import org.jboss.test.messaging.tools.ServerManagement;
+import org.jboss.jms.client.JBossConnection;
+import org.jboss.jms.client.delegate.ClientConnectionDelegate;
+
+import javax.jms.Connection;
+import javax.jms.Session;
+import javax.jms.MessageListener;
+import javax.jms.Message;
+import javax.jms.TextMessage;
+import javax.management.ObjectName;
+
+import EDU.oswego.cs.dl.util.concurrent.Slot;
+
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
+ * @version <tt>$Revision$</tt>
+ *
+ * $Id$
+ */
+public class LargeClusterTest extends ClusteringTestBase
+{
+ // Constants -----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ public LargeClusterTest(String name)
+ {
+ super(name);
+ }
+
+ // Public --------------------------------------------------------
+
+ /**
+ * This test is an example how to programatically make a cluster node to join the cluser.
+ */
+ public void testJoin() throws Exception
+ {
+ // By this time, after running setUp(), we should have an already formed cluster of seven
+ // nodes
+
+ Set view = ServerManagement.getServer(0).getNodeIDView();
+
+ assertEquals(7, view.size());
+ assertTrue(view.contains(new Integer(0)));
+ assertTrue(view.contains(new Integer(1)));
+ assertTrue(view.contains(new Integer(2)));
+ assertTrue(view.contains(new Integer(3)));
+ assertTrue(view.contains(new Integer(4)));
+ assertTrue(view.contains(new Integer(5)));
+ assertTrue(view.contains(new Integer(6)));
+
+ ObjectName postOfficeObjectName = new ObjectName("jboss.messaging:service=PostOffice");
+ ClusterEventNotificationListener clusterEvent = new ClusterEventNotificationListener();
+
+ ServerManagement.addNotificationListener(4, postOfficeObjectName, clusterEvent);
+
+ // We start programatically the eight node.
+
+ ServerManagement.start(7, "all");
+
+ // wait for change to propagate
+
+ if (!clusterEvent.viewChanged(120000))
+ {
+ fail("Did not receive a VIEW_CHANGED event after spawning new server!");
+ }
+
+ view = ServerManagement.getServer(0).getNodeIDView();
+
+ assertEquals(8, view.size());
+ assertTrue(view.contains(new Integer(0)));
+ assertTrue(view.contains(new Integer(1)));
+ assertTrue(view.contains(new Integer(2)));
+ assertTrue(view.contains(new Integer(3)));
+ assertTrue(view.contains(new Integer(4)));
+ assertTrue(view.contains(new Integer(5)));
+ assertTrue(view.contains(new Integer(6)));
+ assertTrue(view.contains(new Integer(7)));
+
+ ServerManagement.removeNotificationListener(4, postOfficeObjectName, clusterEvent);
+
+ ServerManagement.kill(7);
+ }
+
+ /**
+ * This test is an example how to programatically make a cluster node to cleanly leave the
+ * cluster.
+ */
+ public void testCleanLeave() throws Exception
+ {
+ // By this time, after running setUp(), we should have an already formed cluster of seven
+ // nodes
+
+ Set view = ServerManagement.getServer(0).getNodeIDView();
+
+ assertEquals(7, view.size());
+ assertTrue(view.contains(new Integer(0)));
+ assertTrue(view.contains(new Integer(1)));
+ assertTrue(view.contains(new Integer(2)));
+ assertTrue(view.contains(new Integer(3)));
+ assertTrue(view.contains(new Integer(4)));
+ assertTrue(view.contains(new Integer(5)));
+ assertTrue(view.contains(new Integer(6)));
+
+ ObjectName postOfficeObjectName = new ObjectName("jboss.messaging:service=PostOffice");
+ ClusterEventNotificationListener clusterEvent = new ClusterEventNotificationListener();
+
+ ServerManagement.addNotificationListener(0, postOfficeObjectName, clusterEvent);
+
+ // We get all nodes to programatically leave the cluster
+
+ ServerManagement.stop(3);
+
+ if (!clusterEvent.viewChanged(120000))
+ {
+ fail("Did not receive a VIEW_CHANGED event after spawning new server!");
+ }
+
+ assertEquals(6, ServerManagement.getServer(0).getNodeIDView().size());
+ assertTrue(view.contains(new Integer(0)));
+ assertTrue(view.contains(new Integer(1)));
+ assertTrue(view.contains(new Integer(2)));
+ assertTrue(view.contains(new Integer(4)));
+ assertTrue(view.contains(new Integer(5)));
+ assertTrue(view.contains(new Integer(6)));
+
+ ServerManagement.stop(6);
+
+ if (!clusterEvent.viewChanged(120000))
+ {
+ fail("Did not receive a VIEW_CHANGED event after spawning new server!");
+ }
+
+ assertEquals(5, ServerManagement.getServer(0).getNodeIDView().size());
+ assertTrue(view.contains(new Integer(0)));
+ assertTrue(view.contains(new Integer(1)));
+ assertTrue(view.contains(new Integer(2)));
+ assertTrue(view.contains(new Integer(4)));
+ assertTrue(view.contains(new Integer(5)));
+
+ ServerManagement.stop(1);
+
+ if (!clusterEvent.viewChanged(120000))
+ {
+ fail("Did not receive a VIEW_CHANGED event after spawning new server!");
+ }
+
+ assertEquals(4, ServerManagement.getServer(0).getNodeIDView().size());
+ assertTrue(view.contains(new Integer(0)));
+ assertTrue(view.contains(new Integer(2)));
+ assertTrue(view.contains(new Integer(4)));
+ assertTrue(view.contains(new Integer(5)));
+
+ ServerManagement.stop(2);
+
+ if (!clusterEvent.viewChanged(120000))
+ {
+ fail("Did not receive a VIEW_CHANGED event after spawning new server!");
+ }
+
+ assertEquals(3, ServerManagement.getServer(0).getNodeIDView().size());
+ assertTrue(view.contains(new Integer(0)));
+ assertTrue(view.contains(new Integer(4)));
+ assertTrue(view.contains(new Integer(5)));
+
+ ServerManagement.stop(4);
+
+ if (!clusterEvent.viewChanged(120000))
+ {
+ fail("Did not receive a VIEW_CHANGED event after spawning new server!");
+ }
+
+ assertEquals(2, ServerManagement.getServer(0).getNodeIDView().size());
+ assertTrue(view.contains(new Integer(0)));
+ assertTrue(view.contains(new Integer(5)));
+
+ ServerManagement.removeNotificationListener(0, postOfficeObjectName, clusterEvent);
+ ServerManagement.addNotificationListener(5, postOfficeObjectName, clusterEvent);
+
+ ServerManagement.stop(0);
+
+ if (!clusterEvent.viewChanged(120000))
+ {
+ fail("Did not receive a VIEW_CHANGED event after spawning new server!");
+ }
+
+ assertEquals(1, ServerManagement.getServer(5).getNodeIDView().size());
+ assertTrue(view.contains(new Integer(5)));
+
+ ServerManagement.removeNotificationListener(5, postOfficeObjectName, clusterEvent);
+
+ ServerManagement.stop(5);
+ }
+
+ public void testLeaveAndJoin() throws Exception
+ {
+ // By this time, after running setUp(), we should have an already formed cluster of seven
+ // nodes
+
+ Set view = ServerManagement.getServer(0).getNodeIDView();
+
+ assertEquals(7, view.size());
+ assertTrue(view.contains(new Integer(0)));
+ assertTrue(view.contains(new Integer(1)));
+ assertTrue(view.contains(new Integer(2)));
+ assertTrue(view.contains(new Integer(3)));
+ assertTrue(view.contains(new Integer(4)));
+ assertTrue(view.contains(new Integer(5)));
+ assertTrue(view.contains(new Integer(6)));
+
+ ObjectName postOfficeObjectName = new ObjectName("jboss.messaging:service=PostOffice");
+ ClusterEventNotificationListener clusterEvent = new ClusterEventNotificationListener();
+
+ ServerManagement.addNotificationListener(5, postOfficeObjectName, clusterEvent);
+
+ // We get the first node to programatically leave the cluster
+
+ ServerManagement.stop(0);
+
+ if (!clusterEvent.viewChanged(120000))
+ {
+ fail("Did not receive a VIEW_CHANGED event after spawning new server!");
+ }
+
+ view = ServerManagement.getServer(4).getNodeIDView();
+
+ assertEquals(6, view.size());
+ assertTrue(view.contains(new Integer(1)));
+ assertTrue(view.contains(new Integer(2)));
+ assertTrue(view.contains(new Integer(3)));
+ assertTrue(view.contains(new Integer(4)));
+ assertTrue(view.contains(new Integer(5)));
+ assertTrue(view.contains(new Integer(6)));
+
+
+ // We get the first node to re-join
+
+ ServerManagement.start(0, "all");
+
+ if (!clusterEvent.viewChanged(120000))
+ {
+ fail("Did not receive a VIEW_CHANGED event after spawning new server!");
+ }
+
+ view = ServerManagement.getServer(6).getNodeIDView();
+ assertEquals(7, view.size());
+ assertTrue(view.contains(new Integer(0)));
+ assertTrue(view.contains(new Integer(1)));
+ assertTrue(view.contains(new Integer(2)));
+ assertTrue(view.contains(new Integer(3)));
+ assertTrue(view.contains(new Integer(4)));
+ assertTrue(view.contains(new Integer(5)));
+ assertTrue(view.contains(new Integer(6)));
+
+ ServerManagement.removeNotificationListener(5, postOfficeObjectName, clusterEvent);
+
+ }
+
+ public void testDistributedTopic() throws Exception
+ {
+ Connection conn0 = null;
+ Connection conn1 = null;
+ Connection conn2 = null;
+ Connection conn3 = null;
+ Connection conn4 = null;
+ Connection conn5 = null;
+ Connection conn6 = null;
+
+
+ try
+ {
+ conn0 = cf.createConnection();
+ assertEquals(0, ((ClientConnectionDelegate)((JBossConnection)conn0).
+ getDelegate()).getServerID());
+ Session s0 = conn0.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ SimpleMessageListener m0 = new SimpleMessageListener();
+ s0.createConsumer(topic[0]).setMessageListener(m0);
+ conn0.start();
+
+ conn1 = cf.createConnection();
+ assertEquals(1, ((ClientConnectionDelegate)((JBossConnection)conn1).
+ getDelegate()).getServerID());
+ Session s1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ SimpleMessageListener m1 = new SimpleMessageListener();
+ s1.createConsumer(topic[1]).setMessageListener(m1);
+ conn1.start();
+
+ conn2 = cf.createConnection();
+ assertEquals(2, ((ClientConnectionDelegate)((JBossConnection)conn2).
+ getDelegate()).getServerID());
+ Session s2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ SimpleMessageListener m2 = new SimpleMessageListener();
+ s2.createConsumer(topic[2]).setMessageListener(m2);
+ conn2.start();
+
+ conn3 = cf.createConnection();
+ assertEquals(3, ((ClientConnectionDelegate)((JBossConnection)conn3).
+ getDelegate()).getServerID());
+ Session s3 = conn3.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ SimpleMessageListener m3 = new SimpleMessageListener();
+ s3.createConsumer(topic[3]).setMessageListener(m3);
+ conn3.start();
+
+ conn4 = cf.createConnection();
+ assertEquals(4, ((ClientConnectionDelegate)((JBossConnection)conn4).
+ getDelegate()).getServerID());
+ Session s4 = conn4.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ SimpleMessageListener m4 = new SimpleMessageListener();
+ s4.createConsumer(topic[4]).setMessageListener(m4);
+ conn4.start();
+
+ conn5 = cf.createConnection();
+ assertEquals(5, ((ClientConnectionDelegate)((JBossConnection)conn5).
+ getDelegate()).getServerID());
+ Session s5 = conn5.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ SimpleMessageListener m5 = new SimpleMessageListener();
+ s5.createConsumer(topic[5]).setMessageListener(m5);
+ conn5.start();
+
+ conn6 = cf.createConnection();
+ assertEquals(6, ((ClientConnectionDelegate)((JBossConnection)conn6).
+ getDelegate()).getServerID());
+ Session s6 = conn6.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ SimpleMessageListener m6 = new SimpleMessageListener();
+ s6.createConsumer(topic[6]).setMessageListener(m6);
+ conn6.start();
+
+ s3.createProducer(topic[3]).send(s3.createTextMessage("boom"));
+
+ TextMessage rm = null;
+
+ rm = m0.poll(5000);
+ assertEquals("boom", rm.getText());
+
+ rm = m1.poll(5000);
+ assertEquals("boom", rm.getText());
+
+ rm = m2.poll(5000);
+ assertEquals("boom", rm.getText());
+
+ rm = m3.poll(5000);
+ assertEquals("boom", rm.getText());
+
+ rm = m4.poll(5000);
+ assertEquals("boom", rm.getText());
+
+ rm = m5.poll(5000);
+ assertEquals("boom", rm.getText());
+
+ rm = m6.poll(5000);
+ assertEquals("boom", rm.getText());
+
+ }
+ finally
+ {
+ if (conn0 != null)
+ {
+ conn0.close();
+ }
+
+ if (conn1 != null)
+ {
+ conn1.close();
+ }
+
+ if (conn2 != null)
+ {
+ conn2.close();
+ }
+
+ if (conn3 != null)
+ {
+ conn3.close();
+ }
+
+ if (conn4 != null)
+ {
+ conn4.close();
+ }
+
+ if (conn5 != null)
+ {
+ conn5.close();
+ }
+
+ if (conn6 != null)
+ {
+ conn6.close();
+ }
+ }
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ protected void setUp() throws Exception
+ {
+ nodeCount = 7;
+
+ super.setUp();
+
+ log.debug("setup done");
+ }
+
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+
+ ServerManagement.kill(6);
+ ServerManagement.kill(5);
+ ServerManagement.kill(4);
+ ServerManagement.kill(3);
+ ServerManagement.kill(2);
+ ServerManagement.kill(1);
+ }
+
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+ private class SimpleMessageListener implements MessageListener
+ {
+ private Slot slot;
+
+ SimpleMessageListener()
+ {
+ slot = new Slot();
+ }
+
+ public void onMessage(Message message)
+ {
+ try
+ {
+ slot.put(message);
+ }
+ catch(InterruptedException e)
+ {
+ log.error(e);
+ }
+ }
+
+ public TextMessage poll(long timeout) throws InterruptedException
+ {
+ return (TextMessage)slot.poll(timeout);
+ }
+ }
+}
Copied: trunk/tests/src/org/jboss/test/messaging/jms/clustering/ServerManagementTest.java (from rev 1803, trunk/tests/src/org/jboss/test/messaging/util/ServerManagementTest.java)
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/util/ServerManagementTest.java 2006-12-15 22:00:01 UTC (rev 1803)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/ServerManagementTest.java 2006-12-16 04:27:46 UTC (rev 1804)
@@ -0,0 +1,143 @@
+/**
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.test.messaging.jms.clustering;
+
+import org.jboss.test.messaging.MessagingTestCase;
+import org.jboss.test.messaging.tools.ServerManagement;
+
+import javax.naming.InitialContext;
+import javax.management.ObjectName;
+
+/**
+ * Test spawning functionality of the ServerManagment. Used mostly in a clustered testing
+ * environment.
+ *
+ * DO NOT extend ClusteringTestBase, I need direct control over start()/stop()!
+ *
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
+ * @version <tt>$Revision$</tt>
+ *
+ * $Id$
+ */
+public class ServerManagementTest extends MessagingTestCase
+{
+ // Constants -----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ public ServerManagementTest(String name)
+ {
+ super(name);
+ }
+
+ // Public --------------------------------------------------------
+
+ public void testStartServer() throws Exception
+ {
+ ServerManagement.start(0, "all");
+ ServerManagement.start(0, "all");
+ }
+
+ public void testSimpleSpawn() throws Exception
+ {
+ if (!ServerManagement.isRemote())
+ {
+ fail("This test must be run in remote mode!");
+ }
+
+ try
+ {
+ log.info("Starting server 7");
+
+ ServerManagement.start(7, "all");
+
+ Integer index = (Integer)ServerManagement.
+ getAttribute(7, new ObjectName("jboss.messaging:service=ServerPeer"), "serverPeerID");
+
+ assertEquals(7, index.intValue());
+
+ InitialContext ic = new InitialContext(ServerManagement.getJNDIEnvironment(7));
+
+ ic.bind("/xxx", "yyy");
+
+ assertEquals("yyy", ic.lookup("/xxx"));
+ }
+ finally
+ {
+ log.info("Killing server 7");
+ ServerManagement.kill(7);
+ }
+ }
+
+ public void testRessurect() throws Exception
+ {
+ if (!ServerManagement.isRemote())
+ {
+ fail("This test must be run in remote mode!");
+ }
+
+ try
+ {
+ ServerManagement.start(1, "all");
+
+ ServerManagement.kill(1);
+
+ // wait a bit for the server to die
+
+ log.info("Sleeping for 10 seconds ...");
+
+ Thread.sleep(10000);
+
+ // resurrect the server
+
+ ServerManagement.start(1, "all");
+
+ Integer index = (Integer)ServerManagement.
+ getAttribute(1, new ObjectName("jboss.messaging:service=ServerPeer"), "serverPeerID");
+
+ assertEquals(1, index.intValue());
+
+ InitialContext ic = new InitialContext(ServerManagement.getJNDIEnvironment(1));
+
+ ic.bind("/xxx", "yyy");
+
+ assertEquals("yyy", ic.lookup("/xxx"));
+ }
+ finally
+ {
+ ServerManagement.kill(1);
+ }
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ log.debug("setup done");
+ }
+
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+
+ // TODO: clean up spawned servers
+
+ }
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Deleted: trunk/tests/src/org/jboss/test/messaging/jms/clustering/SimpleClusteringTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/SimpleClusteringTest.java 2006-12-15 22:00:01 UTC (rev 1803)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/SimpleClusteringTest.java 2006-12-16 04:27:46 UTC (rev 1804)
@@ -1,213 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.test.messaging.jms.clustering;
-
-import org.jboss.test.messaging.jms.clustering.base.ClusteringTestBase;
-import org.jboss.test.messaging.tools.ServerManagement;
-
-import javax.jms.Connection;
-import javax.jms.Session;
-import javax.jms.MessageListener;
-import javax.jms.Message;
-import javax.jms.TextMessage;
-
-import EDU.oswego.cs.dl.util.concurrent.Slot;
-
-/**
- * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public class SimpleClusteringTest extends ClusteringTestBase
-{
- // Constants -----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- public SimpleClusteringTest(String name)
- {
- super(name);
- }
-
- // Public --------------------------------------------------------
-
- /**
- * This test is an example how to programatically make a cluster node to join the cluser.
- */
- public void testJoin() throws Exception
- {
- // By this time, after running setUp(), we should have an already formed cluster of three
- // nodes (0, 1, 2).
-
- // TODO - verify this assertion
-
- // We start programatically the fourth node.
-
- ServerManagement.start(4, "all");
-
- // TODO - verify that the cluster formed correctly assertion
-
- ServerManagement.stop(3);
- }
-
- /**
- * This test is an example how to programatically make a cluster node to cleanly leave the
- * cluster.
- */
- public void testCleanLeave() throws Exception
- {
- // By this time, after running setUp(), we should have an already formed cluster of three
- // nodes (0, 1, 2).
-
- // TODO - verify this assertion
-
- // We get the first node to programatically leave the cluster
-
- ServerManagement.stop(0);
-
- // TODO - verify that the cluster formed correctly assertion
-
- // We get the last node to programatically leave the cluster
-
- ServerManagement.stop(2);
-
- }
-
- public void testLeaveAndJoin() throws Exception
- {
- // By this time, after running setUp(), we should have an already formed cluster of three
- // nodes (0, 1, 2).
-
- // TODO - verify this assertion
-
- // We get the first node to programatically leave the cluster
-
- ServerManagement.stop(0);
-
- // TODO - verify that the cluster formed correctly assertion
-
- // We get the first node to re-join
-
- ServerManagement.start(0, "all");
-
- }
-
- public void testDistributedTopic() throws Exception
- {
- Connection conn = null;
- Connection conn1 = null;
- Connection conn2 = null;
-
- try
- {
- conn = cf.createConnection();
- conn1 = cf.createConnection();
- conn2 = cf.createConnection();
-
- Session s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Session s1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Session s2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- SimpleMessageListener ml = new SimpleMessageListener();
- SimpleMessageListener ml1 = new SimpleMessageListener();
- SimpleMessageListener ml2 = new SimpleMessageListener();
-
- s.createConsumer(topic[0]).setMessageListener(ml);
- s1.createConsumer(topic[0]).setMessageListener(ml1);
- s2.createConsumer(topic[0]).setMessageListener(ml2);
-
- conn.start();
- conn1.start();
- conn2.start();
-
- s.createProducer(topic[0]).send(s.createTextMessage("boom"));
-
- TextMessage rm = null;
-
- rm = ml.poll(5000);
- assertEquals("boom", rm.getText());
-
- rm = ml1.poll(5000);
- assertEquals("boom", rm.getText());
-
- rm = ml2.poll(5000);
- assertEquals("boom", rm.getText());
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
-
- if (conn1 != null)
- {
- conn1.close();
- }
-
- if (conn2 != null)
- {
- conn2.close();
- }
- }
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- protected void setUp() throws Exception
- {
- nodeCount = 3;
-
- super.setUp();
-
- log.debug("setup done");
- }
-
- protected void tearDown() throws Exception
- {
- super.tearDown();
- }
-
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
- private class SimpleMessageListener implements MessageListener
- {
- private Slot slot;
-
- SimpleMessageListener()
- {
- slot = new Slot();
- }
-
- public void onMessage(Message message)
- {
- try
- {
- slot.put(message);
- }
- catch(InterruptedException e)
- {
- log.error(e);
- }
- }
-
- public TextMessage poll(long timeout) throws InterruptedException
- {
- return (TextMessage)slot.poll(timeout);
- }
- }
-}
Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/base/ClusteringTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/base/ClusteringTestBase.java 2006-12-15 22:00:01 UTC (rev 1803)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/base/ClusteringTestBase.java 2006-12-16 04:27:46 UTC (rev 1804)
@@ -119,13 +119,12 @@
ServerManagement.log(ServerManagement.INFO, "Undeploying Server " + i, i);
ServerManagement.undeployQueue("testDistributedQueue", i);
ServerManagement.undeployTopic("testDistributedTopic", i);
+ ServerManagement.stop(i);
}
ic[i].close();
}
- //ServerManagement.destroySpawnedServers();
-
super.tearDown();
}
Modified: trunk/tests/src/org/jboss/test/messaging/tools/ServerManagement.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/ServerManagement.java 2006-12-15 22:00:01 UTC (rev 1803)
+++ trunk/tests/src/org/jboss/test/messaging/tools/ServerManagement.java 2006-12-16 04:27:46 UTC (rev 1804)
@@ -207,16 +207,24 @@
/**
* The method stops the local or remote server, bringing it to a "hollow" state. A stopped
* server is identical with a server that has just been created, but not started.
+ * @return true if the server was effectively stopped, or false if the server was alreayd stopped
+ * when the method was invoked.
*/
- public static synchronized void stop(int i) throws Exception
+ public static synchronized boolean stop(int i) throws Exception
{
if (servers[i] == null)
{
- log.warn("Server " + i + " has not been created, so it cannot be stopped");
+ log.warn("server " + i + " has not been created, so it cannot be stopped");
+ return false;
}
else
{
- servers[i].getServer().stop();
+ boolean stopped = servers[i].getServer().stop();
+ if (stopped)
+ {
+ log.info("server " + i + " stopped");
+ }
+ return stopped;
}
}
@@ -228,12 +236,13 @@
{
if (servers[i] == null)
{
- log.warn("Server " + i + " has not been created, so it cannot be killed");
+ log.warn("server " + i + " has not been created, so it cannot be killed");
}
else
{
+ log.trace("invoking kill() on server " + i);
servers[i].getServer().kill();
- log.info("Server " + i + " killed");
+ log.info("server " + i + " killed");
servers[i] = null;
}
}
@@ -481,7 +490,8 @@
{
// is remote, need to poll
NotificationListenerPoller p =
- new NotificationListenerPoller((Server)servers[serverIndex], on, listener);
+ new NotificationListenerPoller(((ServerHolder)servers[serverIndex]).getServer(),
+ on, listener);
synchronized(notificationListenerPollers)
{
Modified: trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/LocalTestServer.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/LocalTestServer.java 2006-12-15 22:00:01 UTC (rev 1803)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/LocalTestServer.java 2006-12-16 04:27:46 UTC (rev 1804)
@@ -149,11 +149,11 @@
}
}
- public synchronized void stop() throws Exception
+ public synchronized boolean stop() throws Exception
{
if (!isStarted())
{
- return;
+ return false;
}
try
@@ -173,6 +173,8 @@
{
clearEnvironmentServerIndex();
}
+
+ return true;
}
public synchronized void kill() throws Exception
Modified: trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/RMITestServer.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/RMITestServer.java 2006-12-15 22:00:01 UTC (rev 1803)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/RMITestServer.java 2006-12-16 04:27:46 UTC (rev 1804)
@@ -145,10 +145,11 @@
server.start(containerConfig);
}
- public void stop() throws Exception
+ public boolean stop() throws Exception
{
- server.stop();
+ boolean result = server.stop();
namingDelegate.reset();
+ return result;
}
public synchronized void kill() throws Exception
Modified: trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/Server.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/Server.java 2006-12-15 22:00:01 UTC (rev 1803)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/Server.java 2006-12-16 04:27:46 UTC (rev 1804)
@@ -49,7 +49,11 @@
void start(String containerConfig) throws Exception;
- void stop() throws Exception;
+ /**
+ * @return true if the server was stopped indeed, or false if the server was stopped already
+ * when the method was invoked.
+ */
+ boolean stop() throws Exception;
/**
* For a remote server, it "abruptly" kills the VM running the server. For a local server
Modified: trunk/tests/src/org/jboss/test/messaging/tools/jndi/RemoteContext.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jndi/RemoteContext.java 2006-12-15 22:00:01 UTC (rev 1803)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jndi/RemoteContext.java 2006-12-16 04:27:46 UTC (rev 1804)
@@ -58,7 +58,7 @@
namingDelegate = (NamingDelegate)Naming.lookup(n);
- log.info("remote context for server " + remoteServerIndex + " acquired from rmi:" + n);
+ log.debug("remote context for server " + remoteServerIndex + " acquired from rmi:" + n);
}
// Context implementation ----------------------------------------
Deleted: trunk/tests/src/org/jboss/test/messaging/util/ServerManagementTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/util/ServerManagementTest.java 2006-12-15 22:00:01 UTC (rev 1803)
+++ trunk/tests/src/org/jboss/test/messaging/util/ServerManagementTest.java 2006-12-16 04:27:46 UTC (rev 1804)
@@ -1,159 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.test.messaging.util;
-
-import org.jboss.test.messaging.MessagingTestCase;
-import org.jboss.test.messaging.tools.ServerManagement;
-
-import javax.naming.InitialContext;
-import javax.management.ObjectName;
-
-/**
- * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public class ServerManagementTest extends MessagingTestCase
-{
- // Constants -----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- public ServerManagementTest(String name)
- {
- super(name);
- }
-
- // Public --------------------------------------------------------
-
- public void testSpawnServer() throws Exception
- {
- try
- {
- ServerManagement.start(0, "all");
-
- ServerManagement.start(0, "all");
- }
- finally
- {
- ServerManagement.kill(0);
- }
- }
-
- public void testSimpleSpawn() throws Exception
- {
- if (!ServerManagement.isRemote())
- {
- fail("This test must be run in remote mode!");
- }
-
- try
- {
- log.info("Waiting for server 7 to start ...");
-
- ServerManagement.start(7, "all");
-
- log.info("Server 7 started");
-
- Integer index = (Integer)ServerManagement.
- getAttribute(7, new ObjectName("jboss.messaging:service=ServerPeer"), "serverPeerID");
-
- assertEquals(7, index.intValue());
-
- InitialContext ic = new InitialContext(ServerManagement.getJNDIEnvironment(7));
-
- ic.bind("/xxx", "yyy");
-
- assertEquals("yyy", ic.lookup("/xxx"));
- }
- finally
- {
- log.info("Killing server 7");
- ServerManagement.kill(7);
- }
- }
-
- public void testRessurect() throws Exception
- {
- if (!ServerManagement.isRemote())
- {
- fail("This test must be run in remote mode!");
- }
-
- try
- {
- ServerManagement.start(1, "all");
-
- ServerManagement.kill(1);
-
- // wait a bit for the server to die
-
- log.info("Sleeping for 10 seconds ...");
-
- Thread.sleep(10000);
-
- // resurrect the server
-
- ServerManagement.start(1, "all");
-
- Integer index = (Integer)ServerManagement.
- getAttribute(1, new ObjectName("jboss.messaging:service=ServerPeer"), "serverPeerID");
-
- assertEquals(1, index.intValue());
-
- InitialContext ic = new InitialContext(ServerManagement.getJNDIEnvironment(1));
-
- ic.bind("/xxx", "yyy");
-
- assertEquals("yyy", ic.lookup("/xxx"));
- }
- finally
- {
- ServerManagement.kill(1);
- }
- }
-
- public void testA()
- {
- System.out.println("A");
- }
-
- public void testB()
- {
- System.out.println("B");
- }
-
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- protected void setUp() throws Exception
- {
- super.setUp();
-
- log.debug("setup done");
- }
-
- protected void tearDown() throws Exception
- {
- super.tearDown();
-
- // TODO: clean up spawned servers
-
- }
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
-}
More information about the jboss-cvs-commits
mailing list