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

Elias Ross genman at noderunner.net
Sun Nov 26 23:49:46 EST 2006


  User: genman  
  Date: 06/11/26 23:49:46

  Modified:    src/org/jboss/cache/eviction     BaseEvictionAlgorithm.java
                        BaseEvictionPolicy.java EvictionPolicy.java
                        EvictionTimerTask.java
  Log:
  JBCACHE-880 clean up for adding per-node eviction timeout
  
  Revision  Changes    Path
  1.16      +4 -1      JBossCache/src/org/jboss/cache/eviction/BaseEvictionAlgorithm.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: BaseEvictionAlgorithm.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/eviction/BaseEvictionAlgorithm.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -b -r1.15 -r1.16
  --- BaseEvictionAlgorithm.java	21 Nov 2006 08:57:02 -0000	1.15
  +++ BaseEvictionAlgorithm.java	27 Nov 2006 04:49:46 -0000	1.16
  @@ -20,7 +20,7 @@
    * abstract methods and a policy.
    *
    * @author Daniel Huang - dhuang at jboss.org 10/2005
  - * @version $Revision: 1.15 $
  + * @version $Revision: 1.16 $
    */
   public abstract class BaseEvictionAlgorithm implements EvictionAlgorithm
   {
  @@ -66,8 +66,11 @@
   
      protected void initialize(Region region) throws EvictionException
      {
  +      if (region == null)
  +         throw new IllegalArgumentException("region");
         this.region = region;
         evictionQueue = setupEvictionQueue(region);
  +      log.debug("initialized: " + this);
      }
   
      /**
  
  
  
  1.5       +7 -4      JBossCache/src/org/jboss/cache/eviction/BaseEvictionPolicy.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: BaseEvictionPolicy.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/eviction/BaseEvictionPolicy.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -b -r1.4 -r1.5
  --- BaseEvictionPolicy.java	12 Oct 2006 03:39:59 -0000	1.4
  +++ BaseEvictionPolicy.java	27 Nov 2006 04:49:46 -0000	1.5
  @@ -2,6 +2,7 @@
   
   import org.jboss.cache.CacheException;
   import org.jboss.cache.Fqn;
  +import org.jboss.cache.Node;
   import org.jboss.cache.TreeCache;
   
   import java.util.Set;
  @@ -11,7 +12,7 @@
    *
    * @author Ben Wang  2-2004
    * @author Daniel Huang - dhuang at jboss.org
  - * @version $Revision: 1.4 $
  + * @version $Revision: 1.5 $
    */
   public abstract class BaseEvictionPolicy implements EvictionPolicy
   {
  @@ -62,13 +63,15 @@
      {
         try
         {
  -         return cache_.get(fqn, key);
  +         Node n = cache_.peek(fqn);
  +         if (n == null)
  +            return null;
  +         return n.get(key);
         }
         catch (CacheException e)
         {
  -         e.printStackTrace();
  +         throw new CacheException("Failed locating key for " + fqn, e);
         }
  -      return null;
      }
   
      public void configure(TreeCache cache)
  
  
  
  1.8       +1 -1      JBossCache/src/org/jboss/cache/eviction/EvictionPolicy.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: EvictionPolicy.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/eviction/EvictionPolicy.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -b -r1.7 -r1.8
  --- EvictionPolicy.java	14 Nov 2006 14:17:11 -0000	1.7
  +++ EvictionPolicy.java	27 Nov 2006 04:49:46 -0000	1.8
  @@ -67,7 +67,7 @@
       *
       * @return EvictionPolicyConfig implementation class.
       */
  -   Class getEvictionConfigurationClass();
  +   Class<EvictionPolicyConfig> getEvictionConfigurationClass();
   
      /**
       * This method will be invoked prior to an event being processed for a node
  
  
  
  1.11      +6 -3      JBossCache/src/org/jboss/cache/eviction/EvictionTimerTask.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: EvictionTimerTask.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/eviction/EvictionTimerTask.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -b -r1.10 -r1.11
  --- EvictionTimerTask.java	16 Nov 2006 18:41:26 -0000	1.10
  +++ EvictionTimerTask.java	27 Nov 2006 04:49:46 -0000	1.11
  @@ -20,13 +20,14 @@
   import java.util.Set;
   import java.util.Timer;
   import java.util.TimerTask;
  +import java.util.concurrent.atomic.AtomicInteger;
   
   /**
    * Timer threads to do periodic node clean up by running the eviction policy.
    *
    * @author Ben Wang 2-2004
    * @author Daniel Huang (dhuang at jboss.org)
  - * @version $Revision: 1.10 $
  + * @version $Revision: 1.11 $
    */
   public class EvictionTimerTask extends TimerTask
   {
  @@ -34,7 +35,7 @@
   
      private final Set<Region> processedRegions;
      private int wakeupIntervalSeconds;
  -
  +   private static AtomicInteger tcount = new AtomicInteger();
   
      public EvictionTimerTask()
      {
  @@ -91,6 +92,8 @@
               synchronized (region)
               {
                  final EvictionAlgorithm algo = policy.getEvictionAlgorithm();
  +               if (algo == null)
  +                  throw new NullPointerException("algorithm null");
                  try
                  {
                     algo.process(region);
  @@ -119,7 +122,7 @@
   
         public void cacheStarted(CacheSPI cache)
         {
  -         evictionThread = new Timer();
  +         evictionThread = new Timer("EvictionTimer-" + tcount.getAndIncrement());
            evictionThread.schedule(EvictionTimerTask.this, wakeupIntervalSeconds * 1000, wakeupIntervalSeconds * 1000);
         }
   
  
  
  



More information about the jboss-cvs-commits mailing list