1 7 package org.jboss.cache.eviction; 8 9 import org.jboss.cache.Region; 10 11 12 16 public class ElementSizeAlgorithm extends BaseSortedEvictionAlgorithm 17 { 18 protected EvictionQueue setupEvictionQueue(Region region) throws EvictionException 19 { 20 return new ElementSizeQueue(); 21 } 22 23 protected boolean shouldEvictNode(NodeEntry ne) 24 { 25 ElementSizeConfiguration config = (ElementSizeConfiguration) region.getEvictionPolicyConfig(); 26 27 int size = this.getEvictionQueue().getNumberOfNodes(); 28 if (config.getMaxNodes() != 0 && size > config.getMaxNodes()) 29 { 30 return true; 31 } 32 33 return ne.getNumberOfElements() > config.getMaxElementsPerNode(); 34 } 35 36 37 protected void prune() throws EvictionException 38 { 39 super.prune(); 40 41 ((ElementSizeQueue) this.evictionQueue).prune(); 43 } 44 45 } 46 | Popular Tags |