[jboss-cvs] JBossCache/src/org/jboss/cache/interceptors ...
Manik Surtani
manik at jboss.org
Wed May 23 11:22:03 EDT 2007
User: msurtani
Date: 07/05/23 11:22:03
Modified: src/org/jboss/cache/interceptors
PassivationInterceptor.java
OptimisticReplicationInterceptor.java
OptimisticNodeInterceptor.java
CacheMgmtInterceptor.java
BaseTransactionalContextInterceptor.java
OptimisticValidatorInterceptor.java
InvocationContextInterceptor.java
CallInterceptor.java CacheLoaderInterceptor.java
EvictionInterceptor.java TxInterceptor.java
UnlockInterceptor.java
CreateIfNotExistsInterceptor.java
ReplicationInterceptor.java BaseRpcInterceptor.java
PessimisticLockInterceptor.java
OptimisticCreateIfNotExistsInterceptor.java
OptimisticLockingInterceptor.java
InvalidationInterceptor.java
OptimisticInterceptor.java
NotificationInterceptor.java Interceptor.java
ActivationInterceptor.java
CacheStoreInterceptor.java
DataGravitatorInterceptor.java
Log:
Performance enhancements, including a new invoke() signature for Interceptor
Revision Changes Path
1.41 +7 -5 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.40
retrieving revision 1.41
diff -u -b -r1.40 -r1.41
--- PassivationInterceptor.java 17 Jan 2007 16:24:06 -0000 1.40
+++ PassivationInterceptor.java 23 May 2007 15:22:03 -0000 1.41
@@ -2,6 +2,7 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.marshall.MethodCall;
@@ -16,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.40 2007/01/17 16:24:06 msurtani Exp $
+ * @version $Id: PassivationInterceptor.java,v 1.41 2007/05/23 15:22:03 msurtani Exp $
*/
public class PassivationInterceptor extends Interceptor implements PassivationInterceptorMBean
{
@@ -38,8 +39,9 @@
* @return
* @throws Throwable
*/
- public Object invoke(MethodCall m) throws Throwable
+ public Object invoke(InvocationContext ctx) throws Throwable
{
+ MethodCall m = ctx.getMethodCall();
// hmesha- We don't need to handle transaction during passivation since
// passivation happens local to a node and never replicated
@@ -56,11 +58,11 @@
// to get them manually
Map attributes = getNodeAttributes(fqn);
// notify listeners that this node is about to be passivated
- cache.getNotifier().notifyNodePassivated(fqn, true, true);
+ cache.getNotifier().notifyNodePassivated(fqn, true, ctx, true);
loader.put(fqn, attributes);
- cache.getNotifier().notifyNodePassivated(fqn, false, true);
+ cache.getNotifier().notifyNodePassivated(fqn, false, ctx, true);
}
if (getStatisticsEnabled() && configuration.getExposeManagementStatistics())
@@ -77,7 +79,7 @@
}
}
- return super.invoke(m);
+ return super.invoke(ctx);
}
public long getPassivations()
1.39 +11 -11 JBossCache/src/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: OptimisticReplicationInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -b -r1.38 -r1.39
--- OptimisticReplicationInterceptor.java 23 May 2007 10:28:50 -0000 1.38
+++ OptimisticReplicationInterceptor.java 23 May 2007 15:22:03 -0000 1.39
@@ -44,18 +44,18 @@
// we really just need a set here, but concurrent CopyOnWriteArraySet has poor performance when writing.
private final Set<GlobalTransaction> broadcastTxs = new ConcurrentHashSet<GlobalTransaction>();
- public Object invoke(MethodCall m) throws Throwable
+ public Object invoke(InvocationContext ctx) throws Throwable
{
+ MethodCall m = ctx.getMethodCall();
// bypass for buddy group org metod calls.
- if (MethodDeclarations.isBuddyGroupOrganisationMethod(m.getMethodId())) return super.invoke(m);
+ if (MethodDeclarations.isBuddyGroupOrganisationMethod(m.getMethodId())) return super.invoke(ctx);
- InvocationContext ctx = cache.getInvocationContext();
Option optionOverride = ctx.getOptionOverrides();
if (optionOverride != null && optionOverride.isCacheModeLocal() && ctx.getTransaction() == null)
{
// skip replication!!
log.debug("Skipping replication for this call as cache mode is local, forced via an option override.");
- return super.invoke(m);
+ return super.invoke(ctx);
}
Object retval;
@@ -70,7 +70,7 @@
{
case MethodDeclarations.optimisticPrepareMethod_id:
// pass up the chain.
- retval = super.invoke(m);
+ retval = super.invoke(ctx);
gtx = getGlobalTransaction(ctx);
if (!gtx.isRemote() && ctx.isOriginLocal())
@@ -97,7 +97,7 @@
}
}
- retval = super.invoke(m);
+ retval = super.invoke(ctx);
if (remoteCommitException != null)
{
throw remoteCommitException;
@@ -121,7 +121,7 @@
}
}
- retval = super.invoke(m);
+ retval = super.invoke(ctx);
if (remoteRollbackException != null)
{
throw remoteRollbackException;
@@ -134,7 +134,7 @@
default:
//it is something we do not care about
if (log.isTraceEnabled()) log.trace("Received method " + m + " not handling");
- retval = super.invoke(m);
+ retval = super.invoke(ctx);
break;
}
return retval;
1.64 +51 -50 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.63
retrieving revision 1.64
diff -u -b -r1.63 -r1.64
--- OptimisticNodeInterceptor.java 26 Apr 2007 12:14:58 -0000 1.63
+++ OptimisticNodeInterceptor.java 23 May 2007 15:22:03 -0000 1.64
@@ -51,16 +51,16 @@
notifier = cache.getNotifier();
}
- public Object invoke(MethodCall m) throws Throwable
+ public Object invoke(InvocationContext ctx) throws Throwable
{
- InvocationContext ctx = cache.getInvocationContext();
+ MethodCall m = ctx.getMethodCall();
Object[] args = m.getArgs();
Object result = null;
if (MethodDeclarations.isCrudMethod(m.getMethodId()))
{
- GlobalTransaction gtx = getGlobalTransaction();
+ GlobalTransaction gtx = getGlobalTransaction(ctx);
TransactionWorkspace workspace = getTransactionWorkspace(gtx);
Fqn fqn = getFqn(args, m.getMethodId());
WorkspaceNode workspaceNode = fetchWorkspaceNode(fqn, workspace, true);
@@ -107,58 +107,58 @@
{
case MethodDeclarations.moveMethodLocal_id:
Fqn parentFqn = (Fqn) args[1];
- moveNodeAndNotify(parentFqn, workspaceNode, workspace);
+ moveNodeAndNotify(parentFqn, workspaceNode, workspace, ctx);
break;
case MethodDeclarations.putDataMethodLocal_id:
- putDataMapAndNotify((Map<Object, Object>) args[2], false, workspace, workspaceNode);
+ putDataMapAndNotify((Map<Object, Object>) args[2], false, workspace, workspaceNode, ctx);
break;
case MethodDeclarations.putDataEraseMethodLocal_id:
- putDataMapAndNotify((Map<Object, Object>) args[2], (Boolean) args[args.length - 1], workspace, workspaceNode);
+ putDataMapAndNotify((Map<Object, Object>) args[2], (Boolean) args[args.length - 1], workspace, workspaceNode, ctx);
break;
case MethodDeclarations.putKeyValMethodLocal_id:
case MethodDeclarations.putForExternalReadMethodLocal_id:
Object key = args[2];
Object value = args[3];
- result = putDataKeyValueAndNotify(key, value, workspace, workspaceNode);
+ result = putDataKeyValueAndNotify(key, value, workspace, workspaceNode, ctx);
break;
case MethodDeclarations.removeNodeMethodLocal_id:
- result = removeNode(workspace, workspaceNode, true);
+ result = removeNode(workspace, workspaceNode, true, ctx);
break;
case MethodDeclarations.removeKeyMethodLocal_id:
Object removeKey = args[2];
- result = removeKeyAndNotify(removeKey, workspace, workspaceNode);
+ result = removeKeyAndNotify(removeKey, workspace, workspaceNode, ctx);
break;
case MethodDeclarations.removeDataMethodLocal_id:
- removeDataAndNotify(workspace, workspaceNode);
+ removeDataAndNotify(workspace, workspaceNode, ctx);
break;
case MethodDeclarations.dataGravitationCleanupMethod_id:
- result = super.invoke(m);
+ result = super.invoke(ctx);
default:
if (log.isWarnEnabled()) log.warn("Cannot handle CRUD method " + m);
break;
}
- addToModificationList(gtx, m);
+ addToModificationList(gtx, m, ctx);
}
else
{
switch (m.getMethodId())
{
case MethodDeclarations.getKeyValueMethodLocal_id:
- result = getValueForKeyAndNotify(args, getTransactionWorkspace(getGlobalTransaction()));
+ result = getValueForKeyAndNotify(args, getTransactionWorkspace(getGlobalTransaction(ctx)), ctx);
break;
case MethodDeclarations.getKeysMethodLocal_id:
- result = getKeysAndNotify(args, getTransactionWorkspace(getGlobalTransaction()));
+ result = getKeysAndNotify(args, getTransactionWorkspace(getGlobalTransaction(ctx)), ctx);
break;
case MethodDeclarations.getChildrenNamesMethodLocal_id:
- result = getChildNamesAndNotify(args, getTransactionWorkspace(getGlobalTransaction()));
+ result = getChildNamesAndNotify(args, getTransactionWorkspace(getGlobalTransaction(ctx)), ctx);
break;
case MethodDeclarations.getNodeMethodLocal_id:
- result = getNodeAndNotify(args, getTransactionWorkspace(getGlobalTransaction()));
+ result = getNodeAndNotify(args, getTransactionWorkspace(getGlobalTransaction(ctx)), ctx);
break;
default:
if (trace) log.trace("read Method " + m + " called - Not handling, passing on.");
- result = super.invoke(m);
+ result = super.invoke(ctx);
break;
}
}
@@ -193,9 +193,9 @@
* @param gtx transaction
* @param m methodcall to add
*/
- private void addToModificationList(GlobalTransaction gtx, MethodCall m)
+ private void addToModificationList(GlobalTransaction gtx, MethodCall m, InvocationContext ctx)
{
- Option opt = cache.getInvocationContext().getOptionOverrides();
+ Option opt = ctx.getOptionOverrides();
if (opt == null || !opt.isCacheModeLocal())
{
txTable.addModification(gtx, m);
@@ -218,8 +218,9 @@
* @param parentFqn parent under which the node is to be moved
* @param node node to move
* @param ws transaction workspace
+ * @param ctx
*/
- private void moveNodeAndNotify(Fqn parentFqn, WorkspaceNode node, TransactionWorkspace ws)
+ private void moveNodeAndNotify(Fqn parentFqn, WorkspaceNode node, TransactionWorkspace ws, InvocationContext ctx)
{
Fqn nodeFqn = node.getFqn();
if (nodeFqn.isRoot())
@@ -245,14 +246,14 @@
Fqn nodeNewFqn = new Fqn(parent.getFqn(), nodeFqn.getLastElement());
// pre-notify
- notifier.notifyNodeMoved(nodeFqn, nodeNewFqn, true, false);
+ notifier.notifyNodeMoved(nodeFqn, nodeNewFqn, true, ctx, false);
recursiveMoveNode(node, parent.getFqn(), ws);
// remove old nodes. this may mark some nodes which have already been moved as deleted
- removeNode(ws, node, false);
+ removeNode(ws, node, false, ctx);
// post-notify
- notifier.notifyNodeMoved(nodeFqn, nodeNewFqn, false, false);
+ notifier.notifyNodeMoved(nodeFqn, nodeNewFqn, false, ctx, false);
}
/**
@@ -276,38 +277,38 @@
}
}
- private void putDataMapAndNotify(Map<Object, Object> data, boolean eraseExisitng, TransactionWorkspace workspace, WorkspaceNode workspaceNode)
+ private void putDataMapAndNotify(Map<Object, Object> data, boolean eraseExisitng, TransactionWorkspace workspace, WorkspaceNode workspaceNode, InvocationContext ctx)
{
if (workspaceNode == null)
throw new NodeNotExistsException("optimisticCreateIfNotExistsInterceptor should have created this node!");
// pre-notify
- notifier.notifyNodeModified(workspaceNode.getFqn(), true, CacheListener.ModificationType.PUT_MAP, workspaceNode.getData(), false);
+ notifier.notifyNodeModified(workspaceNode.getFqn(), true, CacheListener.ModificationType.PUT_MAP, workspaceNode.getData(), ctx, false);
if (eraseExisitng) workspaceNode.clearData();
workspaceNode.putAll(data);
workspace.addNode(workspaceNode);
// post-notify
- notifier.notifyNodeModified(workspaceNode.getFqn(), false, CacheListener.ModificationType.PUT_MAP, workspaceNode.getData(), false);
+ notifier.notifyNodeModified(workspaceNode.getFqn(), false, CacheListener.ModificationType.PUT_MAP, workspaceNode.getData(), ctx, false);
}
- private Object putDataKeyValueAndNotify(Object key, Object value, TransactionWorkspace workspace, WorkspaceNode workspaceNode)
+ private Object putDataKeyValueAndNotify(Object key, Object value, TransactionWorkspace workspace, WorkspaceNode workspaceNode, InvocationContext ctx)
{
if (workspaceNode == null)
throw new NodeNotExistsException("optimisticCreateIfNotExistsInterceptor should have created this node!");
Map addedData = Collections.singletonMap(key, value);
// pre-notify
- notifier.notifyNodeModified(workspaceNode.getFqn(), true, CacheListener.ModificationType.PUT_DATA, workspaceNode.getData(), false);
+ notifier.notifyNodeModified(workspaceNode.getFqn(), true, CacheListener.ModificationType.PUT_DATA, workspaceNode.getData(), ctx, false);
Object old = workspaceNode.put(key, value);
workspace.addNode(workspaceNode);
// post-notify
- notifier.notifyNodeModified(workspaceNode.getFqn(), false, CacheListener.ModificationType.PUT_DATA, addedData, false);
+ notifier.notifyNodeModified(workspaceNode.getFqn(), false, CacheListener.ModificationType.PUT_DATA, addedData, ctx, false);
return old;
}
- private boolean removeNode(TransactionWorkspace workspace, WorkspaceNode workspaceNode, boolean notify) throws CacheException
+ private boolean removeNode(TransactionWorkspace workspace, WorkspaceNode workspaceNode, boolean notify, InvocationContext ctx) throws CacheException
{
// it is already removed - we can ignore it
if (workspaceNode == null) return false;
@@ -317,7 +318,7 @@
if (parentNode == null) throw new NodeNotExistsException("Unable to find parent node with fqn " + parentFqn);
// pre-notify
- if (notify) notifier.notifyNodeRemoved(workspaceNode.getFqn(), true, workspaceNode.getData(), false);
+ if (notify) notifier.notifyNodeRemoved(workspaceNode.getFqn(), true, workspaceNode.getData(), ctx, false);
parentNode.removeChild(workspaceNode.getFqn().getLastElement());
@@ -339,44 +340,44 @@
}
// post-notify
- if (notify) notifier.notifyNodeRemoved(workspaceNode.getFqn(), false, null, false);
+ if (notify) notifier.notifyNodeRemoved(workspaceNode.getFqn(), false, null, ctx, false);
return true;
}
- private Object removeKeyAndNotify(Object removeKey, TransactionWorkspace workspace, WorkspaceNode workspaceNode)
+ private Object removeKeyAndNotify(Object removeKey, TransactionWorkspace workspace, WorkspaceNode workspaceNode, InvocationContext ctx)
{
if (workspaceNode == null) return null;
// pre-notify
- notifier.notifyNodeModified(workspaceNode.getFqn(), true, CacheListener.ModificationType.REMOVE_DATA, workspaceNode.getData(), false);
+ notifier.notifyNodeModified(workspaceNode.getFqn(), true, CacheListener.ModificationType.REMOVE_DATA, workspaceNode.getData(), ctx, false);
Object old = workspaceNode.remove(removeKey);
workspace.addNode(workspaceNode);
Map removedData = Collections.singletonMap(removeKey, old);
// post-notify
- notifier.notifyNodeModified(workspaceNode.getFqn(), false, CacheListener.ModificationType.REMOVE_DATA, removedData, false);
+ notifier.notifyNodeModified(workspaceNode.getFqn(), false, CacheListener.ModificationType.REMOVE_DATA, removedData, ctx, false);
return old;
}
- private void removeDataAndNotify(TransactionWorkspace workspace, WorkspaceNode workspaceNode)
+ private void removeDataAndNotify(TransactionWorkspace workspace, WorkspaceNode workspaceNode, InvocationContext ctx)
{
if (workspaceNode == null) return;
Map data = new HashMap(workspaceNode.getData());
// pre-notify
- notifier.notifyNodeModified(workspaceNode.getFqn(), true, CacheListener.ModificationType.REMOVE_DATA, data, false);
+ notifier.notifyNodeModified(workspaceNode.getFqn(), true, CacheListener.ModificationType.REMOVE_DATA, data, ctx, false);
workspaceNode.clearData();
workspace.addNode(workspaceNode);
// post-notify
- notifier.notifyNodeModified(workspaceNode.getFqn(), false, CacheListener.ModificationType.REMOVE_DATA, data, false);
+ notifier.notifyNodeModified(workspaceNode.getFqn(), false, CacheListener.ModificationType.REMOVE_DATA, data, ctx, false);
}
- private Object getValueForKeyAndNotify(Object[] args, TransactionWorkspace workspace)
+ private Object getValueForKeyAndNotify(Object[] args, TransactionWorkspace workspace, InvocationContext ctx)
{
Fqn fqn = (Fqn) args[0];
Object key = args[1];
@@ -390,15 +391,15 @@
else
{
//add this node into the wrokspace
- notifier.notifyNodeVisited(fqn, true, false);
+ notifier.notifyNodeVisited(fqn, true, ctx, false);
Object val = workspaceNode.get(key);
workspace.addNode(workspaceNode);
- notifier.notifyNodeVisited(fqn, false, false);
+ notifier.notifyNodeVisited(fqn, false, ctx, false);
return val;
}
}
- private Object getNodeAndNotify(Object[] args, TransactionWorkspace workspace)
+ private Object getNodeAndNotify(Object[] args, TransactionWorkspace workspace, InvocationContext ctx)
{
Fqn fqn = (Fqn) args[0];
@@ -411,14 +412,14 @@
}
else
{
- notifier.notifyNodeVisited(fqn, true, false);
+ notifier.notifyNodeVisited(fqn, true, ctx, false);
workspace.addNode(workspaceNode);
- notifier.notifyNodeVisited(fqn, false, false);
+ notifier.notifyNodeVisited(fqn, false, ctx, false);
return workspaceNode.getNode();
}
}
- private Object getKeysAndNotify(Object[] args, TransactionWorkspace workspace)
+ private Object getKeysAndNotify(Object[] args, TransactionWorkspace workspace, InvocationContext ctx)
{
Fqn fqn = (Fqn) args[0];
@@ -431,15 +432,15 @@
}
else
{
- notifier.notifyNodeVisited(fqn, true, false);
+ notifier.notifyNodeVisited(fqn, true, ctx, false);
Object keySet = workspaceNode.getKeys();
workspace.addNode(workspaceNode);
- notifier.notifyNodeVisited(fqn, false, false);
+ notifier.notifyNodeVisited(fqn, false, ctx, false);
return keySet;
}
}
- private Object getChildNamesAndNotify(Object[] args, TransactionWorkspace workspace)
+ private Object getChildNamesAndNotify(Object[] args, TransactionWorkspace workspace, InvocationContext ctx)
{
Fqn fqn = (Fqn) args[0];
@@ -452,10 +453,10 @@
}
else
{
- notifier.notifyNodeVisited(fqn, true, false);
+ notifier.notifyNodeVisited(fqn, true, ctx, false);
Object nameSet = workspaceNode.getChildrenNames();
workspace.addNode(workspaceNode);
- notifier.notifyNodeVisited(fqn, false, false);
+ notifier.notifyNodeVisited(fqn, false, ctx, false);
return nameSet;
}
}
1.31 +12 -10 JBossCache/src/org/jboss/cache/interceptors/CacheMgmtInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: CacheMgmtInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/CacheMgmtInterceptor.java,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -b -r1.30 -r1.31
--- CacheMgmtInterceptor.java 23 May 2007 10:28:50 -0000 1.30
+++ CacheMgmtInterceptor.java 23 May 2007 15:22:03 -0000 1.31
@@ -22,6 +22,7 @@
package org.jboss.cache.interceptors;
import org.jboss.cache.CacheSPI;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.jmx.CacheNotificationBroadcaster;
import org.jboss.cache.marshall.MethodCall;
import org.jboss.cache.marshall.MethodDeclarations;
@@ -33,7 +34,7 @@
* Captures cache management statistics
*
* @author Jerry Gauthier
- * @version $Id: CacheMgmtInterceptor.java,v 1.30 2007/05/23 10:28:50 msurtani Exp $
+ * @version $Id: CacheMgmtInterceptor.java,v 1.31 2007/05/23 15:22:03 msurtani Exp $
*/
public class CacheMgmtInterceptor
extends Interceptor
@@ -109,15 +110,16 @@
* @return
* @throws Throwable
*/
- public Object invoke(MethodCall m) throws Throwable
+ public Object invoke(InvocationContext ctx) throws Throwable
{
+ MethodCall m = ctx.getMethodCall();
Map attributes;
Object[] args = m.getArgs();
Object retval;
// if statistics not enabled, execute the method and return
if (!getStatisticsEnabled())
- return super.invoke(m);
+ return super.invoke(ctx);
long t1, t2;
switch (m.getMethodId())
@@ -126,7 +128,7 @@
//fqn = (Fqn) args[0];
//key = args[1];
t1 = System.currentTimeMillis();
- retval = super.invoke(m);
+ retval = super.invoke(ctx);
t2 = System.currentTimeMillis();
if (retval == null)
{
@@ -142,7 +144,7 @@
case MethodDeclarations.putForExternalReadMethodLocal_id:
case MethodDeclarations.putKeyValMethodLocal_id:
t1 = System.currentTimeMillis();
- retval = super.invoke(m);
+ retval = super.invoke(ctx);
t2 = System.currentTimeMillis();
m_store_times = m_store_times + (t2 - t1);
m_stores++;
@@ -152,7 +154,7 @@
//fqn = (Fqn) args[1];
attributes = (Map) args[2];
t1 = System.currentTimeMillis();
- retval = super.invoke(m);
+ retval = super.invoke(ctx);
t2 = System.currentTimeMillis();
if (attributes != null && attributes.size() > 0)
@@ -164,11 +166,11 @@
case MethodDeclarations.evictNodeMethodLocal_id:
case MethodDeclarations.evictVersionedNodeMethodLocal_id:
//fqn = (Fqn) args[0];
- retval = super.invoke(m);
+ retval = super.invoke(ctx);
m_evictions++;
break;
default:
- retval = super.invoke(m);
+ retval = super.invoke(ctx);
break;
}
1.4 +1 -2 JBossCache/src/org/jboss/cache/interceptors/BaseTransactionalContextInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: BaseTransactionalContextInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/BaseTransactionalContextInterceptor.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- BaseTransactionalContextInterceptor.java 7 Feb 2007 22:06:40 -0000 1.3
+++ BaseTransactionalContextInterceptor.java 23 May 2007 15:22:03 -0000 1.4
@@ -41,9 +41,8 @@
}
}
- protected void setTransactionalContext(Transaction tx, GlobalTransaction gtx)
+ protected void setTransactionalContext(Transaction tx, GlobalTransaction gtx, InvocationContext ctx)
{
- InvocationContext ctx = cache.getInvocationContext();
log.trace("Setting up transactional context.");
if (log.isTraceEnabled()) log.trace("Setting tx as " + tx + " and gtx as " + gtx);
ctx.setTransaction(tx);
1.62 +7 -5 JBossCache/src/org/jboss/cache/interceptors/OptimisticValidatorInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: OptimisticValidatorInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/OptimisticValidatorInterceptor.java,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -b -r1.61 -r1.62
--- OptimisticValidatorInterceptor.java 23 Apr 2007 16:14:48 -0000 1.61
+++ OptimisticValidatorInterceptor.java 23 May 2007 15:22:03 -0000 1.62
@@ -8,6 +8,7 @@
import org.jboss.cache.CacheException;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.marshall.MethodCall;
import org.jboss.cache.marshall.MethodDeclarations;
@@ -43,8 +44,9 @@
*/
public class OptimisticValidatorInterceptor extends OptimisticInterceptor
{
- public Object invoke(MethodCall m) throws Throwable
+ public Object invoke(InvocationContext ctx) throws Throwable
{
+ MethodCall m = ctx.getMethodCall();
Object retval = null;
// Methods we are interested in are prepare/commit
@@ -53,16 +55,16 @@
{
case MethodDeclarations.optimisticPrepareMethod_id:
// should pass in a different prepare here
- validateNodes(getGlobalTransaction());
+ validateNodes(getGlobalTransaction(ctx));
break;
case MethodDeclarations.commitMethod_id:
- commit(getGlobalTransaction());
+ commit(getGlobalTransaction(ctx));
break;
case MethodDeclarations.rollbackMethod_id:
- rollBack(getGlobalTransaction());
+ rollBack(getGlobalTransaction(ctx));
break;
default:
- retval = super.invoke(m);
+ retval = super.invoke(ctx);
break;
}
return retval;
1.18 +7 -7 JBossCache/src/org/jboss/cache/interceptors/InvocationContextInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: InvocationContextInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/InvocationContextInterceptor.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- InvocationContextInterceptor.java 22 May 2007 12:28:59 -0000 1.17
+++ InvocationContextInterceptor.java 23 May 2007 15:22:03 -0000 1.18
@@ -22,9 +22,9 @@
*/
public class InvocationContextInterceptor extends BaseTransactionalContextInterceptor implements InvocationContextInterceptorMBean
{
- public Object invoke(MethodCall call) throws Throwable
+ public Object invoke(InvocationContext ctx) throws Throwable
{
- InvocationContext ctx = cache.getInvocationContext();
+ MethodCall call = ctx.getMethodCall();
Option optionOverride = ctx.getOptionOverrides();
boolean suppressExceptions = false;
Transaction suspendedTransaction = null;
@@ -36,7 +36,7 @@
try
{
Transaction tx = getTransaction();
- setTransactionalContext(tx, getGlobalTransaction(tx, call));
+ setTransactionalContext(tx, getGlobalTransaction(tx, call), ctx);
if (optionOverride != null)
{
@@ -48,7 +48,7 @@
if (ctx.getTransaction() != null)
{
suspendedTransaction = txManager.suspend();
- setTransactionalContext(null, null);
+ setTransactionalContext(null, null, ctx);
if (log.isTraceEnabled()) log.trace("Suspending transaction " + suspendedTransaction);
resumeSuspended = true;
}
@@ -61,11 +61,11 @@
if (optionOverride.isBypassInterceptorChain())
{
log.trace("Interceptor chain bypass option set for call; skipping interceptor chain and proceeding to last interceptor.");
- return getLast().invoke(call);
+ return getLast().invoke(ctx);
}
}
- Object retval = super.invoke(call);
+ Object retval = super.invoke(ctx);
// assume we're the first interceptor in the chain. Handle the exception-throwing.
if (retval instanceof Throwable)
{
@@ -84,7 +84,7 @@
{
// clean up any invocation-scope options set up
log.trace("Resetting invocation-scope options");
- cache.getInvocationContext().getOptionOverrides().reset();
+ ctx.getOptionOverrides().reset();
if (resumeSuspended)
{
1.18 +4 -5 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.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- CallInterceptor.java 7 Feb 2007 22:06:41 -0000 1.17
+++ CallInterceptor.java 23 May 2007 15:22:03 -0000 1.18
@@ -19,7 +19,7 @@
* this interceptor unless it is a call the OptimisticNodeInterceptor knows nothing about.
*
* @author Bela Ban
- * @version $Id: CallInterceptor.java,v 1.17 2007/02/07 22:06:41 genman Exp $
+ * @version $Id: CallInterceptor.java,v 1.18 2007/05/23 15:22:03 msurtani Exp $
*/
public class CallInterceptor extends Interceptor
{
@@ -35,9 +35,9 @@
cache = c;
}
- public Object invoke(MethodCall m) throws Throwable
+ public Object invoke(InvocationContext ctx) throws Throwable
{
-
+ MethodCall m = ctx.getMethodCall();
Object retval = null;
if (!MethodDeclarations.isTransactionLifecycleMethod(m.getMethodId()))
@@ -58,7 +58,6 @@
if (log.isTraceEnabled()) log.trace("Suppressing invocation of method " + m + " on cache.");
}
- InvocationContext ctx = cache.getInvocationContext();
Transaction tx = ctx.getTransaction();
if (tx != null && isValid(tx))
{
@@ -90,7 +89,7 @@
}
else
{
- Option o = cache.getInvocationContext().getOptionOverrides();
+ Option o = ctx.getOptionOverrides();
if (o != null && o.isCacheModeLocal())
{
log.debug("Not adding method to modification list since cache mode local is set.");
1.80 +18 -21 JBossCache/src/org/jboss/cache/interceptors/CacheLoaderInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: CacheLoaderInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/CacheLoaderInterceptor.java,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -b -r1.79 -r1.80
--- CacheLoaderInterceptor.java 19 Mar 2007 19:03:34 -0000 1.79
+++ CacheLoaderInterceptor.java 23 May 2007 15:22:03 -0000 1.80
@@ -15,7 +15,6 @@
import java.util.Collections;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
@@ -25,7 +24,7 @@
* Loads nodes that don't exist at the time of the call into memory from the CacheLoader
*
* @author Bela Ban
- * @version $Id: CacheLoaderInterceptor.java,v 1.79 2007/03/19 19:03:34 msurtani Exp $
+ * @version $Id: CacheLoaderInterceptor.java,v 1.80 2007/05/23 15:22:03 msurtani Exp $
*/
public class CacheLoaderInterceptor extends BaseCacheLoaderInterceptor implements CacheLoaderInterceptorMBean
{
@@ -54,8 +53,9 @@
* @return
* @throws Throwable
*/
- public Object invoke(MethodCall m) throws Throwable
+ public Object invoke(InvocationContext ctx) throws Throwable
{
+ MethodCall m = ctx.getMethodCall();
Fqn fqn = null, fqn2 = null;// if set, load the data. fqn2 for 2nd fqn in move().
Object[] args = m.getArgs();
@@ -63,7 +63,6 @@
boolean initNode = false;// keep uninitialized
Object key = null;
- InvocationContext ctx = cache.getInvocationContext();
TransactionEntry entry = null;
GlobalTransaction gtx;
boolean recursive = false;// do we also load children?
@@ -147,16 +146,16 @@
{
if (fqn2 != null)
{
- loadIfNeeded(fqn2, key, initNode, acquireLock, m, entry, false, m.getMethodId() == MethodDeclarations.moveMethodLocal_id);
+ loadIfNeeded(ctx, fqn2, key, initNode, acquireLock, m, entry, false, m.getMethodId() == MethodDeclarations.moveMethodLocal_id);
}
- loadIfNeeded(fqn, key, initNode, acquireLock, m, entry, recursive, m.getMethodId() == MethodDeclarations.moveMethodLocal_id);
+ loadIfNeeded(ctx, fqn, key, initNode, acquireLock, m, entry, recursive, m.getMethodId() == MethodDeclarations.moveMethodLocal_id);
}
- return super.invoke(m);
+ return super.invoke(ctx);
}
- private void loadIfNeeded(Fqn fqn, Object key, boolean initNode, boolean acquireLock, MethodCall m, TransactionEntry entry, boolean recursive, boolean isMove) throws Throwable
+ private void loadIfNeeded(InvocationContext ctx, Fqn fqn, Object key, boolean initNode, boolean acquireLock, MethodCall m, TransactionEntry entry, boolean recursive, boolean isMove) throws Throwable
{
obtainLoaderLock(fqn);
@@ -176,9 +175,9 @@
{
n = createTempNode(fqn, entry);
}
- else if (!wasRemovedInTx(fqn))
+ else if (!wasRemovedInTx(fqn, ctx.getGlobalTransaction()))
{
- n = loadNode(fqn, n, entry);
+ n = loadNode(ctx, fqn, n, entry);
}
// Only attempt to acquire this lock if we need to - i.e., if
// the lock hasn't already been acquired by the Lock
@@ -329,8 +328,9 @@
MethodCall m = MethodCallFactory.create(MethodDeclarations.lockMethodLocal,
fqn, lock_type, recursive);
+
// hacky
- cache.getInterceptorChain().get(0).invoke(m);
+ cache.getInterceptorChain().get(0).invoke(InvocationContext.fromMethodCall(m));
// super.invoke(m);
}
@@ -363,18 +363,15 @@
* transaction.
* This is O(N) WRT to the number of modifications so far.
*/
- private boolean wasRemovedInTx(Fqn fqn)
+ private boolean wasRemovedInTx(Fqn fqn, GlobalTransaction t)
{
- GlobalTransaction t = cache.getInvocationContext().getGlobalTransaction();
if (t == null)
{
return false;
}
TransactionEntry entry = txTable.get(t);
- Iterator i = entry.getCacheLoaderModifications().iterator();
- while (i.hasNext())
+ for (MethodCall m : entry.getCacheLoaderModifications())
{
- MethodCall m = (MethodCall) i.next();
if (m.getMethodId() == MethodDeclarations.removeNodeMethodLocal_id
&& fqn.isChildOrEquals((Fqn) m.getArgs()[1]))
{
@@ -389,7 +386,7 @@
* If it doesn't exist on disk but in memory, clears the
* uninitialized flag, otherwise returns null.
*/
- private NodeSPI loadNode(Fqn fqn, NodeSPI n, TransactionEntry entry) throws Exception
+ private NodeSPI loadNode(InvocationContext ctx, Fqn fqn, NodeSPI n, TransactionEntry entry) throws Exception
{
if (log.isTraceEnabled()) log.trace("loadNode " + fqn);
Map nodeData = loadData(fqn);
@@ -397,20 +394,20 @@
{
log.trace("Node data is not null, loading");
- cache.getNotifier().notifyNodeLoaded(fqn, true, Collections.emptyMap(), true);
+ cache.getNotifier().notifyNodeLoaded(fqn, true, Collections.emptyMap(), ctx, true);
if (isActivation)
{
- cache.getNotifier().notifyNodeActivated(fqn, true, true);
+ cache.getNotifier().notifyNodeActivated(fqn, true, ctx, true);
}
n = createNodes(fqn, entry);
// n.clearDataDirect();
n.putAllDirect(nodeData);
- cache.getNotifier().notifyNodeLoaded(fqn, false, nodeData, true);
+ cache.getNotifier().notifyNodeLoaded(fqn, false, nodeData, ctx, true);
if (isActivation)
{
- cache.getNotifier().notifyNodeActivated(fqn, false, true);
+ cache.getNotifier().notifyNodeActivated(fqn, false, ctx, true);
}
}
1.15 +5 -3 JBossCache/src/org/jboss/cache/interceptors/EvictionInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: EvictionInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/EvictionInterceptor.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- EvictionInterceptor.java 19 Mar 2007 19:03:34 -0000 1.14
+++ EvictionInterceptor.java 23 May 2007 15:22:03 -0000 1.15
@@ -11,6 +11,7 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.Region;
import org.jboss.cache.RegionManager;
import org.jboss.cache.eviction.EvictedEventNode;
@@ -27,7 +28,7 @@
* This interceptor is used to handle eviction events.
*
* @author Daniel Huang
- * @version $Revision: 1.14 $
+ * @version $Revision: 1.15 $
*/
public class EvictionInterceptor extends Interceptor
{
@@ -83,9 +84,10 @@
this.regionManager = cache.getRegionManager();
}
- public Object invoke(MethodCall m) throws Throwable
+ public Object invoke(InvocationContext ctx) throws Throwable
{
- Object ret = super.invoke(m);
+ MethodCall m = ctx.getMethodCall();
+ Object ret = super.invoke(ctx);
if (log.isTraceEnabled())
{
1.81 +99 -89 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.80
retrieving revision 1.81
diff -u -b -r1.80 -r1.81
--- TxInterceptor.java 2 Apr 2007 23:34:21 -0000 1.80
+++ TxInterceptor.java 23 May 2007 15:22:03 -0000 1.81
@@ -59,16 +59,15 @@
*/
private Map remoteTransactions = new ConcurrentHashMap();
- public Object invoke(MethodCall m) throws Throwable
+ public Object invoke(InvocationContext ctx) throws Throwable
{
+ MethodCall m = ctx.getMethodCall();
if (log.isTraceEnabled())
{
log.trace("(" + cache.getLocalAddress() + ") call on method [" + m + "]");
}
// bypass for buddy group org metod calls.
- if (MethodDeclarations.isBuddyGroupOrganisationMethod(m.getMethodId())) return super.invoke(m);
-
- InvocationContext ctx = cache.getInvocationContext();
+ if (MethodDeclarations.isBuddyGroupOrganisationMethod(m.getMethodId())) return super.invoke(ctx);
boolean scrubTxsOnExit = false;
Option optionOverride = ctx.getOptionOverrides();
@@ -94,7 +93,7 @@
case MethodDeclarations.prepareMethod_id:
if (ctx.getGlobalTransaction().isRemote())
{
- result = handleRemotePrepare(m, ctx.getGlobalTransaction());
+ result = handleRemotePrepare(ctx, m);
scrubTxsOnExit = true;
if (configuration.getExposeManagementStatistics() && getStatisticsEnabled())
{
@@ -111,7 +110,7 @@
case MethodDeclarations.rollbackMethod_id:
if (ctx.getGlobalTransaction().isRemote())
{
- result = handleRemoteCommitRollback(m, ctx.getGlobalTransaction());
+ result = handleRemoteCommitRollback(ctx);
scrubTxsOnExit = true;
}
else
@@ -125,7 +124,7 @@
else
{
// non-transaction lifecycle method.
- result = handleNonTxMethod(m);
+ result = handleNonTxMethod(ctx);
}
}
catch (Exception e)
@@ -142,7 +141,7 @@
if (scrubTxsOnExit)
{
- setTransactionalContext(null, null);
+ setTransactionalContext(null, null, ctx);
}
}
return result;
@@ -179,8 +178,9 @@
return retval;
}
- private Object handleRemotePrepare(MethodCall m, GlobalTransaction gtx) throws Throwable
+ private Object handleRemotePrepare(InvocationContext ctx, MethodCall m) throws Throwable
{
+ GlobalTransaction gtx = ctx.getGlobalTransaction();
List<MethodCall> modifications = (List<MethodCall>) m.getArgs()[1];
boolean onePhase = (Boolean) m.getArgs()[configuration.isNodeLockingOptimistic() ? 4 : 3];
@@ -195,10 +195,10 @@
if (ltx == null)
{
if (currentTx != null) txManager.suspend();
- ltx = createLocalTxForGlobalTx(gtx);// creates new LTX and associates it with a GTX
+ ltx = createLocalTxForGlobalTx(gtx, ctx);// creates new LTX and associates it with a GTX
if (log.isDebugEnabled())
{
- log.debug("(" + cache.getLocalAddress() + "): started new local TX as result of remote PREPARE: local TX=" + ltx + ", global TX=" + gtx);
+ log.debug("Started new local TX as result of remote PREPARE: local TX=" + ltx + " (Status=" + ltx.getStatus() + "), global TX=" + gtx);
}
}
else
@@ -237,16 +237,17 @@
if (log.isTraceEnabled()) log.trace("TxTable contents: " + txTable);
}
+ setTransactionalContext(ltx, gtx, ctx);
// register a sync handler for this tx.
registerHandler(ltx, new RemoteSynchronizationHandler(gtx, ltx, cache));
if (configuration.isNodeLockingOptimistic())
{
- retval = handleOptimisticPrepare(m, gtx, modifications, onePhase, ltx);
+ retval = handleOptimisticPrepare(ctx, gtx, modifications, onePhase, ltx);
}
else
{
- retval = handlePessimisticPrepare(m, gtx, modifications, onePhase, ltx);
+ retval = handlePessimisticPrepare(ctx, m, gtx, modifications, onePhase, ltx);
}
}
finally
@@ -268,13 +269,12 @@
* Tests if we already have a tx running. If so, register a sync handler for this method invocation.
* if not, create a local tx if we're using opt locking.
*
- * @param m
* @return
* @throws Throwable
*/
- private Object handleNonTxMethod(MethodCall m) throws Throwable
+ private Object handleNonTxMethod(InvocationContext ctx) throws Throwable
{
- InvocationContext ctx = cache.getInvocationContext();
+ MethodCall m = ctx.getMethodCall();
Transaction tx = ctx.getTransaction();
Object result;
// if there is no current tx and we're using opt locking, we need to use an implicit tx.
@@ -285,13 +285,13 @@
// we need to attach this tx to the InvocationContext.
ctx.setTransaction(tx);
}
- if (tx != null) m = attachGlobalTransaction(tx, m);
+ if (tx != null) m = attachGlobalTransaction(ctx, tx, m);
GlobalTransaction gtx = ctx.getGlobalTransaction();
try
{
- result = super.invoke(m);
+ result = super.invoke(ctx);
if (implicitTransaction)
{
copyInvocationScopeOptionsToTxScope(ctx);
@@ -306,7 +306,7 @@
result = t;
try
{
- setTransactionalContext(tx, gtx);
+ setTransactionalContext(tx, gtx, ctx);
txManager.rollback();
}
catch (Throwable th)
@@ -322,7 +322,7 @@
return result;
}
- private MethodCall attachGlobalTransaction(Transaction tx, MethodCall m) throws Exception
+ private MethodCall attachGlobalTransaction(InvocationContext ctx, Transaction tx, MethodCall m) throws Exception
{
if (log.isDebugEnabled())
{
@@ -347,7 +347,7 @@
}
// make sure we attach this gtx to the invocation context.
- cache.getInvocationContext().setGlobalTransaction(gtx);
+ ctx.setGlobalTransaction(gtx);
return m;
}
@@ -359,16 +359,15 @@
* <p/>
* Resumes any existing txs before returning.
*
- * @param m
* @return
* @throws Throwable
*/
- private Object handleOptimisticPrepare(MethodCall m, GlobalTransaction gtx, List<MethodCall> modifications, boolean onePhase, Transaction ltx) throws Throwable
+ private Object handleOptimisticPrepare(InvocationContext ctx, GlobalTransaction gtx, List<MethodCall> modifications, boolean onePhase, Transaction ltx) throws Throwable
{
Object retval;
if (log.isDebugEnabled()) log.debug("Handling optimistic remote prepare " + gtx);
- replayModifications(modifications, ltx, true);
- retval = super.invoke(m);
+ replayModifications(modifications, ctx, true);
+ retval = super.invoke(ctx);
// JBCACHE-361 Confirm that the transaction is ACTIVE
if (!isActive(ltx))
{
@@ -379,7 +378,7 @@
return retval;
}
- private Object handlePessimisticPrepare(MethodCall m, GlobalTransaction gtx, List<MethodCall> modifications, boolean commit, Transaction ltx) throws Exception
+ private Object handlePessimisticPrepare(InvocationContext ctx, MethodCall m, GlobalTransaction gtx, List<MethodCall> modifications, boolean commit, Transaction ltx) throws Exception
{
boolean success = true;
Object retval;
@@ -388,14 +387,14 @@
// now pass up the prepare method itself.
try
{
- replayModifications(modifications, ltx, false);
+ replayModifications(modifications, ctx, false);
if (isOnePhaseCommitPrepareMehod(m))
{
log.trace("Using one-phase prepare. Not propagating the prepare call up the stack until called to do so by the sync handler.");
}
else
{
- super.invoke(m);
+ super.invoke(ctx);
}
// JBCACHE-361 Confirm that the transaction is ACTIVE
@@ -470,9 +469,11 @@
return null;
}
- private Object replayModifications(List<MethodCall> modifications, Transaction tx, boolean injectDataVersions)
+ private Object replayModifications(List<MethodCall> modifications, InvocationContext ctx, boolean injectDataVersions)
{
Object retval = null;
+ MethodCall originalMethodCall = ctx.getMethodCall();
+ Option originalOption = ctx.getOptionOverrides();
if (modifications != null)
{
@@ -485,20 +486,29 @@
Object[] origArgs = modification.getArgs();
// there may be instances (e.g., data gravitation calls) where a data version is not passed in or not even relevant.
// make sure we are aware of this.
- injectDataVersion(origArgs[origArgs.length - 1]);
+ Option o = null;
+ if (origArgs[origArgs.length - 1] instanceof DataVersion)
+ {
+ o = new Option();
+ o.setDataVersion((DataVersion) origArgs[origArgs.length - 1]);
+ }
// modify the call to the non-dataversioned counterpart since we've popped out the data version
Object[] args = new Object[origArgs.length - 1];
System.arraycopy(origArgs, 0, args, 0, args.length);
- retval = super.invoke(MethodCallFactory.create(MethodDeclarations.getUnversionedMethod(modification.getMethodId()), args));
+ ctx.setMethodCall(MethodCallFactory.create(MethodDeclarations.getUnversionedMethod(modification.getMethodId()), args));
+ if (o != null) ctx.setOptionOverrides(o);
}
else
{
- retval = super.invoke(modification);
+ ctx.setMethodCall(modification);
}
- if (!isActive(tx))
+
+ retval = super.invoke(ctx);
+
+ if (!isActive(ctx.getTransaction()))
{
- throw new ReplicationException("prepare() failed -- " + "local transaction status is not STATUS_ACTIVE; is " + tx.getStatus());
+ throw new ReplicationException("prepare() failed -- " + "local transaction status is not STATUS_ACTIVE; is " + ctx.getTransaction().getStatus());
}
}
catch (Throwable t)
@@ -509,7 +519,8 @@
finally
{
// reset any options
- if (injectDataVersions) cache.getInvocationContext().setOptionOverrides(null);
+ if (injectDataVersions) ctx.setOptionOverrides(originalOption);
+ ctx.setMethodCall(originalMethodCall);
}
if (retval != null && retval instanceof Exception)
{
@@ -524,30 +535,18 @@
return retval;
}
- public void injectDataVersion(Object obj)
- {
- if (obj instanceof DataVersion)
- {
- Option o = new Option();
- o.setDataVersion((DataVersion) obj);
- cache.getInvocationContext().setOptionOverrides(o);
- }
- else
- {
- log.debug("Object " + obj + " is not a DataVersion, not applying to this mod.");
- }
- }
-
/**
* Handles a commit or a rollback for a remote gtx. Called by invoke().
*
- * @param m
* @return
* @throws Throwable
*/
- private Object handleRemoteCommitRollback(MethodCall m, GlobalTransaction gtx) throws Throwable
+ private Object handleRemoteCommitRollback(InvocationContext ctx) throws Throwable
{
Transaction ltx;
+ GlobalTransaction gtx = ctx.getGlobalTransaction();
+ MethodCall m = ctx.getMethodCall();
+
try
{
ltx = getLocalTxForGlobalTx(gtx);
@@ -576,12 +575,12 @@
resumeCurrentTxOnCompletion = true;
txManager.resume(ltx);
// make sure we set this in the ctx
- cache.getInvocationContext().setTransaction(ltx);
+ ctx.setTransaction(ltx);
}
if (log.isDebugEnabled()) log.debug(" executing " + m + "() with local TX " + ltx + " under global tx " + gtx);
// pass commit up the chain
- // super.invoke(m);
+ // super.invoke(ctx);
// commit or rollback the tx.
if (m.getMethodId() == MethodDeclarations.commitMethod_id)
{
@@ -610,7 +609,7 @@
if (currentTx != null)
{
txManager.resume(currentTx);
- cache.getInvocationContext().setTransaction(currentTx);
+ ctx.setTransaction(currentTx);
}
}
@@ -646,14 +645,13 @@
* Handles a commit or a rollback. Called by the synch handler. Simply tests that we are in the correct tx and
* passes the meth call up the interceptor chain.
*
- * @param m
* @return
* @throws Throwable
*/
- private Object handleCommitRollback(MethodCall m) throws Throwable
+ private Object handleCommitRollback(InvocationContext ctx) throws Throwable
{
//GlobalTransaction gtx = findGlobalTransaction(m.getArgs());
- GlobalTransaction gtx = cache.getInvocationContext().getGlobalTransaction();
+ GlobalTransaction gtx = ctx.getGlobalTransaction();
Object result;
// this must have a local transaction associated if a prepare has been
@@ -664,7 +662,7 @@
//if (!ltx.equals(currentTx)) throw new IllegalStateException(" local transaction " + ltx + " transaction does not match running tx " + currentTx);
- result = super.invoke(m);
+ result = super.invoke(ctx);
if (log.isDebugEnabled()) log.debug("Finished local commit/rollback method for " + gtx);
return result;
@@ -679,10 +677,10 @@
*
* @param gtx
*/
- protected void runCommitPhase(GlobalTransaction gtx, Transaction tx, List modifications, boolean onePhaseCommit)
+ protected void runCommitPhase(InvocationContext ctx, GlobalTransaction gtx, Transaction tx, List modifications, boolean onePhaseCommit)
{
// set the hasMods flag in the invocation ctx. This should not be replicated, just used locally by the interceptors.
- cache.getInvocationContext().setTxHasMods(modifications != null && modifications.size() > 0);
+ ctx.setTxHasMods(modifications != null && modifications.size() > 0);
try
{
MethodCall commitMethod;
@@ -710,7 +708,8 @@
{
log.trace(" running commit for " + gtx);
}
- handleCommitRollback(commitMethod);
+ ctx.setMethodCall(commitMethod);
+ handleCommitRollback(ctx);
}
catch (Throwable e)
{
@@ -751,12 +750,12 @@
*
* @param gtx
*/
- protected void runRollbackPhase(GlobalTransaction gtx, Transaction tx, List modifications)
+ protected void runRollbackPhase(InvocationContext ctx, GlobalTransaction gtx, Transaction tx, List modifications)
{
//Transaction ltx = null;
try
{
- cache.getInvocationContext().setTxHasMods(modifications != null && modifications.size() > 0);
+ ctx.setTxHasMods(modifications != null && modifications.size() > 0);
// JBCACHE-457
// MethodCall rollbackMethod = MethodCall(CacheImpl.rollbackMethod, new Object[]{gtx, hasMods ? true : false});
MethodCall rollbackMethod = MethodCallFactory.create(MethodDeclarations.rollbackMethod, gtx);
@@ -770,7 +769,8 @@
//ltx = getLocalTxForGlobalTx(gtx);
rollbackTransactions.put(tx, gtx);
- handleCommitRollback(rollbackMethod);
+ ctx.setMethodCall(rollbackMethod);
+ handleCommitRollback(ctx);
}
catch (Throwable e)
{
@@ -789,7 +789,7 @@
* @return
* @throws Throwable
*/
- protected Object runPreparePhase(GlobalTransaction gtx, List modifications) throws Throwable
+ protected Object runPreparePhase(InvocationContext ctx, GlobalTransaction gtx, List modifications) throws Throwable
{
// build the method call
MethodCall prepareMethod;
@@ -820,12 +820,13 @@
Object result;
// Is there a local transaction associated with GTX ?
- Transaction ltx = txTable.getLocalTransaction(gtx);
+ Transaction ltx = ctx.getTransaction();
//if ltx is not null and it is already running
if (txManager.getTransaction() != null && ltx != null && txManager.getTransaction().equals(ltx))
{
- result = super.invoke(prepareMethod);
+ ctx.setMethodCall(prepareMethod);
+ result = super.invoke(ctx);
}
else
{
@@ -948,12 +949,12 @@
* @return
* @throws Exception
*/
- private Transaction createLocalTxForGlobalTx(GlobalTransaction gtx) throws Exception
+ private Transaction createLocalTxForGlobalTx(GlobalTransaction gtx, InvocationContext ctx) throws Exception
{
Transaction localTx = createLocalTx();
txTable.put(localTx, gtx);
// attach this to the context
- cache.getInvocationContext().setTransaction(localTx);
+ ctx.setTransaction(localTx);
if (log.isTraceEnabled()) log.trace("Created new tx for gtx " + gtx);
return localTx;
}
@@ -971,6 +972,7 @@
CacheSPI cache = null;
List modifications = null;
TransactionEntry entry = null;
+ protected InvocationContext ctx; // the context for this call.
RemoteSynchronizationHandler(GlobalTransaction gtx, Transaction tx, CacheSPI cache)
@@ -992,6 +994,8 @@
}
modifications = entry.getModifications();
+ ctx = cache.getInvocationContext();
+ ctx.setOriginLocal(false);
}
// this should really not be done here -
@@ -1000,7 +1004,9 @@
{
try
{
- setTransactionalContext(tx, gtx);
+ // could happen if a rollback is called and beforeCompletion() doesn't get called.
+ if (ctx == null) ctx = cache.getInvocationContext();
+ setTransactionalContext(tx, gtx, ctx);
try
{
@@ -1017,7 +1023,7 @@
if ((entry = txTable.get(gtx)) != null)
{
modifications = entry.getModifications();
- cache.getInvocationContext().setOptionOverrides(entry.getOption());
+ ctx.setOptionOverrides(entry.getOption());
}
transactions.remove(tx);
@@ -1028,14 +1034,14 @@
// if this is optimistic or sync repl
boolean onePhaseCommit = !configuration.isNodeLockingOptimistic() && configuration.getCacheMode() == Configuration.CacheMode.REPL_ASYNC;
if (log.isDebugEnabled()) log.debug("Running commit phase. One phase? " + onePhaseCommit);
- runCommitPhase(gtx, tx, modifications, onePhaseCommit);
+ runCommitPhase(ctx, gtx, tx, modifications, onePhaseCommit);
log.debug("Finished commit phase");
break;
case Status.STATUS_MARKED_ROLLBACK:
case Status.STATUS_ROLLEDBACK:
log.debug("Running rollback phase");
- runRollbackPhase(gtx, tx, modifications);
+ runRollbackPhase(ctx, gtx, tx, modifications);
log.debug("Finished rollback phase");
break;
@@ -1048,7 +1054,8 @@
// clean up the tx table
txTable.remove(gtx);
txTable.remove(tx);
- setTransactionalContext(null, null);
+ // this should not be necessary since the ctx is local to the sync which will now be gc'd.
+ // setTransactionalContext(null, null, ctx);
cleanupInternalState();
}
}
@@ -1086,9 +1093,10 @@
public void beforeCompletion()
{
super.beforeCompletion();
+ ctx.setOriginLocal(true); // this is the LOCAL sync handler after all!
// fetch the modifications before the transaction is committed
// (and thus removed from the txTable)
- setTransactionalContext(tx, gtx);
+ setTransactionalContext(tx, gtx, ctx);
if (modifications.size() == 0)
{
if (log.isTraceEnabled()) log.trace("No modifications in this tx. Skipping beforeCompletion()");
@@ -1096,7 +1104,7 @@
}
// set any transaction wide options as current for this thread.
- cache.getInvocationContext().setOptionOverrides(entry.getOption());
+ ctx.setOptionOverrides(entry.getOption());
try
{
@@ -1106,7 +1114,7 @@
case Status.STATUS_ACTIVE:
case Status.STATUS_PREPARING:
// run a prepare call.
- Object result = runPreparePhase(gtx, modifications);
+ Object result = runPreparePhase(ctx, gtx, modifications);
if (result instanceof Throwable)
{
@@ -1136,14 +1144,16 @@
finally
{
localRollbackOnly = false;
- setTransactionalContext(null, null);
+ setTransactionalContext(null, null, ctx);
}
}
@Override
public void afterCompletion(int status)
{
- cache.getInvocationContext().setLocalRollbackOnly(localRollbackOnly);
+ // could happen if a rollback is called and beforeCompletion() doesn't get called.
+ if (ctx == null) ctx = cache.getInvocationContext();
+ ctx.setLocalRollbackOnly(localRollbackOnly);
super.afterCompletion(status);
}
1.15 +33 -26 JBossCache/src/org/jboss/cache/interceptors/UnlockInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: UnlockInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/UnlockInterceptor.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- UnlockInterceptor.java 25 Aug 2006 14:10:07 -0000 1.14
+++ UnlockInterceptor.java 23 May 2007 15:22:03 -0000 1.15
@@ -15,9 +15,10 @@
* LockTable. This is a no-op if a transaction is used.
*
* @author Bela Ban
- * @version $Id: UnlockInterceptor.java,v 1.14 2006/08/25 14:10:07 msurtani Exp $
+ * @version $Id: UnlockInterceptor.java,v 1.15 2007/05/23 15:22:03 msurtani Exp $
*/
-public class UnlockInterceptor extends Interceptor {
+public class UnlockInterceptor extends Interceptor
+{
Map lock_table = null;
boolean trace = log.isTraceEnabled();
@@ -28,13 +29,15 @@
lock_table = cache.getLockTable();
}
- public Object invoke(MethodCall m) throws Throwable {
- try {
- return super.invoke(m);
+ public Object invoke(InvocationContext ctx) throws Throwable
+ {
+ MethodCall m = ctx.getMethodCall();
+ try
+ {
+ return super.invoke(ctx);
}
finally
{
- InvocationContext ctx = cache.getInvocationContext();
if (ctx.getOptionOverrides() == null || !ctx.getOptionOverrides().isSuppressLocking())
{
Transaction tx = ctx.getTransaction();
@@ -42,12 +45,14 @@
{
// if (trace) log.trace("Do not do anything; we have a transaction running or node locking is optimistic.");
}
- else { // no TX
+ else
+ { // no TX
Thread currentThread = Thread.currentThread();
- List locks = (List)lock_table.get(currentThread);
+ List locks = (List) lock_table.get(currentThread);
if (trace) log.trace("Attempting to release locks on current thread. Lock table is " + lock_table);
- if (locks != null && locks.size() > 0) {
+ if (locks != null && locks.size() > 0)
+ {
releaseLocks(locks, currentThread);
lock_table.remove(currentThread);
}
@@ -56,10 +61,12 @@
}
}
- private void releaseLocks(List locks, Thread currentThread) {
+ private void releaseLocks(List locks, Thread currentThread)
+ {
IdentityLock lock;
- for (ListIterator it=locks.listIterator(locks.size()); it.hasPrevious();) {
- lock=(IdentityLock)it.previous();
+ for (ListIterator it = locks.listIterator(locks.size()); it.hasPrevious();)
+ {
+ lock = (IdentityLock) it.previous();
if (trace)
log.trace("releasing lock for " + lock.getFqn() + ": " + lock);
lock.release(currentThread);
1.27 +13 -10 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.26
retrieving revision 1.27
diff -u -b -r1.26 -r1.27
--- CreateIfNotExistsInterceptor.java 7 Feb 2007 22:06:41 -0000 1.26
+++ CreateIfNotExistsInterceptor.java 23 May 2007 15:22:03 -0000 1.27
@@ -4,6 +4,7 @@
import org.jboss.cache.CacheImpl;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.marshall.MethodCall;
import org.jboss.cache.marshall.MethodCallFactory;
@@ -19,7 +20,7 @@
* (depending on the create_if_not_exists argument)
*
* @author Bela Ban
- * @version $Id: CreateIfNotExistsInterceptor.java,v 1.26 2007/02/07 22:06:41 genman Exp $
+ * @version $Id: CreateIfNotExistsInterceptor.java,v 1.27 2007/05/23 15:22:03 msurtani Exp $
* @deprecated This code is not used anymore and will be removed in a future unlock
*/
public class CreateIfNotExistsInterceptor extends Interceptor
@@ -110,8 +111,9 @@
* @return
* @throws Throwable
*/
- public Object invoke(MethodCall m) throws Throwable
+ public Object invoke(InvocationContext ctx) throws Throwable
{
+ MethodCall m = ctx.getMethodCall();
Fqn fqn;
boolean isPut = MethodDeclarations.isPutMethod(m.getMethodId()),
isRemove = m.getMethodId() == MethodDeclarations.removeNodeMethodLocal_id,
@@ -134,15 +136,15 @@
findAndBlockOnRemove(fqn, remove_lock);
if (cache.peek(fqn, false) == null)
{
- GlobalTransaction gtx = cache.getInvocationContext().getGlobalTransaction();
+ GlobalTransaction gtx = ctx.getGlobalTransaction();
if (log.isTraceEnabled())
{
log.trace("creating node " + fqn);
}
- createNode(fqn, gtx);
+ createNode(fqn, ctx);
}
- return super.invoke(m);
+ return super.invoke(ctx);
}
finally
{
@@ -157,7 +159,7 @@
addFqnToRemoveList(fqn, remove_lock);
put_lock.unlock();
// we only unlock now because waiting on the put-list and adding to remove-list need to be atomic !
- return super.invoke(m);
+ return super.invoke(ctx);
}
finally
{
@@ -169,7 +171,7 @@
}
}
}
- return super.invoke(m);
+ return super.invoke(ctx);
}
@@ -375,11 +377,12 @@
}
}
- private void createNode(Fqn fqn, GlobalTransaction tx)
+ private void createNode(Fqn fqn, InvocationContext ctx)
{
NodeSPI n, child_node;
Object child_name;
Fqn tmp_fqn = Fqn.ROOT;
+ GlobalTransaction tx = ctx.getGlobalTransaction();
if (fqn == null) return;
synchronized (this)
@@ -405,8 +408,8 @@
// (needed for abort/rollback of transaction)
// cache.addNode(tx, (Fqn)tmp_fqn.clone());
}
- cache.getNotifier().notifyNodeCreated(tmp_fqn, true, true);
- cache.getNotifier().notifyNodeCreated(tmp_fqn, false, true);
+ cache.getNotifier().notifyNodeCreated(tmp_fqn, true, ctx, true);
+ cache.getNotifier().notifyNodeCreated(tmp_fqn, false, ctx, true);
}
n = child_node;
}
1.44 +11 -11 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.43
retrieving revision 1.44
diff -u -b -r1.43 -r1.44
--- ReplicationInterceptor.java 19 Mar 2007 19:03:34 -0000 1.43
+++ ReplicationInterceptor.java 23 May 2007 15:22:03 -0000 1.44
@@ -13,25 +13,25 @@
* 'side-ways' (see docs/design/Refactoring.txt).
*
* @author Bela Ban
- * @version $Id: ReplicationInterceptor.java,v 1.43 2007/03/19 19:03:34 msurtani Exp $
+ * @version $Id: ReplicationInterceptor.java,v 1.44 2007/05/23 15:22:03 msurtani Exp $
*/
public class ReplicationInterceptor extends BaseRpcInterceptor
{
- public Object invoke(MethodCall m) throws Throwable
+ public Object invoke(InvocationContext ctx) throws Throwable
{
- InvocationContext ctx = cache.getInvocationContext();
+ MethodCall m = ctx.getMethodCall();
GlobalTransaction gtx = ctx.getGlobalTransaction();
// bypass for buddy group org metod calls.
- if (MethodDeclarations.isBuddyGroupOrganisationMethod(m.getMethodId())) return super.invoke(m);
+ if (MethodDeclarations.isBuddyGroupOrganisationMethod(m.getMethodId())) return super.invoke(ctx);
boolean isLocalCommitOrRollback = gtx != null && !gtx.isRemote() && (m.getMethodId() == MethodDeclarations.commitMethod_id || m.getMethodId() == MethodDeclarations.rollbackMethod_id);
if (log.isTraceEnabled()) log.trace("isLocalCommitOrRollback? " + isLocalCommitOrRollback + "; gtx = " + gtx);
// pass up the chain if not a local commit or rollback (in which case replicate first)
- Object o = isLocalCommitOrRollback ? null : super.invoke(m);
+ Object o = isLocalCommitOrRollback ? null : super.invoke(ctx);
// ctx = cache.getInvocationContext();
Option optionOverride = ctx.getOptionOverrides();
@@ -39,7 +39,7 @@
if (optionOverride != null && optionOverride.isCacheModeLocal() && ctx.getTransaction() == null)
{
log.trace("skip replication");
- return isLocalCommitOrRollback ? super.invoke(m) : o;
+ return isLocalCommitOrRollback ? super.invoke(ctx) : o;
}
// could be potentially TRANSACTIONAL. If so, we register for transaction completion callbacks (if we
@@ -53,12 +53,12 @@
{
case MethodDeclarations.commitMethod_id:
// REPL_ASYNC will result in only a prepare() method - 1 phase commit.
- if (containsModifications(m)) replicateCall(m, configuration.isSyncCommitPhase());
+ if (containsModifications(ctx)) replicateCall(m, configuration.isSyncCommitPhase());
// now pass up the chain
- o = super.invoke(m);
+ o = super.invoke(ctx);
break;
case MethodDeclarations.prepareMethod_id:
- if (containsModifications(m))
+ if (containsModifications(ctx))
{
// this is a prepare method
runPreparePhase(m, gtx);
@@ -66,12 +66,12 @@
break;
case MethodDeclarations.rollbackMethod_id:
// REPL_ASYNC will result in only a prepare() method - 1 phase commit.
- if (containsModifications(m) && !ctx.isLocalRollbackOnly())
+ if (containsModifications(ctx) && !ctx.isLocalRollbackOnly())
{
replicateCall(m, configuration.isSyncRollbackPhase());
}
// now pass up the chain
- o = super.invoke(m);
+ o = super.invoke(ctx);
break;
case MethodDeclarations.putForExternalReadMethodLocal_id:
cache.getTransactionTable().get(gtx).setForceAsyncReplication(true);
1.23 +5 -4 JBossCache/src/org/jboss/cache/interceptors/BaseRpcInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: BaseRpcInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/BaseRpcInterceptor.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- BaseRpcInterceptor.java 19 Mar 2007 19:03:34 -0000 1.22
+++ BaseRpcInterceptor.java 23 May 2007 15:22:03 -0000 1.23
@@ -4,6 +4,7 @@
package org.jboss.cache.interceptors;
import org.jboss.cache.CacheSPI;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.marshall.MethodCall;
import org.jboss.cache.marshall.MethodCallFactory;
@@ -109,17 +110,17 @@
cache.getRPCManager().getReplicationQueue().add(MethodCallFactory.create(MethodDeclarations.replicateMethod, call));
}
- protected boolean containsModifications(MethodCall m)
+ protected boolean containsModifications(InvocationContext ctx)
{
- switch (m.getMethodId())
+ switch (ctx.getMethodCall().getMethodId())
{
case MethodDeclarations.prepareMethod_id:
case MethodDeclarations.optimisticPrepareMethod_id:
- List mods = (List) m.getArgs()[1];
+ List mods = (List) ctx.getMethodCall().getArgs()[1];
return mods.size() > 0;
case MethodDeclarations.commitMethod_id:
case MethodDeclarations.rollbackMethod_id:
- return cache.getInvocationContext().isTxHasMods();
+ return ctx.isTxHasMods();
default:
return false;
}
1.52 +16 -16 JBossCache/src/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: PessimisticLockInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/PessimisticLockInterceptor.java,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -b -r1.51 -r1.52
--- PessimisticLockInterceptor.java 19 Mar 2007 19:03:34 -0000 1.51
+++ PessimisticLockInterceptor.java 23 May 2007 15:22:03 -0000 1.52
@@ -36,7 +36,7 @@
* current method and unlock when the method returns.
*
* @author Bela Ban
- * @version $Id: PessimisticLockInterceptor.java,v 1.51 2007/03/19 19:03:34 msurtani Exp $
+ * @version $Id: PessimisticLockInterceptor.java,v 1.52 2007/05/23 15:22:03 msurtani Exp $
*/
public class PessimisticLockInterceptor extends Interceptor
{
@@ -62,17 +62,17 @@
}
- public Object invoke(MethodCall m) throws Throwable
+ public Object invoke(InvocationContext ctx) throws Throwable
{
+ MethodCall m = ctx.getMethodCall();
Fqn fqn = null;
NodeLock.LockType lock_type = NodeLock.LockType.NONE;
Object[] args = m.getArgs();
- InvocationContext ctx = cache.getInvocationContext();
boolean lockNecessary = false;
boolean locksAlreadyObtained = false;
if (log.isTraceEnabled()) log.trace("PessimisticLockInterceptor invoked for method " + m);
- if (cache.getInvocationContext().getOptionOverrides() != null && cache.getInvocationContext().getOptionOverrides().isSuppressLocking())
+ if (ctx.getOptionOverrides() != null && ctx.getOptionOverrides().isSuppressLocking())
{
log.trace("Suppressing locking");
switch (m.getMethodId())
@@ -85,7 +85,7 @@
break;
}
- return super.invoke(m);
+ return super.invoke(ctx);
}
/** List<IdentityLock> locks. Locks acquired during the current method; will be released later by UnlockInterceptor.
@@ -106,7 +106,7 @@
{
case MethodDeclarations.moveMethodLocal_id:
fqn = (Fqn) args[0];
- obtainLocksForMove(fqn, (Fqn) args[1]);
+ obtainLocksForMove(ctx, fqn, (Fqn) args[1]);
locksAlreadyObtained = true;
lockNecessary = true;
isDeleteOperation = true;
@@ -183,7 +183,7 @@
{
do
{
- lock(fqn, ctx.getGlobalTransaction(), lock_type, recursive, createIfNotExists, zeroLockTimeout ? 0 : lock_acquisition_timeout, isDeleteOperation, isEvictOperation);
+ lock(ctx, fqn, lock_type, recursive, createIfNotExists, zeroLockTimeout ? 0 : lock_acquisition_timeout, isDeleteOperation, isEvictOperation);
}
while (createIfNotExists && cache.peek(fqn, false) == null);// keep trying until we have the lock (fixes concurrent remove())
}
@@ -199,7 +199,7 @@
{
return null;
}
- Object o = super.invoke(m);
+ Object o = super.invoke(ctx);
// FIXME this should be done in UnlockInterceptor, but I didn't want
// to add the removedNodes map to CacheImpl
if (isDeleteOperation && ctx.getGlobalTransaction() == null)
@@ -223,18 +223,18 @@
return o;
}
- private void obtainLocksForMove(Fqn node, Fqn parent) throws InterruptedException
+ private void obtainLocksForMove(InvocationContext ctx, Fqn node, Fqn parent) throws InterruptedException
{
// parent node (new parent) and current node's existing parent should both get RLs.
// node should have a WL.
// this call will ensure the node gets a WL and it's current parent gets RL.
if (log.isTraceEnabled()) log.trace("Attempting to get WL on node to be moved [" + node + "]");
- lock(node, cache.getInvocationContext().getGlobalTransaction(), NodeLock.LockType.WRITE, true, false, lock_acquisition_timeout, true, false);
+ lock(ctx, node, NodeLock.LockType.WRITE, true, false, lock_acquisition_timeout, true, false);
//now for an RL for the new parent.
if (log.isTraceEnabled()) log.trace("Attempting to get RL on new parent [" + parent + "]");
- lock(parent, cache.getInvocationContext().getGlobalTransaction(), NodeLock.LockType.READ, true, false, lock_acquisition_timeout, false, false);
+ lock(ctx, parent, NodeLock.LockType.READ, true, false, lock_acquisition_timeout, false, false);
}
@@ -242,17 +242,17 @@
* Locks a given node.
*
* @param fqn
- * @param gtx
* @param lock_type DataNode.LOCK_TYPE_READ, DataNode.LOCK_TYPE_WRITE or DataNode.LOCK_TYPE_NONE
* @param recursive Lock children recursively
*/
- private void lock(Fqn fqn, GlobalTransaction gtx, NodeLock.LockType lock_type, boolean recursive, boolean createIfNotExists, long timeout, boolean isDeleteOperation, boolean isEvictionOperation)
+ private void lock(InvocationContext ctx, Fqn fqn, NodeLock.LockType lock_type, boolean recursive, boolean createIfNotExists, long timeout, boolean isDeleteOperation, boolean isEvictionOperation)
throws TimeoutException, LockingException, InterruptedException
{
NodeSPI n;
NodeSPI child_node;
Object child_name;
Thread currentThread = Thread.currentThread();
+ GlobalTransaction gtx = ctx.getGlobalTransaction();
Object owner = (gtx != null) ? gtx : currentThread;
int treeNodeSize;
@@ -312,7 +312,7 @@
}
else
{
- if (writeLockNeeded(lock_type, i, treeNodeSize, isEvictionOperation, isDeleteOperation, createIfNotExists, fqn, child_node.getFqn()))
+ if (writeLockNeeded(ctx, lock_type, i, treeNodeSize, isEvictionOperation, isDeleteOperation, createIfNotExists, fqn, child_node.getFqn()))
{
//acquired=child_node.acquire(owner, lock_timeout, DataNode.LOCK_TYPE_WRITE);
//acquired = lockManager.acquire(child_node, owner, NodeLock.LockType.WRITE, timeout);
@@ -369,10 +369,10 @@
n.markAsDeleted(false);
}
- private boolean writeLockNeeded(NodeLock.LockType lock_type, int currentNodeIndex, int treeNodeSize, boolean isEvictOperation, boolean isRemoveOperation, boolean createIfNotExists, Fqn targetFqn, Fqn currentFqn)
+ private boolean writeLockNeeded(InvocationContext ctx, NodeLock.LockType lock_type, int currentNodeIndex, int treeNodeSize, boolean isEvictOperation, boolean isRemoveOperation, boolean createIfNotExists, Fqn targetFqn, Fqn currentFqn)
{
// write lock forced!!
- if (cache.getInvocationContext().getOptionOverrides().isForceWriteLock()) return true;
+ if (ctx.getOptionOverrides().isForceWriteLock()) return true;
if (cache.getConfiguration().isLockParentForChildInsertRemove())
{
1.48 +11 -11 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.47
retrieving revision 1.48
diff -u -b -r1.47 -r1.48
--- OptimisticCreateIfNotExistsInterceptor.java 2 Apr 2007 23:28:22 -0000 1.47
+++ OptimisticCreateIfNotExistsInterceptor.java 23 May 2007 15:22:03 -0000 1.48
@@ -48,8 +48,9 @@
nodeFactory = cache.getConfiguration().getRuntimeConfig().getNodeFactory();
}
- public Object invoke(MethodCall m) throws Throwable
+ public Object invoke(InvocationContext ctx) throws Throwable
{
+ MethodCall m = ctx.getMethodCall();
if (MethodDeclarations.isPutMethod(m.getMethodId()))
{
Object[] args = m.getArgs();
@@ -57,19 +58,19 @@
if (cache.peek(fqn, false) == null)
{
- createNode(fqn, false);
+ createNode(ctx, fqn, false);
}
}
else if (m.getMethodId() == MethodDeclarations.moveMethodLocal_id)
{
Object[] args = m.getArgs();
- move((Fqn) args[0], (Fqn) args[1]);
+ move(ctx, (Fqn) args[0], (Fqn) args[1]);
}
- return super.invoke(m);
+ return super.invoke(ctx);
}
- private void move(Fqn nodeFqn, Fqn newParent)
+ private void move(InvocationContext ctx, Fqn nodeFqn, Fqn newParent)
{
List<Fqn> fqns = new ArrayList<Fqn>();
fqns.add(newParent);
@@ -84,7 +85,7 @@
for (Fqn f : fqns)
{
- if (cache.peek(f, false) == null) createNode(f, true);
+ if (cache.peek(f, false) == null) createNode(ctx, f, true);
}
}
@@ -94,15 +95,14 @@
* @param targetFqn
* @throws CacheException
*/
- private void createNode(Fqn targetFqn, boolean suppressNotification) throws CacheException
+ private void createNode(InvocationContext ctx, Fqn targetFqn, boolean suppressNotification) throws CacheException
{
// we do nothing if targetFqn is null
if (targetFqn == null) return;
boolean debug = log.isDebugEnabled();
- InvocationContext ctx = cache.getInvocationContext();
- GlobalTransaction gtx = getGlobalTransaction();
+ GlobalTransaction gtx = getGlobalTransaction(ctx);
TransactionWorkspace workspace = getTransactionWorkspace(gtx);
WorkspaceNode workspaceNode;
@@ -235,8 +235,8 @@
Notifier n = cache.getNotifier();
for (Fqn temp : nodesCreated)
{
- n.notifyNodeCreated(temp, true, false);
- n.notifyNodeCreated(temp, false, false);
+ n.notifyNodeCreated(temp, true, ctx, false);
+ n.notifyNodeCreated(temp, false, ctx, false);
if (trace) log.trace("Notifying cache of node created in workspace " + temp);
}
}
1.30 +8 -6 JBossCache/src/org/jboss/cache/interceptors/OptimisticLockingInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: OptimisticLockingInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/OptimisticLockingInterceptor.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- OptimisticLockingInterceptor.java 29 Mar 2007 16:02:58 -0000 1.29
+++ OptimisticLockingInterceptor.java 23 May 2007 15:22:03 -0000 1.30
@@ -8,6 +8,7 @@
import org.jboss.cache.CacheException;
import org.jboss.cache.CacheSPI;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.lock.NodeLock;
import org.jboss.cache.marshall.MethodCall;
@@ -34,8 +35,9 @@
lockAcquisitionTimeout = cache.getConfiguration().getLockAcquisitionTimeout();
}
- public Object invoke(MethodCall m) throws Throwable
+ public Object invoke(InvocationContext ctx) throws Throwable
{
+ MethodCall m = ctx.getMethodCall();
Object retval = null;
//we are interested in the prepare/commit/rollback
@@ -44,7 +46,7 @@
{
case MethodDeclarations.optimisticPrepareMethod_id:
//try and acquire the locks - before passing on
- GlobalTransaction gtx = getGlobalTransaction();
+ GlobalTransaction gtx = getGlobalTransaction(ctx);
try
{
lockNodes(gtx);
@@ -66,7 +68,7 @@
}
// locks have acquired so lets pass on up
- retval = super.invoke(m);
+ retval = super.invoke(ctx);
break;
case MethodDeclarations.commitMethod_id:
case MethodDeclarations.rollbackMethod_id:
@@ -74,13 +76,13 @@
// we unlock last - even if an exception occurs
try
{
- retval = super.invoke(m);
+ retval = super.invoke(ctx);
}
finally
{
try
{
- unlock(getGlobalTransaction());
+ unlock(getGlobalTransaction(ctx));
}
catch (Exception e)
{
@@ -94,7 +96,7 @@
throw new CacheException("_lock() passed up the interceptor stack when Optimistic Locking is used. This is NOT supported.");
default:
//we do not care, just pass up the chain.
- retval = super.invoke(m);
+ retval = super.invoke(ctx);
break;
}
1.33 +4 -4 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.32
retrieving revision 1.33
diff -u -b -r1.32 -r1.33
--- InvalidationInterceptor.java 20 Apr 2007 12:10:12 -0000 1.32
+++ InvalidationInterceptor.java 23 May 2007 15:22:03 -0000 1.33
@@ -52,18 +52,18 @@
txTable = cache.getTransactionTable();
}
- public Object invoke(MethodCall m) throws Throwable
+ public Object invoke(InvocationContext ctx) throws Throwable
{
- InvocationContext ctx = cache.getInvocationContext();
+ MethodCall m = ctx.getMethodCall();
Option optionOverride = ctx.getOptionOverrides();
if (optionOverride != null && optionOverride.isCacheModeLocal() && ctx.getTransaction() == null)
{
// skip replication!!
- return super.invoke(m);
+ return super.invoke(ctx);
}
Transaction tx = ctx.getTransaction();
- Object retval = super.invoke(m);
+ Object retval = super.invoke(ctx);
if (log.isTraceEnabled()) log.trace("(" + cache.getLocalAddress() + ") method call " + m);
1.13 +1 -2 JBossCache/src/org/jboss/cache/interceptors/OptimisticInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: OptimisticInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/OptimisticInterceptor.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- OptimisticInterceptor.java 29 Mar 2007 16:02:58 -0000 1.12
+++ OptimisticInterceptor.java 23 May 2007 15:22:03 -0000 1.13
@@ -75,9 +75,8 @@
* @throws CacheException if the {@link org.jboss.cache.transaction.GlobalTransaction} or {@link javax.transaction.Transaction} associated with the
* {@link org.jboss.cache.InvocationContext} is null.
*/
- protected GlobalTransaction getGlobalTransaction() throws CacheException
+ protected GlobalTransaction getGlobalTransaction(InvocationContext ctx) throws CacheException
{
- InvocationContext ctx = cache.getInvocationContext();
Transaction tx = ctx.getTransaction();
if (tx == null) throw new CacheException("Transaction associated with the current invocation is null!");
GlobalTransaction gtx = ctx.getGlobalTransaction();
1.6 +5 -5 JBossCache/src/org/jboss/cache/interceptors/NotificationInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: NotificationInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/NotificationInterceptor.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- NotificationInterceptor.java 7 Feb 2007 22:06:41 -0000 1.5
+++ NotificationInterceptor.java 23 May 2007 15:22:03 -0000 1.6
@@ -16,12 +16,12 @@
*/
public class NotificationInterceptor extends BaseTransactionalContextInterceptor
{
- public Object invoke(MethodCall call) throws Throwable
+ public Object invoke(InvocationContext ctx) throws Throwable
{
+ MethodCall call = ctx.getMethodCall();
// should only kick in as a call returns.
- Object retval = super.invoke(call);
+ Object retval = super.invoke(ctx);
- InvocationContext ctx = cache.getInvocationContext();
Notifier n = cache.getNotifier();
// now, if we are in a transactional context, copy all local-context invocations to the transaction entry.
if (ctx.getGlobalTransaction() != null)
@@ -40,7 +40,7 @@
if (log.isTraceEnabled())
log.trace("Invoking notifications for this transaction. Notification set: " + entry.getCacheListenerEvents());
- n.invokeQueuedNotifications(entry.getCacheListenerEvents());
+ n.invokeQueuedNotifications(ctx, entry.getCacheListenerEvents());
}
else
{
@@ -68,7 +68,7 @@
else
{
// fire all queued up notifications now.
- n.invokeQueuedNotifications();
+ n.invokeQueuedNotifications(ctx);
}
return retval;
1.28 +9 -8 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.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- Interceptor.java 12 Mar 2007 18:13:46 -0000 1.27
+++ Interceptor.java 23 May 2007 15:22:03 -0000 1.28
@@ -24,6 +24,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheSPI;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.marshall.MethodCall;
import org.jboss.cache.marshall.MethodDeclarations;
@@ -39,7 +40,7 @@
* <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.27 2007/03/12 18:13:46 msurtani Exp $
+ * @version $Id: Interceptor.java,v 1.28 2007/05/23 15:22:03 msurtani Exp $
*/
public abstract class Interceptor implements InterceptorMBean
{
@@ -70,9 +71,9 @@
this.configuration = cache.getConfiguration();
}
- public Object invoke(MethodCall m) throws Throwable
+ public Object invoke(InvocationContext ctx) throws Throwable
{
- return next.invoke(m);
+ return next.invoke(ctx);
}
public boolean getStatisticsEnabled()
1.54 +19 -17 JBossCache/src/org/jboss/cache/interceptors/ActivationInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ActivationInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/ActivationInterceptor.java,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -b -r1.53 -r1.54
--- ActivationInterceptor.java 19 Mar 2007 19:03:34 -0000 1.53
+++ ActivationInterceptor.java 23 May 2007 15:22:03 -0000 1.54
@@ -1,6 +1,7 @@
package org.jboss.cache.interceptors;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.Modification;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.marshall.MethodCall;
@@ -25,7 +26,7 @@
* their attributes have been initialized and their children have been loaded in memory.
*
* @author <a href="mailto:{hmesha at novell.com}">{Hany Mesha}</a>
- * @version $Id: ActivationInterceptor.java,v 1.53 2007/03/19 19:03:34 msurtani Exp $
+ * @version $Id: ActivationInterceptor.java,v 1.54 2007/05/23 15:22:03 msurtani Exp $
*/
public class ActivationInterceptor extends CacheLoaderInterceptor implements ActivationInterceptorMBean
{
@@ -55,15 +56,15 @@
* @return
* @throws Throwable
*/
- public Object invoke(MethodCall m) throws Throwable
+ public Object invoke(InvocationContext ctx) throws Throwable
{
-
+ MethodCall m = ctx.getMethodCall();
Fqn fqn = null;
Object[] args = m.getArgs();
Object retval;
// First call the parent class to load the node
- retval = super.invoke(m);
+ retval = super.invoke(ctx);
// is this a node removal operation?
boolean removeData = false, nodeRemoved = false;
@@ -71,7 +72,7 @@
// Could be TRANSACTIONAL. If so, we register for TX completion (if we haven't done so yet)
if (tx_mgr != null && tx_mgr.getTransaction() != null)
{
- GlobalTransaction gtx = cache.getInvocationContext().getGlobalTransaction();
+ GlobalTransaction gtx = ctx.getGlobalTransaction();
switch (m.getMethodId())
{
case MethodDeclarations.commitMethod_id:
@@ -101,7 +102,7 @@
break;
case MethodDeclarations.optimisticPrepareMethod_id:
case MethodDeclarations.prepareMethod_id:
- prepareCacheLoader(gtx);
+ prepareCacheLoader(ctx);
break;
}
}
@@ -167,13 +168,13 @@
if (allInitialized(n))
{
log.debug("children all initialized");
- remove(fqn);
+ remove(ctx, fqn);
}
}
else if (loaderNoChildren(fqn))
{
if (log.isDebugEnabled()) log.debug("no children " + n);
- remove(fqn);
+ remove(ctx, fqn);
}
}
}
@@ -182,9 +183,9 @@
return retval;
}
- private void remove(Fqn fqn) throws Exception
+ private void remove(InvocationContext ctx, Fqn fqn) throws Exception
{
- cache.getNotifier().notifyNodeActivated(fqn, true, true);
+ cache.getNotifier().notifyNodeActivated(fqn, true, ctx, true);
loader.remove(fqn);
if (configuration.getExposeManagementStatistics() && getStatisticsEnabled())
{
@@ -256,18 +257,19 @@
{
int hint = 1;
if (args[hint] instanceof Boolean) return (Boolean) args[hint];
- for (int i = 0; i < args.length; i++)
+ for (Object arg : args)
{
- if (args[i] instanceof Boolean) return (Boolean) args[i];
+ if (arg instanceof Boolean) return (Boolean) arg;
}
return false;
}
- private void prepareCacheLoader(GlobalTransaction gtx) throws Exception
+ private void prepareCacheLoader(InvocationContext ctx) throws Exception
{
List modifications;
TransactionEntry entry;
int txActs = 0;
+ GlobalTransaction gtx = ctx.getGlobalTransaction();
entry = tx_table.get(gtx);
if (entry == null)
@@ -316,13 +318,13 @@
if (!n.getChildrenDirect().isEmpty() && allInitialized(n))
{
// children have been loaded, remove the node
- addRemoveMod(cache_loader_modifications, fqn);
+ addRemoveMod(ctx, cache_loader_modifications, fqn);
txActs++;
}
// doesn't have children, check the cache loader
else if (loaderNoChildren(fqn))
{
- addRemoveMod(cache_loader_modifications, fqn);
+ addRemoveMod(ctx, cache_loader_modifications, fqn);
txActs++;
}
}
@@ -340,11 +342,11 @@
}
}
- private void addRemoveMod(List l, Fqn fqn)
+ private void addRemoveMod(InvocationContext ctx, List l, Fqn fqn)
{
Modification mod = new Modification(Modification.ModificationType.REMOVE_NODE, fqn);
l.add(mod);
- cache.getNotifier().notifyNodeActivated(fqn, false, true);
+ cache.getNotifier().notifyNodeActivated(fqn, false, ctx, true);
}
}
1.48 +11 -9 JBossCache/src/org/jboss/cache/interceptors/CacheStoreInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: CacheStoreInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/CacheStoreInterceptor.java,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -b -r1.47 -r1.48
--- CacheStoreInterceptor.java 19 Mar 2007 19:03:34 -0000 1.47
+++ CacheStoreInterceptor.java 23 May 2007 15:22:03 -0000 1.48
@@ -3,6 +3,7 @@
import org.jboss.cache.CacheException;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.Modification;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.marshall.MethodCall;
@@ -27,7 +28,7 @@
* through the CacheLoader, either after each method call (no TXs), or at TX commit.
*
* @author Bela Ban
- * @version $Id: CacheStoreInterceptor.java,v 1.47 2007/03/19 19:03:34 msurtani Exp $
+ * @version $Id: CacheStoreInterceptor.java,v 1.48 2007/05/23 15:22:03 msurtani Exp $
*/
public class CacheStoreInterceptor extends BaseCacheLoaderInterceptor implements CacheStoreInterceptorMBean
{
@@ -55,16 +56,17 @@
* @return
* @throws Throwable
*/
- public Object invoke(MethodCall m) throws Throwable
+ public Object invoke(InvocationContext ctx) throws Throwable
{
+ MethodCall m = ctx.getMethodCall();
// if this is a shared cache loader and the call is of remote origin, pass up the chain. - Manik
// see http://www.jboss.com/index.html?module=bb&op=viewtopic&t=76090
- if (!cache.getInvocationContext().isOriginLocal() && loaderConfig.isShared())
+ if (!ctx.isOriginLocal() && loaderConfig.isShared())
{
log.trace("Passing up method call and bypassing this interceptor since the cache loader is shared and this call originated remotely.");
- return super.invoke(m);
+ return super.invoke(ctx);
}
Fqn fqn;
@@ -83,11 +85,11 @@
{
// we have a tx running.
log.trace("transactional so don't put stuff in the cloader yet.");
- GlobalTransaction gtx = cache.getInvocationContext().getGlobalTransaction();
+ GlobalTransaction gtx = ctx.getGlobalTransaction();
switch (m.getMethodId())
{
case MethodDeclarations.commitMethod_id:
- if (cache.getInvocationContext().isTxHasMods())
+ if (ctx.isTxHasMods())
{
// this is a commit call.
if (log.isTraceEnabled()) log.trace("Calling loader.commit() for gtx " + gtx);
@@ -119,7 +121,7 @@
}
break;
case MethodDeclarations.rollbackMethod_id:
- if (cache.getInvocationContext().isTxHasMods())
+ if (ctx.isTxHasMods())
{
// this is a rollback method
if (preparingTxs.containsKey(gtx))
@@ -144,7 +146,7 @@
}
// pass up the chain
- return super.invoke(m);
+ return super.invoke(ctx);
}
// if we're here we don't run in a transaction
@@ -195,7 +197,7 @@
}
// }
- retval = super.invoke(m);
+ retval = super.invoke(ctx);
// put() methods need to be applied *after* the call
// synchronized(this) {
1.42 +20 -27 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.41
retrieving revision 1.42
diff -u -b -r1.41 -r1.42
--- DataGravitatorInterceptor.java 17 Mar 2007 19:11:03 -0000 1.41
+++ DataGravitatorInterceptor.java 23 May 2007 15:22:03 -0000 1.42
@@ -62,24 +62,20 @@
syncCommunications = configuration.getCacheMode() == Configuration.CacheMode.REPL_SYNC || configuration.getCacheMode() == Configuration.CacheMode.INVALIDATION_SYNC;
}
- public Object invoke(MethodCall m) throws Throwable
+ public Object invoke(InvocationContext ctx) throws Throwable
{
- // if (isGravitationEnabled(cache.getInvocationContext()))
- // {
- // Option opt = cache.getInvocationContext().getOptionOverrides();
- // if (opt == null || !opt.isSuppressDataGravitation())
- // {
+ MethodCall m = ctx.getMethodCall();
if (log.isTraceEnabled()) log.trace("Invoked with method call " + m);
if (MethodDeclarations.isBlockUnblockMethod(m.getMethodId()))
{
- return super.invoke(m);
+ return super.invoke(ctx);
}
// Transactional lifecycle methods should be handled regardless of whether data gravitation is enabled or not.
if (!MethodDeclarations.isTransactionLifecycleMethod(m.getMethodId()))
{
- if (isGravitationEnabled(cache.getInvocationContext()) && MethodDeclarations.isGetMethod(m.getMethodId()))
+ if (isGravitationEnabled(ctx) && MethodDeclarations.isGetMethod(m.getMethodId()))
{
// test that the Fqn being requested exists locally in the cache.
Fqn fqn = extractFqn(m.getMethodId(), m.getArgs());
@@ -98,7 +94,7 @@
if (localBackupExists(fqn))
{
log.trace("Gravitating from local backup tree");
- data = localBackupGet(fqn);
+ data = localBackupGet(fqn, ctx);
}
else
{
@@ -117,7 +113,7 @@
createNode(data.backupData, false);
// Clean up the other nodes
- cleanBackupData(data);
+ cleanBackupData(data, ctx.getGlobalTransaction());
}
}
}
@@ -139,21 +135,21 @@
{
case MethodDeclarations.prepareMethod_id:
case MethodDeclarations.optimisticPrepareMethod_id:
- Object o = super.invoke(m);
- doPrepare(cache.getInvocationContext().getGlobalTransaction());
+ Object o = super.invoke(ctx);
+ doPrepare(ctx.getGlobalTransaction());
return o;
case MethodDeclarations.rollbackMethod_id:
- transactionMods.remove(cache.getInvocationContext().getGlobalTransaction());
- return super.invoke(m);
+ transactionMods.remove(ctx.getGlobalTransaction());
+ return super.invoke(ctx);
case MethodDeclarations.commitMethod_id:
- doCommit(cache.getInvocationContext().getGlobalTransaction());
- transactionMods.remove(cache.getInvocationContext().getGlobalTransaction());
- return super.invoke(m);
+ doCommit(ctx.getGlobalTransaction());
+ transactionMods.remove(ctx.getGlobalTransaction());
+ return super.invoke(ctx);
}
}
catch (Throwable throwable)
{
- transactionMods.remove(cache.getInvocationContext().getGlobalTransaction());
+ transactionMods.remove(ctx.getGlobalTransaction());
throw throwable;
}
}
@@ -164,7 +160,7 @@
// if (log.isTraceEnabled())
// log.trace("Suppressing data gravitation for this call.");
// }
- return super.invoke(m);
+ return super.invoke(ctx);
}
private boolean isGravitationEnabled(InvocationContext ctx)
@@ -269,7 +265,7 @@
return result;
}
- private void cleanBackupData(BackupData backup) throws Throwable
+ private void cleanBackupData(BackupData backup, GlobalTransaction gtx) throws Throwable
{
// MethodCall primaryDataCleanup, backupDataCleanup;
// if (buddyManager.isDataGravitationRemoveOnFind())
@@ -283,11 +279,10 @@
// backupDataCleanup = MethodCallFactory.create(MethodDeclarations.evictNodeMethodLocal, new Object[]{backup.backupFqn});
// }
- MethodCall cleanup = MethodCallFactory.create(MethodDeclarations.dataGravitationCleanupMethod, cache.getInvocationContext().getGlobalTransaction(), backup.primaryFqn, backup.backupFqn);
+ MethodCall cleanup = MethodCallFactory.create(MethodDeclarations.dataGravitationCleanupMethod, gtx, backup.primaryFqn, backup.backupFqn);
if (log.isTraceEnabled()) log.trace("Performing cleanup on [" + backup.primaryFqn + "]");
- GlobalTransaction gtx = cache.getInvocationContext().getGlobalTransaction();
if (gtx == null)
{
// broadcast removes
@@ -401,9 +396,7 @@
if (i == treeNodeSize - 1)
{
// set data
- cache.getInvocationContext().getOptionOverrides().setBypassInterceptorChain(true);
- cache.put(fqn, data);
- cache.getInvocationContext().getOptionOverrides().setBypassInterceptorChain(false);
+ child_node.putAllDirect(data);
}
n = child_node;
}
@@ -433,7 +426,7 @@
return exists;
}
- private BackupData localBackupGet(Fqn fqn) throws CacheException
+ private BackupData localBackupGet(Fqn fqn, InvocationContext ctx) throws CacheException
{
GravitateResult result = cache.gravitateData(fqn, true);// a "local" gravitation
boolean found = result.isDataFound();
@@ -448,7 +441,7 @@
{
// Remove locally only; the remote call will
// be broadcast later
- cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
+ ctx.getOptionOverrides().setCacheModeLocal(true);
cache.removeNode(backupFqn);
}
else
More information about the jboss-cvs-commits
mailing list