[jboss-cvs] JBoss Messaging SVN: r1929 - in trunk: src/main/org/jboss/jms/client/container and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Jan 9 12:37:12 EST 2007


Author: clebert.suconic at jboss.com
Date: 2007-01-09 12:37:07 -0500 (Tue, 09 Jan 2007)
New Revision: 1929

Modified:
   trunk/src/main/org/jboss/jms/client/FailoverCommandCenter.java
   trunk/src/main/org/jboss/jms/client/FailoverValve.java
   trunk/src/main/org/jboss/jms/client/container/ClusteringAspect.java
   trunk/src/main/org/jboss/jms/client/container/ConnectionFailureListener.java
   trunk/src/main/org/jboss/jms/client/container/FailoverValveInterceptor.java
   trunk/src/main/org/jboss/jms/client/state/ConnectionState.java
   trunk/tests/src/org/jboss/test/messaging/jms/crash/CreateTwoClientOnServerCommand.java
Log:
minor tweaks...

Modified: trunk/src/main/org/jboss/jms/client/FailoverCommandCenter.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/FailoverCommandCenter.java	2007-01-09 11:36:35 UTC (rev 1928)
+++ trunk/src/main/org/jboss/jms/client/FailoverCommandCenter.java	2007-01-09 17:37:07 UTC (rev 1929)
@@ -76,15 +76,13 @@
 
          valve.close();
 
-         if (remotingConnection != null)
+         if (remotingConnection.isFailed())
          {
-            if (remotingConnection.isFailed())
-            {
-               log.debug(this + " ignoring failure detection notification, as failover was " +
-                  "already performed on this connection");
-            }
-            remotingConnection.setFailed(true);
+            log.debug(this + " ignoring failure detection notification, as failover was " +
+               "already performed on this connection");
+            return;
          }
+         remotingConnection.setFailed(true);
 
          // generate a FAILOVER_STARTED event. The event must be broadcasted AFTER valve closure,
          // to insure the client-side stack is in a deterministic state
@@ -115,16 +113,23 @@
       }
       finally
       {
-         if (failoverSuccessful)
+         // I have this secondary try..finally block, just because if broadcastFailoverEvent throws any exceptions
+         // I don't want a dead lock on everybody waiting the valve to be opened.
+         try
          {
-            broadcastFailoverEvent(new FailoverEvent(FailoverEvent.FAILOVER_COMPLETED, this));
+            if (failoverSuccessful)
+            {
+               broadcastFailoverEvent(new FailoverEvent(FailoverEvent.FAILOVER_COMPLETED, this));
+            }
+            else
+            {
+               broadcastFailoverEvent(new FailoverEvent(FailoverEvent.FAILOVER_FAILED, this));
+            }
          }
-         else
+         finally
          {
-            broadcastFailoverEvent(new FailoverEvent(FailoverEvent.FAILOVER_FAILED, this));
+            valve.open();
          }
-
-         valve.open();
       }
    }
 


Property changes on: trunk/src/main/org/jboss/jms/client/FailoverCommandCenter.java
___________________________________________________________________
Name: svn:keywords
   + Id LastChangedDate Author Revision


Property changes on: trunk/src/main/org/jboss/jms/client/FailoverValve.java
___________________________________________________________________
Name: svn:keywords
   + Id LastChangedDate Author Revision

Modified: trunk/src/main/org/jboss/jms/client/container/ClusteringAspect.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/container/ClusteringAspect.java	2007-01-09 11:36:35 UTC (rev 1928)
+++ trunk/src/main/org/jboss/jms/client/container/ClusteringAspect.java	2007-01-09 17:37:07 UTC (rev 1929)
@@ -127,8 +127,10 @@
             // add a connection listener to detect failure; the consolidated remoting connection
             // listener must be already in place and configured
             state.getRemotingConnection().getConnectionListener().
-               addDelegateListener(new ConnectionFailureListener(fcc));
+               addDelegateListener(new ConnectionFailureListener(fcc, state.getRemotingConnection()));
 
+            state.configureFailoverCommandCenter();
+
             log.debug(this + " installed failure listener on " + cd);
 
             // also cache the username and the password into state, useful in case

Modified: trunk/src/main/org/jboss/jms/client/container/ConnectionFailureListener.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/container/ConnectionFailureListener.java	2007-01-09 11:36:35 UTC (rev 1928)
+++ trunk/src/main/org/jboss/jms/client/container/ConnectionFailureListener.java	2007-01-09 17:37:07 UTC (rev 1929)
@@ -12,6 +12,7 @@
 import org.jboss.jms.client.delegate.ClientConnectionDelegate;
 import org.jboss.jms.client.FailoverEvent;
 import org.jboss.jms.client.FailoverCommandCenter;
+import org.jboss.jms.client.remoting.JMSRemotingConnection;
 import org.jboss.jms.client.state.ConnectionState;
 
 /**
@@ -35,11 +36,16 @@
 
    private FailoverCommandCenter fcc;
 
-   // Constructors ---------------------------------------------------------------------------------
+   // The remotingConnection is needed here to validate that the failure wasn't captured after failover
+   // was already called
+   private JMSRemotingConnection remotingConnection;
 
-   ConnectionFailureListener(FailoverCommandCenter fcc)
+      // Constructors ---------------------------------------------------------------------------------
+
+   ConnectionFailureListener(FailoverCommandCenter fcc, JMSRemotingConnection remotingConnection)
    {
       this.fcc = fcc;
+      this.remotingConnection = remotingConnection;
    }
 
    // ConnectionListener implementation ------------------------------------------------------------
@@ -50,7 +56,7 @@
       {
          log.debug(this + " is being notified of connection failure: " + throwable);
 
-         fcc.failureDetected(throwable, null);
+         fcc.failureDetected(throwable, remotingConnection);
 
       }
       catch (Throwable e)

Modified: trunk/src/main/org/jboss/jms/client/container/FailoverValveInterceptor.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/container/FailoverValveInterceptor.java	2007-01-09 11:36:35 UTC (rev 1928)
+++ trunk/src/main/org/jboss/jms/client/container/FailoverValveInterceptor.java	2007-01-09 17:37:07 UTC (rev 1929)
@@ -32,6 +32,7 @@
  * and queue browser delegate.
  *
  * @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>
  * $Id$
  */
@@ -44,6 +45,9 @@
    // Attributes -----------------------------------------------------------------------------------
 
    private DelegateSupport delegate;
+
+   // We need to cache connectionState here, as fcc could be null for nonClusteredConnections
+   private ConnectionState connectionState;
    private FailoverCommandCenter fcc;
    private FailoverValve valve;
 
@@ -58,9 +62,11 @@
 
    public Object invoke(Invocation invocation) throws Throwable
    {
-      // maintain a reference to the FailoverCommandCenter instance.
 
-      if (fcc == null)
+      // maintain a reference to connectionState, so we can ensure we have already
+      // tested for fcc.
+      // As fcc can be null on nonClusteredConnections we have to cache connectionState instead
+      if (connectionState == null)
       {
          delegate = (DelegateSupport)invocation.getTargetObject();
 
@@ -69,20 +75,28 @@
          {
             hs = hs.getParent();
          }
+         
+         connectionState = (ConnectionState)hs;
 
-         fcc = ((ConnectionState)hs).getFailoverCommandCenter();
+         // maintain a reference to the FailoverCommandCenter instance.
+         fcc = connectionState.getFailoverCommandCenter();
          valve = fcc.getValve();
       }
 
+      // non clustered.. noop
+      if (fcc==null)
+      {
+         return invocation.invokeNext();
+      }
+
       JMSRemotingConnection remotingConnection = null;
 
       try
       {
          valve.enter();
 
-         // it's important to retrieve the remotingConnection while inside the Valve, as there's
+         // it's important to retrieve the remotingConnection while inside the Valve, as there's no
          // guaranteed that no failover has happened yet
-         // guarantee that no failover has happened yet
          remotingConnection = fcc.getRemotingConnection();
          return invocation.invokeNext();
       }

Modified: trunk/src/main/org/jboss/jms/client/state/ConnectionState.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/state/ConnectionState.java	2007-01-09 11:36:35 UTC (rev 1928)
+++ trunk/src/main/org/jboss/jms/client/state/ConnectionState.java	2007-01-09 17:37:07 UTC (rev 1929)
@@ -115,8 +115,6 @@
 
       this.idGenerator = gen;
       this.serverID = serverID;
-
-      fcc = new FailoverCommandCenter(this);
    }
 
    // HierarchicalState implementation -------------------------------------------------------------
@@ -260,6 +258,13 @@
       return fcc;
    }
 
+
+   /** Creates the FailoverCommandCenter as this is a clustered Connection*/
+   public void configureFailoverCommandCenter()
+   {
+      this.fcc = new FailoverCommandCenter(this);
+   }
+
    public String toString()
    {
       return "ConnectionState[" + ((ClientConnectionDelegate)delegate).getID() + "]";

Modified: trunk/tests/src/org/jboss/test/messaging/jms/crash/CreateTwoClientOnServerCommand.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/crash/CreateTwoClientOnServerCommand.java	2007-01-09 11:36:35 UTC (rev 1928)
+++ trunk/tests/src/org/jboss/test/messaging/jms/crash/CreateTwoClientOnServerCommand.java	2007-01-09 17:37:07 UTC (rev 1929)
@@ -38,7 +38,7 @@
  * 
  * @author <a href="tim.fox at jboss.com">Tim Fox</a>
  * @author <a href="clebert.suconic at jboss.com">Clebert Suconic</a>
- * @version 1.1
+ * @version <tt>$Revision$</tt>
  *
  * $Id$
  */




More information about the jboss-cvs-commits mailing list