[jboss-cvs] JBoss Messaging SVN: r1470 - in branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client: container delegate

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Oct 11 19:47:04 EDT 2006


Author: clebert.suconic at jboss.com
Date: 2006-10-11 19:47:02 -0400 (Wed, 11 Oct 2006)
New Revision: 1470

Modified:
   branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client/container/ConnectionAspect.java
   branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client/delegate/ClientConnectionDelegate.java
   branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client/delegate/DelegateSupport.java
Log:
http://jira.jboss.org/jira/browse/JBMESSAGING-519 - working with stateTransfer between new and old connection

Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client/container/ConnectionAspect.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client/container/ConnectionAspect.java	2006-10-11 19:48:23 UTC (rev 1469)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client/container/ConnectionAspect.java	2006-10-11 23:47:02 UTC (rev 1470)
@@ -32,6 +32,7 @@
 import org.jboss.jms.client.delegate.ClientConnectionDelegate;
 import org.jboss.jms.client.delegate.DelegateSupport;
 import org.jboss.jms.client.delegate.ClientSessionDelegate;
+import org.jboss.jms.client.delegate.ClientProducerDelegate;
 import org.jboss.jms.client.state.ConnectionState;
 import org.jboss.jms.client.state.SessionState;
 import org.jboss.jms.client.state.HierarchicalStateSupport;
@@ -53,7 +54,7 @@
  *
  * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @author <a href="mailto:clebert.suconic at jboss.com">Clebert Suconic (added client's HA)</a>
+ * @author <a href="mailto:clebert.suconic at jboss.com">Clebert Suconic</a>
  * @version <tt>$Revision$</tt>
  *
  * $Id$
@@ -228,10 +229,9 @@
             otherConnection.setClientID(currentState.getClientID());
         }
 
-        JMSRemotingConnection newRemoting = otherConnectionState.getRemotingConnection();
+        // Transfering state from newDelegate to currentDelegate
+        currentDelegate.transferHAState(otherConnection);
 
-        currentDelegate.setRemotingConnection(newRemoting);
-
         Iterator sessionsIterator = currentState.getChildren().iterator();
 
         while(sessionsIterator.hasNext())
@@ -240,11 +240,11 @@
 
             ClientSessionDelegate newSessionDelegate=(ClientSessionDelegate)otherConnection.createSessionDelegate(sessionState.isTransacted(),sessionState.getAcknowledgeMode(),sessionState.isXA());
 
-            // don't know if I will need that or not
             ClientSessionDelegate oldSessionDelegate = (ClientSessionDelegate)sessionState.getDelegate();
-            sessionState.setDelegate(newSessionDelegate);
 
+            newSessionDelegate.transferHAState(newSessionDelegate);
 
+
             if (log.isTraceEnabled())
             {
                 log.trace("Replacing session (" + oldSessionDelegate + ") by a new session created on the new failed over connection (" + newSessionDelegate + ")");
@@ -268,10 +268,11 @@
     }
 
     private void handleFailoverOnProducer(ProducerState producerState, ClientSessionDelegate newSessionDelegate, ClientSessionDelegate oldSessionDelegate) throws JMSException {
-        ProducerDelegate newProducerDelegate = newSessionDelegate.createProducerDelegate((JBossDestination)producerState.getDestination());
+        ClientProducerDelegate  newProducerDelegate = (ClientProducerDelegate)newSessionDelegate.createProducerDelegate((JBossDestination)producerState.getDestination());
         // don't know if I will need that or not
-        ProducerDelegate oldProducerDelegate = (ProducerDelegate)producerState.getDelegate();
-        producerState.setDelegate((DelegateSupport)newProducerDelegate);
+        ClientProducerDelegate oldProducerDelegate = (ClientProducerDelegate)producerState.getDelegate();
+        oldProducerDelegate.transferHAState(newProducerDelegate);
+
         if (log.isTraceEnabled())
         {
             log.trace("Replacing producerDelegate on oldSession=" + oldSessionDelegate + " destination=" + producerState.getDestination());

Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client/delegate/ClientConnectionDelegate.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client/delegate/ClientConnectionDelegate.java	2006-10-11 19:48:23 UTC (rev 1469)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client/delegate/ClientConnectionDelegate.java	2006-10-11 23:47:02 UTC (rev 1470)
@@ -41,6 +41,7 @@
  *
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
  *
  * @version <tt>$Revision$</tt>
  *
@@ -239,8 +240,14 @@
       return ((ConnectionState)state).getRemotingConnection().getInvokingClient();
    }
 
-   // Package Private -----------------------------------------------
+    public void transferHAState(DelegateSupport copyFrom) {
+        super.transferHAState(copyFrom);
+        ClientConnectionDelegate other = (ClientConnectionDelegate)copyFrom;
+        this.setRemotingConnection(other.getRemotingConnection());
+    }
 
+    // Package Private -----------------------------------------------
+
    // Private -------------------------------------------------------
 
    // Inner Classes -------------------------------------------------

Modified: branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client/delegate/DelegateSupport.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client/delegate/DelegateSupport.java	2006-10-11 19:48:23 UTC (rev 1469)
+++ branches/Branch_Client_Failover_Experiment/src/main/org/jboss/jms/client/delegate/DelegateSupport.java	2006-10-11 23:47:02 UTC (rev 1470)
@@ -137,11 +137,19 @@
       checkMarshallers();
    }
 
-   public int getID()
-   {
-      return id;
-   }
+    public int getID()
+    {
+       return id;
+    }
 
+    /** During HA events, a new object on the new server is created and all the state on that new object
+     * has to be transfered to this actual object.
+     * For example, the newConnection will have to assume the new ObjectID and the new RemotingConnection. */
+    public void transferHAState(DelegateSupport copyFrom)
+    {
+        this.id=copyFrom.getID();
+    }
+
    // Package protected ---------------------------------------------
 
    // Protected -----------------------------------------------------




More information about the jboss-cvs-commits mailing list