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

Manik Surtani manik at jboss.org
Thu Jun 28 12:53:37 EDT 2007


  User: msurtani
  Date: 07/06/28 12:53:37

  Modified:    src/org/jboss/cache/eviction  EvictionTimerTask.java
  Log:
  Notification changes
  
  Revision  Changes    Path
  1.15      +46 -58    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.14
  retrieving revision 1.15
  diff -u -b -r1.14 -r1.15
  --- EvictionTimerTask.java	26 Mar 2007 11:11:24 -0000	1.14
  +++ EvictionTimerTask.java	28 Jun 2007 16:53:37 -0000	1.15
  @@ -9,32 +9,30 @@
   
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  -import org.jboss.cache.AbstractCacheListener;
  -import org.jboss.cache.CacheSPI;
   import org.jboss.cache.Region;
  -import org.jboss.cache.notifications.Notifier;
   
   import java.util.Collections;
   import java.util.HashSet;
   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.14 $
  + * @version $Revision: 1.15 $
    */
   public class EvictionTimerTask
   {
      private Log log = LogFactory.getLog(EvictionTimerTask.class);
   
      private final Set<Region> processedRegions;
  +   private static AtomicInteger tcount = new AtomicInteger();
      private int wakeupIntervalSeconds;
  -   // Only needed once JBBUILD-350 is fixed and we use the overloaded constructor for Timer below.
  -   //private static AtomicInteger tcount = new AtomicInteger();
  +   private Timer evictionThread;
   
      public EvictionTimerTask()
      {
  @@ -43,13 +41,12 @@
         processedRegions = Collections.synchronizedSet(new HashSet<Region>());
      }
   
  -   public void init(int wakeupIntervalSeconds, Notifier notifier)
  +   public void init(int wakeupIntervalSeconds)
      {
  -      this.wakeupIntervalSeconds = wakeupIntervalSeconds;
         if (log.isTraceEnabled())
            log.trace("Creating a new eviction listener with wakeupIntervalSeconds set at " + wakeupIntervalSeconds);
  -      EvictionListener l = new EvictionListener();
  -      notifier.setEvictionPolicyListener(l);
  +      this.wakeupIntervalSeconds = wakeupIntervalSeconds;
  +      start();
      }
   
      /**
  @@ -77,16 +74,20 @@
         return processedRegions.contains(region);
      }
   
  -   class EvictionListener extends AbstractCacheListener
  +   public void stop()
      {
  -      private Log log = LogFactory.getLog(EvictionListener.class);
  -      private Timer evictionThread;
  +      log.debug("Stopping eviction timer");
  +
  +      if (evictionThread != null)
  +      {
  +         evictionThread.cancel();
  +      }
  +      evictionThread = null;
  +   }
   
  -      public void cacheStarted(CacheSPI cache)
  +   private void start()
         {
  -         //evictionThread = new Timer("EvictionTimer-" + tcount.getAndIncrement(), true);
  -         // use an older JDK 1.4 compat constructor until JBBUILD-350 is fixed.
  -         evictionThread = new Timer(true);
  +      evictionThread = new Timer("EvictionTimer-" + tcount.getAndIncrement(), true);
            TimerTask tt = new TimerTask()
            {
               /**
  @@ -126,19 +127,6 @@
            };
            evictionThread.schedule(tt, wakeupIntervalSeconds * 1000, wakeupIntervalSeconds * 1000);
         }
  -
  -      public void cacheStopped(CacheSPI cache)
  -      {
  -         log.debug("Stopping eviction timer");
  -
  -         if (evictionThread != null)
  -         {
  -            evictionThread.cancel();
  -         }
  -         evictionThread = null;
  -      }
  -   }
  -
   }
   
   
  
  
  



More information about the jboss-cvs-commits mailing list