1 7 package org.jboss.cache.eviction; 8 9 import org.apache.commons.logging.Log; 10 import org.apache.commons.logging.LogFactory; 11 import org.jboss.cache.Region; 12 13 35 public class LFUAlgorithm extends BaseSortedEvictionAlgorithm implements EvictionAlgorithm 36 { 37 private static final Log log = LogFactory.getLog(LFUAlgorithm.class); 38 39 40 public LFUAlgorithm() 41 { 42 super(); 43 } 44 45 protected boolean shouldEvictNode(NodeEntry ne) 46 { 47 if (log.isTraceEnabled()) 48 { 49 log.trace("Deciding whether node in queue " + ne.getFqn() + " requires eviction."); 50 } 51 52 LFUConfiguration config = (LFUConfiguration) region.getEvictionPolicyConfig(); 53 int size = this.getEvictionQueue().getNumberOfNodes(); 54 if (config.getMaxNodes() != 0 && size > config.getMaxNodes()) 55 { 56 return true; 57 } 58 else if (size > config.getMinNodes()) 59 { 60 return true; 61 } 62 63 return false; 64 } 65 66 73 protected EvictionQueue setupEvictionQueue(Region region) throws EvictionException 74 { 75 return new LFUQueue(); 76 } 77 78 protected void prune() throws EvictionException 79 { 80 super.prune(); 81 82 ((LFUQueue) this.evictionQueue).prune(); 84 } 85 } 86 | Popular Tags |