[jboss-cvs] JBoss Messaging SVN: r2839 - in trunk: src/main/org/jboss/jms/client/plugin and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jul 4 14:32:01 EDT 2007


Author: timfox
Date: 2007-07-04 14:32:01 -0400 (Wed, 04 Jul 2007)
New Revision: 2839

Modified:
   trunk/src/etc/remoting/remoting-http-service.xml
   trunk/src/main/org/jboss/jms/client/plugin/RandomLoadBalancingPolicy.java
   trunk/src/main/org/jboss/jms/server/endpoint/ServerConsumerEndpoint.java
   trunk/tests/src/org/jboss/test/messaging/MessagingTestCase.java
   trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterConnectionManagerTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterViewUpdateTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusteredConnectionFactoryTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusteringTestBase.java
   trunk/tests/src/org/jboss/test/messaging/jms/clustering/DisableLoadBalancingAndFailoverTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/clustering/DistributedQueueTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/clustering/DistributedRequestResponseTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/clustering/DistributedTopicTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/clustering/HATest.java
   trunk/tests/src/org/jboss/test/messaging/jms/clustering/LargeClusterTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/clustering/MultipleFailoverTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/clustering/PreserveOrderingTest.java
Log:
Fixed tests for http://jira.jboss.com/jira/browse/JBMESSAGING-1000


Modified: trunk/src/etc/remoting/remoting-http-service.xml
===================================================================
--- trunk/src/etc/remoting/remoting-http-service.xml	2007-07-04 16:46:36 UTC (rev 2838)
+++ trunk/src/etc/remoting/remoting-http-service.xml	2007-07-04 18:32:01 UTC (rev 2839)
@@ -23,7 +23,7 @@
                <attribute name="socket.check_connection" isParam="true">false</attribute>
                <attribute name="callbackStore">org.jboss.remoting.callback.BlockingCallbackStore</attribute>
                <attribute name="callbackPollPeriod" isParam="true">102</attribute>
-               <attribute name="clientLeasePeriod" isParam="true">20000</attribute>
+               <attribute name="clientLeasePeriod" isParam="true">10000</attribute>
             </invoker>
             <handlers>
                <handler subsystem="JMS">org.jboss.jms.server.remoting.JMSServerInvocationHandler</handler>

Modified: trunk/src/main/org/jboss/jms/client/plugin/RandomLoadBalancingPolicy.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/plugin/RandomLoadBalancingPolicy.java	2007-07-04 16:46:36 UTC (rev 2838)
+++ trunk/src/main/org/jboss/jms/client/plugin/RandomLoadBalancingPolicy.java	2007-07-04 18:32:01 UTC (rev 2839)
@@ -70,10 +70,14 @@
    {
       if (random == null)
       {
-         random = new Random();
+      	long seed = System.currentTimeMillis() ^ (long)new Object().hashCode();
+      	
+         random = new Random(seed);
       }
+      
       int nextInt = random.nextInt() % delegates.length;
-      if (nextInt<0)
+      
+      if (nextInt < 0)
       {
          nextInt *= -1;
       }

Modified: trunk/src/main/org/jboss/jms/server/endpoint/ServerConsumerEndpoint.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/ServerConsumerEndpoint.java	2007-07-04 16:46:36 UTC (rev 2838)
+++ trunk/src/main/org/jboss/jms/server/endpoint/ServerConsumerEndpoint.java	2007-07-04 18:32:01 UTC (rev 2839)
@@ -51,9 +51,6 @@
 import org.jboss.remoting.callback.Callback;
 import org.jboss.remoting.callback.ServerInvokerCallbackHandler;
 
-import EDU.oswego.cs.dl.util.concurrent.Callable;
-import EDU.oswego.cs.dl.util.concurrent.TimedCallable;
-
 /**
  * Concrete implementation of ConsumerEndpoint. Lives on the boundary between Messaging Core and the
  * JMS Facade. Handles delivery of messages from the server to the client side consumer.
@@ -318,8 +315,8 @@
             else
             {
                // TODO: dummy synchronization object, in case there's no clientInvoker. This will
-               // happen during the first invocation anyway. It's a kludge, I know, but we will get rid of this
-            	// when we get rid of remoting
+               // happen during the first invocation anyway. It's a kludge, I know, but this whole
+               // synchronization thing is a huge kludge. Needs to be reviewed.
                invoker = new Object();
             }
             
@@ -327,25 +324,9 @@
             {
                // one way invocation, no acknowledgment sent back by the client
                if (trace) { log.trace(this + " submitting message " + message + " to the remoting layer to be sent asynchronously"); }
-                              
-               if (remote)
-               {
-               	// FIXME - there is a bug in remoting when using the bisocket transport that if an invocation is attempted when the connection is closed
-               	// it sends a request to create a socket, then waits for ever for the socket to be created.
-               	// Therefore if this is a message sucker, we excuted using a TimedCallable which is guaranteed to throw an exception if it
-               	// takes too long.
-               	// In this case the consumer will be stopped and later on it will get cleaned up
-               	               	
-               	//TODO make the timeout configurable
-               	Callable callable = new TimedCallable(new HandleCallbackCallable(callbackHandler, callback), 1000);
-               	
-               	callable.call();               	               
-               }
-               else
-               {               
-               	callbackHandler.handleCallbackOneway(callback);
-               }               
                
+               callbackHandler.handleCallbackOneway(callback);
+               
                //We store the delivery id so we know to wait for any deliveries in transit on close
                this.lastDeliveryID = deliveryId;
             }
@@ -373,7 +354,7 @@
          return delivery;
       }
    }
-      
+
    // Filter implementation ------------------------------------------------------------------------
 
    public boolean accept(Message msg)
@@ -651,27 +632,5 @@
    }
 
    // Inner classes --------------------------------------------------------------------------------
-   
-   private class HandleCallbackCallable implements Callable
-   {
-   	private ServerInvokerCallbackHandler handler;
-   	
-   	private Callback callback;
-   	
-   	HandleCallbackCallable(ServerInvokerCallbackHandler handler, Callback callback)
-   	{   		
-   		this.handler = handler;
-   		
-   		this.callback = callback;
-   	}
 
-		public Object call() throws Exception
-		{
-			handler.handleCallback(callback);
-			
-			return null;
-		}
-   	
-   }
-
 }

Modified: trunk/tests/src/org/jboss/test/messaging/MessagingTestCase.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/MessagingTestCase.java	2007-07-04 16:46:36 UTC (rev 2838)
+++ trunk/tests/src/org/jboss/test/messaging/MessagingTestCase.java	2007-07-04 18:32:01 UTC (rev 2839)
@@ -31,6 +31,8 @@
 import javax.jms.MessageConsumer;
 import javax.jms.Session;
 import javax.jms.Topic;
+import javax.jms.XAConnection;
+import javax.jms.XAConnectionFactory;
 import javax.naming.InitialContext;
 import javax.sql.DataSource;
 import javax.transaction.TransactionManager;
@@ -290,7 +292,53 @@
    {
       return ((JBossConnection) conn).getServerID();
    }
+   
+   protected Connection createConnectionOnServer(ConnectionFactory factory, int serverId)
+   throws Exception
+   {
+   	int count=0;
 
+   	while (true)
+   	{
+   		if (count++>10)
+   			return null;
+
+   		Connection connection = factory.createConnection();
+
+   		if (getServerId(connection) == serverId)
+   		{
+   			return connection;
+   		}
+   		else
+   		{
+   			connection.close();
+   		}
+   	}
+   }
+
+   protected XAConnection createXAConnectionOnServer(XAConnectionFactory factory, int serverId)
+   throws Exception
+   {
+   	int count=0;
+
+   	while (true)
+   	{
+   		if (count++>10)
+   			return null;
+
+   		XAConnection connection = factory.createXAConnection();
+
+   		if (getServerId(connection) == serverId)
+   		{
+   			return connection;
+   		}
+   		else
+   		{
+   			connection.close();
+   		}
+   	}
+   }
+
    // Private -------------------------------------------------------
    
    // Inner classes -------------------------------------------------   

Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterConnectionManagerTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterConnectionManagerTest.java	2007-07-04 16:46:36 UTC (rev 2838)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterConnectionManagerTest.java	2007-07-04 18:32:01 UTC (rev 2839)
@@ -201,7 +201,7 @@
       
       try
       {
-      	conn0 = cf0.createConnection();
+      	conn0 = this.createConnectionOnServer(cf0, 0);
       	
       	//Send some messages on node 0
       	
@@ -220,7 +220,7 @@
       	
       	//Consume them on node 1
       	
-      	conn1 = cf1.createConnection();
+      	conn1 = this.createConnectionOnServer(cf1, 1);
       	
       	Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
       	

Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterViewUpdateTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterViewUpdateTest.java	2007-07-04 16:46:36 UTC (rev 2838)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterViewUpdateTest.java	2007-07-04 18:32:01 UTC (rev 2839)
@@ -170,10 +170,10 @@
 
       Connection conn2 = cf.createConnection();
 
+      assertEquals(1, getServerId(conn1));
+      
       assertEquals(2, getServerId(conn2));
 
-      assertEquals(1, getServerId(conn1));
-
       ConnectionState state = this.getConnectionState(conn1);
 
       // Disable Leasing for Failover

Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusteredConnectionFactoryTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusteredConnectionFactoryTest.java	2007-07-04 16:46:36 UTC (rev 2838)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusteredConnectionFactoryTest.java	2007-07-04 18:32:01 UTC (rev 2839)
@@ -87,7 +87,6 @@
 
       try
       {
-
          ServerManagement.killAndWait(0);
          ServerManagement.killAndWait(1);
 
@@ -145,7 +144,6 @@
 
       try
       {
-
          // Poison each server with a different pointcut crash
          ServerManagement.poisonTheServer(1, PoisonInterceptor.CF_CREATE_CONNECTION);
 

Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusteringTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusteringTestBase.java	2007-07-04 16:46:36 UTC (rev 2838)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusteringTestBase.java	2007-07-04 18:32:01 UTC (rev 2839)
@@ -29,8 +29,6 @@
 import javax.jms.Queue;
 import javax.jms.Session;
 import javax.jms.Topic;
-import javax.jms.XAConnection;
-import javax.jms.XAConnectionFactory;
 import javax.naming.Context;
 import javax.naming.InitialContext;
 
@@ -69,7 +67,7 @@
    
    protected ServiceAttributeOverrides overrides;
 
-   // No need to have multiple conncetion factories since a clustered connection factory will create
+   // 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;
@@ -165,51 +163,7 @@
          getDelegate()).getState());
    }
 
-   protected Connection createConnectionOnServer(ConnectionFactory factory, int serverId)
-      throws Exception
-   {
-      int count=0;
-
-      while (true)
-      {
-         if (count++>10)
-            return null;
-
-         Connection connection = factory.createConnection();
-
-         if (getServerId(connection) == serverId)
-         {
-            return connection;
-         }
-         else
-         {
-            connection.close();
-         }
-      }
-   }
-
-   protected XAConnection createXAConnectionOnServer(XAConnectionFactory factory, int serverId)
-      throws Exception
-   {
-      int count=0;
    
-      while (true)
-      {
-         if (count++>10)
-            return null;
-   
-         XAConnection connection = factory.createXAConnection();
-   
-         if (getServerId(connection) == serverId)
-         {
-            return connection;
-         }
-         else
-         {
-            connection.close();
-         }
-      }
-   }
 
    protected void waitForFailoverComplete(int serverID, Connection conn1)
       throws Exception

Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/DisableLoadBalancingAndFailoverTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/DisableLoadBalancingAndFailoverTest.java	2007-07-04 16:46:36 UTC (rev 2838)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/DisableLoadBalancingAndFailoverTest.java	2007-07-04 18:32:01 UTC (rev 2839)
@@ -237,7 +237,7 @@
          	long end = System.currentTimeMillis();
          	
          	//Make sure it doesn't take too long
-         	assertTrue((end - start) <= 20);
+         	assertTrue((end - start) <= 100);
          }                 
       }
       finally

Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/DistributedQueueTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/DistributedQueueTest.java	2007-07-04 16:46:36 UTC (rev 2838)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/DistributedQueueTest.java	2007-07-04 18:32:01 UTC (rev 2839)
@@ -112,9 +112,9 @@
       {
          //This will create 3 different connection on 3 different nodes, since
          //the cf is clustered
-         conn0 = cf.createConnection();
-         conn1 = cf.createConnection();
-         conn2 = cf.createConnection();
+         conn0 = this.createConnectionOnServer(cf, 0);
+         conn1 = this.createConnectionOnServer(cf, 1);
+         conn2 = this.createConnectionOnServer(cf, 2);
          
          checkConnectionsDifferentServers(new Connection[] {conn0, conn1, conn2});
 
@@ -566,9 +566,9 @@
       	
          //This will create 3 different connection on 3 different nodes, since
          //the cf is clustered
-         conn0 = cf.createConnection();
-         conn1 = cf.createConnection();
-         conn2 = cf.createConnection();
+         conn0 = this.createConnectionOnServer(cf, 0);
+         conn1 = this.createConnectionOnServer(cf, 1);
+         conn2 = this.createConnectionOnServer(cf, 2);
          
          checkConnectionsDifferentServers(new Connection[] {conn0, conn1, conn2});
 

Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/DistributedRequestResponseTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/DistributedRequestResponseTest.java	2007-07-04 16:46:36 UTC (rev 2838)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/DistributedRequestResponseTest.java	2007-07-04 18:32:01 UTC (rev 2839)
@@ -134,7 +134,7 @@
 	      Queue queue0 = (Queue)ic0.lookup("/queue/testDistributedQueue");
 	      Queue queue1 = (Queue)ic1.lookup("/queue/testDistributedQueue");
 	   	
-         conn0 = cf.createConnection();
+         conn0 = this.createConnectionOnServer(cf, 0);
          
          conn1 = cf.createConnection();
          

Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/DistributedTopicTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/DistributedTopicTest.java	2007-07-04 16:46:36 UTC (rev 2838)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/DistributedTopicTest.java	2007-07-04 18:32:01 UTC (rev 2839)
@@ -165,9 +165,9 @@
       {
          //This will create 3 different connection on 3 different nodes, since
          //the cf is clustered
-         conn0 = cf.createConnection();
-         conn1 = cf.createConnection();
-         conn2 = cf.createConnection();
+         conn0 = this.createConnectionOnServer(cf, 0);
+         conn1 = this.createConnectionOnServer(cf, 1);
+         conn2 = this.createConnectionOnServer(cf, 2);
          
          checkConnectionsDifferentServers(new Connection[] {conn0, conn1, conn2});
 
@@ -300,9 +300,9 @@
       {
          //This will create 3 different connection on 3 different nodes, since
          //the cf is clustered
-         conn0 = cf.createConnection();
-         conn1 = cf.createConnection();
-         conn2 = cf.createConnection();
+      	conn0 = this.createConnectionOnServer(cf, 0);
+         conn1 = this.createConnectionOnServer(cf, 1);
+         conn2 = this.createConnectionOnServer(cf, 2);
          
          checkConnectionsDifferentServers(new Connection[] {conn0, conn1, conn2});
 
@@ -448,9 +448,9 @@
       try
       {
          // This will create 3 different connection on 3 different nodes, since the cf is clustered
-         conn0 = cf.createConnection();
-         conn1 = cf.createConnection();
-         conn2 = cf.createConnection();
+      	conn0 = this.createConnectionOnServer(cf, 0);
+         conn1 = this.createConnectionOnServer(cf, 1);
+         conn2 = this.createConnectionOnServer(cf, 2);
          
          checkConnectionsDifferentServers(new Connection[] {conn0, conn1, conn2});
 
@@ -695,9 +695,9 @@
       {
          //This will create 3 different connection on 3 different nodes, since
          //the cf is clustered
-         conn1 = cf.createConnection();
-         conn2 = cf.createConnection();
-         conn3 = cf.createConnection();
+      	conn1 = this.createConnectionOnServer(cf, 0);
+         conn2 = this.createConnectionOnServer(cf, 1);
+         conn3 = this.createConnectionOnServer(cf, 2);
          
          checkConnectionsDifferentServers(new Connection[] {conn1, conn2, conn3});
          conn1.setClientID("wib1");
@@ -907,9 +907,9 @@
       {
          //This will create 3 different connection on 3 different nodes, since
          //the cf is clustered
-         conn1 = cf.createConnection();
-         conn2 = cf.createConnection();
-         conn3 = cf.createConnection();
+      	conn1 = this.createConnectionOnServer(cf, 0);
+         conn2 = this.createConnectionOnServer(cf, 1);
+         conn3 = this.createConnectionOnServer(cf, 2);
          
          checkConnectionsDifferentServers(new Connection[] {conn1, conn2, conn3});
          
@@ -1045,9 +1045,9 @@
 
          //This will create 3 different connection on 3 different nodes, since
          //the cf is clustered
-         conn0 = cf.createConnection();
-         conn1 = cf.createConnection();
-         conn2 = cf.createConnection();
+         conn0 = this.createConnectionOnServer(cf, 0);
+         conn1 = this.createConnectionOnServer(cf, 1);
+         conn2 = this.createConnectionOnServer(cf, 2);
          
          checkConnectionsDifferentServers(new Connection[] {conn0, conn1, conn2});
 
@@ -1236,9 +1236,9 @@
 
          //This will create 3 different connection on 3 different nodes, since
          //the cf is clustered
-         conn0 = cf.createConnection();
-         conn1 = cf.createConnection();
-         conn2 = cf.createConnection();
+         conn0 = this.createConnectionOnServer(cf, 0);
+         conn1 = this.createConnectionOnServer(cf, 1);
+         conn2 = this.createConnectionOnServer(cf, 2);
          
          conn0.setClientID("cl123");
          conn1.setClientID("cl123");

Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/HATest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/HATest.java	2007-07-04 16:46:36 UTC (rev 2838)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/HATest.java	2007-07-04 18:32:01 UTC (rev 2839)
@@ -95,6 +95,8 @@
       Connection conn3 = factory.createConnection();
 
       Connection[] conn = new Connection[]{conn1, conn2, conn3};
+      
+      this.checkConnectionsDifferentServers(conn);
 
       log.info("Connection delegate information after creation");
 

Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/LargeClusterTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/LargeClusterTest.java	2007-07-04 16:46:36 UTC (rev 2838)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/LargeClusterTest.java	2007-07-04 18:32:01 UTC (rev 2839)
@@ -283,7 +283,7 @@
 
       try
       {
-         conn0 = cf.createConnection();
+         conn0 = this.createConnectionOnServer(cf, 0);
          assertEquals(0, ((ClientConnectionDelegate)((JBossConnection)conn0).
             getDelegate()).getServerID());
          Session s0 = conn0.createSession(false, Session.AUTO_ACKNOWLEDGE);

Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/MultipleFailoverTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/MultipleFailoverTest.java	2007-07-04 16:46:36 UTC (rev 2838)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/MultipleFailoverTest.java	2007-07-04 18:32:01 UTC (rev 2839)
@@ -75,7 +75,7 @@
       {
          // we start with a cluster of two (server 0 and server 1)
 
-         conn = cf.createConnection();
+         conn = this.createConnectionOnServer(cf, 0);
          conn.start();
 
          // send/receive message
@@ -200,7 +200,7 @@
 
       try
       {
-         conn = cf.createConnection();
+         conn = this.createConnectionOnServer(cf, 0);
 
          Session sessSend = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
 

Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/PreserveOrderingTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/PreserveOrderingTest.java	2007-07-04 16:46:36 UTC (rev 2838)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/PreserveOrderingTest.java	2007-07-04 18:32:01 UTC (rev 2839)
@@ -110,9 +110,9 @@
       {
          //This will create 3 different connection on 3 different nodes, since
          //the cf is clustered
-         conn0 = cf.createConnection();
-         conn1 = cf.createConnection();
-         conn2 = cf.createConnection();
+         conn0 = this.createConnectionOnServer(cf, 0);
+         conn1 = this.createConnectionOnServer(cf, 1);
+         conn2 = this.createConnectionOnServer(cf, 2);
          
          log.info("Created connections");
          
@@ -224,9 +224,9 @@
       {
          //This will create 3 different connection on 3 different nodes, since
          //the cf is clustered
-         conn0 = cf.createConnection();
-         conn1 = cf.createConnection();
-         conn2 = cf.createConnection();
+         conn0 = this.createConnectionOnServer(cf, 0);
+         conn1 = this.createConnectionOnServer(cf, 1);
+         conn2 = this.createConnectionOnServer(cf, 2);
          conn0.setClientID("cl1");
          conn1.setClientID("cl1");
          conn2.setClientID("cl1");




More information about the jboss-cvs-commits mailing list