[jboss-cvs] JBossCache/src/org/jboss/cache/interceptors ...
Manik Surtani
msurtani at belmont.prod.atl2.jboss.com
Wed Aug 30 13:08:18 EDT 2006
User: msurtani
Date: 06/08/30 13:08:18
Modified: src/org/jboss/cache/interceptors
BaseRpcInterceptor.java CacheLoaderInterceptor.java
CreateIfNotExistsInterceptor.java
DataGravitatorInterceptor.java
InvalidationInterceptor.java
OptimisticReplicationInterceptor.java
PessimisticLockInterceptor.java TxInterceptor.java
Log:
Java5 optimisations
Revision Changes Path
1.19 +93 -93 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.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- BaseRpcInterceptor.java 25 Aug 2006 14:10:07 -0000 1.18
+++ BaseRpcInterceptor.java 30 Aug 2006 17:08:18 -0000 1.19
@@ -5,10 +5,10 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.buddyreplication.BuddyManager;
+import org.jboss.cache.marshall.MethodCall;
import org.jboss.cache.marshall.MethodCallFactory;
import org.jboss.cache.marshall.MethodDeclarations;
import org.jgroups.Address;
-import org.jboss.cache.marshall.MethodCall;
import java.util.Iterator;
import java.util.List;
@@ -69,7 +69,7 @@
if (!sync && cache.getReplQueue() != null && !usingBuddyReplication)
{
- putCallOnAsyncReplicationQueue( call );
+ putCallOnAsyncReplicationQueue(call);
}
else
{
@@ -99,7 +99,7 @@
protected void putCallOnAsyncReplicationQueue(MethodCall call)
{
if (log.isDebugEnabled()) log.debug("Putting call " + call + " on the replication queue.");
- cache.getReplQueue().add(MethodCallFactory.create(MethodDeclarations.replicateMethod, new Object[]{call}));
+ cache.getReplQueue().add(MethodCallFactory.create(MethodDeclarations.replicateMethod, call));
}
protected boolean containsModifications(MethodCall m)
@@ -108,7 +108,7 @@
{
case MethodDeclarations.prepareMethod_id:
case MethodDeclarations.optimisticPrepareMethod_id:
- List mods = (List)m.getArgs()[1];
+ List mods = (List) m.getArgs()[1];
return mods.size() > 0;
case MethodDeclarations.commitMethod_id:
case MethodDeclarations.rollbackMethod_id:
1.49 +140 -112 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.48
retrieving revision 1.49
diff -u -b -r1.48 -r1.49
--- CacheLoaderInterceptor.java 25 Aug 2006 14:10:07 -0000 1.48
+++ CacheLoaderInterceptor.java 30 Aug 2006 17:08:18 -0000 1.49
@@ -1,13 +1,23 @@
package org.jboss.cache.interceptors;
-import org.jboss.cache.*;
+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.TransactionTable;
+import org.jboss.cache.TreeCache;
+import org.jboss.cache.TreeCacheProxyImpl;
import org.jboss.cache.config.Option;
import org.jboss.cache.loader.AsyncCacheLoader;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.loader.ChainingCacheLoader;
+import org.jboss.cache.marshall.MethodCall;
import org.jboss.cache.marshall.MethodCallFactory;
import org.jboss.cache.marshall.MethodDeclarations;
-import org.jboss.cache.marshall.MethodCall;
import java.util.Collection;
import java.util.Collections;
@@ -20,8 +30,9 @@
/**
* 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.48 2006/08/25 14:10:07 msurtani Exp $
+ * @version $Id: CacheLoaderInterceptor.java,v 1.49 2006/08/30 17:08:18 msurtani Exp $
*/
public class CacheLoaderInterceptor extends BaseCacheLoaderInterceptor implements CacheLoaderInterceptorMBean
{
@@ -40,7 +51,7 @@
public void setCache(CacheSPI cache)
{
super.setCache(cache);
- isCustomCacheLoader = isCustomCacheLoaderConfigured( loader );
+ isCustomCacheLoader = isCustomCacheLoaderConfigured(loader);
txTable = cache.getTransactionTable();
}
@@ -63,7 +74,7 @@
{
// test the underlying cache loader
CacheLoader underlying = ((AsyncCacheLoader) cl).getCacheLoader();
- return isCustomCacheLoaderConfigured( underlying );
+ return isCustomCacheLoaderConfigured(underlying);
}
else
{
@@ -76,13 +87,15 @@
/**
* 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.
+ *
* @return
* @throws Throwable
*/
- public Object invoke(MethodCall m) throws Throwable {
- Fqn fqn=null; // if set, load the data
+ public Object invoke(MethodCall m) throws Throwable
+ {
+ Fqn fqn = null; // if set, load the data
- Object[] args=m.getArgs();
+ Object[] args = m.getArgs();
boolean acquireLock = false; // do we need to acquire a lock if we load this node from cloader?
boolean initNode = false; // keep uninitialized
@@ -102,21 +115,21 @@
{
case MethodDeclarations.putDataEraseMethodLocal_id:
case MethodDeclarations.putDataMethodLocal_id:
- fqn=(Fqn)args[1];
+ fqn = (Fqn) args[1];
initNode = true;
break;
case MethodDeclarations.putKeyValMethodLocal_id:
- fqn=(Fqn)args[1];
+ fqn = (Fqn) args[1];
if (useCacheStore)
initNode = true;
else
acquireLock = true;
break;
case MethodDeclarations.addChildMethodLocal_id:
- fqn=(Fqn)args[1];
+ fqn = (Fqn) args[1];
break;
case MethodDeclarations.getKeyValueMethodLocal_id:
- fqn=(Fqn)args[0];
+ fqn = (Fqn) args[0];
key = args[1];
acquireLock = true;
break;
@@ -125,7 +138,7 @@
case MethodDeclarations.getChildrenNamesMethodLocal_id:
case MethodDeclarations.releaseAllLocksMethodLocal_id:
case MethodDeclarations.printMethodLocal_id:
- fqn=(Fqn)args[0];
+ fqn = (Fqn) args[0];
acquireLock = true;
break;
case MethodDeclarations.rollbackMethod_id:
@@ -133,11 +146,15 @@
cleanupNodesCreated(entry);
break;
default :
- if (!useCacheStore) {
- if (m.getMethodId() == MethodDeclarations.removeKeyMethodLocal_id) {
- fqn=(Fqn)args[1];
- } else if (m.getMethodId() == MethodDeclarations.removeDataMethodLocal_id) {
- fqn=(Fqn)args[1];
+ if (!useCacheStore)
+ {
+ if (m.getMethodId() == MethodDeclarations.removeKeyMethodLocal_id)
+ {
+ fqn = (Fqn) args[1];
+ }
+ else if (m.getMethodId() == MethodDeclarations.removeDataMethodLocal_id)
+ {
+ fqn = (Fqn) args[1];
initNode = true;
}
}
@@ -202,6 +219,7 @@
/**
* Load the children.
+ *
* @param node may be null if the node was not found.
*/
private void loadChildren(Fqn fqn, Node node) throws Throwable
@@ -218,7 +236,8 @@
// For getChildrenNames null means no children
if (children_names == null)
{
- if (n != null) {
+ if (n != null)
+ {
if (useCacheStore)
n.setChildren(null);
n.setChildrenLoaded(true);
@@ -230,9 +249,9 @@
if (n == null) n = (TreeCacheProxyImpl) createNodes(fqn, null); // dont care about local transactions
// Create one DataNode per child, mark as UNINITIALIZED
- for (Iterator i = children_names.iterator(); i.hasNext(); )
+ for (Iterator i = children_names.iterator(); i.hasNext();)
{
- String child_name = (String)i.next();
+ String child_name = (String) i.next();
Fqn child_fqn = new Fqn(child_name); // this is a RELATIVE Fqn!!
// create child if it didn't exist
cache.getInvocationContext().getOptionOverrides().setBypassInterceptorChain(true);
@@ -248,51 +267,59 @@
return n == null || (n.getKeys().contains(TreeCache.UNINITIALIZED) && (key == null || !n.getKeys().contains(key)));
}
- public long getCacheLoaderLoads() {
+ public long getCacheLoaderLoads()
+ {
return m_cacheLoads;
}
- public long getCacheLoaderMisses() {
+ public long getCacheLoaderMisses()
+ {
return m_cacheMisses;
}
- public void resetStatistics() {
+ public void resetStatistics()
+ {
m_cacheLoads = 0;
m_cacheMisses = 0;
}
- public Map dumpStatistics() {
- Map<String, Long> retval=new HashMap<String, Long>();
+ public Map dumpStatistics()
+ {
+ Map<String, Long> retval = new HashMap<String, Long>();
retval.put("CacheLoaderLoads", m_cacheLoads);
retval.put("CacheLoaderMisses", m_cacheMisses);
return retval;
}
- protected void lock(Fqn fqn, DataNode.LockType lock_type, boolean recursive) throws Throwable {
+ protected void lock(Fqn fqn, DataNode.LockType lock_type, boolean recursive) throws Throwable
+ {
if (configuration.isNodeLockingOptimistic()) return;
- MethodCall m=MethodCallFactory.create(MethodDeclarations.lockMethodLocal,
- new Object[]{fqn, lock_type, Boolean.valueOf(recursive)});
+ MethodCall m = MethodCallFactory.create(MethodDeclarations.lockMethodLocal,
+ fqn, lock_type, recursive);
super.invoke(m);
}
/**
* Retrieves a node from memory; doesn't access the cache loader
+ *
* @param fqn
*/
- protected Node getNode(Fqn fqn) {
- int treeNodeSize=fqn.size();
+ protected Node getNode(Fqn fqn)
+ {
+ int treeNodeSize = fqn.size();
// 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);
+ for (int i = 0; i < treeNodeSize && n != null; i++)
+ {
+ child_name = fqn.get(i);
cache.getInvocationContext().getOptionOverrides().setBypassInterceptorChain(true);
- child_node=n.getChild(new Fqn(child_name));
- n=child_node;
+ child_node = n.getChild(new Fqn(child_name));
+ n = child_node;
}
return n;
}
@@ -311,9 +338,9 @@
Iterator i = entry.getCacheLoaderModifications().iterator();
while (i.hasNext())
{
- MethodCall m = (MethodCall)i.next();
+ MethodCall m = (MethodCall) i.next();
if (m.getMethodId() == MethodDeclarations.removeNodeMethodLocal_id
- && fqn.isChildOrEquals((Fqn)m.getArgs()[1]))
+ && fqn.isChildOrEquals((Fqn) m.getArgs()[1]))
return true;
}
return false;
@@ -467,7 +494,8 @@
return nodeData;
}
- private void warnCustom() {
+ private void warnCustom()
+ {
log.warn("CacheLoader.get(Fqn) returned a null; assuming the node nodes not exist.");
log.warn("The CacheLoader interface has changed since JBossCache 1.3.x");
log.warn("Please see http://jira.jboss.com/jira/browse/JBCACHE-118");
1.19 +142 -101 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.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- CreateIfNotExistsInterceptor.java 25 Aug 2006 14:10:07 -0000 1.18
+++ CreateIfNotExistsInterceptor.java 30 Aug 2006 17:08:18 -0000 1.19
@@ -6,9 +6,9 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.GlobalTransaction;
import org.jboss.cache.Node;
+import org.jboss.cache.marshall.MethodCall;
import org.jboss.cache.marshall.MethodCallFactory;
import org.jboss.cache.marshall.MethodDeclarations;
-import org.jboss.cache.marshall.MethodCall;
import java.util.ArrayList;
import java.util.Iterator;
@@ -16,22 +16,25 @@
/**
* 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.18 2006/08/25 14:10:07 msurtani Exp $
+ * @version $Id: CreateIfNotExistsInterceptor.java,v 1.19 2006/08/30 17:08:18 msurtani Exp $
* @deprecated This code is not used anymore and will be removed in a future release
*/
-public class CreateIfNotExistsInterceptor extends Interceptor {
+public class CreateIfNotExistsInterceptor extends Interceptor
+{
- private final ReentrantLock put_lock=new ReentrantLock();
+ private final ReentrantLock put_lock = new ReentrantLock();
- private final ReentrantLock remove_lock=new ReentrantLock();
+ private final ReentrantLock remove_lock = new ReentrantLock();
- private final ArrayList put_list=new ArrayList();
+ private final ArrayList put_list = new ArrayList();
- private final ArrayList remove_list=new ArrayList();
+ private final ArrayList remove_list = new ArrayList();
- public void setCache(CacheSPI cache) {
+ public void setCache(CacheSPI cache)
+ {
super.setCache(cache);
}
@@ -55,8 +58,6 @@
return super.invoke(m);
}*/
-
-
// /**
// * Synchronize between put(), remove() and evict() methods. This is coarse-grained, and should be replaced
// * with FQN-based synchronization, e.g. put("/1/2/3" should <em>not</em> synchronize with remove("/a/b/c").
@@ -104,48 +105,58 @@
/**
* Synchronize between put(), remove() and evict() methods. This is coarse-grained, and should be replaced
* with FQN-based synchronization, e.g. put("/1/2/3" should <em>not</em> synchronize with remove("/a/b/c").
+ *
* @return
* @throws Throwable
*/
- public Object invoke(MethodCall m) throws Throwable {
+ public Object invoke(MethodCall m) throws Throwable
+ {
Fqn fqn;
- boolean isPut=MethodDeclarations.isPutMethod(m.getMethodId()),
- isRemove=m.getMethodId() == MethodDeclarations.removeNodeMethodLocal_id,
- isEvict=m.getMethodId() == MethodDeclarations.evictNodeMethodLocal_id;
-
- if(isPut || isRemove || isEvict) { // we need to sync put(), remove() and evict() calls
- Object[] args=m.getArgs();
- fqn=(Fqn)(args != null? (isEvict? args[0] : args[1]) : null);
- if(fqn == null)
+ boolean isPut = MethodDeclarations.isPutMethod(m.getMethodId()),
+ isRemove = m.getMethodId() == MethodDeclarations.removeNodeMethodLocal_id,
+ isEvict = m.getMethodId() == MethodDeclarations.evictNodeMethodLocal_id;
+
+ if (isPut || isRemove || isEvict)
+ { // we need to sync put(), remove() and evict() calls
+ Object[] args = m.getArgs();
+ fqn = (Fqn) (args != null ? (isEvict ? args[0] : args[1]) : null);
+ if (fqn == null)
throw new CacheException("failed extracting FQN from method " + m);
- if(isPut) { // lock needs to be held across puts()
- try {
+ if (isPut)
+ { // lock needs to be held across puts()
+ try
+ {
addFqnToPutList(fqn, put_lock);
findAndBlockOnRemove(fqn, remove_lock);
- if(!cache.hasChild(fqn)) {
- GlobalTransaction gtx=cache.getInvocationContext().getGlobalTransaction();
- if(log.isTraceEnabled())
+ if (!cache.hasChild(fqn))
+ {
+ GlobalTransaction gtx = cache.getInvocationContext().getGlobalTransaction();
+ if (log.isTraceEnabled())
log.trace("creating node " + fqn);
createNode(fqn, gtx);
}
return super.invoke(m);
}
- finally {
+ finally
+ {
removeFqnFromPutList(fqn, put_lock);
}
}
- else { // remove() or evict(): wait until all puts() that work on the same subtree have completed
- try {
+ else
+ { // remove() or evict(): wait until all puts() that work on the same subtree have completed
+ try
+ {
findAndBlockOnPut(fqn, put_lock); // does NOT release put_lock !
addFqnToRemoveList(fqn, remove_lock);
put_lock.release();
// we only release now because waiting on the put-list and adding to remove-list need to be atomic !
return super.invoke(m);
}
- finally {
- if(put_lock.holds() > 0)
+ finally
+ {
+ if (put_lock.holds() > 0)
put_lock.release();
removeFqnFromRemoveList(fqn, remove_lock);
}
@@ -159,25 +170,29 @@
* Finds all FQNs in the put_list form which <code>fqn</code> is a parent (or equals), and waits on them.
* Loops until no more matching FQNs are found or the list is empty.<p/>
* <em>Don't</em> release the lock, the caller will release it !
+ *
* @param fqn
* @param lock
* @throws InterruptedException
*/
- private void findAndBlockOnPut(Fqn fqn, ReentrantLock lock) throws InterruptedException {
+ private void findAndBlockOnPut(Fqn fqn, ReentrantLock lock) throws InterruptedException
+ {
Fqn tmp;
- while(true) {
+ while (true)
+ {
//try {
lock.acquire();
- tmp=findFqnInPutList(fqn);
- if(tmp == null) // put_list is empty, or fqn has not been found
+ tmp = findFqnInPutList(fqn);
+ if (tmp == null) // put_list is empty, or fqn has not been found
return;
- if(log.isTraceEnabled())
+ if (log.isTraceEnabled())
log.trace("found " + tmp + " in put-list, waiting");
- synchronized(tmp) {
+ synchronized (tmp)
+ {
lock.release();
tmp.wait();
}
- if(log.isTraceEnabled())
+ if (log.isTraceEnabled())
log.trace("wait() for put-list on " + tmp + " got notified");
//}
//finally {
@@ -190,49 +205,59 @@
/**
* Finds all FQNs in the remove_list for which <code>fqn</code> is a child (or equals), and waits for them.
* Loops until no more matching FQNs are found or the list is empty.
+ *
* @param fqn
* @param lock
* @throws InterruptedException
*/
- private void findAndBlockOnRemove(Fqn fqn, ReentrantLock lock) throws InterruptedException {
+ private void findAndBlockOnRemove(Fqn fqn, ReentrantLock lock) throws InterruptedException
+ {
Fqn tmp;
- while(true) {
+ while (true)
+ {
lock.acquire();
- try {
- tmp=findFqnInRemoveList(fqn);
- if(tmp == null) // remove_list is empty, or fqn has not been found
+ try
+ {
+ tmp = findFqnInRemoveList(fqn);
+ if (tmp == null) // remove_list is empty, or fqn has not been found
return;
- if(log.isTraceEnabled())
+ if (log.isTraceEnabled())
log.trace("found " + tmp + " in remove-list, waiting");
- synchronized(tmp) {
+ synchronized (tmp)
+ {
lock.release();
tmp.wait();
}
- if(log.isTraceEnabled())
+ if (log.isTraceEnabled())
log.trace("wait() for remove-list on " + tmp + " got notified");
}
- finally {
+ finally
+ {
lock.release();
}
}
}
- private Fqn findFqnInPutList(Fqn fqn) {
+ private Fqn findFqnInPutList(Fqn fqn)
+ {
Fqn tmp;
- for(Iterator it=put_list.iterator(); it.hasNext();) {
- tmp=(Fqn)it.next();
- if(tmp.isChildOf(fqn) || tmp.equals(fqn)) // child or same, e.g. put(/a/b/c) and rem(/a/b) or rem(/a/b/c)
+ for (Iterator it = put_list.iterator(); it.hasNext();)
+ {
+ tmp = (Fqn) it.next();
+ if (tmp.isChildOf(fqn) || tmp.equals(fqn)) // child or same, e.g. put(/a/b/c) and rem(/a/b) or rem(/a/b/c)
return tmp;
}
return null;
}
- private Fqn findFqnInRemoveList(Fqn fqn) {
+ private Fqn findFqnInRemoveList(Fqn fqn)
+ {
Fqn tmp;
- for(Iterator it=remove_list.iterator(); it.hasNext();) {
- tmp=(Fqn)it.next();
- if(fqn.isChildOf(tmp) || fqn.equals(tmp)) // child or same, e.g. put(/a/b/c) and rem(/a/b) or rem(/a/b/c)
+ for (Iterator it = remove_list.iterator(); it.hasNext();)
+ {
+ tmp = (Fqn) it.next();
+ if (fqn.isChildOf(tmp) || fqn.equals(tmp)) // child or same, e.g. put(/a/b/c) and rem(/a/b) or rem(/a/b/c)
return tmp;
}
return null;
@@ -242,14 +267,17 @@
throws InterruptedException
{
lock.acquire();
- try {
- if(!put_list.contains(fqn)) {
+ try
+ {
+ if (!put_list.contains(fqn))
+ {
put_list.add(fqn);
- if(log.isTraceEnabled())
+ if (log.isTraceEnabled())
log.trace("adding " + fqn + " to put-list (size=" + put_list.size() + ")");
}
}
- finally {
+ finally
+ {
lock.release();
}
}
@@ -258,34 +286,39 @@
throws InterruptedException
{
lock.acquire();
- try {
- if(!remove_list.contains(fqn)) {
+ try
+ {
+ if (!remove_list.contains(fqn))
+ {
remove_list.add(fqn);
- if(log.isTraceEnabled())
+ if (log.isTraceEnabled())
log.trace("adding " + fqn + " to remove-list (size=" + remove_list.size() + ")");
}
}
- finally {
+ finally
+ {
lock.release();
}
}
-
private void removeFqnFromPutList(Fqn fqn, ReentrantLock lock)
throws InterruptedException
{
lock.acquire();
- try {
- if(log.isTraceEnabled())
+ try
+ {
+ if (log.isTraceEnabled())
log.trace("removing " + fqn + " from put-list (size=" + put_list.size() + ")");
put_list.remove(fqn);
lock.release();
- synchronized(fqn) {
+ synchronized (fqn)
+ {
fqn.notifyAll();
}
}
- finally {
+ finally
+ {
lock.release();
}
}
@@ -294,39 +327,47 @@
throws InterruptedException
{
lock.acquire();
- try {
- if(log.isTraceEnabled())
+ try
+ {
+ if (log.isTraceEnabled())
log.trace("removing " + fqn + " from remove-list (size=" + remove_list.size() + ")");
remove_list.remove(fqn);
lock.release();
- synchronized(fqn) {
+ synchronized (fqn)
+ {
fqn.notifyAll();
}
}
- finally {
+ finally
+ {
lock.release();
}
}
- private void createNode(Fqn fqn, GlobalTransaction tx) {
+ private void createNode(Fqn fqn, GlobalTransaction tx)
+ {
Node n, child_node;
Object child_name;
- Fqn tmp_fqn=Fqn.ROOT;
+ Fqn tmp_fqn = Fqn.ROOT;
- if(fqn == null) return;
- synchronized(this) {
- int treeNodeSize=fqn.size();
- 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(new Fqn(child_name));
- if(child_node == null) {
+ if (fqn == null) return;
+ synchronized (this)
+ {
+ int treeNodeSize = fqn.size();
+ 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(new Fqn(child_name));
+ if (child_node == null)
+ {
//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});
+ child_node = n.addChild(new Fqn(child_name));
+ if (tx != null)
+ {
+ MethodCall undo_op = MethodCallFactory.create(MethodDeclarations.removeNodeMethodLocal,
+ tx, tmp_fqn, false);
cache.addUndoOperation(tx, undo_op);
// add the node name to the list maintained for the current tx
@@ -336,7 +377,7 @@
cache.getNotifier().notifyNodeCreated(tmp_fqn, true);
cache.getNotifier().notifyNodeCreated(tmp_fqn, false);
}
- n=child_node;
+ n = child_node;
}
}
}
1.24 +391 -387 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.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- DataGravitatorInterceptor.java 25 Aug 2006 14:10:07 -0000 1.23
+++ DataGravitatorInterceptor.java 30 Aug 2006 17:08:18 -0000 1.24
@@ -22,12 +22,12 @@
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Option;
import org.jboss.cache.loader.NodeData;
+import org.jboss.cache.marshall.MethodCall;
import org.jboss.cache.marshall.MethodCallFactory;
import org.jboss.cache.marshall.MethodDeclarations;
import org.jboss.invocation.MarshalledValueInputStream;
import org.jgroups.Address;
import org.jgroups.blocks.GroupRequest;
-import org.jboss.cache.marshall.MethodCall;
import java.io.ByteArrayInputStream;
import java.util.ArrayList;
@@ -38,11 +38,11 @@
/**
* The Data Gravitator interceptor intercepts cache misses and attempts t gravitate data from other parts of the cluster.
- *
+ * <p/>
* Only used if Buddy Replication is enabled. Also, the interceptor only kicks in if an {@link Option} is passed in to
* force Data Gravitation for a specific invocation or if <b>autoDataGravitation</b> is set to <b>true</b> when configuring
* Buddy Replication.
- *
+ * <p/>
* See the JBoss Cache User Guide for more details on configuration options. There is a section dedicated to Buddy Replication
* in the Replication chapter.
*
@@ -185,11 +185,11 @@
mods.add(cleanup);
if (configuration.isNodeLockingOptimistic())
{
- prepare = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, new Object[]{gtx, mods, null, cache.getLocalAddress(), Boolean.FALSE});
+ prepare = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, gtx, mods, null, cache.getLocalAddress(), false);
}
else
{
- prepare = MethodCallFactory.create(MethodDeclarations.prepareMethod, new Object[]{gtx, mods, cache.getLocalAddress(), syncCommunications});
+ prepare = MethodCallFactory.create(MethodDeclarations.prepareMethod, gtx, mods, cache.getLocalAddress(), syncCommunications);
}
replicateCall(getMembersOutsideBuddyGroup(), prepare, syncCommunications);
@@ -205,7 +205,7 @@
if (transactionMods.containsKey(gtx))
{
if (log.isTraceEnabled()) log.trace("Broadcasting commit for gtx " + gtx);
- replicateCall(getMembersOutsideBuddyGroup(), MethodCallFactory.create(MethodDeclarations.commitMethod, new Object[]{gtx}), syncCommunications);
+ replicateCall(getMembersOutsideBuddyGroup(), MethodCallFactory.create(MethodDeclarations.commitMethod, gtx), syncCommunications);
}
else
{
@@ -278,10 +278,10 @@
// backupDataCleanup = MethodCallFactory.create(MethodDeclarations.evictNodeMethodLocal, new Object[]{backup.backupFqn});
// }
- MethodCall cleanup = MethodCallFactory.create(MethodDeclarations.dataGravitationCleanupMethod, new Object[]{cache.getInvocationContext().getGlobalTransaction(), backup.primaryFqn, backup.backupFqn});
+ MethodCall cleanup = MethodCallFactory.create(MethodDeclarations.dataGravitationCleanupMethod, cache.getInvocationContext().getGlobalTransaction(), backup.primaryFqn, backup.backupFqn);
- if (log.isTraceEnabled()) log.trace("Performing cleanup on [" +backup.primaryFqn+ "]");
+ if (log.isTraceEnabled()) log.trace("Performing cleanup on [" + backup.primaryFqn + "]");
GlobalTransaction gtx = cache.getInvocationContext().getGlobalTransaction();
if (gtx == null)
{
@@ -289,14 +289,15 @@
// remove main Fqn
//replicateCall(cache.getMembers(), primaryDataCleanup, syncCommunications);
- if (log.isTraceEnabled()) log.trace("Performing cleanup on [" +backup.backupFqn+ "]");
+ if (log.isTraceEnabled()) log.trace("Performing cleanup on [" + backup.backupFqn + "]");
// remove backup Fqn
//replicateCall(cache.getMembers(), backupDataCleanup, syncCommunications);
replicateCall(cache.getMembers(), cleanup, syncCommunications);
}
else
{
- if (log.isTraceEnabled()) log.trace("Data gravitation performed under global transaction " + gtx + ". Not broadcasting cleanups until the tx commits. Adding to tx mod list instead.");
+ if (log.isTraceEnabled())
+ log.trace("Data gravitation performed under global transaction " + gtx + ". Not broadcasting cleanups until the tx commits. Adding to tx mod list instead.");
transactionMods.put(gtx, cleanup);
TransactionEntry te = getTransactionEntry(gtx);
te.addModification(cleanup);
@@ -305,11 +306,12 @@
private Object[] gravitateData(Fqn fqn) throws Exception
{
- if (log.isTraceEnabled()) log.trace("cache=" + cache.getLocalAddress() + "; requesting data gravitation for Fqn " + fqn);
+ if (log.isTraceEnabled())
+ log.trace("cache=" + cache.getLocalAddress() + "; requesting data gravitation for Fqn " + fqn);
List<Address> mbrs = cache.getMembers();
- Boolean searchSubtrees = (buddyManager.isDataGravitationSearchBackupTrees() ? Boolean.TRUE : Boolean.FALSE );
+ Boolean searchSubtrees = (buddyManager.isDataGravitationSearchBackupTrees() ? Boolean.TRUE : Boolean.FALSE);
Boolean marshal = configuration.isUseRegionBasedMarshalling() ? Boolean.TRUE : Boolean.FALSE;
- MethodCall dGrav = MethodCallFactory.create(MethodDeclarations.dataGravitationMethod, new Object[]{fqn, searchSubtrees, marshal});
+ MethodCall dGrav = MethodCallFactory.create(MethodDeclarations.dataGravitationMethod, fqn, searchSubtrees, marshal);
List resps = cache.getRPCManager().callRemoteMethods(mbrs, dGrav, GroupRequest.GET_FIRST, true, buddyManager.getBuddyCommunicationTimeout());
if (resps == null)
{
@@ -323,12 +325,13 @@
Object result = null;
Object backupFqn = null;
- while(i.hasNext())
+ while (i.hasNext())
{
Object o = i.next();
if (o instanceof Throwable)
{
- if (log.isDebugEnabled()) log.debug("Found remote Throwable among responses - removing from responses list", (Exception)o);
+ if (log.isDebugEnabled())
+ log.debug("Found remote Throwable among responses - removing from responses list", (Exception) o);
}
else if (o != null)
{
@@ -353,7 +356,7 @@
}
if (log.isTraceEnabled()) log.trace("got responses " + resps);
- return new Object[]{result,backupFqn};
+ return new Object[]{result, backupFqn};
}
}
@@ -381,15 +384,16 @@
private void createNodes(Fqn fqn, Map data) throws CacheException
{
int treeNodeSize;
- if ((treeNodeSize=fqn.size()) == 0) return;
- Node n=cache;
- for(int i=0; i < treeNodeSize; i++)
+ if ((treeNodeSize = fqn.size()) == 0) return;
+ Node n = cache;
+ for (int i = 0; i < treeNodeSize; i++)
{
Object child_name = fqn.get(i);
Node child_node = n.addChild(new Fqn(child_name));
- if(child_node == null)
+ if (child_node == null)
{
- if(log.isTraceEnabled()) log.trace("failed to find or create child " + child_name + " of node " + n.getFqn());
+ if (log.isTraceEnabled())
+ log.trace("failed to find or create child " + child_name + " of node " + n.getFqn());
return;
}
if (i == treeNodeSize - 1)
@@ -432,7 +436,7 @@
private BackupData localBackupGet(Fqn fqn) throws CacheException
{
List gravitatedData = cache._gravitateData(fqn, true, false); // a "local" gravitation
- boolean found = ((Boolean)gravitatedData.get(0)).booleanValue();
+ boolean found = ((Boolean) gravitatedData.get(0)).booleanValue();
BackupData data = null;
if (found)
1.25 +152 -151 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.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- InvalidationInterceptor.java 25 Aug 2006 14:10:07 -0000 1.24
+++ InvalidationInterceptor.java 30 Aug 2006 17:08:18 -0000 1.25
@@ -15,10 +15,10 @@
import org.jboss.cache.TransactionTable;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Option;
+import org.jboss.cache.marshall.MethodCall;
import org.jboss.cache.marshall.MethodCallFactory;
import org.jboss.cache.marshall.MethodDeclarations;
import org.jboss.cache.optimistic.TransactionWorkspace;
-import org.jboss.cache.marshall.MethodCall;
import javax.transaction.SystemException;
import javax.transaction.Transaction;
@@ -32,7 +32,7 @@
/**
* This interceptor acts as a replacement to the replication interceptor when
* the TreeCache is configured with ClusteredSyncMode as INVALIDATE.
- *
+ * <p/>
* The idea is that rather than replicating changes to all caches in a cluster
* when CRUD (Create, Remove, Update, Delete) methods are called, simply call
* evict(Fqn) on the remote caches for each changed node. This allows the
@@ -49,7 +49,7 @@
public void setCache(CacheSPI cache)
{
super.setCache(cache);
- txTable=cache.getTransactionTable();
+ txTable = cache.getTransactionTable();
}
public Object invoke(MethodCall m) throws Throwable
@@ -65,13 +65,13 @@
Transaction tx = ctx.getTransaction();
Object retval = super.invoke(m);
- if (log.isTraceEnabled()) log.trace("(" + cache.getLocalAddress() + ") method call " + m );
+ if (log.isTraceEnabled()) log.trace("(" + cache.getLocalAddress() + ") method call " + m);
// now see if this is a CRUD method:
if (MethodDeclarations.isCrudMethod(m.getMethodId()))
{
if (log.isDebugEnabled()) log.debug("Is a CRUD method");
- Fqn fqn = findFqn( m.getArgs() );
+ Fqn fqn = findFqn(m.getArgs());
if (fqn != null)
{
// could be potentially TRANSACTIONAL. Ignore if it is, until we see a prepare().
@@ -79,7 +79,7 @@
{
// the no-tx case:
//replicate an evict call.
- invalidateAcrossCluster( fqn, null );
+ invalidateAcrossCluster(fqn, null);
}
}
}
@@ -141,7 +141,7 @@
public Map dumpStatistics()
{
- Map<String, Long> retval=new HashMap<String, Long>();
+ Map<String, Long> retval = new HashMap<String, Long>();
retval.put("Invalidations", m_invalidations);
return retval;
}
@@ -154,10 +154,10 @@
// only propagate version details if we're using explicit versioning.
MethodCall call = workspace != null && !workspace.isVersioningImplicit() ?
- MethodCallFactory.create(MethodDeclarations.evictVersionedNodeMethodLocal, new Object[]{fqn, workspace.getNode(fqn).getVersion()}) :
- MethodCallFactory.create(MethodDeclarations.evictNodeMethodLocal, new Object[]{fqn});
+ MethodCallFactory.create(MethodDeclarations.evictVersionedNodeMethodLocal, fqn, workspace.getNode(fqn).getVersion()) :
+ MethodCallFactory.create(MethodDeclarations.evictNodeMethodLocal, fqn);
- if (log.isDebugEnabled()) log.debug("Cache ["+cache.getLocalAddress()+"] replicating " + call);
+ if (log.isDebugEnabled()) log.debug("Cache [" + cache.getLocalAddress() + "] replicating " + call);
// voila, invalidated!
replicateCall(call, configuration.getCacheMode() == Configuration.CacheMode.INVALIDATION_SYNC);
}
@@ -185,6 +185,7 @@
* Removes non-crud methods, plus clobs together common calls to Fqn's.
* E.g, if we have put("/a/b", "1", "2") followed by a put("/a/b", "3",
* "4") we should only evict "/a/b" once.
+ *
* @param list
* @return Iterator containing a unique set of Fqns of crud methods in this tx
*/
1.26 +185 -185 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.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- OptimisticReplicationInterceptor.java 25 Aug 2006 14:10:07 -0000 1.25
+++ OptimisticReplicationInterceptor.java 30 Aug 2006 17:08:18 -0000 1.26
@@ -12,9 +12,9 @@
import org.jboss.cache.InvocationContext;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Option;
+import org.jboss.cache.marshall.MethodCall;
import org.jboss.cache.marshall.MethodCallFactory;
import org.jboss.cache.marshall.MethodDeclarations;
-import org.jboss.cache.marshall.MethodCall;
import java.util.List;
import java.util.Map;
@@ -179,7 +179,7 @@
{
broadcastTxs.remove(gtx);
MethodCall commit_method = MethodCallFactory.create(MethodDeclarations.commitMethod,
- new Object[]{gtx});
+ gtx);
log.debug("running remote commit for " + gtx
+ " and coord=" + cache.getLocalAddress());
@@ -208,11 +208,11 @@
try
{
broadcastTxs.remove(gtx);
- MethodCall rollback_method = MethodCallFactory.create(MethodDeclarations.rollbackMethod, new Object[]{gtx});
+ MethodCall rollback_method = MethodCallFactory.create(MethodDeclarations.rollbackMethod, gtx);
log.debug("running remote rollback for " + gtx
+ " and coord=" + cache.getLocalAddress());
- replicateCall( rollback_method, remoteCallSync );
+ replicateCall(rollback_method, remoteCallSync);
}
catch (Exception e)
1.30 +2 -2 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.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- PessimisticLockInterceptor.java 29 Aug 2006 16:35:52 -0000 1.29
+++ PessimisticLockInterceptor.java 30 Aug 2006 17:08:18 -0000 1.30
@@ -36,7 +36,7 @@
* current method and unlock when the method returns.
*
* @author Bela Ban
- * @version $Id: PessimisticLockInterceptor.java,v 1.29 2006/08/29 16:35:52 msurtani Exp $
+ * @version $Id: PessimisticLockInterceptor.java,v 1.30 2006/08/30 17:08:18 msurtani Exp $
*/
public class PessimisticLockInterceptor extends Interceptor
{
@@ -130,7 +130,7 @@
case MethodDeclarations.lockMethodLocal_id:
fqn = (Fqn) args[0];
lock_type = (DataNode.LockType) args[1];
- recursive = ((Boolean) args[2]).booleanValue();
+ recursive = (Boolean) args[2];
break;
case MethodDeclarations.commitMethod_id:
// commit propagated up from the tx interceptor
1.58 +1038 -1024JBossCache/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.57
retrieving revision 1.58
diff -u -b -r1.57 -r1.58
--- TxInterceptor.java 25 Aug 2006 14:10:07 -0000 1.57
+++ TxInterceptor.java 30 Aug 2006 17:08:18 -0000 1.58
@@ -18,10 +18,10 @@
import org.jboss.cache.TreeCacheProxyImpl;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Option;
+import org.jboss.cache.marshall.MethodCall;
import org.jboss.cache.marshall.MethodCallFactory;
import org.jboss.cache.marshall.MethodDeclarations;
import org.jgroups.Address;
-import org.jboss.cache.marshall.MethodCall;
import javax.transaction.Status;
import javax.transaction.Synchronization;
@@ -76,7 +76,7 @@
{
if (log.isTraceEnabled())
{
- log.trace("("+cache.getLocalAddress()+") call on method [" + m + "]");
+ log.trace("(" + cache.getLocalAddress() + ") call on method [" + m + "]");
}
// bypass for buddy group org metod calls.
if (MethodDeclarations.isBuddyGroupOrganisationMethod(m.getMethodId())) return super.invoke(m);
@@ -89,11 +89,13 @@
Option optionOverride = ctx.getOptionOverrides();
ctx.setTransaction(txManager == null ? null : txManager.getTransaction());
- if (optionOverride!= null && optionOverride.isFailSilently() && ctx.getTransaction() != null)
+ if (optionOverride != null && optionOverride.isFailSilently() && ctx.getTransaction() != null)
{
suspendedTransaction = txManager.suspend();
resumeSuspended = true;
- } else {
+ }
+ else
+ {
suspendedTransaction = null;
resumeSuspended = false;
}
@@ -110,13 +112,13 @@
{
// this is a prepare, commit, or rollback.
// start by setting transactional details into InvocationContext.
- ctx.setGlobalTransaction( findGlobalTransaction(m.getArgs()) );
+ ctx.setGlobalTransaction(findGlobalTransaction(m.getArgs()));
if (log.isDebugEnabled()) log.debug("Got gtx from method call " + ctx.getGlobalTransaction());
- ctx.getGlobalTransaction().setRemote( isRemoteGlobalTx(ctx.getGlobalTransaction()) );
+ ctx.getGlobalTransaction().setRemote(isRemoteGlobalTx(ctx.getGlobalTransaction()));
//replaceGtx(m, gtxFromMethodCall);
- if (ctx.getGlobalTransaction().isRemote()) remoteTransactions.put(ctx.getGlobalTransaction(),NULL);
+ if (ctx.getGlobalTransaction().isRemote()) remoteTransactions.put(ctx.getGlobalTransaction(), NULL);
switch (m.getMethodId())
{
@@ -131,7 +133,7 @@
}
else
{
- if(log.isTraceEnabled()) log.trace("received my own message (discarding it)");
+ if (log.isTraceEnabled()) log.trace("received my own message (discarding it)");
result = null;
}
break;
@@ -208,7 +210,7 @@
public Map dumpStatistics()
{
- Map retval=new HashMap(3);
+ Map retval = new HashMap(3);
retval.put("Prepares", new Long(m_prepares));
retval.put("Commits", new Long(m_commits));
retval.put("Rollbacks", new Long(m_rollbacks));
@@ -321,6 +323,7 @@
/**
* 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
@@ -336,7 +339,7 @@
{
tx = createLocalTx();
// we need to attach this tx to the InvocationContext.
- ctx.setTransaction( tx );
+ ctx.setTransaction(tx);
}
if (tx != null) m = attachGlobalTransaction(tx, m);
@@ -374,7 +377,8 @@
private MethodCall attachGlobalTransaction(Transaction tx, MethodCall m) throws Exception
{
- if (log.isDebugEnabled()) log.debug(" local transaction exists - registering global tx if not present for " + Thread.currentThread());
+ if (log.isDebugEnabled())
+ log.debug(" local transaction exists - registering global tx if not present for " + Thread.currentThread());
if (log.isTraceEnabled())
{
GlobalTransaction tempGtx = txTable.get(tx);
@@ -403,8 +407,9 @@
* This is called by invoke() if we are in a remote gtx's prepare() phase.
* Finds the appropriate tx, suspends any existing txs, registers a sync handler
* and passes up the chain.
- *
+ * <p/>
* Resumes any existing txs before returning.
+ *
* @param m
* @return
* @throws Throwable
@@ -446,7 +451,8 @@
}
// JBCACHE-361 Confirm that the transaction is ACTIVE
- if (!isActive(ltx)) {
+ if (!isActive(ltx))
+ {
throw new ReplicationException("prepare() failed -- " +
"local transaction status is not STATUS_ACTIVE;" +
" is " + ltx.getStatus());
@@ -476,7 +482,8 @@
try
{
// invokeOnePhaseCommitMethod(gtx, modifications.size() > 0, success);
- if (success) ltx.commit() ; else ltx.rollback();
+ if (success) ltx.commit();
+ else ltx.rollback();
}
catch (Throwable t)
{
@@ -540,6 +547,7 @@
/**
* Handles a commit or a rollback for a remote gtx. Called by invoke().
+ *
* @param m
* @return
* @throws Throwable
@@ -575,7 +583,7 @@
resumeCurrentTxOnCompletion = true;
txManager.resume(ltx);
// make sure we set this in the ctx
- cache.getInvocationContext().setTransaction( ltx );
+ cache.getInvocationContext().setTransaction(ltx);
}
if (log.isDebugEnabled()) log.debug(" executing " + m + "() with local TX " + ltx + " under global tx " + gtx);
@@ -585,7 +593,7 @@
if (m.getMethodId() == MethodDeclarations.commitMethod_id)
{
txManager.commit();
- if (configuration.isUseInterceptorMbeans() &&getStatisticsEnabled())
+ if (configuration.isUseInterceptorMbeans() && getStatisticsEnabled())
m_commits++;
}
else
@@ -605,7 +613,7 @@
if (currentTx != null)
{
txManager.resume(currentTx);
- cache.getInvocationContext().setTransaction( currentTx );
+ cache.getInvocationContext().setTransaction(currentTx);
}
}
@@ -640,13 +648,14 @@
/**
* 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
{
- GlobalTransaction gtx = findGlobalTransaction( m.getArgs() );
+ GlobalTransaction gtx = findGlobalTransaction(m.getArgs());
Object result;
// this must have a local transaction associated if a prepare has been
@@ -669,12 +678,13 @@
/**
* creates a commit() MethodCall and feeds it to handleCommitRollback();
+ *
* @param gtx
*/
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.
- cache.getInvocationContext().setTxHasMods( modifications != null && modifications.size() > 0 );
+ cache.getInvocationContext().setTxHasMods(modifications != null && modifications.size() > 0);
try
{
MethodCall commitMethod;
@@ -683,19 +693,19 @@
// running a 1-phase commit.
if (configuration.isNodeLockingOptimistic())
{
- commitMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, new Object[]{
- gtx, modifications, null, (Address) cache.getLocalAddress(), Boolean.TRUE});
+ commitMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod,
+ gtx, modifications, null, (Address) cache.getLocalAddress(), true);
}
else
{
- commitMethod = MethodCallFactory.create(MethodDeclarations.prepareMethod, new Object[]
- {gtx, modifications, (Address) cache.getLocalAddress(),
- Boolean.TRUE});
+ commitMethod = MethodCallFactory.create(MethodDeclarations.prepareMethod,
+ gtx, modifications, (Address) cache.getLocalAddress(),
+ true);
}
}
else
{
- commitMethod = MethodCallFactory.create(MethodDeclarations.commitMethod, new Object[]{gtx});
+ commitMethod = MethodCallFactory.create(MethodDeclarations.commitMethod, gtx);
}
if (log.isTraceEnabled()) {log.trace(" running commit for " + gtx);}
@@ -726,6 +736,7 @@
/**
* creates a rollback() MethodCall and feeds it to handleCommitRollback();
+ *
* @param gtx
*/
protected void runRollbackPhase(GlobalTransaction gtx, Transaction tx, List modifications)
@@ -733,10 +744,10 @@
//Transaction ltx = null;
try
{
- cache.getInvocationContext().setTxHasMods( modifications != null && modifications.size() > 0 );
+ cache.getInvocationContext().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});
+// MethodCall rollbackMethod = MethodCall(TreeCache.rollbackMethod, new Object[]{gtx, hasMods ? true : false});
+ MethodCall rollbackMethod = MethodCallFactory.create(MethodDeclarations.rollbackMethod, gtx);
if (log.isTraceEnabled()) {log.trace(" running rollback for " + gtx);}
//JBCACHE-359 Store a lookup for the gtx so a listener
@@ -773,14 +784,13 @@
// running a 2-phase commit.
if (configuration.isNodeLockingOptimistic())
{
- prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, new Object[]{
- gtx, modifications, null, (Address) cache.getLocalAddress(), Boolean.FALSE});
+ prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, gtx, modifications, null, (Address) cache.getLocalAddress(), false);
}
- else if(configuration.getCacheMode() != Configuration.CacheMode.REPL_ASYNC)
+ else if (configuration.getCacheMode() != Configuration.CacheMode.REPL_ASYNC)
{
prepareMethod = MethodCallFactory.create(MethodDeclarations.prepareMethod,
- new Object[]{gtx, modifications, (Address) cache.getLocalAddress(),
- Boolean.FALSE}); // don't commit or rollback - wait for call
+ gtx, modifications, (Address) cache.getLocalAddress(),
+ false); // don't commit or rollback - wait for call
}
//}
else
@@ -817,6 +827,7 @@
/**
* Tests if a global transaction originated from a different cache in the cluster
+ *
* @param gtx
* @return true if the gtx is remote, false if it originated locally.
*/
@@ -827,6 +838,7 @@
/**
* Creates a gtx (if one doesnt exist), a sync handler, and registers the tx.
+ *
* @param tx
* @return
* @throws Exception
@@ -863,6 +875,7 @@
/**
* Registers a sync hander against a tx.
+ *
* @param tx
* @param handler
* @throws Exception
@@ -901,6 +914,7 @@
/**
* Creates and starts a local tx
+ *
* @return
* @throws Exception
*/
@@ -916,6 +930,7 @@
/**
* Creates a new local transaction for a given global transaction.
+ *
* @param gtx
* @return
* @throws Exception
@@ -933,8 +948,8 @@
private void setInvocationContext(Transaction tx, GlobalTransaction gtx)
{
InvocationContext ctx = cache.getInvocationContext();
- ctx.setTransaction( tx );
- ctx.setGlobalTransaction( gtx );
+ ctx.setTransaction(tx);
+ ctx.setGlobalTransaction(gtx);
}
private void scrubInvocationCtx(boolean removeTxs)
@@ -1000,7 +1015,6 @@
{
case Status.STATUS_COMMITTED:
-
// 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);
@@ -1056,7 +1070,7 @@
}
// set any transaction wide options as current for this thread.
- cache.getInvocationContext().setOptionOverrides( entry.getOption() );
+ cache.getInvocationContext().setOptionOverrides(entry.getOption());
try
{
@@ -1099,7 +1113,7 @@
public void afterCompletion(int status)
{
- cache.getInvocationContext().setLocalRollbackOnly( localRollbackOnly );
+ cache.getInvocationContext().setLocalRollbackOnly(localRollbackOnly);
super.afterCompletion(status);
}
More information about the jboss-cvs-commits
mailing list