01: // CacheSweeper.java
02: // $Id: CacheSweeper.java,v 1.25 2000/08/16 21:38:03 ylafon Exp $
03: // (c) COPYRIGHT MIT, INRIA and Keio, 1999.
04: // Please first read the full copyright statement in file COPYRIGHT.html
05:
06: package org.w3c.www.protocol.http.cache;
07:
08: public abstract class CacheSweeper extends Thread {
09: // the states are used for the timed calls to the collect methods
10:
11: // clean only the deleted resources
12: protected static final int STATE_CLEAN_STORED = 1;
13: // force the deletion of the maximum number of deleted resources
14: protected static final int STATE_FORCE_CLEAN_STORED = 2;
15: // delete resources and clean stale cached resources
16: protected static final int STATE_CLEAN_GENERATIONS = 3;
17: // get space as fast as it can, and wipe them out as fast as possible
18: protected static final int STATE_FORCE_CLEAN_GENERATIONS = 4;
19:
20: /**
21: * Used to trigger a signal
22: */
23: public abstract void signal();
24:
25: /**
26: * change the state of the Sweeper
27: * @param an integer, setting the new cache state
28: */
29: protected abstract void setState(int state);
30:
31: /**
32: * collect the still stored resources (disk)
33: * @param generation, the CacheGeneration to clean
34: */
35: protected abstract void collectStored(CacheGeneration generation);
36:
37: /**
38: * collect the still stored resources (disk)
39: * in the whole cache
40: */
41: protected abstract void collectStored();
42:
43: /**
44: * collect the existing resources
45: * @param generation, the CacheGeneration to clean
46: * @param bytes, a long. The number of bytes to collect
47: * @param check, a boolean. If true, then only the stale resources
48: * will be removed
49: * @return a long, the number of collected bytes
50: */
51: protected abstract long collectCached(CacheGeneration generation,
52: long bytes, boolean check);
53:
54: /**
55: * collect the existing resources
56: * @param bytes, a long. The number of bytes to collect
57: * @param check, a boolean. If true, then only the stale resources
58: * will be removed
59: * @return a long, the number of collected bytes
60: */
61: protected abstract long collectCached(long bytes, boolean check);
62:
63: /**
64: * initialize the sweeper
65: */
66: public abstract void initialize(CacheFilter filter);
67: }
|