[jboss-cvs] JBossCache/src/org/jboss/cache/interceptors ...
Brian Stansberry
brian.stansberry at jboss.com
Sun Oct 29 23:32:27 EST 2006
User: bstansberry
Date: 06/10/29 23:32:27
Modified: src/org/jboss/cache/interceptors
PassivationInterceptor.java
Log:
[JBCACHE-825] Don't passivate if node is not in memory
Revision Changes Path
1.30 +45 -24 JBossCache/src/org/jboss/cache/interceptors/PassivationInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: PassivationInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/PassivationInterceptor.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- PassivationInterceptor.java 25 Sep 2006 05:50:04 -0000 1.29
+++ PassivationInterceptor.java 30 Oct 2006 04:32:27 -0000 1.30
@@ -18,7 +18,7 @@
* CacheLoader, either before each method call (no TXs), or at TX commit.
*
* @author <a href="mailto:{hmesha at novell.com}">{Hany Mesha}</a>
- * @version $Id: PassivationInterceptor.java,v 1.29 2006/09/25 05:50:04 bwang Exp $
+ * @version $Id: PassivationInterceptor.java,v 1.30 2006/10/30 04:32:27 bstansberry Exp $
*/
public class PassivationInterceptor extends Interceptor implements PassivationInterceptorMBean
{
@@ -42,36 +42,51 @@
*/
public Object invoke(MethodCall m) throws Throwable
{
- Fqn fqn;
- Object[] args = m.getArgs();
-
- // could be potentially TRANSACTIONAL. If so, we register for TX completion (if we haven't done so yet)
// hmesha- We don't need to handle transaction during passivation since
// passivation happens local to a node and never replicated
- // evict() method need to be applied to the CacheLoader before passing up the call
+ // evict() method need to be applied to the CacheLoader before passing the call on
if (m.getMethodId() == MethodDeclarations.evictNodeMethodLocal_id)
{
- fqn = (Fqn) args[0];
- // evict method local doesn't hold attributes therefore we have to get them manually
+ Object[] args = m.getArgs();
+ Fqn fqn = (Fqn) args[0];
+ try
+ {
synchronized (this)
{
+ // evict method local doesn't hold attributes therefore we have
+ // to get them manually
Map attributes = getNodeAttributes(fqn);
+
// remove internal flag if node was never fully loaded
if (attributes != null)
{
attributes.remove(TreeCache.UNINITIALIZED);
}
- // notify listeners to the cache instance that this node is about to be passivated
+ // notify listeners that this node is about to be passivated
cache.getNotifier().notifyNodePassivated(fqn, true);
- cache.getNotifier().notifyNodePassivated(fqn, false);
+
loader.put(fqn, attributes);
+
+ // TODO -- should this be moved to after super.invoke()??
+ cache.getNotifier().notifyNodePassivated(fqn, false);
}
+
if (getStatisticsEnabled() && configuration.isUseMbean())
{
m_passivations.increment();
}
}
+ catch (NodeNotLoadedException e)
+ {
+ if (log.isTraceEnabled())
+ {
+ log.trace("Node " + fqn + " not loaded in memory; passivation skipped");
+ }
+ // TODO should we just return here and abort the rest of the
+ // interceptor chain? Probably a bad idea.
+ }
+ }
return super.invoke(m);
}
@@ -96,11 +111,11 @@
/**
* Returns attributes for a node.
*/
- private Map getNodeAttributes(Fqn fqn)
+ private Map getNodeAttributes(Fqn fqn) throws NodeNotLoadedException
{
if (fqn == null)
{
- return null;
+ throw new NodeNotLoadedException();
}
Node n = cache;
int size = fqn.size();
@@ -115,7 +130,13 @@
}
else
{
- return null;
+ throw new NodeNotLoadedException();
+ }
}
+
+ private static class NodeNotLoadedException extends Exception
+ {
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -4078972305344328905L;
}
}
More information about the jboss-cvs-commits
mailing list