[jbosscache-commits] JBoss Cache SVN: r8157 - core/trunk/src/main/java/org/jboss/cache/lock.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Thu Aug 6 05:32:15 EDT 2009


Author: manik.surtani at jboss.com
Date: 2009-08-06 05:32:14 -0400 (Thu, 06 Aug 2009)
New Revision: 8157

Modified:
   core/trunk/src/main/java/org/jboss/cache/lock/PessimisticNodeBasedLockManager.java
Log:
JBCACHE-1527 Unnecessary write locks acquired during a data gravitation event and pessimistic locking

Modified: core/trunk/src/main/java/org/jboss/cache/lock/PessimisticNodeBasedLockManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/lock/PessimisticNodeBasedLockManager.java	2009-08-05 22:06:43 UTC (rev 8156)
+++ core/trunk/src/main/java/org/jboss/cache/lock/PessimisticNodeBasedLockManager.java	2009-08-06 09:32:14 UTC (rev 8157)
@@ -121,6 +121,7 @@
       Thread currentThread = Thread.currentThread();
       GlobalTransaction gtx = ctx.getGlobalTransaction();
       boolean created = false;
+      int createdLevel = -1;
       // if the tx associated with the current thread is rolling back, barf! JBCACHE-923
       if (gtx != null) TransactionTable.assertTransactionValid(ctx);
 
@@ -142,7 +143,11 @@
             {
                // if the new node is to be marked as deleted, do not notify!
                currentNode = parent.addChildDirect(childName, !skipNotification);
-               created = true;
+               if (!created)
+               {
+                  created = true;
+                  createdLevel = currentIndex;
+               }
                if (trace) log.trace("Child node was null, so created child node " + childName);
                if (createdNodes != null) createdNodes.add(currentNode);
             }
@@ -163,6 +168,7 @@
          {
             lockTypeRequired = WRITE;
          }
+         
 
          Fqn currentNodeFqn = currentNode.getFqn();
          // actually acquire the lock we need.  This method blocks.
@@ -188,10 +194,17 @@
                currentNode = rootNode;
                currentIndex = -1;
                parent = null;
+               created = false;
+               createdLevel = -1;
             }
             else
             {
                currentNode = parent;
+               if (createdLevel == currentIndex)
+               {
+                  created = false;
+                  createdLevel = -1;
+               }
                currentIndex--;
                parent = null;
                if (System.currentTimeMillis() > expiryTime)



More information about the jbosscache-commits mailing list