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

Manik Surtani msurtani at jboss.com
Mon Mar 5 14:15:17 EST 2007


  User: msurtani
  Date: 07/03/05 14:15:17

  Modified:    src/org/jboss/cache/interceptors  Tag:
                        Branch_JBossCache_1_4_0
                        PessimisticLockInterceptor.java
  Log:
  JBCACHE-999
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.20.2.11 +22 -40    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.10
  retrieving revision 1.20.2.11
  diff -u -b -r1.20.2.10 -r1.20.2.11
  --- PessimisticLockInterceptor.java	9 Feb 2007 13:49:35 -0000	1.20.2.10
  +++ PessimisticLockInterceptor.java	5 Mar 2007 19:15:17 -0000	1.20.2.11
  @@ -36,7 +36,7 @@
    * current method and unlock when the method returns.
    *
    * @author Bela Ban
  - * @version $Id: PessimisticLockInterceptor.java,v 1.20.2.10 2007/02/09 13:49:35 msurtani Exp $
  + * @version $Id: PessimisticLockInterceptor.java,v 1.20.2.11 2007/03/05 19:15:17 msurtani Exp $
    */
   public class PessimisticLockInterceptor extends Interceptor
   {
  @@ -194,15 +194,33 @@
         // to add the removedNodes map to TreeCache
         if (storeLockedNode && ctx.getGlobalTransaction() == null)
         {
  -         //cache.getRemovedNodesMap().remove(fqn);
  -         //cache.peek(fqn);
            // do a REAL remove here.
  +         // this is for NON TRANSACTIONAL calls
            cache.realRemove(fqn, true);
         }
  +      else if (m.getMethodId() == MethodDeclarations.commitMethod_id || isOnePhaseCommitPrepareMehod(m) || m.getMethodId() == MethodDeclarations.rollbackMethod_id)
  +      {
  +         // and this is for transactional ones
  +         cleanup(ctx.getGlobalTransaction());
  +      }
   
         return o;
      }
   
  +   private void cleanup(GlobalTransaction gtx)
  +   {
  +      TransactionEntry entry = tx_table.get(gtx);
  +      // Let's do it in stack style, LIFO
  +      entry.releaseAllLocksLIFO(gtx);
  +
  +      Transaction ltx = entry.getTransaction();
  +      if (log.isTraceEnabled())
  +      {
  +         log.trace("removing local transaction " + ltx + " and global transaction " + gtx);
  +      }
  +      tx_table.remove(ltx);
  +      tx_table.remove(gtx);
  +   }
   
      /**
       * Locks a given node.
  @@ -222,7 +240,6 @@
         Thread currentThread = Thread.currentThread();
         Object owner = (gtx != null) ? (Object) gtx : currentThread;
         int treeNodeSize;
  -      boolean acquired = false;
         int currentLockType;
   
   
  @@ -449,15 +466,6 @@
            Fqn f = (Fqn) removedNodes.next();
            cache.realRemove(f, false);
         }
  -
  -      // Let's do it in stack style, LIFO
  -      entry.releaseAllLocksLIFO(gtx);
  -
  -      Transaction ltx = entry.getTransaction();
  -      if (log.isTraceEnabled())
  -         log.trace("removing local transaction " + ltx + " and global transaction " + gtx);
  -      tx_table.remove(ltx);
  -      tx_table.remove(gtx);
      }
   
   
  @@ -493,34 +501,8 @@
   
         }
   
  -      // 1. Revert the modifications by running the undo-op list in reverse. This *cannot* throw any exceptions !
  +      // Revert the modifications by running the undo-op list in reverse. This *cannot* throw any exceptions !
         entry.undoOperations(cache);
  -
  -      // This was removed as we don't use temporary nodes anymore; we now create undo-operations on put(), e.g.
  -      // put(/a/b/c) on /a, create b and c, plus undo operations _remove(a/b/c) and _remove(/a/b)
  -
  -      // 2. Remove all temporary nodes. Need to do it backwards since node is LIFO.
  -//      for(ListIterator it=new LinkedList(entry.getNodes()).listIterator(entry.getNodes().size());
  -//          it.hasPrevious();) {
  -//         node_name=(Fqn)it.previous();
  -//         try {
  -//            cache._remove(tx, node_name, false);
  -//         }
  -//         catch(Throwable t) {
  -//            log.error("failed removing node \"" + node_name + "\"", t);
  -//         }
  -//      }
  -
  -      // 3. Finally, release all locks held by this TX
  -      // Let's do it in stack style, LIFO
  -      // Note that the lock could have been released already so don't panic.
  -      entry.releaseAllLocksLIFO(tx);
  -
  -      Transaction ltx = entry.getTransaction();
  -      if (log.isTraceEnabled())
  -         log.trace("removing local transaction " + ltx + " and global transaction " + tx);
  -      tx_table.remove(ltx);
  -      tx_table.remove(tx);
      }
   
   }
  
  
  



More information about the jboss-cvs-commits mailing list