[jboss-cvs] JBossAS SVN: r65637 - branches/Branch_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 Sep 26 17:15:15 EDT 2007
Author: bstansberry at jboss.com
Date: 2007-09-26 17:15:15 -0400 (Wed, 26 Sep 2007)
New Revision: 65637
Modified:
branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/cache/tree/StatefulTreeCache.java
Log:
Handle gravitation of data into inactive regions
Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/cache/tree/StatefulTreeCache.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/cache/tree/StatefulTreeCache.java 2007-09-26 20:40:32 UTC (rev 65636)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/cache/tree/StatefulTreeCache.java 2007-09-26 21:15:15 UTC (rev 65637)
@@ -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