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

Manik Surtani msurtani at jboss.com
Tue Oct 10 09:51:42 EDT 2006


  User: msurtani
  Date: 06/10/10 09:51:42

  Modified:    src/org/jboss/cache   Cache.java TreeCacheProxyImpl.java
  Log:
  Updated behaviour of getRegion()
  
  Revision  Changes    Path
  1.9       +5 -5      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.8
  retrieving revision 1.9
  diff -u -b -r1.8 -r1.9
  --- Cache.java	9 Oct 2006 08:02:59 -0000	1.8
  +++ Cache.java	10 Oct 2006 13:51:42 -0000	1.9
  @@ -129,16 +129,16 @@
       * Eviction call that evicts the specified {@link Node} from memory.
       *
       * @param fqn       <b><i>absolute</i></b> {@link Fqn} to the {@link Node} to be evicted.
  -    * @param recursive
  +    * @param recursive evicts children as well
       */
      void evict(Fqn fqn, boolean recursive);
   
      /**
       * Retrieves a {@link Region} for a given {@link Fqn}.  If the region does not exist,
       * and <li>createIfAbsent</li> is true, then one is created.
  -    * Note that if there is parent Fqn that matches an existing region, the region will be
  -    * retrieved first. That is, we will do a recursive search for the matching region starting
  -    * from the root.
  +    * <p/>
  +    * If not, parent Fqns will be consulted in turn for registered regions, gradually working up to
  +    * Fqn.ROOT.  If no regions are defined in any of the parents either, a null is returned.
       *
       * @param fqn Fqn that is contained in a region.
       * @param createIfAbsent If true, will create a new associated region if not found.
  
  
  
  1.41      +22 -17    JBossCache/src/org/jboss/cache/TreeCacheProxyImpl.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: TreeCacheProxyImpl.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/TreeCacheProxyImpl.java,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -b -r1.40 -r1.41
  --- TreeCacheProxyImpl.java	9 Oct 2006 08:02:59 -0000	1.40
  +++ TreeCacheProxyImpl.java	10 Oct 2006 13:51:42 -0000	1.41
  @@ -51,6 +51,7 @@
      /**
       * A temp solution untill we figure out how to extract the membership functionality from
       * TreeCache.
  +    *
       * @return
       */
      public TreeCache getTreeCache()
  @@ -259,26 +260,29 @@
   
      public Region getRegion(Fqn fqn, boolean createIfAbsent)
      {
  -      // loop thru children fqn to find the match first.
  -      // Or alternatively we can iterate thru the regionRegistry to
  -      // find the match.
  -      for(int i=0; i < fqn.size(); i++)
  -      {
  -         Fqn f = fqn.getFqnChild(i);
  -         if (treeCache.regionsRegistry.containsKey(f))
  +      // first see if a region for this specific Fqn exists
  +      if (treeCache.regionsRegistry.containsKey(fqn)) return treeCache.regionsRegistry.get(fqn);
  +
  +      // if not, attempt to create one ...
  +      if (createIfAbsent)
            {
  -            // first match is returned
  -            return treeCache.regionsRegistry.get(f);
  -         }
  +         Region r = new RegionImpl(treeCache, fqn);
  +         treeCache.regionsRegistry.put(fqn, r);
  +         return r;
         }
   
  -      if(createIfAbsent)
  -      {
  -         return new RegionImpl(treeCache, fqn);
  -      } else
  +      // else try and find a parent which has a defined region, may return null if nothing is defined.
  +      Region r = null;
  +      Fqn nextFqn = fqn;
  +
  +      while (r == null)
         {
  -         return null;
  +         nextFqn = nextFqn.getParent();
  +         r = treeCache.regionsRegistry.get(nextFqn);
  +         if (nextFqn.isRoot()) break;
         }
  +
  +      return r;
      }
   
      public void create() throws Exception
  @@ -508,6 +512,7 @@
      // -----------
   
      // TODO: Think about what we need to do here regarding locking on Nodes
  +
      public boolean acquire(Object owner, long lock_timeout, DataNode.LockType lockType) throws InterruptedException
      {
         return currentNode.acquire(owner, lock_timeout, lockType);
  
  
  



More information about the jboss-cvs-commits mailing list