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

Manik Surtani msurtani at jboss.com
Thu Jan 4 00:35:37 EST 2007


  User: msurtani
  Date: 07/01/04 00:35:37

  Modified:    src/org/jboss/cache/interceptors            
                        OptimisticLockingInterceptor.java
                        OptimisticValidatorInterceptor.java
                        OptimisticInterceptor.java
                        PassivationInterceptor.java
                        OptimisticNodeInterceptor.java
                        CreateIfNotExistsInterceptor.java
                        CacheLoaderInterceptor.java
                        OptimisticCreateIfNotExistsInterceptor.java
                        DataGravitatorInterceptor.java
                        PessimisticLockInterceptor.java
                        ActivationInterceptor.java TxInterceptor.java
  Log:
  Major changes around nodes, and the way they interact with the interceptor stack.
  Also removed redundant methods in NodeSPI and removed the need for casting to NodeSPI in most cases.
  
  Revision  Changes    Path
  1.25      +4 -4      JBossCache/src/org/jboss/cache/interceptors/OptimisticLockingInterceptor.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: OptimisticLockingInterceptor.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/OptimisticLockingInterceptor.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -b -r1.24 -r1.25
  --- OptimisticLockingInterceptor.java	30 Dec 2006 17:49:54 -0000	1.24
  +++ OptimisticLockingInterceptor.java	4 Jan 2007 05:35:37 -0000	1.25
  @@ -10,7 +10,7 @@
   import org.jboss.cache.CacheSPI;
   import org.jboss.cache.GlobalTransaction;
   import org.jboss.cache.InvocationContext;
  -import org.jboss.cache.Node;
  +import org.jboss.cache.NodeSPI;
   import org.jboss.cache.TransactionEntry;
   import org.jboss.cache.lock.NodeLock;
   import org.jboss.cache.marshall.MethodCall;
  @@ -146,13 +146,13 @@
         for (Iterator it = nodes.iterator(); it.hasNext();)
         {
            WorkspaceNode workspaceNode = (WorkspaceNode) it.next();
  -         Node node = workspaceNode.getNode();
  +         NodeSPI node = workspaceNode.getNode();
   
  -         boolean acquired = node.getNodeSPI().getLock().acquire(gtx, lockAcquisitionTimeout, NodeLock.LockType.WRITE);
  +         boolean acquired = node.getLock().acquire(gtx, lockAcquisitionTimeout, NodeLock.LockType.WRITE);
            if (acquired)
            {
               if (log.isTraceEnabled()) log.trace("acquired lock on node " + node.getFqn());
  -            cache.getTransactionTable().addLock(gtx, node.getNodeSPI().getLock());
  +            cache.getTransactionTable().addLock(gtx, node.getLock());
            }
            else
            {
  
  
  
  1.50      +8 -9      JBossCache/src/org/jboss/cache/interceptors/OptimisticValidatorInterceptor.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: OptimisticValidatorInterceptor.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/OptimisticValidatorInterceptor.java,v
  retrieving revision 1.49
  retrieving revision 1.50
  diff -u -b -r1.49 -r1.50
  --- OptimisticValidatorInterceptor.java	3 Jan 2007 15:33:08 -0000	1.49
  +++ OptimisticValidatorInterceptor.java	4 Jan 2007 05:35:37 -0000	1.50
  @@ -10,7 +10,6 @@
   import org.jboss.cache.Fqn;
   import org.jboss.cache.GlobalTransaction;
   import org.jboss.cache.InvocationContext;
  -import org.jboss.cache.Node;
   import org.jboss.cache.NodeSPI;
   import org.jboss.cache.marshall.MethodCall;
   import org.jboss.cache.marshall.MethodDeclarations;
  @@ -170,7 +169,7 @@
            if (wrappedNode.isDeleted())
            {
               if (trace) log.trace("Workspace node " + wrappedNode.getFqn() + " deleted; removing");
  -            Node dNode = wrappedNode.getNode();
  +            NodeSPI dNode = wrappedNode.getNode();
   
   
               if (dNode.getFqn().isRoot())
  @@ -179,14 +178,14 @@
               }
               else
               {
  -               Node parent = dNode.getParent();
  +               NodeSPI parent = dNode.getParent();
                  if (parent == null)
                  {
                     throw new IllegalStateException("dNode " + dNode + " has no parent");
                  }
  -               cache.getInvocationContext().getOptionOverrides().setBypassInterceptorChain(true);
  -               parent.removeChild(new Fqn(dNode.getFqn().getLastElement()));
  -               cache.getInvocationContext().getOptionOverrides().setBypassInterceptorChain(false);
  +
  +               parent.removeChildDirect(new Fqn(dNode.getFqn().getLastElement()));
  +
               }
            }
            else
  @@ -199,14 +198,14 @@
                  Map mergedChildren = wrappedNode.getMergedChildren();
   
                  // this could be done better to account for more subtle merges
  -               current.getNodeSPI().setChildrenMap(mergedChildren);
  +               current.setChildrenMap(mergedChildren);
   
                  // do we need to notify listeners of a modification??  If all we've done is added children then don't
                  // notify.
                  Map mergedData = wrappedNode.getMergedData();
  -               Map rawData = current.getRawData();
  +               Map rawData = current.getDataDirect();
   
  -               Map raw = current.getNodeSPI().getRawData();
  +               Map raw = current.getDataDirect();
                  raw.clear();
                  raw.putAll(mergedData);
                  if (wrappedNode.isVersioningImplicit())
  
  
  
  1.9       +3 -3      JBossCache/src/org/jboss/cache/interceptors/OptimisticInterceptor.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: OptimisticInterceptor.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/OptimisticInterceptor.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -b -r1.8 -r1.9
  --- OptimisticInterceptor.java	31 Dec 2006 02:08:40 -0000	1.8
  +++ OptimisticInterceptor.java	4 Jan 2007 05:35:37 -0000	1.9
  @@ -10,7 +10,7 @@
   import org.jboss.cache.CacheSPI;
   import org.jboss.cache.Fqn;
   import org.jboss.cache.GlobalTransaction;
  -import org.jboss.cache.Node;
  +import org.jboss.cache.NodeSPI;
   import org.jboss.cache.OptimisticTransactionEntry;
   import org.jboss.cache.TransactionTable;
   import org.jboss.cache.optimistic.TransactionWorkspace;
  @@ -54,13 +54,13 @@
       * @param list
       * @param n
       */
  -   protected void greedyGetFqns(List<Fqn> list, Node n, Fqn newBase)
  +   protected void greedyGetFqns(List<Fqn> list, NodeSPI n, Fqn newBase)
      {
         list.add(n.getFqn());
         Fqn newFqn = new Fqn(newBase, n.getFqn().getLastElement());
         list.add(newFqn);
   
  -      for (Node child : n.getChildren())
  +      for (NodeSPI child : n.getChildrenDirect())
         {
            greedyGetFqns(list, child, newFqn);
         }
  
  
  
  1.39      +5 -10     JBossCache/src/org/jboss/cache/interceptors/PassivationInterceptor.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: PassivationInterceptor.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/PassivationInterceptor.java,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -b -r1.38 -r1.39
  --- PassivationInterceptor.java	3 Jan 2007 15:33:08 -0000	1.38
  +++ PassivationInterceptor.java	4 Jan 2007 05:35:37 -0000	1.39
  @@ -2,7 +2,7 @@
   
   import org.jboss.cache.CacheSPI;
   import org.jboss.cache.Fqn;
  -import org.jboss.cache.Node;
  +import org.jboss.cache.NodeSPI;
   import org.jboss.cache.loader.CacheLoader;
   import org.jboss.cache.marshall.MethodCall;
   import org.jboss.cache.marshall.MethodDeclarations;
  @@ -16,7 +16,7 @@
    * CacheLoader, either before each method call (no TXs), or at TX commit.
    *
    * @author <a href="mailto:{hmesha at novell.com}">{Hany Mesha}</a>
  - * @version $Id: PassivationInterceptor.java,v 1.38 2007/01/03 15:33:08 msurtani Exp $
  + * @version $Id: PassivationInterceptor.java,v 1.39 2007/01/04 05:35:37 msurtani Exp $
    */
   public class PassivationInterceptor extends Interceptor implements PassivationInterceptorMBean
   {
  @@ -106,16 +106,11 @@
         {
            throw new NodeNotLoadedException();
         }
  -      Node n = cache.getRoot();
  -      int size = fqn.size();
  -      for (int i = 0; i < size && n != null; i++)
  -      {
  -         cache.getInvocationContext().getOptionOverrides().setBypassInterceptorChain(true);
  -         n = n.getChild(new Fqn(fqn.get(i)));
  -      }
  +      NodeSPI n = cache.peek(fqn);
  +
         if (n != null)
         {
  -         return n.getNodeSPI().getRawData();
  +         return n.getDataDirect();
         }
         else
         {
  
  
  
  1.45      +4 -2      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.44
  retrieving revision 1.45
  diff -u -b -r1.44 -r1.45
  --- OptimisticNodeInterceptor.java	3 Jan 2007 17:50:31 -0000	1.44
  +++ OptimisticNodeInterceptor.java	4 Jan 2007 05:35:37 -0000	1.45
  @@ -12,7 +12,7 @@
   import org.jboss.cache.Fqn;
   import org.jboss.cache.GlobalTransaction;
   import org.jboss.cache.InvocationContext;
  -import org.jboss.cache.Node;
  +import org.jboss.cache.NodeSPI;
   import org.jboss.cache.config.Option;
   import org.jboss.cache.factories.NodeFactory;
   import org.jboss.cache.marshall.MethodCall;
  @@ -47,6 +47,8 @@
         // bypass for buddy group org method calls.
         if (MethodDeclarations.isBuddyGroupOrganisationMethod(m.getMethodId())) return super.invoke(m);
   
  +      if (log.isTraceEnabled()) log.trace("Processing method call " + m);
  +
         InvocationContext ctx = cache.getInvocationContext();
         Object[] args = m.getArgs();
   
  @@ -475,7 +477,7 @@
         // if we do not have the node then we need to add it to the workspace
         if (workspaceNode == null)
         {
  -         Node node = cache.peek(fqn);
  +         NodeSPI node = cache.peek(fqn);
            if (node == null)
            {
               return null;// seems to happen quite a bit
  
  
  
  1.24      +86 -56    JBossCache/src/org/jboss/cache/interceptors/CreateIfNotExistsInterceptor.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CreateIfNotExistsInterceptor.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/CreateIfNotExistsInterceptor.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -b -r1.23 -r1.24
  --- CreateIfNotExistsInterceptor.java	3 Jan 2007 15:33:08 -0000	1.23
  +++ CreateIfNotExistsInterceptor.java	4 Jan 2007 05:35:37 -0000	1.24
  @@ -5,7 +5,7 @@
   import org.jboss.cache.CacheSPI;
   import org.jboss.cache.Fqn;
   import org.jboss.cache.GlobalTransaction;
  -import org.jboss.cache.Node;
  +import org.jboss.cache.NodeSPI;
   import org.jboss.cache.marshall.MethodCall;
   import org.jboss.cache.marshall.MethodCallFactory;
   import org.jboss.cache.marshall.MethodDeclarations;
  @@ -19,7 +19,7 @@
    * (depending on the create_if_not_exists argument)
    *
    * @author Bela Ban
  - * @version $Id: CreateIfNotExistsInterceptor.java,v 1.23 2007/01/03 15:33:08 msurtani Exp $
  + * @version $Id: CreateIfNotExistsInterceptor.java,v 1.24 2007/01/04 05:35:37 msurtani Exp $
    * @deprecated This code is not used anymore and will be removed in a future unlock
    */
   public class CreateIfNotExistsInterceptor extends Interceptor
  @@ -39,7 +39,7 @@
         super.setCache(cache);
      }
   
  -/*   public Object invoke(MethodCall m) throws Throwable {
  +   /*   public Object invoke(MethodCall m) throws Throwable {
   
         // we need to sync here - might have concurrent put() and remove() calls
         synchronized(this) { // only 1 thread can be here at any time - missing node needs to be created only once
  @@ -59,48 +59,48 @@
         return super.invoke(m);
      }*/
   
  -//   /**
  -//    * Synchronize between put(), remove() and evict() methods. This is coarse-grained, and should be replaced
  -//    * with FQN-based synchronization, e.g. put("/1/2/3" should <em>not</em> synchronize with remove("/a/b/c").
  -//    * @param m
  -//    * @return
  -//    * @throws Throwable
  -//    */
  -//   public Object invoke(MethodCall m) throws Throwable {
  -//      Method meth=m.getMethod();
  -//
  -//      boolean isPut=putMethods.contains(meth),
  -//            isRemove=CacheImpl.removeNodeMethodLocal.equals(meth),
  -//            isEvict=CacheImpl.evictNodeMethodLocal.equals(meth);
  -//
  -//      if(isPut || isRemove || isEvict) {  // we need to sync put(), remove() and evict() calls
  -//         try {
  -//            Object[] args=m.getArgs();
  -//            Fqn fqn=(Fqn)(args != null? (isEvict? args[0] : args[1]) : null);
  -//            if(fqn == null)
  -//               throw new CacheException("failed extracting FQN from method " + m);
  -//
  -//            lock.lockInterruptibly();
  -//            if(isPut) { // lock needs to be held across puts()
  -//               if(!cache.exists(fqn)) {
  -//                  GlobalTransaction gtx=cache.getCurrentTransaction();
  -//                  if(log.isTraceEnabled())
  -//                     log.trace("creating node " + fqn);
  -//                  createNode(fqn, gtx);
  -//                  // lock(fqn, DataNode.LOCK_TYPE_WRITE, false);
  -//               }
  -//               else
  -//                  lock.unlock();
  -//            }
  -//            return super.invoke(m);
  -//         }
  -//         finally {
  -//            if(lock.holds() > 0)
  -//               lock.unlock();  // unlock lock for put()
  -//         }
  -//      }
  -//      return super.invoke(m); // no locks held for non put()/remove()/evict() methods (e.g. for get() methods)
  -//   }
  +   //   /**
  +   //    * Synchronize between put(), remove() and evict() methods. This is coarse-grained, and should be replaced
  +   //    * with FQN-based synchronization, e.g. put("/1/2/3" should <em>not</em> synchronize with remove("/a/b/c").
  +   //    * @param m
  +   //    * @return
  +   //    * @throws Throwable
  +   //    */
  +   //   public Object invoke(MethodCall m) throws Throwable {
  +   //      Method meth=m.getMethod();
  +   //
  +   //      boolean isPut=putMethods.contains(meth),
  +   //            isRemove=CacheImpl.removeNodeMethodLocal.equals(meth),
  +   //            isEvict=CacheImpl.evictNodeMethodLocal.equals(meth);
  +   //
  +   //      if(isPut || isRemove || isEvict) {  // we need to sync put(), remove() and evict() calls
  +   //         try {
  +   //            Object[] args=m.getArgs();
  +   //            Fqn fqn=(Fqn)(args != null? (isEvict? args[0] : args[1]) : null);
  +   //            if(fqn == null)
  +   //               throw new CacheException("failed extracting FQN from method " + m);
  +   //
  +   //            lock.lockInterruptibly();
  +   //            if(isPut) { // lock needs to be held across puts()
  +   //               if(!cache.exists(fqn)) {
  +   //                  GlobalTransaction gtx=cache.getCurrentTransaction();
  +   //                  if(log.isTraceEnabled())
  +   //                     log.trace("creating node " + fqn);
  +   //                  createNode(fqn, gtx);
  +   //                  // lock(fqn, DataNode.LOCK_TYPE_WRITE, false);
  +   //               }
  +   //               else
  +   //                  lock.unlock();
  +   //            }
  +   //            return super.invoke(m);
  +   //         }
  +   //         finally {
  +   //            if(lock.holds() > 0)
  +   //               lock.unlock();  // unlock lock for put()
  +   //         }
  +   //      }
  +   //      return super.invoke(m); // no locks held for non put()/remove()/evict() methods (e.g. for get() methods)
  +   //   }
   
   
      /**
  @@ -118,14 +118,16 @@
                 isEvict = m.getMethodId() == MethodDeclarations.evictNodeMethodLocal_id;
   
         if (isPut || isRemove || isEvict)
  -      {  // we need to sync put(), remove() and evict() calls
  +      {// we need to sync put(), remove() and evict() calls
            Object[] args = m.getArgs();
            fqn = (Fqn) (args != null ? (isEvict ? args[0] : args[1]) : null);
            if (fqn == null)
  +         {
               throw new CacheException("failed extracting FQN from method " + m);
  +         }
   
            if (isPut)
  -         { // lock needs to be held across puts()
  +         {// lock needs to be held across puts()
               try
               {
                  addFqnToPutList(fqn, put_lock);
  @@ -134,7 +136,9 @@
                  {
                     GlobalTransaction gtx = cache.getInvocationContext().getGlobalTransaction();
                     if (log.isTraceEnabled())
  +                  {
                        log.trace("creating node " + fqn);
  +                  }
                     createNode(fqn, gtx);
                  }
   
  @@ -146,10 +150,10 @@
               }
            }
            else
  -         { // remove() or evict(): wait until all puts() that work on the same subtree have completed
  +         {// remove() or evict(): wait until all puts() that work on the same subtree have completed
               try
               {
  -               findAndBlockOnPut(fqn, put_lock);  // does NOT unlock put_lock !
  +               findAndBlockOnPut(fqn, put_lock);// does NOT unlock put_lock !
                  addFqnToRemoveList(fqn, remove_lock);
                  put_lock.unlock();
                  // we only unlock now because waiting on the put-list and adding to remove-list need to be atomic ! 
  @@ -158,7 +162,9 @@
               finally
               {
                  if (put_lock.isHeldByCurrentThread())
  +               {
                     put_lock.unlock();
  +               }
                  removeFqnFromRemoveList(fqn, remove_lock);
               }
            }
  @@ -184,17 +190,23 @@
            //try {
            lock.lockInterruptibly();
            tmp = findFqnInPutList(fqn);
  -         if (tmp == null) // put_list is empty, or fqn has not been found
  +         if (tmp == null)// put_list is empty, or fqn has not been found
  +         {
               return;
  +         }
            if (log.isTraceEnabled())
  +         {
               log.trace("found " + tmp + " in put-list, waiting");
  +         }
            synchronized (tmp)
            {
               lock.unlock();
               tmp.wait();
            }
            if (log.isTraceEnabled())
  +         {
               log.trace("wait() for put-list on " + tmp + " got notified");
  +         }
            //}
            //finally {
            // if(lock.holds() > 0)
  @@ -220,18 +232,24 @@
            try
            {
               tmp = findFqnInRemoveList(fqn);
  -            if (tmp == null) // remove_list is empty, or fqn has not been found
  +            if (tmp == null)// remove_list is empty, or fqn has not been found
  +            {
                  return;
  +            }
               if (log.isTraceEnabled())
  +            {
                  log.trace("found " + tmp + " in remove-list, waiting");
  +            }
               synchronized (tmp)
               {
                  lock.unlock();
                  tmp.wait();
               }
               if (log.isTraceEnabled())
  +            {
                  log.trace("wait() for remove-list on " + tmp + " got notified");
            }
  +         }
            finally
            {
               lock.unlock();
  @@ -246,9 +264,11 @@
         for (Iterator it = put_list.iterator(); it.hasNext();)
         {
            tmp = (Fqn) it.next();
  -         if (tmp.isChildOf(fqn) || tmp.equals(fqn))  // child or same, e.g. put(/a/b/c) and rem(/a/b) or rem(/a/b/c)
  +         if (tmp.isChildOf(fqn) || tmp.equals(fqn))// child or same, e.g. put(/a/b/c) and rem(/a/b) or rem(/a/b/c)
  +         {
               return tmp;
         }
  +      }
         return null;
      }
   
  @@ -258,9 +278,11 @@
         for (Iterator it = remove_list.iterator(); it.hasNext();)
         {
            tmp = (Fqn) it.next();
  -         if (fqn.isChildOf(tmp) || fqn.equals(tmp))  // child or same, e.g. put(/a/b/c) and rem(/a/b) or rem(/a/b/c)
  +         if (fqn.isChildOf(tmp) || fqn.equals(tmp))// child or same, e.g. put(/a/b/c) and rem(/a/b) or rem(/a/b/c)
  +         {
               return tmp;
         }
  +      }
         return null;
      }
   
  @@ -274,9 +296,11 @@
            {
               put_list.add(fqn);
               if (log.isTraceEnabled())
  +            {
                  log.trace("adding " + fqn + " to put-list (size=" + put_list.size() + ")");
            }
         }
  +      }
         finally
         {
            lock.unlock();
  @@ -293,9 +317,11 @@
            {
               remove_list.add(fqn);
               if (log.isTraceEnabled())
  +            {
                  log.trace("adding " + fqn + " to remove-list (size=" + remove_list.size() + ")");
            }
         }
  +      }
         finally
         {
            lock.unlock();
  @@ -310,7 +336,9 @@
         try
         {
            if (log.isTraceEnabled())
  +         {
               log.trace("removing " + fqn + " from put-list (size=" + put_list.size() + ")");
  +         }
            put_list.remove(fqn);
            lock.unlock();
            synchronized (fqn)
  @@ -331,7 +359,9 @@
         try
         {
            if (log.isTraceEnabled())
  +         {
               log.trace("removing " + fqn + " from remove-list (size=" + remove_list.size() + ")");
  +         }
            remove_list.remove(fqn);
            lock.unlock();
            synchronized (fqn)
  @@ -347,7 +377,7 @@
   
      private void createNode(Fqn fqn, GlobalTransaction tx)
      {
  -      Node n, child_node;
  +      NodeSPI n, child_node;
         Object child_name;
         Fqn tmp_fqn = Fqn.ROOT;
   
  @@ -360,11 +390,11 @@
            {
               child_name = fqn.get(i);
               tmp_fqn = new Fqn(tmp_fqn, child_name);
  -            child_node = n.getChild(new Fqn(child_name));
  +            child_node = n.getChildDirect(child_name);
               if (child_node == null)
               {
                  //child_node=n.createChild(child_name, tmp_fqn, n);
  -               child_node = n.addChild(new Fqn(child_name));
  +               child_node = n.addChildDirect(new Fqn(child_name));
                  if (tx != null)
                  {
                     MethodCall undo_op = MethodCallFactory.create(MethodDeclarations.removeNodeMethodLocal,
  
  
  
  1.69      +60 -64    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.68
  retrieving revision 1.69
  diff -u -b -r1.68 -r1.69
  --- CacheLoaderInterceptor.java	3 Jan 2007 15:33:08 -0000	1.68
  +++ CacheLoaderInterceptor.java	4 Jan 2007 05:35:37 -0000	1.69
  @@ -5,10 +5,9 @@
   import org.jboss.cache.Fqn;
   import org.jboss.cache.GlobalTransaction;
   import org.jboss.cache.InvocationContext;
  -import org.jboss.cache.Node;
  +import org.jboss.cache.NodeSPI;
   import org.jboss.cache.TransactionEntry;
   import org.jboss.cache.TransactionTable;
  -import org.jboss.cache.config.Option;
   import org.jboss.cache.loader.AsyncCacheLoader;
   import org.jboss.cache.loader.CacheLoader;
   import org.jboss.cache.loader.ChainingCacheLoader;
  @@ -29,7 +28,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.68 2007/01/03 15:33:08 msurtani Exp $
  + * @version $Id: CacheLoaderInterceptor.java,v 1.69 2007/01/04 05:35:37 msurtani Exp $
    */
   public class CacheLoaderInterceptor extends BaseCacheLoaderInterceptor implements CacheLoaderInterceptorMBean
   {
  @@ -77,7 +76,7 @@
         else
         {
            // tests for org.jboss.cache.loader.*
  -         Package pkg = cl.getClass().getPackage(); // may be null if this is an inner class?  In which case it is certainly a custom cache loader instance.
  +         Package pkg = cl.getClass().getPackage();// may be null if this is an inner class?  In which case it is certainly a custom cache loader instance.
            return pkg == null || !pkg.getName().startsWith("org.jboss.cache");
         }
      }
  @@ -91,17 +90,17 @@
       */
      public Object invoke(MethodCall m) throws Throwable
      {
  -      Fqn fqn = null, fqn2 = null; // if set, load the data.  fqn2 for 2nd fqn in move().
  +      Fqn fqn = null, fqn2 = null;// if set, load the data.  fqn2 for 2nd fqn in move().
   
         Object[] args = m.getArgs();
  -      boolean acquireLock = false; // do we need to acquire a lock if we load this node from cloader?
  +      boolean acquireLock = false;// do we need to acquire a lock if we load this node from cloader?
   
  -      boolean initNode = false; // keep uninitialized
  +      boolean initNode = false;// keep uninitialized
         Object key = null;
         InvocationContext ctx = cache.getInvocationContext();
         TransactionEntry entry = null;
         GlobalTransaction gtx;
  -      boolean recursive = false; // do we also load children?
  +      boolean recursive = false;// do we also load children?
   
   
         if ((gtx = ctx.getGlobalTransaction()) != null)
  @@ -180,7 +179,9 @@
         if (fqn != null)
         {
            if (fqn2 != null)
  +         {
               loadIfNeeded(fqn2, key, initNode, acquireLock, m, entry, false, m.getMethodId() == MethodDeclarations.moveMethodLocal_id);
  +         }
            loadIfNeeded(fqn, key, initNode, acquireLock, m, entry, recursive, m.getMethodId() == MethodDeclarations.moveMethodLocal_id);
         }
   
  @@ -195,7 +196,7 @@
         try
         {
   
  -         Node n = cache.peek(fqn);
  +         NodeSPI n = cache.peek(fqn);
   
            boolean mustLoad = mustLoad(n, key);
            if (log.isTraceEnabled())
  @@ -226,7 +227,7 @@
               // - Manik Surtani (21 March 2006)
               if (acquireLock)
               {
  -               lock(fqn, NodeLock.LockType.WRITE, false); // non-recursive for now
  +               lock(fqn, NodeLock.LockType.WRITE, false);// non-recursive for now
               }
            }
   
  @@ -249,10 +250,10 @@
       *
       * @param node may be null if the node was not found.
       */
  -   private void loadChildren(Fqn fqn, Node node, boolean recursive, boolean isMove) throws Throwable
  +   private void loadChildren(Fqn fqn, NodeSPI node, boolean recursive, boolean isMove) throws Throwable
      {
   
  -      if (node != null && node.getNodeSPI().getChildrenLoaded())
  +      if (node != null && node.getChildrenLoaded())
         {
            return;
         }
  @@ -270,53 +271,54 @@
            {
               if (useCacheStore)
               {
  -               node.getNodeSPI().getChildrenMap().clear();
  +               node.getChildrenMap().clear();
               }
  -            node.getNodeSPI().setChildrenLoaded(true);
  +            node.setChildrenLoaded(true);
            }
            return;
         }
   
         // Create if node had not been created already
         if (node == null)
  -         node = createNodes(fqn, null); // dont care about local transactions
  +      {
  +         node = createNodes(fqn, null);// dont care about local transactions
  +      }
   
         // Create one DataNode per child, mark as UNINITIALIZED
         for (Object name : children_names)
         {
  -         Fqn child_fqn = new Fqn(name); // this is a RELATIVE Fqn!!
  +         Fqn child_fqn = new Fqn(name);// this is a RELATIVE Fqn!!
   
            // create child if it didn't exist
  -         cache.getInvocationContext().getOptionOverrides().setBypassInterceptorChain(true);
  -         Node child = node.addChild(child_fqn);
  -         Map childMap = child.getNodeSPI().getRawData();
  +         NodeSPI child = node.addChildDirect(child_fqn);
  +         Map childMap = child.getDataDirect();
            if ((isMove || isActivation) && recursive)
            {
               // load data for children as well!
               childMap.putAll(loader.get(child.getFqn()));
  -            child.getNodeSPI().setDataLoaded(true);
  +            child.setDataLoaded(true);
            }
            else
            {
  -            child.getNodeSPI().setDataLoaded(false);
  +            child.setDataLoaded(false);
            }
            if (recursive)
            {
               loadChildren(child.getFqn(), child, true, isMove);
            }
         }
  -      lock(fqn, recursive ? NodeLock.LockType.WRITE : NodeLock.LockType.READ, true); // recursive=true: lock entire subtree
  -      node.getNodeSPI().setChildrenLoaded(true);
  +      lock(fqn, recursive ? NodeLock.LockType.WRITE : NodeLock.LockType.READ, true);// recursive=true: lock entire subtree
  +      node.setChildrenLoaded(true);
      }
   
  -   private boolean mustLoad(Node n, Object key)
  +   private boolean mustLoad(NodeSPI n, Object key)
      {
         if (n == null)
         {
            log.trace("mustLoad, node null");
            return true;
         }
  -      if (!n.getNodeSPI().getDataLoaded())
  +      if (!n.getDataLoaded())
         {
            log.trace("must Load, uninitialized");
            return true;
  @@ -369,22 +371,23 @@
       *
       * @param fqn
       */
  -   protected Node getNode(Fqn fqn)
  +   protected NodeSPI getNode(Fqn fqn)
      {
  -      int treeNodeSize = fqn.size();
  -
  -      // root node
  -      Node n = cache.getRoot();
  -      Node child_node;
  -      Object child_name;
  -      for (int i = 0; i < treeNodeSize && n != null; i++)
  -      {
  -         child_name = fqn.get(i);
  -         cache.getInvocationContext().getOptionOverrides().setBypassInterceptorChain(true);
  -         child_node = n.getChild(new Fqn(child_name));
  -         n = child_node;
  -      }
  -      return n;
  +      return cache.peek(fqn);
  +      //      int treeNodeSize = fqn.size();
  +      //
  +      //      // root node
  +      //      Node n = cache.getRoot();
  +      //      Node child_node;
  +      //      Object child_name;
  +      //      for (int i = 0; i < treeNodeSize && n != null; i++)
  +      //      {
  +      //         child_name = fqn.get(i);
  +      //         cache.getInvocationContext().getOptionOverrides().setBypassInterceptorChain(true);
  +      //         child_node = n.getChild(new Fqn(child_name));
  +      //         n = child_node;
  +      //      }
  +      //      return n;
      }
   
      /**
  @@ -418,7 +421,7 @@
       * If it doesn't exist on disk but in memory, clears the
       * uninitialized flag, otherwise returns null.
       */
  -   private Node loadNode(Fqn fqn, Node n, TransactionEntry entry) throws Exception
  +   private NodeSPI loadNode(Fqn fqn, NodeSPI n, TransactionEntry entry) throws Exception
      {
         if (log.isTraceEnabled()) log.trace("loadNode " + fqn);
         Map nodeData = loadData(fqn);
  @@ -426,16 +429,14 @@
         {
            log.trace("Node data is not null, loading");
            n = createNodes(fqn, entry);
  -         cache.getInvocationContext().getOptionOverrides().setBypassInterceptorChain(true);
  -         n.clearData();
  -         cache.getInvocationContext().getOptionOverrides().setBypassInterceptorChain(true);
  -         n.put(nodeData);
  +         n.clearDataDirect();
  +         n.putDirect(nodeData);
         }
   
  -      if (n != null && !n.getNodeSPI().getDataLoaded())
  +      if (n != null && !n.getDataLoaded())
         {
            log.trace("Setting dataLoaded to true");
  -         n.getNodeSPI().setDataLoaded(true);
  +         n.setDataLoaded(true);
         }
         return n;
      }
  @@ -443,10 +444,10 @@
      /**
       * Creates a new memory node in preparation for storage.
       */
  -   private Node createTempNode(Fqn fqn, TransactionEntry entry) throws Exception
  +   private NodeSPI createTempNode(Fqn fqn, TransactionEntry entry) throws Exception
      {
  -      Node n = createNodes(fqn, entry);
  -      n.getNodeSPI().setDataLoaded(false);
  +      NodeSPI n = createNodes(fqn, entry);
  +      n.setDataLoaded(false);
         if (log.isTraceEnabled())
         {
            log.trace("createTempNode n " + n);
  @@ -455,38 +456,33 @@
      }
   
   
  -   private Node createNodes(Fqn fqn, TransactionEntry entry) throws Exception
  +   private NodeSPI createNodes(Fqn fqn, TransactionEntry entry) throws Exception
      {
         Fqn tmp_fqn = Fqn.ROOT;
   
         int size = fqn.size();
   
         // root node
  -      Node n = cache.getRoot();
  +      NodeSPI n = cache.getRoot();
         for (int i = 0; i < size; i++)
         {
            Object child_name = fqn.get(i);
            tmp_fqn = new Fqn(tmp_fqn, child_name);
   
  -//         Node child_node = n.getChild(new Fqn(child_name));
  -         Node child_node = findChild(n, child_name);
  +         NodeSPI child_node = findChild(n, child_name);
            boolean last = (i == size - 1);
   
            if (child_node == null)
            {
  -            Option o = cache.getInvocationContext().getOptionOverrides();
  -            o.setBypassInterceptorChain(true);
               if (last)
               {
  -               child_node = n.addChild(new Fqn(child_name));
  -               child_node.getNodeSPI().setDataLoaded(true);
  -               //child_node = n.createChild(child_name, tmp_fqn, n);
  +               child_node = n.addChildDirect(new Fqn(child_name));
  +               child_node.setDataLoaded(true);
               }
               else
               {
  -               //child_node = n.createChild(child_name, tmp_fqn, n, CacheImpl.UNINITIALIZED, null);
  -               child_node = n.addChild(new Fqn(child_name));
  -               child_node.getNodeSPI().setDataLoaded(false);
  +               child_node = n.addChildDirect(new Fqn(child_name));
  +               child_node.setDataLoaded(false);
               }
   
               if (entry != null)
  @@ -501,9 +497,9 @@
         return n;
      }
   
  -   private Node findChild(Node child, Object child_name)
  +   private NodeSPI findChild(NodeSPI child, Object child_name)
      {
  -      return child.getNodeSPI().getChildrenMap().get(child_name);
  +      return (NodeSPI) child.getChildrenMap().get(child_name);
      }
   
      private void cleanupNodesCreated(TransactionEntry entry)
  
  
  
  1.39      +15 -7     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.38
  retrieving revision 1.39
  diff -u -b -r1.38 -r1.39
  --- OptimisticCreateIfNotExistsInterceptor.java	3 Jan 2007 15:33:08 -0000	1.38
  +++ OptimisticCreateIfNotExistsInterceptor.java	4 Jan 2007 05:35:37 -0000	1.39
  @@ -11,7 +11,7 @@
   import org.jboss.cache.Fqn;
   import org.jboss.cache.GlobalTransaction;
   import org.jboss.cache.InvocationContext;
  -import org.jboss.cache.Node;
  +import org.jboss.cache.NodeSPI;
   import org.jboss.cache.OptimisticTransactionEntry;
   import org.jboss.cache.TransactionEntry;
   import org.jboss.cache.factories.NodeFactory;
  @@ -70,7 +70,7 @@
         fqns.add(newParent);
   
         //  peek into Node and get a hold of all child fqns as these need to be in the workspace.
  -      Node node = cache.peek(nodeFqn);
  +      NodeSPI node = cache.peek(nodeFqn);
         greedyGetFqns(fqns, node, newParent);
   
   
  @@ -133,7 +133,7 @@
            // to the transaction
            if (workspaceNode == null)
            {
  -            Node node = cache.getRoot();
  +            NodeSPI node = cache.getRoot();
               workspaceNode = nodeFactory.createWorkspaceNode(node, workspace);
               workspace.addNode(workspaceNode);
               if (debug) log.debug("Created root node: " + workspaceNode);
  @@ -158,10 +158,12 @@
               // try and get the child of current node
   
               if (debug)
  +            {
                  log.debug("workspaceNode.getChild(" + childName + ")");
  -            Node tempchildNode = workspaceNode.getChild(new Fqn(childName));
  +            }
  +            NodeSPI tempchildNode = workspaceNode.getChild(new Fqn(childName));
   
  -//                if (log.isDebugEnabled()) log.debug(" Entered synchronized workspaceNode " + workspaceNode + " access  for gtx " + gtx);
  +            //                if (log.isDebugEnabled()) log.debug(" Entered synchronized workspaceNode " + workspaceNode + " access  for gtx " + gtx);
   
               // no child exists with this name
               if (tempchildNode == null)
  @@ -196,12 +198,14 @@
                     versionToPassIn = version;
                  }
   
  -               Node tempNode = workspaceNode.createChild(childName, workspaceNode.getNode(), cache, versionToPassIn);
  +               NodeSPI tempNode = workspaceNode.createChild(childName, workspaceNode.getNode(), cache, versionToPassIn);
   
                  childWorkspaceNode = nodeFactory.createWorkspaceNode(tempNode, workspace);
                  childWorkspaceNode.setVersioningImplicit(versionToPassIn == null || !isTargetFqn);
                  if (log.isTraceEnabled())
  +               {
                     log.trace("setting versioning of " + childWorkspaceNode.getFqn() + " to be " + (childWorkspaceNode.isVersioningImplicit() ? "implicit" : "explicit"));
  +               }
   
                  // now add the wrapped child node into the transaction space
                  workspace.addNode(childWorkspaceNode);
  @@ -219,7 +223,9 @@
                  if (childWorkspaceNode == null || childWorkspaceNode.isDeleted())
                  {
                     if (debug)
  +                  {
                        log.debug("Child node " + tempchildNode.getFqn() + " doesn't exist in workspace or has been deleted.  Adding to workspace in gtx " + gtx);
  +                  }
                     childWorkspaceNode = nodeFactory.createWorkspaceNode(tempchildNode, workspace);
                     if (isTargetFqn && !workspace.isVersioningImplicit())
                     {
  @@ -231,7 +237,9 @@
                        childWorkspaceNode.setVersioningImplicit(true);
                     }
                     if (log.isTraceEnabled())
  +                  {
                        log.trace("setting versioning of " + childWorkspaceNode.getFqn() + " to be " + (childWorkspaceNode.isVersioningImplicit() ? "implicit" : "explicit"));
  +                  }
   
                  }
                  else
  @@ -246,7 +254,7 @@
               workspaceNode = childWorkspaceNode;
            }
   
  -      } // end sync block
  +      }// end sync block
         if (debug) log.debug("done synchronized access of GlobalTX");
   
         if (!suppressNotification)
  
  
  
  1.34      +41 -30    JBossCache/src/org/jboss/cache/interceptors/DataGravitatorInterceptor.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: DataGravitatorInterceptor.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/DataGravitatorInterceptor.java,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -b -r1.33 -r1.34
  --- DataGravitatorInterceptor.java	2 Jan 2007 17:15:29 -0000	1.33
  +++ DataGravitatorInterceptor.java	4 Jan 2007 05:35:37 -0000	1.34
  @@ -14,6 +14,7 @@
   import org.jboss.cache.GlobalTransaction;
   import org.jboss.cache.InvocationContext;
   import org.jboss.cache.Node;
  +import org.jboss.cache.NodeSPI;
   import org.jboss.cache.TransactionEntry;
   import org.jboss.cache.buddyreplication.BuddyManager;
   import org.jboss.cache.buddyreplication.GravitateResult;
  @@ -66,11 +67,11 @@
   
      public Object invoke(MethodCall m) throws Throwable
      {
  -//        if (isGravitationEnabled(cache.getInvocationContext()))
  -//        {
  -//            Option opt = cache.getInvocationContext().getOptionOverrides();
  -//            if (opt == null || !opt.isSuppressDataGravitation())
  -//            {
  +      //        if (isGravitationEnabled(cache.getInvocationContext()))
  +      //        {
  +      //            Option opt = cache.getInvocationContext().getOptionOverrides();
  +      //            if (opt == null || !opt.isSuppressDataGravitation())
  +      //            {
         if (log.isTraceEnabled()) log.trace("Invoked with method call " + m);
   
         // Transactional lifecycle methods should be handled regardless of whether data gravitation is enabled or not.
  @@ -122,9 +123,11 @@
            else
            {
               if (log.isTraceEnabled())
  +            {
                  log.trace("Suppressing data gravitation for this call.");
            }
         }
  +      }
         else
         {
   
  @@ -152,13 +155,13 @@
               throw throwable;
            }
         }
  -//            }
  -//        }
  -//        else
  -//        {
  -//           if (log.isTraceEnabled())
  -//              log.trace("Suppressing data gravitation for this call.");
  -//        }
  +      //            }
  +      //        }
  +      //        else
  +      //        {
  +      //           if (log.isTraceEnabled())
  +      //              log.trace("Suppressing data gravitation for this call.");
  +      //        }
         return super.invoke(m);
      }
   
  @@ -232,7 +235,9 @@
         if (resp[0] != null)
         {
            if (log.isTraceEnabled())
  +         {
               log.trace("Got response " + resp[0]);
  +         }
   
            List nodes = null;
            if (configuration.isUseRegionBasedMarshalling())
  @@ -267,17 +272,17 @@
   
      private void cleanBackupData(BackupData backup) throws Throwable
      {
  -//       MethodCall primaryDataCleanup, backupDataCleanup;
  -//       if (buddyManager.isDataGravitationRemoveOnFind())
  -//       {
  -//           primaryDataCleanup = MethodCallFactory.create(MethodDeclarations.removeNodeMethodLocal, new Object[]{null, backup.primaryFqn, Boolean.FALSE});
  -//           backupDataCleanup = MethodCallFactory.create(MethodDeclarations.removeNodeMethodLocal, new Object[]{null, backup.backupFqn, Boolean.FALSE});
  -//       }
  -//       else
  -//       {
  -//           primaryDataCleanup = MethodCallFactory.create(MethodDeclarations.evictNodeMethodLocal, new Object[]{backup.primaryFqn});
  -//           backupDataCleanup = MethodCallFactory.create(MethodDeclarations.evictNodeMethodLocal, new Object[]{backup.backupFqn});
  -//       }
  +      //       MethodCall primaryDataCleanup, backupDataCleanup;
  +      //       if (buddyManager.isDataGravitationRemoveOnFind())
  +      //       {
  +      //           primaryDataCleanup = MethodCallFactory.create(MethodDeclarations.removeNodeMethodLocal, new Object[]{null, backup.primaryFqn, Boolean.FALSE});
  +      //           backupDataCleanup = MethodCallFactory.create(MethodDeclarations.removeNodeMethodLocal, new Object[]{null, backup.backupFqn, Boolean.FALSE});
  +      //       }
  +      //       else
  +      //       {
  +      //           primaryDataCleanup = MethodCallFactory.create(MethodDeclarations.evictNodeMethodLocal, new Object[]{backup.primaryFqn});
  +      //           backupDataCleanup = MethodCallFactory.create(MethodDeclarations.evictNodeMethodLocal, new Object[]{backup.backupFqn});
  +      //       }
   
         MethodCall cleanup = MethodCallFactory.create(MethodDeclarations.dataGravitationCleanupMethod, cache.getInvocationContext().getGlobalTransaction(), backup.primaryFqn, backup.backupFqn);
   
  @@ -298,7 +303,9 @@
         else
         {
            if (log.isTraceEnabled())
  +         {
               log.trace("Data gravitation performed under global transaction " + gtx + ".  Not broadcasting cleanups until the tx commits.  Adding to tx mod list instead.");
  +         }
            transactionMods.put(gtx, cleanup);
            TransactionEntry te = getTransactionEntry(gtx);
            te.addModification(cleanup);
  @@ -308,7 +315,9 @@
      private Object[] gravitateData(Fqn fqn) throws Exception
      {
         if (log.isTraceEnabled())
  +      {
            log.trace("cache=" + cache.getLocalAddress() + "; requesting data gravitation for Fqn " + fqn);
  +      }
         List<Address> mbrs = cache.getMembers();
         Boolean searchSubtrees = (buddyManager.isDataGravitationSearchBackupTrees() ? Boolean.TRUE : Boolean.FALSE);
         Boolean marshal = configuration.isUseRegionBasedMarshalling() ? Boolean.TRUE : Boolean.FALSE;
  @@ -332,8 +341,10 @@
               if (o instanceof Throwable)
               {
                  if (log.isDebugEnabled())
  +               {
                     log.debug("Found remote Throwable among responses - removing from responses list", (Exception) o);
               }
  +            }
               else if (o != null)
               {
                  // keep looping till we find a FOUND answer.
  @@ -386,17 +397,17 @@
      {
         int treeNodeSize;
         if ((treeNodeSize = fqn.size()) == 0) return;
  -      Node n = cache.getRoot();
  +      NodeSPI n = cache.getRoot();
         for (int i = 0; i < treeNodeSize; i++)
         {
            Object child_name = fqn.get(i);
  -         cache.getInvocationContext().getOptionOverrides().setBypassInterceptorChain(true);
  -         Node child_node = n.addChild(new Fqn(child_name));
  -         cache.getInvocationContext().getOptionOverrides().setBypassInterceptorChain(false);
  +         NodeSPI child_node = n.addChildDirect(new Fqn(child_name));
            if (child_node == null)
            {
               if (log.isTraceEnabled())
  +            {
                  log.trace("failed to find or create child " + child_name + " of node " + n.getFqn());
  +            }
               return;
            }
            if (i == treeNodeSize - 1)
  @@ -436,7 +447,7 @@
   
      private BackupData localBackupGet(Fqn fqn) throws CacheException
      {
  -      GravitateResult result = cache.gravitateData(fqn, true, false); // a "local" gravitation
  +      GravitateResult result = cache.gravitateData(fqn, true, false);// a "local" gravitation
         boolean found = result.getDataFound();
         BackupData data = null;
   
  @@ -464,8 +475,8 @@
   
      private Collection<Node> getBackupRootCollection()
      {
  -      Node backupRoot = cache.peek(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN);
  -      return backupRoot == null ? Collections.EMPTY_SET : backupRoot.getChildren();
  +      NodeSPI backupRoot = cache.peek(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN);
  +      return backupRoot == null ? Collections.EMPTY_SET : backupRoot.getChildrenDirect();
      }
   
      private static class BackupData
  
  
  
  1.42      +20 -26    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.41
  retrieving revision 1.42
  diff -u -b -r1.41 -r1.42
  --- PessimisticLockInterceptor.java	31 Dec 2006 03:01:20 -0000	1.41
  +++ PessimisticLockInterceptor.java	4 Jan 2007 05:35:37 -0000	1.42
  @@ -11,7 +11,6 @@
   import org.jboss.cache.Fqn;
   import org.jboss.cache.GlobalTransaction;
   import org.jboss.cache.InvocationContext;
  -import org.jboss.cache.Node;
   import org.jboss.cache.NodeSPI;
   import org.jboss.cache.TransactionEntry;
   import org.jboss.cache.TransactionTable;
  @@ -37,7 +36,7 @@
    * current method and unlock when the method returns.
    *
    * @author Bela Ban
  - * @version $Id: PessimisticLockInterceptor.java,v 1.41 2006/12/31 03:01:20 msurtani Exp $
  + * @version $Id: PessimisticLockInterceptor.java,v 1.42 2007/01/04 05:35:37 msurtani Exp $
    */
   public class PessimisticLockInterceptor extends Interceptor
   {
  @@ -197,7 +196,7 @@
            //cache.getRemovedNodesMap().remove(fqn);
            //cache.peek(fqn);
            // do a REAL remove here.
  -         Node n = cache.peek(fqn);
  +         NodeSPI n = cache.peek(fqn);
            if (n != null)
            {
               lockManager.getLock(n).releaseAll(Thread.currentThread());
  @@ -234,8 +233,8 @@
      private void lock(Fqn fqn, GlobalTransaction gtx, NodeLock.LockType lock_type, boolean recursive, boolean createIfNotExists, long timeout, boolean isDeleteOperation)
              throws TimeoutException, LockingException, InterruptedException
      {
  -      Node n;
  -      Node child_node;
  +      NodeSPI n;
  +      NodeSPI child_node;
         Object child_name;
         Thread currentThread = Thread.currentThread();
         Object owner = (gtx != null) ? gtx : currentThread;
  @@ -267,12 +266,12 @@
            {
               // this is the root node
               child_name = Fqn.ROOT.getLastElement();
  -            child_node = cache.getRoot();
  +            child_node = n;
            }
            else
            {
               child_name = fqn.get(i);
  -            child_node = n.getNodeSPI().getChildrenMap().get(child_name);
  +            child_node = n.getChildDirect(child_name);
            }
            /*
            cache.getInvocationContext().getOptionOverrides().setBypassInterceptorChain(true);
  @@ -281,8 +280,7 @@
            */
            if (child_node == null && createIfNotExists)
            {
  -            cache.getInvocationContext().getOptionOverrides().setBypassInterceptorChain(true);
  -            child_node = n.addChild(new Fqn(child_name));
  +            child_node = n.addChildDirect(new Fqn(child_name));
            }
   
            if (child_node == null)
  @@ -350,14 +348,14 @@
         if (isDeleteOperation && gtx != null) cache.getTransactionTable().get(gtx).addRemovedNode(fqn);
      }
   
  -   private boolean needToReverseRemove(Node n, TransactionEntry te, NodeLock.LockType lockTypeRequested, boolean isRemoveOperation, boolean createIfNotExists)
  +   private boolean needToReverseRemove(NodeSPI n, TransactionEntry te, NodeLock.LockType lockTypeRequested, boolean isRemoveOperation, boolean createIfNotExists)
      {
  -      return !isRemoveOperation && createIfNotExists && lockTypeRequested == NodeLock.LockType.WRITE && ((NodeSPI) n).isDeleted() && te.getRemovedNodes().contains(n.getFqn());
  +      return !isRemoveOperation && createIfNotExists && lockTypeRequested == NodeLock.LockType.WRITE && n.isDeleted() && te.getRemovedNodes().contains(n.getFqn());
      }
   
  -   private void reverseRemove(Node n)
  +   private void reverseRemove(NodeSPI n)
      {
  -      ((NodeSPI) n).markAsDeleted(false);
  +      n.markAsDeleted(false);
      }
   
      private boolean writeLockNeeded(NodeLock.LockType lock_type, int currentNodeIndex, int treeNodeSize, boolean isRemoveOperation, boolean createIfNotExists, Fqn targetFqn, Fqn currentFqn)
  @@ -380,7 +378,7 @@
         return nodePosition == (treeNodeSize - 1);
      }
   
  -   private void acquireNodeLock(Node node, Object owner, GlobalTransaction gtx, NodeLock.LockType lock_type, long lock_timeout) throws LockingException, TimeoutException, InterruptedException
  +   private void acquireNodeLock(NodeSPI node, Object owner, GlobalTransaction gtx, NodeLock.LockType lock_type, long lock_timeout) throws LockingException, TimeoutException, InterruptedException
      {
         boolean acquired = lockManager.acquire(node, owner, lock_type, lock_timeout);
         if (acquired)
  @@ -428,18 +426,14 @@
      {
         int treeNodeSize;
         if ((treeNodeSize = fqn.size()) == 0) return;
  -      Node n = cache.getRoot();
  +      NodeSPI n = cache.getRoot();
         for (int i = 0; i < treeNodeSize; i++)
         {
            Object child_name = fqn.get(i);
            Fqn childFqn = new Fqn(child_name);
  -         cache.getInvocationContext().getOptionOverrides().setBypassInterceptorChain(true);
  -         Node child_node = n.getChild(childFqn);
  -         if (child_node == null)
  -         {
  -            cache.getInvocationContext().getOptionOverrides().setBypassInterceptorChain(true);
  -            child_node = n.addChild(childFqn);//, gtx, true);
  -         }
  +
  +         NodeSPI child_node = n.getChildDirect(childFqn);
  +         if (child_node == null) child_node = n.addChildDirect(childFqn);
            // test if this node needs to be 'undeleted'
            // reverse the "remove" if the node has been previously removed in the same tx, if this operation is a put()
            if (gtx != null && needToReverseRemove(child_node, tx_table.get(gtx), NodeLock.LockType.WRITE, false, true))
  @@ -570,17 +564,17 @@
   
      private static class LockManager
      {
  -      boolean acquire(Node node, Object owner, NodeLock.LockType lockType, long timeout) throws InterruptedException
  +      boolean acquire(NodeSPI node, Object owner, NodeLock.LockType lockType, long timeout) throws InterruptedException
         {
            return getLock(node).acquire(owner, timeout, lockType);
         }
   
  -      NodeLock getLock(Node node)
  +      NodeLock getLock(NodeSPI node)
         {
  -         return node.getNodeSPI().getLock();
  +         return node.getLock();
         }
   
  -      public Set acquireAll(Node node, Object owner, NodeLock.LockType lockType, long timeout) throws InterruptedException
  +      public Set acquireAll(NodeSPI node, Object owner, NodeLock.LockType lockType, long timeout) throws InterruptedException
         {
            return getLock(node).acquireAll(owner, timeout, lockType);
         }
  
  
  
  1.48      +16 -12    JBossCache/src/org/jboss/cache/interceptors/ActivationInterceptor.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ActivationInterceptor.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/ActivationInterceptor.java,v
  retrieving revision 1.47
  retrieving revision 1.48
  diff -u -b -r1.47 -r1.48
  --- ActivationInterceptor.java	3 Jan 2007 15:33:08 -0000	1.47
  +++ ActivationInterceptor.java	4 Jan 2007 05:35:37 -0000	1.48
  @@ -3,7 +3,7 @@
   import org.jboss.cache.Fqn;
   import org.jboss.cache.GlobalTransaction;
   import org.jboss.cache.Modification;
  -import org.jboss.cache.Node;
  +import org.jboss.cache.NodeSPI;
   import org.jboss.cache.TransactionEntry;
   import org.jboss.cache.TransactionTable;
   import org.jboss.cache.marshall.MethodCall;
  @@ -25,7 +25,7 @@
    * their attributes have been initialized and their children have been loaded in memory.
    *
    * @author <a href="mailto:{hmesha at novell.com}">{Hany Mesha}</a>
  - * @version $Id: ActivationInterceptor.java,v 1.47 2007/01/03 15:33:08 msurtani Exp $
  + * @version $Id: ActivationInterceptor.java,v 1.48 2007/01/04 05:35:37 msurtani Exp $
    */
   public class ActivationInterceptor extends CacheLoaderInterceptor implements ActivationInterceptorMBean
   {
  @@ -157,11 +157,11 @@
                  // its attributes have been initialized, its children have been loaded,
                  // AND it was found in the cache loader (nodeLoaded = true).
                  // Then notify the listeners that the node has been activated.
  -               Node n = getNode(fqn); // don't load
  +               NodeSPI n = getNode(fqn);// don't load
                  // node not null and attributes have been loaded?
  -               if (n != null && n.getNodeSPI().getDataLoaded())
  +               if (n != null && n.getDataLoaded())
                  {
  -                  if (!n.getChildren().isEmpty())
  +                  if (!n.getChildrenDirect().isEmpty())
                     {
                        if (allInitialized(n))
                        {
  @@ -194,16 +194,20 @@
      /**
       * Returns true if a node has all children loaded and initialized.
       */
  -   private boolean allInitialized(Node n)
  +   private boolean allInitialized(NodeSPI n)
  +   {
  +      if (!n.getChildrenLoaded())
      {
  -      if (!n.getNodeSPI().getChildrenLoaded())
            return false;
  +      }
   
  -      for (Node child : n.getChildren())
  +      for (NodeSPI child : n.getChildrenDirect())
  +      {
  +         if (!child.getDataLoaded())
         {
  -         if (!child.getNodeSPI().getDataLoaded())
               return false;
         }
  +      }
         return true;
      }
   
  @@ -303,12 +307,12 @@
                  Fqn fqn = (Fqn) args[1];
                  if (fqn != null && cache.getRoot().hasChild(fqn) && loader.exists(fqn))
                  {
  -                  Node n = getNode(fqn); // don't load
  +                  NodeSPI n = getNode(fqn);// don't load
                     // node not null and attributes have been loaded?
  -                  if (n != null && n.getNodeSPI().getDataLoaded())
  +                  if (n != null && n.getDataLoaded())
                     {
                        // has children?
  -                     if (!n.getChildren().isEmpty() && allInitialized(n))
  +                     if (!n.getChildrenDirect().isEmpty() && allInitialized(n))
                        {
                           // children have been loaded, remove the node
                           addRemoveMod(cache_loader_modifications, fqn);
  
  
  
  1.72      +6 -5      JBossCache/src/org/jboss/cache/interceptors/TxInterceptor.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: TxInterceptor.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/TxInterceptor.java,v
  retrieving revision 1.71
  retrieving revision 1.72
  diff -u -b -r1.71 -r1.72
  --- TxInterceptor.java	3 Jan 2007 15:33:08 -0000	1.71
  +++ TxInterceptor.java	4 Jan 2007 05:35:37 -0000	1.72
  @@ -19,7 +19,6 @@
   import org.jboss.cache.marshall.MethodCallFactory;
   import org.jboss.cache.marshall.MethodDeclarations;
   import org.jboss.cache.optimistic.DataVersion;
  -import org.jgroups.Address;
   
   import javax.transaction.Status;
   import javax.transaction.Synchronization;
  @@ -681,12 +680,12 @@
               if (configuration.isNodeLockingOptimistic())
               {
                  commitMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod,
  -                       gtx, modifications, null, (Address) cache.getLocalAddress(), true);
  +                       gtx, modifications, null, cache.getLocalAddress(), true);
               }
               else
               {
                  commitMethod = MethodCallFactory.create(MethodDeclarations.prepareMethod,
  -                       gtx, modifications, (Address) cache.getLocalAddress(),
  +                       gtx, modifications, cache.getLocalAddress(),
                          true);
               }
            }
  @@ -719,8 +718,10 @@
      {
         TransactionEntry entry = txTable.get(gtx);
         if (entry != null)
  +      {
            entry.releaseAllLocksLIFO(gtx);
      }
  +   }
   
      /**
       * creates a rollback() MethodCall and feeds it to handleCommitRollback();
  @@ -771,12 +772,12 @@
         // running a 2-phase commit.
         if (configuration.isNodeLockingOptimistic())
         {
  -         prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, gtx, modifications, null, (Address) cache.getLocalAddress(), false);
  +         prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, gtx, modifications, null, cache.getLocalAddress(), false);
         }
         else if (configuration.getCacheMode() != Configuration.CacheMode.REPL_ASYNC)
         {
            prepareMethod = MethodCallFactory.create(MethodDeclarations.prepareMethod,
  -                 gtx, modifications, (Address) cache.getLocalAddress(),
  +                 gtx, modifications, cache.getLocalAddress(),
                    false);// don't commit or rollback - wait for call
         }
         //}
  
  
  



More information about the jboss-cvs-commits mailing list