public class FileCache extends Object implements JmxMonitoringAware<FileCacheProbe>
Modifier and Type | Class and Description |
---|---|
static class |
FileCache.CacheResult |
static class |
FileCache.CacheType |
Modifier and Type | Field and Description |
---|---|
protected AbstractJmxMonitoringConfig<FileCacheProbe> |
monitoringConfig
File cache probes
|
Constructor and Description |
---|
FileCache() |
Modifier and Type | Method and Description |
---|---|
FileCache.CacheResult |
add(HttpRequestPacket request,
File cacheFile)
Add a resource to the cache.
|
protected void |
addCachingHeaders(FileCacheEntry entry,
HttpResponsePacket response) |
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 static long |
convertToLong(String dateHeader) |
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()
Return the object associated
JmxMonitoringConfig . |
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
FileCacheProbe s about the "entry added" event. |
protected static void |
notifyProbesEntryHit(FileCache fileCache,
FileCacheEntry entry)
Notify registered
FileCacheProbe s about the "entry hit event. |
protected static void |
notifyProbesEntryMissed(FileCache fileCache,
HttpRequestPacket request)
Notify registered
FileCacheProbe s about the "entry missed" event. |
protected static void |
notifyProbesEntryRemoved(FileCache fileCache,
FileCacheEntry entry)
Notify registered
FileCacheProbe s about the "entry removed" event. |
protected static void |
notifyProbesError(FileCache fileCache,
Throwable error)
Notify registered
FileCacheProbe s 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 cacheable.
|
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) |
protected final AbstractJmxMonitoringConfig<FileCacheProbe> monitoringConfig
public void initialize(MemoryManager memoryManager, DelayedExecutor delayedExecutor)
public FileCache.CacheResult add(HttpRequestPacket request, File cacheFile)
public HttpPacket get(HttpRequestPacket request)
protected void remove(FileCacheEntry entry)
protected JmxObject createJmxManagementObject()
protected HttpPacket makeResponse(FileCacheEntry entry, HttpRequestPacket request) throws IOException
IOException
public 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 cacheable.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 false
public void setEnabled(boolean enabled)
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 IOException
IOException
protected boolean checkIfUnmodifiedSince(FileCacheEntry entry, HttpRequestPacket request) throws IOException
IOException
protected boolean checkIfMatch(FileCacheEntry entry, HttpRequestPacket request) throws IOException
request
- The servlet request we are processingentry
- the FileCacheEntry to validatetrue
if the resource meets the specified condition,
and false if the condition is not satisfied, in which case request
processing is stoppedIOException
public JmxMonitoringConfig<FileCacheProbe> getMonitoringConfig()
JmxMonitoringConfig
.getMonitoringConfig
in interface JmxMonitoringAware<FileCacheProbe>
getMonitoringConfig
in interface MonitoringAware<FileCacheProbe>
JmxMonitoringConfig
.protected static void notifyProbesEntryAdded(FileCache fileCache, FileCacheEntry entry)
FileCacheProbe
s about the "entry added" event.fileCache
- the FileCache event occurred on.entry
- entry been addedprotected static void notifyProbesEntryRemoved(FileCache fileCache, FileCacheEntry entry)
FileCacheProbe
s about the "entry removed" event.fileCache
- the FileCache event occurred on.entry
- entry been removedprotected static void notifyProbesEntryHit(FileCache fileCache, FileCacheEntry entry)
FileCacheProbe
s about the "entry hit event.fileCache
- the FileCache event occurred on.entry
- entry been hit.protected static void notifyProbesEntryMissed(FileCache fileCache, HttpRequestPacket request)
FileCacheProbe
s about the "entry missed" event.fileCache
- the FileCache event occurred on.request
- HTTP request.protected static void notifyProbesError(FileCache fileCache, Throwable error)
FileCacheProbe
s about the error.fileCache
- the FileCache event occurred on.protected static long convertToLong(String dateHeader)
protected void addCachingHeaders(FileCacheEntry entry, HttpResponsePacket response)
Copyright © 2013 Oracle Corporation. All Rights Reserved.