[jbosscache-commits] JBoss Cache SVN: r7454 - in core/trunk/src: test/java/org/jboss/cache and 1 other directory.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Mon Jan 12 19:12:37 EST 2009


Author: mircea.markus
Date: 2009-01-12 19:12:37 -0500 (Mon, 12 Jan 2009)
New Revision: 7454

Modified:
   core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java
   core/trunk/src/test/java/org/jboss/cache/UnitTestCacheFactory.java
Log:
do not pass possible exceptions to jgroups as this might behave funny(this resulted in a dedlock when passing running tests in parallel on 10 threads)

Modified: core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java	2009-01-12 12:29:59 UTC (rev 7453)
+++ core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java	2009-01-13 00:12:37 UTC (rev 7454)
@@ -660,55 +660,63 @@
 
       public void viewAccepted(View newView)
       {
-         Vector<Address> newMembers = newView.getMembers();
-         if (log.isInfoEnabled()) log.info("Received new cluster view: " + newView);
-         synchronized (coordinatorLock)
+         try
          {
-            boolean needNotification = false;
-            if (newMembers != null)
+            Vector<Address> newMembers = newView.getMembers();
+            if (log.isInfoEnabled()) log.info("Received new cluster view: " + newView);
+            synchronized (coordinatorLock)
             {
-               if (members != null)
+               boolean needNotification = false;
+               if (newMembers != null)
                {
-                  // we had a membership list before this event.  Check to make sure we haven't lost any members,
-                  // and if so, determine what members have been removed
-                  // and roll back any tx and break any locks
-                  List<Address> removed = new ArrayList<Address>(members);
-                  removed.removeAll(newMembers);
-                  spi.getInvocationContext().getOptionOverrides().setSkipCacheStatusCheck(true);
-                  NodeSPI root = spi.getRoot();
-                  if (root != null)
+                  if (members != null)
                   {
-                     // UGH!!!  What a shameless hack!
-                     if (configuration.getNodeLockingScheme() == NodeLockingScheme.MVCC)
+                     // we had a membership list before this event.  Check to make sure we haven't lost any members,
+                     // and if so, determine what members have been removed
+                     // and roll back any tx and break any locks
+                     List<Address> removed = new ArrayList<Address>(members);
+                     removed.removeAll(newMembers);
+                     spi.getInvocationContext().getOptionOverrides().setSkipCacheStatusCheck(true);
+                     NodeSPI root = spi.getRoot();
+                     if (root != null)
                      {
+                        // UGH!!!  What a shameless hack!
+                        if (configuration.getNodeLockingScheme() == NodeLockingScheme.MVCC)
+                        {
 
-                        removeLocksForDeadMembers(root.getDelegationTarget(), removed);
+                           removeLocksForDeadMembers(root.getDelegationTarget(), removed);
+                        }
+                        else
+                        {
+                           removeLocksForDeadMembers(root, removed);
+                        }
                      }
-                     else
-                     {
-                        removeLocksForDeadMembers(root, removed);
-                     }
                   }
+
+                  members = new ArrayList<Address>(newMembers); // defensive copy.
+
+                  needNotification = true;
                }
 
-               members = new ArrayList<Address>(newMembers); // defensive copy.
+               // Now that we have a view, figure out if we are the coordinator
+               coordinator = (members != null && members.size() != 0 && members.get(0).equals(getLocalAddress()));
 
-               needNotification = true;
-            }
+               // now notify listeners - *after* updating the coordinator. - JBCACHE-662
+               if (needNotification && notifier != null)
+               {
+                  InvocationContext ctx = spi.getInvocationContext();
+                  notifier.notifyViewChange(newView, ctx);
+               }
 
-            // Now that we have a view, figure out if we are the coordinator
-            coordinator = (members != null && members.size() != 0 && members.get(0).equals(getLocalAddress()));
-
-            // now notify listeners - *after* updating the coordinator. - JBCACHE-662
-            if (needNotification && notifier != null)
-            {
-               InvocationContext ctx = spi.getInvocationContext();
-               notifier.notifyViewChange(newView, ctx);
+               // Wake up any threads that are waiting to know about who the coordinator is
+               coordinatorLock.notifyAll();
             }
-
-            // Wake up any threads that are waiting to know about who the coordinator is
-            coordinatorLock.notifyAll();
          }
+         catch (Throwable e)
+         {
+            //do not rethrow! jgroups might behave funny, resulting even in deadlock
+            log.error("Error found while processing view accepted!!!", e);            
+         }
       }
 
       /**
@@ -723,12 +731,20 @@
        */
       public void block()
       {
-         flushBlockGate.close();
-         if (log.isDebugEnabled()) log.debug("Block received at " + getLocalAddress());
-         notifier.notifyCacheBlocked(true);
-         notifier.notifyCacheBlocked(false);
+         try
+         {
+            flushBlockGate.close();
+            if (log.isDebugEnabled()) log.debug("Block received at " + getLocalAddress());
+            notifier.notifyCacheBlocked(true);
+            notifier.notifyCacheBlocked(false);
 
-         if (log.isDebugEnabled()) log.debug("Block processed at " + getLocalAddress());
+            if (log.isDebugEnabled()) log.debug("Block processed at " + getLocalAddress());
+         }
+         catch (Throwable e)
+         {
+            //do not rethrow! jgroups might behave funny, resulting even in deadlock
+            log.error("Error found while processing block()", e);
+         }
       }
 
       /**
@@ -736,13 +752,21 @@
        */
       public void unblock()
       {
-         if (log.isDebugEnabled()) log.debug("UnBlock received at " + getLocalAddress());
+         try
+         {
+            if (log.isDebugEnabled()) log.debug("UnBlock received at " + getLocalAddress());
 
-         notifier.notifyCacheUnblocked(true);
-         notifier.notifyCacheUnblocked(false);
+            notifier.notifyCacheUnblocked(true);
+            notifier.notifyCacheUnblocked(false);
 
-         if (log.isDebugEnabled()) log.debug("UnBlock processed at " + getLocalAddress());
-         flushBlockGate.open();
+            if (log.isDebugEnabled()) log.debug("UnBlock processed at " + getLocalAddress());
+            flushBlockGate.open();
+         }
+         catch (Throwable e)
+         {
+            //do not rethrow! jgroups might behave funny, resulting even in deadlock
+            log.error("Error found while processing unblock", e);
+         }
       }
 
    }

Modified: core/trunk/src/test/java/org/jboss/cache/UnitTestCacheFactory.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/UnitTestCacheFactory.java	2009-01-12 12:29:59 UTC (rev 7453)
+++ core/trunk/src/test/java/org/jboss/cache/UnitTestCacheFactory.java	2009-01-13 00:12:37 UTC (rev 7454)
@@ -114,6 +114,13 @@
       return createCache(config, start, ownerClass);
    }
 
+   public Cache<K, V> createCache(Configuration.CacheMode mode, Class ownerClass) throws ConfigurationException
+   {
+      Configuration config = UnitTestConfigurationFactory.getEmptyConfiguration();
+      config.setCacheMode(mode);
+      return createCache(config, ownerClass);
+   }
+
    public Cache<K, V> createCache(String configFileName, Class ownerClass) throws ConfigurationException
    {
       return createCache(configFileName, true, ownerClass);




More information about the jbosscache-commits mailing list