FileDocCategorySizeDatePackage
FileCacheFactory.javaAPI DocGlassfish v2 API13415Fri May 04 22:37:04 BST 2007com.sun.enterprise.web.connector.grizzly

FileCacheFactory

public class FileCacheFactory extends Object
A factory for creating FileCache instance.
author
Jeanfrancois Arcand

Fields Summary
public int
secondsMaxAge
Timeout before remove the static resource from the cache.
public int
maxCacheEntries
The maximum entries in the fileCache
public long
minEntrySize
The maximum size of a cached resources.
public long
maxEntrySize
The maximum size of a cached resources.
public long
maxLargeFileCacheSize
The maximum cached bytes
public long
maxSmallFileCacheSize
The maximum cached bytes
public static boolean
isEnabled
Is the FileCache enabled.
public boolean
isLargeFileCacheEnabled
Is the large FileCache enabled.
public int
port
The port used
protected static final ConcurrentHashMap
cache
Create a factory per port.
protected ConcurrentLinkedQueue
cacheManager
The cache manager used by instance of FileCache created by this factory;
protected boolean
isMonitoringEnabled
Is monitoring enabled
protected FileCache
fileCache
A list of FileCache instance this Factory is owning.
private int
headerBBSize
The Header ByteBuffer default size.
Constructors Summary
protected FileCacheFactory()

    
    // ---------------------------------------------------------------------//
    
    
             
    
Methods Summary
public java.util.concurrent.ConcurrentHashMapgetCache()
Return the FileCache

        if ( fileCache != null ){
            return fileCache.getCache();
        } else {
            return null;
        }
    
public longgetCountContentHits()
Return the Number of hits on cached file content

return
hits on cache file content

        if (fileCache == null) return 0L;
        return fileCache.getCountContentHits();  
    
public longgetCountContentMisses()
Return the Number of misses on cached file content

return
missed on cached file content

        if (fileCache == null) return 0L;
        return fileCache.getCountContentMisses(); 
    
public longgetCountEntries()
Return the number of current cache entries.

return
current cache entries

      
        if (fileCache == null) return 0L;
        return fileCache.getCountEntries();          
    
public longgetCountHits()
Return the Number of cache lookup hits

return
cache hits

        if (fileCache == null) return 0L;
        return fileCache.getCountHits(); 
    
public longgetCountInfoHits()
The Number of hits on cached file info

return
hits on cached file info

        if (fileCache == null) return 0L;
        return fileCache.getCountInfoHits();
    
public longgetCountInfoMisses()
Return the number of misses on cached file info

return
misses on cache file info

        if (fileCache == null) return 0L;
        return fileCache.getCountInfoMisses(); 
    
public longgetCountMisses()
Return the Number of cache lookup misses

return
cache misses

        if (fileCache == null) return 0L;
        return fileCache.getCountMisses();  
    
public longgetCountOpenEntries()
The number of current open cache entries

return
open cache entries

     
        if (fileCache == null) return 0L;
        return fileCache.getCountOpenEntries();      
    
public static com.sun.enterprise.web.connector.grizzly.FileCacheFactorygetFactory(int currentPort)
Return an instance of this Factory.

                
        FileCacheFactory fileCacheFactory = cache.get(currentPort);
        if ( fileCacheFactory == null ){
            fileCacheFactory = newInstance(currentPort); 
        }

        return fileCacheFactory;
    
public FileCachegetFileCache()
Return an instance of a FileCache

        if ( fileCache == null){
            fileCache = new FileCache();
            fileCache.setIsEnabled(isEnabled);
            fileCache.setLargeFileCacheEnabled(isLargeFileCacheEnabled);
            fileCache.setSecondsMaxAge(secondsMaxAge);
            fileCache.setMaxCacheEntries(maxCacheEntries);
            fileCache.setMinEntrySize(minEntrySize);
            fileCache.setMaxEntrySize(maxEntrySize);
            fileCache.setMaxLargeCacheSize(maxLargeFileCacheSize);
            fileCache.setMaxSmallCacheSize(maxSmallFileCacheSize);         
            fileCache.setCacheManager(cacheManager);
            fileCache.setIsMonitoringEnabled(isMonitoringEnabled);
            fileCache.setHeaderBBSize(headerBBSize);
        }
        
        return fileCache;
    
public intgetFlagEnabled()
Returns flag indicating whether file cache has been enabled

return
1 if file cache has been enabled, 0 otherwise

        return (isEnabled == true?1:0);
    
public intgetHeaderBBSize()
Retunr the header size buffer.

        return headerBBSize;
    
public booleangetLargeFileCacheEnabled()
Is the large file cache support enabled.

        return isLargeFileCacheEnabled;
    
public intgetMaxCacheEntries()
Return the maximum entries this cache can contains.

        return maxCacheEntries;
    
public longgetMaxEntries()
Return the maximum number of cache entries

return
maximum cache entries

        if (fileCache == null) return 0L;
        return maxCacheEntries;
    
public longgetMaxEntrySize()
Get the maximum size a FileCacheEntry can have.

        return maxEntrySize;
    
public longgetMaxHeapCacheSize()
Return the maximum heap space used for cache

return
maximum heap size

        if (fileCache == null) return 0L;
        return fileCache.getMaxHeapCacheSize();
    
public longgetMaxLargeCacheSize()
Get the maximum cache size

        return maxLargeFileCacheSize;
    
public longgetMaxMmapCacheSize()
Return the Maximum Memory Map size to be used for caching

return
maximum Memory Map size

        if (fileCache == null) return 0L;
        return fileCache.getMaxMmapCacheSize();   
    
public longgetMaxOpenEntries()
Return the maximum number of open cache entries

return
maximum open cache entries

        if (fileCache == null) return 0L;
        return fileCache.getMaxOpenEntries();
    
public longgetMaxSmallCacheSize()
Get the maximum cache size

        return maxSmallFileCacheSize;
    
public longgetMinEntrySize()
Get the maximum size a FileCacheEntry can have.

        return minEntrySize;
    
public intgetSecondsMaxAge()
Return the maximum age of a valid cache entry

return
cache entry maximum age

        return secondsMaxAge;
    
public longgetSizeHeapCache()
Return the heap space used for cache

return
heap size

        if (fileCache == null) return 0L;
        return fileCache.getSizeHeapCache();
    
public longgetSizeMmapCache()
Return the size of Mapped memory used for caching

return
Mapped memory size

        if (fileCache == null) return 0L;
        return fileCache.getSizeMmapCache();  
    
public static booleanisEnabled()
Is the fileCache enabled.

        return isEnabled;
    
public static com.sun.enterprise.web.connector.grizzly.FileCacheFactorynewInstance(int currentPort)
Configure the factory.

        FileCacheFactory fileCacheFactory= new FileCacheFactory();

        fileCacheFactory.port = currentPort;
        cache.put(currentPort, fileCacheFactory);

        ConcurrentLinkedQueue<FileCacheEntry> cacheManager =
            new  ConcurrentLinkedQueue<FileCacheEntry>();
        fileCacheFactory.setCacheManager(cacheManager);  

        return fileCacheFactory;
    
public voidsetCacheManager(java.util.concurrent.ConcurrentLinkedQueue cacheManager)

        this.cacheManager = cacheManager;
    
public voidsetHeaderBBSize(int headerBBSize)
Set the size of the header ByteBuffer.

        this.headerBBSize = headerBBSize;
    
public static voidsetIsEnabled(boolean isE)
Is the file caching mechanism enabled.

        isEnabled = isE;
    
public voidsetIsMonitoringEnabled(boolean isMonitoringEnabled)
Turn monitoring on/off

        this.isMonitoringEnabled = isMonitoringEnabled;
        FileCache.setIsMonitoringEnabled(isMonitoringEnabled);
    
public voidsetLargeFileCacheEnabled(boolean isLargeEnabled)
Is the large file cache support enabled.

        this.isLargeFileCacheEnabled = isLargeEnabled;
    
public voidsetMaxCacheEntries(int mEntries)
Set the maximum entries this cache can contains.

        maxCacheEntries = mEntries;
    
public voidsetMaxEntrySize(long mEntrySize)
Set the maximum size a FileCacheEntry can have.

        maxEntrySize = mEntrySize;
    
public voidsetMaxLargeCacheSize(long mCacheSize)
Set the maximum cache size

        maxLargeFileCacheSize = mCacheSize;
    
public voidsetMaxSmallCacheSize(long mCacheSize)
Set the maximum cache size

        maxSmallFileCacheSize = mCacheSize;
    
public voidsetMinEntrySize(long mSize)
Set the maximum size a FileCacheEntry can have.

        minEntrySize = mSize;
    
public voidsetSecondsMaxAge(int sMaxAges)
The timeout in seconds before remove a FileCacheEntry from the fileCache

        secondsMaxAge = sMaxAges;