|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.glassfish.grizzly.http.server.filecache.FileCache
public class FileCache
This class implements a file caching mechanism used to cache static resources.
| Nested Class Summary | |
|---|---|
static class |
FileCache.CacheType
|
| Field Summary | |
|---|---|
protected AbstractJmxMonitoringConfig<FileCacheProbe> |
monitoringConfig
File cache probes |
| Constructor Summary | |
|---|---|
FileCache()
|
|
| Method Summary | |
|---|---|
void |
add(HttpRequestPacket request,
java.io.File cacheFile)
Add a resource to the cache. |
protected long |
addHeapSize(long size)
|
protected long |
addMappedMemorySize(long size)
|
protected boolean |
checkIfHeaders(FileCacheEntry entry,
HttpRequestPacket request)
Check if the conditions specified in the optional If headers are satisfied. |
protected boolean |
checkIfMatch(FileCacheEntry entry,
HttpRequestPacket request)
Check if the if-match condition is satisfied. |
protected boolean |
checkIfUnmodifiedSince(FileCacheEntry entry,
HttpRequestPacket request)
Check if the if-unmodified-since condition is satisfied. |
protected JmxObject |
createJmxManagementObject()
|
HttpPacket |
get(HttpRequestPacket request)
Send the cache. |
long |
getHeapCacheSize()
Return the heap space used for cache |
long |
getMappedCacheSize()
Return the size of Mapped memory used for caching |
int |
getMaxCacheEntries()
|
long |
getMaxEntrySize()
|
long |
getMaxLargeFileCacheSize()
|
long |
getMaxSmallFileCacheSize()
|
long |
getMinEntrySize()
|
JmxMonitoringConfig<FileCacheProbe> |
getMonitoringConfig()
|
int |
getSecondsMaxAge()
|
void |
initialize(MemoryManager memoryManager,
DelayedExecutor delayedExecutor)
|
boolean |
isEnabled()
|
protected HttpPacket |
makeResponse(FileCacheEntry entry,
HttpRequestPacket request)
Send the cached resource. |
protected static void |
notifyProbesEntryAdded(FileCache fileCache,
FileCacheEntry entry)
Notify registered FileCacheProbes about the "entry added" event. |
protected static void |
notifyProbesEntryHit(FileCache fileCache,
FileCacheEntry entry)
Notify registered FileCacheProbes about the "entry hit event. |
protected static void |
notifyProbesEntryMissed(FileCache fileCache,
HttpRequestPacket request)
Notify registered FileCacheProbes about the "entry missed" event. |
protected static void |
notifyProbesEntryRemoved(FileCache fileCache,
FileCacheEntry entry)
Notify registered FileCacheProbes about the "entry removed" event. |
protected static void |
notifyProbesError(FileCache fileCache,
java.lang.Throwable error)
Notify registered FileCacheProbes about the error. |
protected void |
remove(FileCacheEntry entry)
|
void |
setEnabled(boolean enabled)
Enables/disables the FileCache. |
void |
setMaxCacheEntries(int maxCacheEntries)
Sets the maximum number of files that may be cached. |
void |
setMaxEntrySize(long maxEntrySize)
The maximum size, in bytes, a resource may be before it can no longer be considered cachable. |
void |
setMaxLargeFileCacheSize(long maxLargeFileCacheSize)
Sets the maximum size, in bytes, of the memory mapped cache for large files. |
void |
setMaxSmallFileCacheSize(long maxSmallFileCacheSize)
The maximum size, in bytes, of the heap cache for files below the water mark set by getMinEntrySize(). |
void |
setMinEntrySize(long minEntrySize)
The maximum size, in bytes, a file must be in order to be cached in the heap cache. |
void |
setSecondsMaxAge(int secondsMaxAge)
Sets the maximum time, in seconds, a file may be cached. |
protected long |
subHeapSize(long size)
|
protected long |
subMappedMemorySize(long size)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final AbstractJmxMonitoringConfig<FileCacheProbe> monitoringConfig
| Constructor Detail |
|---|
public FileCache()
| Method Detail |
|---|
public void initialize(MemoryManager memoryManager,
DelayedExecutor delayedExecutor)
public void add(HttpRequestPacket request,
java.io.File cacheFile)
public HttpPacket get(HttpRequestPacket request)
protected void remove(FileCacheEntry entry)
protected JmxObject createJmxManagementObject()
protected HttpPacket makeResponse(FileCacheEntry entry,
HttpRequestPacket request)
throws java.io.IOException
java.io.IOExceptionpublic int getSecondsMaxAge()
public void setSecondsMaxAge(int secondsMaxAge)
secondsMaxAge - max age of a cached file, in seconds.public int getMaxCacheEntries()
public void setMaxCacheEntries(int maxCacheEntries)
maxCacheEntries - the maximum number of files that may be cached.public long getMinEntrySize()
public void setMinEntrySize(long minEntrySize)
minEntrySize - the maximum size, in bytes, a file must be in order
to be cached in the heap cache.public long getMaxEntrySize()
public void setMaxEntrySize(long maxEntrySize)
maxEntrySize - the maximum size, in bytes, a resource may be before it can no
longer be considered cachable.public long getMaxLargeFileCacheSize()
public void setMaxLargeFileCacheSize(long maxLargeFileCacheSize)
maxLargeFileCacheSize - the maximum size, in bytes, of the memory
mapped cache for large files.public long getMaxSmallFileCacheSize()
getMinEntrySize().public void setMaxSmallFileCacheSize(long maxSmallFileCacheSize)
getMinEntrySize().
maxSmallFileCacheSize - the maximum size, in bytes, of the heap
cache for files below the water mark set by getMinEntrySize().public boolean isEnabled()
true if the FileCache is enabled,
otherwise falsepublic void setEnabled(boolean enabled)
FileCache. By default, the
FileCache is disabled.
enabled - true to enable the FileCache.protected final long addHeapSize(long size)
protected final long subHeapSize(long size)
public long getHeapCacheSize()
protected final long addMappedMemorySize(long size)
protected final long subMappedMemorySize(long size)
public long getMappedCacheSize()
protected boolean checkIfHeaders(FileCacheEntry entry,
HttpRequestPacket request)
throws java.io.IOException
java.io.IOException
protected boolean checkIfUnmodifiedSince(FileCacheEntry entry,
HttpRequestPacket request)
throws java.io.IOException
java.io.IOException
protected boolean checkIfMatch(FileCacheEntry entry,
HttpRequestPacket request)
throws java.io.IOException
request - The servlet request we are processingentry - the FileCacheEntry to validate
true if the resource meets the specified condition,
and false if the condition is not satisfied, in which case request
processing is stopped
java.io.IOExceptionpublic JmxMonitoringConfig<FileCacheProbe> getMonitoringConfig()
getMonitoringConfig in interface JmxMonitoringAware<FileCacheProbe>getMonitoringConfig in interface MonitoringAware<FileCacheProbe>
protected static void notifyProbesEntryAdded(FileCache fileCache,
FileCacheEntry entry)
FileCacheProbes about the "entry added" event.
fileCache - the FileCache event occurred on.entry - entry been added
protected static void notifyProbesEntryRemoved(FileCache fileCache,
FileCacheEntry entry)
FileCacheProbes about the "entry removed" event.
fileCache - the FileCache event occurred on.entry - entry been removed
protected static void notifyProbesEntryHit(FileCache fileCache,
FileCacheEntry entry)
FileCacheProbes about the "entry hit event.
fileCache - the FileCache event occurred on.entry - entry been hit.
protected static void notifyProbesEntryMissed(FileCache fileCache,
HttpRequestPacket request)
FileCacheProbes about the "entry missed" event.
fileCache - the FileCache event occurred on.request - HTTP request.
protected static void notifyProbesError(FileCache fileCache,
java.lang.Throwable error)
FileCacheProbes about the error.
fileCache - the FileCache event occurred on.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||