[jboss-cvs] JBossCache/src/org/jboss/cache/interceptors ...
Manik Surtani
msurtani at jboss.com
Fri Aug 25 08:41:35 EDT 2006
User: msurtani
Date: 06/08/25 08:41:35
Modified: src/org/jboss/cache/interceptors
CallInterceptor.java
CreateIfNotExistsInterceptor.java
DataGravitatorInterceptor.java Interceptor.java
InvalidationInterceptor.java
OptimisticCreateIfNotExistsInterceptor.java
OptimisticNodeInterceptor.java
ReplicationInterceptor.java TxInterceptor.java
Log:
- "modernised" MethodDeclarations
- removed unnessary method maps in various interceptors, replaced with methods in MethodDeclarations
- some work on replacing JGroups MethodCall with JBCMethodCall
Revision Changes Path
1.14 +5 -17 JBossCache/src/org/jboss/cache/interceptors/CallInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: CallInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/CallInterceptor.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- CallInterceptor.java 18 Aug 2006 15:40:39 -0000 1.13
+++ CallInterceptor.java 25 Aug 2006 12:41:35 -0000 1.14
@@ -5,13 +5,10 @@
import org.jboss.cache.InvocationContext;
import org.jboss.cache.TreeCache;
import org.jboss.cache.config.Option;
+import org.jboss.cache.marshall.JBCMethodCall;
import org.jboss.cache.marshall.MethodDeclarations;
-import org.jgroups.blocks.MethodCall;
import javax.transaction.Transaction;
-import java.lang.reflect.Method;
-import java.util.HashSet;
-import java.util.Set;
/**
* Always at the end of the chain, directly in front of the cache. Simply calls into the cache using reflection.
@@ -22,20 +19,11 @@
* this interceptor unless it is a call the OptimisticNodeInterceptor knows nothing about.
*
* @author Bela Ban
- * @version $Id: CallInterceptor.java,v 1.13 2006/08/18 15:40:39 msurtani Exp $
+ * @version $Id: CallInterceptor.java,v 1.14 2006/08/25 12:41:35 msurtani Exp $
*/
public class CallInterceptor extends Interceptor
{
- private static Set<Method> transactionLifecycleMethods = new HashSet<Method>();
private TreeCache treeCache;
- static
- {
- transactionLifecycleMethods.add(MethodDeclarations.commitMethod);
- transactionLifecycleMethods.add(MethodDeclarations.rollbackMethod);
- transactionLifecycleMethods.add(MethodDeclarations.prepareMethod);
- transactionLifecycleMethods.add(MethodDeclarations.optimisticPrepareMethod);
- }
-
public void setCache(CacheSPI cache)
{
@@ -47,12 +35,12 @@
treeCache = c;
}
- public Object invoke(MethodCall m) throws Throwable
+ public Object invoke(JBCMethodCall m) throws Throwable
{
Object retval = null;
- if (!transactionLifecycleMethods.contains(m.getMethod()))
+ if (!MethodDeclarations.isTransactionLifecycleMethod(m.getMethodId()))
{
if (log.isTraceEnabled()) log.trace("Passing up method " + m + " so it gets invoked on cache.");
try
@@ -86,7 +74,7 @@
// in case a method has been invoked that the OptimisticNodeInterceptor knows nothing about, it will
// filter down here.
- if (!configuration.isNodeLockingOptimistic() && MethodDeclarations.isCrudMethod(m.getMethod()))
+ if (!configuration.isNodeLockingOptimistic() && MethodDeclarations.isCrudMethod(m.getMethodId()))
{
// if method is a CRUD (Create/Remove/Update/Delete) method: add it to the modification
// list, otherwise skip (e.g. get() is not added)
1.17 +8 -18 JBossCache/src/org/jboss/cache/interceptors/CreateIfNotExistsInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: CreateIfNotExistsInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/CreateIfNotExistsInterceptor.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- CreateIfNotExistsInterceptor.java 25 Aug 2006 11:59:02 -0000 1.16
+++ CreateIfNotExistsInterceptor.java 25 Aug 2006 12:41:35 -0000 1.17
@@ -1,22 +1,24 @@
package org.jboss.cache.interceptors;
import EDU.oswego.cs.dl.util.concurrent.ReentrantLock;
-import org.jboss.cache.*;
+import org.jboss.cache.CacheException;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.GlobalTransaction;
+import org.jboss.cache.Node;
+import org.jboss.cache.marshall.JBCMethodCall;
import org.jboss.cache.marshall.MethodCallFactory;
import org.jboss.cache.marshall.MethodDeclarations;
-import org.jboss.cache.marshall.JBCMethodCall;
import org.jgroups.blocks.MethodCall;
-import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Iterator;
-import java.util.List;
/**
* Handles putXXX() methods: if the given node doesn't exist, it will be created
* (depending on the create_if_not_exists argument)
* @author Bela Ban
- * @version $Id: CreateIfNotExistsInterceptor.java,v 1.16 2006/08/25 11:59:02 msurtani Exp $
+ * @version $Id: CreateIfNotExistsInterceptor.java,v 1.17 2006/08/25 12:41:35 msurtani Exp $
* @deprecated This code is not used anymore and will be removed in a future release
*/
public class CreateIfNotExistsInterceptor extends Interceptor {
@@ -25,20 +27,10 @@
private final ReentrantLock remove_lock=new ReentrantLock();
- static final List putMethods=new ArrayList(4);
-
- /** FQNs which are the target of put(). Remove() methods need to block until those FQNs have been
- * created and/or updated */
private final ArrayList put_list=new ArrayList();
private final ArrayList remove_list=new ArrayList();
- static {
- putMethods.add(MethodDeclarations.putDataEraseMethodLocal);
- putMethods.add(MethodDeclarations.putDataMethodLocal);
- putMethods.add(MethodDeclarations.putKeyValMethodLocal);
- }
-
public void setCache(CacheSPI cache) {
super.setCache(cache);
@@ -113,15 +105,13 @@
/**
* Synchronize between put(), remove() and evict() methods. This is coarse-grained, and should be replaced
* with FQN-based synchronization, e.g. put("/1/2/3" should <em>not</em> synchronize with remove("/a/b/c").
- * @param m
* @return
* @throws Throwable
*/
public Object invoke(MethodCall call) throws Throwable {
JBCMethodCall m = (JBCMethodCall) call;
- Method meth=m.getMethod();
Fqn fqn;
- boolean isPut=putMethods.contains(meth),
+ boolean isPut=MethodDeclarations.isPutMethod(m.getMethodId()),
isRemove=m.getMethodId() == MethodDeclarations.removeNodeMethodLocal_id,
isEvict=m.getMethodId() == MethodDeclarations.evictNodeMethodLocal_id;
1.22 +1 -1 JBossCache/src/org/jboss/cache/interceptors/DataGravitatorInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: DataGravitatorInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/DataGravitatorInterceptor.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- DataGravitatorInterceptor.java 18 Aug 2006 15:40:39 -0000 1.21
+++ DataGravitatorInterceptor.java 25 Aug 2006 12:41:35 -0000 1.22
@@ -74,7 +74,7 @@
if (log.isTraceEnabled()) log.trace("Invoked with method call " + m);
// Transactional lifecycle methods should be handled regardless of whether data gravitation is enabled or not.
- if (!isTransactionLifecycleMethod(m))
+ if (!MethodDeclarations.isTransactionLifecycleMethod(m.getMethodId()))
{
if (isGravitationEnabled(cache.getInvocationContext()))
{
1.21 +1 -19 JBossCache/src/org/jboss/cache/interceptors/Interceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Interceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/Interceptor.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- Interceptor.java 22 Aug 2006 12:27:51 -0000 1.20
+++ Interceptor.java 25 Aug 2006 12:41:35 -0000 1.21
@@ -39,7 +39,7 @@
* Class representing an interceptor.
* <em>Note that this will be replaced by {@link org.jboss.aop.advice.Interceptor} in one of the next releases</em>
* @author Bela Ban
- * @version $Id: Interceptor.java,v 1.20 2006/08/22 12:27:51 msurtani Exp $
+ * @version $Id: Interceptor.java,v 1.21 2006/08/25 12:41:35 msurtani Exp $
*/
public abstract class Interceptor implements InterceptorMBean {
protected Interceptor next=null, last = null;
@@ -158,22 +158,4 @@
return false;
}
}
-
- protected boolean isTransactionLifecycleMethod(JBCMethodCall mc)
- {
- int id = mc.getMethodId();
- return id == MethodDeclarations.commitMethod_id ||
- id == MethodDeclarations.rollbackMethod_id ||
- id == MethodDeclarations.prepareMethod_id ||
- id == MethodDeclarations.optimisticPrepareMethod_id;
- }
-
- protected boolean isBuddyGroupOrganisationMethod(JBCMethodCall mc)
- {
- int id = mc.getMethodId();
-
- return id == MethodDeclarations.remoteAnnounceBuddyPoolNameMethod_id ||
- id == MethodDeclarations.remoteAssignToBuddyGroupMethod_id ||
- id == MethodDeclarations.remoteRemoveFromBuddyGroupMethod_id;
- }
}
1.23 +6 -6 JBossCache/src/org/jboss/cache/interceptors/InvalidationInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: InvalidationInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/InvalidationInterceptor.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- InvalidationInterceptor.java 18 Aug 2006 15:40:39 -0000 1.22
+++ InvalidationInterceptor.java 25 Aug 2006 12:41:35 -0000 1.23
@@ -61,7 +61,7 @@
if (log.isTraceEnabled()) log.trace("(" + cache.getLocalAddress() + ") method call " + m );
// now see if this is a CRUD method:
- if (MethodDeclarations.isCrudMethod(meth))
+ if (MethodDeclarations.isCrudMethod(m.getMethodId()))
{
if (log.isDebugEnabled()) log.debug("Is a CRUD method");
Fqn fqn = findFqn( m.getArgs() );
@@ -91,7 +91,7 @@
GlobalTransaction gtx = ctx.getGlobalTransaction();
TransactionEntry entry = txTable.get(gtx);
if (entry == null) throw new IllegalStateException("cannot find transaction entry for " + gtx);
- List<MethodCall> modifications = new LinkedList<MethodCall>(entry.getModifications());
+ List<JBCMethodCall> modifications = new LinkedList<JBCMethodCall>(entry.getModifications());
if (modifications.size() > 0)
{
@@ -155,7 +155,7 @@
replicateCall(call, configuration.getCacheMode() == Configuration.CacheMode.INVALIDATION_SYNC);
}
- protected void invalidateModifications(List<MethodCall> modifications, TransactionWorkspace workspace) throws Throwable
+ protected void invalidateModifications(List<JBCMethodCall> modifications, TransactionWorkspace workspace) throws Throwable
{
// optimise the calls list here.
Set<Fqn> modifiedFqns = optimisedIterator(modifications);
@@ -181,12 +181,12 @@
* @param list
* @return Iterator containing a unique set of Fqns of crud methods in this tx
*/
- protected Set<Fqn> optimisedIterator(List<MethodCall> list)
+ protected Set<Fqn> optimisedIterator(List<JBCMethodCall> list)
{
Set<Fqn> fqns = new HashSet<Fqn>();
- for (MethodCall mc : list)
+ for (JBCMethodCall mc : list)
{
- if (MethodDeclarations.isCrudMethod(mc.getMethod()))
+ if (MethodDeclarations.isCrudMethod(mc.getMethodId()))
{
fqns.add(findFqn(mc.getArgs()));
}
1.26 +3 -12 JBossCache/src/org/jboss/cache/interceptors/OptimisticCreateIfNotExistsInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: OptimisticCreateIfNotExistsInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/OptimisticCreateIfNotExistsInterceptor.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- OptimisticCreateIfNotExistsInterceptor.java 24 Aug 2006 14:57:52 -0000 1.25
+++ OptimisticCreateIfNotExistsInterceptor.java 25 Aug 2006 12:41:35 -0000 1.26
@@ -8,11 +8,11 @@
import org.jboss.cache.*;
import org.jboss.cache.factories.NodeFactory;
+import org.jboss.cache.marshall.JBCMethodCall;
import org.jboss.cache.marshall.MethodDeclarations;
import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.optimistic.TransactionWorkspace;
import org.jboss.cache.optimistic.WorkspaceNode;
-import org.jgroups.blocks.MethodCall;
import java.util.ArrayList;
import java.util.Iterator;
@@ -26,20 +26,11 @@
*/
public class OptimisticCreateIfNotExistsInterceptor extends OptimisticInterceptor
{
- private static final List putMethods = new ArrayList(3);
-
- static
- {
- putMethods.add(MethodDeclarations.putDataEraseMethodLocal);
- putMethods.add(MethodDeclarations.putDataMethodLocal);
- putMethods.add(MethodDeclarations.putKeyValMethodLocal);
- }
-
- public Object invoke(MethodCall m) throws Throwable
+ public Object invoke(JBCMethodCall m) throws Throwable
{
//should this be just put methods
- if (putMethods.contains(m.getMethod()))
+ if (MethodDeclarations.isPutMethod(m.getMethodId()))
{
Object[] args = m.getArgs();
Fqn fqn = (Fqn) (args != null ? args[1] : null);
1.25 +10 -6 JBossCache/src/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: OptimisticNodeInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- OptimisticNodeInterceptor.java 18 Aug 2006 15:40:39 -0000 1.24
+++ OptimisticNodeInterceptor.java 25 Aug 2006 12:41:35 -0000 1.25
@@ -6,18 +6,23 @@
*/
package org.jboss.cache.interceptors;
-import org.jboss.cache.*;
+import org.jboss.cache.CacheException;
+import org.jboss.cache.DataNode;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.GlobalTransaction;
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.TreeCacheProxyImpl;
+import org.jboss.cache.TreeNode;
import org.jboss.cache.config.Option;
import org.jboss.cache.factories.NodeFactory;
-import org.jboss.cache.marshall.MethodDeclarations;
import org.jboss.cache.marshall.JBCMethodCall;
+import org.jboss.cache.marshall.MethodDeclarations;
+import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.optimistic.TransactionWorkspace;
import org.jboss.cache.optimistic.WorkspaceNode;
-import org.jboss.cache.optimistic.DataVersion;
import org.jgroups.blocks.MethodCall;
import javax.transaction.Transaction;
-import java.lang.reflect.Method;
import java.util.Iterator;
import java.util.Map;
import java.util.SortedMap;
@@ -35,7 +40,6 @@
JBCMethodCall m = (JBCMethodCall) call;
InvocationContext ctx = cache.getInvocationContext();
Transaction tx = ctx.getTransaction();
- Method meth = m.getMethod();
Object[] args = m.getArgs();
Object result = null;
@@ -44,7 +48,7 @@
TransactionWorkspace workspace = getTransactionWorkspace(gtx);
- if (MethodDeclarations.isCrudMethod(meth))
+ if (MethodDeclarations.isCrudMethod(m.getMethodId()))
{
if (tx == null || !isValid(tx))
{
1.37 +2 -2 JBossCache/src/org/jboss/cache/interceptors/ReplicationInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ReplicationInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/ReplicationInterceptor.java,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -b -r1.36 -r1.37
--- ReplicationInterceptor.java 25 Aug 2006 11:59:02 -0000 1.36
+++ ReplicationInterceptor.java 25 Aug 2006 12:41:35 -0000 1.37
@@ -16,7 +16,7 @@
* 'side-ways' (see docs/design/Refactoring.txt).
*
* @author Bela Ban
- * @version $Id: ReplicationInterceptor.java,v 1.36 2006/08/25 11:59:02 msurtani Exp $
+ * @version $Id: ReplicationInterceptor.java,v 1.37 2006/08/25 12:41:35 msurtani Exp $
*/
public class ReplicationInterceptor extends BaseRpcInterceptor
{
@@ -73,7 +73,7 @@
}
}
}
- else if (MethodDeclarations.isCrudMethod(method))
+ else if (MethodDeclarations.isCrudMethod(m.getMethodId()))
{
// NON-TRANSACTIONAL and CRUD method
if (log.isTraceEnabled()) log.trace("Non-tx crud meth");
1.56 +2 -2 JBossCache/src/org/jboss/cache/interceptors/TxInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: TxInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/TxInterceptor.java,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -b -r1.55 -r1.56
--- TxInterceptor.java 18 Aug 2006 15:40:39 -0000 1.55
+++ TxInterceptor.java 25 Aug 2006 12:41:35 -0000 1.56
@@ -81,7 +81,7 @@
log.trace("("+cache.getLocalAddress()+") call on method [" + m + "]");
}
// bypass for buddy group org metod calls.
- if (isBuddyGroupOrganisationMethod(m)) return super.invoke(m);
+ if (MethodDeclarations.isBuddyGroupOrganisationMethod(m.getMethodId())) return super.invoke(m);
InvocationContext ctx = cache.getInvocationContext();
@@ -108,7 +108,7 @@
// prepare/commit/rollback called by a remote cache, since calling
// such methods on TreeCache directly would fail.
- if (isTransactionLifecycleMethod(m))
+ if (MethodDeclarations.isTransactionLifecycleMethod(m.getMethodId()))
{
// this is a prepare, commit, or rollback.
// start by setting transactional details into InvocationContext.
More information about the jboss-cvs-commits
mailing list