[jboss-cvs] JBossCache/src/org/jboss/cache/eviction ...
Manik Surtani
msurtani at jboss.com
Wed Nov 15 11:30:39 EST 2006
User: msurtani
Date: 06/11/15 11:30:39
Modified: src/org/jboss/cache/eviction EvictionTimerTask.java
Log:
Fixed eviction breakages
Revision Changes Path
1.7 +41 -1 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.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- EvictionTimerTask.java 14 Nov 2006 14:17:11 -0000 1.6
+++ EvictionTimerTask.java 15 Nov 2006 16:30:39 -0000 1.7
@@ -10,25 +10,31 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Region;
+import org.jboss.cache.AbstractCacheListener;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.notifications.Notifier;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.TimerTask;
+import java.util.Timer;
/**
* 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.6 $
+ * @version $Revision: 1.7 $
*/
public class EvictionTimerTask extends TimerTask
{
private Log log = LogFactory.getLog(EvictionTimerTask.class);
private final Set processedRegions;
+ private int wakeupIntervalSeconds;
+
public EvictionTimerTask()
{
@@ -37,6 +43,14 @@
processedRegions = Collections.synchronizedSet(new HashSet());
}
+ public void init(int wakeupIntervalSeconds, Notifier notifier)
+ {
+ 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);
+ }
+
/**
* Add a MarshRegion to process by the Eviction Thread.
*
@@ -91,4 +105,30 @@
}
}
}
+
+ class EvictionListener extends AbstractCacheListener
+ {
+ private Log log = LogFactory.getLog(EvictionListener.class);
+ private Timer evictionThread;
+
+ public void cacheStarted(CacheSPI cache)
+ {
+ log.debug("Starting eviction timer");
+ evictionThread = new Timer();
+ evictionThread.schedule(EvictionTimerTask.this,
+ 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