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

Manik Surtani msurtani at jboss.com
Sat Dec 30 22:01:20 EST 2006


  User: msurtani
  Date: 06/12/30 22:01:20

  Modified:    src/org/jboss/cache/interceptors     
                        OptimisticNodeInterceptor.java
                        CacheLoaderInterceptor.java
                        OptimisticCreateIfNotExistsInterceptor.java
                        PessimisticLockInterceptor.java
                        CacheStoreInterceptor.java
  Log:
  move api still WIP
  
  Revision  Changes    Path
  1.40      +10 -8     JBossCache/src/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: OptimisticNodeInterceptor.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -b -r1.39 -r1.40
  --- OptimisticNodeInterceptor.java	31 Dec 2006 02:08:40 -0000	1.39
  +++ OptimisticNodeInterceptor.java	31 Dec 2006 03:01:20 -0000	1.40
  @@ -52,7 +52,7 @@
               throw new CacheException("Setting a data version while performing a move() is not supported!!");
            }
   
  -         Fqn parentFqn = (Fqn) args[0], nodeFqn = (Fqn) args[1];
  +         Fqn parentFqn = (Fqn) args[1], nodeFqn = (Fqn) args[0];
   
            if (log.isTraceEnabled())
            {
  @@ -189,6 +189,11 @@
      public void doMove(WorkspaceNode parent, WorkspaceNode node, TransactionWorkspace ws)
      {
         Fqn nodeFqn = node.getFqn();
  +      if (nodeFqn.isRoot())
  +      {
  +         log.warn("Attempting to move the root node.  Not taking any action, treating this as a no-op.");
  +         return;
  +      }
         WorkspaceNode oldParent = getOrCreateWorkspaceNode(nodeFqn.getParent(), ws);
         Object nodeName = nodeFqn.getLastElement();
   
  @@ -203,11 +208,11 @@
         // now adjust Fqns of node and all children.
         moveFqns(node, parent.getFqn(), ws);
   
  -      // remove old nodes.
  +      // remove old nodes. this may mark some nodes which have already been moved as deleted
         removeNode(ws, node);
  -
  -
  -      System.out.println("WS: " + ws);
  +      // now remove deletion markers on the nodes moved (and their children).
  +      WorkspaceNode newChild = getOrCreateWorkspaceNode(new Fqn(parent.getFqn(), nodeFqn.getLastElement()), ws);
  +      newChild.markAsDeleted(false, true);
      }
   
      /**
  @@ -219,9 +224,6 @@
         WorkspaceNode movedNode = getOrCreateWorkspaceNode(newFqn, ws);
         movedNode.put(node.getData());
   
  -      System.out.println("  Moved node: " + movedNode);
  -      System.out.println("  Data: " + movedNode.getData());
  -
         // process children
         for (Object n : node.getChildrenNames())
         {
  
  
  
  1.66      +3 -3      JBossCache/src/org/jboss/cache/interceptors/CacheLoaderInterceptor.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CacheLoaderInterceptor.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/CacheLoaderInterceptor.java,v
  retrieving revision 1.65
  retrieving revision 1.66
  diff -u -b -r1.65 -r1.66
  --- CacheLoaderInterceptor.java	30 Dec 2006 17:49:54 -0000	1.65
  +++ CacheLoaderInterceptor.java	31 Dec 2006 03:01:20 -0000	1.66
  @@ -29,7 +29,7 @@
    * Loads nodes that don't exist at the time of the call into memory from the CacheLoader
    *
    * @author Bela Ban
  - * @version $Id: CacheLoaderInterceptor.java,v 1.65 2006/12/30 17:49:54 msurtani Exp $
  + * @version $Id: CacheLoaderInterceptor.java,v 1.66 2006/12/31 03:01:20 msurtani Exp $
    */
   public class CacheLoaderInterceptor extends BaseCacheLoaderInterceptor implements CacheLoaderInterceptorMBean
   {
  @@ -132,8 +132,8 @@
               }
               break;
            case MethodDeclarations.moveMethodLocal_id:
  -            fqn = (Fqn) args[1];
  -            fqn2 = (Fqn) args[0];
  +            fqn = (Fqn) args[0];
  +            fqn2 = (Fqn) args[1];
               acquireLock = true;
               //initNode = true;
               recursive = true;
  
  
  
  1.34      +1 -1      JBossCache/src/org/jboss/cache/interceptors/OptimisticCreateIfNotExistsInterceptor.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: OptimisticCreateIfNotExistsInterceptor.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/OptimisticCreateIfNotExistsInterceptor.java,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -b -r1.33 -r1.34
  --- OptimisticCreateIfNotExistsInterceptor.java	30 Dec 2006 17:49:53 -0000	1.33
  +++ OptimisticCreateIfNotExistsInterceptor.java	31 Dec 2006 03:01:20 -0000	1.34
  @@ -54,7 +54,7 @@
         return super.invoke(m);
      }
   
  -   private void move(Fqn newParent, Fqn nodeFqn)
  +   private void move(Fqn nodeFqn, Fqn newParent)
      {
         List<Fqn> fqns = new ArrayList<Fqn>();
         fqns.add(newParent);
  
  
  
  1.41      +14 -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.40
  retrieving revision 1.41
  diff -u -b -r1.40 -r1.41
  --- PessimisticLockInterceptor.java	31 Dec 2006 02:08:40 -0000	1.40
  +++ PessimisticLockInterceptor.java	31 Dec 2006 03:01:20 -0000	1.41
  @@ -37,7 +37,7 @@
    * current method and unlock when the method returns.
    *
    * @author Bela Ban
  - * @version $Id: PessimisticLockInterceptor.java,v 1.40 2006/12/31 02:08:40 msurtani Exp $
  + * @version $Id: PessimisticLockInterceptor.java,v 1.41 2006/12/31 03:01:20 msurtani Exp $
    */
   public class PessimisticLockInterceptor extends Interceptor
   {
  @@ -67,6 +67,7 @@
         Object[] args = m.getArgs();
         InvocationContext ctx = cache.getInvocationContext();
         boolean lockNecessary = false;
  +      boolean locksAlreadyObtained = false;
   
         if (log.isTraceEnabled()) log.trace("PessimisticLockInterceptor invoked for method " + m);
         if (cache.getInvocationContext().getOptionOverrides() != null && cache.getInvocationContext().getOptionOverrides().isSuppressLocking())
  @@ -101,8 +102,11 @@
         switch (m.getMethodId())
         {
            case MethodDeclarations.moveMethodLocal_id:
  -            obtainLocksForMove((Fqn) args[0], (Fqn) args[1]);
  +            fqn = (Fqn) args[0];
  +            obtainLocksForMove(fqn, (Fqn) args[1]);
  +            locksAlreadyObtained = true;
               lockNecessary = true;
  +            isDeleteOperation = true;
               break;
            case MethodDeclarations.putDataMethodLocal_id:
            case MethodDeclarations.putDataEraseMethodLocal_id:
  @@ -165,12 +169,15 @@
         // release the locks for the given TX
         if (fqn != null)
         {
  +         if (!locksAlreadyObtained)
  +         {
            do
            {
               lock(fqn, ctx.getGlobalTransaction(), lock_type, recursive, createIfNotExists, zeroLockTimeout ? 0 : lock_acquisition_timeout, isDeleteOperation);
            }
            while (createIfNotExists && !cache.getRoot().hasChild(fqn));// keep trying until we have the lock (fixes concurrent remove())
         }
  +      }
         else if (!lockNecessary)
         {
            if (log.isTraceEnabled())
  @@ -201,14 +208,14 @@
         return o;
      }
   
  -   private void obtainLocksForMove(Fqn parent, Fqn node) throws InterruptedException
  +   private void obtainLocksForMove(Fqn node, Fqn parent) throws InterruptedException
      {
         // parent node (new parent) and current node's existing parent should both get RLs.
         // node should have a WL.
   
         // 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, false);
  +      lock(node, cache.getInvocationContext().getGlobalTransaction(), NodeLock.LockType.WRITE, true, false, lock_acquisition_timeout, true);
   
         //now for an RL for the new parent.
         if (log.isTraceEnabled()) log.trace("Attempting to get RL on new parent [" + parent + "]");
  
  
  
  1.43      +2 -2      JBossCache/src/org/jboss/cache/interceptors/CacheStoreInterceptor.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CacheStoreInterceptor.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/CacheStoreInterceptor.java,v
  retrieving revision 1.42
  retrieving revision 1.43
  diff -u -b -r1.42 -r1.43
  --- CacheStoreInterceptor.java	31 Dec 2006 02:08:40 -0000	1.42
  +++ CacheStoreInterceptor.java	31 Dec 2006 03:01:20 -0000	1.43
  @@ -27,7 +27,7 @@
    * through the CacheLoader, either after each method call (no TXs), or at TX commit.
    *
    * @author Bela Ban
  - * @version $Id: CacheStoreInterceptor.java,v 1.42 2006/12/31 02:08:40 msurtani Exp $
  + * @version $Id: CacheStoreInterceptor.java,v 1.43 2006/12/31 03:01:20 msurtani Exp $
    */
   public class CacheStoreInterceptor extends BaseCacheLoaderInterceptor implements CacheStoreInterceptorMBean
   {
  @@ -255,7 +255,7 @@
         }
      }
   
  -   private void doMove(Fqn parent, Fqn node) throws Exception
  +   private void doMove(Fqn node, Fqn parent) throws Exception
      {
         Fqn newNodeFqn = new Fqn(parent, node.getLastElement());
         //UnversionedNode n = (UnversionedNode) ((TreeCacheProxyImpl) cache).peek(newNodeFqn);
  
  
  



More information about the jboss-cvs-commits mailing list