Author: manik.surtani(a)jboss.com
Date: 2008-06-25 11:33:13 -0400 (Wed, 25 Jun 2008)
New Revision: 6038
Added:
core/trunk/src/main/java/org/jboss/cache/transaction/OptimisticTransactionContext.java
core/trunk/src/main/java/org/jboss/cache/transaction/TransactionContext.java
Removed:
core/trunk/src/main/java/org/jboss/cache/transaction/OptimisticTransactionEntry.java
core/trunk/src/main/java/org/jboss/cache/transaction/TransactionEntry.java
Modified:
core/trunk/src/main/java/org/jboss/cache/InvocationContext.java
core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
core/trunk/src/main/java/org/jboss/cache/interceptors/ActivationInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/BaseTransactionalContextInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/CallInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticLockingInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticTxInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/ReplicationInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
core/trunk/src/main/java/org/jboss/cache/lock/LockUtil.java
core/trunk/src/main/java/org/jboss/cache/transaction/TransactionTable.java
core/trunk/src/test/java/org/jboss/cache/api/NodeAPITest.java
core/trunk/src/test/java/org/jboss/cache/invocationcontext/TransactionTest.java
core/trunk/src/test/java/org/jboss/cache/lock/AbstractLockManagerRecordingTest.java
core/trunk/src/test/java/org/jboss/cache/transaction/AbortionTest.java
core/trunk/src/test/java/org/jboss/cache/transaction/NotifyingTransactionManager.java
Log:
Renamed TransactionEntry to TransactionContext
Modified: core/trunk/src/main/java/org/jboss/cache/InvocationContext.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/InvocationContext.java 2008-06-25 15:10:47
UTC (rev 6037)
+++ core/trunk/src/main/java/org/jboss/cache/InvocationContext.java 2008-06-25 15:33:13
UTC (rev 6038)
@@ -13,7 +13,7 @@
import org.jboss.cache.lock.NodeLock;
import org.jboss.cache.marshall.MethodCall;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.TransactionEntry;
+import org.jboss.cache.transaction.TransactionContext;
import org.jboss.cache.transaction.TransactionTable;
import javax.transaction.Transaction;
@@ -37,7 +37,7 @@
private Transaction transaction;
private GlobalTransaction globalTransaction;
- private TransactionEntry transactionEntry;
+ private TransactionContext transactionContext;
private Option optionOverrides;
// defaults to true.
private boolean originLocal = true;
@@ -109,20 +109,20 @@
* @return the transaction entry associated with the current transaction, or null if
the current thread is not associated with a transaction.
* @since 2.2.0
*/
- public TransactionEntry getTransactionEntry()
+ public TransactionContext getTransactionContext()
{
- return transactionEntry;
+ return transactionContext;
}
/**
* Sets the transaction entry to be associated with the current thread.
*
- * @param transactionEntry transaction entry to set
+ * @param transactionContext transaction entry to set
* @since 2.2.0
*/
- public void setTransactionEntry(TransactionEntry transactionEntry)
+ public void setTransactionContext(TransactionContext transactionContext)
{
- this.transactionEntry = transactionEntry;
+ this.transactionContext = transactionContext;
}
/**
@@ -187,7 +187,7 @@
/**
* Returns an immutable, defensive copy of the List of locks currently maintained for
the current scope.
* <p/>
- * Note that if a transaction is in scope, these locks are retrieved from the {@link
org.jboss.cache.transaction.TransactionEntry} rather than
+ * Note that if a transaction is in scope, these locks are retrieved from the {@link
org.jboss.cache.transaction.TransactionContext} rather than
* this {@link org.jboss.cache.InvocationContext}. Retrieving locks from here will
ensure they are retrieved from the appropriate
* scope.
* <p/>
@@ -201,14 +201,14 @@
public List getLocks()
{
// first check transactional scope
- if (transactionEntry != null) return transactionEntry.getLocks();
+ if (transactionContext != null) return transactionContext.getLocks();
return Collections.unmodifiableList(new ArrayList(invocationLocks));
}
/**
* Adds a List of locks to the currently maintained collection of locks acquired.
* <p/>
- * Note that if a transaction is in scope, these locks are recorded on the {@link
org.jboss.cache.transaction.TransactionEntry} rather than
+ * Note that if a transaction is in scope, these locks are recorded on the {@link
org.jboss.cache.transaction.TransactionContext} rather than
* this {@link org.jboss.cache.InvocationContext}. Adding locks here will ensure they
are promoted to the appropriate
* scope.
* <p/>
@@ -222,9 +222,9 @@
public void addAllLocks(List locks)
{
// first check transactional scope
- if (transactionEntry != null)
+ if (transactionContext != null)
{
- transactionEntry.addAllLocks(locks);
+ transactionContext.addAllLocks(locks);
}
else
{
@@ -237,7 +237,7 @@
/**
* Adds a lock to the currently maintained collection of locks acquired.
* <p/>
- * Note that if a transaction is in scope, this lock is recorded on the {@link
org.jboss.cache.transaction.TransactionEntry} rather than
+ * Note that if a transaction is in scope, this lock is recorded on the {@link
org.jboss.cache.transaction.TransactionContext} rather than
* this {@link org.jboss.cache.InvocationContext}. Adding a lock here will ensure it
is promoted to the appropriate
* scope.
* <p/>
@@ -251,9 +251,9 @@
public void addLock(Object lock)
{
// first check transactional scope
- if (transactionEntry != null)
+ if (transactionContext != null)
{
- transactionEntry.addLock(lock);
+ transactionContext.addLock(lock);
}
else
{
@@ -266,7 +266,7 @@
/**
* Removes a lock from the currently maintained collection of locks acquired.
* <p/>
- * Note that if a transaction is in scope, this lock is removed from the {@link
org.jboss.cache.transaction.TransactionEntry} rather than
+ * Note that if a transaction is in scope, this lock is removed from the {@link
org.jboss.cache.transaction.TransactionContext} rather than
* this {@link org.jboss.cache.InvocationContext}. Removing a lock here will ensure
it is removed in the appropriate
* scope.
* <p/>
@@ -280,9 +280,9 @@
public void removeLock(Object lock)
{
// first check transactional scope
- if (transactionEntry != null)
+ if (transactionContext != null)
{
- transactionEntry.removeLock(lock);
+ transactionContext.removeLock(lock);
}
else
{
@@ -294,7 +294,7 @@
/**
* Clears all locks from the currently maintained collection of locks acquired.
* <p/>
- * Note that if a transaction is in scope, locks are cleared from the {@link
org.jboss.cache.transaction.TransactionEntry} rather than
+ * Note that if a transaction is in scope, locks are cleared from the {@link
org.jboss.cache.transaction.TransactionContext} rather than
* this {@link org.jboss.cache.InvocationContext}. Clearing locks here will ensure
they are cleared in the appropriate
* scope.
* <p/>
@@ -305,9 +305,9 @@
public void clearLocks()
{
// first check transactional scope
- if (transactionEntry != null)
+ if (transactionContext != null)
{
- transactionEntry.clearLocks();
+ transactionContext.clearLocks();
}
else
{
@@ -397,7 +397,7 @@
copy.optionOverrides = optionOverrides == null ? null : optionOverrides.copy();
copy.originLocal = originLocal;
copy.transaction = transaction;
- copy.transactionEntry = transactionEntry;
+ copy.transactionContext = transactionContext;
copy.txHasMods = txHasMods;
return null;
}
Modified: core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2008-06-25 15:10:47 UTC
(rev 6037)
+++ core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2008-06-25 15:33:13 UTC
(rev 6038)
@@ -281,7 +281,7 @@
if (gtx != null)
{
CreateNodeCommand createNodeCommand =
commandsFactory.buildCreateNodeCommand(child_fqn);
- ctx.getTransactionEntry().addModification(createNodeCommand);
+ ctx.getTransactionContext().addModification(createNodeCommand);
}
}
}
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/ActivationInterceptor.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/interceptors/ActivationInterceptor.java 2008-06-25
15:10:47 UTC (rev 6037)
+++
core/trunk/src/main/java/org/jboss/cache/interceptors/ActivationInterceptor.java 2008-06-25
15:33:13 UTC (rev 6038)
@@ -21,7 +21,7 @@
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.TransactionEntry;
+import org.jboss.cache.transaction.TransactionContext;
import javax.transaction.SystemException;
import javax.transaction.TransactionManager;
@@ -290,14 +290,14 @@
private void prepareCacheLoader(InvocationContext ctx) throws Throwable
{
GlobalTransaction gtx = ctx.getGlobalTransaction();
- TransactionEntry entry = ctx.getTransactionEntry();
- if (entry == null)
+ TransactionContext tCtx = ctx.getTransactionContext();
+ if (tCtx == null)
{
- throw new Exception("entry for transaction " + gtx + " not found
in transaction table");
+ throw new Exception("tCtx for transaction " + gtx + " not found
in transaction table");
}
List<Modification> cacheLoaderModifications = new
ArrayList<Modification>();
- builder.visitCollection(ctx, entry.getModifications());
+ builder.visitCollection(ctx, tCtx.getModifications());
if (cacheLoaderModifications.size() > 0)
{
loader.prepare(gtx, cacheLoaderModifications, false);
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java 2008-06-25
15:10:47 UTC (rev 6037)
+++
core/trunk/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java 2008-06-25
15:33:13 UTC (rev 6038)
@@ -15,7 +15,7 @@
import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.interceptors.base.CommandInterceptor;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.TransactionEntry;
+import org.jboss.cache.transaction.TransactionContext;
import org.jboss.cache.transaction.TransactionTable;
import org.jgroups.Address;
@@ -106,11 +106,11 @@
Transaction tx = ctx.getTransaction();
if (tx != null)
{
- TransactionEntry te = ctx.getTransactionEntry();
- if (te != null)
+ TransactionContext transactionContext = ctx.getTransactionContext();
+ if (transactionContext != null)
{
- if (te.isForceAsyncReplication()) sync = false;
- else if (te.isForceSyncReplication()) sync = true;
+ if (transactionContext.isForceAsyncReplication()) sync = false;
+ else if (transactionContext.isForceSyncReplication()) sync = true;
}
}
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/BaseTransactionalContextInterceptor.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/interceptors/BaseTransactionalContextInterceptor.java 2008-06-25
15:10:47 UTC (rev 6037)
+++
core/trunk/src/main/java/org/jboss/cache/interceptors/BaseTransactionalContextInterceptor.java 2008-06-25
15:33:13 UTC (rev 6038)
@@ -5,7 +5,7 @@
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.interceptors.base.CommandInterceptor;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.TransactionEntry;
+import org.jboss.cache.transaction.TransactionContext;
import org.jboss.cache.transaction.TransactionTable;
import javax.transaction.Status;
@@ -32,18 +32,18 @@
protected void copyInvocationScopeOptionsToTxScope(InvocationContext ctx)
{
- // notify the transaction entry that this override is in place.
- TransactionEntry entry = txTable.get(ctx.getGlobalTransaction());
- if (entry != null)
+ // notify the transaction tCtx that this override is in place.
+ TransactionContext tCtx = txTable.get(ctx.getGlobalTransaction());
+ if (tCtx != null)
{
Option txScopeOption = new Option();
txScopeOption.setCacheModeLocal(ctx.getOptionOverrides() != null &&
ctx.getOptionOverrides().isCacheModeLocal());
txScopeOption.setSkipCacheStatusCheck(ctx.getOptionOverrides() != null
&& ctx.getOptionOverrides().isSkipCacheStatusCheck());
- entry.setOption(txScopeOption);
+ tCtx.setOption(txScopeOption);
}
}
- protected void setTransactionalContext(Transaction tx, GlobalTransaction gtx,
TransactionEntry entry, InvocationContext ctx)
+ protected void setTransactionalContext(Transaction tx, GlobalTransaction gtx,
TransactionContext tCtx, InvocationContext ctx)
{
if (trace)
{
@@ -52,21 +52,21 @@
}
ctx.setTransaction(tx);
ctx.setGlobalTransaction(gtx);
- if (entry == null)
+ if (tCtx == null)
{
if (gtx != null)
{
- ctx.setTransactionEntry(txTable.get(gtx));
+ ctx.setTransactionContext(txTable.get(gtx));
}
else if (tx == null)
{
- // then nullify the transaction entry as well
- ctx.setTransactionEntry(null);
+ // then nullify the transaction tCtx as well
+ ctx.setTransactionContext(null);
}
}
else
{
- ctx.setTransactionEntry(entry);
+ ctx.setTransactionContext(tCtx);
}
}
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java 2008-06-25
15:10:47 UTC (rev 6037)
+++
core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java 2008-06-25
15:33:13 UTC (rev 6038)
@@ -30,7 +30,7 @@
import org.jboss.cache.lock.LockType;
import org.jboss.cache.lock.TimeoutException;
import org.jboss.cache.notifications.Notifier;
-import org.jboss.cache.transaction.TransactionEntry;
+import org.jboss.cache.transaction.TransactionContext;
import org.jboss.cache.transaction.TransactionTable;
import java.util.Collections;
@@ -93,7 +93,7 @@
{
if (command.getFqn() != null)
{
- loadIfNeeded(ctx, command.getFqn(), null, false, true, false,
ctx.getTransactionEntry(), false, false, false);
+ loadIfNeeded(ctx, command.getFqn(), null, false, true, false,
ctx.getTransactionContext(), false, false, false);
}
return invokeNextInterceptor(ctx, command);
}
@@ -103,7 +103,7 @@
{
if (command.getFqn() != null)
{
- loadIfNeeded(ctx, command.getFqn(), command.getKey(), false, useCacheStore,
!useCacheStore, ctx.getTransactionEntry(), false, false, false);
+ loadIfNeeded(ctx, command.getFqn(), command.getKey(), false, useCacheStore,
!useCacheStore, ctx.getTransactionContext(), false, false, false);
}
return invokeNextInterceptor(ctx, command);
}
@@ -121,9 +121,9 @@
{
if (command.getTo() != null)
{
- loadIfNeeded(ctx, command.getTo(), null, false, false, true,
ctx.getTransactionEntry(), false, true, false);
+ loadIfNeeded(ctx, command.getTo(), null, false, false, true,
ctx.getTransactionContext(), false, true, false);
}
- loadIfNeeded(ctx, command.getFqn(), null, false, false, true,
ctx.getTransactionEntry(), true, true, false);
+ loadIfNeeded(ctx, command.getFqn(), null, false, false, true,
ctx.getTransactionContext(), true, true, false);
}
return invokeNextInterceptor(ctx, command);
}
@@ -133,7 +133,7 @@
{
if (command.getFqn() != null)
{
- loadIfNeeded(ctx, command.getFqn(), command.getKey(), false, false, true,
ctx.getTransactionEntry(), false, false, false);
+ loadIfNeeded(ctx, command.getFqn(), command.getKey(), false, false, true,
ctx.getTransactionContext(), false, false, false);
}
return invokeNextInterceptor(ctx, command);
}
@@ -144,7 +144,7 @@
{
if (command.getFqn() != null)
{
- loadIfNeeded(ctx, command.getFqn(), null, false, false, true,
ctx.getTransactionEntry(), false, false, !usingOptimisticInvalidation);
+ loadIfNeeded(ctx, command.getFqn(), null, false, false, true,
ctx.getTransactionContext(), false, false, !usingOptimisticInvalidation);
}
return invokeNextInterceptor(ctx, command);
}
@@ -155,7 +155,7 @@
Fqn fqn = command.getFqn();
if (fqn != null)
{
- loadIfNeeded(ctx, fqn, null, false, false, false, ctx.getTransactionEntry(),
false, false, true);
+ loadIfNeeded(ctx, fqn, null, false, false, false, ctx.getTransactionContext(),
false, false, true);
NodeSPI n = dataContainer.peek(fqn, true, true);
loadChildren(fqn, n, false, false, ctx);
}
@@ -168,7 +168,7 @@
{
if (command.getFqn() != null)
{
- loadIfNeeded(ctx, command.getFqn(), null, true, false, true,
ctx.getTransactionEntry(), false, false, false);
+ loadIfNeeded(ctx, command.getFqn(), null, true, false, true,
ctx.getTransactionContext(), false, false, false);
}
return invokeNextInterceptor(ctx, command);
}
@@ -178,7 +178,7 @@
{
if (command.getFqn() != null)
{
- loadIfNeeded(ctx, command.getFqn(), null, true, false, true,
ctx.getTransactionEntry(), false, false, false);
+ loadIfNeeded(ctx, command.getFqn(), null, true, false, true,
ctx.getTransactionContext(), false, false, false);
}
return invokeNextInterceptor(ctx, command);
}
@@ -190,7 +190,7 @@
if (trace) log.trace("Removing temporarily created nodes from
treecache");
// this needs to be done in reverse order.
- List list = ctx.getTransactionEntry().getDummyNodesCreatedByCacheLoader();
+ List list = ctx.getTransactionContext().getDummyNodesCreatedByCacheLoader();
if (list != null && list.size() > 0)
{
ListIterator i = list.listIterator(list.size());
@@ -215,7 +215,7 @@
{
if (configuration.isNodeLockingOptimistic() && command.getFqn() != null)
{
- loadIfNeeded(ctx, command.getFqn(), null, false, false, false,
ctx.getTransactionEntry(), false, false, false);
+ loadIfNeeded(ctx, command.getFqn(), null, false, false, false,
ctx.getTransactionContext(), false, false, false);
}
return invokeNextInterceptor(ctx, command);
}
@@ -225,7 +225,7 @@
{
if (command.getFqn() != null && !useCacheStore)
{
- loadIfNeeded(ctx, command.getFqn(), command.getKey(), false, false, false,
ctx.getTransactionEntry(), false, false, false);
+ loadIfNeeded(ctx, command.getFqn(), command.getKey(), false, false, false,
ctx.getTransactionContext(), false, false, false);
}
return invokeNextInterceptor(ctx, command);
}
@@ -236,12 +236,12 @@
Fqn fqn = command.getFqn();
if (fqn != null && !useCacheStore)
{
- loadIfNeeded(ctx, fqn, null, false, true, false, ctx.getTransactionEntry(),
false, false, false);
+ loadIfNeeded(ctx, fqn, null, false, true, false, ctx.getTransactionContext(),
false, false, false);
}
return invokeNextInterceptor(ctx, command);
}
- private void loadIfNeeded(InvocationContext ctx, Fqn fqn, Object key, boolean allKeys,
boolean initNode, boolean acquireLock, TransactionEntry entry, boolean recursive, boolean
isMove, boolean bypassLoadingData) throws Throwable
+ private void loadIfNeeded(InvocationContext ctx, Fqn fqn, Object key, boolean allKeys,
boolean initNode, boolean acquireLock, TransactionContext transactionContext, boolean
recursive, boolean isMove, boolean bypassLoadingData) throws Throwable
{
NodeSPI n = dataContainer.peek(fqn, true, true);
Object lockOwner = lockManager.getLockOwner(ctx);
@@ -269,7 +269,7 @@
{
if (initNode)
{
- n = createTempNode(fqn, entry);
+ n = createTempNode(fqn, transactionContext);
}
// Only attempt to acquire this lock if we need to - i.e., if
@@ -297,12 +297,12 @@
if (n == null && loader.exists(fqn))
{
// just create a dummy node in memory
- n = createTempNode(fqn, entry);
+ n = createTempNode(fqn, transactionContext);
}
}
else
{
- n = loadNode(ctx, fqn, n, entry);
+ n = loadNode(ctx, fqn, n, transactionContext);
}
}
}
@@ -470,10 +470,10 @@
*/
private boolean wasRemovedInTx(Fqn fqn, InvocationContext ctx)
{
- TransactionEntry entry = ctx.getTransactionEntry();
- if (entry == null) return false;
+ TransactionContext transactionContext = ctx.getTransactionContext();
+ if (transactionContext == null) return false;
- for (ReversibleCommand txCacheCommand : entry.getModifications())
+ for (ReversibleCommand txCacheCommand : transactionContext.getModifications())
{
if (txCacheCommand instanceof RemoveNodeCommand &&
fqn.isChildOrEquals(txCacheCommand.getFqn())) return true;
}
@@ -485,7 +485,7 @@
* If it doesn't exist on disk but in memory, clears the
* uninitialized flag, otherwise returns null.
*/
- private NodeSPI loadNode(InvocationContext ctx, Fqn fqn, NodeSPI n, TransactionEntry
entry) throws Exception
+ private NodeSPI loadNode(InvocationContext ctx, Fqn fqn, NodeSPI n, TransactionContext
transactionContext) throws Exception
{
if (trace) log.trace("loadNode " + fqn);
Map nodeData = loadData(fqn);
@@ -499,7 +499,7 @@
notifier.notifyNodeActivated(fqn, true, Collections.emptyMap(), ctx);
}
- n = createNodes(fqn, entry);
+ n = createNodes(fqn, transactionContext);
// n.clearDataDirect();
n.setInternalState(nodeData);
@@ -523,9 +523,9 @@
/**
* Creates a new memory node in preparation for storage.
*/
- private NodeSPI createTempNode(Fqn fqn, TransactionEntry entry) throws Exception
+ private NodeSPI createTempNode(Fqn fqn, TransactionContext transactionContext) throws
Exception
{
- NodeSPI n = createNodes(fqn, entry);
+ NodeSPI n = createNodes(fqn, transactionContext);
n.setDataLoaded(false);
if (trace)
{
@@ -535,7 +535,7 @@
}
@SuppressWarnings("unchecked")
- private NodeSPI createNodes(Fqn fqn, TransactionEntry entry) throws Exception
+ private NodeSPI createNodes(Fqn fqn, TransactionContext transactionContext) throws
Exception
{
Object[] results = dataContainer.createNodes(fqn);
List<NodeSPI> createdNodes = (List<NodeSPI>) results[0];
@@ -544,9 +544,9 @@
for (NodeSPI node : createdNodes)
{
node.setDataLoaded(false);
- if (entry != null)
+ if (transactionContext != null)
{
- entry.loadUninitialisedNode(node.getFqn());
+ transactionContext.loadUninitialisedNode(node.getFqn());
}
lastCreated = node;
}
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java 2008-06-25
15:10:47 UTC (rev 6037)
+++
core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java 2008-06-25
15:33:13 UTC (rev 6038)
@@ -27,7 +27,7 @@
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.loader.CacheLoaderManager;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.TransactionEntry;
+import org.jboss.cache.transaction.TransactionContext;
import javax.transaction.SystemException;
import javax.transaction.TransactionManager;
@@ -182,7 +182,7 @@
if (inTransaction())
{
if (trace) log.trace("transactional so don't put stuff in the cloader
yet.");
- prepareCacheLoader(command.getGlobalTransaction(), ctx.getTransactionEntry(),
command.isOnePhaseCommit());
+ prepareCacheLoader(command.getGlobalTransaction(), ctx.getTransactionContext(),
command.isOnePhaseCommit());
}
return invokeNextInterceptor(ctx, command);
}
@@ -333,13 +333,13 @@
return retval;
}
- private void prepareCacheLoader(GlobalTransaction gtx, TransactionEntry entry, boolean
onePhase) throws Throwable
+ private void prepareCacheLoader(GlobalTransaction gtx, TransactionContext
transactionContext, boolean onePhase) throws Throwable
{
- if (entry == null)
+ if (transactionContext == null)
{
- throw new Exception("entry for transaction " + gtx + " not found
in transaction table");
+ throw new Exception("transactionContext for transaction " + gtx +
" not found in transaction table");
}
- List<ReversibleCommand> modifications = entry.getModifications();
+ List<ReversibleCommand> modifications =
transactionContext.getModifications();
if (modifications.size() == 0)
{
if (trace) log.trace("Transaction has not logged any
modifications!");
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CallInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/CallInterceptor.java 2008-06-25
15:10:47 UTC (rev 6037)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/CallInterceptor.java 2008-06-25
15:33:13 UTC (rev 6038)
@@ -8,11 +8,11 @@
import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
import org.jboss.cache.commands.tx.PrepareCommand;
import org.jboss.cache.commands.tx.RollbackCommand;
+import org.jboss.cache.commands.write.ClearDataCommand;
import org.jboss.cache.commands.write.MoveCommand;
import org.jboss.cache.commands.write.PutDataMapCommand;
import org.jboss.cache.commands.write.PutForExternalReadCommand;
import org.jboss.cache.commands.write.PutKeyValueCommand;
-import org.jboss.cache.commands.write.ClearDataCommand;
import org.jboss.cache.commands.write.RemoveKeyCommand;
import org.jboss.cache.commands.write.RemoveNodeCommand;
import org.jboss.cache.factories.annotations.Inject;
@@ -171,7 +171,7 @@
}
else
{
- ctx.getTransactionEntry().addModification(command);
+ ctx.getTransactionContext().addModification(command);
}
}
return result;
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java 2008-06-25
15:10:47 UTC (rev 6037)
+++
core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java 2008-06-25
15:33:13 UTC (rev 6038)
@@ -15,7 +15,15 @@
import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
import org.jboss.cache.commands.tx.PrepareCommand;
import org.jboss.cache.commands.tx.RollbackCommand;
-import org.jboss.cache.commands.write.*;
+import org.jboss.cache.commands.write.ClearDataCommand;
+import org.jboss.cache.commands.write.InvalidateCommand;
+import org.jboss.cache.commands.write.MoveCommand;
+import org.jboss.cache.commands.write.OptimisticInvalidateCommand;
+import org.jboss.cache.commands.write.PutDataMapCommand;
+import org.jboss.cache.commands.write.PutForExternalReadCommand;
+import org.jboss.cache.commands.write.PutKeyValueCommand;
+import org.jboss.cache.commands.write.RemoveKeyCommand;
+import org.jboss.cache.commands.write.RemoveNodeCommand;
import org.jboss.cache.config.Option;
import org.jboss.cache.factories.CommandsFactory;
import org.jboss.cache.factories.annotations.Inject;
@@ -25,8 +33,8 @@
import org.jboss.cache.optimistic.TransactionWorkspace;
import org.jboss.cache.optimistic.WorkspaceNode;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.OptimisticTransactionEntry;
-import org.jboss.cache.transaction.TransactionEntry;
+import org.jboss.cache.transaction.OptimisticTransactionContext;
+import org.jboss.cache.transaction.TransactionContext;
import org.jboss.cache.transaction.TransactionTable;
import javax.transaction.SystemException;
@@ -81,7 +89,7 @@
public Object visitPutForExternalReadCommand(InvocationContext ctx,
PutForExternalReadCommand command) throws Throwable
{
// these are always local more, as far as invalidation is concerned
- if (ctx.getTransaction() != null)
ctx.getTransactionEntry().addLocalModification(command);
+ if (ctx.getTransaction() != null)
ctx.getTransactionContext().addLocalModification(command);
return invokeNextInterceptor(ctx, command);
}
@@ -125,16 +133,17 @@
if (trace) log.trace("Entering InvalidationInterceptor's prepare
phase");
// fetch the modifications before the transaction is committed (and thus removed
from the txTable)
GlobalTransaction gtx = ctx.getGlobalTransaction();
- TransactionEntry entry = ctx.getTransactionEntry();
- if (entry == null) throw new IllegalStateException("cannot find transaction
entry for " + gtx);
+ TransactionContext transactionContext = ctx.getTransactionContext();
+ if (transactionContext == null)
+ throw new IllegalStateException("cannot find transaction
transactionContext for " + gtx);
- if (entry.hasModifications())
+ if (transactionContext.hasModifications())
{
List<ReversibleCommand> mods;
- if (entry.hasLocalModifications())
+ if (transactionContext.hasLocalModifications())
{
mods = new
ArrayList<ReversibleCommand>(command.getModifications());
- mods.removeAll(entry.getLocalModifications());
+ mods.removeAll(transactionContext.getLocalModifications());
}
else
{
@@ -159,13 +168,14 @@
{
// here we just record the modifications but actually do the invalidate in
commit.
GlobalTransaction gtx = ctx.getGlobalTransaction();
- TransactionEntry entry = ctx.getTransactionEntry();
- if (entry == null) throw new IllegalStateException("cannot find transaction
entry for " + gtx);
+ TransactionContext transactionContext = ctx.getTransactionContext();
+ if (transactionContext == null)
+ throw new IllegalStateException("cannot find transaction
transactionContext for " + gtx);
- if (entry.hasModifications())
+ if (transactionContext.hasModifications())
{
- List<ReversibleCommand> mods = new
ArrayList<ReversibleCommand>(entry.getModifications());
- if (entry.hasLocalModifications())
mods.removeAll(entry.getLocalModifications());
+ List<ReversibleCommand> mods = new
ArrayList<ReversibleCommand>(transactionContext.getModifications());
+ if (transactionContext.hasLocalModifications())
mods.removeAll(transactionContext.getLocalModifications());
txMods.put(gtx, mods);
}
}
@@ -229,7 +239,7 @@
}
else
{
- if (isLocalModeForced(ctx))
ctx.getTransactionEntry().addLocalModification((ReversibleCommand) command);
+ if (isLocalModeForced(ctx))
ctx.getTransactionContext().addLocalModification((ReversibleCommand) command);
}
}
return retval;
@@ -396,7 +406,7 @@
protected TransactionWorkspace getWorkspace(InvocationContext ctx)
{
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry)
ctx.getTransactionEntry();
+ OptimisticTransactionContext entry = (OptimisticTransactionContext)
ctx.getTransactionContext();
return entry.getTransactionWorkSpace();
}
}
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticInterceptor.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticInterceptor.java 2008-06-25
15:10:47 UTC (rev 6037)
+++
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticInterceptor.java 2008-06-25
15:33:13 UTC (rev 6038)
@@ -19,7 +19,7 @@
import org.jboss.cache.optimistic.TransactionWorkspace;
import org.jboss.cache.optimistic.WorkspaceNode;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.OptimisticTransactionEntry;
+import org.jboss.cache.transaction.OptimisticTransactionContext;
import org.jboss.cache.transaction.TransactionTable;
import javax.transaction.Transaction;
@@ -47,15 +47,15 @@
protected TransactionWorkspace getTransactionWorkspace(InvocationContext ctx) throws
CacheException
{
- OptimisticTransactionEntry transactionEntry = (OptimisticTransactionEntry)
ctx.getTransactionEntry();
+ OptimisticTransactionContext transactionContext = (OptimisticTransactionContext)
ctx.getTransactionContext();
- if (transactionEntry == null)
+ if (transactionContext == null)
{
throw new CacheException("Unable to map global transaction " +
ctx.getGlobalTransaction() + " to transaction entry when trying to retrieve
transaction workspace.");
}
// try and get the workspace from the transaction
- return transactionEntry.getTransactionWorkSpace();
+ return transactionContext.getTransactionWorkSpace();
}
/**
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticLockingInterceptor.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticLockingInterceptor.java 2008-06-25
15:10:47 UTC (rev 6037)
+++
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticLockingInterceptor.java 2008-06-25
15:33:13 UTC (rev 6038)
@@ -19,7 +19,7 @@
import org.jboss.cache.optimistic.TransactionWorkspace;
import org.jboss.cache.optimistic.WorkspaceNode;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.TransactionEntry;
+import org.jboss.cache.transaction.TransactionContext;
/**
* Locks nodes during transaction boundaries. Only affects prepare/commit/rollback
method calls; other method calls
@@ -30,14 +30,11 @@
*/
public class OptimisticLockingInterceptor extends OptimisticInterceptor
{
- private long lockAcquisitionTimeout;
-
@Start
private void init()
{
if (txManager == null)
log.fatal("No transaction manager lookup class has been defined.
Transactions cannot be used and thus OPTIMISTIC locking cannot be used! Expect
errors!!");
- lockAcquisitionTimeout = configuration.getLockAcquisitionTimeout();
}
@Override
@@ -125,8 +122,8 @@
{
try
{
- TransactionEntry entry = ctx.getTransactionEntry();
- if (entry != null)
+ TransactionContext transactionContext = ctx.getTransactionContext();
+ if (transactionContext != null)
{
lockManager.unlock(ctx);
}
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java 2008-06-25
15:10:47 UTC (rev 6037)
+++
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java 2008-06-25
15:33:13 UTC (rev 6038)
@@ -346,7 +346,7 @@
private void addToModificationList(ReversibleCommand command, InvocationContext ctx)
{
Option opt = ctx.getOptionOverrides();
- ctx.getTransactionEntry().addModification(command);
+ ctx.getTransactionContext().addModification(command);
if (log.isDebugEnabled()) log.debug("Adding command " + command + "
to modification list");
}
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java 2008-06-25
15:10:47 UTC (rev 6037)
+++
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java 2008-06-25
15:33:13 UTC (rev 6038)
@@ -33,8 +33,8 @@
import org.jboss.cache.optimistic.TransactionWorkspace;
import org.jboss.cache.optimistic.WorkspaceNode;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.OptimisticTransactionEntry;
-import org.jboss.cache.transaction.TransactionEntry;
+import org.jboss.cache.transaction.OptimisticTransactionContext;
+import org.jboss.cache.transaction.TransactionContext;
import org.jboss.cache.util.concurrent.ConcurrentHashSet;
import java.util.ArrayList;
@@ -75,11 +75,11 @@
if (!skipReplicationOfTransactionMethod(ctx))
{
GlobalTransaction gtx = getGlobalTransaction(ctx);
- TransactionEntry te = ctx.getTransactionEntry();
- if (te.hasLocalModifications())
+ TransactionContext transactionContext = ctx.getTransactionContext();
+ if (transactionContext.hasLocalModifications())
{
OptimisticPrepareCommand replicablePrepareCommand = command.copy(); // makre
sure we remove any "local" transactions
- replicablePrepareCommand.removeModifications(te.getLocalModifications());
+
replicablePrepareCommand.removeModifications(transactionContext.getLocalModifications());
command = replicablePrepareCommand;
}
@@ -147,14 +147,14 @@
@Override
public Object visitPutForExternalReadCommand(InvocationContext ctx,
PutForExternalReadCommand command) throws Throwable
{
- ctx.getTransactionEntry().setForceAsyncReplication(true);
+ ctx.getTransactionContext().setForceAsyncReplication(true);
return handleDefault(ctx, command);
}
public Object handleDefault(InvocationContext ctx, VisitableCommand command) throws
Throwable
{
if (isLocalModeForced(ctx) && command instanceof ReversibleCommand)
- ctx.getTransactionEntry().addLocalModification((ReversibleCommand) command);
+ ctx.getTransactionContext().addLocalModification((ReversibleCommand) command);
return invokeNextInterceptor(ctx, command);
}
@@ -378,13 +378,13 @@
protected TransactionWorkspace getTransactionWorkspace(InvocationContext ctx) throws
CacheException
{
- OptimisticTransactionEntry transactionEntry = (OptimisticTransactionEntry)
ctx.getTransactionEntry();
- if (transactionEntry == null)
+ OptimisticTransactionContext transactionContext = (OptimisticTransactionContext)
ctx.getTransactionContext();
+ if (transactionContext == null)
{
throw new CacheException("unable to map global transaction " + ctx +
" to transaction entry");
}
// try and get the workspace from the transaction
- return transactionEntry.getTransactionWorkSpace();
+ return transactionContext.getTransactionWorkSpace();
}
}
\ No newline at end of file
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticTxInterceptor.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticTxInterceptor.java 2008-06-25
15:10:47 UTC (rev 6037)
+++
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticTxInterceptor.java 2008-06-25
15:33:13 UTC (rev 6038)
@@ -13,8 +13,8 @@
import org.jboss.cache.commands.write.RemoveNodeCommand;
import org.jboss.cache.config.Option;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.OptimisticTransactionEntry;
-import org.jboss.cache.transaction.TransactionEntry;
+import org.jboss.cache.transaction.OptimisticTransactionContext;
+import org.jboss.cache.transaction.TransactionContext;
import javax.transaction.Transaction;
import java.util.List;
@@ -99,13 +99,13 @@
if (optionOverride != null
&& (optionOverride.isForceAsynchronous() ||
optionOverride.isForceSynchronous()))
{
- TransactionEntry entry = ctx.getTransactionEntry();
- if (entry != null)
+ TransactionContext transactionContext = ctx.getTransactionContext();
+ if (transactionContext != null)
{
if (optionOverride.isForceAsynchronous())
- entry.setForceAsyncReplication(true);
+ transactionContext.setForceAsyncReplication(true);
else
- entry.setForceSyncReplication(true);
+ transactionContext.setForceSyncReplication(true);
}
}
}
@@ -143,17 +143,17 @@
protected void cleanupStaleLocks(InvocationContext ctx) throws Throwable
{
super.cleanupStaleLocks(ctx);
- TransactionEntry entry = ctx.getTransactionEntry();
- if (entry != null)
+ TransactionContext transactionContext = ctx.getTransactionContext();
+ if (transactionContext != null)
{
- ((OptimisticTransactionEntry) entry).getTransactionWorkSpace().clearNodes();
+ ((OptimisticTransactionContext)
transactionContext).getTransactionWorkSpace().clearNodes();
}
}
@Override
- protected TransactionEntry createNewTransactionEntry(Transaction tx) throws Exception
+ protected TransactionContext createNewTransactionContext(Transaction tx) throws
Exception
{
- return new OptimisticTransactionEntry(tx);
+ return new OptimisticTransactionContext(tx);
}
private class ModificationsReplayVisitor extends AbstractVisitor
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java 2008-06-25
15:10:47 UTC (rev 6037)
+++
core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java 2008-06-25
15:33:13 UTC (rev 6038)
@@ -37,7 +37,7 @@
import org.jboss.cache.lock.LockUtil;
import org.jboss.cache.lock.PessimisticNodeBasedLockManager;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.TransactionEntry;
+import org.jboss.cache.transaction.TransactionContext;
import java.util.LinkedList;
import java.util.List;
@@ -125,7 +125,7 @@
if (!command.isOnePhaseCommit()) return invokeNextInterceptor(ctx, command);
// commit propagated up from the tx interceptor
- commit(ctx.getTransactionEntry(), ctx.getGlobalTransaction());
+ commit(ctx.getTransactionContext(), ctx.getGlobalTransaction());
Object retVal = invokeNextInterceptor(ctx, command);
lockManager.unlock(ctx);
return retVal;
@@ -134,7 +134,7 @@
@Override
protected Object handleCommitCommand(InvocationContext ctx, CommitCommand command)
throws Throwable
{
- commit(ctx.getTransactionEntry(), command.getGlobalTransaction());
+ commit(ctx.getTransactionContext(), command.getGlobalTransaction());
if (trace) log.trace("bypassed locking as method commit() doesn't require
locking");
Object retVal = invokeNextInterceptor(ctx, command);
lockManager.unlock(ctx);
@@ -144,23 +144,23 @@
@Override
protected Object handleRollbackCommand(InvocationContext ctx, RollbackCommand command)
throws Throwable
{
- TransactionEntry entry = ctx.getTransactionEntry();
+ TransactionContext transactionContext = ctx.getTransactionContext();
if (trace)
{
log.trace("called to rollback cache with GlobalTransaction=" +
command.getGlobalTransaction());
}
- if (entry == null)
+ if (transactionContext == null)
{
- log.error("entry for transaction " + command.getGlobalTransaction() +
" not found (transaction has possibly already been rolled back)");
+ log.error("transactionContext for transaction " +
command.getGlobalTransaction() + " not found (transaction has possibly already been
rolled back)");
}
else
{
- for (Fqn fqn : entry.getRemovedNodes())
+ for (Fqn fqn : transactionContext.getRemovedNodes())
{
dataContainer.removeFromDataStructure(fqn, false);
}
// 1. Revert the modifications by running the undo-op list in reverse. This
*cannot* throw any exceptions !
- entry.undoOperations();
+ transactionContext.undoOperations();
}
if (trace)
{
@@ -183,7 +183,7 @@
lockManager.lockPessimistically(ctx, command.getFqn(), WRITE, false, false,
true, false, null, false);
if (ctx.getGlobalTransaction() != null)
{
- ctx.getTransactionEntry().addRemovedNode(command.getFqn());
+ ctx.getTransactionContext().addRemovedNode(command.getFqn());
}
lockManager.lockAllAndRecord(dataContainer.peek(command.getFqn(), true, false),
WRITE, ctx);
}
@@ -215,19 +215,19 @@
// we need to mark new nodes created as deleted since they are only created to form
a path to the node being removed, to
// create a lock.
boolean created = lockManager.lockPessimistically(ctx, command.getFqn(), WRITE,
true, false, true, true, createdNodes, true);
- TransactionEntry entry = null;
+ TransactionContext transactionContext = null;
if (ctx.getGlobalTransaction() != null)
{
- entry = ctx.getTransactionEntry();
- entry.addRemovedNode(command.getFqn());
+ transactionContext = ctx.getTransactionContext();
+ transactionContext.addRemovedNode(command.getFqn());
for (NodeSPI nodeSPI : createdNodes)
{
- entry.addRemovedNode(nodeSPI.getFqn());
+ transactionContext.addRemovedNode(nodeSPI.getFqn());
nodeSPI.markAsDeleted(true);
}
}
- lockAllForRemoval(dataContainer.peek(command.getFqn(), false, false), ctx, entry);
+ lockAllForRemoval(dataContainer.peek(command.getFqn(), false, false), ctx,
transactionContext);
if (!createdNodes.isEmpty())
{
@@ -256,19 +256,19 @@
/**
* Acquires write locks on the node and all child nodes, adding children to the list
of removed nodes in the context.
*
- * @param node node to inspect
- * @param ctx invocation context
- * @param entry transaction entry
+ * @param node node to inspect
+ * @param ctx invocation context
+ * @param transactionContext transaction entry
* @throws InterruptedException in the event of interruption
*/
- public void lockAllForRemoval(NodeSPI node, InvocationContext ctx, TransactionEntry
entry) throws InterruptedException
+ public void lockAllForRemoval(NodeSPI node, InvocationContext ctx, TransactionContext
transactionContext) throws InterruptedException
{
if (node == null) return;
// lock node
lockManager.lockAndRecord(node, WRITE, ctx);
// add to deleted list
- if (entry != null) entry.addRemovedNode(node.getFqn());
+ if (transactionContext != null) transactionContext.addRemovedNode(node.getFqn());
// now children.
Map<Object, NodeSPI> children = node.getChildrenMapDirect();
@@ -277,7 +277,7 @@
for (NodeSPI child : children.values())
{
// lock child.
- lockAllForRemoval(child, ctx, entry);
+ lockAllForRemoval(child, ctx, transactionContext);
}
}
}
@@ -340,16 +340,16 @@
/**
* Remove all locks held by <tt>tx</tt>, remove the transaction from the
transaction table
*/
- private void commit(TransactionEntry entry, GlobalTransaction gtx)
+ private void commit(TransactionContext transactionContext, GlobalTransaction gtx)
{
if (trace) log.trace("committing cache with gtx " + gtx);
- if (entry == null)
+ if (transactionContext == null)
{
- log.error("entry for transaction " + gtx + " not found (maybe
already committed)");
+ log.error("transactionContext for transaction " + gtx + " not
found (maybe already committed)");
return;
}
// first remove nodes that should be deleted.
- for (Fqn fqn : entry.getRemovedNodes())
+ for (Fqn fqn : transactionContext.getRemovedNodes())
{
dataContainer.removeFromDataStructure(fqn, false);
}
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/ReplicationInterceptor.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/interceptors/ReplicationInterceptor.java 2008-06-25
15:10:47 UTC (rev 6037)
+++
core/trunk/src/main/java/org/jboss/cache/interceptors/ReplicationInterceptor.java 2008-06-25
15:33:13 UTC (rev 6038)
@@ -15,7 +15,7 @@
import org.jboss.cache.commands.write.RemoveNodeCommand;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.TransactionEntry;
+import org.jboss.cache.transaction.TransactionContext;
/**
* Takes care of replicating modifications to other nodes in a cluster. Also
@@ -40,11 +40,11 @@
public Object visitPrepareCommand(InvocationContext ctx, PrepareCommand command)
throws Throwable
{
Object retVal = invokeNextInterceptor(ctx, command);
- TransactionEntry te = ctx.getTransactionEntry();
- if (te.hasLocalModifications())
+ TransactionContext transactionContext = ctx.getTransactionContext();
+ if (transactionContext.hasLocalModifications())
{
PrepareCommand replicablePrepareCommand = command.copy(); // makre sure we
remove any "local" transactions
- replicablePrepareCommand.removeModifications(te.getLocalModifications());
+
replicablePrepareCommand.removeModifications(transactionContext.getLocalModifications());
command = replicablePrepareCommand;
}
@@ -70,8 +70,8 @@
if (isTransactionalAndLocal(ctx))
{
Object returnValue = invokeNextInterceptor(ctx, command);
- ctx.getTransactionEntry().setForceAsyncReplication(true);
- if (local) ctx.getTransactionEntry().addLocalModification(command);
+ ctx.getTransactionContext().setForceAsyncReplication(true);
+ if (local) ctx.getTransactionContext().addLocalModification(command);
return returnValue;
}
else
@@ -140,7 +140,7 @@
}
else
{
- if (local) ctx.getTransactionEntry().addLocalModification((ReversibleCommand)
command);
+ if (local) ctx.getTransactionContext().addLocalModification((ReversibleCommand)
command);
}
return returnValue;
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java 2008-06-25
15:10:47 UTC (rev 6037)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java 2008-06-25
15:33:13 UTC (rev 6038)
@@ -33,7 +33,7 @@
import org.jboss.cache.lock.LockManager;
import org.jboss.cache.notifications.Notifier;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.TransactionEntry;
+import org.jboss.cache.transaction.TransactionContext;
import org.jboss.cache.transaction.TransactionTable;
import org.jboss.cache.util.concurrent.ConcurrentHashSet;
@@ -359,22 +359,22 @@
// at this point we have a non-null ltx
// Asssociate the local TX with the global TX. Create new
- // entry for TX in txTable, the modifications
- // below will need this entry to add their modifications
+ // transactionContext for TX in txTable, the modifications
+ // below will need this transactionContext to add their modifications
// under the GlobalTx key
- TransactionEntry entry = txTable.get(gtx);
- if (entry == null)
+ TransactionContext transactionContext = txTable.get(gtx);
+ if (transactionContext == null)
{
- // create a new transaction entry
- if (log.isDebugEnabled()) log.debug("creating new tx entry");
- entry = createNewTransactionEntry(ltx);
- txTable.put(gtx, entry);
+ // create a new transaction transactionContext
+ if (log.isDebugEnabled()) log.debug("creating new tx
transactionContext");
+ transactionContext = createNewTransactionContext(ltx);
+ txTable.put(gtx, transactionContext);
}
- setTransactionalContext(ltx, gtx, entry, ctx);
+ setTransactionalContext(ltx, gtx, transactionContext, ctx);
// register a sync handler for this tx.
- registerHandler(ltx, new RemoteSynchronizationHandler(gtx, ltx, entry), ctx);
+ registerHandler(ltx, new RemoteSynchronizationHandler(gtx, ltx,
transactionContext), ctx);
success = false;
@@ -448,9 +448,9 @@
return retval;
}
- protected TransactionEntry createNewTransactionEntry(Transaction tx) throws Exception
+ protected TransactionContext createNewTransactionContext(Transaction tx) throws
Exception
{
- return new TransactionEntry(tx);
+ return new TransactionContext(tx);
}
private ReplicableCommand attachGlobalTransaction(InvocationContext ctx, Transaction
tx, VisitableCommand command) throws Throwable
@@ -599,8 +599,8 @@
protected void cleanupStaleLocks(InvocationContext ctx) throws Throwable
{
- TransactionEntry entry = ctx.getTransactionEntry();
- if (entry != null) lockManager.unlock(ctx);
+ TransactionContext transactionContext = ctx.getTransactionContext();
+ if (transactionContext != null) lockManager.unlock(ctx);
}
/**
@@ -736,16 +736,16 @@
if (TransactionTable.isValid(tx) && transactions.add(tx))
{
gtx = txTable.getCurrentTransaction(tx, true);
- TransactionEntry entry;
+ TransactionContext transactionContext;
if (ctx.getGlobalTransaction() == null)
{
ctx.setGlobalTransaction(gtx);
- entry = txTable.get(gtx);
- ctx.setTransactionEntry(entry);
+ transactionContext = txTable.get(gtx);
+ ctx.setTransactionContext(transactionContext);
}
else
{
- entry = ctx.getTransactionEntry();
+ transactionContext = ctx.getTransactionContext();
}
if (gtx.isRemote())
{
@@ -757,7 +757,7 @@
if (trace) log.trace("Registering sync handler for tx " + tx +
", gtx " + gtx);
// see the comment in the LocalSyncHandler for the last isOriginLocal param.
- LocalSynchronizationHandler myHandler = new LocalSynchronizationHandler(gtx,
tx, entry, !ctx.isOriginLocal());
+ LocalSynchronizationHandler myHandler = new LocalSynchronizationHandler(gtx,
tx, transactionContext, !ctx.isOriginLocal());
registerHandler(tx, myHandler, ctx);
}
}
@@ -781,7 +781,7 @@
*/
private void registerHandler(Transaction tx, Synchronization handler,
InvocationContext ctx) throws Exception
{
- OrderedSynchronizationHandler orderedHandler =
ctx.getTransactionEntry().getOrderedSynchronizationHandler();
//OrderedSynchronizationHandler.getInstance(tx);
+ OrderedSynchronizationHandler orderedHandler =
ctx.getTransactionContext().getOrderedSynchronizationHandler();
//OrderedSynchronizationHandler.getInstance(tx);
if (trace) log.trace("registering for TX completion:
SynchronizationHandler(" + handler + ")");
@@ -893,31 +893,32 @@
Transaction tx = null;
GlobalTransaction gtx = null;
List<ReversibleCommand> modifications = null;
- TransactionEntry entry = null;
+ TransactionContext transactionContext = null;
protected InvocationContext ctx; // the context for this call.
- RemoteSynchronizationHandler(GlobalTransaction gtx, Transaction tx,
TransactionEntry entry)
+ RemoteSynchronizationHandler(GlobalTransaction gtx, Transaction tx,
TransactionContext entry)
{
this.gtx = gtx;
this.tx = tx;
- this.entry = entry;
+ this.transactionContext = entry;
}
public void beforeCompletion()
{
if (trace) log.trace("Running beforeCompletion on gtx " + gtx);
- if (entry == null)
+ if (transactionContext == null)
{
log.error("Transaction has a null transaction entry - beforeCompletion()
will fail.");
throw new IllegalStateException("cannot find transaction entry for
" + gtx);
}
- modifications = entry.getModifications();
+ modifications = transactionContext.getModifications();
ctx = invocationContextContainer.get();
- setTransactionalContext(tx, gtx, entry, ctx);
+ setTransactionalContext(tx, gtx, transactionContext, ctx);
- if (ctx.isOptionsUninitialised() && entry.getOption() != null)
ctx.setOptionOverrides(entry.getOption());
+ if (ctx.isOptionsUninitialised() && transactionContext.getOption() !=
null)
+ ctx.setOptionOverrides(transactionContext.getOption());
assertCanContinue();
@@ -932,12 +933,12 @@
if (ctx == null)
{
ctx = invocationContextContainer.get();
- setTransactionalContext(tx, gtx, entry, ctx);
+ setTransactionalContext(tx, gtx, transactionContext, ctx);
- if (ctx.isOptionsUninitialised() && entry != null &&
entry.getOption() != null)
+ if (ctx.isOptionsUninitialised() && transactionContext != null
&& transactionContext.getOption() != null)
{
// use the options from the transaction entry instead
- ctx.setOptionOverrides(entry.getOption());
+ ctx.setOptionOverrides(transactionContext.getOption());
}
}
@@ -957,11 +958,11 @@
if (trace) log.trace("calling aftercompletion for " + gtx);
// set any transaction wide options as current for this thread.
- if (entry != null)
+ if (transactionContext != null)
{
// this should ideally be set in beforeCompletion(), after compacting the
list.
- if (modifications == null) modifications = entry.getModifications();
- ctx.setOptionOverrides(entry.getOption());
+ if (modifications == null) modifications =
transactionContext.getModifications();
+ ctx.setOptionOverrides(transactionContext.getOption());
}
if (tx != null) transactions.remove(tx);
@@ -1017,8 +1018,8 @@
tx = null;
gtx = null;
modifications = null;
- if (entry != null) entry.reset();
- entry = null;
+ if (transactionContext != null) transactionContext.reset();
+ transactionContext = null;
}
@Override
@@ -1059,9 +1060,9 @@
* @param tx
* @param remoteLocal
*/
- LocalSynchronizationHandler(GlobalTransaction gtx, Transaction tx, TransactionEntry
entry, boolean remoteLocal)
+ LocalSynchronizationHandler(GlobalTransaction gtx, Transaction tx,
TransactionContext transactionContext, boolean remoteLocal)
{
- super(gtx, tx, entry);
+ super(gtx, tx, transactionContext);
this.remoteLocal = remoteLocal;
}
@@ -1072,8 +1073,8 @@
ctx.setOriginLocal(!remoteLocal); // this is the LOCAL sync handler after all!
// fetch the modifications before the transaction is committed
// (and thus removed from the txTable)
- setTransactionalContext(tx, gtx, entry, ctx);
- if (!entry.hasModifications())
+ setTransactionalContext(tx, gtx, transactionContext, ctx);
+ if (!transactionContext.hasModifications())
{
if (trace) log.trace("No modifications in this tx. Skipping
beforeCompletion()");
modifications = Collections.emptyList();
@@ -1082,7 +1083,7 @@
// set any transaction wide options as current for this thread, caching original
options that would then be reset
originalOptions = ctx.getOptionOverrides();
- transactionalOptions = entry.getOption();
+ transactionalOptions = transactionContext.getOption();
ctx.setOptionOverrides(transactionalOptions);
try
@@ -1139,7 +1140,7 @@
// could happen if a rollback is called and beforeCompletion() doesn't get
called.
if (ctx == null) ctx = invocationContextContainer.get();
ctx.setLocalRollbackOnly(localRollbackOnly);
- setTransactionalContext(tx, gtx, entry, ctx);
+ setTransactionalContext(tx, gtx, transactionContext, ctx);
ctx.setOptionOverrides(transactionalOptions);
try
{
Modified: core/trunk/src/main/java/org/jboss/cache/lock/LockUtil.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/lock/LockUtil.java 2008-06-25 15:10:47 UTC
(rev 6037)
+++ core/trunk/src/main/java/org/jboss/cache/lock/LockUtil.java 2008-06-25 15:33:13 UTC
(rev 6038)
@@ -9,7 +9,7 @@
import org.jboss.cache.factories.CommandsFactory;
import org.jboss.cache.statetransfer.StateTransferManager;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.TransactionEntry;
+import org.jboss.cache.transaction.TransactionContext;
import org.jboss.cache.transaction.TransactionTable;
import javax.transaction.Status;
@@ -216,15 +216,15 @@
if (ctx.getGlobalTransaction() != null) //if no tx then reverse remove does not
make sense
{
Fqn fqn = childNode.getFqn();
- TransactionEntry entry = ctx.getTransactionEntry();
- boolean needToReverseRemove = reverseRemoveCheck &&
childNode.isDeleted() && entry != null &&
entry.getRemovedNodes().contains(fqn);
+ TransactionContext transactionContext = ctx.getTransactionContext();
+ boolean needToReverseRemove = reverseRemoveCheck &&
childNode.isDeleted() && transactionContext != null &&
transactionContext.getRemovedNodes().contains(fqn);
if (!needToReverseRemove) return;
childNode.markAsDeleted(false);
//if we'll rollback the tx data should be added to the node again
Map oldData = new HashMap(childNode.getDataDirect());
PutDataMapCommand command =
commandsFactory.buildPutDataMapCommand(ctx.getGlobalTransaction(), fqn, oldData);
// txTable.get(gtx).addUndoOperation(command); --- now need to make sure this is
added to the normal mods list instead
- entry.addModification(command);
+ transactionContext.addModification(command);
//we're prepared for rollback, now reset the node
childNode.clearDataDirect();
if (createdNodes != null)
Copied:
core/trunk/src/main/java/org/jboss/cache/transaction/OptimisticTransactionContext.java
(from rev 6034,
core/trunk/src/main/java/org/jboss/cache/transaction/OptimisticTransactionEntry.java)
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/transaction/OptimisticTransactionContext.java
(rev 0)
+++
core/trunk/src/main/java/org/jboss/cache/transaction/OptimisticTransactionContext.java 2008-06-25
15:33:13 UTC (rev 6038)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at
gnu.org.
+ */
+package org.jboss.cache.transaction;
+
+import org.jboss.cache.optimistic.TransactionWorkspace;
+import org.jboss.cache.optimistic.TransactionWorkspaceImpl;
+
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+
+/**
+ * Subclasses the {@link TransactionContext} class to add a {@link TransactionWorkspace}.
Used with optimistic locking
+ * where each call is assigned a trasnaction and a transaction workspace.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani
(manik(a)jboss.org)</a>
+ * @author <a href="mailto:stevew@jofti.com">Steve Woodcock
(stevew(a)jofti.com)</a>
+ */
+
+public class OptimisticTransactionContext extends TransactionContext
+{
+ private TransactionWorkspace transactionWorkSpace = new TransactionWorkspaceImpl();
+
+ public OptimisticTransactionContext(Transaction tx) throws SystemException,
RollbackException
+ {
+ super(tx);
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuffer sb = new StringBuffer(super.toString());
+ sb.append("\nworkspace: ").append(transactionWorkSpace);
+ return sb.toString();
+ }
+
+ /**
+ * @return Returns the transactionWorkSpace.
+ */
+ public TransactionWorkspace getTransactionWorkSpace()
+ {
+ return transactionWorkSpace;
+ }
+
+ /**
+ * @param transactionWorkSpace The transactionWorkSpace to set.
+ */
+ public void setTransactionWorkSpace(TransactionWorkspace transactionWorkSpace)
+ {
+ this.transactionWorkSpace = transactionWorkSpace;
+ }
+
+}
Property changes on:
core/trunk/src/main/java/org/jboss/cache/transaction/OptimisticTransactionContext.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Deleted:
core/trunk/src/main/java/org/jboss/cache/transaction/OptimisticTransactionEntry.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/transaction/OptimisticTransactionEntry.java 2008-06-25
15:10:47 UTC (rev 6037)
+++
core/trunk/src/main/java/org/jboss/cache/transaction/OptimisticTransactionEntry.java 2008-06-25
15:33:13 UTC (rev 6038)
@@ -1,57 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at
gnu.org.
- */
-package org.jboss.cache.transaction;
-
-import org.jboss.cache.optimistic.TransactionWorkspace;
-import org.jboss.cache.optimistic.TransactionWorkspaceImpl;
-
-import javax.transaction.RollbackException;
-import javax.transaction.SystemException;
-import javax.transaction.Transaction;
-
-/**
- * Subclasses the {@link TransactionEntry} class to add a {@link TransactionWorkspace}.
Used with optimistic locking
- * where each call is assigned a trasnaction and a transaction workspace.
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani
(manik(a)jboss.org)</a>
- * @author <a href="mailto:stevew@jofti.com">Steve Woodcock
(stevew(a)jofti.com)</a>
- */
-
-public class OptimisticTransactionEntry extends TransactionEntry
-{
- private TransactionWorkspace transactionWorkSpace = new TransactionWorkspaceImpl();
-
- public OptimisticTransactionEntry(Transaction tx) throws SystemException,
RollbackException
- {
- super(tx);
- }
-
- @Override
- public String toString()
- {
- StringBuffer sb = new StringBuffer(super.toString());
- sb.append("\nworkspace: ").append(transactionWorkSpace);
- return sb.toString();
- }
-
- /**
- * @return Returns the transactionWorkSpace.
- */
- public TransactionWorkspace getTransactionWorkSpace()
- {
- return transactionWorkSpace;
- }
-
- /**
- * @param transactionWorkSpace The transactionWorkSpace to set.
- */
- public void setTransactionWorkSpace(TransactionWorkspace transactionWorkSpace)
- {
- this.transactionWorkSpace = transactionWorkSpace;
- }
-
-}
Copied: core/trunk/src/main/java/org/jboss/cache/transaction/TransactionContext.java (from
rev 6034, core/trunk/src/main/java/org/jboss/cache/transaction/TransactionEntry.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/TransactionContext.java
(rev 0)
+++
core/trunk/src/main/java/org/jboss/cache/transaction/TransactionContext.java 2008-06-25
15:33:13 UTC (rev 6038)
@@ -0,0 +1,462 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at
gnu.org.
+ */
+package org.jboss.cache.transaction;
+
+
+import net.jcip.annotations.ThreadSafe;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.NodeSPI;
+import org.jboss.cache.commands.ReversibleCommand;
+import org.jboss.cache.config.Option;
+import org.jboss.cache.interceptors.OrderedSynchronizationHandler;
+import org.jboss.cache.lock.NodeLock;
+
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+
+/**
+ * Information associated with a {@link GlobalTransaction} about the transaction state.
+ * <p/>
+ * A TransactionContext maintains:
+ * <ul>
+ * <li>Handle to the local Transaction</li>
+ * <li>List of {@link org.jboss.cache.commands.ReversibleCommand}s that make up
this transaction</li>
+ * <li>List of locks acquired</li>
+ * <li>Any transaction-scope options</li>
+ * </ul>
+ *
+ * @author <a href="mailto:bela@jboss.org">Bela Ban</a>
+ * @author Manik Surtani
+ * @version $Revision$
+ */
+@ThreadSafe
+public class TransactionContext
+{
+
+ private static final Log log = LogFactory.getLog(TransactionContext.class);
+ private static final boolean trace = log.isTraceEnabled();
+
+ /**
+ * Local transaction
+ */
+ private Transaction ltx = null;
+ private Option option;
+ private OrderedSynchronizationHandler orderedSynchronizationHandler;
+
+ private boolean forceAsyncReplication = false;
+ private boolean forceSyncReplication = false;
+
+ /**
+ * List<ReversibleCommand> of modifications ({@link ReversibleCommand}).
They will be replicated on TX commit
+ */
+ private List<ReversibleCommand> modificationList;
+ /**
+ * A list of modifications that have been encountered with a LOCAL mode option. These
will be removed from the modification list during replication.
+ */
+ private List<ReversibleCommand> localModifications;
+
+ /**
+ * LinkedHashSet of locks acquired by the transaction. We use a LinkedHashSet because
we need efficient Set semantics
+ * but also need guaranteed ordering for use by lock release code (see JBCCACHE-874).
+ * <p/>
+ * This needs to be unchecked since we support both MVCC (Fqns held here) or legacy
Opt/Pess locking (NodeLocks held here).
+ * once we drop support for opt/pess locks we can genericise this to contain Fqns. -
Manik Surtani, June 2008
+ */
+ private LinkedHashSet transactionLocks;
+ private final Map<Fqn, NodeSPI> lookedUpNodes = new HashMap<Fqn,
NodeSPI>();
+
+
+ /**
+ * A list of dummy uninitialised nodes created by the cache loader interceptor to load
data for a
+ * given node in this tx.
+ */
+ private List<Fqn> dummyNodesCreatedByCacheLoader;
+
+ /**
+ * List<Fqn> of nodes that have been removed by the transaction
+ */
+ private final List<Fqn> removedNodes = new LinkedList<Fqn>();
+
+ public TransactionContext(Transaction tx) throws SystemException, RollbackException
+ {
+ ltx = tx;
+ orderedSynchronizationHandler = new OrderedSynchronizationHandler(tx);
+ }
+
+ /**
+ * Adds a modification to the modification list.
+ */
+ public void addModification(ReversibleCommand command)
+ {
+ if (command == null) return;
+ if (modificationList == null) modificationList = new
LinkedList<ReversibleCommand>();
+ modificationList.add(command);
+ }
+
+ /**
+ * Returns all modifications.
+ */
+ public List<ReversibleCommand> getModifications()
+ {
+ if (modificationList == null) return Collections.emptyList();
+ return modificationList;
+ }
+
+ /**
+ * Adds a modification to the local modification list.
+ */
+ public void addLocalModification(ReversibleCommand command)
+ {
+ if (command == null) return;
+ if (localModifications == null) localModifications = new
LinkedList<ReversibleCommand>();
+ localModifications.add(command);
+ }
+
+ /**
+ * Returns all modifications that have been invoked with the LOCAL cache mode option.
These will also be in the standard modification list.
+ */
+ public List<ReversibleCommand> getLocalModifications()
+ {
+ if (localModifications == null) return Collections.emptyList();
+ return localModifications;
+ }
+
+
+ /**
+ * Adds the node that has been removed.
+ *
+ * @param fqn
+ */
+ public void addRemovedNode(Fqn fqn)
+ {
+ removedNodes.add(fqn);
+ }
+
+ /**
+ * Gets the list of removed nodes.
+ */
+ public List<Fqn> getRemovedNodes()
+ {
+ return new ArrayList<Fqn>(removedNodes);
+ }
+
+ /**
+ * Sets the local transaction for this entry.
+ */
+ public void setTransaction(Transaction tx)
+ {
+ ltx = tx;
+ }
+
+ /**
+ * Returns a local transaction associated with this TransactionEntry
+ */
+ public Transaction getTransaction()
+ {
+ return ltx;
+ }
+
+ /**
+ * Adds a lock to the currently maintained collection of locks acquired.
+ * <p/>
+ * Most code could not use this method directly, but use {@link
org.jboss.cache.InvocationContext#addLock(Object)} instead,
+ * which would delegate to this method if a transaction is in scope or otherwise use
invocation-specific locks.
+ * <p/>
+ * Note that currently (as of 3.0.0) this lock is weakly typed. This is to allow
support for both MVCC (which uses {@link Fqn}s as locks)
+ * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link
NodeLock} as locks). Once support for
+ * legacy node locking schemes are dropped, this method will be more strongly typed to
accept {@link Fqn}.
+ *
+ * @param lock lock to add
+ * @see org.jboss.cache.InvocationContext#addLock(Object)
+ */
+ @SuppressWarnings("unchecked")
+ public void addLock(Object lock)
+ {
+ // no need to worry about concurrency here - a context is only valid for a single
thread.
+ if (transactionLocks == null) transactionLocks = new LinkedHashSet(5);
+ transactionLocks.add(lock);
+ }
+
+ /**
+ * Removes a lock from the currently maintained collection of locks acquired.
+ * <p/>
+ * Most code could not use this method directly, but use {@link
org.jboss.cache.InvocationContext#removeLock(Object)} instead,
+ * which would delegate to this method if a transaction is in scope or otherwise use
invocation-specific locks.
+ * <p/>
+ * Note that currently (as of 3.0.0) this lock is weakly typed. This is to allow
support for both MVCC (which uses {@link Fqn}s as locks)
+ * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link
NodeLock} as locks). Once support for
+ * legacy node locking schemes are dropped, this method will be more strongly typed to
accept {@link Fqn}.
+ *
+ * @param lock lock to remove
+ * @see org.jboss.cache.InvocationContext#removeLock(Object)
+ */
+ @SuppressWarnings("unchecked")
+ public void removeLock(Object lock)
+ {
+ // no need to worry about concurrency here - a context is only valid for a single
thread.
+ if (transactionLocks != null) transactionLocks.remove(lock);
+ }
+
+ /**
+ * Clears all locks from the currently maintained collection of locks acquired.
+ * <p/>
+ * Most code could not use this method directly, but use {@link
org.jboss.cache.InvocationContext#clearLocks()} instead,
+ * which would delegate to this method if a transaction is in scope or otherwise use
invocation-specific locks.
+ * <p/>
+ * Note that currently (as of 3.0.0) this lock is weakly typed. This is to allow
support for both MVCC (which uses {@link Fqn}s as locks)
+ * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link
NodeLock} as locks). Once support for
+ * legacy node locking schemes are dropped, this method will be more strongly typed to
accept {@link Fqn}.
+ *
+ * @see org.jboss.cache.InvocationContext#clearLocks()
+ */
+ public void clearLocks()
+ {
+ if (transactionLocks != null) transactionLocks.clear();
+ }
+
+
+ /**
+ * Adds a List of locks to the currently maintained collection of locks acquired.
+ * <p/>
+ * Most code could not use this method directly, but use {@link
org.jboss.cache.InvocationContext#addAllLocks(java.util.List)} instead,
+ * which would delegate to this method if a transaction is in scope or otherwise use
invocation-specific locks.
+ * <p/>
+ * Note that currently (as of 3.0.0) this list is unchecked. This is to allow support
for both MVCC (which uses Fqns as locks)
+ * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link
NodeLock} as locks). Once support for
+ * legacy node locking schemes are dropped, this method will be more strongly typed to
accept <tt>List<Fqn></tt>.
+ *
+ * @param newLocks locks to add
+ * @see org.jboss.cache.InvocationContext#addAllLocks(java.util.List)
+ */
+ @SuppressWarnings("unchecked")
+ public void addAllLocks(List newLocks)
+ {
+ // no need to worry about concurrency here - a context is only valid for a single
thread.
+ if (transactionLocks == null) transactionLocks = new LinkedHashSet(5);
+ transactionLocks.addAll(newLocks);
+ }
+
+ /**
+ * Returns an immutable, defensive copy of the List of locks currently maintained for
the transaction.
+ * <p/>
+ * Most code could not use this method directly, but use {@link
org.jboss.cache.InvocationContext#getLocks()} instead,
+ * which would delegate to this method if a transaction is in scope or otherwise use
invocation-specific locks.
+ * <p/>
+ * Note that currently (as of 3.0.0) this list is unchecked. This is to allow support
for both MVCC (which uses Fqns as locks)
+ * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link
NodeLock} as locks). Once support for
+ * legacy node locking schemes are dropped, this method will be more strongly typed to
return <tt>List<Fqn></tt>.
+ *
+ * @return locks held in current scope.
+ * @see org.jboss.cache.InvocationContext#getLocks()
+ */
+ @SuppressWarnings("unchecked")
+ public List getLocks()
+ {
+ return Collections.unmodifiableList(new ArrayList(transactionLocks));
+ }
+
+
+ /**
+ * Gets the value of the forceAsyncReplication flag. Used by ReplicationInterceptor
and OptimisticReplicationInterceptor
+ * when dealing with {@link
org.jboss.cache.Cache#putForExternalRead(org.jboss.cache.Fqn,Object,Object)} within
+ * a transactional context.
+ *
+ * @return true if the forceAsyncReplication flag is set to true.
+ */
+ public boolean isForceAsyncReplication()
+ {
+ return forceAsyncReplication;
+ }
+
+ /**
+ * Sets the value of the forceAsyncReplication flag. Used by ReplicationInterceptor
and OptimisticReplicationInterceptor
+ * when dealing with {@link
org.jboss.cache.Cache#putForExternalRead(org.jboss.cache.Fqn,Object,Object)} within
+ * a transactional context. Also used by OptimisticReplicationInterceptor when
dealing
+ * with {@link org.jboss.cache.config.Option#setForceAsynchronous(boolean)} in a
+ * non-transactional context (i.e. with an implicit transaction).
+ *
+ * @param forceAsyncReplication value of forceAsyncReplication
+ */
+ public void setForceAsyncReplication(boolean forceAsyncReplication)
+ {
+ this.forceAsyncReplication = forceAsyncReplication;
+ if (forceAsyncReplication)
+ {
+ forceSyncReplication = false;
+ }
+ }
+
+ /**
+ * Gets the value of the forceSyncReplication flag. Used by ReplicationInterceptor
and OptimisticReplicationInterceptor
+ * when dealing with {@link
org.jboss.cache.Cache#putForExternalRead(org.jboss.cache.Fqn,Object,Object)} within
+ * a transactional context.
+ *
+ * @return true if the forceAsyncReplication flag is set to true.
+ */
+ public boolean isForceSyncReplication()
+ {
+ return forceSyncReplication;
+ }
+
+ /**
+ * Sets the value of the forceSyncReplication flag. Used by ReplicationInterceptor
and OptimisticReplicationInterceptor
+ * when dealing with {@link
org.jboss.cache.Cache#putForExternalRead(org.jboss.cache.Fqn,Object,Object)} within
+ * a transactional context.
+ *
+ * @param forceSyncReplication value of forceSyncReplication
+ */
+ public void setForceSyncReplication(boolean forceSyncReplication)
+ {
+ this.forceSyncReplication = forceSyncReplication;
+ if (forceSyncReplication)
+ {
+ forceAsyncReplication = false;
+ }
+ }
+
+
+ /**
+ * Posts all undo operations to the CacheImpl.
+ */
+ public void undoOperations()
+ {
+ if (modificationList == null)
+ {
+ if (trace) log.trace("Modification list is null, no modifications in this
transaction!");
+ return;
+ }
+
+ if (trace) log.trace("undoOperations " + modificationList);
+
+ ArrayList<ReversibleCommand> copy;
+// synchronized (modificationList)
+// {
+ // no need to sync? Only one thread would access a transaction at any given time?
+ copy = new ArrayList<ReversibleCommand>(modificationList);
+// }
+ for (ListIterator i = copy.listIterator(copy.size()); i.hasPrevious();)
+ {
+ Object undoOp = i.previous();
+ ReversibleCommand txCommand = (ReversibleCommand) undoOp;
+ if (log.isDebugEnabled()) log.debug("Calling rollback() on command " +
undoOp);
+ txCommand.rollback();
+ }
+ }
+
+ /**
+ * Returns debug information about this transaction.
+ */
+ @Override
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.append("TransactionEntry\nmodificationList:
").append(modificationList);
+ return sb.toString();
+ }
+
+ public void loadUninitialisedNode(Fqn fqn)
+ {
+ if (dummyNodesCreatedByCacheLoader == null)
+ dummyNodesCreatedByCacheLoader = new LinkedList<Fqn>();
+ dummyNodesCreatedByCacheLoader.add(fqn);
+ }
+
+ public List<Fqn> getDummyNodesCreatedByCacheLoader()
+ {
+ return dummyNodesCreatedByCacheLoader;
+ }
+
+ /**
+ * Sets a transaction-scope option override
+ *
+ * @param o
+ */
+ public void setOption(Option o)
+ {
+ this.option = o;
+ }
+
+ /**
+ * Retrieves a transaction scope option override
+ */
+ public Option getOption()
+ {
+ return this.option;
+ }
+
+ public OrderedSynchronizationHandler getOrderedSynchronizationHandler()
+ {
+ return orderedSynchronizationHandler;
+ }
+
+ public void setOrderedSynchronizationHandler(OrderedSynchronizationHandler
orderedSynchronizationHandler)
+ {
+ this.orderedSynchronizationHandler = orderedSynchronizationHandler;
+ }
+
+ /**
+ * Returns true if modifications were registered to either modificationList or to
class loader modifications list.
+ */
+ public boolean hasModifications()
+ {
+ return modificationList != null && !modificationList.isEmpty();
+ }
+
+ /**
+ * @return true if any modifications have been invoked with cache mode being LOCAL.
+ */
+ public boolean hasLocalModifications()
+ {
+ return localModifications != null && !localModifications.isEmpty();
+ }
+
+ public NodeSPI lookUpNode(Fqn fqn)
+ {
+ return lookedUpNodes.get(fqn);
+ }
+
+ public void putLookedUpNode(Fqn f, NodeSPI n)
+ {
+ lookedUpNodes.put(f, n);
+ }
+
+ public void clearLookedUpNodes()
+ {
+ lookedUpNodes.clear();
+ }
+
+ public Map<Fqn, NodeSPI> getLookedUpNodes()
+ {
+ return lookedUpNodes;
+ }
+
+
+ /**
+ * Cleans up internal state
+ */
+ public void reset()
+ {
+ orderedSynchronizationHandler = null;
+ if (modificationList != null) modificationList = null;
+ if (localModifications != null) localModifications = null;
+ option = null;
+ transactionLocks.clear();
+ if (dummyNodesCreatedByCacheLoader != null)
dummyNodesCreatedByCacheLoader.clear();
+ removedNodes.clear();
+ }
+}
Property changes on:
core/trunk/src/main/java/org/jboss/cache/transaction/TransactionContext.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Deleted: core/trunk/src/main/java/org/jboss/cache/transaction/TransactionEntry.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/TransactionEntry.java 2008-06-25
15:10:47 UTC (rev 6037)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/TransactionEntry.java 2008-06-25
15:33:13 UTC (rev 6038)
@@ -1,465 +0,0 @@
-/*
- * JBoss, the OpenSource J2EE webOS
- *
- * Distributable under LGPL license.
- * See terms of license at
gnu.org.
- */
-package org.jboss.cache.transaction;
-
-
-import net.jcip.annotations.ThreadSafe;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.Modification;
-import org.jboss.cache.NodeSPI;
-import org.jboss.cache.commands.ReversibleCommand;
-import org.jboss.cache.config.Option;
-import org.jboss.cache.interceptors.OrderedSynchronizationHandler;
-import org.jboss.cache.lock.IdentityLock;
-import org.jboss.cache.lock.NodeLock;
-
-import javax.transaction.RollbackException;
-import javax.transaction.SystemException;
-import javax.transaction.Transaction;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-
-/**
- * Information associated with a {@link GlobalTransaction} about the transaction state.
- * <p/>
- * A TransactionEntry maintains:
- * <ul>
- * <li>Handle to local Transactions: there can be more than 1 local TX associated
with a GlobalTransaction
- * <li>List of modifications ({@link Modification})
- * <li>List of nodes that were created as part of lock acquisition. These nodes can
be
- * safely deleted when a transaction is rolled back
- * <li>List of locks ({@link IdentityLock}) that have been acquired by
- * this transaction so far
- * </ul>
- *
- * @author <a href="mailto:bela@jboss.org">Bela Ban</a> Apr 14,
2003
- * @version $Revision$
- */
-@ThreadSafe
-public class TransactionEntry
-{
-
- private static final Log log = LogFactory.getLog(TransactionEntry.class);
- private static final boolean trace = log.isTraceEnabled();
-
- /**
- * Local transaction
- */
- private Transaction ltx = null;
- private Option option;
- private OrderedSynchronizationHandler orderedSynchronizationHandler;
-
- private boolean forceAsyncReplication = false;
- private boolean forceSyncReplication = false;
-
- /**
- * List<ReversibleCommand> of modifications ({@link ReversibleCommand}).
They will be replicated on TX commit
- */
- private List<ReversibleCommand> modificationList;
- /**
- * A list of modifications that have been encountered with a LOCAL mode option. These
will be removed from the modification list during replication.
- */
- private List<ReversibleCommand> localModifications;
-
- /**
- * LinkedHashSet of locks acquired by the transaction. We use a LinkedHashSet because
we need efficient Set semantics
- * but also need guaranteed ordering for use by lock release code (see JBCCACHE-874).
- * <p/>
- * This needs to be unchecked since we support both MVCC (Fqns held here) or legacy
Opt/Pess locking (NodeLocks held here).
- * once we drop support for opt/pess locks we can genericise this to contain Fqns. -
Manik Surtani, June 2008
- */
- private LinkedHashSet transactionLocks;
- private final Map<Fqn, NodeSPI> lookedUpNodes = new HashMap<Fqn,
NodeSPI>();
-
-
- /**
- * A list of dummy uninitialised nodes created by the cache loader interceptor to load
data for a
- * given node in this tx.
- */
- private List<Fqn> dummyNodesCreatedByCacheLoader;
-
- /**
- * List<Fqn> of nodes that have been removed by the transaction
- */
- private final List<Fqn> removedNodes = new LinkedList<Fqn>();
-
- public TransactionEntry(Transaction tx) throws SystemException, RollbackException
- {
- ltx = tx;
- orderedSynchronizationHandler = new OrderedSynchronizationHandler(tx);
- }
-
- /**
- * Adds a modification to the modification list.
- */
- public void addModification(ReversibleCommand command)
- {
- if (command == null) return;
- if (modificationList == null) modificationList = new
LinkedList<ReversibleCommand>();
- modificationList.add(command);
- }
-
- /**
- * Returns all modifications.
- */
- public List<ReversibleCommand> getModifications()
- {
- if (modificationList == null) return Collections.emptyList();
- return modificationList;
- }
-
- /**
- * Adds a modification to the local modification list.
- */
- public void addLocalModification(ReversibleCommand command)
- {
- if (command == null) return;
- if (localModifications == null) localModifications = new
LinkedList<ReversibleCommand>();
- localModifications.add(command);
- }
-
- /**
- * Returns all modifications that have been invoked with the LOCAL cache mode option.
These will also be in the standard modification list.
- */
- public List<ReversibleCommand> getLocalModifications()
- {
- if (localModifications == null) return Collections.emptyList();
- return localModifications;
- }
-
-
- /**
- * Adds the node that has been removed.
- *
- * @param fqn
- */
- public void addRemovedNode(Fqn fqn)
- {
- removedNodes.add(fqn);
- }
-
- /**
- * Gets the list of removed nodes.
- */
- public List<Fqn> getRemovedNodes()
- {
- return new ArrayList<Fqn>(removedNodes);
- }
-
- /**
- * Sets the local transaction for this entry.
- */
- public void setTransaction(Transaction tx)
- {
- ltx = tx;
- }
-
- /**
- * Returns a local transaction associated with this TransactionEntry
- */
- public Transaction getTransaction()
- {
- return ltx;
- }
-
- /**
- * Adds a lock to the currently maintained collection of locks acquired.
- * <p/>
- * Most code could not use this method directly, but use {@link
org.jboss.cache.InvocationContext#addLock(Object)} instead,
- * which would delegate to this method if a transaction is in scope or otherwise use
invocation-specific locks.
- * <p/>
- * Note that currently (as of 3.0.0) this lock is weakly typed. This is to allow
support for both MVCC (which uses {@link Fqn}s as locks)
- * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link
NodeLock} as locks). Once support for
- * legacy node locking schemes are dropped, this method will be more strongly typed to
accept {@link Fqn}.
- *
- * @param lock lock to add
- * @see org.jboss.cache.InvocationContext#addLock(Object)
- */
- @SuppressWarnings("unchecked")
- public void addLock(Object lock)
- {
- // no need to worry about concurrency here - a context is only valid for a single
thread.
- if (transactionLocks == null) transactionLocks = new LinkedHashSet(5);
- transactionLocks.add(lock);
- }
-
- /**
- * Removes a lock from the currently maintained collection of locks acquired.
- * <p/>
- * Most code could not use this method directly, but use {@link
org.jboss.cache.InvocationContext#removeLock(Object)} instead,
- * which would delegate to this method if a transaction is in scope or otherwise use
invocation-specific locks.
- * <p/>
- * Note that currently (as of 3.0.0) this lock is weakly typed. This is to allow
support for both MVCC (which uses {@link Fqn}s as locks)
- * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link
NodeLock} as locks). Once support for
- * legacy node locking schemes are dropped, this method will be more strongly typed to
accept {@link Fqn}.
- *
- * @param lock lock to remove
- * @see org.jboss.cache.InvocationContext#removeLock(Object)
- */
- @SuppressWarnings("unchecked")
- public void removeLock(Object lock)
- {
- // no need to worry about concurrency here - a context is only valid for a single
thread.
- if (transactionLocks != null) transactionLocks.remove(lock);
- }
-
- /**
- * Clears all locks from the currently maintained collection of locks acquired.
- * <p/>
- * Most code could not use this method directly, but use {@link
org.jboss.cache.InvocationContext#clearLocks()} instead,
- * which would delegate to this method if a transaction is in scope or otherwise use
invocation-specific locks.
- * <p/>
- * Note that currently (as of 3.0.0) this lock is weakly typed. This is to allow
support for both MVCC (which uses {@link Fqn}s as locks)
- * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link
NodeLock} as locks). Once support for
- * legacy node locking schemes are dropped, this method will be more strongly typed to
accept {@link Fqn}.
- *
- * @see org.jboss.cache.InvocationContext#clearLocks()
- */
- public void clearLocks()
- {
- if (transactionLocks != null) transactionLocks.clear();
- }
-
-
- /**
- * Adds a List of locks to the currently maintained collection of locks acquired.
- * <p/>
- * Most code could not use this method directly, but use {@link
org.jboss.cache.InvocationContext#addAllLocks(java.util.List)} instead,
- * which would delegate to this method if a transaction is in scope or otherwise use
invocation-specific locks.
- * <p/>
- * Note that currently (as of 3.0.0) this list is unchecked. This is to allow support
for both MVCC (which uses Fqns as locks)
- * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link
NodeLock} as locks). Once support for
- * legacy node locking schemes are dropped, this method will be more strongly typed to
accept <tt>List<Fqn></tt>.
- *
- * @param newLocks locks to add
- * @see org.jboss.cache.InvocationContext#addAllLocks(java.util.List)
- */
- @SuppressWarnings("unchecked")
- public void addAllLocks(List newLocks)
- {
- // no need to worry about concurrency here - a context is only valid for a single
thread.
- if (transactionLocks == null) transactionLocks = new LinkedHashSet(5);
- transactionLocks.addAll(newLocks);
- }
-
- /**
- * Returns an immutable, defensive copy of the List of locks currently maintained for
the transaction.
- * <p/>
- * Most code could not use this method directly, but use {@link
org.jboss.cache.InvocationContext#getLocks()} instead,
- * which would delegate to this method if a transaction is in scope or otherwise use
invocation-specific locks.
- * <p/>
- * Note that currently (as of 3.0.0) this list is unchecked. This is to allow support
for both MVCC (which uses Fqns as locks)
- * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link
NodeLock} as locks). Once support for
- * legacy node locking schemes are dropped, this method will be more strongly typed to
return <tt>List<Fqn></tt>.
- *
- * @return locks held in current scope.
- * @see org.jboss.cache.InvocationContext#getLocks()
- */
- @SuppressWarnings("unchecked")
- public List getLocks()
- {
- return Collections.unmodifiableList(new ArrayList(transactionLocks));
- }
-
-
- /**
- * Gets the value of the forceAsyncReplication flag. Used by ReplicationInterceptor
and OptimisticReplicationInterceptor
- * when dealing with {@link
org.jboss.cache.Cache#putForExternalRead(org.jboss.cache.Fqn,Object,Object)} within
- * a transactional context.
- *
- * @return true if the forceAsyncReplication flag is set to true.
- */
- public boolean isForceAsyncReplication()
- {
- return forceAsyncReplication;
- }
-
- /**
- * Sets the value of the forceAsyncReplication flag. Used by ReplicationInterceptor
and OptimisticReplicationInterceptor
- * when dealing with {@link
org.jboss.cache.Cache#putForExternalRead(org.jboss.cache.Fqn,Object,Object)} within
- * a transactional context. Also used by OptimisticReplicationInterceptor when
dealing
- * with {@link org.jboss.cache.config.Option#setForceAsynchronous(boolean)} in a
- * non-transactional context (i.e. with an implicit transaction).
- *
- * @param forceAsyncReplication value of forceAsyncReplication
- */
- public void setForceAsyncReplication(boolean forceAsyncReplication)
- {
- this.forceAsyncReplication = forceAsyncReplication;
- if (forceAsyncReplication)
- {
- forceSyncReplication = false;
- }
- }
-
- /**
- * Gets the value of the forceSyncReplication flag. Used by ReplicationInterceptor
and OptimisticReplicationInterceptor
- * when dealing with {@link
org.jboss.cache.Cache#putForExternalRead(org.jboss.cache.Fqn,Object,Object)} within
- * a transactional context.
- *
- * @return true if the forceAsyncReplication flag is set to true.
- */
- public boolean isForceSyncReplication()
- {
- return forceSyncReplication;
- }
-
- /**
- * Sets the value of the forceSyncReplication flag. Used by ReplicationInterceptor
and OptimisticReplicationInterceptor
- * when dealing with {@link
org.jboss.cache.Cache#putForExternalRead(org.jboss.cache.Fqn,Object,Object)} within
- * a transactional context.
- *
- * @param forceSyncReplication value of forceSyncReplication
- */
- public void setForceSyncReplication(boolean forceSyncReplication)
- {
- this.forceSyncReplication = forceSyncReplication;
- if (forceSyncReplication)
- {
- forceAsyncReplication = false;
- }
- }
-
-
- /**
- * Posts all undo operations to the CacheImpl.
- */
- public void undoOperations()
- {
- if (modificationList == null)
- {
- if (trace) log.trace("Modification list is null, no modifications in this
transaction!");
- return;
- }
-
- if (trace) log.trace("undoOperations " + modificationList);
-
- ArrayList<ReversibleCommand> copy;
-// synchronized (modificationList)
-// {
- // no need to sync? Only one thread would access a transaction at any given time?
- copy = new ArrayList<ReversibleCommand>(modificationList);
-// }
- for (ListIterator i = copy.listIterator(copy.size()); i.hasPrevious();)
- {
- Object undoOp = i.previous();
- ReversibleCommand txCommand = (ReversibleCommand) undoOp;
- if (log.isDebugEnabled()) log.debug("Calling rollback() on command " +
undoOp);
- txCommand.rollback();
- }
- }
-
- /**
- * Returns debug information about this transaction.
- */
- @Override
- public String toString()
- {
- StringBuilder sb = new StringBuilder();
- sb.append("TransactionEntry\nmodificationList:
").append(modificationList);
- return sb.toString();
- }
-
- public void loadUninitialisedNode(Fqn fqn)
- {
- if (dummyNodesCreatedByCacheLoader == null)
- dummyNodesCreatedByCacheLoader = new LinkedList<Fqn>();
- dummyNodesCreatedByCacheLoader.add(fqn);
- }
-
- public List<Fqn> getDummyNodesCreatedByCacheLoader()
- {
- return dummyNodesCreatedByCacheLoader;
- }
-
- /**
- * Sets a transaction-scope option override
- *
- * @param o
- */
- public void setOption(Option o)
- {
- this.option = o;
- }
-
- /**
- * Retrieves a transaction scope option override
- */
- public Option getOption()
- {
- return this.option;
- }
-
- public OrderedSynchronizationHandler getOrderedSynchronizationHandler()
- {
- return orderedSynchronizationHandler;
- }
-
- public void setOrderedSynchronizationHandler(OrderedSynchronizationHandler
orderedSynchronizationHandler)
- {
- this.orderedSynchronizationHandler = orderedSynchronizationHandler;
- }
-
- /**
- * Returns true if modifications were registered to either modificationList or to
class loader modifications list.
- */
- public boolean hasModifications()
- {
- return modificationList != null && !modificationList.isEmpty();
- }
-
- /**
- * @return true if any modifications have been invoked with cache mode being LOCAL.
- */
- public boolean hasLocalModifications()
- {
- return localModifications != null && !localModifications.isEmpty();
- }
-
- public NodeSPI lookUpNode(Fqn fqn)
- {
- return lookedUpNodes.get(fqn);
- }
-
- public void putLookedUpNode(Fqn f, NodeSPI n)
- {
- lookedUpNodes.put(f, n);
- }
-
- public void clearLookedUpNodes()
- {
- lookedUpNodes.clear();
- }
-
- public Map<Fqn, NodeSPI> getLookedUpNodes()
- {
- return lookedUpNodes;
- }
-
-
- /**
- * Cleans up internal state
- */
- public void reset()
- {
- orderedSynchronizationHandler = null;
- if (modificationList != null) modificationList = null;
- if (localModifications != null) localModifications = null;
- option = null;
- transactionLocks.clear();
- if (dummyNodesCreatedByCacheLoader != null)
dummyNodesCreatedByCacheLoader.clear();
- removedNodes.clear();
- }
-}
Modified: core/trunk/src/main/java/org/jboss/cache/transaction/TransactionTable.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/TransactionTable.java 2008-06-25
15:10:47 UTC (rev 6037)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/TransactionTable.java 2008-06-25
15:33:13 UTC (rev 6038)
@@ -26,7 +26,7 @@
/**
* Maintains the mapping between a local {@link Transaction} and a {@link
GlobalTransaction}.
- * Also stores {@link TransactionEntry} instances under a given transaction.
+ * Also stores {@link TransactionContext} instances under a given transaction.
*
* @author <a href="mailto:bela@jboss.org">Bela Ban</a> Apr 14,
2003
* @version $Revision$
@@ -47,7 +47,7 @@
/**
* Mappings between GlobalTransactions and modifications.
*/
- protected final Map<GlobalTransaction, TransactionEntry> gtx2EntryMap = new
ConcurrentHashMap<GlobalTransaction, TransactionEntry>();
+ protected final Map<GlobalTransaction, TransactionContext> gtx2ContextMap = new
ConcurrentHashMap<GlobalTransaction, TransactionContext>();
protected final Map<GlobalTransaction, Transaction> gtx2TxMap = new
ConcurrentHashMap<GlobalTransaction, Transaction>();
@@ -85,7 +85,7 @@
*/
public int getNumGlobalTransactions()
{
- return gtx2EntryMap.size();
+ return gtx2ContextMap.size();
}
/**
@@ -152,32 +152,32 @@
* Returns the local transaction entry for the global transaction.
* Returns null if tx is null or it was not found.
*/
- public TransactionEntry get(GlobalTransaction gtx)
+ public TransactionContext get(GlobalTransaction gtx)
{
- return gtx != null ? gtx2EntryMap.get(gtx) : null;
+ return gtx != null ? gtx2ContextMap.get(gtx) : null;
}
/**
- * Associates the global transaction with a transaction entry.
+ * Associates the global transaction with a transaction context.
*/
- public void put(GlobalTransaction tx, TransactionEntry entry)
+ public void put(GlobalTransaction tx, TransactionContext transactionContext)
{
if (tx == null)
{
log.error("key (GlobalTransaction) is null");
return;
}
- gtx2EntryMap.put(tx, entry);
+ gtx2ContextMap.put(tx, transactionContext);
}
/**
* Removes a global transation, returns the old transaction entry.
*/
- public TransactionEntry remove(GlobalTransaction tx)
+ public TransactionContext remove(GlobalTransaction tx)
{
if (tx == null) return null;
gtx2TxMap.remove(tx);
- return gtx2EntryMap.remove(tx);
+ return gtx2ContextMap.remove(tx);
}
/**
@@ -193,7 +193,7 @@
public void remove(GlobalTransaction gtx, Transaction tx)
{
gtx2TxMap.remove(gtx);
- gtx2EntryMap.remove(gtx);
+ gtx2ContextMap.remove(gtx);
tx2gtxMap.remove(tx);
}
@@ -205,7 +205,7 @@
{
StringBuffer sb = new StringBuffer();
sb.append(tx2gtxMap.size()).append(" mappings, ");
- sb.append(gtx2EntryMap.size()).append(" transactions");
+ sb.append(gtx2ContextMap.size()).append(" transactions");
return sb.toString();
}
@@ -218,16 +218,16 @@
return toString();
StringBuffer sb = new StringBuffer();
sb.append("LocalTransactions:
").append(tx2gtxMap.size()).append("\n");
- sb.append("GlobalTransactions:
").append(gtx2EntryMap.size()).append("\n");
+ sb.append("GlobalTransactions:
").append(gtx2ContextMap.size()).append("\n");
sb.append("tx2gtxMap:\n");
for (Map.Entry<Transaction, GlobalTransaction> entry : tx2gtxMap.entrySet())
{
sb.append(entry.getKey()).append(":
").append(entry.getValue()).append("\n");
}
sb.append("gtx2EntryMap:\n");
- for (Map.Entry<GlobalTransaction, TransactionEntry> entry :
gtx2EntryMap.entrySet())
+ for (Map.Entry<GlobalTransaction, TransactionContext> transactionContextEntry
: gtx2ContextMap.entrySet())
{
- sb.append(entry.getKey()).append(":
").append(entry.getValue()).append("\n");
+ sb.append(transactionContextEntry.getKey()).append(":
").append(transactionContextEntry.getValue()).append("\n");
}
return sb.toString();
}
@@ -398,17 +398,17 @@
Address addr = rpcManager.getLocalAddress();
gtx = GlobalTransaction.create(addr);
put(tx, gtx);
- TransactionEntry ent;
+ TransactionContext transactionContext;
try
{
- ent = isOptimisticLocking ? new OptimisticTransactionEntry(tx) : new
TransactionEntry(tx);
+ transactionContext = isOptimisticLocking ? new
OptimisticTransactionContext(tx) : new TransactionContext(tx);
}
catch (Exception e)
{
throw new CacheException("Unable to create a transaction entry!",
e);
}
- put(gtx, ent);
+ put(gtx, transactionContext);
if (trace)
{
log.trace("created new GTX: " + gtx + ", local TX=" +
tx);
Modified: core/trunk/src/test/java/org/jboss/cache/api/NodeAPITest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/NodeAPITest.java 2008-06-25 15:10:47 UTC
(rev 6037)
+++ core/trunk/src/test/java/org/jboss/cache/api/NodeAPITest.java 2008-06-25 15:33:13 UTC
(rev 6038)
@@ -9,7 +9,7 @@
import org.jboss.cache.interceptors.PessimisticLockInterceptor;
import org.jboss.cache.interceptors.base.CommandInterceptor;
import org.jboss.cache.optimistic.TransactionWorkspace;
-import org.jboss.cache.transaction.OptimisticTransactionEntry;
+import org.jboss.cache.transaction.OptimisticTransactionContext;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
@@ -323,7 +323,7 @@
@SuppressWarnings("unchecked")
private TransactionWorkspace<Object, Object> getTransactionWorkspace() throws
Exception
{
- return ((OptimisticTransactionEntry)
cache.getTransactionTable().get(cache.getTransactionTable().get(tm.getTransaction()))).getTransactionWorkSpace();
+ return ((OptimisticTransactionContext)
cache.getTransactionTable().get(cache.getTransactionTable().get(tm.getTransaction()))).getTransactionWorkSpace();
}
public void testGetChildAPI()
Modified: core/trunk/src/test/java/org/jboss/cache/invocationcontext/TransactionTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/invocationcontext/TransactionTest.java 2008-06-25
15:10:47 UTC (rev 6037)
+++
core/trunk/src/test/java/org/jboss/cache/invocationcontext/TransactionTest.java 2008-06-25
15:33:13 UTC (rev 6038)
@@ -4,7 +4,7 @@
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration.CacheMode;
-import org.jboss.cache.transaction.TransactionEntry;
+import org.jboss.cache.transaction.TransactionContext;
import org.jboss.cache.transaction.TransactionTable;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
@@ -123,7 +123,7 @@
assertNotNull("Gtx should have been set up by now",
cache.getInvocationContext().getGlobalTransaction());
Transaction tx = tm.getTransaction();
- TransactionEntry entry = tt.get(tt.get(tx));
+ TransactionContext transactionContext = tt.get(tt.get(tx));
if (commit)
{
@@ -139,10 +139,10 @@
assertEquals("Method call should have been scrubbed", null,
cache.getInvocationContext().getMethodCall());
assertEquals("Cache command should have been scrubbed", null,
cache.getInvocationContext().getCommand());
- // check that the transaction entry hasn't leaked stuff.
- assert entry.getModifications().isEmpty() : "Should have scrubbed
modifications in transaction entry";
- assert entry.getLocks().isEmpty() : "Should have scrubbed modifications in
transaction entry";
- assert entry.getOrderedSynchronizationHandler() == null : "Should have removed
the ordered sync handler";
+ // check that the transaction transactionContext hasn't leaked stuff.
+ assert transactionContext.getModifications().isEmpty() : "Should have scrubbed
modifications in transaction transactionContext";
+ assert transactionContext.getLocks().isEmpty() : "Should have scrubbed
modifications in transaction transactionContext";
+ assert transactionContext.getOrderedSynchronizationHandler() == null : "Should
have removed the ordered sync handler";
}
private void setUpOnePhaseCache()
Modified:
core/trunk/src/test/java/org/jboss/cache/lock/AbstractLockManagerRecordingTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/lock/AbstractLockManagerRecordingTest.java 2008-06-25
15:10:47 UTC (rev 6037)
+++
core/trunk/src/test/java/org/jboss/cache/lock/AbstractLockManagerRecordingTest.java 2008-06-25
15:33:13 UTC (rev 6038)
@@ -10,7 +10,7 @@
import org.jboss.cache.transaction.DummyTransaction;
import org.jboss.cache.transaction.DummyTransactionManager;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.TransactionEntry;
+import org.jboss.cache.transaction.TransactionContext;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
@@ -52,12 +52,12 @@
InvocationContext ctx = icc.get();
ctx.setGlobalTransaction(new GlobalTransaction());
ctx.setTransaction(new DummyTransaction(DummyTransactionManager.getInstance()));
- ctx.setTransactionEntry(new TransactionEntry(ctx.getTransaction()));
+ ctx.setTransactionContext(new TransactionContext(ctx.getTransaction()));
// lock and record.
lm.lockAndRecord(node, WRITE, ctx);
assert ctx.getLocks().contains(fqnBasedLocking ? fqn : node.getLock());
- assert ctx.getTransactionEntry().getLocks().size() == 1;
+ assert ctx.getTransactionContext().getLocks().size() == 1;
assert lm.isLocked(node) : "Should be locked";
lm.unlock(ctx);
assert !lm.isLocked(node) : "Should not be locked";
Modified: core/trunk/src/test/java/org/jboss/cache/transaction/AbortionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/AbortionTest.java 2008-06-25
15:10:47 UTC (rev 6037)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/AbortionTest.java 2008-06-25
15:33:13 UTC (rev 6038)
@@ -8,9 +8,9 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
-import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.interceptors.OrderedSynchronizationHandler;
import org.jboss.cache.transaction.NotifyingTransactionManager.Notification;
+import org.jboss.cache.util.TestingUtil;
import org.jgroups.JChannel;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
@@ -152,9 +152,9 @@
this.abortBeforeCompletion = abortBeforeCompletion;
}
- public void notify(Transaction tx, TransactionEntry entry) throws SystemException,
RollbackException
+ public void notify(Transaction tx, TransactionContext transactionContext) throws
SystemException, RollbackException
{
- OrderedSynchronizationHandler osh = entry.getOrderedSynchronizationHandler();
+ OrderedSynchronizationHandler osh =
transactionContext.getOrderedSynchronizationHandler();
final Transaction finalTx = tx;
System.out.println("Notify called.");
Modified:
core/trunk/src/test/java/org/jboss/cache/transaction/NotifyingTransactionManager.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/transaction/NotifyingTransactionManager.java 2008-06-25
15:10:47 UTC (rev 6037)
+++
core/trunk/src/test/java/org/jboss/cache/transaction/NotifyingTransactionManager.java 2008-06-25
15:33:13 UTC (rev 6038)
@@ -66,7 +66,7 @@
public interface Notification
{
- public void notify(Transaction tx, TransactionEntry entry) throws SystemException,
RollbackException;
+ public void notify(Transaction tx, TransactionContext transactionContext) throws
SystemException, RollbackException;
}
public CacheSPI getCache()