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

Manik Surtani msurtani at jboss.com
Thu Dec 14 07:51:48 EST 2006


  User: msurtani
  Date: 06/12/14 07:51:48

  Modified:    src/org/jboss/cache    Tag: Branch_JBossCache_1_4_0
                        TreeCache.java DataNode.java Node.java
  Log:
  Updated the way nodes are marked for removal (API stuff)
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.195.2.36 +8 -49     JBossCache/src/org/jboss/cache/TreeCache.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: TreeCache.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/TreeCache.java,v
  retrieving revision 1.195.2.35
  retrieving revision 1.195.2.36
  diff -u -b -r1.195.2.35 -r1.195.2.36
  --- TreeCache.java	14 Dec 2006 12:21:39 -0000	1.195.2.35
  +++ TreeCache.java	14 Dec 2006 12:51:47 -0000	1.195.2.36
  @@ -99,7 +99,7 @@
    * @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
    * @author Brian Stansberry
    * @author Daniel Huang (dhuang at jboss.org)
  - * @version $Id: TreeCache.java,v 1.195.2.35 2006/12/14 12:21:39 msurtani Exp $
  + * @version $Id: TreeCache.java,v 1.195.2.36 2006/12/14 12:51:47 msurtani Exp $
    *          <p/>
    * @see <a href="http://labs.jboss.com/portal/jbosscache/docs">JBossCache doc</a>
    */
  @@ -109,7 +109,6 @@
      private static final String[] MUX_TYPES = {"java.lang.String", "java.lang.String"};
      private static final String JBOSS_SERVER_DOMAIN = "jboss";
   
  -   private static final String REMOVAL_MARKER = "__JBOSS_MARKED_FOR_REMOVAL";
      private boolean forceAnycast = false;
      /**
       * Default replication version, from {@link Version#getVersionShort}.
  @@ -3635,7 +3634,7 @@
            n = n.getChild(obj);
            if (n == null)
               return null;
  -         else if (!includeNodesMarkedAsRemoved && isMarkedForRemoval(n))
  +         else if (!includeNodesMarkedAsRemoved && ((DataNode) n).isMarkedForRemoval())
               return null;
         }
         return (Node) n;
  @@ -4155,46 +4154,6 @@
         return count;
      }
   
  -   private void markForRemoval(Node n)
  -   {
  -      n.put(REMOVAL_MARKER, null);
  -      // mark children as well.
  -      Map children = n.getChildren(true);
  -      if (children != null && !children.isEmpty())
  -      {
  -         // traverse children
  -         Iterator i = children.values().iterator();
  -         while (i.hasNext())
  -         {
  -            markForRemoval((Node) i.next());
  -         }
  -      }
  -   }
  -
  -   public void scrubRemoveMarker(Node n, boolean deep)
  -   {
  -      n.remove(REMOVAL_MARKER);
  -      // unmark children as well.
  -      if (deep)
  -      {
  -         Map children = n.getChildren(true);
  -         if (children != null && !children.isEmpty())
  -         {
  -            // traverse children
  -            Iterator i = children.values().iterator();
  -            while (i.hasNext())
  -            {
  -               scrubRemoveMarker((Node) i.next(), true);
  -            }
  -         }
  -      }
  -   }
  -
  -   public boolean isMarkedForRemoval(TreeNode n)
  -   {
  -      return n.containsKey(REMOVAL_MARKER);
  -   }
  -
      /**
       * Internal method; not to be used externally.
       *
  @@ -4207,12 +4166,12 @@
            return;
   
         if (log.isDebugEnabled()) log.debug("Performing a real remove for node " + f + ", marked for removal.");
  -      if (skipMarkerCheck || isMarkedForRemoval(n))
  +      if (skipMarkerCheck || n.isMarkedForRemoval())
         {
            if (n.getFqn().isRoot())
            {
               // do not actually delete; just remove deletion marker
  -            scrubRemoveMarker(n, false);
  +            n.unmarkForRemoval(false);
               // but now remove all children, since the call has been to remove("/")
               n.removeAllChildren();
            }
  @@ -4554,7 +4513,7 @@
         }
         notifyNodeModify(fqn, true);
   
  -      scrubRemoveMarker(n, false);
  +      n.unmarkForRemoval(false);
   
         // TODO: move creation of undo-operations to separate Interceptor
         // create a compensating method call (reverting the effect of
  @@ -4630,7 +4589,7 @@
         notifyNodeModify(fqn, true);
         old_value = n.put(key, value);
   
  -      scrubRemoveMarker(n, false);
  +      n.unmarkForRemoval(false);
   
         // create a compensating method call (reverting the effect of
         // this modification) and put it into the TX's undo list.
  @@ -4788,7 +4747,7 @@
         if (isNodeLockingOptimistic() || eviction)
            parent_node.removeChild(n.getName());
         else
  -         markForRemoval(n);
  +         n.markForRemoval();
   
         if (eviction)
            parent_node.setChildrenLoaded(false);
  @@ -5065,7 +5024,7 @@
         }
         tmp.addChild(child_name, old_node);
         // make sure any deleted markers are removed from this child.
  -      scrubRemoveMarker((Node) old_node, true);
  +      old_node.unmarkForRemoval(true);
         notifyNodeCreated(new Fqn(parent_fqn, child_name));
      }
   
  
  
  
  1.15.2.1  +7 -0      JBossCache/src/org/jboss/cache/DataNode.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: DataNode.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/DataNode.java,v
  retrieving revision 1.15
  retrieving revision 1.15.2.1
  diff -u -b -r1.15 -r1.15.2.1
  --- DataNode.java	25 Apr 2006 15:18:28 -0000	1.15
  +++ DataNode.java	14 Dec 2006 12:51:48 -0000	1.15.2.1
  @@ -27,6 +27,8 @@
      /** Lock type of write. */
      int LOCK_TYPE_WRITE = 2;
   
  +   public static final String REMOVAL_MARKER = "__JBOSS_MARKED_FOR_REMOVAL";
  +
      /** Initialized property for debugging "print_lock_details" */
      boolean PRINT_LOCK_DETAILS = Boolean.getBoolean("print_lock_details");
   
  @@ -44,4 +46,9 @@
       */
      Object clone() throws CloneNotSupportedException;
   
  +   boolean isMarkedForRemoval();
  +
  +   void unmarkForRemoval(boolean deep);
  +
  +   void markForRemoval();
   }
  
  
  
  1.38.2.4  +40 -1     JBossCache/src/org/jboss/cache/Node.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Node.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/Node.java,v
  retrieving revision 1.38.2.3
  retrieving revision 1.38.2.4
  diff -u -b -r1.38.2.3 -r1.38.2.4
  --- Node.java	13 Dec 2006 16:01:47 -0000	1.38.2.3
  +++ Node.java	14 Dec 2006 12:51:48 -0000	1.38.2.4
  @@ -181,7 +181,7 @@
         while (c.hasNext())
         {
            Node ch = (Node) c.next();
  -         if (!cache.isMarkedForRemoval(ch))
  +         if (!ch.isMarkedForRemoval())
            {
               toReturn.put(ch.getName(), ch);
            }
  @@ -650,5 +650,44 @@
         // whenever a cache is assigned via setTreeCacheInstance
      }
   
  +   public void markForRemoval()
  +   {
  +      put(REMOVAL_MARKER, null);
  +      // mark children as well.
  +      Map children = getChildren(true);
  +      if (children != null && !children.isEmpty())
  +      {
  +         // traverse children
  +         Iterator i = children.values().iterator();
  +         while (i.hasNext())
  +         {
  +            ((Node) i.next()).markForRemoval();
  +         }
  +      }
  +   }
  +
  +   public void unmarkForRemoval(boolean deep)
  +   {
  +      remove(REMOVAL_MARKER);
  +      // unmark children as well.
  +      if (deep)
  +      {
  +         Map children = getChildren(true);
  +         if (children != null && !children.isEmpty())
  +         {
  +            // traverse children
  +            Iterator i = children.values().iterator();
  +            while (i.hasNext())
  +            {
  +               ((Node) i.next()).unmarkForRemoval(true);
  +            }
  +         }
  +      }
  +   }
  +
  +   public boolean isMarkedForRemoval()
  +   {
  +      return containsKey(REMOVAL_MARKER);
  +   }
   }
   
  
  
  



More information about the jboss-cvs-commits mailing list