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

Manik Surtani msurtani at jboss.com
Thu Jan 25 09:12:07 EST 2007


  User: msurtani
  Date: 07/01/25 09:12:07

  Modified:    src/org/jboss/cache       NodeSPI.java Node.java
                        CacheImpl.java Cache.java DefaultCacheFactory.java
                        UnversionedNode.java
  Log:
  JBCACHE-948
  
  Revision  Changes    Path
  1.14      +4 -2      JBossCache/src/org/jboss/cache/NodeSPI.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: NodeSPI.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/NodeSPI.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -b -r1.13 -r1.14
  --- NodeSPI.java	19 Jan 2007 14:47:40 -0000	1.13
  +++ NodeSPI.java	25 Jan 2007 14:12:07 -0000	1.14
  @@ -259,12 +259,13 @@
       * <p/>
       * The caller needs to ensure a proper lock has been obtained prior to calling this method, otherwise a
       *
  +    * @return true if the node was found, false otherwise
       * @param fqn of child.
       * @throws org.jboss.cache.lock.LockingException
       *          if locking was not obtained
       * @see #removeChild(Fqn)
       */
  -   void removeChildDirect(Fqn fqn);
  +   boolean removeChildDirect(Fqn fqn);
   
      /**
       * Removes a child directly from a node.
  @@ -273,12 +274,13 @@
       * <p/>
       * The caller needs to ensure a proper lock has been obtained prior to calling this method.
       *
  +    * @return true if the node was found, false otherwise
       * @param childName of child.
       * @throws org.jboss.cache.lock.LockingException
       *          if locking was not obtained
       * @see #removeChild(Object)
       */
  -   void removeChildDirect(Object childName);
  +   boolean removeChildDirect(Object childName);
   
   
      /**
  
  
  
  1.60      +6 -4      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.59
  retrieving revision 1.60
  diff -u -b -r1.59 -r1.60
  --- Node.java	19 Jan 2007 14:47:40 -0000	1.59
  +++ Node.java	25 Jan 2007 14:12:07 -0000	1.60
  @@ -94,16 +94,18 @@
       * <p/>
       * If you wish to remove children based on absolute {@link Fqn}s, use the {@link Cache} interface instead.
       *
  +    * @return true if the node was found and removed, false otherwise
       * @param f {@link Fqn} of the child node, relative to the current node.
       */
  -   void removeChild(Fqn f);
  +   boolean removeChild(Fqn f);
   
      /**
       * Removes a child node specified by the given name.
       *
  +    * @return true if the node was found and removed, false otherwise
       * @param childName name of the child node, directly under the current node.
       */
  -   void removeChild(Object childName);
  +   boolean removeChild(Object childName);
   
   
      /**
  @@ -136,7 +138,7 @@
       * Equivalent to calling
       * <pre>
       *   if (!node.getKeys().contains(key))
  -    *     return node.putAll(key, value);
  +    *     return node.put(key, value);
       *   else
       *     return node.get(key);
       * </pre>
  @@ -155,7 +157,7 @@
       * <pre>
       * if ((node.getKeys().contains(key))
       * {
  -    *     return node.putAll(key, value);
  +    *     return node.put(key, value);
       * }
       * else
       *     return null;
  
  
  
  1.37      +31 -24    JBossCache/src/org/jboss/cache/CacheImpl.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CacheImpl.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/CacheImpl.java,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -b -r1.36 -r1.37
  --- CacheImpl.java	24 Jan 2007 15:29:28 -0000	1.36
  +++ CacheImpl.java	25 Jan 2007 14:12:07 -0000	1.37
  @@ -1483,11 +1483,11 @@
       *
       * @param fqn The fully qualified name of the node.
       */
  -   public void remove(Fqn fqn) throws CacheException
  +   public boolean remove(Fqn fqn) throws CacheException
      {
         GlobalTransaction tx = getCurrentTransaction();
         MethodCall m = MethodCallFactory.create(MethodDeclarations.removeNodeMethodLocal, tx, fqn, true);
  -      invokeMethod(m);
  +      return (Boolean)invokeMethod(m);
      }
   
      /**
  @@ -2006,9 +2006,9 @@
         return _put(tx, fqn, key, value, create_undo_ops);
      }
   
  -   public void _remove(GlobalTransaction tx, Fqn fqn, boolean create_undo_ops, DataVersion dv) throws CacheException
  +   public boolean _remove(GlobalTransaction tx, Fqn fqn, boolean create_undo_ops, DataVersion dv) throws CacheException
      {
  -      _remove(tx, fqn, create_undo_ops, true);
  +      return _remove(tx, fqn, create_undo_ops, true);
      }
   
      public Object _remove(GlobalTransaction tx, Fqn fqn, Object key, boolean create_undo_ops, DataVersion dv) throws CacheException
  @@ -2182,15 +2182,15 @@
      /**
       * Internal remove method.
       */
  -   public void _remove(GlobalTransaction tx, Fqn fqn, boolean create_undo_ops) throws CacheException
  +   public boolean _remove(GlobalTransaction tx, Fqn fqn, boolean create_undo_ops) throws CacheException
      {
  -      _remove(tx, fqn, create_undo_ops, true);
  +      return _remove(tx, fqn, create_undo_ops, true);
      }
   
  -   public void _remove(GlobalTransaction tx, Fqn fqn, boolean create_undo_ops, boolean sendNodeEvent)
  +   public boolean _remove(GlobalTransaction tx, Fqn fqn, boolean create_undo_ops, boolean sendNodeEvent)
              throws CacheException
      {
  -      _remove(tx, fqn, create_undo_ops, sendNodeEvent, false);
  +      return _remove(tx, fqn, create_undo_ops, sendNodeEvent, false);
      }
   
      /**
  @@ -2201,10 +2201,10 @@
       * @param create_undo_ops
       * @param sendNodeEvent
       */
  -   public void _remove(GlobalTransaction tx, Fqn fqn, boolean create_undo_ops, boolean sendNodeEvent, boolean eviction)
  +   public boolean _remove(GlobalTransaction tx, Fqn fqn, boolean create_undo_ops, boolean sendNodeEvent, boolean eviction)
              throws CacheException
      {
  -      _remove(tx, fqn, create_undo_ops, sendNodeEvent, eviction, null);
  +      return _remove(tx, fqn, create_undo_ops, sendNodeEvent, eviction, null);
      }
   
      /**
  @@ -2218,9 +2218,10 @@
       * @param sendNodeEvent
       * @param eviction
       * @param version
  +    * @return true if the node was removed, false if not found
       * @throws CacheException
       */
  -   public void _remove(GlobalTransaction tx, Fqn fqn, boolean create_undo_ops, boolean sendNodeEvent, boolean eviction, DataVersion version)
  +   public boolean _remove(GlobalTransaction tx, Fqn fqn, boolean create_undo_ops, boolean sendNodeEvent, boolean eviction, DataVersion version)
              throws CacheException
      {
   
  @@ -2242,8 +2243,7 @@
               if (status == Status.STATUS_MARKED_ROLLBACK || status == Status.STATUS_ROLLEDBACK || status == Status.STATUS_ROLLING_BACK)
               {
                  log.debug("This remove call is triggered by a transaction rollback, as a compensation operation.  Do a realRemove() instead.");
  -               realRemove(fqn, true);
  -               return;
  +               return realRemove(fqn, true);
               }
            }
            catch (Exception e)
  @@ -2266,15 +2266,15 @@
                  Fqn tmp = new Fqn(fqn, s);
                  try
                  {
  -                  _remove(tx, tmp, create_undo_ops, true, eviction);
  +                  return _remove(tx, tmp, create_undo_ops, true, eviction);
                  }
                  catch (Exception e)
                  {
                     log.error("failure removing node " + tmp);
  +                  return false;
                  }
               }
            }
  -         return;
         }
   
         // Find the node. This will add the temporarily created parent nodes to the TX's node list if tx != null)
  @@ -2285,7 +2285,7 @@
            {
               log.trace("node " + fqn + " not found");
            }
  -         return;
  +         return false;
         }
   
         if (eviction)
  @@ -2298,14 +2298,16 @@
         }
   
         parent_node = n.getParent();
  +      boolean found;
   
         // remove subtree from parent
         if (eviction || configuration.isNodeLockingOptimistic())
         {
  -         parent_node.removeChildDirect(n.getFqn().getLastElement());
  +         found = parent_node.removeChildDirect(n.getFqn().getLastElement());
         }
         else
         {
  +         found = (n.isDeleted() == false);
            n.markAsDeleted(true);
         }
   
  @@ -2335,6 +2337,8 @@
         {
            notifier.notifyNodeRemoved(fqn, false, null, true);
         }
  +      
  +      return found;
      }
   
      /**
  @@ -3697,15 +3701,16 @@
   
      /**
       * Internal method; not to be used externally.
  +    * Returns true if the node was found, false if not.
       *
       * @param f
       */
  -   public void realRemove(Fqn f, boolean skipMarkerCheck)
  +   public boolean realRemove(Fqn f, boolean skipMarkerCheck)
      {
         NodeSPI n = peek(f, true);
         if (n == null)
         {
  -         return;
  +         return false;
         }
   
         if (log.isDebugEnabled()) log.debug("Performing a real remove for node " + f + ", marked for removal.");
  @@ -3717,15 +3722,17 @@
               n.markAsDeleted(false);
               // but now remove all children, since the call has been to remove("/")
               n.removeChildrenDirect();
  +            return true;
            }
            else
            {
  -            n.getParent().removeChildDirect(n.getFqn().getLastElement());
  +            return n.getParent().removeChildDirect(n.getFqn().getLastElement());
            }
         }
         else
         {
            if (log.isDebugEnabled()) log.debug("Node " + f + " NOT marked for removal as expected, not removing!");
  +         return false;
         }
      }
   
  @@ -3775,7 +3782,7 @@
               {
                  if (configuration.getMarshallerClass() == null || configuration.getMarshallerClass().equals(VersionAwareMarshaller.class.getName()))
                  {
  -                  marshaller_ = new VersionAwareMarshaller(getRegionManager(), configuration.isInactiveOnStartup(), configuration.isUseRegionBasedMarshalling(), configuration.getReplVersionString());
  +                  marshaller_ = new VersionAwareMarshaller(getRegionManager(), configuration);
                  }
                  else
                  {
  @@ -3786,7 +3793,7 @@
                     catch (Exception e)
                     {
                        log.error("Unable to load marshaller " + configuration.getMarshallerClass() + ".  Falling back to default (" + VersionAwareMarshaller.class.getName() + ")");
  -                     marshaller_ = new VersionAwareMarshaller(getRegionManager(), configuration.isInactiveOnStartup(), configuration.isUseRegionBasedMarshalling(), configuration.getReplVersionString());
  +                     marshaller_ = new VersionAwareMarshaller(getRegionManager(), configuration);
                     }
                  }
                  if (log.isInfoEnabled()) log.info("Using marshaller " + marshaller_.getClass().getName());
  @@ -4018,9 +4025,9 @@
         return getRegionManager().removeRegion(fqn);
      }
   
  -   public void removeNode(Fqn fqn)
  +   public boolean removeNode(Fqn fqn)
      {
  -      remove(fqn);
  +      return remove(fqn);
      }
   
      public void putForExternalRead(Fqn fqn, Object key, Object value)
  
  
  
  1.24      +2 -1      JBossCache/src/org/jboss/cache/Cache.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Cache.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/Cache.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -b -r1.23 -r1.24
  --- Cache.java	24 Jan 2007 15:29:28 -0000	1.23
  +++ Cache.java	25 Jan 2007 14:12:07 -0000	1.24
  @@ -193,9 +193,10 @@
      /**
       * Removes a {@link Node} indicated by absolute {@link Fqn}.
       *
  +    * @return true if the node was removed, false if the node was not found
       * @param fqn {@link Node} to remove
       */
  -   void removeNode(Fqn fqn);
  +   boolean removeNode(Fqn fqn);
   
      /**
       * Convenience method that allows for direct access to the data in a {@link Node}.
  
  
  
  1.4       +1 -11     JBossCache/src/org/jboss/cache/DefaultCacheFactory.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: DefaultCacheFactory.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/DefaultCacheFactory.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -b -r1.3 -r1.4
  --- DefaultCacheFactory.java	19 Jan 2007 12:05:41 -0000	1.3
  +++ DefaultCacheFactory.java	25 Jan 2007 14:12:07 -0000	1.4
  @@ -20,7 +20,7 @@
    */
   public class DefaultCacheFactory implements CacheFactory
   {
  -   private static CacheFactory singleton = null;
  +   private static CacheFactory singleton = new DefaultCacheFactory();
      private Log log = LogFactory.getLog(DefaultCacheFactory.class);
   
      /**
  @@ -36,16 +36,6 @@
       */
      public static CacheFactory getInstance()
      {
  -      if (singleton == null)
  -      {
  -         synchronized (DefaultCacheFactory.class)
  -         {
  -            if (singleton == null)
  -            {
  -               singleton = new DefaultCacheFactory();
  -            }
  -         }
  -      }
         return singleton;
      }
   
  
  
  
  1.23      +17 -10    JBossCache/src/org/jboss/cache/UnversionedNode.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: UnversionedNode.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/UnversionedNode.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -b -r1.22 -r1.23
  --- UnversionedNode.java	19 Jan 2007 14:47:40 -0000	1.22
  +++ UnversionedNode.java	25 Jan 2007 14:12:07 -0000	1.23
  @@ -463,36 +463,43 @@
         }
      }
   
  -   public void removeChild(Fqn fqn)
  +   public boolean removeChild(Fqn fqn)
      {
  -      cache.removeNode(new Fqn(getFqn(), fqn));
  +      return cache.removeNode(new Fqn(getFqn(), fqn));
      }
   
      public int dataSize()
      {
  -      return getData().size();
  +      return cache.getKeys(getFqn()).size();
      }
   
  -   public void removeChild(Object childName)
  +   public boolean removeChild(Object childName)
      {
  -      removeChild(new Fqn(getFqn(), childName));
  +      return removeChild(new Fqn(getFqn(), childName));
      }
   
  -   public synchronized void removeChildDirect(Object childName)
  +   public boolean removeChildDirect(Object childName)
      {
  -      children().remove(childName);
  +      return children().remove(childName) != null;
      }
   
  -   public void removeChildDirect(Fqn f)
  +   public boolean removeChildDirect(Fqn f)
      {
         if (f.size() == 1)
         {
  -         removeChildDirect(f.getLastElement());
  +         return removeChildDirect(f.getLastElement());
         }
         else
         {
            NodeSPI child = getChildDirect(f);
  -         if (child != null) child.getParent().removeChildDirect(f.getLastElement());
  +         if (child != null) 
  +         {
  +            return child.getParent().removeChildDirect(f.getLastElement());
  +         }
  +         else
  +         {
  +            return false;
  +         }
         }
      }
   
  
  
  



More information about the jboss-cvs-commits mailing list