[jboss-cvs] JBossCache/src/org/jboss/cache/interceptors ...
Manik Surtani
msurtani at jboss.com
Tue Feb 27 12:27:44 EST 2007
User: msurtani
Date: 07/02/27 12:27:44
Modified: src/org/jboss/cache/interceptors
PessimisticLockInterceptor.java
ActivationInterceptor.java
Log:
JBCACHE-814
Revision Changes Path
1.48 +15 -8 JBossCache/src/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: PessimisticLockInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/PessimisticLockInterceptor.java,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -b -r1.47 -r1.48
--- PessimisticLockInterceptor.java 7 Feb 2007 22:06:41 -0000 1.47
+++ PessimisticLockInterceptor.java 27 Feb 2007 17:27:44 -0000 1.48
@@ -36,7 +36,7 @@
* current method and unlock when the method returns.
*
* @author Bela Ban
- * @version $Id: PessimisticLockInterceptor.java,v 1.47 2007/02/07 22:06:41 genman Exp $
+ * @version $Id: PessimisticLockInterceptor.java,v 1.48 2007/02/27 17:27:44 msurtani Exp $
*/
public class PessimisticLockInterceptor extends Interceptor
{
@@ -97,6 +97,7 @@
boolean createIfNotExists = false;
boolean zeroLockTimeout = false;// only used if the call is an evict() call. See JBCACHE-794
boolean isDeleteOperation = false;// needed for JBCACHE-871
+ boolean isEvictOperation = false;
// 1. Determine the type of lock (read, write, or none) depending on the method. If no lock is required, invoke
// the method, then return immediately
@@ -133,6 +134,7 @@
zeroLockTimeout = true;
fqn = (Fqn) args[0];
lock_type = NodeLock.LockType.WRITE;
+ isEvictOperation = true;
break;
case MethodDeclarations.getKeyValueMethodLocal_id:
case MethodDeclarations.getNodeMethodLocal_id:
@@ -175,7 +177,7 @@
{
do
{
- lock(fqn, ctx.getGlobalTransaction(), lock_type, recursive, createIfNotExists, zeroLockTimeout ? 0 : lock_acquisition_timeout, isDeleteOperation);
+ lock(fqn, ctx.getGlobalTransaction(), lock_type, recursive, createIfNotExists, zeroLockTimeout ? 0 : lock_acquisition_timeout, isDeleteOperation, isEvictOperation);
}
while (createIfNotExists && cache.peek(fqn, false) == null);// keep trying until we have the lock (fixes concurrent remove())
}
@@ -217,11 +219,11 @@
// this call will ensure the node gets a WL and it's current parent gets RL.
if (log.isTraceEnabled()) log.trace("Attempting to get WL on node to be moved [" + node + "]");
- lock(node, cache.getInvocationContext().getGlobalTransaction(), NodeLock.LockType.WRITE, true, false, lock_acquisition_timeout, true);
+ lock(node, cache.getInvocationContext().getGlobalTransaction(), NodeLock.LockType.WRITE, true, false, lock_acquisition_timeout, true, false);
//now for an RL for the new parent.
if (log.isTraceEnabled()) log.trace("Attempting to get RL on new parent [" + parent + "]");
- lock(parent, cache.getInvocationContext().getGlobalTransaction(), NodeLock.LockType.READ, true, false, lock_acquisition_timeout, false);
+ lock(parent, cache.getInvocationContext().getGlobalTransaction(), NodeLock.LockType.READ, true, false, lock_acquisition_timeout, false, false);
}
@@ -233,7 +235,7 @@
* @param lock_type DataNode.LOCK_TYPE_READ, DataNode.LOCK_TYPE_WRITE or DataNode.LOCK_TYPE_NONE
* @param recursive Lock children recursively
*/
- private void lock(Fqn fqn, GlobalTransaction gtx, NodeLock.LockType lock_type, boolean recursive, boolean createIfNotExists, long timeout, boolean isDeleteOperation)
+ private void lock(Fqn fqn, GlobalTransaction gtx, NodeLock.LockType lock_type, boolean recursive, boolean createIfNotExists, long timeout, boolean isDeleteOperation, boolean isEvictionOperation)
throws TimeoutException, LockingException, InterruptedException
{
NodeSPI n;
@@ -304,7 +306,7 @@
}
else
{
- if (writeLockNeeded(lock_type, i, treeNodeSize, isDeleteOperation, createIfNotExists, fqn, child_node.getFqn()))
+ if (writeLockNeeded(lock_type, i, treeNodeSize, isEvictionOperation, isDeleteOperation, createIfNotExists, fqn, child_node.getFqn()))
{
//acquired=child_node.acquire(owner, lock_timeout, DataNode.LOCK_TYPE_WRITE);
//acquired = lockManager.acquire(child_node, owner, NodeLock.LockType.WRITE, timeout);
@@ -361,7 +363,7 @@
n.markAsDeleted(false);
}
- private boolean writeLockNeeded(NodeLock.LockType lock_type, int currentNodeIndex, int treeNodeSize, boolean isRemoveOperation, boolean createIfNotExists, Fqn targetFqn, Fqn currentFqn)
+ private boolean writeLockNeeded(NodeLock.LockType lock_type, int currentNodeIndex, int treeNodeSize, boolean isEvictOperation, boolean isRemoveOperation, boolean createIfNotExists, Fqn targetFqn, Fqn currentFqn)
{
// write lock forced!!
if (cache.getInvocationContext().getOptionOverrides().isForceWriteLock()) return true;
@@ -378,7 +380,7 @@
return createIfNotExists;// we're at a node in the tree, not yet at the target node, and we need to create the next node. So we need a WL here.
}
}
- return lock_type == NodeLock.LockType.WRITE && isTargetNode(currentNodeIndex, treeNodeSize) && (createIfNotExists || isRemoveOperation);//normal operation, write lock explicitly requested and this is the target to be written to.
+ return lock_type == NodeLock.LockType.WRITE && isTargetNode(currentNodeIndex, treeNodeSize) && (createIfNotExists || isRemoveOperation || isEvictOperation);//normal operation, write lock explicitly requested and this is the target to be written to.
}
private boolean isTargetNode(int nodePosition, int treeNodeSize)
@@ -394,6 +396,11 @@
// Record the lock for release on method return or tx commit/rollback
recordNodeLock(gtx, lockManager.getLock(node));
}
+ else
+ {
+ //if (log.isDebugEnabled()) log.debug("Unable to acquire lock on node " + node.getFqn());
+ //throw new LockingException("Could not acquite lock for " + node.getFqn());
+ }
}
private void recordNodeLock(GlobalTransaction gtx, NodeLock lock)
1.51 +2 -2 JBossCache/src/org/jboss/cache/interceptors/ActivationInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ActivationInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/ActivationInterceptor.java,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -b -r1.50 -r1.51
--- ActivationInterceptor.java 7 Feb 2007 22:06:40 -0000 1.50
+++ ActivationInterceptor.java 27 Feb 2007 17:27:44 -0000 1.51
@@ -25,7 +25,7 @@
* their attributes have been initialized and their children have been loaded in memory.
*
* @author <a href="mailto:{hmesha at novell.com}">{Hany Mesha}</a>
- * @version $Id: ActivationInterceptor.java,v 1.50 2007/02/07 22:06:40 genman Exp $
+ * @version $Id: ActivationInterceptor.java,v 1.51 2007/02/27 17:27:44 msurtani Exp $
*/
public class ActivationInterceptor extends CacheLoaderInterceptor implements ActivationInterceptorMBean
{
@@ -171,7 +171,7 @@
}
else if (loaderNoChildren(fqn))
{
- log.debug("no children " + n);
+ if (log.isDebugEnabled()) log.debug("no children " + n);
remove(fqn);
}
}
More information about the jboss-cvs-commits
mailing list