[jboss-cvs] JBoss Messaging SVN: r2963 - in trunk: src/main/org/jboss/messaging/core/impl/clusterconnection and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Aug 6 15:47:09 EDT 2007
Author: timfox
Date: 2007-08-06 15:47:09 -0400 (Mon, 06 Aug 2007)
New Revision: 2963
Removed:
trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusteringTestBase.java
Modified:
trunk/src/main/org/jboss/jms/server/ServerPeer.java
trunk/src/main/org/jboss/messaging/core/impl/clusterconnection/ClusterConnectionManager.java
trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterLeakTest.java
trunk/tests/src/org/jboss/test/messaging/jms/clustering/GroupManagementTest.java
trunk/tests/src/org/jboss/test/messaging/jms/clustering/LargeClusterTest.java
trunk/tests/src/org/jboss/test/messaging/jms/clustering/PreserveOrderingTest.java
trunk/tests/src/org/jboss/test/messaging/jms/clustering/TemporaryDestinationTest.java
trunk/tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java
trunk/tests/src/org/jboss/test/messaging/tools/container/RMITestServer.java
trunk/tests/src/org/jboss/test/messaging/tools/container/Server.java
Log:
Tests speedup
Modified: trunk/src/main/org/jboss/jms/server/ServerPeer.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/ServerPeer.java 2007-08-06 18:40:27 UTC (rev 2962)
+++ trunk/src/main/org/jboss/jms/server/ServerPeer.java 2007-08-06 19:47:09 UTC (rev 2963)
@@ -259,7 +259,6 @@
clusterNotifier.registerListener(clusterConnectionManager);
}
-
// Start the wired components
messageIDManager.start();
@@ -612,13 +611,13 @@
return defaultPreserveOrdering;
}
- public void setDefaultPreserveOrdering(boolean preserve)
+ public void setDefaultPreserveOrdering(boolean preserve) throws Exception
{
- if (started)
- {
- throw new IllegalStateException("Cannot set DefaultPreserveOrdering while the service is running");
- }
this.defaultPreserveOrdering = preserve;
+ if (started)
+ {
+ clusterConnectionManager.setPreserveOrdering(preserve);
+ }
}
public long getRecoverDeliveriesTimeout()
Modified: trunk/src/main/org/jboss/messaging/core/impl/clusterconnection/ClusterConnectionManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/impl/clusterconnection/ClusterConnectionManager.java 2007-08-06 18:40:27 UTC (rev 2962)
+++ trunk/src/main/org/jboss/messaging/core/impl/clusterconnection/ClusterConnectionManager.java 2007-08-06 19:47:09 UTC (rev 2963)
@@ -175,6 +175,20 @@
}
}
+ public void setPreserveOrdering(boolean preserveOrdering) throws Exception
+ {
+ boolean needToClose = this.preserveOrdering != preserveOrdering;
+ if (needToClose)
+ {
+ closeAllSuckers();
+ }
+ this.preserveOrdering = preserveOrdering;
+ if (needToClose)
+ {
+ createAllSuckers();
+ }
+ }
+
public void closeAllSuckers()
{
Iterator iter = connections.values().iterator();
Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterLeakTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterLeakTest.java 2007-08-06 18:40:27 UTC (rev 2962)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterLeakTest.java 2007-08-06 19:47:09 UTC (rev 2963)
@@ -52,7 +52,7 @@
* <p/>
* $Id$
*/
-public class ClusterLeakTest extends ClusteringTestBase
+public class ClusterLeakTest extends NewClusteringTestBase
{
// Constants ------------------------------------------------------------------------------------
Deleted: trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusteringTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusteringTestBase.java 2007-08-06 18:40:27 UTC (rev 2962)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusteringTestBase.java 2007-08-06 19:47:09 UTC (rev 2963)
@@ -1,356 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.test.messaging.jms.clustering;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.Topic;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-
-import org.jboss.jms.client.FailoverEvent;
-import org.jboss.jms.client.FailoverListener;
-import org.jboss.jms.client.JBossConnection;
-import org.jboss.jms.client.JBossConnectionFactory;
-import org.jboss.jms.client.delegate.ClientClusteredConnectionFactoryDelegate;
-import org.jboss.jms.client.delegate.DelegateSupport;
-import org.jboss.jms.client.state.ConnectionState;
-import org.jboss.test.messaging.MessagingTestCase;
-import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.test.messaging.tools.container.ServiceAttributeOverrides;
-
-import EDU.oswego.cs.dl.util.concurrent.LinkedQueue;
-
-/**
- * @author <a href="mailto:tim.fox at jboss.org">Tim Fox</a>
- * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- * $Id$
- */
-public class ClusteringTestBase extends MessagingTestCase
-{
- // Constants ------------------------------------------------------------------------------------
-
- // Static ---------------------------------------------------------------------------------------
-
- // Attributes -----------------------------------------------------------------------------------
-
- protected int nodeCount;
- protected String config = "all";
-
- protected Context[] ic;
- protected Queue queue[];
- protected Topic topic[];
-
- protected ServiceAttributeOverrides overrides;
-
- // No need to have multiple connection factories since a clustered connection factory will create
- // connections in a round robin fashion on different servers.
-
- protected ConnectionFactory cf;
-
- // Constructors ---------------------------------------------------------------------------------
-
- public ClusteringTestBase(String name)
- {
- super(name);
- }
-
- // Public ---------------------------------------------------------------------------------------
-
- // Package protected ----------------------------------------------------------------------------
-
- // Protected ------------------------------------------------------------------------------------
-
- protected int getFailoverNodeForNode(JBossConnectionFactory factory, int nodeID)
- {
- Integer l = (Integer)((ClientClusteredConnectionFactoryDelegate)(factory.getDelegate())).getFailoverMap().get(new Integer(nodeID));
-
- return l.intValue();
- }
-
- protected void setUp() throws Exception
- {
- super.setUp();
-
- if (nodeCount < 1)
- {
- throw new Exception("Node count not defined! Initalize nodeCount in the test's setUp()");
- }
-
- for (int i = 0; i < nodeCount; i++)
- {
- // make sure all servers are created and started; make sure that database is zapped
- // ONLY for the first server, the others rely on values they expect to find in shared
- // tables; don't clear the database for those.
- ServerManagement.start(i, config, overrides, i == 0);
-
- ServerManagement.deployQueue("testDistributedQueue", i);
- ServerManagement.deployTopic("testDistributedTopic", i);
- }
-
-
- lookups();
-
- drainQueues();
- }
-
- // Perform Context creation and lookups on queues and factories
- // Case a server is restarted, a test may want to recreate contexts in certain scenarios
- protected void lookups() throws Exception
- {
- ic = new Context[nodeCount];
- queue = new Queue[nodeCount];
- topic = new Topic[nodeCount];
-
- for (int i = 0; i < nodeCount; i++)
- {
- log.info("Getting lookups for " + i);
- ic[i] = new InitialContext(ServerManagement.getJNDIEnvironment(i));
- queue[i] = (Queue)ic[i].lookup("queue/testDistributedQueue");
- topic[i] = (Topic)ic[i].lookup("topic/testDistributedTopic");
- }
-
- // We only need to lookup one connection factory since it will be clustered so we will
- // actually create connections on different servers (round robin).
- cf = (ConnectionFactory)ic[0].lookup("/ClusteredConnectionFactory");
-
- }
-
- protected void tearDown() throws Exception
- {
- log.info("tearing down");
- for(int i = 0; i < nodeCount; i++)
- {
- if (ServerManagement.isStarted(i))
- {
- //log.info("stopping server " + i);
- //ServerManagement.log(ServerManagement.INFO, "Undeploying Server " + i, i);
- ServerManagement.undeployQueue("testDistributedQueue", i);
- ServerManagement.undeployTopic("testDistributedTopic", i);
- //ServerManagement.stop(i);
- }
-
- ic[i].close();
- }
-
- super.tearDown();
- }
-
- protected String getLocatorURL(Connection conn)
- {
- return getConnectionState(conn).getRemotingConnection().
- getRemotingClient().getInvoker().getLocator().getLocatorURI();
- }
-
- protected String getObjectId(Connection conn)
- {
- return ((DelegateSupport) ((JBossConnection) conn).
- getDelegate()).getID();
- }
-
- protected ConnectionState getConnectionState(Connection conn)
- {
- return (ConnectionState) (((DelegateSupport) ((JBossConnection) conn).
- getDelegate()).getState());
- }
-
-
-
- protected void waitForFailoverComplete(int serverID, Connection conn1)
- throws Exception
- {
-
- assertEquals(serverID, ((JBossConnection)conn1).getServerID());
-
- // register a failover listener
- SimpleFailoverListener failoverListener = new SimpleFailoverListener();
- ((JBossConnection)conn1).registerFailoverListener(failoverListener);
-
- log.debug("killing node " + serverID + " ....");
-
- ServerManagement.kill(serverID);
-
- log.info("########");
- log.info("######## KILLED NODE " + serverID);
- log.info("########");
-
- // wait for the client-side failover to complete
-
- while (true)
- {
- FailoverEvent event = failoverListener.getEvent(30000);
- if (event != null && FailoverEvent.FAILOVER_COMPLETED == event.getType())
- {
- break;
- }
- if (event == null)
- {
- fail("Did not get expected FAILOVER_COMPLETED event");
- }
- }
-
- // failover complete
- log.info("failover completed");
- }
-
-
-
- /**
- * Lookup for the connection with the right serverID. I'm using this method to find the proper
- * serverId so I won't relay on loadBalancing policies on testcases.
- */
- protected Connection getConnection(Connection[] conn, int serverId) throws Exception
- {
- for(int i = 0; i < conn.length; i++)
- {
- ConnectionState state = (ConnectionState)(((DelegateSupport)((JBossConnection)conn[i]).
- getDelegate()).getState());
-
- if (state.getServerID() == serverId)
- {
- return conn[i];
- }
- }
-
- return null;
- }
-
- protected void checkConnectionsDifferentServers(Connection[] conn) throws Exception
- {
- int[] serverID = new int[conn.length];
- for(int i = 0; i < conn.length; i++)
- {
- ConnectionState state = (ConnectionState)(((DelegateSupport)((JBossConnection)conn[i]).
- getDelegate()).getState());
- serverID[i] = state.getServerID();
- }
-
- for(int i = 0; i < nodeCount; i++)
- {
- for(int j = 0; j < nodeCount; j++)
- {
- if (i == j)
- {
- continue;
- }
-
- if (serverID[i] == serverID[j])
- {
- fail("Connections " + i + " and " + j +
- " are pointing to the same physical node (" + serverID[i] + ")");
- }
- }
- }
- }
-
- // Private --------------------------------------------------------------------------------------
-
- private void drainQueues() throws Exception
- {
- Connection[] conn = new Connection[nodeCount];
-
- try
- {
- // TODO This is a dangerous hack, relying on an arbitrary distribution algorithm
- // (round-robin in this case). If we want a connection to a specific node, we should be
- // able to look up something like "/ClusteredConnectionFactory0"
-
- for(int i = 0; i < nodeCount; i++)
- {
- conn[i] = cf.createConnection();
- }
-
- // Safety check, making sure we get connections to distinct nodes
-
- checkConnectionsDifferentServers(conn);
-
- for(int i = 0; i < nodeCount; i++)
- {
- Session s = conn[i].createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageConsumer c = s.createConsumer(queue[i]);
- conn[i].start();
-
- Message msg = null;
- do
- {
- msg = c.receive(1000);
- if (msg != null)
- {
- log.info("Drained message " + msg + " on node " + i);
- }
- }
- while (msg != null);
- }
- }
- finally
- {
- for(int i = 0; i < nodeCount; i++)
- {
- if (conn[i] != null)
- {
- conn[i].close();
- }
- }
- }
- }
-
- // Inner classes --------------------------------------------------------------------------------
-
- protected class SimpleFailoverListener implements FailoverListener
- {
- private LinkedQueue buffer;
-
- public SimpleFailoverListener()
- {
- buffer = new LinkedQueue();
- }
-
- public void failoverEventOccured(FailoverEvent event)
- {
- try
- {
- buffer.put(event);
- }
- catch(InterruptedException e)
- {
- throw new RuntimeException("Putting thread interrupted while trying to add event " +
- "to buffer", e);
- }
- }
-
- /**
- * Blocks until a FailoverEvent is available or timeout occurs, in which case returns null.
- */
- public FailoverEvent getEvent(long timeout) throws InterruptedException
- {
- return (FailoverEvent)buffer.poll(timeout);
- }
- }
-
-}
Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/GroupManagementTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/GroupManagementTest.java 2007-08-06 18:40:27 UTC (rev 2962)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/GroupManagementTest.java 2007-08-06 19:47:09 UTC (rev 2963)
@@ -379,8 +379,6 @@
assertEquals(2, view.size());
assertTrue(view.contains(new Integer(0)));
assertTrue(view.contains(new Integer(9)));
-
-
}
finally
{
@@ -390,7 +388,6 @@
}
}
-
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/LargeClusterTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/LargeClusterTest.java 2007-08-06 18:40:27 UTC (rev 2962)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/LargeClusterTest.java 2007-08-06 19:47:09 UTC (rev 2963)
@@ -27,7 +27,7 @@
*
* $Id$
*/
-public class LargeClusterTest extends ClusteringTestBase
+public class LargeClusterTest extends NewClusteringTestBase
{
// Constants -----------------------------------------------------
@@ -246,7 +246,6 @@
assertTrue(view.contains(new Integer(5)));
assertTrue(view.contains(new Integer(6)));
-
// We get the first node to re-join
ServerManagement.start(0, "all");
@@ -267,7 +266,6 @@
assertTrue(view.contains(new Integer(6)));
ServerManagement.removeNotificationListener(5, postOfficeObjectName, clusterEvent);
-
}
public void testDistributedTopic() throws Exception
Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/PreserveOrderingTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/PreserveOrderingTest.java 2007-08-06 18:40:27 UTC (rev 2962)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/PreserveOrderingTest.java 2007-08-06 19:47:09 UTC (rev 2963)
@@ -28,10 +28,8 @@
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;
-import javax.management.ObjectName;
import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.test.messaging.tools.container.ServiceAttributeOverrides;
/**
*
@@ -41,7 +39,7 @@
* $Id: $
*
*/
-public class PreserveOrderingTest extends ClusteringTestBase
+public class PreserveOrderingTest extends NewClusteringTestBase
{
// Constants -----------------------------------------------------
@@ -87,29 +85,16 @@
{
nodeCount = 3;
- overrides = new ServiceAttributeOverrides();
-
- overrides.put(new ObjectName("jboss.messaging:service=ServerPeer"), "DefaultPreserveOrdering", "true");
-
super.setUp();
- log.debug("setup done");
- }
-
- protected void tearDown() throws Exception
- {
- super.tearDown();
-
for (int i = 0; i < nodeCount; i++)
{
- if (ServerManagement.isStarted(i))
- {
- ServerManagement.log(ServerManagement.INFO, "Undeploying Server " + i, i);
- ServerManagement.stop(i);
- }
+ ServerManagement.getServer(i).setPreserveOrdering(true);
}
+
+ log.debug("setup done");
}
-
+
protected void preserveOrderingQueue(boolean persistent) throws Exception
{
Connection conn0 = null;
Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/TemporaryDestinationTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/TemporaryDestinationTest.java 2007-08-06 18:40:27 UTC (rev 2962)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/TemporaryDestinationTest.java 2007-08-06 19:47:09 UTC (rev 2963)
@@ -29,9 +29,7 @@
import javax.jms.TextMessage;
import javax.jms.Topic;
-import org.jboss.test.messaging.tools.ServerManagement;
-
/**
* A test for temporary destinations in a clustered enviroment.
* See http://jira.jboss.org/jira/browse/JBMESSAGING-841.
Modified: trunk/tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java 2007-08-06 18:40:27 UTC (rev 2962)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java 2007-08-06 19:47:09 UTC (rev 2963)
@@ -906,6 +906,11 @@
{
getServerPeer().setUseXAForMessagePull(xa);
}
+
+ public void setPreserveOrdering(boolean preserve) throws Exception
+ {
+ getServerPeer().setDefaultPreserveOrdering(preserve);
+ }
// Public ---------------------------------------------------------------------------------------
Modified: trunk/tests/src/org/jboss/test/messaging/tools/container/RMITestServer.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/RMITestServer.java 2007-08-06 18:40:27 UTC (rev 2962)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/RMITestServer.java 2007-08-06 19:47:09 UTC (rev 2963)
@@ -506,6 +506,11 @@
{
server.setUseXAForMessagePull(xa);
}
+
+ public void setPreserveOrdering(boolean preserve) throws Exception
+ {
+ server.setPreserveOrdering(preserve);
+ }
// Public --------------------------------------------------------
Modified: trunk/tests/src/org/jboss/test/messaging/tools/container/Server.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/Server.java 2007-08-06 18:40:27 UTC (rev 2962)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/Server.java 2007-08-06 19:47:09 UTC (rev 2963)
@@ -292,4 +292,6 @@
void setUseXAForMessagePull(boolean xa) throws Exception;
+ void setPreserveOrdering(boolean preserve) throws Exception;
+
}
More information about the jboss-cvs-commits
mailing list