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

Manik Surtani msurtani at jboss.com
Tue Aug 22 07:38:54 EDT 2006


  User: msurtani
  Date: 06/08/22 07:38:54

  Modified:    src/org/jboss/cache/interceptors    
                        ActivationInterceptor.java
                        CacheLoaderInterceptor.java
                        PassivationInterceptor.java
                        PessimisticLockInterceptor.java
  Log:
  Fixed breakage in passivation code
  
  Revision  Changes    Path
  1.32      +15 -15    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.31
  retrieving revision 1.32
  diff -u -b -r1.31 -r1.32
  --- ActivationInterceptor.java	18 Aug 2006 15:40:39 -0000	1.31
  +++ ActivationInterceptor.java	22 Aug 2006 11:38:54 -0000	1.32
  @@ -1,13 +1,14 @@
   package org.jboss.cache.interceptors;
   
   import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap;
  -import org.jboss.cache.DataNode;
   import org.jboss.cache.Fqn;
   import org.jboss.cache.GlobalTransaction;
   import org.jboss.cache.Modification;
  +import org.jboss.cache.Node;
   import org.jboss.cache.TransactionEntry;
   import org.jboss.cache.TransactionTable;
   import org.jboss.cache.TreeCache;
  +import org.jboss.cache.TreeCacheProxyImpl;
   import org.jboss.cache.marshall.JBCMethodCall;
   import org.jboss.cache.marshall.MethodDeclarations;
   import org.jgroups.blocks.MethodCall;
  @@ -27,7 +28,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.31 2006/08/18 15:40:39 msurtani Exp $
  + * @version $Id: ActivationInterceptor.java,v 1.32 2006/08/22 11:38:54 msurtani Exp $
    */
   public class ActivationInterceptor extends CacheLoaderInterceptor implements ActivationInterceptorMBean {
      
  @@ -143,10 +144,10 @@
               // 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.
  -            DataNode n = getNode(fqn); // don't load
  +            Node n = getNode(fqn); // don't load
               // node not null and attributes have been loaded?
  -            if (n != null && !n.containsKey(TreeCache.UNINITIALIZED)) {
  -               if (n.hasChildren()) {
  +            if (n != null && !n.getKeys().contains(TreeCache.UNINITIALIZED)) {
  +               if (!n.getChildren().isEmpty()) {
                     if (allInitialized(n)) {
                        log.debug("children all initialized");
                        remove(fqn);
  @@ -171,13 +172,12 @@
      /**
       * Returns true if a node has all children loaded and initialized.
       */ 
  -   private boolean allInitialized(DataNode n) {
  -      if (!n.getChildrenLoaded())
  -         return false;
  -      for (Iterator it=n.getChildren().values().iterator(); it.hasNext();) {
  -         DataNode child = (DataNode)it.next();
  -         if (child.containsKey(TreeCache.UNINITIALIZED))
  -            return false;
  +   private boolean allInitialized(Node n) {
  +      if (!((TreeCacheProxyImpl)n).getChildrenLoaded()) return false;
  +
  +      for (Node child : n.getChildren())
  +      {
  +         if (child.getKeys().contains(TreeCache.UNINITIALIZED)) return false;
         }
         return true;
      }
  @@ -260,11 +260,11 @@
                  // Then notify the listeners that the node has been activated.
                   Fqn fqn = (Fqn)args[1];
                   if(fqn != null && cache.hasChild(fqn)  && loader.exists(fqn)) {
  -                   DataNode n=getNode(fqn); // don't load
  +                   Node n=getNode(fqn); // don't load
                      // node not null and attributes have been loaded?
  -                   if (n != null && !n.containsKey(TreeCache.UNINITIALIZED)) {
  +                   if (n != null && !n.getKeys().contains(TreeCache.UNINITIALIZED)) {
                         // has children?
  -                      if(n.hasChildren() && allInitialized(n)) {
  +                      if(!n.getChildren().isEmpty() && allInitialized(n)) {
                            // children have been loaded, remove the node
                            addRemoveMod(cache_loader_modifications, fqn);
                            txActs++;
  
  
  
  1.47      +5 -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.46
  retrieving revision 1.47
  diff -u -b -r1.46 -r1.47
  --- CacheLoaderInterceptor.java	21 Aug 2006 17:05:49 -0000	1.46
  +++ CacheLoaderInterceptor.java	22 Aug 2006 11:38:54 -0000	1.47
  @@ -23,7 +23,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.46 2006/08/21 17:05:49 msurtani Exp $
  + * @version $Id: CacheLoaderInterceptor.java,v 1.47 2006/08/22 11:38:54 msurtani Exp $
    */
   public class CacheLoaderInterceptor extends BaseCacheLoaderInterceptor implements CacheLoaderInterceptorMBean
   {
  @@ -284,7 +284,7 @@
        * Retrieves a node from memory; doesn't access the cache loader
        * @param fqn
        */
  -   protected DataNode getNode(Fqn fqn) {
  +   protected Node getNode(Fqn fqn) {
         int treeNodeSize=fqn.size();
   
         // root node
  @@ -293,10 +293,11 @@
         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 (DataNode) n;
  +      return n;
      }
   
      /**
  @@ -338,6 +339,7 @@
         }
         else if (n != null && n.getKeys().contains(TreeCache.UNINITIALIZED))
         {
  +         cache.getInvocationContext().getOptionOverrides().setBypassInterceptorChain(true);
            n.remove(TreeCache.UNINITIALIZED);
         }
         return n;
  
  
  
  1.25      +3 -1      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.24
  retrieving revision 1.25
  diff -u -b -r1.24 -r1.25
  --- PassivationInterceptor.java	17 Aug 2006 17:34:59 -0000	1.24
  +++ PassivationInterceptor.java	22 Aug 2006 11:38:54 -0000	1.25
  @@ -18,7 +18,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.24 2006/08/17 17:34:59 msurtani Exp $
  + * @version $Id: PassivationInterceptor.java,v 1.25 2006/08/22 11:38:54 msurtani Exp $
    */
   public class PassivationInterceptor extends Interceptor implements PassivationInterceptorMBean {
      
  @@ -27,6 +27,7 @@
   
      public void setCache(CacheSPI cache)
      {
  +      super.setCache(cache);
         this.loader = cache.getCacheLoader();
      }
   
  @@ -93,6 +94,7 @@
         Node n = cache;
         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)));
         }
         if (n != null)
  
  
  
  1.26      +4 -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.25
  retrieving revision 1.26
  diff -u -b -r1.25 -r1.26
  --- PessimisticLockInterceptor.java	18 Aug 2006 15:40:39 -0000	1.25
  +++ PessimisticLockInterceptor.java	22 Aug 2006 11:38:54 -0000	1.26
  @@ -15,7 +15,6 @@
   import org.jboss.cache.TransactionEntry;
   import org.jboss.cache.TransactionTable;
   import org.jboss.cache.TreeCacheProxyImpl;
  -import org.jboss.cache.config.Option;
   import org.jboss.cache.lock.IdentityLock;
   import org.jboss.cache.lock.IsolationLevel;
   import org.jboss.cache.lock.LockingException;
  @@ -38,7 +37,7 @@
    * current method and unlock when the method returns.
    *
    * @author Bela Ban
  - * @version $Id: PessimisticLockInterceptor.java,v 1.25 2006/08/18 15:40:39 msurtani Exp $
  + * @version $Id: PessimisticLockInterceptor.java,v 1.26 2006/08/22 11:38:54 msurtani Exp $
    */
   public class PessimisticLockInterceptor extends Interceptor {
      TransactionTable tx_table=null;
  @@ -213,14 +212,11 @@
         for(int i=0; i < treeNodeSize; i++) {
            child_name=fqn.get(i);
   
  -         Option o = cache.getInvocationContext().getOptionOverrides();
  -         o.setBypassInterceptorChain(true);
  -
  +         cache.getInvocationContext().getOptionOverrides().setBypassInterceptorChain(true);
            child_node = n.getChild(new Fqn(child_name));
            if (child_node == null && createIfNotExists)
            {
  -             o = cache.getInvocationContext().getOptionOverrides();
  -             o.setBypassInterceptorChain(true);
  +             cache.getInvocationContext().getOptionOverrides().setBypassInterceptorChain(true);
                child_node= n.addChild(new Fqn(child_name));
            }
   
  @@ -298,6 +294,7 @@
           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)); //, gtx, true);
               if(child_node == null)
               {
  
  
  



More information about the jboss-cvs-commits mailing list