1 7 package org.jboss.cache.eviction; 8 9 import org.jboss.cache.Fqn; 10 import org.jboss.cache.aop.AOPInstance; 11 import org.jboss.cache.aop.TreeCacheAop; 12 13 import java.util.Set ; 14 import java.util.Iterator ; 15 16 32 public class AopLRUAlgorithm extends LRUAlgorithm 33 { 34 static final long TOLERANCE = 10; 36 37 42 protected Set getAssociatedEvictNode(Fqn fqn) { 43 return getChildrenNames(fqn); 47 } 48 49 52 protected boolean preAddedNodes(Fqn fqn) { 53 if(fqn.getFqnChild(0).equals(TreeCacheAop.JBOSS_INTERNAL)) return false; 55 return true; 56 } 57 58 private boolean isAopNode(Fqn fqn) { 59 EvictionPolicy policy = region_.getEvictionPolicy(); 60 return (policy.getCacheData(fqn, AOPInstance.KEY) == null); 61 } 62 63 68 private Set getChildrenNames(Fqn fqn) { 69 EvictionPolicy policy = region_.getEvictionPolicy(); 70 return policy.getChildrenNames(fqn); 71 } 72 73 78 protected boolean preVisitedNodes(Fqn fqn, long stamp) { 79 if(isAopNode(fqn)) { 81 Set set = getChildrenNames(fqn); 82 Iterator it = set.iterator(); 83 while(it.hasNext()) { 84 Object child = it.next(); 85 Fqn childFqn = new Fqn(child); 86 if( !preVisitedNodes(childFqn, stamp) ) return false; 87 try { 88 updateChildTimeStamp(childFqn, stamp); 89 } catch (EvictionException e) { 90 e.printStackTrace(); 91 return false; 92 } 93 } 94 } 95 return true; 96 } 97 98 private void updateChildTimeStamp(Fqn childFqn, long stamp) throws EvictionException 99 { 100 NodeEntry ne = (NodeEntry)nodeMap_.get(childFqn); 101 ne.setModifiedTimeStamp(stamp); 102 demote(childFqn); 103 } 104 } 105 | Popular Tags |