[hornetq-commits] JBoss hornetq SVN: r9561 - branches/2_2_0_HA_Improvements/src/main/org/hornetq/core/client/impl.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed Aug 18 10:03:21 EDT 2010


Author: ataylor
Date: 2010-08-18 10:03:20 -0400 (Wed, 18 Aug 2010)
New Revision: 9561

Modified:
   branches/2_2_0_HA_Improvements/src/main/org/hornetq/core/client/impl/ClientSessionFactoryImpl.java
   branches/2_2_0_HA_Improvements/src/main/org/hornetq/core/client/impl/ClientSessionFactoryInternal.java
   branches/2_2_0_HA_Improvements/src/main/org/hornetq/core/client/impl/ClientSessionImpl.java
   branches/2_2_0_HA_Improvements/src/main/org/hornetq/core/client/impl/ClientSessionInternal.java
   branches/2_2_0_HA_Improvements/src/main/org/hornetq/core/client/impl/DelegatingSession.java
Log:
fixed deadlock during failover

Modified: branches/2_2_0_HA_Improvements/src/main/org/hornetq/core/client/impl/ClientSessionFactoryImpl.java
===================================================================
--- branches/2_2_0_HA_Improvements/src/main/org/hornetq/core/client/impl/ClientSessionFactoryImpl.java	2010-08-18 05:42:32 UTC (rev 9560)
+++ branches/2_2_0_HA_Improvements/src/main/org/hornetq/core/client/impl/ClientSessionFactoryImpl.java	2010-08-18 14:03:20 UTC (rev 9561)
@@ -100,11 +100,11 @@
 
    private final Object exitLock = new Object();
 
-   private final Object createSessionLock = new Object();
+   private final Object createSessionLock = new CreateSessionLock();
 
    private boolean inCreateSession;
 
-   private final Object failoverLock = new Object();
+   private final Object failoverLock = new FailoverLock();
 
    private final ExecutorFactory orderedExecutorFactory;
 
@@ -349,15 +349,22 @@
 
    // Must be synchronized to prevent it happening concurrently with failover which can lead to
    // inconsistencies
-   public void removeSession(final ClientSessionInternal session)
+   public void removeSession(final ClientSessionInternal session, boolean failingOver)
    {
-      synchronized (createSessionLock)
+      if (!failingOver)
       {
-         synchronized (failoverLock)
+         synchronized (createSessionLock)
          {
-            sessions.remove(session);
+            synchronized (failoverLock)
+            {
+               sessions.remove(session);
+            }
          }
       }
+      else
+      {
+         sessions.remove(session);
+      }
    }
 
    public synchronized int numConnections()
@@ -610,7 +617,7 @@
          {
             try
             {
-               session.cleanUp();
+               session.cleanUp(true);
             }
             catch (Exception e)
             {
@@ -1276,4 +1283,14 @@
          cancelled = true;
       }
    }
+
+   class CreateSessionLock
+   {
+
+   }
+
+   class FailoverLock
+   {
+
+   }
 }

Modified: branches/2_2_0_HA_Improvements/src/main/org/hornetq/core/client/impl/ClientSessionFactoryInternal.java
===================================================================
--- branches/2_2_0_HA_Improvements/src/main/org/hornetq/core/client/impl/ClientSessionFactoryInternal.java	2010-08-18 05:42:32 UTC (rev 9560)
+++ branches/2_2_0_HA_Improvements/src/main/org/hornetq/core/client/impl/ClientSessionFactoryInternal.java	2010-08-18 14:03:20 UTC (rev 9561)
@@ -35,6 +35,6 @@
 
    int numSessions();
    
-   void removeSession(final ClientSessionInternal session);
+   void removeSession(final ClientSessionInternal session, boolean failingOver);
    
 }

Modified: branches/2_2_0_HA_Improvements/src/main/org/hornetq/core/client/impl/ClientSessionImpl.java
===================================================================
--- branches/2_2_0_HA_Improvements/src/main/org/hornetq/core/client/impl/ClientSessionImpl.java	2010-08-18 05:42:32 UTC (rev 9560)
+++ branches/2_2_0_HA_Improvements/src/main/org/hornetq/core/client/impl/ClientSessionImpl.java	2010-08-18 14:03:20 UTC (rev 9561)
@@ -838,11 +838,16 @@
          ClientSessionImpl.log.trace("Failed to close session", e);
       }
 
-      doCleanup();
+      doCleanup(false);
    }
 
    public synchronized void cleanUp() throws Exception
    {
+      cleanUp(false);
+   }
+
+   public synchronized void cleanUp(boolean failingOver) throws Exception
+   {
       if (closed)
       {
          return;
@@ -852,7 +857,7 @@
 
       cleanUpChildren();
 
-      doCleanup();
+      doCleanup(failingOver);
    }
 
    public void setSendAcknowledgementHandler(final SendAcknowledgementHandler handler)
@@ -1661,7 +1666,7 @@
       }
    }
 
-   private void doCleanup()
+   private void doCleanup(boolean failingOver)
    {
       remotingConnection.removeFailureListener(this);
 
@@ -1672,7 +1677,7 @@
          channel.close();
       }
 
-      sessionFactory.removeSession(this);
+      sessionFactory.removeSession(this, failingOver);
    }
 
    private void cleanUpChildren() throws Exception

Modified: branches/2_2_0_HA_Improvements/src/main/org/hornetq/core/client/impl/ClientSessionInternal.java
===================================================================
--- branches/2_2_0_HA_Improvements/src/main/org/hornetq/core/client/impl/ClientSessionInternal.java	2010-08-18 05:42:32 UTC (rev 9560)
+++ branches/2_2_0_HA_Improvements/src/main/org/hornetq/core/client/impl/ClientSessionInternal.java	2010-08-18 14:03:20 UTC (rev 9561)
@@ -62,6 +62,8 @@
 
    void cleanUp() throws Exception;
 
+   void cleanUp(boolean failingOver) throws Exception;
+
    void returnBlocking();
 
    void setForceNotSameRM(boolean force);

Modified: branches/2_2_0_HA_Improvements/src/main/org/hornetq/core/client/impl/DelegatingSession.java
===================================================================
--- branches/2_2_0_HA_Improvements/src/main/org/hornetq/core/client/impl/DelegatingSession.java	2010-08-18 05:42:32 UTC (rev 9560)
+++ branches/2_2_0_HA_Improvements/src/main/org/hornetq/core/client/impl/DelegatingSession.java	2010-08-18 14:03:20 UTC (rev 9561)
@@ -139,6 +139,11 @@
       session.cleanUp();
    }
 
+   public void cleanUp(boolean failingOver) throws Exception
+   {
+      session.cleanUp(failingOver);
+   }
+
    public void close() throws HornetQException
    {
       closed = true;



More information about the hornetq-commits mailing list