[jboss-cvs] JBossCache/src/org/jboss/cache/interceptors ...

Manik Surtani manik at jboss.org
Mon Jul 30 07:12:47 EDT 2007


  User: msurtani
  Date: 07/07/30 07:12:47

  Modified:    src/org/jboss/cache/interceptors  Tag:
                        Branch_JBossCache_1_4_0
                        PessimisticLockInterceptor.java
  Log:
  JBCACHE-1157
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.20.2.12 +9 -7      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.11
  retrieving revision 1.20.2.12
  diff -u -b -r1.20.2.11 -r1.20.2.12
  --- PessimisticLockInterceptor.java	5 Mar 2007 19:15:17 -0000	1.20.2.11
  +++ PessimisticLockInterceptor.java	30 Jul 2007 11:12:47 -0000	1.20.2.12
  @@ -36,7 +36,7 @@
    * current method and unlock when the method returns.
    *
    * @author Bela Ban
  - * @version $Id: PessimisticLockInterceptor.java,v 1.20.2.11 2007/03/05 19:15:17 msurtani Exp $
  + * @version $Id: PessimisticLockInterceptor.java,v 1.20.2.12 2007/07/30 11:12:47 msurtani Exp $
    */
   public class PessimisticLockInterceptor extends Interceptor
   {
  @@ -97,6 +97,7 @@
         boolean recursive = false;
         boolean createIfNotExists = false;
         boolean zeroLockTimeout = false; // only used if the call is an evict() call.  See JBCACHE-794
  +      boolean isRemoveData = 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
  @@ -122,6 +123,7 @@
               break;
            case MethodDeclarations.removeKeyMethodLocal_id:
            case MethodDeclarations.removeDataMethodLocal_id:
  +            isRemoveData = true;
            case MethodDeclarations.addChildMethodLocal_id:
               fqn = (Fqn) args[1];
               lock_type = DataNode.LOCK_TYPE_WRITE;
  @@ -172,13 +174,13 @@
            {
               do
               {
  -               lock(fqn, ctx.getGlobalTransaction(), lock_type, recursive, zeroLockTimeout ? 0 : lock_timeout, createIfNotExists, storeLockedNode);
  +               lock(fqn, ctx.getGlobalTransaction(), lock_type, recursive, zeroLockTimeout ? 0 : lock_timeout, createIfNotExists, storeLockedNode, isRemoveData);
               }
               while(!cache.exists(fqn)); // keep trying until we have the lock (fixes concurrent remove())
               // terminates successfully, or with (Timeout)Exception
            }
            else
  -            lock(fqn, ctx.getGlobalTransaction(), lock_type, recursive, zeroLockTimeout ? 0 : lock_timeout, createIfNotExists, storeLockedNode);
  +            lock(fqn, ctx.getGlobalTransaction(), lock_type, recursive, zeroLockTimeout ? 0 : lock_timeout, createIfNotExists, storeLockedNode, isRemoveData);
         }
         else
         {
  @@ -231,7 +233,7 @@
       * @param recursive Lock children recursively
       */
      private void lock(Fqn fqn, GlobalTransaction gtx, int lock_type, boolean recursive,
  -                     long lock_timeout, boolean createIfNotExists, boolean isRemoveNodeOperation)
  +                     long lock_timeout, boolean createIfNotExists, boolean isRemoveNodeOperation, boolean isRemoveDataOperation)
              throws TimeoutException, LockingException, InterruptedException
      {
         DataNode n;
  @@ -286,7 +288,7 @@
            }
            else
            {
  -            if (writeLockNeeded(lock_type, i, treeNodeSize, isRemoveNodeOperation, createIfNotExists, fqn, child_node.getFqn()))
  +            if (writeLockNeeded(lock_type, i, treeNodeSize, isRemoveNodeOperation, createIfNotExists, isRemoveDataOperation, fqn, child_node.getFqn()))
               {
                  currentLockType = DataNode.LOCK_TYPE_WRITE;
               }
  @@ -355,7 +357,7 @@
         n.unmarkForRemoval(false);
      }
   
  -   private boolean writeLockNeeded(int lock_type, int currentNodeIndex, int treeNodeSize, boolean isRemoveOperation, boolean createIfNotExists, Fqn targetFqn, Fqn currentFqn)
  +   private boolean writeLockNeeded(int lock_type, int currentNodeIndex, int treeNodeSize, boolean isRemoveOperation, boolean createIfNotExists, boolean isRemoveDataOperation, Fqn targetFqn, Fqn currentFqn)
      {
         if (writeLockOnChildInsertRemove)
         {
  @@ -366,7 +368,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 == DataNode.LOCK_TYPE_WRITE && isTargetNode(currentNodeIndex, treeNodeSize) && (createIfNotExists || isRemoveOperation); //normal operation, write lock explicitly requested and this is the target to be written to.
  +      return lock_type == DataNode.LOCK_TYPE_WRITE && isTargetNode(currentNodeIndex, treeNodeSize) && (createIfNotExists || isRemoveOperation || isRemoveDataOperation); //normal operation, write lock explicitly requested and this is the target to be written to.
      }
   
      private boolean isTargetNode(int nodePosition, int treeNodeSize)
  
  
  



More information about the jboss-cvs-commits mailing list