|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.grizzly.http.FileCache
public class FileCache
This class implements a file caching mechanism used to cache static resources.
Nested Class Summary | |
---|---|
class |
FileCache.FileCacheEntry
|
Field Summary | |
---|---|
protected static ByteBuffer |
connectionCloseBB
A connection: close of ByteBuffer |
protected static ByteBuffer |
connectionKaBB
A connection: keep-alive of ByteBuffer |
static String |
DEFAULT_SERVLET_NAME
|
protected static ByteBuffer |
nullByteBuffer
A dummy instance of ByteBuffer |
static String |
OK
HTTP OK header |
static int |
SC_NOT_MODIFIED
Status code (304) indicating that a conditional GET operation found that the resource was available and not modified. |
static int |
SC_PRECONDITION_FAILED
Status code (412) indicating that the precondition given in one or more of the request-header fields evaluated to false when it was tested on the server. |
Constructor Summary | |
---|---|
FileCache()
|
Method Summary | |
---|---|
void |
add(String mappedServlet,
String baseDir,
String requestURI,
String host,
MimeHeaders headers,
boolean xPoweredBy)
Add a resource to the cache. |
protected void |
addHeapSize(long size)
|
protected void |
addMappedMemorySize(long size)
|
protected boolean |
checkIfHeaders(Request request,
FileCache.FileCacheEntry entry)
Check if the conditions specified in the optional If headers are satisfied. |
protected boolean |
checkIfMatch(Request request,
FileCache.FileCacheEntry entry)
Check if the if-match condition is satisfied. |
protected boolean |
checkIfUnmodifiedSince(Request request,
FileCache.FileCacheEntry entry)
Check if the if-unmodified-since condition is satisfied. |
protected void |
countContentHit()
|
protected void |
countContentMiss()
|
protected void |
countHit()
|
protected void |
countInfoHit()
|
protected void |
countInfoMiss()
|
protected void |
countMiss()
|
protected void |
decOpenCacheEntries()
|
InetAddress |
getAddress()
|
ConcurrentHashMap<String,FileCache.FileCacheEntry> |
getCache()
Return the FileCache |
long |
getCountContentHits()
Return the Number of hits on cached file content |
int |
getCountContentMisses()
Return the Number of misses on cached file content |
long |
getCountEntries()
Return the number of current cache entries. |
long |
getCountHits()
Return the Number of cache lookup hits |
long |
getCountInfoHits()
The Number of hits on cached file info |
long |
getCountInfoMisses()
Return the number of misses on cached file info |
long |
getCountMisses()
Return the Number of cache lookup misses |
long |
getCountOpenEntries()
The number of current open cache entries |
int |
getFlagEnabled()
Returns flag indicating whether file cache has been enabled |
int |
getHeaderBBSize()
Retunr the header size buffer. |
boolean |
getLargeFileCacheEnabled()
Is the large file cache support enabled. |
int |
getMaxCacheEntries()
Return the maximum entries this cache can contains. |
long |
getMaxEntries()
Return the maximum number of cache entries |
long |
getMaxEntrySize()
Get the maximum size a FileCache.FileCacheEntry can have. |
long |
getMaxHeapCacheSize()
Return the maximum heap space used for cache |
long |
getMaxLargeCacheSize()
Get the maximum cache size |
long |
getMaxMmapCacheSize()
Return the Maximum Memory Map size to be used for caching |
long |
getMaxOpenEntries()
Return the maximum number of open cache entries |
long |
getMaxSmallCacheSize()
Get the maximum cache size |
long |
getMinEntrySize()
Get the maximum size a FileCache.FileCacheEntry can have. |
int |
getPort()
|
int |
getSecondsMaxAge()
Return the maximum age of a valid cache entry |
long |
getSizeHeapCache()
Return the heap space used for cache |
long |
getSizeMmapCache()
Return the size of Mapped memory used for caching |
protected void |
incOpenCacheEntries()
|
boolean |
isEnabled()
Is the fileCache enabled. |
protected FileCache.FileCacheEntry |
map(Request request)
Return true if the file is cached. |
protected void |
recalcCacheStats(FileCache.FileCacheEntry entry)
|
protected void |
recalcCacheStatsIfMonitoring(FileCache.FileCacheEntry entry)
|
boolean |
sendCache(Request req)
Send the cache. |
protected void |
sendCache(Request request,
FileCache.FileCacheEntry entry)
Send the cached resource. |
void |
setAddress(InetAddress address)
Associates the specified network address with this cache instance. |
void |
setCacheManager(Queue<FileCache.FileCacheEntry> cacheManager)
Set the cache manager used by this instance. |
void |
setHeaderBBSize(int headerBBSize)
Set the size of the header ByteBuffer. |
void |
setIsEnabled(boolean isEnabled)
Is the file caching mechanism enabled. |
void |
setIsMonitoringEnabled(boolean isMe)
Turn monitoring on/off |
void |
setLargeFileCacheEnabled(boolean isLargeEnabled)
Is the large file cache support enabled. |
void |
setMaxCacheEntries(int mEntries)
Set the maximum entries this cache can contains. |
void |
setMaxEntrySize(long mEntrySize)
Set the maximum size a FileCache.FileCacheEntry can have. |
void |
setMaxLargeCacheSize(long mCacheSize)
Set the maximum cache size |
void |
setMaxSmallCacheSize(long mCacheSize)
Set the maximum cache size |
void |
setMinEntrySize(long mSize)
Set the maximum size a FileCache.FileCacheEntry can have. |
void |
setPort(int port)
|
void |
setSecondsMaxAge(int sMaxAges)
The timeout in seconds before remove a FileCache.FileCacheEntry
from the FileCache |
protected void |
subHeapSize(long size)
|
protected void |
subMappedMemorySize(long size)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String DEFAULT_SERVLET_NAME
protected static final ByteBuffer nullByteBuffer
ByteBuffer
protected static final ByteBuffer connectionCloseBB
ByteBuffer
protected static final ByteBuffer connectionKaBB
ByteBuffer
public static final String OK
public static final int SC_NOT_MODIFIED
public static final int SC_PRECONDITION_FAILED
Constructor Detail |
---|
public FileCache()
Method Detail |
---|
public void add(String mappedServlet, String baseDir, String requestURI, String host, MimeHeaders headers, boolean xPoweredBy)
protected final FileCache.FileCacheEntry map(Request request)
protected void recalcCacheStatsIfMonitoring(FileCache.FileCacheEntry entry)
protected final void recalcCacheStats(FileCache.FileCacheEntry entry)
public boolean sendCache(Request req)
public void setCacheManager(Queue<FileCache.FileCacheEntry> cacheManager)
protected void sendCache(Request request, FileCache.FileCacheEntry entry) throws IOException
IOException
public int getPort()
public void setPort(int port)
port
- the port to setpublic InetAddress getAddress()
public void setAddress(InetAddress address)
Associates the specified network address with this cache instance.
address
- the network addresspublic int getFlagEnabled()
public int getSecondsMaxAge()
public long getCountEntries()
public long getMaxEntries()
protected void incOpenCacheEntries()
protected void decOpenCacheEntries()
public long getCountOpenEntries()
public long getMaxOpenEntries()
protected void addHeapSize(long size)
protected void subHeapSize(long size)
public long getSizeHeapCache()
public long getMaxHeapCacheSize()
protected void addMappedMemorySize(long size)
protected void subMappedMemorySize(long size)
public long getSizeMmapCache()
public long getMaxMmapCacheSize()
protected void countHit()
public long getCountHits()
protected void countMiss()
public long getCountMisses()
protected void countInfoHit()
public long getCountInfoHits()
protected void countInfoMiss()
public long getCountInfoMisses()
protected void countContentHit()
public long getCountContentHits()
protected void countContentMiss()
public int getCountContentMisses()
public void setIsMonitoringEnabled(boolean isMe)
public void setSecondsMaxAge(int sMaxAges)
FileCache.FileCacheEntry
from the FileCache
public void setMaxCacheEntries(int mEntries)
public int getMaxCacheEntries()
public void setMinEntrySize(long mSize)
FileCache.FileCacheEntry
can have.
public long getMinEntrySize()
FileCache.FileCacheEntry
can have.
public void setMaxEntrySize(long mEntrySize)
FileCache.FileCacheEntry
can have.
public long getMaxEntrySize()
FileCache.FileCacheEntry
can have.
public void setMaxLargeCacheSize(long mCacheSize)
public long getMaxLargeCacheSize()
public void setMaxSmallCacheSize(long mCacheSize)
public long getMaxSmallCacheSize()
public boolean isEnabled()
public void setIsEnabled(boolean isEnabled)
public void setLargeFileCacheEnabled(boolean isLargeEnabled)
public boolean getLargeFileCacheEnabled()
public ConcurrentHashMap<String,FileCache.FileCacheEntry> getCache()
public int getHeaderBBSize()
public void setHeaderBBSize(int headerBBSize)
protected boolean checkIfUnmodifiedSince(Request request, FileCache.FileCacheEntry entry) throws IOException
IOException
protected boolean checkIfHeaders(Request request, FileCache.FileCacheEntry entry) throws IOException
IOException
protected boolean checkIfMatch(Request request, FileCache.FileCacheEntry entry) throws 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
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |