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

Manik Surtani msurtani at jboss.com
Thu Jan 4 11:46:45 EST 2007


  User: msurtani
  Date: 07/01/04 11:46:45

  Modified:    src/org/jboss/cache    RegionImpl.java RegionManager.java
                        Region.java
  Log:
  Fixed poor initialisation of eviction regions
  
  Revision  Changes    Path
  1.17      +16 -8     JBossCache/src/org/jboss/cache/RegionImpl.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: RegionImpl.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/RegionImpl.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -b -r1.16 -r1.17
  --- RegionImpl.java	30 Dec 2006 17:49:54 -0000	1.16
  +++ RegionImpl.java	4 Jan 2007 16:46:45 -0000	1.17
  @@ -134,6 +134,7 @@
      {
         try
         {
  +         if (nodeEventQueue == null) createQueue();// in case the queue does not exist yet.
            if (nodeEventQueue.size() > capacityWarnThreshold)
            {
               log.warn("putNodeEvent(): eviction node event queue size is at 98% threshold value of capacity: " + configuration.getEventQueueSize() +
  @@ -176,10 +177,14 @@
         nodeEventQueue.clear();
      }
   
  -   private void createQueue()
  +   private synchronized void createQueue()
  +   {
  +      if (nodeEventQueue == null)
      {
         if (configuration == null)
  +         {
            throw new IllegalArgumentException("null eviction configuration");
  +         }
         int size = configuration.getEventQueueSize();
         capacityWarnThreshold = (98 * size) / 100 - 100;
         if (capacityWarnThreshold <= 0)
  @@ -188,6 +193,7 @@
         }
         nodeEventQueue = new LinkedBlockingQueue<EvictedEventNode>(size);
      }
  +   }
   
      public EvictionRegionConfig getEvictionRegionConfig()
      {
  @@ -215,7 +221,9 @@
      private EvictionPolicy createPolicy(String className)
      {
         if (className == null)
  +      {
            throw new IllegalArgumentException("null className");
  +      }
         try
         {
            if (log.isTraceEnabled()) log.trace("Instantiating " + className);
  
  
  
  1.20      +25 -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.19
  retrieving revision 1.20
  diff -u -b -r1.19 -r1.20
  --- RegionManager.java	4 Jan 2007 05:35:39 -0000	1.19
  +++ RegionManager.java	4 Jan 2007 16:46:45 -0000	1.20
  @@ -119,10 +119,24 @@
   
      public Region getRegion(Fqn fqn, boolean createIfAbsent)
      {
  +      return getRegion(fqn, Region.Type.ANY, createIfAbsent);
  +   }
  +
  +   public Region getRegion(Fqn fqn, Region.Type type, boolean createIfAbsent)
  +   {
         Fqn fqnToUse = fqn;
         if (DEFAULT_REGION.equals(fqnToUse)) fqnToUse = Fqn.ROOT;
         // first see if a region for this specific Fqn exists
  -      if (regionsRegistry.containsKey(fqnToUse)) return regionsRegistry.get(fqnToUse);
  +      if (regionsRegistry.containsKey(fqnToUse))
  +      {
  +         Region r = regionsRegistry.get(fqnToUse);
  +         if (type == Region.Type.ANY
  +                 || (type == Region.Type.MARSHALLING && r.getClassLoader() != null)
  +                 || (type == Region.Type.EVICTION && r.getEvictionPolicyConfig() != null))
  +         {
  +            return r;
  +         }
  +      }
   
         // if not, attempt to create one ...
         if (createIfAbsent)
  @@ -142,17 +156,23 @@
         }
   
         // else try and find a parent which has a defined region, may return null if nothing is defined.
  -      Region r = null;
  +      Region nextBestThing = null;
         Fqn nextFqn = fqnToUse;
   
  -      while (r == null)
  +      while (nextBestThing == null)
         {
            nextFqn = nextFqn.getParent();
  -         r = regionsRegistry.get(nextFqn);
  +         Region r = regionsRegistry.get(nextFqn);
  +         if (type == Region.Type.ANY
  +                 || (type == Region.Type.MARSHALLING && r.getClassLoader() != null)
  +                 || (type == Region.Type.EVICTION && r.getEvictionPolicyConfig() != null))
  +         {
  +            nextBestThing = r;
  +         }
            if (nextFqn.isRoot()) break;
         }
   
  -      return r;
  +      return nextBestThing;
      }
   
      /**
  
  
  
  1.11      +5 -0      JBossCache/src/org/jboss/cache/Region.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Region.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/Region.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -b -r1.10 -r1.11
  --- Region.java	3 Jan 2007 15:33:09 -0000	1.10
  +++ Region.java	4 Jan 2007 16:46:45 -0000	1.11
  @@ -19,6 +19,11 @@
    */
   public interface Region extends Comparable<Region>
   {
  +   public enum Type
  +   {
  +      EVICTION, MARSHALLING, ANY
  +   }
  +
      /**
       * Registers a specific {@link ClassLoader} (rather than the default) for a region, represented by a {@link Fqn}.
       *
  
  
  



More information about the jboss-cvs-commits mailing list