[jboss-cvs] JBoss Messaging SVN: r1788 - in trunk/src/main/org/jboss: jms/client/container jms/client/delegate jms/server/endpoint messaging/core/plugin

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Dec 14 01:26:49 EST 2006


Author: ovidiu.feodorov at jboss.com
Date: 2006-12-14 01:26:45 -0500 (Thu, 14 Dec 2006)
New Revision: 1788

Modified:
   trunk/src/main/org/jboss/jms/client/container/HAAspect.java
   trunk/src/main/org/jboss/jms/client/container/StateCreationAspect.java
   trunk/src/main/org/jboss/jms/client/delegate/DelegateSupport.java
   trunk/src/main/org/jboss/jms/server/endpoint/CreateConnectionResult.java
   trunk/src/main/org/jboss/messaging/core/plugin/IdBlock.java
Log:
Fixed StateCreationAspect to prevent double initialization of the ClientConnectionDelegate for the clustered case.


Modified: trunk/src/main/org/jboss/jms/client/container/HAAspect.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/container/HAAspect.java	2006-12-14 06:09:44 UTC (rev 1787)
+++ trunk/src/main/org/jboss/jms/client/container/HAAspect.java	2006-12-14 06:26:45 UTC (rev 1788)
@@ -282,7 +282,7 @@
 
          // Did not get a valid connection to the node we've just tried
 
-         int actualServerID = r.getActualFailoverNode();
+         int actualServerID = r.getActualFailoverNodeID();
 
          if (actualServerID == -1)
          {

Modified: trunk/src/main/org/jboss/jms/client/container/StateCreationAspect.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/container/StateCreationAspect.java	2006-12-14 06:09:44 UTC (rev 1787)
+++ trunk/src/main/org/jboss/jms/client/container/StateCreationAspect.java	2006-12-14 06:26:45 UTC (rev 1788)
@@ -86,12 +86,14 @@
 
       CreateConnectionResult res = (CreateConnectionResult)inv.invokeNext();
 
-      if(trace) { log.trace("got " + res + " on return"); }
-
       ClientConnectionDelegate connectionDelegate = (ClientConnectionDelegate)res.getDelegate();
 
-      if (connectionDelegate != null)
+      if (connectionDelegate != null && connectionDelegate.getState() == null)
       {
+         // no state set yet, initialize and configure it
+
+         if(trace) { log.trace(connectionDelegate + " not configured, configuring ..."); }
+
          connectionDelegate.init();
 
          int serverID = connectionDelegate.getServerID();
@@ -110,6 +112,10 @@
             new ConnectionState(serverID, connectionDelegate, remotingConn, versionToUse, g);
 
          connectionDelegate.setState(connectionState);
+
+         // the delegate is completely configured now; will use this state to avoid redundant
+         // configuration on a double pass through StateCreationAspect, which happens for clustered
+         // connections
       }
 
       return res;

Modified: trunk/src/main/org/jboss/jms/client/delegate/DelegateSupport.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/delegate/DelegateSupport.java	2006-12-14 06:09:44 UTC (rev 1787)
+++ trunk/src/main/org/jboss/jms/client/delegate/DelegateSupport.java	2006-12-14 06:26:45 UTC (rev 1788)
@@ -34,7 +34,6 @@
 import org.jboss.jms.server.remoting.MessagingMarshallable;
 import org.jboss.logging.Logger;
 import org.jboss.remoting.Client;
-import org.jboss.remoting.serialization.SerializationStreamFactory;
 
 /**
  * Base class for all client-side delegate classes.
@@ -67,27 +66,28 @@
 
    // Attributes ----------------------------------------------------
 
-   //This is set on the server
+   // This is set on the server.
    protected int id;
 
-   //This is set on the client
-   //The reason we don't use the meta-data to store the state for the delegate is to avoid
-   //the extra HashMap lookup that would entail.
-   //This can be significant since the state could be queried for many aspects
-   //in an a single invocation
+   // This is set on the client.
+   // The reason we don't use the meta-data to store the state for the delegate is to avoid the
+   // extra HashMap lookup that would entail. This can be significant since the state could be
+   // queried for many aspects in an a single invocation.
    protected transient HierarchicalState state;
 
    // Static --------------------------------------------------------
 
    // Constructors --------------------------------------------------
 
-   public DelegateSupport(int objectID)
+   public DelegateSupport(int id)
    {
-      this.id = objectID;
+      this.id = id;
+      this.state = null;
    }
 
    public DelegateSupport()
    {
+      this(Integer.MIN_VALUE);
    }
 
    // Interceptor implementation ------------------------------------
@@ -142,20 +142,20 @@
       checkMarshallers();
    }
 
-    public int getID()
-    {
-       return id;
-    }
+   public int getID()
+   {
+      return id;
+   }
 
-    /**
-     * During HA events, a new object is created on the new server and the state on that new object
-     * has to be transfered to this actual object. For example, a Connection will have to assume the
-     * ObjectID of the new connection endpoint and the new RemotingConnection.
-     */
-    public void copyAttributes(DelegateSupport newDelegate)
-    {
-        id = newDelegate.getID();
-    }
+   /**
+    * During HA events, a new object is created on the new server and the state on that new object
+    * has to be transfered to this actual object. For example, a Connection will have to assume the
+    * ObjectID of the new connection endpoint and the new RemotingConnection.
+    */
+   public void copyAttributes(DelegateSupport newDelegate)
+   {
+      id = newDelegate.getID();
+   }
 
    // Package protected ---------------------------------------------
 

Modified: trunk/src/main/org/jboss/jms/server/endpoint/CreateConnectionResult.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/CreateConnectionResult.java	2006-12-14 06:09:44 UTC (rev 1787)
+++ trunk/src/main/org/jboss/jms/server/endpoint/CreateConnectionResult.java	2006-12-14 06:26:45 UTC (rev 1788)
@@ -37,30 +37,60 @@
  */
 public class CreateConnectionResult implements Serializable
 {
+   // Constants -----------------------------------------------------
+
    private static final long serialVersionUID = 4311863642735135167L;
-   
+
+   // Static --------------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
    private ConnectionDelegate delegate;
-   
-   private int actualFailoverNodeId;
-   
-   public CreateConnectionResult(ConnectionDelegate del)
+
+   private int actualFailoverNodeID;
+
+   // Constructors --------------------------------------------------
+
+   public CreateConnectionResult(ConnectionDelegate delegate)
    {
-      this.delegate = del;
+      this(delegate, Integer.MIN_VALUE);
    }
-   
-   public CreateConnectionResult(int actualFailoverNode)
+
+   public CreateConnectionResult(int actualFailoverNodeID)
    {
-      this.actualFailoverNodeId = actualFailoverNode;
+      this(null, actualFailoverNodeID);
    }
-   
+
+   private CreateConnectionResult(ConnectionDelegate delegate,
+                                  int actualFailoverNodeId)
+   {
+      this.delegate = delegate;
+      this.actualFailoverNodeID = actualFailoverNodeId;
+   }
+
+   // Public --------------------------------------------------------
+
    public ConnectionDelegate getDelegate()
    {
       return delegate;
    }
-   
-   public int getActualFailoverNode()
+
+   public int getActualFailoverNodeID()
    {
-      return actualFailoverNodeId;
+      return actualFailoverNodeID;
    }
 
+   public String toString()
+   {
+      return "CreateConnectionResult[" + delegate + ", failover node " + actualFailoverNodeID + "]";
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+
 }

Modified: trunk/src/main/org/jboss/messaging/core/plugin/IdBlock.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/plugin/IdBlock.java	2006-12-14 06:09:44 UTC (rev 1787)
+++ trunk/src/main/org/jboss/messaging/core/plugin/IdBlock.java	2006-12-14 06:26:45 UTC (rev 1788)
@@ -76,4 +76,9 @@
       out.writeLong(high);
    }
 
+   public String toString()
+   {
+      return "IdBlock[" + low + "-" + high + "]";
+   }
+
 }




More information about the jboss-cvs-commits mailing list