[jboss-cvs] JBossCache/src/org/jboss/cache/interceptors ...
Manik Surtani
msurtani at jboss.com
Wed Jul 19 17:34:44 EDT 2006
User: msurtani
Date: 06/07/19 17:34:44
Modified: src/org/jboss/cache/interceptors
ActivationInterceptor.java
BaseCacheLoaderInterceptor.java
BaseRpcInterceptor.java CacheLoaderInterceptor.java
CacheMgmtInterceptor.java
CacheStoreInterceptor.java CallInterceptor.java
CreateIfNotExistsInterceptor.java
DataGravitatorInterceptor.java
EvictionInterceptor.java Interceptor.java
InvalidationInterceptor.java
OptimisticCreateIfNotExistsInterceptor.java
OptimisticInterceptor.java
OptimisticLockingInterceptor.java
OptimisticNodeInterceptor.java
OptimisticReplicationInterceptor.java
OptimisticValidatorInterceptor.java
OrderedSynchronizationHandler.java
PassivationInterceptor.java
PessimisticLockInterceptor.java
ReplicationInterceptor.java TxInterceptor.java
UnlockInterceptor.java
Removed: src/org/jboss/cache/interceptors
BaseInterceptor.java
Log:
JBCACHE-657
JBCACHE-594
Revision Changes Path
1.29 +8 -9 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.28
retrieving revision 1.29
diff -u -b -r1.28 -r1.29
--- ActivationInterceptor.java 12 Jun 2006 20:24:31 -0000 1.28
+++ ActivationInterceptor.java 19 Jul 2006 21:34:43 -0000 1.29
@@ -22,7 +22,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.28 2006/06/12 20:24:31 msurtani Exp $
+ * @version $Id: ActivationInterceptor.java,v 1.29 2006/07/19 21:34:43 msurtani Exp $
*/
public class ActivationInterceptor extends CacheLoaderInterceptor implements ActivationInterceptorMBean {
@@ -44,7 +44,6 @@
* already loaded and its attributes already initialized, then remove it from
* the cache loader and notify the cache listeners that the node has been activated.
*
- * @param m
* @return
* @throws Throwable
*/
@@ -63,13 +62,13 @@
// 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 = getInvocationContext().getGlobalTransaction();
+ GlobalTransaction gtx = InvocationContext.getCurrent().getGlobalTransaction();
switch (m.getMethodId())
{
case MethodDeclarations.commitMethod_id:
if (hasModifications(args)) {
loader.commit(gtx);
- if (cache.getUseInterceptorMbeans()&& statsEnabled) {
+ if (configuration.isUseInterceptorMbeans() && getStatisticsEnabled()) {
Integer acts = (Integer)m_txActivations.get(gtx);
if (acts != null)
m_activations = m_activations + acts.intValue();
@@ -80,7 +79,7 @@
case MethodDeclarations.rollbackMethod_id:
if (hasModifications(args)) {
loader.rollback(gtx);
- if (cache.getUseInterceptorMbeans()&& statsEnabled)
+ if (configuration.isUseInterceptorMbeans() && getStatisticsEnabled())
m_txActivations.remove(gtx);
}
break;
@@ -134,7 +133,7 @@
// If the node is being removed, just remove it and don't perform
// activation processing
loader.remove(fqn);
- else if (fqn != null && cache.exists(fqn) && loader.exists(fqn)) {
+ else if (fqn != null && cache.hasChild(fqn) && loader.exists(fqn)) {
// Remove the node from the cache loader if it exists in memory,
// its attributes have been initialized, its children have been loaded,
// AND it was found in the cache loader (nodeLoaded = true).
@@ -160,7 +159,7 @@
private void remove(Fqn fqn) throws Exception {
loader.remove(fqn);
cache.notifyNodeActivate(fqn, false);
- if (cache.getUseInterceptorMbeans()&& statsEnabled)
+ if (configuration.isUseInterceptorMbeans() && getStatisticsEnabled())
m_activations++;
}
@@ -255,7 +254,7 @@
// AND it was found in the cache loader (nodeLoaded = true).
// Then notify the listeners that the node has been activated.
Fqn fqn = (Fqn)args[1];
- if(fqn != null && cache.exists(fqn) && loader.exists(fqn)) {
+ if(fqn != null && cache.hasChild(fqn) && loader.exists(fqn)) {
DataNode n=getNode(fqn); // don't load
// node not null and attributes have been loaded?
if (n != null && !n.containsKey(TreeCache.UNINITIALIZED)) {
@@ -277,7 +276,7 @@
}
if (cache_loader_modifications.size() > 0) {
loader.prepare(gtx, cache_loader_modifications, false);
- if (cache.getUseInterceptorMbeans() && statsEnabled && txActs > 0)
+ if (configuration.isUseInterceptorMbeans() && getStatisticsEnabled() && txActs > 0)
m_txActivations.put(gtx, new Integer(txActs));
}
}
1.6 +3 -3 JBossCache/src/org/jboss/cache/interceptors/BaseCacheLoaderInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: BaseCacheLoaderInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/BaseCacheLoaderInterceptor.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- BaseCacheLoaderInterceptor.java 22 Jun 2006 09:58:01 -0000 1.5
+++ BaseCacheLoaderInterceptor.java 19 Jul 2006 21:34:43 -0000 1.6
@@ -7,13 +7,13 @@
package org.jboss.cache.interceptors;
import EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap;
-import org.jboss.cache.TreeCache;
+import org.jboss.cache.CacheSPI;
import org.jboss.cache.loader.CacheLoader;
+import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.ConcurrentModificationException;
/**
* asbtract superclass for cache loader and cache store interceptors.
@@ -25,7 +25,7 @@
protected CacheLoader loader = null;
private Map lockMap = new ConcurrentReaderHashMap();
- public void setCache(TreeCache cache)
+ public void setCache(CacheSPI cache)
{
super.setCache(cache);
this.loader = cache.getCacheLoader();
1.16 +12 -51 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.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- BaseRpcInterceptor.java 6 Jun 2006 10:17:14 -0000 1.15
+++ BaseRpcInterceptor.java 19 Jul 2006 21:34:43 -0000 1.16
@@ -3,12 +3,14 @@
*/
package org.jboss.cache.interceptors;
-import org.jboss.cache.TreeCache;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.buddyreplication.BuddyManager;
+import org.jboss.cache.marshall.JBCMethodCall;
import org.jboss.cache.marshall.MethodCallFactory;
import org.jboss.cache.marshall.MethodDeclarations;
-import org.jboss.cache.marshall.JBCMethodCall;
import org.jgroups.blocks.MethodCall;
+import org.jgroups.Address;
import java.util.Iterator;
import java.util.List;
@@ -24,39 +26,13 @@
private BuddyManager buddyManager;
private boolean usingBuddyReplication;
- public void setCache(TreeCache cache)
+ public void setCache(CacheSPI cache)
{
- this.cache = cache;
+ super.setCache(cache);
buddyManager = cache.getBuddyManager();
usingBuddyReplication = buddyManager != null;
}
-//
-// public Object replicate(MethodCall method_call) throws Throwable {
-// try {
-// Interceptor.getInvocationContext().setOriginLocal(false);
-// return super.invoke(method_call);
-// }
-// finally {
-// Interceptor.getInvocationContext().setOriginLocal(true);
-// }
-// }
-//
-// public void replicate(List method_calls) throws Throwable {
-// try {
-// Interceptor.getInvocationContext().setOriginLocal(false);
-// MethodCall method_call;
-// for(Iterator it=method_calls.iterator(); it.hasNext();) {
-// method_call=(MethodCall)it.next();
-// super.invoke(method_call);
-// }
-// }
-// finally {
-// Interceptor.getInvocationContext().setOriginLocal(true);
-// }
-// }
-//
-
/**
* Checks whether any of the responses are exceptions. If yes, re-throws
* them (as exceptions or runtime exceptions).
@@ -88,12 +64,12 @@
replicateCall(null, call, sync);
}
- protected void replicateCall(List recipients, JBCMethodCall call, boolean sync) throws Throwable
+ protected void replicateCall(List<Address> recipients, JBCMethodCall call, boolean sync) throws Throwable
{
if (log.isTraceEnabled()) log.trace("Broadcasting call " + call + " to recipient list " + recipients);
- if (!sync && cache.getUseReplQueue() && cache.getReplQueue() != null && !usingBuddyReplication)
+ if (!sync && cache.getReplQueue() != null && !usingBuddyReplication)
{
putCallOnAsyncReplicationQueue( call );
}
@@ -101,18 +77,18 @@
{
if (usingBuddyReplication) call = buddyManager.transformFqns(call);
- List callRecipients = recipients;
+ List<Address> callRecipients = recipients;
if (callRecipients == null)
{
callRecipients = usingBuddyReplication ? buddyManager.getBuddyAddresses() : cache.getMembers();
}
- List rsps = cache.callRemoteMethods(callRecipients,
+ List rsps = cache.getRPCManager().callRemoteMethods(callRecipients,
MethodDeclarations.replicateMethod,
new Object[]{call},
sync, // is synchronised?
true, // ignore self?
- cache.getSyncReplTimeout());
+ configuration.getSyncReplTimeout());
if (log.isTraceEnabled())
{
log.trace("responses=" + rsps);
@@ -124,25 +100,10 @@
protected void putCallOnAsyncReplicationQueue(MethodCall call)
{
- // should this be:
- // cache.getReplQueue().add(call); // ??
if (log.isDebugEnabled()) log.debug("Putting call " + call + " on the replication queue.");
cache.getReplQueue().add(MethodCallFactory.create(MethodDeclarations.replicateMethod, new Object[]{call}));
}
- /* private void checkForNonSerializableArgs(MethodCall method_call) throws NotSerializableException {
- Object[] args=method_call.getArgs();
- if(args != null && args.length > 0) {
- for(int i=0; i < args.length; i++) {
- Object arg=args[i];
- if(arg != null) {
- if(!(arg instanceof Serializable || arg instanceof Externalizable))
- throw new NotSerializableException(arg.getClass().getName());
- }
- }
- }
- }*/
-
protected boolean containsModifications(JBCMethodCall m)
{
switch (m.getMethodId())
@@ -153,7 +114,7 @@
return mods.size() > 0;
case MethodDeclarations.commitMethod_id:
case MethodDeclarations.rollbackMethod_id:
- return getInvocationContext().isTxHasMods();
+ return InvocationContext.getCurrent().isTxHasMods();
default :
return false;
}
1.41 +18 -14 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.40
retrieving revision 1.41
diff -u -b -r1.40 -r1.41
--- CacheLoaderInterceptor.java 12 Jun 2006 20:24:31 -0000 1.40
+++ CacheLoaderInterceptor.java 19 Jul 2006 21:34:43 -0000 1.41
@@ -20,7 +20,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.40 2006/06/12 20:24:31 msurtani Exp $
+ * @version $Id: CacheLoaderInterceptor.java,v 1.41 2006/07/19 21:34:43 msurtani Exp $
*/
public class CacheLoaderInterceptor extends BaseCacheLoaderInterceptor implements CacheLoaderInterceptorMBean
{
@@ -36,7 +36,7 @@
*/
protected boolean useCacheStore = true;
- public void setCache(TreeCache cache)
+ public void setCache(CacheSPI cache)
{
super.setCache(cache);
isCustomCacheLoader = isCustomCacheLoaderConfigured( loader );
@@ -75,7 +75,6 @@
/**
* Makes sure a node is loaded into memory before a call executes (no-op if node is already loaded). If attributes
* of a node are to be accessed by the method, the attributes are also loaded.
- * @param m
* @return
* @throws Throwable
*/
@@ -88,7 +87,7 @@
Map nodeData = null;
boolean initNode = false; // keep uninitialized
Object key = null;
- InvocationContext ctx = getInvocationContext();
+ InvocationContext ctx = InvocationContext.getCurrent();
TransactionEntry entry = null;
GlobalTransaction gtx = null;
if ((gtx = ctx.getGlobalTransaction()) != null)
@@ -266,7 +265,7 @@
protected void lock(Fqn fqn, int lock_type, boolean recursive) throws Throwable {
- if (cache.isNodeLockingOptimistic()) return;
+ if (configuration.isNodeLockingOptimistic()) return;
MethodCall meth=MethodCallFactory.create(MethodDeclarations.lockMethodLocal,
new Object[]{fqn,
@@ -282,12 +281,13 @@
protected DataNode getNode(Fqn fqn) {
int treeNodeSize=fqn.size();
- TreeNode n = cache.getRoot();
- TreeNode child_node;
+ // root node
+ Node n = cache;
+ Node child_node;
Object child_name;
for(int i=0; i < treeNodeSize && n != null; i++) {
child_name=fqn.get(i);
- child_node=n.getChild(child_name);
+ child_node=n.getChild(new Fqn(child_name));
n=child_node;
}
return (DataNode) n;
@@ -300,7 +300,7 @@
*/
private boolean wasRemovedInTx(Fqn fqn)
{
- GlobalTransaction t = getInvocationContext().getGlobalTransaction();
+ GlobalTransaction t = InvocationContext.getCurrent().getGlobalTransaction();
if (t == null)
return false;
TransactionEntry entry = txTable.get(t);
@@ -354,23 +354,27 @@
int size = fqn.size();
- TreeNode n = cache.getRoot();
+ // root node
+ Node n = cache;
for (int i = 0; i < size; i++)
{
Object child_name = fqn.get(i);
tmp_fqn = new Fqn(tmp_fqn, child_name);
- TreeNode child_node = n.getChild(child_name);
+ Node child_node = n.getChild(new Fqn(child_name));
boolean last = (i == size - 1);
if (child_node == null)
{
if (last)
{
- child_node = n.createChild(child_name, tmp_fqn, n);
+ child_node = n.addChild(new Fqn(child_name));
+ //child_node = n.createChild(child_name, tmp_fqn, n);
}
else
{
- child_node = n.createChild(child_name, tmp_fqn, n, TreeCache.UNINITIALIZED, null);
+ //child_node = n.createChild(child_name, tmp_fqn, n, TreeCache.UNINITIALIZED, null);
+ child_node = n.addChild(new Fqn(child_name));
+ child_node.put(TreeCache.UNINITIALIZED, null);
}
if (entry != null)
@@ -416,7 +420,7 @@
boolean nodeExists = (nodeData != null);
if (log.isTraceEnabled()) log.trace("nodeExists " + nodeExists);
- if (cache.getUseInterceptorMbeans() && statsEnabled)
+ if (configuration.isUseInterceptorMbeans() && getStatisticsEnabled())
{
if (nodeExists)
m_cacheLoads++;
1.17 +14 -14 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.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- CacheMgmtInterceptor.java 18 Jul 2006 10:50:45 -0000 1.16
+++ CacheMgmtInterceptor.java 19 Jul 2006 21:34:43 -0000 1.17
@@ -21,15 +21,14 @@
*/
package org.jboss.cache.interceptors;
-import org.jboss.cache.*;
-import org.jboss.cache.marshall.MethodDeclarations;
+import EDU.oswego.cs.dl.util.concurrent.SynchronizedLong;
+import org.jboss.cache.CacheListener;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.Fqn;
import org.jboss.cache.marshall.JBCMethodCall;
-import org.jgroups.blocks.MethodCall;
+import org.jboss.cache.marshall.MethodDeclarations;
import org.jgroups.View;
-
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.Map;
+import org.jgroups.blocks.MethodCall;
import javax.management.ListenerNotFoundException;
import javax.management.MBeanNotificationInfo;
@@ -38,12 +37,14 @@
import javax.management.NotificationBroadcasterSupport;
import javax.management.NotificationFilter;
import javax.management.NotificationListener;
-import EDU.oswego.cs.dl.util.concurrent.SynchronizedLong;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
/**
* Captures cache management statistics
* @author Jerry Gauthier
- * @version $Id: CacheMgmtInterceptor.java,v 1.16 2006/07/18 10:50:45 msurtani Exp $
+ * @version $Id: CacheMgmtInterceptor.java,v 1.17 2006/07/19 21:34:43 msurtani Exp $
*/
public class CacheMgmtInterceptor extends Interceptor implements CacheMgmtInterceptorMBean, NotificationBroadcaster
{
@@ -100,7 +101,7 @@
private CacheMgmtListener m_listener = new CacheMgmtListener();
private NotificationBroadcasterSupport m_broadcaster = null;
- public void setCache(TreeCache cache)
+ public void setCache(CacheSPI cache)
{
super.setCache(cache);
m_broadcaster = new NotificationBroadcasterSupport();
@@ -108,7 +109,6 @@
/**
* Pass the method on and capture cache statistics
- * @param
* @return
* @throws Throwable
*/
@@ -125,7 +125,7 @@
// if statistics not enabled, execute the method and return
- if (!statsEnabled)
+ if (!getStatisticsEnabled())
return super.invoke(m);
long t1, t2;
@@ -299,14 +299,14 @@
if (emit)
{
m_listeners++;
- cache.addTreeCacheListener(m_listener);
+ cache.addCacheListener(m_listener);
}
else
{
m_listeners--;
if (m_listeners <= 0)
{
- cache.removeTreeCacheListener(m_listener);
+ cache.removeCacheListener(m_listener);
}
}
}
1.27 +15 -16 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.26
retrieving revision 1.27
diff -u -b -r1.26 -r1.27
--- CacheStoreInterceptor.java 12 Jun 2006 20:24:31 -0000 1.26
+++ CacheStoreInterceptor.java 19 Jul 2006 21:34:43 -0000 1.27
@@ -1,15 +1,16 @@
package org.jboss.cache.interceptors;
import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap;
+import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.GlobalTransaction;
import org.jboss.cache.Modification;
import org.jboss.cache.TransactionEntry;
import org.jboss.cache.TransactionTable;
-import org.jboss.cache.TreeCache;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.marshall.MethodDeclarations;
import org.jboss.cache.marshall.JBCMethodCall;
+import org.jboss.cache.marshall.MethodDeclarations;
import org.jgroups.blocks.MethodCall;
import javax.transaction.TransactionManager;
@@ -25,7 +26,7 @@
* Writes modifications back to the store on the way out: stores modifications back
* through the CacheLoader, either after each method call (no TXs), or at TX commit.
* @author Bela Ban
- * @version $Id: CacheStoreInterceptor.java,v 1.26 2006/06/12 20:24:31 msurtani Exp $
+ * @version $Id: CacheStoreInterceptor.java,v 1.27 2006/07/19 21:34:43 msurtani Exp $
*/
public class CacheStoreInterceptor extends BaseCacheLoaderInterceptor implements CacheStoreInterceptorMBean
{
@@ -37,7 +38,7 @@
private Map preparingTxs = new ConcurrentHashMap();
private long m_cacheStores = 0;
- public void setCache(TreeCache cache) {
+ public void setCache(CacheSPI cache) {
super.setCache(cache);
this.loaderConfig = cache.getCacheLoaderManager().getCacheLoaderConfig();
tx_mgr=cache.getTransactionManager();
@@ -59,15 +60,13 @@
// 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 (!getInvocationContext().isOriginLocal() && loaderConfig.isShared()) {
+ if (!InvocationContext.getCurrent().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);
}
Fqn fqn;
- Map attributes;
Object key, value;
- Method meth=m.getMethod();
Object[] args=m.getArgs();
Object retval, tmp_retval=null;
boolean use_tmp_retval=false;
@@ -80,11 +79,11 @@
if (tx_mgr != null && tx_mgr.getTransaction() != null) {
// we have a tx running.
log.trace("transactional so don't put stuff in the cloader yet.");
- GlobalTransaction gtx = getInvocationContext().getGlobalTransaction();
+ GlobalTransaction gtx = InvocationContext.getCurrent().getGlobalTransaction();
switch (m.getMethodId())
{
case MethodDeclarations.commitMethod_id:
- if (getInvocationContext().isTxHasMods()) {
+ if (InvocationContext.getCurrent().isTxHasMods()) {
// this is a commit call.
if (log.isTraceEnabled()) log.trace("Calling loader.commit() for gtx " + gtx);
// sync call (a write) on the loader
@@ -99,7 +98,7 @@
releaseLoaderLocks(fqnsModified);
preparingTxs.remove(gtx);
}
- if (cache.getUseInterceptorMbeans()&& statsEnabled) {
+ if (configuration.isUseInterceptorMbeans() && getStatisticsEnabled()) {
Integer puts = (Integer)m_txStores.get(gtx);
if (puts != null)
m_cacheStores = m_cacheStores + puts.intValue();
@@ -111,14 +110,14 @@
}
break;
case MethodDeclarations.rollbackMethod_id:
- if (getInvocationContext().isTxHasMods()) {
+ if (InvocationContext.getCurrent().isTxHasMods()) {
// this is a rollback method
if (preparingTxs.containsKey(gtx))
{
preparingTxs.remove(gtx);
loader.rollback(gtx);
}
- if (cache.getUseInterceptorMbeans()&& statsEnabled)
+ if (configuration.isUseInterceptorMbeans() && getStatisticsEnabled())
m_txStores.remove(gtx);
}
else {
@@ -203,7 +202,7 @@
{
releaseLoaderLock(fqn);
}
- if (cache.getUseInterceptorMbeans()&& statsEnabled)
+ if (configuration.isUseInterceptorMbeans() && getStatisticsEnabled())
m_cacheStores++;
break;
case MethodDeclarations.putKeyValMethodLocal_id:
@@ -220,7 +219,7 @@
{
releaseLoaderLock(fqn);
}
- if (cache.getUseInterceptorMbeans()&& statsEnabled)
+ if (configuration.isUseInterceptorMbeans() && getStatisticsEnabled())
m_cacheStores++;
break;
}
@@ -284,7 +283,7 @@
JBCMethodCall methodCall=(JBCMethodCall) it.next();
Modification mod=convertMethodCallToModification(methodCall);
cache_loader_modifications.add(mod);
- if (cache.getUseInterceptorMbeans()&& statsEnabled) {
+ if (configuration.isUseInterceptorMbeans() && getStatisticsEnabled()) {
if ( (mod.getType() == Modification.PUT_DATA) ||
(mod.getType() == Modification.PUT_DATA_ERASE) ||
(mod.getType() == Modification.PUT_KEY_VALUE) )
@@ -295,7 +294,7 @@
if(cache_loader_modifications.size() > 0) {
loader.prepare(gtx, cache_loader_modifications, onePhase);
preparingTxs.put(gtx, gtx);
- if (cache.getUseInterceptorMbeans()&& statsEnabled && txPuts > 0)
+ if (configuration.isUseInterceptorMbeans() && getStatisticsEnabled() && txPuts > 0)
m_txStores.put(gtx, new Integer(txPuts));
}
}
1.10 +8 -7 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.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- CallInterceptor.java 12 Jun 2006 20:24:31 -0000 1.9
+++ CallInterceptor.java 19 Jul 2006 21:34:43 -0000 1.10
@@ -1,13 +1,14 @@
package org.jboss.cache.interceptors;
+import org.jboss.cache.CacheSPI;
import org.jboss.cache.GlobalTransaction;
import org.jboss.cache.InvocationContext;
-import org.jboss.cache.TreeCache;
import org.jboss.cache.config.Option;
import org.jboss.cache.marshall.MethodDeclarations;
import org.jgroups.blocks.MethodCall;
import javax.transaction.Transaction;
+import java.lang.reflect.Method;
import java.util.HashSet;
import java.util.Set;
@@ -20,11 +21,11 @@
* this interceptor unless it is a call the OptimisticNodeInterceptor knows nothing about.
*
* @author Bela Ban
- * @version $Id: CallInterceptor.java,v 1.9 2006/06/12 20:24:31 msurtani Exp $
+ * @version $Id: CallInterceptor.java,v 1.10 2006/07/19 21:34:43 msurtani Exp $
*/
public class CallInterceptor extends Interceptor
{
- private static Set transactionLifecycleMethods = new HashSet();
+ private static Set<Method> transactionLifecycleMethods = new HashSet<Method>();
static
{
transactionLifecycleMethods.add(MethodDeclarations.commitMethod);
@@ -34,7 +35,7 @@
}
- public void setCache(TreeCache cache)
+ public void setCache(CacheSPI cache)
{
super.setCache(cache);
}
@@ -61,7 +62,7 @@
if (log.isTraceEnabled()) log.trace("Suppressing invocation of method " + m + " on cache.");
}
- InvocationContext ctx = getInvocationContext();
+ InvocationContext ctx = InvocationContext.getCurrent();
Transaction tx = ctx.getTransaction();
if (tx != null && isValid(tx))
{
@@ -77,7 +78,7 @@
// in case a method has been invoked that the OptimisticNodeInterceptor knows nothing about, it will
// filter down here.
- if (!cache.isNodeLockingOptimistic() && MethodDeclarations.isCrudMethod(m.getMethod()))
+ if (!configuration.isNodeLockingOptimistic() && MethodDeclarations.isCrudMethod(m.getMethod()))
{
// if method is a CRUD (Create/Remove/Update/Delete) method: add it to the modification
// list, otherwise skip (e.g. get() is not added)
@@ -93,7 +94,7 @@
}
else
{
- Option o = getInvocationContext().getOptionOverrides();
+ Option o = InvocationContext.getCurrent().getOptionOverrides();
if (o != null && o.isCacheModeLocal())
{
log.debug("Not adding method to modification list since cache mode local is set.");
1.13 +9 -8 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.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- CreateIfNotExistsInterceptor.java 8 Jun 2006 22:00:35 -0000 1.12
+++ CreateIfNotExistsInterceptor.java 19 Jul 2006 21:34:43 -0000 1.13
@@ -16,7 +16,7 @@
* Handles putXXX() methods: if the given node doesn't exist, it will be created
* (depending on the create_if_not_exists argument)
* @author Bela Ban
- * @version $Id: CreateIfNotExistsInterceptor.java,v 1.12 2006/06/08 22:00:35 msurtani Exp $
+ * @version $Id: CreateIfNotExistsInterceptor.java,v 1.13 2006/07/19 21:34:43 msurtani Exp $
* @deprecated This code is not used anymore and will be removed in a future release
*/
public class CreateIfNotExistsInterceptor extends Interceptor {
@@ -41,7 +41,7 @@
}
- public void setCache(TreeCache cache) {
+ public void setCache(CacheSPI cache) {
super.setCache(cache);
}
@@ -136,8 +136,8 @@
try {
addFqnToPutList(fqn, put_lock);
findAndBlockOnRemove(fqn, remove_lock);
- if(!cache.exists(fqn)) {
- GlobalTransaction gtx=cache.getCurrentTransaction();
+ if(!cache.hasChild(fqn)) {
+ GlobalTransaction gtx=InvocationContext.getCurrent().getGlobalTransaction();
if(log.isTraceEnabled())
log.trace("creating node " + fqn);
createNode(fqn, gtx);
@@ -322,20 +322,21 @@
}
private void createNode(Fqn fqn, GlobalTransaction tx) {
- TreeNode n, child_node;
+ Node n, child_node;
Object child_name;
Fqn tmp_fqn=Fqn.ROOT;
if(fqn == null) return;
synchronized(this) {
int treeNodeSize=fqn.size();
- n=cache.getRoot();
+ n=cache;
for(int i=0; i < treeNodeSize; i++) {
child_name=fqn.get(i);
tmp_fqn=new Fqn(tmp_fqn, child_name);
- child_node=n.getChild(child_name);
+ child_node=n.getChild(new Fqn(child_name));
if(child_node == null) {
- child_node=n.createChild(child_name, tmp_fqn, n);
+ //child_node=n.createChild(child_name, tmp_fqn, n);
+ child_node=n.addChild(new Fqn(child_name));
if(tx != null) {
MethodCall undo_op=MethodCallFactory.create(MethodDeclarations.removeNodeMethodLocal,
new Object[]{tx, tmp_fqn, Boolean.FALSE});
1.18 +37 -33 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.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- DataGravitatorInterceptor.java 10 Jul 2006 16:28:50 -0000 1.17
+++ DataGravitatorInterceptor.java 19 Jul 2006 21:34:43 -0000 1.18
@@ -10,19 +10,22 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheException;
+import org.jboss.cache.CacheSPI;
import org.jboss.cache.DataNode;
import org.jboss.cache.Fqn;
import org.jboss.cache.GlobalTransaction;
import org.jboss.cache.InvocationContext;
+import org.jboss.cache.Node;
import org.jboss.cache.TransactionEntry;
-import org.jboss.cache.TreeCache;
import org.jboss.cache.buddyreplication.BuddyManager;
+import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Option;
import org.jboss.cache.loader.NodeData;
+import org.jboss.cache.marshall.JBCMethodCall;
import org.jboss.cache.marshall.MethodCallFactory;
import org.jboss.cache.marshall.MethodDeclarations;
-import org.jboss.cache.marshall.JBCMethodCall;
import org.jboss.invocation.MarshalledValueInputStream;
+import org.jgroups.Address;
import org.jgroups.blocks.GroupRequest;
import org.jgroups.blocks.MethodCall;
@@ -32,7 +35,6 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Vector;
/**
* The Data Gravitator interceptor intercepts cache misses and attempts t gravitate data from other parts of the cluster.
@@ -53,19 +55,19 @@
private Log log = LogFactory.getLog(DataGravitatorInterceptor.class);
private Map transactionMods = new ConcurrentHashMap();
- public void setCache(TreeCache cache)
+ public void setCache(CacheSPI cache)
{
super.setCache(cache);
this.buddyManager = cache.getBuddyManager();
- syncCommunications = cache.getCacheModeInternal() == TreeCache.REPL_SYNC;
+ syncCommunications = configuration.getCacheModeInt() == Configuration.CacheMode.REPL_SYNC || configuration.getCacheModeInt() == Configuration.CacheMode.INVALIDATION_SYNC;
}
public Object invoke(MethodCall call) throws Throwable
{
JBCMethodCall m = (JBCMethodCall) call;
-// if (isGravitationEnabled(getInvocationContext()))
+// if (isGravitationEnabled(InvocationContext.getCurrent()))
// {
-// Option opt = getInvocationContext().getOptionOverrides();
+// Option opt = InvocationContext.getCurrent().getOptionOverrides();
// if (opt == null || !opt.isSuppressDataGravitation())
// {
if (log.isTraceEnabled()) log.trace("Invoked with method call " + m);
@@ -73,7 +75,7 @@
// Transactional lifecycle methods should be handled regardless of whether data gravitation is enabled or not.
if (!isTransactionLifecycleMethod(m))
{
- if (isGravitationEnabled(getInvocationContext()))
+ if (isGravitationEnabled(InvocationContext.getCurrent()))
{
// test that the Fqn being requested exists locally in the cache.
Fqn fqn = extractFqn(m.getMethodId(), m.getArgs());
@@ -84,7 +86,7 @@
}
else
{
- if (!cache.exists(fqn))
+ if (!cache.hasChild(fqn))
{
BackupData data = null;
@@ -132,20 +134,20 @@
case MethodDeclarations.prepareMethod_id:
case MethodDeclarations.optimisticPrepareMethod_id:
Object o = super.invoke(m);
- doPrepare(getInvocationContext().getGlobalTransaction());
+ doPrepare(InvocationContext.getCurrent().getGlobalTransaction());
return o;
case MethodDeclarations.rollbackMethod_id:
- transactionMods.remove(getInvocationContext().getGlobalTransaction());
+ transactionMods.remove(InvocationContext.getCurrent().getGlobalTransaction());
return super.invoke(m);
case MethodDeclarations.commitMethod_id:
- doCommit(getInvocationContext().getGlobalTransaction());
- transactionMods.remove(getInvocationContext().getGlobalTransaction());
+ doCommit(InvocationContext.getCurrent().getGlobalTransaction());
+ transactionMods.remove(InvocationContext.getCurrent().getGlobalTransaction());
return super.invoke(m);
}
}
catch (Throwable throwable)
{
- transactionMods.remove(getInvocationContext().getGlobalTransaction());
+ transactionMods.remove(InvocationContext.getCurrent().getGlobalTransaction());
throw throwable;
}
}
@@ -182,13 +184,13 @@
JBCMethodCall prepare;
List mods = new ArrayList(1);
mods.add(cleanup);
- if (cache.isNodeLockingOptimistic())
+ if (configuration.isNodeLockingOptimistic())
{
prepare = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, new Object[]{gtx, mods, null, cache.getLocalAddress(), Boolean.FALSE});
}
else
{
- prepare = MethodCallFactory.create(MethodDeclarations.prepareMethod, new Object[]{gtx, mods, cache.getLocalAddress(), cache.getCacheModeInternal() == TreeCache.REPL_SYNC || cache.getCacheModeInternal() == TreeCache.INVALIDATION_SYNC ? Boolean.FALSE : Boolean.TRUE});
+ prepare = MethodCallFactory.create(MethodDeclarations.prepareMethod, new Object[]{gtx, mods, cache.getLocalAddress(), syncCommunications});
}
replicateCall(getMembersOutsideBuddyGroup(), prepare, syncCommunications);
@@ -212,9 +214,9 @@
}
}
- private List getMembersOutsideBuddyGroup()
+ private List<Address> getMembersOutsideBuddyGroup()
{
- List members = new ArrayList(cache.getMembers());
+ List<Address> members = new ArrayList<Address>(cache.getMembers());
members.remove(cache.getLocalAddress());
members.removeAll(buddyManager.getBuddyAddresses());
return members;
@@ -233,7 +235,7 @@
log.trace("Got response " + resp[0]);
List nodes = null;
- if (cache.getUseRegionBasedMarshalling())
+ if (configuration.isUseRegionBasedMarshalling())
{
ClassLoader cl = Thread.currentThread().getContextClassLoader();
try
@@ -277,11 +279,11 @@
// backupDataCleanup = MethodCallFactory.create(MethodDeclarations.evictNodeMethodLocal, new Object[]{backup.backupFqn});
// }
- JBCMethodCall cleanup = MethodCallFactory.create(MethodDeclarations.dataGravitationCleanupMethod, new Object[]{getInvocationContext().getGlobalTransaction(), backup.primaryFqn, backup.backupFqn});
+ JBCMethodCall cleanup = MethodCallFactory.create(MethodDeclarations.dataGravitationCleanupMethod, new Object[]{InvocationContext.getCurrent().getGlobalTransaction(), backup.primaryFqn, backup.backupFqn});
if (log.isTraceEnabled()) log.trace("Performing cleanup on [" +backup.primaryFqn+ "]");
- GlobalTransaction gtx = getInvocationContext().getGlobalTransaction();
+ GlobalTransaction gtx = InvocationContext.getCurrent().getGlobalTransaction();
if (gtx == null)
{
// broadcast removes
@@ -305,11 +307,11 @@
private Object[] gravitateData(Fqn fqn) throws Exception
{
if (log.isTraceEnabled()) log.trace("cache=" + cache.getLocalAddress() + "; requesting data gravitation for Fqn " + fqn);
- Vector mbrs = cache.getMembers();
+ List<Address> mbrs = cache.getMembers();
Boolean searchSubtrees = (buddyManager.isDataGravitationSearchBackupTrees() ? Boolean.TRUE : Boolean.FALSE );
- Boolean marshal = cache.getUseRegionBasedMarshalling() ? Boolean.TRUE : Boolean.FALSE;
+ Boolean marshal = configuration.isUseRegionBasedMarshalling() ? Boolean.TRUE : Boolean.FALSE;
MethodCall dGrav = MethodCallFactory.create(MethodDeclarations.dataGravitationMethod, new Object[]{fqn, searchSubtrees, marshal});
- List resps = cache.callRemoteMethods(mbrs, dGrav, GroupRequest.GET_FIRST, true, buddyManager.getBuddyCommunicationTimeout());
+ List resps = cache.getRPCManager().callRemoteMethods(mbrs, dGrav, GroupRequest.GET_FIRST, true, buddyManager.getBuddyCommunicationTimeout());
if (resps == null)
{
log.error("No replies to call " + dGrav + ". Perhaps we're alone in the cluster?");
@@ -341,7 +343,7 @@
break;
}
}
- else if (!cache.getUseRegionBasedMarshalling())
+ else if (!configuration.isUseRegionBasedMarshalling())
{
// Null is OK if we are using region based marshalling; it
// is what is returned if a region is inactive. Otherwise
@@ -359,14 +361,14 @@
private void createNode(boolean localOnly, List nodeData) throws CacheException
{
Iterator nodes = nodeData.iterator();
- GlobalTransaction gtx = getInvocationContext().getGlobalTransaction();
+ GlobalTransaction gtx = InvocationContext.getCurrent().getGlobalTransaction();
while (nodes.hasNext())
{
NodeData data = (NodeData) nodes.next();
if (localOnly)
{
- if (!cache.exists(data.getFqn()))
+ if (!cache.hasChild(data.getFqn()))
{
createNodes(gtx, data.getFqn(), data.getAttributes());
}
@@ -382,11 +384,11 @@
{
int treeNodeSize;
if ((treeNodeSize=fqn.size()) == 0) return;
- DataNode n=cache.getRoot();
+ Node n=cache;
for(int i=0; i < treeNodeSize; i++)
{
- Object child_name=fqn.get(i);
- DataNode child_node=(DataNode) n.getOrCreateChild(child_name, gtx, true);
+ Object child_name = fqn.get(i);
+ Node child_node = n.addChild(new Fqn(child_name));
if(child_node == null)
{
if(log.isTraceEnabled()) log.trace("failed to find or create child " + child_name + " of node " + n.getFqn());
@@ -395,7 +397,9 @@
if (i == treeNodeSize - 1)
{
// set data
- cache._put(gtx, fqn, data, true);
+ // TODO: This needs to bypass the interceptor stack. Old code used an _put()
+ //cache._put(gtx, fqn, data, true);
+ cache.put(fqn, data);
}
n = child_node;
}
@@ -420,7 +424,7 @@
{
DataNode node = (DataNode) backupRoots.next();
Fqn newSearchFqn = new Fqn(node.getFqn(), fqn);
- exists = cache.exists(newSearchFqn);
+ exists = cache.hasChild(newSearchFqn);
if (exists) break;
}
@@ -449,7 +453,7 @@
}
else
{
- cache.evict(backupFqn);
+ cache.evict(backupFqn, true);
}
}
1.4 +3 -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.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- EvictionInterceptor.java 16 May 2006 22:42:26 -0000 1.3
+++ EvictionInterceptor.java 19 Jul 2006 21:34:43 -0000 1.4
@@ -9,8 +9,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
-import org.jboss.cache.TreeCache;
import org.jboss.cache.eviction.EvictedEventNode;
import org.jboss.cache.eviction.Region;
import org.jboss.cache.eviction.RegionManager;
@@ -26,7 +26,7 @@
* This interceptor is used to handle eviction events.
*
* @author Daniel Huang
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
public class EvictionInterceptor extends Interceptor
{
@@ -73,7 +73,7 @@
this.regionManager = regionManager;
}
- public void setCache(TreeCache cache)
+ public void setCache(CacheSPI cache)
{
super.setCache(cache);
this.regionManager = cache.getEvictionRegionManager();
1.16 +12 -27 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.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- Interceptor.java 6 Jun 2006 10:17:14 -0000 1.15
+++ Interceptor.java 19 Jul 2006 21:34:43 -0000 1.16
@@ -23,10 +23,10 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.TreeCache;
-import org.jboss.cache.marshall.MethodDeclarations;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.config.Configuration;
import org.jboss.cache.marshall.JBCMethodCall;
+import org.jboss.cache.marshall.MethodDeclarations;
import org.jgroups.blocks.MethodCall;
import javax.transaction.Status;
@@ -39,13 +39,14 @@
* Class representing an interceptor.
* <em>Note that this will be replaced by {@link org.jboss.aop.advice.Interceptor} in one of the next releases</em>
* @author Bela Ban
- * @version $Id: Interceptor.java,v 1.15 2006/06/06 10:17:14 msurtani Exp $
+ * @version $Id: Interceptor.java,v 1.16 2006/07/19 21:34:43 msurtani Exp $
*/
public abstract class Interceptor implements InterceptorMBean {
- Interceptor next=null;
- TreeCache cache=null;
- Log log=null;
- boolean statsEnabled = true;
+ protected Interceptor next=null;
+ protected CacheSPI cache;
+ protected Log log=null;
+ protected Configuration configuration;
+ private boolean statsEnabled = false;
public Interceptor() {
log=LogFactory.getLog(getClass());
@@ -60,8 +61,10 @@
return next;
}
- public void setCache(TreeCache cache) {
+ public void setCache(CacheSPI cache)
+ {
this.cache=cache;
+ this.configuration = cache.getConfiguration();
}
public Object invoke(MethodCall m) throws Throwable {
@@ -127,24 +130,6 @@
}
/**
- * Sets the invocation context
- * @param invocationContext
- */
- public void setInvocationContext(InvocationContext invocationContext)
- {
- cache.setInvocationContext( invocationContext );
- }
-
- /**
- * Retrieves an InvocationContext.
- * @return the context for the current invocation
- */
- public InvocationContext getInvocationContext()
- {
- return cache.getInvocationContext();
- }
-
- /**
* This only works for prepare() and optimisticPrepare() method calls.
* @param m
*/
1.20 +14 -22 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.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- InvalidationInterceptor.java 12 Jun 2006 20:24:31 -0000 1.19
+++ InvalidationInterceptor.java 19 Jul 2006 21:34:43 -0000 1.20
@@ -8,6 +8,7 @@
import org.jboss.cache.*;
import org.jboss.cache.config.Option;
+import org.jboss.cache.config.Configuration;
import org.jboss.cache.marshall.MethodCallFactory;
import org.jboss.cache.marshall.MethodDeclarations;
import org.jboss.cache.marshall.JBCMethodCall;
@@ -33,22 +34,19 @@
*/
public class InvalidationInterceptor extends BaseRpcInterceptor implements InvalidationInterceptorMBean
{
- private boolean synchronous;
private long m_invalidations = 0;
protected TransactionTable txTable;
- public void setCache(TreeCache cache)
+ public void setCache(CacheSPI cache)
{
super.setCache(cache);
- // may as well cache this test ...
- synchronous = cache.getCacheModeInternal() == TreeCache.INVALIDATION_SYNC;
txTable=cache.getTransactionTable();
}
public Object invoke(MethodCall call) throws Throwable
{
JBCMethodCall m = (JBCMethodCall) call;
- InvocationContext ctx = getInvocationContext();
+ InvocationContext ctx = InvocationContext.getCurrent();
Option optionOverride = ctx.getOptionOverrides();
if (optionOverride != null && optionOverride.isCacheModeLocal() && ctx.getTransaction() == null)
{
@@ -93,13 +91,13 @@
GlobalTransaction gtx = ctx.getGlobalTransaction();
TransactionEntry entry = txTable.get(gtx);
if (entry == null) throw new IllegalStateException("cannot find transaction entry for " + gtx);
- List modifications = new LinkedList(entry.getModifications());
+ List<MethodCall> modifications = new LinkedList<MethodCall>(entry.getModifications());
if (modifications.size() > 0)
{
try
{
- invalidateModifications(modifications, cache.isNodeLockingOptimistic() ? getWorkspace(gtx) : null);
+ invalidateModifications(modifications, configuration.isNodeLockingOptimistic() ? getWorkspace(gtx) : null);
}
catch (Throwable t)
{
@@ -144,7 +142,7 @@
protected void invalidateAcrossCluster(Fqn fqn, TransactionWorkspace workspace) throws Throwable
{
// increment invalidations counter if statistics maintained
- if (cache.getUseInterceptorMbeans()&& statsEnabled)
+ if (configuration.isUseInterceptorMbeans() && getStatisticsEnabled())
m_invalidations++;
// only propagate version details if we're using explicit versioning.
@@ -154,18 +152,14 @@
if (log.isDebugEnabled()) log.debug("Cache ["+cache.getLocalAddress()+"] replicating " + call);
// voila, invalidated!
- replicateCall(call, synchronous);
+ replicateCall(call, configuration.getCacheModeInt() == Configuration.CacheMode.INVALIDATION_SYNC);
}
- protected void invalidateModifications(List modifications, TransactionWorkspace workspace) throws Throwable
+ protected void invalidateModifications(List<MethodCall> modifications, TransactionWorkspace workspace) throws Throwable
{
// optimise the calls list here.
- Iterator modifiedFqns = optimisedIterator(modifications);
- while (modifiedFqns.hasNext())
- {
- Fqn fqn = (Fqn) modifiedFqns.next();
- invalidateAcrossCluster(fqn, workspace);
- }
+ Set<Fqn> modifiedFqns = optimisedIterator(modifications);
+ for (Fqn fqn : modifiedFqns) invalidateAcrossCluster(fqn, workspace);
}
protected TransactionWorkspace getWorkspace(GlobalTransaction gtx)
@@ -187,18 +181,16 @@
* @param list
* @return Iterator containing a unique set of Fqns of crud methods in this tx
*/
- protected Iterator optimisedIterator(List list)
+ protected Set<Fqn> optimisedIterator(List<MethodCall> list)
{
- Set fqns = new HashSet();
- Iterator listIter = list.iterator();
- while (listIter.hasNext())
+ Set<Fqn> fqns = new HashSet<Fqn>();
+ for (MethodCall mc : list)
{
- MethodCall mc = (MethodCall) listIter.next();
if (MethodDeclarations.isCrudMethod(mc.getMethod()))
{
fqns.add(findFqn(mc.getArgs()));
}
}
- return fqns.iterator();
+ return fqns;
}
}
1.22 +4 -9 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.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- OptimisticCreateIfNotExistsInterceptor.java 30 May 2006 16:33:02 -0000 1.21
+++ OptimisticCreateIfNotExistsInterceptor.java 19 Jul 2006 21:34:43 -0000 1.22
@@ -35,11 +35,6 @@
putMethods.add(MethodDeclarations.putKeyValMethodLocal);
}
- public void setCache(TreeCache cache)
- {
- super.setCache(cache);
- }
-
public Object invoke(MethodCall m) throws Throwable
{
@@ -52,9 +47,9 @@
{
throw new CacheException("failed extracting FQN from method " + m);
}
- if (!cache.exists(fqn))
+ if (!cache.hasChild(fqn))
{
- GlobalTransaction gtx = getInvocationContext().getGlobalTransaction();
+ GlobalTransaction gtx = InvocationContext.getCurrent().getGlobalTransaction();
if (gtx != null)
{
createNode(fqn, gtx, txTable);
@@ -103,7 +98,7 @@
// how many levels do we have?
int treeNodeSize = fqn.size();
- InvocationContext ctx = getInvocationContext();
+ InvocationContext ctx = InvocationContext.getCurrent();
// try and get the root from the transaction
TransactionWorkspace workspace = transactionEntry.getTransactionWorkSpace();
@@ -124,7 +119,7 @@
// to the transaction
if (workspaceNode == null)
{
- workspaceNode = NodeFactory.getInstance().createWorkspaceNode(cache.getRoot(), workspace);
+ workspaceNode = NodeFactory.getInstance().createWorkspaceNode((TreeNode) cache.get(Fqn.ROOT), workspace);
workspace.addNode(workspaceNode);
if (log.isDebugEnabled()) log.debug(" created root node " + workspaceNode + " in workspace " + gtx);
}
1.4 +1 -3 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.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- OptimisticInterceptor.java 18 Apr 2006 09:54:39 -0000 1.3
+++ OptimisticInterceptor.java 19 Jul 2006 21:34:43 -0000 1.4
@@ -21,10 +21,8 @@
protected TransactionManager txManager = null;
protected TransactionTable txTable = null;
- public void setCache(TreeCache cache)
+ public void setCache(CacheSPI cache)
{
- //super.setCache(cache);
- this.cache = cache;
txManager = cache.getTransactionManager();
txTable = cache.getTransactionTable();
}
1.17 +4 -5 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.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- OptimisticLockingInterceptor.java 6 Jun 2006 10:17:14 -0000 1.16
+++ OptimisticLockingInterceptor.java 19 Jul 2006 21:34:43 -0000 1.17
@@ -7,11 +7,11 @@
package org.jboss.cache.interceptors;
import org.jboss.cache.CacheException;
+import org.jboss.cache.CacheSPI;
import org.jboss.cache.DataNode;
import org.jboss.cache.GlobalTransaction;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.TransactionEntry;
-import org.jboss.cache.TreeCache;
import org.jboss.cache.marshall.JBCMethodCall;
import org.jboss.cache.marshall.MethodDeclarations;
import org.jboss.cache.optimistic.TransactionWorkspace;
@@ -32,16 +32,15 @@
{
private long lockAcquisitionTimeout;
- public void setCache(TreeCache cache)
+ public void setCache(CacheSPI cache)
{
- super.setCache(cache);
- lockAcquisitionTimeout = cache.getLockAcquisitionTimeout();
+ lockAcquisitionTimeout = cache.getConfiguration().getLockAcquisitionTimeout();
}
public Object invoke(MethodCall call) throws Throwable
{
JBCMethodCall m = (JBCMethodCall) call;
- InvocationContext ctx = getInvocationContext();
+ InvocationContext ctx = InvocationContext.getCurrent();
Object retval = null;
Method meth = m.getMethod();
1.22 +8 -13 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.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- OptimisticNodeInterceptor.java 12 Jun 2006 20:24:31 -0000 1.21
+++ OptimisticNodeInterceptor.java 19 Jul 2006 21:34:43 -0000 1.22
@@ -30,15 +30,10 @@
*/
public class OptimisticNodeInterceptor extends OptimisticInterceptor
{
- public void setCache(TreeCache cache)
- {
- super.setCache(cache);
- }
-
public Object invoke(MethodCall call) throws Throwable
{
JBCMethodCall m = (JBCMethodCall) call;
- InvocationContext ctx = getInvocationContext();
+ InvocationContext ctx = InvocationContext.getCurrent();
Transaction tx = ctx.getTransaction();
Method meth = m.getMethod();
Object[] args = m.getArgs();
@@ -58,7 +53,7 @@
// assign a global transaction here if we need to - should do all
// this in the transaction interceptor
- WorkspaceNode workspaceNode = getOrCreateWorkspaceNode(getFqn(args), workspace, cache);
+ WorkspaceNode workspaceNode = getOrCreateWorkspaceNode(getFqn(args), workspace);
// use explicit versioning
if (ctx.getOptionOverrides() != null && ctx.getOptionOverrides().getDataVersion() != null)
@@ -182,7 +177,7 @@
Fqn parentFqn = temp.getFqn();
// get a wrapped parent
- WorkspaceNode parentNode = getOrCreateWorkspaceNode(parentFqn, workspace, cache);
+ WorkspaceNode parentNode = getOrCreateWorkspaceNode(parentFqn, workspace);
if (parentNode == null)
throw new CacheException("Unable to find parent node with Fqn " + parentFqn);
@@ -232,7 +227,7 @@
{
Fqn fqn = (Fqn) args[0];
Object key = args[1];
- WorkspaceNode workspaceNode = getOrCreateWorkspaceNode(fqn, workspace, cache);
+ WorkspaceNode workspaceNode = getOrCreateWorkspaceNode(fqn, workspace);
if (workspaceNode == null)
{
@@ -252,7 +247,7 @@
{
Fqn fqn = (Fqn) args[0];
- WorkspaceNode workspaceNode = getOrCreateWorkspaceNode(fqn, workspace, cache);
+ WorkspaceNode workspaceNode = getOrCreateWorkspaceNode(fqn, workspace);
if (workspaceNode == null)
{
@@ -270,7 +265,7 @@
{
Fqn fqn = (Fqn) args[0];
- WorkspaceNode workspaceNode = getOrCreateWorkspaceNode(fqn, workspace, cache);
+ WorkspaceNode workspaceNode = getOrCreateWorkspaceNode(fqn, workspace);
if (workspaceNode == null)
{
@@ -289,7 +284,7 @@
{
Fqn fqn = (Fqn) args[0];
- WorkspaceNode workspaceNode = getOrCreateWorkspaceNode(fqn, workspace, cache);
+ WorkspaceNode workspaceNode = getOrCreateWorkspaceNode(fqn, workspace);
if (workspaceNode == null)
{
@@ -304,7 +299,7 @@
}
}
- private WorkspaceNode getOrCreateWorkspaceNode(Fqn fqn, TransactionWorkspace workspace, TreeCache cache)
+ private WorkspaceNode getOrCreateWorkspaceNode(Fqn fqn, TransactionWorkspace workspace)
{
WorkspaceNode workspaceNode = workspace.getNode(fqn);
// if we do not have the node then we need to add it to the workspace
1.22 +5 -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.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- OptimisticReplicationInterceptor.java 12 Jun 2006 20:24:31 -0000 1.21
+++ OptimisticReplicationInterceptor.java 19 Jul 2006 21:34:43 -0000 1.22
@@ -10,8 +10,8 @@
import org.jboss.cache.CacheException;
import org.jboss.cache.GlobalTransaction;
import org.jboss.cache.InvocationContext;
-import org.jboss.cache.TreeCache;
import org.jboss.cache.config.Option;
+import org.jboss.cache.config.Configuration;
import org.jboss.cache.marshall.JBCMethodCall;
import org.jboss.cache.marshall.MethodCallFactory;
import org.jboss.cache.marshall.MethodDeclarations;
@@ -33,16 +33,10 @@
// local prepare failures
private Map broadcastTxs = new ConcurrentHashMap();
-
- public void setCache(TreeCache cache)
- {
- super.setCache(cache);
- }
-
public Object invoke(MethodCall call) throws Throwable
{
JBCMethodCall m = (JBCMethodCall) call;
- InvocationContext ctx = getInvocationContext();
+ InvocationContext ctx = InvocationContext.getCurrent();
Option optionOverride = ctx.getOptionOverrides();
if (optionOverride != null && optionOverride.isCacheModeLocal() && ctx.getTransaction() == null)
{
@@ -146,7 +140,7 @@
protected Object broadcastPrepare(JBCMethodCall methodCall, GlobalTransaction gtx) throws Throwable
{
- boolean remoteCallSync = cache.getCacheModeInternal() == TreeCache.REPL_SYNC;
+ boolean remoteCallSync = configuration.getCacheModeInt() == Configuration.CacheMode.REPL_SYNC;
Object[] args = methodCall.getArgs();
List modifications = (List) args[1];
@@ -178,7 +172,7 @@
protected void broadcastCommit(GlobalTransaction gtx) throws Throwable
{
- boolean remoteCallSync = cache.getSyncCommitPhase();
+ boolean remoteCallSync = configuration.isSyncCommitPhase();
// 1. Multicast commit() to all members (exclude myself though)
if (cache.getMembers() != null && cache.getMembers().size() > 1)
@@ -208,7 +202,7 @@
protected void broadcastRollback(GlobalTransaction gtx) throws Throwable
{
- boolean remoteCallSync = cache.getSyncRollbackPhase();
+ boolean remoteCallSync = configuration.isSyncRollbackPhase();
if (cache.getMembers() != null && cache.getMembers().size() > 1)
{
1.26 +1 -7 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.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- OptimisticValidatorInterceptor.java 6 Jun 2006 10:17:14 -0000 1.25
+++ OptimisticValidatorInterceptor.java 19 Jul 2006 21:34:43 -0000 1.26
@@ -39,16 +39,10 @@
*/
public class OptimisticValidatorInterceptor extends OptimisticInterceptor
{
-
- public void setCache(TreeCache cache)
- {
- super.setCache(cache);
- }
-
public Object invoke(MethodCall call) throws Throwable
{
JBCMethodCall m = (JBCMethodCall) call;
- InvocationContext ctx = getInvocationContext();
+ InvocationContext ctx = InvocationContext.getCurrent();
Transaction tx = ctx.getTransaction();
GlobalTransaction gtx = ctx.getGlobalTransaction();
Object retval = null;
1.4 +1 -2 JBossCache/src/org/jboss/cache/interceptors/OrderedSynchronizationHandler.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: OrderedSynchronizationHandler.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/OrderedSynchronizationHandler.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- OrderedSynchronizationHandler.java 10 Apr 2006 05:31:04 -0000 1.3
+++ OrderedSynchronizationHandler.java 19 Jul 2006 21:34:43 -0000 1.4
@@ -20,7 +20,7 @@
* afterCompletion() <em>before</em> the TransactionInterceptor's.
*
* @author Bela Ban
- * @version $Id: OrderedSynchronizationHandler.java,v 1.3 2006/04/10 05:31:04 genman Exp $
+ * @version $Id: OrderedSynchronizationHandler.java,v 1.4 2006/07/19 21:34:43 msurtani Exp $
*/
public class OrderedSynchronizationHandler implements Synchronization {
Transaction tx=null;
@@ -40,7 +40,6 @@
* Creates a new instance of OrderedSynchronizationHandler, or fetches an existing instance. Key is the local
* transaction (tx). This instance registers with the TransactionManager automatically
* @param tx
- * @return
*/
public static OrderedSynchronizationHandler getInstance(Transaction tx) throws SystemException, RollbackException {
OrderedSynchronizationHandler retval=(OrderedSynchronizationHandler)instances.get(tx);
1.23 +8 -6 JBossCache/src/org/jboss/cache/interceptors/PassivationInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: PassivationInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/PassivationInterceptor.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- PassivationInterceptor.java 6 Jun 2006 10:17:14 -0000 1.22
+++ PassivationInterceptor.java 19 Jul 2006 21:34:43 -0000 1.23
@@ -3,6 +3,8 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.TreeNode;
import org.jboss.cache.TreeCache;
+import org.jboss.cache.Node;
+import org.jboss.cache.CacheSPI;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.marshall.MethodDeclarations;
import org.jboss.cache.marshall.JBCMethodCall;
@@ -18,15 +20,15 @@
* CacheLoader, either before each method call (no TXs), or at TX commit.
*
* @author <a href="mailto:{hmesha at novell.com}">{Hany Mesha}</a>
- * @version $Id: PassivationInterceptor.java,v 1.22 2006/06/06 10:17:14 msurtani Exp $
+ * @version $Id: PassivationInterceptor.java,v 1.23 2006/07/19 21:34:43 msurtani Exp $
*/
public class PassivationInterceptor extends Interceptor implements PassivationInterceptorMBean {
protected CacheLoader loader = null;
private SynchronizedLong m_passivations = new SynchronizedLong(0);
- public void setCache(TreeCache cache) {
- super.setCache(cache);
+ public void setCache(CacheSPI cache)
+ {
this.loader = cache.getCacheLoader();
}
@@ -62,7 +64,7 @@
cache.notifyNodePassivate(fqn, true);
loader.put(fqn, attributes);
}
- if (statsEnabled && cache.getUseInterceptorMbeans())
+ if (getStatisticsEnabled() && configuration.isUseInterceptorMbeans())
m_passivations.increment();
}
@@ -89,10 +91,10 @@
private Map getNodeAttributes(Fqn fqn) {
if (fqn == null)
return null;
- TreeNode n = cache.getRoot();
+ Node n = cache;
int size = fqn.size();
for(int i=0; i < size && n != null; i++) {
- n = n.getChild(fqn.get(i));
+ n = n.getChild(new Fqn(fqn.get(i)));
}
if (n != null)
return n.getData();
1.21 +19 -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.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- PessimisticLockInterceptor.java 6 Jun 2006 10:17:14 -0000 1.20
+++ PessimisticLockInterceptor.java 19 Jul 2006 21:34:43 -0000 1.21
@@ -13,6 +13,8 @@
import org.jboss.cache.TransactionEntry;
import org.jboss.cache.TransactionTable;
import org.jboss.cache.TreeCache;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.Node;
import org.jboss.cache.lock.IdentityLock;
import org.jboss.cache.lock.IsolationLevel;
import org.jboss.cache.lock.LockingException;
@@ -35,7 +37,7 @@
* current method and unlock when the method returns.
*
* @author Bela Ban
- * @version $Id: PessimisticLockInterceptor.java,v 1.20 2006/06/06 10:17:14 msurtani Exp $
+ * @version $Id: PessimisticLockInterceptor.java,v 1.21 2006/07/19 21:34:43 msurtani Exp $
*/
public class PessimisticLockInterceptor extends Interceptor {
TransactionTable tx_table=null;
@@ -45,11 +47,10 @@
private long lock_acquisition_timeout;
- public void setCache(TreeCache cache) {
- super.setCache(cache);
+ public void setCache(CacheSPI cache) {
tx_table=cache.getTransactionTable();
lock_table=cache.getLockTable();
- lock_acquisition_timeout=cache.getLockAcquisitionTimeout();
+ lock_acquisition_timeout=cache.getConfiguration().getLockAcquisitionTimeout();
}
@@ -60,7 +61,7 @@
int lock_type=DataNode.LOCK_TYPE_NONE;
long lock_timeout=lock_acquisition_timeout;
Object[] args=m.getArgs();
- InvocationContext ctx = getInvocationContext();
+ InvocationContext ctx = InvocationContext.getCurrent();
if (log.isTraceEnabled()) log.trace("PessimisticLockInterceptor invoked for method " + m);
if (ctx.getOptionOverrides() != null && ctx.getOptionOverrides().isSuppressLocking())
@@ -157,13 +158,15 @@
if(fqn != null) {
if(createIfNotExists) {
do {
- lock(fqn, ctx.getGlobalTransaction(), lock_type, recursive, lock_timeout, createIfNotExists);
+ // TODO: WHat do we do about createIfNotExists flag?
+ lock(fqn, ctx.getGlobalTransaction(), lock_type, recursive, lock_timeout);//, createIfNotExists);
}
- while(!cache.exists(fqn)); // keep trying until we have the lock (fixes concurrent remove())
+ while(!cache.hasChild(fqn)); // keep trying until we have the lock (fixes concurrent remove())
// terminates successfully, or with (Timeout)Exception
}
else
- lock(fqn, ctx.getGlobalTransaction(), lock_type, recursive, lock_timeout, createIfNotExists);
+ // TODO: WHat do we do about createIfNotExists flag?
+ lock(fqn, ctx.getGlobalTransaction(), lock_type, recursive, lock_timeout);//, createIfNotExists);
}
else {
if(log.isTraceEnabled())
@@ -184,10 +187,10 @@
* @param recursive Lock children recursively
*/
private void lock(Fqn fqn, GlobalTransaction gtx, int lock_type, boolean recursive,
- long lock_timeout, boolean createIfNotExists)
+ long lock_timeout)
throws TimeoutException, LockingException, InterruptedException {
- DataNode n;
- DataNode child_node;
+ Node n;
+ Node child_node;
Object child_name;
Thread currentThread = Thread.currentThread();
Object owner = (gtx != null) ? (Object)gtx : currentThread;
@@ -205,13 +208,13 @@
if((treeNodeSize=fqn.size()) == 0)
return;
- if(cache.getIsolationLevelClass() == IsolationLevel.NONE)
+ if(configuration.getIsolationLevel() == IsolationLevel.NONE)
lock_type=DataNode.LOCK_TYPE_NONE;
- n=cache.getRoot();
+ n=cache;
for(int i=0; i < treeNodeSize; i++) {
child_name=fqn.get(i);
- child_node=(DataNode) n.getOrCreateChild(child_name, gtx, createIfNotExists);
+ child_node= n.addChild(new Fqn(child_name));
if(child_node == null) {
if(log.isTraceEnabled())
log.trace("failed to find or create child " + child_name + " of node " + n.getFqn());
@@ -279,11 +282,11 @@
{
int treeNodeSize;
if ((treeNodeSize=fqn.size()) == 0) return;
- DataNode n=cache.getRoot();
+ Node n=cache;
for(int i=0; i < treeNodeSize; i++)
{
Object child_name=fqn.get(i);
- DataNode child_node=(DataNode) n.getOrCreateChild(child_name, gtx, true);
+ Node child_node= n.addChild(new Fqn(child_name)); //, gtx, true);
if(child_node == null)
{
if(log.isTraceEnabled()) log.trace("failed to find or create child " + child_name + " of node " + n.getFqn());
1.33 +14 -14 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.32
retrieving revision 1.33
diff -u -b -r1.32 -r1.33
--- ReplicationInterceptor.java 12 Jun 2006 20:24:31 -0000 1.32
+++ ReplicationInterceptor.java 19 Jul 2006 21:34:43 -0000 1.33
@@ -2,7 +2,7 @@
import org.jboss.cache.GlobalTransaction;
import org.jboss.cache.InvocationContext;
-import org.jboss.cache.TreeCache;
+import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Option;
import org.jboss.cache.marshall.JBCMethodCall;
import org.jboss.cache.marshall.MethodDeclarations;
@@ -16,7 +16,7 @@
* 'side-ways' (see docs/design/Refactoring.txt).
*
* @author Bela Ban
- * @version $Id: ReplicationInterceptor.java,v 1.32 2006/06/12 20:24:31 msurtani Exp $
+ * @version $Id: ReplicationInterceptor.java,v 1.33 2006/07/19 21:34:43 msurtani Exp $
*/
public class ReplicationInterceptor extends BaseRpcInterceptor
{
@@ -24,7 +24,7 @@
public Object invoke(MethodCall call) throws Throwable
{
JBCMethodCall m = (JBCMethodCall) call;
- InvocationContext ctx = getInvocationContext();
+ InvocationContext ctx = InvocationContext.getCurrent();
GlobalTransaction gtx = ctx.getGlobalTransaction();
boolean isLocalCommitOrRollback = gtx != null && !gtx.isRemote() && (m.getMethodId() == MethodDeclarations.commitMethod_id || m.getMethodId() == MethodDeclarations.rollbackMethod_id);
@@ -54,7 +54,7 @@
{
case MethodDeclarations.commitMethod_id:
// REPL_ASYNC will result in only a prepare() method - 1 phase commit.
- if (containsModifications(m)) replicateCall(m, cache.getSyncCommitPhase());
+ if (containsModifications(m)) replicateCall(m, configuration.isSyncCommitPhase());
// now pass up the chain
o = super.invoke(m);
break;
@@ -66,7 +66,7 @@
break;
case MethodDeclarations.rollbackMethod_id:
// REPL_ASYNC will result in only a prepare() method - 1 phase commit.
- if (containsModifications(m) && !ctx.isLocalRollbackOnly()) replicateCall(m, cache.getSyncRollbackPhase());
+ if (containsModifications(m) && !ctx.isLocalRollbackOnly()) replicateCall(m, configuration.isSyncRollbackPhase());
// now pass up the chain
o = super.invoke(m);
break;
@@ -80,7 +80,7 @@
if (ctx.isOriginLocal())
{
// don't re-broadcast if we've received this from anotehr cache in the cluster.
- handleReplicatedMethod(m, cache.getCacheModeInternal());
+ handleReplicatedMethod(m, configuration.getCacheModeInt());
}
}
else
@@ -91,29 +91,29 @@
return o;
}
- void handleReplicatedMethod(JBCMethodCall m, int mode) throws Throwable
+ void handleReplicatedMethod(JBCMethodCall m, Configuration.CacheMode mode) throws Throwable
{
- if (mode == TreeCache.REPL_SYNC && (m.getMethodId() == MethodDeclarations.putFailFastKeyValueMethodLocal_id))
+ if (mode == Configuration.CacheMode.REPL_SYNC && (m.getMethodId() == MethodDeclarations.putFailFastKeyValueMethodLocal_id))
{
if (log.isTraceEnabled())
{
log.trace("forcing asynchronous replication for putFailFast()");
}
- mode = TreeCache.REPL_ASYNC;
+ mode = Configuration.CacheMode.REPL_ASYNC;
}
if (log.isTraceEnabled())
{
log.trace("invoking method " + m + ", members=" + cache.getMembers() + ", mode=" +
- cache.getCacheMode() + ", exclude_self=" + true + ", timeout=" +
- cache.getSyncReplTimeout());
+ configuration.getCacheModeInt() + ", exclude_self=" + true + ", timeout=" +
+ configuration.getSyncReplTimeout());
}
switch (mode)
{
- case TreeCache.REPL_ASYNC:
+ case REPL_ASYNC:
// 2. Replicate change to all *other* members (exclude self !)
replicateCall(m, false);
break;
- case TreeCache.REPL_SYNC:
+ case REPL_SYNC:
// REVISIT Needs to exclude itself and apply the local change manually.
// This is needed such that transient field is modified properly in-VM.
replicateCall(m, true);
@@ -137,7 +137,7 @@
*/
protected void runPreparePhase(JBCMethodCall prepareMethod, GlobalTransaction gtx) throws Throwable
{
- boolean async = cache.getCacheModeInternal() == TreeCache.REPL_ASYNC;
+ boolean async = configuration.getCacheModeInt() == Configuration.CacheMode.REPL_ASYNC;
if (log.isTraceEnabled())
{
log.trace("(" + cache.getLocalAddress() + "): running remote prepare for global tx " + gtx + " with async mode=" + async);
1.51 +30 -29 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.50
retrieving revision 1.51
diff -u -b -r1.50 -r1.51
--- TxInterceptor.java 10 Jul 2006 14:58:53 -0000 1.50
+++ TxInterceptor.java 19 Jul 2006 21:34:43 -0000 1.51
@@ -15,7 +15,9 @@
import org.jboss.cache.TransactionEntry;
import org.jboss.cache.TransactionTable;
import org.jboss.cache.TreeCache;
+import org.jboss.cache.CacheSPI;
import org.jboss.cache.config.Option;
+import org.jboss.cache.config.Configuration;
import org.jboss.cache.marshall.JBCMethodCall;
import org.jboss.cache.marshall.MethodCallFactory;
import org.jboss.cache.marshall.MethodDeclarations;
@@ -64,9 +66,8 @@
private Map remoteTransactions = new ConcurrentHashMap();
- public void setCache(TreeCache cache)
+ public void setCache(CacheSPI cache)
{
- super.setCache(cache);
txManager = cache.getTransactionManager();
txTable = cache.getTransactionTable();
}
@@ -81,7 +82,7 @@
// bypass for buddy group org metod calls.
if (isBuddyGroupOrganisationMethod(m)) return super.invoke(m);
- InvocationContext ctx = getInvocationContext();
+ InvocationContext ctx = InvocationContext.getCurrent();
final Transaction suspendedTransaction;
boolean scrubTxsOnExit = false;
@@ -126,7 +127,7 @@
{
result = handleRemotePrepare(m, ctx.getGlobalTransaction());
scrubTxsOnExit = true;
- if (cache.getUseInterceptorMbeans()&& statsEnabled)
+ if (configuration.isUseInterceptorMbeans() && getStatisticsEnabled())
m_prepares++;
}
else
@@ -243,7 +244,7 @@
private Object handleRemotePrepare(JBCMethodCall m, GlobalTransaction gtx) throws Throwable
{
List modifications = (List) m.getArgs()[1];
- boolean onePhase = ((Boolean) m.getArgs()[cache.isNodeLockingOptimistic() ? 4 : 3]).booleanValue();
+ boolean onePhase = ((Boolean) m.getArgs()[configuration.isNodeLockingOptimistic() ? 4 : 3]).booleanValue();
// Is there a local transaction associated with GTX ?
Transaction ltx = txTable.getLocalTransaction(gtx);
@@ -288,7 +289,7 @@
{
// create a new transaction entry
- TransactionEntry entry = cache.isNodeLockingOptimistic() ? new OptimisticTransactionEntry() : new TransactionEntry();
+ TransactionEntry entry = configuration.isNodeLockingOptimistic() ? new OptimisticTransactionEntry() : new TransactionEntry();
entry.setTransaction(ltx);
log.debug("creating new tx entry");
txTable.put(gtx, entry);
@@ -298,7 +299,7 @@
// register a sync handler for this tx.
registerHandler(ltx, new RemoteSynchronizationHandler(gtx, ltx, cache));
- if (cache.isNodeLockingOptimistic())
+ if (configuration.isNodeLockingOptimistic())
retval = handleOptimisticPrepare(m, gtx, modifications, onePhase, ltx);
else
retval = handlePessimisticPrepare(m, gtx, modifications, onePhase, ltx);
@@ -327,11 +328,11 @@
*/
private Object handleNonTxMethod(MethodCall m) throws Throwable
{
- InvocationContext ctx = getInvocationContext();
+ InvocationContext ctx = InvocationContext.getCurrent();
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.
- boolean implicitTransaction = cache.isNodeLockingOptimistic() && tx == null;
+ boolean implicitTransaction = configuration.isNodeLockingOptimistic() && tx == null;
if (implicitTransaction)
{
tx = createLocalTx();
@@ -394,7 +395,7 @@
}
// make sure we attach this gtx to the invocation context.
- getInvocationContext().setGlobalTransaction(gtx);
+ InvocationContext.getCurrent().setGlobalTransaction(gtx);
return m;
}
@@ -575,7 +576,7 @@
resumeCurrentTxOnCompletion = true;
txManager.resume(ltx);
// make sure we set this in the ctx
- getInvocationContext().setTransaction( ltx );
+ InvocationContext.getCurrent().setTransaction( ltx );
}
if (log.isDebugEnabled()) log.debug(" executing " + m + "() with local TX " + ltx + " under global tx " + gtx);
@@ -585,13 +586,13 @@
if (m.getMethodId() == MethodDeclarations.commitMethod_id)
{
txManager.commit();
- if (cache.getUseInterceptorMbeans()&& statsEnabled)
+ if (configuration.isUseInterceptorMbeans() &&getStatisticsEnabled())
m_commits++;
}
else
{
txManager.rollback();
- if (cache.getUseInterceptorMbeans()&& statsEnabled)
+ if (configuration.isUseInterceptorMbeans() && getStatisticsEnabled())
m_rollbacks++;
}
}
@@ -605,7 +606,7 @@
if (currentTx != null)
{
txManager.resume(currentTx);
- getInvocationContext().setTransaction( currentTx );
+ InvocationContext.getCurrent().setTransaction( currentTx );
}
}
@@ -674,14 +675,14 @@
protected void runCommitPhase(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.
- getInvocationContext().setTxHasMods( modifications != null && modifications.size() > 0 );
+ InvocationContext.getCurrent().setTxHasMods( modifications != null && modifications.size() > 0 );
try
{
MethodCall commitMethod;
if (onePhaseCommit)
{
// running a 1-phase commit.
- if (cache.isNodeLockingOptimistic())
+ if (configuration.isNodeLockingOptimistic())
{
commitMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, new Object[]{
gtx, modifications, null, (Address) cache.getLocalAddress(), Boolean.TRUE});
@@ -733,7 +734,7 @@
//Transaction ltx = null;
try
{
- getInvocationContext().setTxHasMods( modifications != null && modifications.size() > 0 );
+ InvocationContext.getCurrent().setTxHasMods( modifications != null && modifications.size() > 0 );
// JBCACHE-457
// MethodCall rollbackMethod = MethodCall(TreeCache.rollbackMethod, new Object[]{gtx, hasMods ? Boolean.TRUE : Boolean.FALSE});
MethodCall rollbackMethod = MethodCallFactory.create(MethodDeclarations.rollbackMethod, new Object[]{gtx});
@@ -771,12 +772,12 @@
// if (cache.getCacheModeInternal() != TreeCache.REPL_ASYNC)
// {
// running a 2-phase commit.
- if (cache.isNodeLockingOptimistic())
+ if (configuration.isNodeLockingOptimistic())
{
prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, new Object[]{
gtx, modifications, null, (Address) cache.getLocalAddress(), Boolean.FALSE});
}
- else if(cache.getCacheModeInternal() != TreeCache.REPL_ASYNC)
+ else if(configuration.getCacheModeInt() != Configuration.CacheMode.REPL_ASYNC)
{
prepareMethod = MethodCallFactory.create(MethodDeclarations.prepareMethod,
new Object[]{gtx, modifications, (Address) cache.getLocalAddress(),
@@ -925,14 +926,14 @@
Transaction localTx = createLocalTx();
txTable.put(localTx, gtx);
// attach this to the context
- getInvocationContext().setTransaction(localTx);
+ InvocationContext.getCurrent().setTransaction(localTx);
if (log.isTraceEnabled()) log.trace("Created new tx for gtx " + gtx);
return localTx;
}
private void setInvocationContext(Transaction tx, GlobalTransaction gtx)
{
- InvocationContext ctx = getInvocationContext();
+ InvocationContext ctx = InvocationContext.getCurrent();
ctx.setTransaction( tx );
ctx.setGlobalTransaction( gtx );
}
@@ -942,7 +943,7 @@
if (removeTxs) setInvocationContext(null, null);
// only scrub options; not tx and gtx
- getInvocationContext().setOptionOverrides(null);
+ InvocationContext.getCurrent().setOptionOverrides(null);
}
// ------------------------------------------------------------------------
@@ -954,12 +955,12 @@
{
Transaction tx = null;
GlobalTransaction gtx = null;
- TreeCache cache = null;
+ CacheSPI cache = null;
List modifications = null;
TransactionEntry entry = null;
- RemoteSynchronizationHandler(GlobalTransaction gtx, Transaction tx, TreeCache cache)
+ RemoteSynchronizationHandler(GlobalTransaction gtx, Transaction tx, CacheSPI cache)
{
this.gtx = gtx;
this.tx = tx;
@@ -992,7 +993,7 @@
if ((entry = txTable.get(gtx)) != null)
{
modifications = entry.getModifications();
- getInvocationContext().setOptionOverrides(entry.getOption());
+ InvocationContext.getCurrent().setOptionOverrides(entry.getOption());
}
transactions.remove(tx);
@@ -1002,7 +1003,7 @@
// if this is optimistic or sync repl
- boolean onePhaseCommit = !cache.isNodeLockingOptimistic() && cache.getCacheModeInternal() == TreeCache.REPL_ASYNC;
+ boolean onePhaseCommit = !configuration.isNodeLockingOptimistic() && configuration.getCacheModeInt() == Configuration.CacheMode.REPL_ASYNC;
if (log.isDebugEnabled()) log.debug("Running commit phase. One phase? " + onePhaseCommit);
runCommitPhase(gtx, tx, modifications, onePhaseCommit);
log.debug("Finished commit phase");
@@ -1038,7 +1039,7 @@
{
private boolean localRollbackOnly = true;
- LocalSynchronizationHandler(GlobalTransaction gtx, Transaction tx, TreeCache cache)
+ LocalSynchronizationHandler(GlobalTransaction gtx, Transaction tx, CacheSPI cache)
{
super(gtx, tx, cache);
}
@@ -1056,7 +1057,7 @@
}
// set any transaction wide options as current for this thread.
- getInvocationContext().setOptionOverrides( entry.getOption() );
+ InvocationContext.getCurrent().setOptionOverrides( entry.getOption() );
try
{
@@ -1099,7 +1100,7 @@
public void afterCompletion(int status)
{
- getInvocationContext().setLocalRollbackOnly( localRollbackOnly );
+ InvocationContext.getCurrent().setLocalRollbackOnly( localRollbackOnly );
super.afterCompletion(status);
}
1.12 +4 -5 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.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- UnlockInterceptor.java 6 May 2006 09:53:11 -0000 1.11
+++ UnlockInterceptor.java 19 Jul 2006 21:34:43 -0000 1.12
@@ -1,6 +1,6 @@
package org.jboss.cache.interceptors;
-import org.jboss.cache.TreeCache;
+import org.jboss.cache.CacheSPI;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.lock.IdentityLock;
import org.jgroups.blocks.MethodCall;
@@ -15,15 +15,14 @@
* LockTable. This is a no-op if a transaction is used.
*
* @author Bela Ban
- * @version $Id: UnlockInterceptor.java,v 1.11 2006/05/06 09:53:11 msurtani Exp $
+ * @version $Id: UnlockInterceptor.java,v 1.12 2006/07/19 21:34:43 msurtani Exp $
*/
public class UnlockInterceptor extends Interceptor {
Map lock_table = null;
boolean trace = log.isTraceEnabled();
- public void setCache(TreeCache cache) {
- super.setCache(cache);
+ public void setCache(CacheSPI cache) {
lock_table = cache.getLockTable();
}
@@ -33,7 +32,7 @@
}
finally
{
- InvocationContext ctx = getInvocationContext();
+ InvocationContext ctx = InvocationContext.getCurrent();
if (ctx.getOptionOverrides() == null || !ctx.getOptionOverrides().isSuppressLocking())
{
Transaction tx = ctx.getTransaction();
More information about the jboss-cvs-commits
mailing list