1 4 package com.tc.object.cache; 5 6 import com.tc.util.Assert; 7 import com.tc.util.State; 8 9 import java.util.List ; 10 11 public class TestCacheStats implements CacheStats { 12 13 private static final State INIT = new State("INIT"); 14 private static final State PROCESSING = new State("PROCESSING"); 15 private static final State COMPLETE = new State("COMPLETE"); 16 17 public int countBefore; 18 public int toKeep; 19 public int evicted; 20 public List objectsEvicted; 21 public int countAfter; 22 private State state = INIT; 23 24 public int getObjectCountToEvict(int currentCount) { 25 this.countBefore = currentCount; 26 int toEvict = currentCount - toKeep; 27 if (toEvict > 0) { 28 state = PROCESSING; 29 } 30 return toEvict; 31 } 32 33 public void objectEvicted(int evictedCount, int currentCount, List targetObjects4GC) { 34 this.evicted = evictedCount; 35 this.countAfter = currentCount; 36 this.objectsEvicted = targetObjects4GC; 37 state = COMPLETE; 38 } 39 40 public void validate() { 41 Assert.assertTrue(state != PROCESSING); 42 } 43 44 } 45 | Popular Tags |