KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > object > cache > TestCacheStats


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

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 JavaDoc;
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 JavaDoc 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 JavaDoc 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