|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.w3c.www.protocol.http.cache.CacheFilter
Field Summary | |
static java.lang.String |
CACHE_CONNECTED_P
Name of the property indicating wether the cache is connected or not. |
static java.lang.String |
CACHE_DIRECTORY_P
Name of the property giving the cache's directory. |
static java.lang.String |
CACHE_SIZE_P
The name of the properties indicating the size of the cache (in bytes). |
protected static int |
CACHEDIR_SPLITS
Number of sub-levels file system directories in the cache directory. |
protected boolean |
connected
Is this cache connected ? |
protected boolean |
debug
The debug flag. |
static java.lang.String |
DEBUG_P
Name of the property indicating if the cache is in debug mode. |
protected java.io.File |
directory
The directory where the cache is stored. |
protected long |
expires_drift
The expires drift. |
static java.lang.String |
FILE_SIZE_RATIO_P
Name of the property indicating the max size for files to be cached. |
protected double |
fileSizeRatio
The file size quota. |
static java.lang.String |
GARBAGE_COLLECTION_ENABLED_P
Name of the property enabling garbage collection of the cache. |
protected boolean |
garbageCollectionEnabled
Should we enable garbage collection of the cache ? |
static java.lang.Integer |
HOW_HIT
STATE_HOW value - Indicates request fulfilled through a hot. |
static java.lang.Integer |
HOW_MISS
STATE_HOW value - Indicates request fulfilled through a miss. |
static java.lang.Integer |
HOW_REVALIDATION_FAILURE
STATE_HOW value - indicates request fulfilled through unsucessfull revalidation. |
static java.lang.Integer |
HOW_REVALIDATION_SUCCESS
STATE_HOW value - indicates request fulfilled through sucessfull revalidation. |
protected ObservableProperties |
props
The properties we initialized ourself from. |
protected boolean |
shared
Is this cached shared ? |
static java.lang.String |
SHARED_P
Name of the property indicating if this cache is shared. |
protected int |
size
The current cache size. |
static java.lang.String |
STATE_CACHABLE
Name of the property that indicates that the cache cab be used. |
static java.lang.String |
STATE_HOW
Logging state - for some logger to keep track of what's happening. |
static java.lang.String |
STATE_NOCACHE
The state used to disable that filter per request. |
static java.lang.String |
STATE_ORIGREQ
Name of the request state used tokeep track of original request |
static java.lang.String |
STATE_RESOURCE
|
static java.lang.String |
STATE_REVALIDATION
Name of the request state that marks a request as being a revalidation. |
static java.lang.String |
STATE_WARNINGS
Name of the request state used to collect warnings. |
protected cacheStatistics |
stats
Our real time statistics. |
protected static HttpWarning |
WARN_DISCONNECTED
The HTTP warning used to notify of a disconnected cache. |
protected static HttpWarning |
WARN_HEURISTIC
The HTTP warning used to indicate a heuristic expiration time. |
protected static HttpWarning |
WARN_STALE
The HTTP warning used to mark invalid entries |
Constructor Summary | |
CacheFilter()
|
Method Summary | |
protected void |
addWarning(Request request,
HttpWarning warning)
Add a warning, to be emitted at reply time. |
boolean |
canCache(Request request,
Reply reply)
Can the given reply to the given request be added to the cache. |
boolean |
canUseCache(Request request)
Can the given request be fullfilled by the cache filter ? This method distinguishes two situations. |
protected boolean |
checkCacheDirectory(java.io.File dir)
|
boolean |
exceptionFilter(Request request,
HttpException ex)
This filter doesn't handle exceptions. |
int |
getCacheSize()
Get the total size allocated to the cache. |
protected java.io.File |
getFile(java.net.URL url)
Get a file to save that URL in. |
static java.lang.String |
getHow(Request request)
Returns a String indicating what the cache did with that request. |
cacheStatistics |
getStatistics()
Get the statistics repository associated with that filter. |
protected java.io.File |
getSubdirectory(int i)
|
boolean |
hasResource(java.lang.String url)
Does the cache knows about this resource ? |
Reply |
ingoingFilter(Request request)
|
void |
initialize(HttpManager manager)
Initialize a new reuqest manager. |
boolean |
isConnected()
Is this cache connected to the net ? |
boolean |
isGarbageCollectionEnabled()
Are we allow to run garbage collections at all ? |
boolean |
isShared()
Is this cache shared among multiple users ? |
CachedResource |
loadResource(java.lang.String url)
Try to load from the cache the resource's whose URL is gievn. |
protected void |
markUsed(CachedResource resource)
|
protected void |
markUsed(CachedResource resource,
int nsize)
|
protected void |
markUsed(CachedResource resource,
int osize,
int nsize)
Mark the given cached resource as having been used recently. |
Reply |
outgoingFilter(Request request,
Reply reply)
|
boolean |
propertyChanged(java.lang.String name)
PropertyMonitoring implementation - Commit property changes. |
void |
pushDocument(Request request,
Reply reply)
Push a document in the cache. |
void |
removeResource(java.lang.String urlloc)
Remove a resource from the cache. |
protected void |
setWarnings(Request request,
Reply reply)
Copy all warnings colllected into the given reply. |
void |
sync()
Save all cache related infos to stable storage. |
protected void |
trace(Request request,
java.lang.String msg)
|
protected void |
updateCacheSpaceCounter(int delta)
|
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
protected static final int CACHEDIR_SPLITS
public static final java.lang.Integer HOW_HIT
public static final java.lang.Integer HOW_MISS
public static final java.lang.Integer HOW_REVALIDATION_SUCCESS
public static final java.lang.Integer HOW_REVALIDATION_FAILURE
public static final java.lang.String STATE_HOW
public static final java.lang.String STATE_NOCACHE
public static final java.lang.String STATE_WARNINGS
public static final java.lang.String STATE_ORIGREQ
public static final java.lang.String STATE_REVALIDATION
public static final java.lang.String STATE_CACHABLE
public static final java.lang.String STATE_RESOURCE
protected static HttpWarning WARN_DISCONNECTED
protected static HttpWarning WARN_STALE
protected static HttpWarning WARN_HEURISTIC
public static final java.lang.String CACHE_SIZE_P
This property defaults to 5000000 bytes.
public static final java.lang.String DEBUG_P
This property defaults to false.
public static final java.lang.String SHARED_P
This property defaults to true.
public static final java.lang.String CACHE_DIRECTORY_P
public static final java.lang.String CACHE_CONNECTED_P
public static final java.lang.String GARBAGE_COLLECTION_ENABLED_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.
protected ObservableProperties props
protected java.io.File directory
protected int size
protected boolean debug
protected boolean shared
protected boolean connected
protected boolean garbageCollectionEnabled
protected double fileSizeRatio
Indicates the percentage of cache size allowed to be occupied by a single file. This is not taken into account when garbage collection is disabled.
protected long expires_drift
Control if we will cache already expires documents, in the hope that revalidation will be enough to refresh them, or also because the cache will be used in disconnected mode.
protected cacheStatistics stats
Constructor Detail |
public CacheFilter()
Method Detail |
protected void addWarning(Request request, HttpWarning warning)
During request processing, cached resources can add any kind of warnings, which will be collected and forwarded back to the reply.
request
- The request being process, and whose reply requires
some warnings.warning
- The warning to be emitted if ever we use the cache
filter to answer the above request.protected final void setWarnings(Request request, Reply reply)
request
- The request that has been processed by the cache filter.reply
- The reply that has been constructed from the cache.addWarning(org.w3c.www.protocol.http.Request, org.w3c.www.http.HttpWarning)
protected final void trace(Request request, java.lang.String msg)
protected final void updateCacheSpaceCounter(int delta)
public static java.lang.String getHow(Request request)
request
- A request that may have been processed through the cache
filterpublic final boolean isShared()
public final boolean isConnected()
public final boolean isGarbageCollectionEnabled()
protected java.io.File getFile(java.net.URL url)
url
- The URL to be dumped.protected void markUsed(CachedResource resource, int osize, int nsize)
resource
- The CachedResource instance that has been used.protected void markUsed(CachedResource resource, int nsize)
protected void markUsed(CachedResource resource)
protected boolean checkCacheDirectory(java.io.File dir)
protected java.io.File getSubdirectory(int i)
public boolean propertyChanged(java.lang.String name)
name
- The name of the property that has changed.public final int getCacheSize()
public void initialize(HttpManager manager) throws PropRequestFilterException
manager
- The manager to initialize.public cacheStatistics getStatistics()
public CachedResource loadResource(java.lang.String url) throws InvalidResourceException
url
- The String version of the url of the resource to load.CachedResource
(or one of its
subclasses), or null if not found.public boolean hasResource(java.lang.String url)
public void removeResource(java.lang.String urlloc)
urlloc
- The URL of the resource to remove, encoded as a String.public boolean canUseCache(Request request)
org.w3c.www.protocol.http.cache
state of the request to Boolean.TRUE, ans we return
true.public boolean canCache(Request request, Reply reply)
We don't check for expires or maxage here, since we expect some sites to use negative expires, or zero max age, just for the sake of revalidation (that's fine).
public boolean exceptionFilter(Request request, HttpException ex)
request
- The request that triggered the exception.ex
- The triggered exception.public Reply ingoingFilter(Request request) throws HttpException
public Reply outgoingFilter(Request request, Reply reply) throws HttpException
public void pushDocument(Request request, Reply reply)
It is recommended that the reply provides at least the following informations:
public void sync()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |