[jboss-cvs] JBossAS SVN: r67370 - branches/JBPAPP_4_2/ejb3/src/main/org/jboss/ejb3/cache/tree.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Nov 21 23:08:57 EST 2007


Author: bstansberry at jboss.com
Date: 2007-11-21 23:08:57 -0500 (Wed, 21 Nov 2007)
New Revision: 67370

Modified:
   branches/JBPAPP_4_2/ejb3/src/main/org/jboss/ejb3/cache/tree/StatefulTreeCache.java
Log:
[JBPAPP-295] Handle gravitation of data into inactive regions

Modified: branches/JBPAPP_4_2/ejb3/src/main/org/jboss/ejb3/cache/tree/StatefulTreeCache.java
===================================================================
--- branches/JBPAPP_4_2/ejb3/src/main/org/jboss/ejb3/cache/tree/StatefulTreeCache.java	2007-11-22 03:51:17 UTC (rev 67369)
+++ branches/JBPAPP_4_2/ejb3/src/main/org/jboss/ejb3/cache/tree/StatefulTreeCache.java	2007-11-22 04:08:57 UTC (rev 67370)
@@ -40,6 +40,7 @@
 import org.jboss.cache.CacheException;
 import org.jboss.cache.AbstractTreeCacheListener;
 import org.jboss.cache.DataNode;
+import org.jboss.cache.RegionNotEmptyException;
 import org.jboss.cache.TreeCache;
 import org.jboss.cache.TreeCacheMBean;
 import org.jboss.ejb3.Container;
@@ -319,7 +320,18 @@
       Region region = evictRegionManager.createRegion(cacheNode, element);
       
       cache.registerClassLoader(cacheNode.toString(), cl);
-      cache.activateRegion(cacheNode.toString());
+      try
+      {
+         cache.activateRegion(cacheNode.toString());
+      }
+      catch (RegionNotEmptyException e)
+      {
+         // this can happen with nested bean contexts if gravitation
+         // pulls a parent bean over after the parent region is stopped
+         // Clean up and try again
+         cleanBeanRegion();
+         cache.activateRegion(cacheNode.toString());
+      }
       
       log.debug("initialize(): create eviction region: " +region + " for ejb: " +this.ejbContainer.getEjbName());
    
@@ -359,17 +371,9 @@
       // Remove the listener
       cache.removeTreeCacheListener(listener);
 
-      try {
-         // Remove locally. We do this to clean up the persistent store,
-         // which is not affected by the inactivateRegion call below.
-         Option opt = new Option();
-      	 opt.setCacheModeLocal(true);
-         cache.remove(cacheNode, opt);
-      } 
-      catch (CacheException e) 
-      {
-         log.error("Stop(): can't remove bean from the underlying distributed cache");
-      }      
+      // Remove locally. We do this to clean up the persistent store,
+      // which is not affected by the inactivateRegion call below.
+      cleanBeanRegion();    
       
       try
       {
@@ -484,6 +488,20 @@
       return new Fqn(cacheNode, hashBuckets[index], beanId);
    }
    
+   private void cleanBeanRegion()
+   {
+      try {
+         // Remove locally.
+         Option opt = new Option();
+         opt.setCacheModeLocal(true);
+         cache.remove(cacheNode, opt);
+      } 
+      catch (CacheException e) 
+      {
+         log.error("Stop(): can't remove bean from the underlying distributed cache");
+      }       
+   }
+   
    /** 
     * Creates a RuntimeException, but doesn't pass CacheException as the cause
     * as it is a type that likely doesn't exist on a client.




More information about the jboss-cvs-commits mailing list