[jboss-cvs] jboss-ejb3/src/main/org/jboss/ejb3/cache/tree ...
Ben Wang
bwang at jboss.com
Tue Jul 25 12:46:12 EDT 2006
User: bwang
Date: 06/07/25 12:46:12
Modified: src/main/org/jboss/ejb3/cache/tree StatefulTreeCache.java
Log:
Ported fixes from 4.0
Revision Changes Path
1.17 +28 -28 jboss-ejb3/src/main/org/jboss/ejb3/cache/tree/StatefulTreeCache.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: StatefulTreeCache.java
===================================================================
RCS file: /cvsroot/jboss/jboss-ejb3/src/main/org/jboss/ejb3/cache/tree/StatefulTreeCache.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- StatefulTreeCache.java 17 May 2006 14:42:32 -0000 1.16
+++ StatefulTreeCache.java 25 Jul 2006 16:46:12 -0000 1.17
@@ -28,7 +28,6 @@
import org.jboss.aop.Advisor;
import org.jboss.cache.xml.XmlHelper;
-import org.jboss.cache.eviction.LRUConfiguration;
import org.jboss.cache.eviction.RegionManager;
import org.jboss.cache.eviction.Region;
import org.jboss.cache.CacheException;
@@ -53,7 +52,7 @@
* Comment
*
* @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision: 1.16 $
+ * @version $Revision: 1.17 $
*/
public class StatefulTreeCache implements ClusteredStatefulCache
{
@@ -64,6 +63,8 @@
private TreeCache cache;
private Fqn cacheNode;
private ClusteredStatefulCacheListener listener;
+ private RegionManager evictRegionManager;
+ public static long MarkInUseWaitTime = 15000;
public StatefulBeanContext create()
{
@@ -92,7 +93,8 @@
try
{
ctx = (StatefulBeanContext) pool.get(initTypes, initValues);
- cache.put(cacheNode + "/" + ctx.getId(), "bean", ctx);
+ Fqn id = Fqn.fromString(cacheNode + "/" + ctx.getId());
+ cache.put(id, "bean", ctx);
ctx.inUse = true;
ctx.lastUsed = System.currentTimeMillis();
}
@@ -110,9 +112,10 @@
public StatefulBeanContext get(Object key) throws EJBException
{
StatefulBeanContext entry = null;
+ Fqn id = Fqn.fromString(cacheNode + "/" +key);
try
{
- Object obj = cache.get(cacheNode + "/" + key, "bean");
+ Object obj = cache.get(id, "bean");
entry = (StatefulBeanContext) obj;
}
catch (CacheException e)
@@ -124,6 +127,13 @@
throw new EJBNoSuchObjectException("Could not find Stateful bean: " + key);
}
entry.inUse = true;
+ // Mark it to eviction thread that don't passivate it yet.
+ evictRegionManager.markNodeCurrentlyInUse(id, MarkInUseWaitTime);
+ if(log.isDebugEnabled())
+ {
+ log.debug("get: retrieved bean with cache id " +id.toString());
+ }
+
entry.lastUsed = System.currentTimeMillis();
return entry;
}
@@ -131,15 +141,20 @@
public void remove(Object key)
{
StatefulBeanContext ctx = null;
+ Fqn id = Fqn.fromString(cacheNode + "/" +key);
try
{
- cache.remove(cacheNode + "/" + key);
+ if(log.isDebugEnabled())
+ {
+ log.debug("remove: cache id " +id.toString());
+ }
+ cache.remove(id);
}
catch (CacheException e)
{
throw new RuntimeException(e);
}
- if (ctx != null) pool.remove(ctx);
+// if (ctx != null) pool.remove(ctx);
}
public void finished(StatefulBeanContext ctx)
@@ -148,22 +163,9 @@
{
ctx.inUse = false;
ctx.lastUsed = System.currentTimeMillis();
- // TODO I think we can getby without this now because even if it is passivated during inUse, we can
- // still retrieve it? But if we really need to do it, we could over-ride the evict method then.
- /*
- if (ctx.markedForPassivation)
- {
- try
- {
- Fqn fqn = Fqn.fromString(cacheNode + "/" + ctx.getId());
- eviction.passivate(fqn, ctx);
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- }
- */
+ Fqn id = Fqn.fromString(cacheNode + "/" + ctx.getId());
+ // OK, it is free to passivate now.
+ evictRegionManager.unmarkNodeCurrentlyInUse(id);
}
}
@@ -192,12 +194,10 @@
cacheNode = Fqn.fromString("/" + container.getEjbName() + "/");
// Try to create an eviction region per ejb
- RegionManager rm = cache.getEvictionRegionManager();
- Element element = getElementConfig(cacheNode.toString(), config.idleTimeoutSeconds(), config.maxSize());
- Region region = rm.createRegion(cacheNode, element);
- //TODO This is a workaround for a bug in createRegion(). Regions aren't active for eviction until this is called
- rm.getRegions();
-
+ evictRegionManager = cache.getEvictionRegionManager();
+ Element element = getElementConfig(cacheNode.toString(), config.idleTimeoutSeconds(),
+ config.maxSize());
+ Region region = evictRegionManager.createRegion(cacheNode, element);
log.debug("initialize(): create eviction region: " +region + " for ejb: " +container.getEjbName());
}
More information about the jboss-cvs-commits
mailing list