[jbosscache-commits] JBoss Cache SVN: r5639 - in core/trunk/src/main/java/org/jboss/cache: interceptors and 1 other directories.
jbosscache-commits at lists.jboss.org
jbosscache-commits at lists.jboss.org
Wed Apr 23 06:33:07 EDT 2008
Author: manik.surtani at jboss.com
Date: 2008-04-23 06:33:06 -0400 (Wed, 23 Apr 2008)
New Revision: 5639
Modified:
core/trunk/src/main/java/org/jboss/cache/InvocationContext.java
core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java
Log:
Fixed lock suppression
Modified: core/trunk/src/main/java/org/jboss/cache/InvocationContext.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/InvocationContext.java 2008-04-23 10:15:15 UTC (rev 5638)
+++ core/trunk/src/main/java/org/jboss/cache/InvocationContext.java 2008-04-23 10:33:06 UTC (rev 5639)
@@ -190,7 +190,7 @@
*/
public void clearInvocationLocksAcquired()
{
- if (isSupressLocking()) return;
+ if (isLockingSuppressed()) return;
if (!isValidTransaction())
{ // no TX
List<NodeLock> locks = getInvocationLocksAcquired();
@@ -218,7 +218,10 @@
}
}
- public boolean isSupressLocking()
+ /**
+ * @return true if options exist to suppress locking - false otherwise. Note that this is only used by the {@link org.jboss.cache.interceptors.PessimisticLockInterceptor}.
+ */
+ public boolean isLockingSuppressed()
{
return getOptionOverrides() != null && getOptionOverrides().isSuppressLocking();
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java 2008-04-23 10:15:15 UTC (rev 5638)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java 2008-04-23 10:33:06 UTC (rev 5639)
@@ -50,11 +50,6 @@
private CacheData cacheData;
private LockManager lockManager;
private Configuration configuration;
-
- /**
- * Map<Thread, List<NodeLock>>. Keys = threads, values = lists of locks held by that thread
- */
- // private ThreadLocal<List<NodeLock>> lockTable;
private long lockAcquisitionTimeout;
@Inject
@@ -82,7 +77,7 @@
private Object handlePutCommand(InvocationContext ctx, CacheDataCommand command, boolean zeroAcquisitionTimeout)
throws Throwable
{
- if ((ctx.isSupressLocking()) || configuration.getIsolationLevel() == IsolationLevel.NONE)
+ if ((ctx.isLockingSuppressed()) || configuration.getIsolationLevel() == IsolationLevel.NONE)
{
if (trace) log.trace("Suppressing locking, creating nodes if necessary");
int treeNodeSize = command.getFqn().size();
@@ -107,18 +102,7 @@
return retVal;
}
- // TODO: This is unused. I'm guessing that is a bug?!?? This does need to be checked.
-
-// protected boolean skipMethodCall(InvocationContext ctx)
-// {
-// return (supressLocking(ctx) && !MethodDeclarations.isPutMethod(ctx.getMethodCall().getMethodId()));
-// }
-
-// private boolean supressLocking(InvocationContext ctx)
-// {
-// return ctx.getOptionOverrides() != null && ctx.getOptionOverrides().isSuppressLocking();
-// }
-
+ @Override
public Object handlePrepareCommand(InvocationContext ctx, PrepareCommand command) throws Throwable
{
// 2-phase commit prepares are no-ops here.
@@ -131,6 +115,7 @@
return retVal;
}
+ @Override
public Object handleCommitCommand(InvocationContext ctx, CommitCommand command) throws Throwable
{
commit(command.getGlobalTransaction());
@@ -140,6 +125,7 @@
return retVal;
}
+ @Override
public Object handleRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable
{
TransactionEntry entry = txTable.get(command.getGlobalTransaction());
@@ -169,9 +155,10 @@
return retVal;
}
+ @Override
public Object handleMoveCommand(InvocationContext ctx, MoveCommand command) throws Throwable
{
- if (ctx.isSupressLocking()) return invokeNextInterceptor(ctx, command);
+ if (ctx.isLockingSuppressed()) return invokeNextInterceptor(ctx, command);
long timeout = ctx.getContextLockAcquisitionTimeout(lockAcquisitionTimeout);
// this call will ensure the node gets a WL and it's current parent gets RL.
if (trace) log.trace("Attempting to get WL on node to be moved [" + command.getFqn() + "]");
@@ -202,9 +189,10 @@
return retValue;
}
+ @Override
public Object handleRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
{
- if (ctx.isSupressLocking()) return invokeNextInterceptor(ctx, command);
+ if (ctx.isLockingSuppressed()) return invokeNextInterceptor(ctx, command);
// need to make a note of ALL nodes created here!!
List<NodeSPI> createdNodes = new LinkedList<NodeSPI>();
// we need to mark new nodes created as deleted since they are only created to form a path to the node being removed, to
@@ -251,6 +239,7 @@
return created ? false : retVal;
}
+ @Override
public Object handleRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command) throws Throwable
{
lockManager.acquireLocksWithTimeout(ctx, command.getFqn(), NodeLock.LockType.WRITE, false, false, false, false, null, false);
@@ -259,6 +248,7 @@
return retVal;
}
+ @Override
public Object handleRemoveDataCommand(InvocationContext ctx, RemoveDataCommand command) throws Throwable
{
lockManager.acquireLocksWithTimeout(ctx, command.getFqn(), NodeLock.LockType.WRITE, false, false, false, false, null, false);
@@ -267,6 +257,7 @@
return retVal;
}
+ @Override
public Object handleEvictFqnCommand(InvocationContext ctx, EvictNodeCommand command) throws Throwable
{
lockManager.acquireLocksWithTimeout(ctx, command.getFqn(), NodeLock.LockType.WRITE, false, true, false, false, null, false);
@@ -275,6 +266,7 @@
return retVal;
}
+ @Override
public Object handleGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand command) throws Throwable
{
lockManager.acquireLocksWithTimeout(ctx, command.getFqn(), NodeLock.LockType.READ, false, false, false, false, null, false);
@@ -283,6 +275,7 @@
return retVal;
}
+ @Override
public Object handleGetNodeCommand(InvocationContext ctx, GetNodeCommand command) throws Throwable
{
lockManager.acquireLocksWithTimeout(ctx, command.getFqn(), NodeLock.LockType.READ, false, false, false, false, null, false);
@@ -291,6 +284,7 @@
return retVal;
}
+ @Override
public Object handleGetKeysCommand(InvocationContext ctx, GetKeysCommand command) throws Throwable
{
lockManager.acquireLocksWithTimeout(ctx, command.getFqn(), NodeLock.LockType.READ, false, false, false, false, null, false);
@@ -299,6 +293,7 @@
return retVal;
}
+ @Override
public Object handleGetChildrenNamesCommand(InvocationContext ctx, GetChildrenNamesCommand command) throws Throwable
{
lockManager.acquireLocksWithTimeout(ctx, command.getFqn(), NodeLock.LockType.READ, false, false, false, false, null, false);
Modified: core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java 2008-04-23 10:15:15 UTC (rev 5638)
+++ core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java 2008-04-23 10:33:06 UTC (rev 5639)
@@ -53,7 +53,8 @@
boolean acquireLockOnParent, boolean reverseRemoveCheck, List<NodeSPI> createdNodes, boolean skipNotification)
throws InterruptedException
{
- if (fqn == null || configuration.getIsolationLevel() == IsolationLevel.NONE) return false;
+ if (fqn == null || configuration.getIsolationLevel() == IsolationLevel.NONE || ctx.isLockingSuppressed())
+ return false;
boolean created;
long timeout = zeroLockTimeout ? 0 : ctx.getContextLockAcquisitionTimeout(lockAcquisitionTimeout);
More information about the jbosscache-commits
mailing list