[jboss-cvs] JBossCache/src/org/jboss/cache/interceptors ...
Brian Stansberry
brian.stansberry at jboss.com
Sun Oct 29 23:40:57 EST 2006
User: bstansberry
Date: 06/10/29 23:40:57
Modified: src/org/jboss/cache/interceptors Tag:
Branch_JBossCache_1_4_0 PassivationInterceptor.java
Log:
[JBCACHE-825] Don't passivate if node is not in memory
Revision Changes Path
No revision
No revision
1.22.2.1 +42 -21 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.22
retrieving revision 1.22.2.1
diff -u -b -r1.22 -r1.22.2.1
--- PassivationInterceptor.java 6 Jun 2006 10:17:14 -0000 1.22
+++ PassivationInterceptor.java 30 Oct 2006 04:40:57 -0000 1.22.2.1
@@ -9,7 +9,6 @@
import org.jgroups.blocks.MethodCall;
import EDU.oswego.cs.dl.util.concurrent.SynchronizedLong;
-import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
@@ -18,7 +17,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.22 2006/06/06 10:17:14 msurtani Exp $
+ * @version $Id: PassivationInterceptor.java,v 1.22.2.1 2006/10/30 04:40:57 bstansberry Exp $
*/
public class PassivationInterceptor extends Interceptor implements PassivationInterceptorMBean {
@@ -40,31 +39,45 @@
* @throws Throwable
*/
public Object invoke(MethodCall call) throws Throwable {
- JBCMethodCall m = (JBCMethodCall) call;
- Fqn fqn;
- Object[] args=m.getArgs();
+ JBCMethodCall m = (JBCMethodCall) call;
- // 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
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.notifyNodePassivate(fqn, true);
loader.put(fqn, attributes);
}
if (statsEnabled && cache.getUseInterceptorMbeans())
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);
}
@@ -86,9 +99,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();
+
TreeNode n = cache.getRoot();
int size = fqn.size();
for(int i=0; i < size && n != null; i++) {
@@ -97,6 +112,12 @@
if (n != null)
return n.getData();
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