01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.object.cache;
05:
06: import com.tc.util.Assert;
07: import com.tc.util.State;
08:
09: 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,
34: List targetObjects4GC) {
35: this .evicted = evictedCount;
36: this .countAfter = currentCount;
37: this .objectsEvicted = targetObjects4GC;
38: state = COMPLETE;
39: }
40:
41: public void validate() {
42: Assert.assertTrue(state != PROCESSING);
43: }
44:
45: }
|