[jboss-cvs] JBossCache/src/org/jboss/cache/interceptors ...
Brian Stansberry
brian.stansberry at jboss.com
Mon Jan 29 22:20:16 EST 2007
User: bstansberry
Date: 07/01/29 22:20:16
Modified: src/org/jboss/cache/interceptors Tag:
Branch_JBossCache_1_4_0
PessimisticLockInterceptor.java
Log:
[JBCACHE-955] Add LockParentForChildInsertRemove
Revision Changes Path
No revision
No revision
1.20.2.9 +14 -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.20.2.8
retrieving revision 1.20.2.9
diff -u -b -r1.20.2.8 -r1.20.2.9
--- PessimisticLockInterceptor.java 14 Dec 2006 12:51:48 -0000 1.20.2.8
+++ PessimisticLockInterceptor.java 30 Jan 2007 03:20:16 -0000 1.20.2.9
@@ -36,12 +36,14 @@
* current method and unlock when the method returns.
*
* @author Bela Ban
- * @version $Id: PessimisticLockInterceptor.java,v 1.20.2.8 2006/12/14 12:51:48 msurtani Exp $
+ * @version $Id: PessimisticLockInterceptor.java,v 1.20.2.9 2007/01/30 03:20:16 bstansberry Exp $
*/
public class PessimisticLockInterceptor extends Interceptor
{
TransactionTable tx_table = null;
+ boolean writeLockOnChildInsertRemove = true;
+
/**
* Map<Object, java.util.List>. Keys = threads, values = lists of locks held by that thread
*/
@@ -55,6 +57,7 @@
tx_table = cache.getTransactionTable();
lock_table = cache.getLockTable();
lock_acquisition_timeout = cache.getLockAcquisitionTimeout();
+ writeLockOnChildInsertRemove = cache.getLockParentForChildInsertRemove();
}
@@ -323,11 +326,14 @@
private boolean writeLockNeeded(int lock_type, int currentNodeIndex, int treeNodeSize, boolean isRemoveOperation, boolean createIfNotExists, Fqn targetFqn, Fqn currentFqn)
{
+ if (writeLockOnChildInsertRemove)
+ {
if (isRemoveOperation && currentNodeIndex == treeNodeSize - 2)
return true; // we're doing a remove and we've reached the PARENT node of the target to be removed.
if (!isTargetNode(currentNodeIndex, treeNodeSize) && !cache.exists(new Fqn(currentFqn, targetFqn.get(currentNodeIndex + 1))))
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 == DataNode.LOCK_TYPE_WRITE && isTargetNode(currentNodeIndex, treeNodeSize) && (createIfNotExists || isRemoveOperation); //normal operation, write lock explicitly requested and this is the target to be written to.
}
More information about the jboss-cvs-commits
mailing list