[jboss-cvs] JBossAS SVN: r61606 - trunk/ejb3/src/main/org/jboss/ejb3/cache/tree.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Mar 22 14:26:07 EDT 2007
Author: bstansberry at jboss.com
Date: 2007-03-22 14:26:06 -0400 (Thu, 22 Mar 2007)
New Revision: 61606
Modified:
trunk/ejb3/src/main/org/jboss/ejb3/cache/tree/StatefulTreeCache.java
Log:
[EJBTHREE-923] Avoid unnecessary passivation/activation callbacks for beans cached on remote nodes
Modified: trunk/ejb3/src/main/org/jboss/ejb3/cache/tree/StatefulTreeCache.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/cache/tree/StatefulTreeCache.java 2007-03-22 18:25:33 UTC (rev 61605)
+++ trunk/ejb3/src/main/org/jboss/ejb3/cache/tree/StatefulTreeCache.java 2007-03-22 18:26:06 UTC (rev 61606)
@@ -75,6 +75,7 @@
GRAVITATE_OPTION.setForceDataGravitation(true);
}
+ private ThreadLocal<Boolean> localActivity = new ThreadLocal<Boolean>();
private Logger log = Logger.getLogger(StatefulTreeCache.class);
private Pool pool;
private WeakReference<ClassLoader> classloader;
@@ -152,8 +153,10 @@
{
StatefulBeanContext entry = null;
Fqn id = new Fqn(cacheNode, key.toString());
+ Boolean active = localActivity.get();
try
{
+ localActivity.set(Boolean.TRUE);
// If need be, gravitate
InvocationContext ictx = cache.getInvocationContext();
ictx.setOptionOverrides(getGravitateOption());
@@ -164,6 +167,10 @@
RuntimeException re = convertToRuntimeException(e);
throw re;
}
+ finally
+ {
+ localActivity.set(active);
+ }
if (entry == null)
{
@@ -363,9 +370,18 @@
private void putInCache(StatefulBeanContext ctx)
{
- ctx.preReplicate();
- cache.put(new Fqn(cacheNode, ctx.getId().toString()), "bean", ctx);
- ctx.markedForReplication = false;
+ Boolean active = localActivity.get();
+ try
+ {
+ localActivity.set(Boolean.TRUE);
+ ctx.preReplicate();
+ cache.put(new Fqn(cacheNode, ctx.getId().toString()), "bean", ctx);
+ ctx.markedForReplication = false;
+ }
+ finally
+ {
+ localActivity.set(active);
+ }
}
/**
@@ -394,9 +410,19 @@
{
// Ignore everything but "post" events for nodes in our region
if(pre) return;
+ if (nodeData == null) return;
if(fqn.size() != FQN_SIZE) return;
if(!fqn.isChildOrEquals(cacheNode)) return;
- if (nodeData == null) return;
+
+ // Don't activate a bean just so we can replace the object
+ // with a replicated one
+ if (Boolean.TRUE != localActivity.get())
+ {
+ // But we do want to record that the bean's now in memory
+ // FIXEME Bill D -- uncomment this when you port stats from 4.2
+ //--passivatedCount;
+ return;
+ }
StatefulBeanContext bean = (StatefulBeanContext) nodeData.get("bean");
@@ -438,8 +464,13 @@
StatefulBeanContext bean = null;
ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
+ Boolean active = localActivity.get();
try
{
+ localActivity.set(Boolean.TRUE);
+ // EJBTHREE-746 Bypass interceptors and thus avoid generating another
+ // eviction event (which will cause another attempt to passivate)
+ // Caller thread (eviction) already has a lock on the node
InvocationContext ctx = cache.getInvocationContext();
ctx.setOptionOverrides(getBypassOption());
bean = (StatefulBeanContext) cache.get(fqn, "bean");
@@ -506,6 +537,7 @@
finally
{
Thread.currentThread().setContextClassLoader(oldCl);
+ localActivity.set(active);
}
}
}
More information about the jboss-cvs-commits
mailing list