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

Manik Surtani msurtani at jboss.com
Thu Nov 16 10:40:19 EST 2006


  User: msurtani
  Date: 06/11/16 10:40:19

  Modified:    src/org/jboss/cache   TreeCache.java RegionManager.java
  Log:
  Fixed CVS merge screwup
  
  Revision  Changes    Path
  1.274     +41 -301   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.273
  retrieving revision 1.274
  diff -u -b -r1.273 -r1.274
  --- TreeCache.java	16 Nov 2006 07:46:17 -0000	1.273
  +++ TreeCache.java	16 Nov 2006 15:40:19 -0000	1.274
  @@ -39,8 +39,8 @@
   import org.jboss.cache.notifications.Notifier;
   import org.jboss.cache.optimistic.DataVersion;
   import org.jboss.cache.statetransfer.StateTransferManager;
  -import org.jboss.util.stream.MarshalledValueOutputStream;
   import org.jboss.util.stream.MarshalledValueInputStream;
  +import org.jboss.util.stream.MarshalledValueOutputStream;
   import org.jgroups.Address;
   import org.jgroups.Channel;
   import org.jgroups.ChannelClosedException;
  @@ -72,6 +72,7 @@
   import java.io.OutputStream;
   import java.lang.reflect.Method;
   import java.util.ArrayList;
  +import java.util.Arrays;
   import java.util.Collection;
   import java.util.Collections;
   import java.util.HashMap;
  @@ -82,7 +83,6 @@
   import java.util.Map;
   import java.util.Set;
   import java.util.Vector;
  -import java.util.Arrays;
   
   /**
    * A tree-like structure that is replicated across several members. Updates are
  @@ -94,7 +94,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.273 2006/11/16 07:46:17 bstansberry Exp $
  + * @version $Id: TreeCache.java,v 1.274 2006/11/16 15:40:19 msurtani Exp $
    *          <p/>
    * @see <a href="http://labs.jboss.com/portal/jbosscache/docs">JBossCache doc</a>
    */
  @@ -111,7 +111,7 @@
       */
      protected DataNode root = NodeFactory.getInstance().createRootDataNode(NodeFactory.NODE_TYPE_TREENODE, this);
   
  -   private RegionManager regionManager = new RegionManager(this);
  +   private RegionManager regionManager = null;
   
   
      final static Object NULL = new Object();
  @@ -258,12 +258,6 @@
   
      private ThreadLocal<InvocationContext> invocationContextContainer = new ThreadLocal<InvocationContext>();
   
  -   /**
  -    * Set of Fqns of nodes that are currently being processed by
  -    * activateReqion or inactivateRegion.  Requests for these fqns
  -    * will be ignored by _getState().
  -    */
  -   protected final Set activationChangeNodes = Collections.synchronizedSet(new HashSet());
      public boolean started;
   
      public Configuration getConfiguration()
  @@ -292,6 +286,7 @@
      {
         notifier = new Notifier(this);
         this.configuration = configuration;
  +      regionManager = new RegionManager(this);
      }
   
      /**
  @@ -300,6 +295,7 @@
      public TreeCache() throws Exception
      {
         notifier = new Notifier(this);
  +      regionManager = new RegionManager(this);
      }
   
      /**
  @@ -309,6 +305,7 @@
      {
         notifier = new Notifier(this);
         this.channel = channel;
  +      regionManager = new RegionManager(this);
      }
   
      /**
  @@ -1011,130 +1008,6 @@
      }
   
      /**
  -    * Causes the cache to transfer state for the subtree rooted at
  -    * <code>subtreeFqn</code> and to begin accepting replication messages
  -    * for that subtree.
  -    * <p/>
  -    * <strong>NOTE:</strong> This method will cause the creation of a node
  -    * in the local tree at <code>subtreeFqn</code> whether or not that
  -    * node exists anywhere else in the cluster.  If the node does not exist
  -    * elsewhere, the local node will be empty.  The creation of this node will
  -    * not be replicated.
  -    *
  -    * @param subtreeFqn Fqn string indicating the uppermost node in the
  -    *                   portion of the tree that should be activated.
  -    * @throws RegionNotEmptyException if the node <code>subtreeFqn</code>
  -    *                                 exists and has either data or children
  -    */
  -   public void activateRegion(String subtreeFqn) throws RegionNameConflictException, CacheException
  -   {
  -      Fqn fqn = Fqn.fromString(subtreeFqn);
  -
  -      // Check whether the node already exists and has data
  -      DataNode subtreeRoot = findNode(fqn);
  -      if (!(isNodeEmpty(subtreeRoot)))
  -      {
  -         throw new RegionNotEmptyException("Node " + subtreeRoot.getFqn() + " already exists and is not empty");
  -      }
  -
  -      if (log.isDebugEnabled())
  -      {
  -         log.debug("activating " + fqn);
  -      }
  -
  -      try
  -      {
  -
  -         // Add this fqn to the set of those we are activating
  -         // so calls to _getState for the fqn can return quickly
  -         activationChangeNodes.add(fqn);
  -
  -         Region region = regionManager.getRegion(fqn, true);
  -
  -         // If a classloader is registered for the node's region, use it
  -         ClassLoader cl = region.getClassLoader();
  -
  -         // Request partial state from the cluster and integrate it
  -         if (buddyManager == null)
  -         {
  -            // Get the state from any node that has it and put it
  -            // in the main tree
  -            if (subtreeRoot == null)
  -            {
  -               // We'll update this node with the state we receive
  -               subtreeRoot = createSubtreeRootNode(fqn);
  -            }
  -
  -            Object[] mbrArray = getMembers().toArray();
  -            getStateTransferManager().loadState(subtreeRoot.getFqn(), subtreeRoot, mbrArray, cl);
  -         }
  -         else
  -         {
  -            // Get the state from each DataOwner and integrate in their
  -            // respective buddy backup tree
  -            List buddies = buddyManager.getBuddyAddresses();
  -            for (Iterator it = buddies.iterator(); it.hasNext();)
  -            {
  -               Address buddy = (Address) it.next();
  -               Object[] sources = {buddy};
  -               Fqn base = new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, BuddyManager.getGroupNameFromAddress(buddy));
  -               Fqn buddyRoot = new Fqn(base, fqn);
  -               subtreeRoot = findNode(buddyRoot);
  -               if (subtreeRoot == null)
  -               {
  -                  // We'll update this node with the state we receive
  -                  subtreeRoot = createSubtreeRootNode(buddyRoot);
  -               }
  -               getStateTransferManager().loadState(fqn, subtreeRoot, sources, cl);
  -            }
  -         }
  -      }
  -      catch (Throwable t)
  -      {
  -         log.error("failed to activate " + subtreeFqn, t);
  -
  -         // "Re-deactivate" the region
  -         try
  -         {
  -            inactivateRegion(subtreeFqn);
  -         }
  -         catch (Exception e)
  -         {
  -            log.error("failed inactivating " + subtreeFqn, e);
  -            // just swallow this one and throw the first one
  -         }
  -
  -         // Throw the exception on, wrapping if necessary
  -         if (t instanceof RegionNameConflictException)
  -         {
  -            throw(RegionNameConflictException) t;
  -         }
  -         else if (t instanceof RegionNotEmptyException)
  -         {
  -            throw(RegionNotEmptyException) t;
  -         }
  -         else if (t instanceof CacheException)
  -         {
  -            throw(CacheException) t;
  -         }
  -         else
  -         {
  -            throw new CacheException(t.getClass().getName() + " " +
  -                    t.getLocalizedMessage(), t);
  -         }
  -      }
  -      finally
  -      {
  -         activationChangeNodes.remove(fqn);
  -      }
  -   }
  -
  -   public boolean isActivatingDeactivating(Fqn fqn)
  -   {
  -      return activationChangeNodes.contains(fqn);
  -   }
  -
  -   /**
       * Returns whether the given node is empty; i.e. has no key/value pairs
       * in its data map and has no children.
       *
  @@ -1142,7 +1015,7 @@
       * @return <code>true</code> if <code>node</code> is <code>null</code> or
       *         empty; <code>false</code> otherwise.
       */
  -   private boolean isNodeEmpty(DataNode node)
  +   protected boolean isNodeEmpty(DataNode node)
      {
         boolean empty = true;
         if (node != null)
  @@ -1223,138 +1096,6 @@
      }
   
      /**
  -    * Causes the cache to stop accepting replication events for the subtree
  -    * rooted at <code>subtreeFqn</code> and evict all nodes in that subtree.
  -    *
  -    * @param subtreeFqn Fqn string indicating the uppermost node in the
  -    *                   portion of the tree that should be activated.
  -    * @throws RegionNameConflictException if <code>subtreeFqn</code> indicates
  -    *                                     a node that is part of another
  -    *                                     subtree that is being specially
  -    *                                     managed (either by activate/inactiveRegion()
  -    *                                     or by registerClassLoader())
  -    * @throws CacheException              if there is a problem evicting nodes
  -    * @throws IllegalStateException       if {@link Configuration#isUseRegionBasedMarshalling()} is <code>false</code>
  -    */
  -   public void inactivateRegion(String subtreeFqn) throws RegionNameConflictException, CacheException
  -   {
  -      if (!configuration.isUseRegionBasedMarshalling())
  -      {
  -         throw new IllegalStateException("TreeCache.deactivate(). useRegionBasedMarshalling flag is not set!");
  -      }
  -
  -      Fqn fqn = Fqn.fromString(subtreeFqn);
  -      DataNode parent = null;
  -      DataNode subtreeRoot = null;
  -      boolean parentLocked = false;
  -      boolean subtreeLocked = false;
  -      try
  -      {
  -         // Record that this fqn is in status change, so can't provide state
  -         activationChangeNodes.add(fqn);
  -
  -         boolean inactive = marshaller_.isInactive(subtreeFqn);
  -         if (!inactive)
  -         {
  -            regionManager.deactivate(subtreeFqn);
  -         }
  -
  -         // Create a list with the Fqn in the main tree and any buddy backup trees
  -         ArrayList list = new ArrayList();
  -         list.add(fqn);
  -         if (buddyManager != null)
  -         {
  -            Set buddies = getChildrenNames(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN);
  -            if (buddies != null)
  -            {
  -               for (Iterator it = buddies.iterator(); it.hasNext();)
  -               {
  -                  Fqn base = new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, it.next());
  -                  list.add(new Fqn(base, fqn));
  -               }
  -            }
  -         }
  -
  -         // Remove the subtree from the main tree  and any buddy backup trees
  -         for (Iterator it = list.iterator(); it.hasNext();)
  -         {
  -            Fqn subtree = (Fqn) it.next();
  -            subtreeRoot = findNode(subtree);
  -            if (subtreeRoot != null)
  -            {
  -               // Acquire locks
  -               Object owner = getOwnerForLock();
  -               subtreeRoot.acquireAll(owner, stateFetchTimeout, DataNode.LockType.WRITE);
  -               subtreeLocked = true;
  -
  -               // Lock the parent, as we're about to write to it
  -               parent = (DataNode) subtreeRoot.getParent();
  -               if (parent != null)
  -               {
  -                  parent.acquire(owner, stateFetchTimeout, DataNode.LockType.WRITE);
  -                  parentLocked = true;
  -               }
  -
  -               // Remove the subtree
  -               _evictSubtree(subtree);
  -
  -               // Release locks
  -               if (parent != null)
  -               {
  -                  log.debug("forcing release of locks in parent");
  -                  parent.releaseAllForce();
  -               }
  -
  -               parentLocked = false;
  -
  -               log.debug("forcing release of all locks in subtree");
  -               subtreeRoot.releaseAllForce();
  -               subtreeLocked = false;
  -            }
  -         }
  -      }
  -      catch (InterruptedException ie)
  -      {
  -         throw new CacheException("Interrupted while acquiring lock", ie);
  -      }
  -      finally
  -      {
  -         // If we didn't succeed, undo the marshalling change
  -         // NO. Since we inactivated, we may have missed changes
  -         //if (!success && !inactive)
  -         //   marshaller_.activate(subtreeFqn);
  -
  -         // If necessary, release locks
  -         if (parentLocked)
  -         {
  -            log.debug("forcing release of locks in parent");
  -            try
  -            {
  -               parent.releaseAllForce();
  -            }
  -            catch (Throwable t)
  -            {
  -               log.error("failed releasing locks", t);
  -            }
  -         }
  -         if (subtreeLocked)
  -         {
  -            log.debug("forcing release of all locks in subtree");
  -            try
  -            {
  -               subtreeRoot.releaseAllForce();
  -            }
  -            catch (Throwable t)
  -            {
  -               log.error("failed releasing locks", t);
  -            }
  -         }
  -
  -         activationChangeNodes.remove(fqn);
  -      }
  -   }
  -
  -   /**
       * Evicts the node at <code>subtree</code> along with all descendant nodes.
       *
       * @param subtree Fqn indicating the uppermost node in the
  @@ -3622,19 +3363,14 @@
   
         public void setState(byte[] new_state)
         {
  -         try
  -         {
  -
            if (new_state == null)
            {
               my_log.debug("transferred state is null (may be first member in cluster)");
               return;
               }
  -            else
  +         try
               {
                  getStateTransferManager().setState(new_state, Fqn.ROOT, null);
  -            }
  -
               isStateSet = true;
            }
            catch (Throwable t)
  @@ -3722,16 +3458,14 @@
   
         public void setState(InputStream istream)
         {
  -         try
  -         {
  -
               if (istream == null)
               {
                  my_log.debug("stream is null (may be first member in cluster)");
                  return;
               }
  +         try
  +         {           
               getStateTransferManager().setState(istream, Fqn.ROOT, null);
  -
               isStateSet = true;
            }
            catch (Throwable t)
  @@ -3754,7 +3488,6 @@
                  stateLock.notifyAll();
               }
            }
  -
         }
   
         public void setState(String state_id, byte[] state)
  @@ -4165,6 +3898,13 @@
   
      public RegionManager getRegionManager()
      {
  +      if (regionManager == null)
  +      {
  +         synchronized (this)
  +         {
  +            if (regionManager == null) regionManager = new RegionManager(this);
  +         }
  +      }
         return regionManager;
      }
   
  
  
  
  1.11      +293 -5    JBossCache/src/org/jboss/cache/RegionManager.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: RegionManager.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/RegionManager.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -b -r1.10 -r1.11
  --- RegionManager.java	16 Nov 2006 07:48:00 -0000	1.10
  +++ RegionManager.java	16 Nov 2006 15:40:19 -0000	1.11
  @@ -8,11 +8,17 @@
   import org.jboss.cache.config.ConfigurationException;
   import org.jboss.cache.eviction.RegionNameConflictException;
   import org.jboss.cache.eviction.EvictionTimerTask;
  +import org.jboss.cache.marshall.VersionAwareMarshaller;
  +import org.jgroups.Address;
   
   import java.util.ArrayList;
   import java.util.Collections;
  +import java.util.HashSet;
  +import java.util.Iterator;
   import java.util.List;
   import java.util.Map;
  +import java.util.Set;
  +import java.util.Vector;
   import java.util.concurrent.ConcurrentHashMap;
   
   /**
  @@ -40,6 +46,8 @@
      private EvictionConfig evictionConfig;
      private EvictionTimerTask evictionTimerTask = new EvictionTimerTask();
   
  +   protected final Set activationChangeNodes = Collections.synchronizedSet(new HashSet());
  +
   
      public RegionManager()
      {
  @@ -254,7 +262,7 @@
                  r.setActive(true);
                  // FIXME - persistent state transfer counts too!
                  if (treeCache.getConfiguration().isFetchInMemoryState()) 
  -                  treeCache.activateRegion(r.getFqn().toString());               
  +                  activateRegion(r.getFqn().toString());               
               }
            }
            else if (defaultInactive)
  @@ -264,7 +272,7 @@
               r.setActive(true);
               // FIXME - persistent state transfer counts too!
               if (treeCache.getConfiguration().isFetchInMemoryState()) 
  -               treeCache.activateRegion(r.getFqn().toString());            
  +               activateRegion(r.getFqn().toString());            
            }
         }
         catch (Exception e)
  @@ -274,6 +282,286 @@
      }
   
      /**
  +    * Causes the cache to transfer state for the subtree rooted at
  +    * <code>subtreeFqn</code> and to begin accepting replication messages
  +    * for that subtree.
  +    * <p/>
  +    * <strong>NOTE:</strong> This method will cause the creation of a node
  +    * in the local tree at <code>subtreeFqn</code> whether or not that
  +    * node exists anywhere else in the cluster.  If the node does not exist
  +    * elsewhere, the local node will be empty.  The creation of this node will
  +    * not be replicated.
  +    *
  +    * @param subtreeFqn Fqn string indicating the uppermost node in the
  +    *                   portion of the tree that should be activated.
  +    * @throws RegionNotEmptyException if the node <code>subtreeFqn</code>
  +    *                                 exists and has either data or children
  +    */
  +   public void activateRegion(String subtreeFqn) throws CacheException
  +   {
  +      Fqn fqn = Fqn.fromString(subtreeFqn);
  +
  +      // Check whether the node already exists and has data
  +      DataNode subtreeRoot = treeCache.findNode(fqn);
  +      
  +      /*
  +       * Commented out on Nov 16,2006 Manik&Vladimir 
  +       * 
  +       * if (!(treeCache.isNodeEmpty(subtreeRoot)))
  +      {
  +         throw new RegionNotEmptyException("Node " + subtreeRoot.getFqn() + " already exists and is not empty");
  +      }*/
  +
  +      if(isActivatingDeactivating(fqn))
  +      {
  +         throw new CacheException("Region " + subtreeRoot.getFqn() + " is already being activated/deactivated");
  +      }
  +      
  +      if (log.isDebugEnabled())
  +      {
  +         log.debug("activating " + fqn);
  +      }
  +
  +      try
  +      {
  +
  +         // Add this fqn to the set of those we are activating
  +         // so calls to _getState for the fqn can return quickly
  +         activationChangeNodes.add(fqn);
  +
  +         Region region = getRegion(fqn, true);
  +
  +         // If a classloader is registered for the node's region, use it
  +         ClassLoader cl = region.getClassLoader();
  +
  +         BuddyManager buddyManager = treeCache.getBuddyManager();
  +         // Request partial state from the cluster and integrate it
  +         if (buddyManager == null)
  +         {
  +            // Get the state from any node that has it and put it
  +            // in the main tree
  +            if (subtreeRoot == null)
  +            {
  +               // We'll update this node with the state we receive
  +               subtreeRoot = treeCache.createSubtreeRootNode(fqn);
  +            }
  +
  +            Address [] groupMembers = null;
  +            Vector<Address> members = treeCache.getMembers();
  +            synchronized (members)
  +            {
  +               groupMembers = members.toArray(new Address[members.size()]);
  +            }
  +            if (groupMembers.length < 2)
  +            {
  +               if (log.isDebugEnabled())
  +                  log.debug("No nodes able to give state");
  +            }
  +            else
  +            {
  +               treeCache.fetchPartialState(groupMembers, subtreeRoot.getFqn());
  +            }       
  +         }
  +         else
  +         {
  +            // Get the state from each DataOwner and integrate in their
  +            // respective buddy backup tree
  +            List buddies = buddyManager.getBuddyAddresses();
  +            for (Iterator it = buddies.iterator(); it.hasNext();)
  +            {
  +               Address buddy = (Address) it.next();
  +               Object sources[] = new Object[]{buddy};               
  +               Fqn base = new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, BuddyManager.getGroupNameFromAddress(buddy));
  +               Fqn buddyRoot = new Fqn(base, fqn);
  +               subtreeRoot = treeCache.findNode(buddyRoot);
  +               if (subtreeRoot == null)
  +               {
  +                  // We'll update this node with the state we receive
  +                  subtreeRoot = treeCache.createSubtreeRootNode(buddyRoot);
  +               }
  +               treeCache.fetchPartialState(sources, subtreeRoot.getFqn());                
  +            }
  +         }        
  +      }
  +      catch (Throwable t)
  +      {
  +         log.error("failed to activate " + subtreeFqn, t);
  +
  +         // "Re-deactivate" the region
  +         try
  +         {
  +            inactivateRegion(subtreeFqn);
  +         }
  +         catch (Exception e)
  +         {
  +            log.error("failed inactivating " + subtreeFqn, e);
  +            // just swallow this one and throw the first one
  +         }
  +
  +         // Throw the exception on, wrapping if necessary         
  +         if (t instanceof RegionNotEmptyException)
  +         {
  +            throw(RegionNotEmptyException) t;
  +         }
  +         else if (t instanceof CacheException)
  +         {
  +            throw(CacheException) t;
  +         }
  +         else
  +         {
  +            throw new CacheException(t.getClass().getName() + " " +
  +                    t.getLocalizedMessage(), t);
  +         }
  +      }
  +      finally
  +      {
  +         activationChangeNodes.remove(fqn);
  +      }
  +   }
  +   
  +   /**
  +    * Causes the cache to stop accepting replication events for the subtree
  +    * rooted at <code>subtreeFqn</code> and evict all nodes in that subtree.
  +    *
  +    * @param subtreeFqn Fqn string indicating the uppermost node in the
  +    *                   portion of the tree that should be activated.
  +    * @throws RegionNameConflictException if <code>subtreeFqn</code> indicates
  +    *                                     a node that is part of another
  +    *                                     subtree that is being specially
  +    *                                     managed (either by activate/inactiveRegion()
  +    *                                     or by registerClassLoader())
  +    * @throws CacheException              if there is a problem evicting nodes
  +    * @throws IllegalStateException       if {@link Configuration#isUseRegionBasedMarshalling()} is <code>false</code>
  +    */
  +   public void inactivateRegion(String subtreeFqn) throws CacheException
  +   {     
  +      Fqn fqn = Fqn.fromString(subtreeFqn);
  +      DataNode parent = null;
  +      DataNode subtreeRoot = null;
  +      boolean parentLocked = false;
  +      boolean subtreeLocked = false;
  +      
  +      if(isActivatingDeactivating(fqn))
  +      {
  +         throw new CacheException("Region " + subtreeRoot.getFqn() + " is already being activated/deactivated");
  +      }
  +      
  +      try
  +      {
  +         // Record that this fqn is in status change, so can't provide state
  +         activationChangeNodes.add(fqn);
  +
  +         VersionAwareMarshaller marshaller = treeCache.getMarshaller();
  +         boolean inactive = marshaller.isInactive(subtreeFqn);
  +         if (!inactive)
  +         {
  +            deactivate(subtreeFqn);
  +         }
  +
  +         // Create a list with the Fqn in the main tree and any buddy backup trees
  +         BuddyManager buddyManager = treeCache.getBuddyManager();
  +         ArrayList list = new ArrayList();
  +         list.add(fqn);
  +         
  +         if (buddyManager != null)
  +         {
  +            Set buddies = treeCache.getChildrenNames(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN);
  +            if (buddies != null)
  +            {
  +               for (Iterator it = buddies.iterator(); it.hasNext();)
  +               {
  +                  Fqn base = new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, it.next());
  +                  list.add(new Fqn(base, fqn));
  +               }
  +            }
  +         }
  +
  +         long stateFetchTimeout = treeCache.getConfiguration().getLockAcquisitionTimeout() + 5000;
  +         // Remove the subtree from the main tree  and any buddy backup trees
  +         for (Iterator it = list.iterator(); it.hasNext();)
  +         {
  +            Fqn subtree = (Fqn) it.next();
  +            subtreeRoot = treeCache.findNode(subtree);
  +            if (subtreeRoot != null)
  +            {
  +               // Acquire locks
  +               Object owner = treeCache.getOwnerForLock();
  +               subtreeRoot.acquireAll(owner, stateFetchTimeout, DataNode.LockType.WRITE);
  +               subtreeLocked = true;
  +
  +               // Lock the parent, as we're about to write to it
  +               parent = (DataNode) subtreeRoot.getParent();
  +               if (parent != null)
  +               {
  +                  parent.acquire(owner, stateFetchTimeout, DataNode.LockType.WRITE);
  +                  parentLocked = true;
  +               }
  +
  +               // Remove the subtree
  +               treeCache._evictSubtree(subtree);
  +
  +               // Release locks
  +               if (parent != null)
  +               {
  +                  log.debug("forcing release of locks in parent");
  +                  parent.releaseAllForce();
  +               }
  +
  +               parentLocked = false;
  +
  +               log.debug("forcing release of all locks in subtree");
  +               subtreeRoot.releaseAllForce();
  +               subtreeLocked = false;
  +            }
  +         }
  +      }
  +      catch (InterruptedException ie)
  +      {
  +         throw new CacheException("Interrupted while acquiring lock", ie);
  +      }
  +      finally
  +      {
  +         // If we didn't succeed, undo the marshalling change
  +         // NO. Since we inactivated, we may have missed changes
  +         //if (!success && !inactive)
  +         //   marshaller_.activate(subtreeFqn);
  +
  +         // If necessary, release locks
  +         if (parentLocked)
  +         {
  +            log.debug("forcing release of locks in parent");
  +            try
  +            {
  +               parent.releaseAllForce();
  +            }
  +            catch (Throwable t)
  +            {
  +               log.error("failed releasing locks", t);
  +            }
  +         }
  +         if (subtreeLocked)
  +         {
  +            log.debug("forcing release of all locks in subtree");
  +            try
  +            {
  +               subtreeRoot.releaseAllForce();
  +            }
  +            catch (Throwable t)
  +            {
  +               log.error("failed releasing locks", t);
  +            }
  +         }
  +
  +         activationChangeNodes.remove(fqn);
  +      }
  +   }
  +   
  +   public boolean isActivatingDeactivating(Fqn fqn)
  +   {
  +      return activationChangeNodes.contains(fqn);
  +   }
  +
  +   /**
       * Overloaded form of {@link #activate(Fqn)}
       *
       * @param fqn
  @@ -331,7 +619,7 @@
                  // FIXME - we should always clean up; otherwise stale data 
                  // is in memory!
                  if (treeCache.getConfiguration().isFetchInMemoryState())  
  -                  treeCache.inactivateRegion(fqn.toString());
  +                  inactivateRegion(fqn.toString());
               }
            }
            else if (!defaultInactive)
  @@ -341,7 +629,7 @@
               // FIXME - we should always clean up; otherwise stale data 
               // is in memory!
               if (treeCache.getConfiguration().isFetchInMemoryState()) 
  -               treeCache.inactivateRegion(fqn.toString());
  +               inactivateRegion(fqn.toString());
            }
         }
         catch (Exception e)
  @@ -461,7 +749,7 @@
    * @author Ben Wang 02-2004
    * @author Daniel Huang (dhuang at jboss.org)
    * @author Brian Stansberry
  - * @version $Id: RegionManager.java,v 1.10 2006/11/16 07:48:00 bstansberry Exp $
  + * @version $Id: RegionManager.java,v 1.11 2006/11/16 15:40:19 msurtani Exp $
    */
   /*public class ERegionManager
   {
  
  
  



More information about the jboss-cvs-commits mailing list