|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.w3c.www.protocol.http.cache.CacheStore
public class CacheStore
Field Summary | |
---|---|
static java.lang.String |
CACHE_DIRECTORY_P
Name of the property giving the cache's directory. |
static java.lang.String |
FILE_SIZE_RATIO_P
Name of the property indicating the max size for files to be cached. |
static java.lang.String |
GARBAGE_COLLECTION_ENABLED_P
Name of the property enabling garbage collection of the cache. |
static java.lang.String |
GARBAGE_COLLECTION_THRESHOLD_P
Name of the property used to knkow the percentage of bytes to be kept after a garbage collection It defaults to 0.80 (80% of the cache size) |
static java.lang.String |
GENERATION_COMPACT_DELAY_P
Name of the property indicating the amount of time in second between two attempts to compact generations. |
static java.lang.String |
GENERATION_FILENAME
|
static java.lang.String |
MAX_CACHED_RESOURCES_P
Name of the property indicating the maximal number of resources the cache can load in memory (not the content of the resources) |
static java.lang.String |
MAX_GENERATIONS_P
Name of the property indicating the maximal number of generations in this cache store |
protected ObservableProperties |
props
The properties we initialized ourself from. |
static java.lang.String |
STORE_SIZE_P
The name of the properties indicating the storesize of the cache (in bytes). |
static java.lang.String |
SYNCHRONIZATION_DELAY_P
Name of the property indicating the amount of time in second between two synchronization of the database (aka dump on disk) Milliseconds |
Constructor Summary | |
---|---|
CacheStore()
|
Method Summary | |
---|---|
protected CacheGeneration |
addNewGeneration()
Create and add a new Generation. |
protected void |
checkDirs()
Check the subdirectories. |
protected void |
checkState()
used for debugging, display some internal information about the state of the cache |
protected int |
cleanCacheDir()
Clean the Cache directory, remove unused files. |
protected void |
compactGenerations()
Compact our generations The algorithm is the following, If the number of generation is the maximum number allowed, then a check is done from the the generation after the MRU one and if the sum of two generation can fit into one, it is done, and the generation is removed from the list |
long |
getCachedByteCount()
get the cached size of this cache |
long |
getCachedByteFree()
get the number of bytes available for the cache memory |
CachedResource |
getCachedResource(CachedResource cr)
extract a cached resource from the store |
CachedResource |
getCachedResource(java.lang.String url)
Get a cached resource relative to the given URL. |
CachedResource |
getCachedResourceReference(java.lang.String url)
Get a cached resource relative to the given URL. |
long |
getCompactGenerationDelay()
Get the delay between two attempts to compact the generations. |
CacheGeneration |
getLRUGeneration()
Get the LRU generation, ie the Least recently used generation |
CacheGeneration |
getLRULoadedGeneration()
Get the oldest loaded generation |
CacheGeneration |
getMRUGeneration()
Get the last generation, ie the Most recently used generation |
float |
getMRUGenerationRatio()
Get the fill ratio of the last generation (the most recently used) |
protected java.io.File |
getNewEntryFile()
allocate a new name for the next cached resource. |
CacheGeneration |
getNextGeneration(CacheGeneration gen)
Get the next generation (in LRU order). |
CacheGeneration |
getPrevGeneration(CacheGeneration gen)
Get the previous generation (in LRU order). |
long |
getRequiredByteNumber()
get the number of bytes the garbage collector needs to collect to keep the cache in good state, it will only move the resource to the delete list, another check has to be done to save physical space |
CacheSerializer |
getSerializer()
return the serializer used by the cache |
StoreState |
getState()
|
long |
getStoredByteCount()
get the number of bytes used phisycally by this cache |
CacheSweeper |
getSweeper()
return the cache sweeper used by the cache |
long |
getSyncDelay()
Get the synchronization delay between to sync, in milliseconds |
CacheValidator |
getValidator()
return the cache validator used by the cache |
void |
initialize(CacheFilter filter)
initialize this CacheStore, and get some infos from the parent, aka the cache filter |
protected CacheGeneration |
loadGeneration(CacheGeneration cg)
Load the given generation and unload the LRU loaded generation if necessary. |
protected void |
loadGenerations()
Load the generations. |
protected void |
loadState()
Load the store state |
boolean |
propertyChanged(java.lang.String name)
Property monitoring for the CacheStore. |
protected void |
removeResource(CacheGeneration cg,
CachedResource cr)
Remove the given CachedResource from the given CacheGeneration. |
protected void |
resizeGeneration(CacheGeneration cg,
CachedResource cr)
Resize the generation in order to be able to store the given Resource. |
protected void |
saveGeneration(CacheGeneration cg)
Save a generation. |
protected void |
saveState()
Save the current state |
boolean |
storeCachedResource(CachedResource cr)
Store a newly created (or updated) CachedResource. |
boolean |
storeCachedResource(CachedResource cr,
long oldsize)
Store a newly created (or updated) CachedResource. |
void |
sync()
synchronize the internal database with the storage |
java.lang.String |
toString()
|
protected void |
unloadGeneration(CacheGeneration cg)
UnLoad a "loaded" generation. |
CachedResource |
updateResourceGeneration(CachedResource cr)
update this cached resource from generation x ot the latest |
protected void |
updateSweeperPriority()
update the mode of the sweeper according to the state of the cache store, |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String CACHE_DIRECTORY_P
public static final java.lang.String STORE_SIZE_P
This property defaults to 20 Mbytes.
public static final java.lang.String GARBAGE_COLLECTION_THRESHOLD_P
public static final java.lang.String FILE_SIZE_RATIO_P
The ratio should be given as a floating point value between 0 and 1. If set to 0.1 and the cache size is 5000000, files larger then 500000 will not be cached (except if garbage collection is disbabled).
This property defaults to 0.1. Note that the generation size will be taken from this threshold
public static final java.lang.String GARBAGE_COLLECTION_ENABLED_P
public static final java.lang.String SYNCHRONIZATION_DELAY_P
public static final java.lang.String GENERATION_COMPACT_DELAY_P
public static final java.lang.String MAX_CACHED_RESOURCES_P
public static final java.lang.String MAX_GENERATIONS_P
public static final java.lang.String GENERATION_FILENAME
protected ObservableProperties props
Constructor Detail |
---|
public CacheStore()
Method Detail |
---|
public boolean propertyChanged(java.lang.String name)
propertyChanged
in interface PropertyMonitoring
name
- The name of the property that has changed.
public StoreState getState()
public CacheSweeper getSweeper()
public CacheSerializer getSerializer()
public CacheValidator getValidator()
public CacheGeneration getNextGeneration(CacheGeneration gen)
gen
- the current generation
public CacheGeneration getPrevGeneration(CacheGeneration gen)
gen
- the current generation
public CacheGeneration getMRUGeneration()
public float getMRUGenerationRatio()
public CacheGeneration getLRUGeneration()
public CacheGeneration getLRULoadedGeneration()
public long getSyncDelay()
public long getCompactGenerationDelay()
protected CacheGeneration addNewGeneration() throws InvalidCacheException
InvalidCacheException
- if the cache is corruptedprotected CacheGeneration loadGeneration(CacheGeneration cg) throws InvalidCacheException
cg
- the generation to load
InvalidCacheException
- if the cache is corruptedprotected void unloadGeneration(CacheGeneration cg) throws InvalidCacheException
the
- loaded generation
InvalidCacheException
- if the cache is corruptedprotected void saveGeneration(CacheGeneration cg) throws InvalidCacheException
the
- generation to be saved
InvalidCacheException
- if the cache is corruptedprotected void loadGenerations() throws InvalidCacheException
InvalidCacheException
protected void loadState()
protected void saveState()
public long getRequiredByteNumber()
public long getCachedByteCount()
public long getStoredByteCount()
public long getCachedByteFree()
public void sync()
protected void removeResource(CacheGeneration cg, CachedResource cr) throws NoSuchResourceException
NoSuchResourceException
- if this resource was not in this
generationpublic CachedResource getCachedResource(java.lang.String url) throws InvalidCacheException
url
- the URL of the CachedResource
InvalidCacheException
- if the cache is corruptedstoreCachedResource(org.w3c.www.protocol.http.cache.CachedResource)
public CachedResource getCachedResource(CachedResource cr) throws InvalidCacheException
the
- cached resource to be extracted
InvalidCacheException
- if the cache is corruptedprotected void resizeGeneration(CacheGeneration cg, CachedResource cr)
cg
- the generation to resizecr
- the CachedResource to store.public CachedResource getCachedResourceReference(java.lang.String url) throws InvalidCacheException
url
- the URL of the CachedResource
InvalidCacheException
- if the cache is corruptedstoreCachedResource(org.w3c.www.protocol.http.cache.CachedResource)
public CachedResource updateResourceGeneration(CachedResource cr) throws InvalidCacheException
the
- cached resource to be updated
InvalidCacheException
- if the cache is corruptedpublic boolean storeCachedResource(CachedResource cr) throws InvalidCacheException
cr
- the CachedResource to store
true
if the resource has been cached
InvalidCacheException
- if the cache is corruptedpublic boolean storeCachedResource(CachedResource cr, long oldsize) throws InvalidCacheException
cr
- the CachedResource to store
true
if the resource has been cached
InvalidCacheException
- if the cache is corruptedprotected java.io.File getNewEntryFile()
public java.lang.String toString()
toString
in class java.lang.Object
protected void checkDirs()
protected int cleanCacheDir()
protected void updateSweeperPriority()
protected void compactGenerations()
protected void checkState()
public void initialize(CacheFilter filter) throws InvalidCacheException
filter
- a CacheFilter, our parent
InvalidCacheException
- if the cache not initialized
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |