[jboss-cvs] JBoss Messaging SVN: r1729 - in branches/Branch_Client_Failover_Experiment: src/main/org/jboss/jms/server/connectionfactory src/main/org/jboss/messaging/core/plugin/postoffice/cluster tests tests/src/org/jboss/test/messaging/jms/clustering

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Dec 8 10:29:29 EST 2006


Author: timfox
Date: 2006-12-08 10:29:23 -0500 (Fri, 08 Dec 2006)
New Revision: 1729

Modified:
   branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryJNDIMapper.java
   branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/DefaultClusteredPostOffice.java
   branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/RemoveReplicantRequest.java
   branches/Branch_Client_Failover_Experiment/tests/build.xml
   branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering/HATest.java
Log:
More HA



Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryJNDIMapper.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryJNDIMapper.java	2006-12-08 14:07:04 UTC (rev 1728)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryJNDIMapper.java	2006-12-08 15:29:23 UTC (rev 1729)
@@ -226,7 +226,10 @@
          if (replicator != null)
          {         
             //There may be no clustered post office deployed
-            replicator.remove(CF_PREFIX + uniqueName);
+            if (!replicator.remove(CF_PREFIX + uniqueName))
+            {
+               throw new IllegalStateException("Cannot find replicant to remove: " + CF_PREFIX + uniqueName);
+            }
          }
          
       }
@@ -288,17 +291,21 @@
             
             ClusteredClientConnectionFactoryDelegate clusteredDelegate = createClusteredDelegate(updatedReplicantMap);
             
-            // Now rebind ...
-            
-            ServerConnectionFactoryEndpoint endpoint =
-               (ServerConnectionFactoryEndpoint)endpoints.get(uniqueName);
-            
-            if (endpoint == null)
-            {
-               throw new IllegalStateException("Cannot find endpoint " + uniqueName );
+            //It could be null if the cf is being undeployed
+            if (clusteredDelegate != null)
+            {               
+               // Now rebind ...
+               
+               ServerConnectionFactoryEndpoint endpoint =
+                  (ServerConnectionFactoryEndpoint)endpoints.get(uniqueName);
+               
+               if (endpoint == null)
+               {
+                  throw new IllegalStateException("Cannot find endpoint " + uniqueName );
+               }
+   
+               rebindConnectionFactory(initialContext, endpoint.getJNDIBindings(), clusteredDelegate);
             }
-
-            rebindConnectionFactory(initialContext, endpoint.getJNDIBindings(), clusteredDelegate);
          }
       }
       catch (NamingException e)
@@ -333,12 +340,9 @@
     */
    private ClusteredClientConnectionFactoryDelegate createClusteredDelegate(Map localDelegates)
    {
-
-
       //TODO: make it trace after the code is stable
       log.info("Updating FailoverDelegates " + localDelegates.size() + " on serverPeer:" + serverPeer.getServerPeerID());
 
-
       int s = localDelegates.size();
 
       int[] nodesIDs = new int[s];
@@ -350,7 +354,7 @@
 
       int idx = 0;
 
-      for(Iterator i = localDelegates.entrySet().iterator(); i.hasNext(); )
+      for(Iterator i = localDelegates.entrySet().iterator(); i.hasNext();)
       {
          Map.Entry entry = (Map.Entry)i.next();
 
@@ -365,7 +369,6 @@
 
          if (delegates[idx].getServerId() == this.serverPeer.getServerPeerID())
          {
-
             // sanity check
             if (mainDelegate != null)
             {
@@ -377,41 +380,43 @@
          idx++;
       }
       // sanity check
-      if (mainDelegate == null)
-      {
-         throw new IllegalStateException("Couldn't find a delegate for this serverID=" + this.serverPeer.getServerPeerID());
-      }
-
       
       // Generate the failover indexes. This could probably be optimised if need be.
       
-      int[] failoverIndexes = new int[s];
+      //MainDelegate would be null in the case the cf is being undeployed locally
       
-      for (int i = 0; i < s; i++)
-      {
-         int failoverNode = failoverNodeIDs[i];
-         int failoverIndex = -1;
+      ClusteredClientConnectionFactoryDelegate clusteredDelegate = null;
+      
+      if (mainDelegate != null)
+      {         
+         int[] failoverIndexes = new int[s];
          
-         for (int j = 0; j < s; j++)
+         for (int i = 0; i < s; i++)
          {
-            if (nodesIDs[j] == failoverNode)
+            int failoverNode = failoverNodeIDs[i];
+            int failoverIndex = -1;
+            
+            for (int j = 0; j < s; j++)
             {
-               failoverIndex = j;
-               break;
+               if (nodesIDs[j] == failoverNode)
+               {
+                  failoverIndex = j;
+                  break;
+               }
             }
+            
+            if (failoverIndex == -1)
+            {
+               throw new IllegalStateException("Failover node " + failoverNode + " is not in list of nodes at node " + serverPeer.getServerPeerID() + "!");
+            }
+            
+            failoverIndexes[i] = failoverIndex;
          }
-         
-         if (failoverIndex == -1)
-         {
-            throw new IllegalStateException("Failover node " + failoverNode + " is not in list of nodes at node " + serverPeer.getServerPeerID() + "!");
-         }
-         
-         failoverIndexes[i] = failoverIndex;
+   
+         clusteredDelegate =
+            new ClusteredClientConnectionFactoryDelegate(mainDelegate, delegates, failoverIndexes);
       }
 
-      ClusteredClientConnectionFactoryDelegate clusteredDelegate =
-         new ClusteredClientConnectionFactoryDelegate(mainDelegate,delegates,failoverIndexes);
-
       return clusteredDelegate;
    }
 

Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/DefaultClusteredPostOffice.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/DefaultClusteredPostOffice.java	2006-12-08 14:07:04 UTC (rev 1728)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/DefaultClusteredPostOffice.java	2006-12-08 15:29:23 UTC (rev 1729)
@@ -21,7 +21,6 @@
  */
 package org.jboss.messaging.core.plugin.postoffice.cluster;
 
-import EDU.oswego.cs.dl.util.concurrent.QueuedExecutor;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.DataInputStream;
@@ -44,6 +43,7 @@
 import javax.jms.TextMessage;
 import javax.sql.DataSource;
 import javax.transaction.TransactionManager;
+
 import org.jboss.jms.server.QueuedExecutorPool;
 import org.jboss.logging.Logger;
 import org.jboss.messaging.core.Delivery;
@@ -76,6 +76,8 @@
 import org.jgroups.blocks.RequestHandler;
 import org.w3c.dom.Element;
 
+import EDU.oswego.cs.dl.util.concurrent.QueuedExecutor;
+
 /**
  * 
  * A DefaultClusteredPostOffice
@@ -1887,7 +1889,7 @@
     *        the given key.
     */
    private void notifyListeners(Serializable key, Map updatedReplicantMap)
-   {
+   { 
       synchronized (replicationListeners)
       {         
          for (Iterator i = replicationListeners.iterator(); i.hasNext(); )
@@ -2189,8 +2191,7 @@
 
       log.info(this.currentNodeId + " Node with address: " + address + " joined");
       
-      // We need to regenerate the failover map
-      //generateFailoverMap(currentView);
+      //Currently does nothing
    }
 
    /*
@@ -2238,6 +2239,7 @@
          failOver(theNodeId.intValue());
       }
    }
+         
 
    // Inner classes -------------------------------------------------------------------
     

Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/RemoveReplicantRequest.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/RemoveReplicantRequest.java	2006-12-08 14:07:04 UTC (rev 1728)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/RemoveReplicantRequest.java	2006-12-08 15:29:23 UTC (rev 1729)
@@ -48,7 +48,10 @@
    
    Object execute(PostOfficeInternal office) throws Exception
    {
-      office.removeReplicantLocally(nodeId, key);
+      if (!office.removeReplicantLocally(nodeId, key))
+      {
+         throw new IllegalStateException("Failed to remove replicant locally: " + nodeId + " key: "+ key);
+      }
       
       return null;
    }

Modified: branches/Branch_Client_Failover_Experiment/tests/build.xml
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/build.xml	2006-12-08 14:07:04 UTC (rev 1728)
+++ branches/Branch_Client_Failover_Experiment/tests/build.xml	2006-12-08 15:29:23 UTC (rev 1729)
@@ -715,7 +715,7 @@
                     haltonerror="${junit.batchtest.haltonerror}">
             <formatter type="plain" usefile="${junit.formatter.usefile}"/>
             <fileset dir="${build.tests.classes}">
-               <include name="**/jms/clustering/HATest.class"/>
+               <include name="**/jms/clustering/*Test.class"/>
             </fileset>
          </batchtest>
       </junit>

Modified: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering/HATest.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering/HATest.java	2006-12-08 14:07:04 UTC (rev 1728)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering/HATest.java	2006-12-08 15:29:23 UTC (rev 1729)
@@ -22,12 +22,16 @@
 
 package org.jboss.test.messaging.jms.clustering;
 
+import javax.jms.Connection;
 import javax.jms.MessageConsumer;
 import javax.jms.TextMessage;
 
+import org.jboss.jms.client.JBossConnection;
 import org.jboss.jms.client.JBossConnectionFactory;
 import org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate;
 import org.jboss.jms.client.delegate.ClusteredClientConnectionFactoryDelegate;
+import org.jboss.jms.client.delegate.DelegateSupport;
+import org.jboss.jms.client.state.ConnectionState;
 import org.jboss.jms.message.MessageProxy;
 import org.jboss.test.messaging.jms.clustering.base.ClusteringTestBase;
 import org.jboss.test.messaging.tools.ServerManagement;
@@ -217,6 +221,10 @@
       
       // Default failover policy just chooses the node to the right
       
+      log.info("failoverindex[0]:" + failoverIndexes[0]);
+      log.info("failoverindex[1]:" + failoverIndexes[1]);
+      log.info("failoverindex[2]:" + failoverIndexes[2]);
+      
       assertEquals(1, failoverIndexes[0]);
       
       assertEquals(2, failoverIndexes[1]);




More information about the jboss-cvs-commits mailing list