[jboss-cvs] JBossCache/src/org/jboss/cache/eviction ...
Manik Surtani
msurtani at jboss.com
Thu Jan 18 11:55:19 EST 2007
User: msurtani
Date: 07/01/18 11:55:19
Modified: src/org/jboss/cache/eviction ExpirationPolicy.java
FIFOPolicy.java ExpirationAlgorithm.java
LFUPolicy.java LRUPolicy.java
BaseEvictionPolicy.java EvictionPolicyConfig.java
ElementSizePolicy.java EvictionPolicy.java
MRUPolicy.java
Log:
JBCACHE-889
Revision Changes Path
1.3 +9 -6 JBossCache/src/org/jboss/cache/eviction/ExpirationPolicy.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ExpirationPolicy.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/eviction/ExpirationPolicy.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- ExpirationPolicy.java 8 Dec 2006 19:19:05 -0000 1.2
+++ ExpirationPolicy.java 18 Jan 2007 16:55:18 -0000 1.3
@@ -4,6 +4,7 @@
/**
* Returns the {@link ExpirationAlgorithm} as the policy's algorithm.
+ *
* @author rosse
*/
public class ExpirationPolicy extends BaseEvictionPolicy
@@ -11,7 +12,8 @@
private EvictionAlgorithm algorithm;
- public ExpirationPolicy() {
+ public ExpirationPolicy()
+ {
algorithm = new ExpirationAlgorithm(this);
}
@@ -20,7 +22,7 @@
return algorithm;
}
- public Class getEvictionConfigurationClass()
+ public Class<ExpirationConfiguration> getEvictionConfigurationClass()
{
return ExpirationConfiguration.class;
}
@@ -29,7 +31,8 @@
* Returns true if it's a visit node event.
*/
@Override
- public boolean canIgnoreEvent(Fqn fqn, NodeEventType eventType) {
+ public boolean canIgnoreEvent(Fqn fqn, NodeEventType eventType)
+ {
return (eventType == NodeEventType.VISIT_NODE_EVENT);
}
}
1.4 +2 -2 JBossCache/src/org/jboss/cache/eviction/FIFOPolicy.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: FIFOPolicy.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/eviction/FIFOPolicy.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- FIFOPolicy.java 5 Dec 2005 03:17:13 -0000 1.3
+++ FIFOPolicy.java 18 Jan 2007 16:55:18 -0000 1.4
@@ -12,7 +12,7 @@
*
* @author Daniel Huang (dhuang at jboss.org)
* @author Morten Kvistgaard
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
public class FIFOPolicy extends BaseEvictionPolicy implements EvictionPolicy
{
@@ -29,7 +29,7 @@
return algorithm;
}
- public Class getEvictionConfigurationClass()
+ public Class<FIFOConfiguration> getEvictionConfigurationClass()
{
return FIFOConfiguration.class;
}
1.7 +3 -1 JBossCache/src/org/jboss/cache/eviction/ExpirationAlgorithm.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ExpirationAlgorithm.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/eviction/ExpirationAlgorithm.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- ExpirationAlgorithm.java 10 Jan 2007 00:10:47 -0000 1.6
+++ ExpirationAlgorithm.java 18 Jan 2007 16:55:18 -0000 1.7
@@ -4,6 +4,7 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.FqnComparator;
+import org.jboss.cache.NodeSPI;
import org.jboss.cache.Region;
import java.util.Iterator;
@@ -118,7 +119,8 @@
private Long getExpiration(Fqn fqn)
{
- Long l = (Long) policy.getCacheData(fqn, config.getExpirationKeyName());
+ NodeSPI n = policy.getCache().peek(fqn, false);
+ Long l = (Long) (n == null ? null : n.getDirect(config.getExpirationKeyName()));
if (l == null)
return null;
return l;
1.2 +2 -2 JBossCache/src/org/jboss/cache/eviction/LFUPolicy.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: LFUPolicy.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/eviction/LFUPolicy.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- LFUPolicy.java 5 Dec 2005 03:17:13 -0000 1.1
+++ LFUPolicy.java 18 Jan 2007 16:55:18 -0000 1.2
@@ -10,7 +10,7 @@
* Least Frequently Used Eviction Policy.
*
* @author Daniel Huang - dhuang at jboss.org - 10/2005
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
public class LFUPolicy extends BaseEvictionPolicy implements EvictionPolicy
{
@@ -27,7 +27,7 @@
return algorithm;
}
- public Class getEvictionConfigurationClass()
+ public Class<LFUConfiguration> getEvictionConfigurationClass()
{
return LFUConfiguration.class;
}
1.13 +5 -5 JBossCache/src/org/jboss/cache/eviction/LRUPolicy.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: LRUPolicy.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/eviction/LRUPolicy.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- LRUPolicy.java 30 Dec 2006 17:50:05 -0000 1.12
+++ LRUPolicy.java 18 Jan 2007 16:55:18 -0000 1.13
@@ -7,7 +7,7 @@
*/
package org.jboss.cache.eviction;
-import org.jboss.cache.CacheImpl;
+import org.jboss.cache.CacheSPI;
import org.jboss.cache.RegionManager;
/**
@@ -16,7 +16,7 @@
*
* @author Ben Wang 02-2004
* @author Daniel Huang - dhuang at jboss.org
- * @version $Revision: 1.12 $
+ * @version $Revision: 1.13 $
*/
public class LRUPolicy extends BaseEvictionPolicy implements EvictionPolicy
{
@@ -35,14 +35,14 @@
return algorithm;
}
- public Class getEvictionConfigurationClass()
+ public Class<LRUConfiguration> getEvictionConfigurationClass()
{
return LRUConfiguration.class;
}
- public void configure(CacheImpl cache)
+ public void setCache(CacheSPI cache)
{
- super.configure(cache);
+ super.setCache(cache);
regionManager_ = cache_.getRegionManager();
}
}
1.9 +13 -54 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.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- BaseEvictionPolicy.java 17 Jan 2007 16:24:07 -0000 1.8
+++ BaseEvictionPolicy.java 18 Jan 2007 16:55:18 -0000 1.9
@@ -1,22 +1,18 @@
package org.jboss.cache.eviction;
-import org.jboss.cache.CacheException;
-import org.jboss.cache.CacheImpl;
+import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
-import org.jboss.cache.NodeSPI;
-
-import java.util.Set;
/**
* Base class implementation of EvictionPolicy and TreeCacheListener.
*
* @author Ben Wang 2-2004
* @author Daniel Huang - dhuang at jboss.org
- * @version $Revision: 1.8 $
+ * @version $Revision: 1.9 $
*/
public abstract class BaseEvictionPolicy implements EvictionPolicy
{
- protected CacheImpl cache_;
+ protected CacheSPI cache_;
public BaseEvictionPolicy()
{
@@ -32,54 +28,17 @@
*/
public void evict(Fqn fqn) throws Exception
{
- cache_.evict(fqn);
- }
-
- /**
- * Return a set of child names under a given Fqn.
- *
- * @param fqn Get child names for given Fqn in cache.
- * @return Set of children name as Objects
- */
- public Set getChildrenNames(Fqn fqn)
- {
- try
- {
- return cache_.getChildrenNames(fqn);
- }
- catch (CacheException e)
- {
- e.printStackTrace();
- }
- return null;
+ cache_.evict(fqn, false);
}
- public boolean hasChild(Fqn fqn)
+ public void setCache(CacheSPI cache)
{
- return cache_.hasChild(fqn);
- }
-
- public Object getCacheData(Fqn fqn, Object key)
- {
- try
- {
- NodeSPI n = cache_.peek(fqn, true);
- if (n == null)
- {
- return null;
- }
-
- return n.getDirect(key);
- }
- catch (CacheException e)
- {
- throw new CacheException("Failed locating key for " + fqn, e);
- }
+ this.cache_ = cache;
}
- public void configure(CacheImpl cache)
+ public CacheSPI getCache()
{
- this.cache_ = cache;
+ return this.cache_;
}
/*
1.7 +4 -4 JBossCache/src/org/jboss/cache/eviction/EvictionPolicyConfig.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: EvictionPolicyConfig.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/eviction/EvictionPolicyConfig.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- EvictionPolicyConfig.java 15 Nov 2006 15:16:39 -0000 1.6
+++ EvictionPolicyConfig.java 18 Jan 2007 16:55:18 -0000 1.7
@@ -21,7 +21,7 @@
{
/**
* Gets the class name of the {@link EvictionPolicy} implementation
- * this object will be used to configure. Used by {@link org.jboss.cache.RegionManager}
+ * this object will be used to setCache. Used by {@link org.jboss.cache.RegionManager}
* to instantiate the policy.
*
* @return fully qualified class name
1.2 +1 -1 JBossCache/src/org/jboss/cache/eviction/ElementSizePolicy.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ElementSizePolicy.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/eviction/ElementSizePolicy.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- ElementSizePolicy.java 7 May 2006 03:34:39 -0000 1.1
+++ ElementSizePolicy.java 18 Jan 2007 16:55:18 -0000 1.2
@@ -25,7 +25,7 @@
return this.algorithm;
}
- public Class getEvictionConfigurationClass()
+ public Class<ElementSizeConfiguration> getEvictionConfigurationClass()
{
return ElementSizeConfiguration.class;
}
1.10 +7 -20 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.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- EvictionPolicy.java 30 Dec 2006 17:50:05 -0000 1.9
+++ EvictionPolicy.java 18 Jan 2007 16:55:18 -0000 1.10
@@ -6,11 +6,9 @@
*/
package org.jboss.cache.eviction;
-import org.jboss.cache.CacheImpl;
+import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
-import java.util.Set;
-
/**
* Generic eviction policy interface.
* <p/>
@@ -31,27 +29,16 @@
void evict(Fqn fqn) throws Exception;
/**
- * Return children names as Objects
- *
- * @param fqn
- * @return Child names under given fqn
+ * @return the CacheSPI instance this eviction policy is configured to work on.
*/
- Set getChildrenNames(Fqn fqn);
+ CacheSPI getCache();
/**
- * Is this a leaf node?
+ * Method called to set the cache in this implementation.
*
- * @param fqn
- * @return true/false if leaf node.
- */
- boolean hasChild(Fqn fqn);
-
- Object getCacheData(Fqn fqn, Object key);
-
- /**
- * Method called to configure this implementation.
+ * @param cache the cache to set
*/
- void configure(CacheImpl cache);
+ void setCache(CacheSPI cache);
/**
* Get the associated EvictionAlgorithm used by the EvictionPolicy.
@@ -67,7 +54,7 @@
*
* @return EvictionPolicyConfig implementation class.
*/
- Class<EvictionPolicyConfig> getEvictionConfigurationClass();
+ Class<? extends EvictionPolicyConfig> getEvictionConfigurationClass();
/**
* This method will be invoked prior to an event being processed for a node
1.2 +2 -2 JBossCache/src/org/jboss/cache/eviction/MRUPolicy.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: MRUPolicy.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/eviction/MRUPolicy.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- MRUPolicy.java 5 Dec 2005 03:17:13 -0000 1.1
+++ MRUPolicy.java 18 Jan 2007 16:55:18 -0000 1.2
@@ -12,7 +12,7 @@
* This algorithm will evict the most recently used cache entries from cache.
*
* @author Daniel Huang (dhuang at jboss.org)
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
public class MRUPolicy extends BaseEvictionPolicy implements EvictionPolicy
{
@@ -30,7 +30,7 @@
return algorithm;
}
- public Class getEvictionConfigurationClass()
+ public Class<MRUConfiguration> getEvictionConfigurationClass()
{
return MRUConfiguration.class;
}
More information about the jboss-cvs-commits
mailing list