[jboss-cvs] JBoss Messaging SVN: r2990 - in trunk: tests/src/org/jboss/test/messaging/jms/clustering and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Aug 9 08:34:12 EDT 2007


Author: timfox
Date: 2007-08-09 08:34:12 -0400 (Thu, 09 Aug 2007)
New Revision: 2990

Modified:
   trunk/src/main/org/jboss/jms/client/delegate/ClientClusteredConnectionFactoryDelegate.java
   trunk/tests/src/org/jboss/test/messaging/jms/clustering/HATest.java
Log:
Tests speedup


Modified: trunk/src/main/org/jboss/jms/client/delegate/ClientClusteredConnectionFactoryDelegate.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/delegate/ClientClusteredConnectionFactoryDelegate.java	2007-08-09 10:41:51 UTC (rev 2989)
+++ trunk/src/main/org/jboss/jms/client/delegate/ClientClusteredConnectionFactoryDelegate.java	2007-08-09 12:34:12 UTC (rev 2990)
@@ -139,7 +139,6 @@
    
    public ClientConnectionFactoryDelegate[] getDelegates()
    {
-   	sanityCheck();
       return delegates;
    }
 
@@ -151,7 +150,6 @@
 
    public Map getFailoverMap()
    {
-   	sanityCheck();
       return failoverMap;
    }
 
@@ -178,10 +176,15 @@
    
    /** Method used to update the delegate and failoverMap during viewChange */
    public synchronized void updateFailoverInfo(ClientConnectionFactoryDelegate[] delegates,
-                                               Map failoverMap)
+                                               Map newFailoverMap)
    {	
+   	log.trace("Updating failover info " + delegates.length + " map " + newFailoverMap);
+   	
       this.delegates = delegates;
-      this.failoverMap = failoverMap;
+      
+      //Note! We do not overwrite the failoverMap, we *add* to it, see http://jira.jboss.com/jira/browse/JBMESSAGING-1041
+      
+      failoverMap.putAll(newFailoverMap);
 
       if (supportsLoadBalancing)
       {
@@ -218,14 +221,6 @@
 
    // Private --------------------------------------------------------------------------------------
    
-   private void sanityCheck()
-   {
-   	if (delegates.length != failoverMap.size())
-   	{
-         throw new IllegalStateException("Number of delegates (" + delegates.length + ") and failover map size (" + failoverMap.size() + " )are not equal");
-   	}
-   }
-
    // Inner classes --------------------------------------------------------------------------------
 
 }

Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/HATest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/HATest.java	2007-08-09 10:41:51 UTC (rev 2989)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/HATest.java	2007-08-09 12:34:12 UTC (rev 2990)
@@ -22,6 +22,9 @@
 
 package org.jboss.test.messaging.jms.clustering;
 
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
 import java.util.Set;
 
 import javax.jms.Connection;
@@ -32,6 +35,7 @@
 import javax.jms.Session;
 import javax.jms.TextMessage;
 import javax.jms.Topic;
+import javax.management.ObjectName;
 
 import org.jboss.jms.client.FailoverEvent;
 import org.jboss.jms.client.JBossConnection;
@@ -73,7 +77,61 @@
    
    // Public --------------------------------------------------------
    
-   //
+   public void testAddToFailoverMapOnKill() throws Exception
+   {
+   	Connection conn = null;
+   	
+   	try
+   	{	   	
+	   	conn = this.createConnectionOnServer(cf, 0);
+	   	
+	   	Map failoverMap = ((ClientClusteredConnectionFactoryDelegate)(cf.getDelegate())).getFailoverMap();
+	   	
+	   	dumpFailoverMap(failoverMap);
+	   		   	
+	   	assertEquals(3, failoverMap.size());
+	   	
+	   	Map mapCopy = new HashMap(failoverMap);
+	   	
+	   	ServerManagement.kill(1);
+	   	
+	   	Thread.sleep(5000);
+	   		   	
+	   	failoverMap = ((ClientClusteredConnectionFactoryDelegate)(cf.getDelegate())).getFailoverMap();
+	   	
+	   	dumpFailoverMap(failoverMap);
+	   	
+	   	//Failover map should be added to not replaced
+	   	
+	   	assertEquals(3, failoverMap.size());
+	   	
+	   	assertEquals(2, ((Integer)failoverMap.get(new Integer(0))).intValue());
+	   	
+	   	assertEquals(0, ((Integer)failoverMap.get(new Integer(2))).intValue());
+	   	
+	   	assertEquals(((Integer)mapCopy.get(new Integer(1))).intValue(), ((Integer)failoverMap.get(new Integer(1))).intValue());
+   	}
+   	finally
+   	{
+   		if (conn != null)
+   		{
+   			conn.close();
+   		}
+   	}
+   }
+   
+   private void dumpFailoverMap(Map failoverMap)
+   {
+      log.info("Dumping failover map");
+      Iterator iter = failoverMap.entrySet().iterator();
+      while (iter.hasNext())
+      {
+      	Map.Entry entry = (Map.Entry)iter.next();
+      	log.info(entry.getKey() + "-->" + entry.getValue());
+      }
+   }
+   
+   
 
    /**
     * This test was created as per http://jira.jboss.org/jira/browse/JBMESSAGING-685.




More information about the jboss-cvs-commits mailing list