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

Elias Ross genman at noderunner.net
Mon Nov 20 18:32:49 EST 2006


  User: genman  
  Date: 06/11/20 18:32:49

  Modified:    src/org/jboss/cache   NodeImpl.java TreeCache.java
  Log:
  JBCACHE-867 - add undo method calls for remove, add more debugging
  
  Revision  Changes    Path
  1.18      +42 -7     JBossCache/src/org/jboss/cache/NodeImpl.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: NodeImpl.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/NodeImpl.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -b -r1.17 -r1.18
  --- NodeImpl.java	20 Nov 2006 18:04:08 -0000	1.17
  +++ NodeImpl.java	20 Nov 2006 23:32:49 -0000	1.18
  @@ -17,6 +17,7 @@
   import org.jboss.cache.marshall.MethodCall;
   import org.jboss.cache.marshall.MethodCallFactory;
   import org.jboss.cache.marshall.MethodDeclarations;
  +import org.jboss.cache.util.MapCopy;
   
   import java.io.ObjectStreamException;
   import java.io.Serializable;
  @@ -386,9 +387,25 @@
         return n;
      }
   
  -   public synchronized Object remove(Object key)
  +   public Object remove(Object key)
      {
  -      return data != null ? data.remove(key) : null;
  +      if (cache.getInvocationContext().getOptionOverrides().isBypassInterceptorChain())
  +      {
  +         Object result;
  +         synchronized (this)
  +         {
  +			if (data == null)
  +			   result = null;
  +			else
  +			   result = data.remove(key);
  +         }
  +         cache.getInvocationContext().getOptionOverrides().setBypassInterceptorChain(false);
  +         return result;
  +      }
  +      else
  +      {
  +         return cache.remove(getFqn(), key);
  +      }
      }
   
      public void printDetails(StringBuffer sb, int indent)
  @@ -407,7 +424,7 @@
      public String toString()
      {
         StringBuffer sb = new StringBuffer();
  -      sb.append("Node ").append(fqn);
  +      sb.append("Node[ ").append(fqn);
         synchronized (this)
         {
            if (data != null)
  @@ -426,6 +443,7 @@
            if (isWriteLocked())
               sb.append(" WL");
         }
  +      sb.append("]");
         return sb.toString();
      }
   
  @@ -488,13 +506,21 @@
         }
      }
   
  -   public synchronized void clearData()
  +   public void clearData()
      {
  -      if (data != null)
  +      if (cache.getInvocationContext().getOptionOverrides().isBypassInterceptorChain())
  +      {
  +		 synchronized (this)
         {
  +			if (data != null)
            data.clear();
         }
      }
  +      else
  +      {
  +		 ((TreeCacheProxyImpl) cache).treeCache.removeData(getFqn());
  +      }
  +   }
   
      public Node getChild(Fqn fqn)
      {
  @@ -606,7 +632,7 @@
      public void print(StringBuffer sb, int indent)
      {
         printIndent(sb, indent);
  -      sb.append(Fqn.SEPARATOR).append(getName());
  +      sb.append(Fqn.SEPARATOR).append(getName()).append(" ").append(getData().size());
         if (children != null && children.size() > 0)
         {
            Collection values = children.values();
  @@ -728,6 +754,15 @@
         return this;
      }
   
  +   /**
  +    * Might be useful to expose; a debug feature for now.
  +    */
  +   void setReadOnly()
  +   {
  +       this.data = new MapCopy(data());
  +       this.children = new MapCopy(children());
  +   }
  +
      private class ChildrenNames extends AbstractSet implements Serializable
      {
   
  
  
  
  1.284     +18 -13    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.283
  retrieving revision 1.284
  diff -u -b -r1.283 -r1.284
  --- TreeCache.java	20 Nov 2006 12:04:43 -0000	1.283
  +++ TreeCache.java	20 Nov 2006 23:32:49 -0000	1.284
  @@ -96,7 +96,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.283 2006/11/20 12:04:43 genman Exp $
  + * @version $Id: TreeCache.java,v 1.284 2006/11/20 23:32:49 genman Exp $
    *          <p/>
    * @see <a href="http://labs.jboss.com/portal/jbosscache/docs">JBossCache doc</a>
    */
  @@ -2232,7 +2232,7 @@
      {
         if (log.isTraceEnabled())
         {
  -         log.trace(new StringBuffer("_put(").append(tx).append(", \"").append(fqn).append("\", ").append(data).append(")"));
  +         log.trace("_put(" + tx + ", \"" + fqn + "\", " + data + " undo=" + create_undo_ops + " erase=" + erase_contents + ")");
         }
   
         Node n = findNodeCheck(tx, fqn);
  @@ -2240,19 +2240,20 @@
         notifier.notifyNodeModified(fqn, true, rawData);
         
         getInvocationContext().getOptionOverrides().setBypassInterceptorChain(true);
  -      ((DataNode)n).put(data, (boolean)erase_contents);
   
         // create a compensating method call (reverting the effect of
         // this modification) and put it into the TX's undo list.
         if (tx != null && create_undo_ops)
         {
  -         // erase previous hashmap contents
  +         // erase and set to previous hashmap contents
            MethodCall undo_op = MethodCallFactory.create(MethodDeclarations.putDataEraseMethodLocal, tx, fqn,
                  new MapCopy(rawData),
                  false, true);
            tx_table.addUndoOperation(tx, undo_op);
         }
   
  +      ((DataNode)n).put(data, (boolean)erase_contents);
  +
         notifier.notifyNodeModified(fqn, false, rawData);
   
      }
  @@ -2375,7 +2376,7 @@
   
         if (log.isTraceEnabled())
         {
  -         log.trace(new StringBuffer("_remove(").append(tx).append(", \"").append(fqn).append("\")"));
  +         log.trace("_remove(" + tx + ", \"" + fqn + "\", undo=" + create_undo_ops + ")");
         }
   
         if (fqn.size() == 0)
  @@ -2483,7 +2484,7 @@
   
         if (log.isTraceEnabled())
         {
  -         log.trace(new StringBuffer("_remove(").append(tx).append(", \"").append(fqn).append("\", ").append(key).append(")"));
  +         log.trace("_remove(" + tx + ", \"" + fqn + "\", key=" + key + ")");
         }
   
         // Find the node. This will lock it (if <tt>locking</tt> is true) and
  @@ -2497,6 +2498,7 @@
   
         notifier.notifyNodeModified(fqn, true, n.getNodeSPI().getRawData());
   
  +      getInvocationContext().getOptionOverrides().setBypassInterceptorChain(true);
         old_value = n.remove(key);
   
         // create a compensating method call (reverting the effect of
  @@ -2557,11 +2559,10 @@
      {
         DataNode n = null;
         MethodCall undo_op = null;
  -      Map old_data = null;
   
         if (log.isTraceEnabled())
         {
  -         log.trace(new StringBuffer("_removeData(").append(tx).append(", \"").append(fqn).append("\")"));
  +         log.trace("_removeData(" + tx + ", \"" + fqn + "\")");
         }
   
         // Find the node. This will lock it (if <tt>locking</tt> is true) and
  @@ -2575,10 +2576,14 @@
   
         // create a compensating method call (reverting the effect of
         // this modification) and put it into the TX's undo list.
  -      if (tx != null && create_undo_ops && !n.getData().isEmpty() && !eviction)
  +      if (tx != null && create_undo_ops && !eviction)
  +      {
  +		 Map data = n.getData();
  +		 if (!data.isEmpty())
         {
            undo_op = MethodCallFactory.create(MethodDeclarations.putDataMethodLocal, 
  -               tx, fqn, new MapCopy(old_data), false);
  +			   tx, fqn, new MapCopy(data), false);
  +		 }
         }
   
         if (eviction)
  @@ -2590,6 +2595,7 @@
            notifier.notifyNodeModified(fqn, true, n.getNodeSPI().getRawData());
         }
   
  +      getInvocationContext().getOptionOverrides().setBypassInterceptorChain(true);
         n.clearData();
         if (eviction)
         {
  @@ -2698,8 +2704,7 @@
      {
         if (log.isTraceEnabled())
         {
  -         log.trace(new StringBuffer("_addChild(").append("\"").append(parent_fqn).
  -                 append("\", \"").append(child_name).append("\")"));
  +         log.trace("_addChild(\"" + parent_fqn +"\", \"" + child_name + "\", node=" + childNode + ")");
         }
   
         if (parent_fqn == null || child_name == null || childNode == null)
  
  
  



More information about the jboss-cvs-commits mailing list