DODS 5.1 API

org.enhydra.dods.cache
Class QueryCacheImpl

java.lang.Object
  |
  +--org.enhydra.dods.cache.QueryCacheImpl
All Implemented Interfaces:
CacheAdministration, QueryCache

public class QueryCacheImpl
extends java.lang.Object
implements QueryCache

This class contains data and mechanisms needed for caching data objects and queries.


Field Summary
protected  LRUCache cache
          LRU cache for storing data objects.
protected  boolean cacheReadOnly
          This attribute contains information if cache is read-only.
protected  LRUCache complexQCache
          Cache for storing complex queries.
protected  boolean fullCaching
          This attribute contains information if the type of caching is "full".
protected  java.lang.String initialQueryCache
          Initial query statement, used for cache initialization.
protected  boolean multi
          This attribute contains information if multi databases are used.
protected  LRUCache simpleQCache
          Cache for storing simple queries.
 
Fields inherited from interface org.enhydra.dods.cache.QueryCache
DEFAULT_MAX_CACHE_SIZE, DEFAULT_MAX_COMPLEX_QUERY_CACHE_SIZE, DEFAULT_MAX_SIMPLE_QUERY_CACHE_SIZE
 
Constructor Summary
QueryCacheImpl()
          Constructor () - creates cache with its default maximal size and simple and complex query caches with their default maximal sizes.
QueryCacheImpl(int maxCSize)
          Constructor (int) - creates cache with maximal size maxCSize and simple and complex query caches with their default maximal sizes.
 
Method Summary
 QueryCacheItem addComplexQuery(QueryCacheItem queryItem)
           
 GenericDO addDO(GenericDO newDO)
           
 QueryCacheItem addSimpleQuery(QueryCacheItem queryItem)
           
protected  void checkFull()
          Checks if this is special type of caching - full caching and updates attribute fullCaching if necessary.
 GenericDO deleteDO(GenericDO DO)
          Deletes DO from simpleQCache and complexQCache
 LRUCache getCache()
          Returns cache.
 java.util.Map getCacheContent()
          Returns cache content.
 boolean getCacheReadOnly()
          Returns read-only attribute.
 int getCacheSize()
          Returns size of currently used cache.
 java.lang.String getCacheType()
          Get cache type.
 int getComplexQueryCacheSize()
          Returns size of currently used complex query cache.
 QueryResult getComplexQueryResults(java.lang.String dbName, java.lang.String query)
           
 GenericDO getDOByHandle(java.lang.String handle)
           
 java.lang.String getInitialQueryCache()
          Returns initialQueryCache.
 int getMaxCacheSize()
          Returns maximum cache size.
 int getMaxCacheSize(boolean real)
          Get maximum cache size.
 int getMaxComplexQueryCacheSize()
          Returns maximum size of complex query cache.
 int getMaxComplexQueryCacheSize(boolean real)
          Gets maximum complex query cache size.
 int getMaxSimpleQueryCacheSize()
          Returns maximum size of simple query cache.
 int getMaxSimpleQueryCacheSize(boolean real)
          Gets maximum simple query cache size.
 QueryResult getQueryResults(java.lang.String dbName, java.lang.String query)
           
 int getSimpleQueryCacheSize()
          Returns size of currently used simple query cache.
 QueryResult getSimpleQueryResults(java.lang.String dbName, java.lang.String query)
           
 boolean isFull()
          Returns
 boolean isMulti()
           
 QueryCacheItem newQueryCacheItemInstance(java.lang.String dbName)
           
 void readConfiguration(com.lutris.util.Config config, com.lutris.util.Config globalConfig)
          Read cache configuration from application's configuration file.
 void refresh()
          Refreshes caches.
 QueryCacheItem removeComplexQuery(QueryCacheItem queryItem)
           
 GenericDO removeDO(GenericDO DO)
          Remove DO from cache.
 GenericDO removeDO(java.lang.String handle)
          Remove DO from cache.
 QueryCacheItem removeSimpleQuery(QueryCacheItem queryItem)
           
 void setCacheReadOnly(boolean readOnly)
          Sets read-only attribute.
 void setInitialQueryCache(java.lang.String initQ)
          Sets initialQueryCache attribute.
 void setMaxCacheSize(int maxSize)
          Sets maximum cache size.
 void setMaxComplexQueryCacheSize(int maxSize)
          Sets maximum size of complex query cache.
 void setMaxSimpleQueryCacheSize(int maxSize)
          Sets maximum size of simple query cache.
 void setMulti(boolean newMulti)
           
 void show()
          Shows content of this class.
 boolean toReconfigure()
          Checks wheather cache reconfiguration needs to be done.
 java.lang.String toString()
          Shows content of this class.
 GenericDO updateDO(GenericDO DO)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

cache

protected LRUCache cache
LRU cache for storing data objects. key: cache handle value: data object


simpleQCache

protected LRUCache simpleQCache
Cache for storing simple queries. key: query in String form value: org.enhydra.dods.cache.QueryItemCache


complexQCache

protected LRUCache complexQCache
Cache for storing complex queries. key: query in String form value: org.enhydra.dods.cache.QueryItemCache (value of conds in QueryItemCache is null for complex queries)


cacheReadOnly

protected boolean cacheReadOnly
This attribute contains information if cache is read-only. (true - is read-only, otherwise false)


initialQueryCache

protected java.lang.String initialQueryCache
Initial query statement, used for cache initialization.


fullCaching

protected boolean fullCaching
This attribute contains information if the type of caching is "full".


multi

protected boolean multi
This attribute contains information if multi databases are used.

Constructor Detail

QueryCacheImpl

public QueryCacheImpl(int maxCSize)
Constructor (int) - creates cache with maximal size maxCSize and simple and complex query caches with their default maximal sizes.

Parameters:
maxCSize - maximal cache size.

QueryCacheImpl

public QueryCacheImpl()
Constructor () - creates cache with its default maximal size and simple and complex query caches with their default maximal sizes.

Method Detail

refresh

public void refresh()
Refreshes caches.


getCacheContent

public java.util.Map getCacheContent()
Returns cache content.

Specified by:
getCacheContent in interface QueryCache
Returns:
cache content as HashMap of DO objects.

getMaxCacheSize

public int getMaxCacheSize()
Returns maximum cache size.

Specified by:
getMaxCacheSize in interface CacheAdministration
Returns:
Maximum cache size.

getMaxCacheSize

public int getMaxCacheSize(boolean real)
Get maximum cache size. If the cache is unbounded (the maximum size is negative), the current cache size is returned.

Specified by:
getMaxCacheSize in interface CacheAdministration
Parameters:
real - If this parameter is true method return real maximum cache size, othervise return appropriate value for statistic.
Returns:
maximum cache size.

getCacheSize

public int getCacheSize()
Returns size of currently used cache.

Specified by:
getCacheSize in interface CacheAdministration
Returns:
Size of currently used cache.

setMaxCacheSize

public void setMaxCacheSize(int maxSize)
Sets maximum cache size.

Specified by:
setMaxCacheSize in interface CacheAdministration
Parameters:
maxSize - Maximum cache size.

getMaxSimpleQueryCacheSize

public int getMaxSimpleQueryCacheSize()
Returns maximum size of simple query cache.

Specified by:
getMaxSimpleQueryCacheSize in interface CacheAdministration
Returns:
Maximum size of simple query cache.

getMaxSimpleQueryCacheSize

public int getMaxSimpleQueryCacheSize(boolean real)
Gets maximum simple query cache size. If the cache is unbounded (the maximum size is negative), the current cache size is returned.

Specified by:
getMaxSimpleQueryCacheSize in interface CacheAdministration
Parameters:
real - If this parameter is true method return real maximum cache size, othervise return appropriate value for statistic.
Returns:
maximum simple query cache size.

setMaxSimpleQueryCacheSize

public void setMaxSimpleQueryCacheSize(int maxSize)
Sets maximum size of simple query cache.

Specified by:
setMaxSimpleQueryCacheSize in interface CacheAdministration
Parameters:
maxSize - maximum size of simple query cache.

getSimpleQueryCacheSize

public int getSimpleQueryCacheSize()
Returns size of currently used simple query cache.

Specified by:
getSimpleQueryCacheSize in interface CacheAdministration
Returns:
Size of currently used simple query cache.

getMaxComplexQueryCacheSize

public int getMaxComplexQueryCacheSize()
Returns maximum size of complex query cache.

Specified by:
getMaxComplexQueryCacheSize in interface CacheAdministration
Returns:
Maximum size of complex query cache.

getMaxComplexQueryCacheSize

public int getMaxComplexQueryCacheSize(boolean real)
Gets maximum complex query cache size. If the cache is unbounded (the maximum size is negative), the current cache size is returned.

Specified by:
getMaxComplexQueryCacheSize in interface CacheAdministration
Parameters:
real - If this parameter is true method return real maximum cache size, othervise return appropriate value for statistic.
Returns:
maximum complex query cache size.

setMaxComplexQueryCacheSize

public void setMaxComplexQueryCacheSize(int maxSize)
Sets maximum size of complex query cache.

Specified by:
setMaxComplexQueryCacheSize in interface CacheAdministration
Parameters:
maxSize - maximum size of complex query cache.

getComplexQueryCacheSize

public int getComplexQueryCacheSize()
Returns size of currently used complex query cache.

Specified by:
getComplexQueryCacheSize in interface CacheAdministration
Returns:
Size of currently used complex query cache.

setCacheReadOnly

public void setCacheReadOnly(boolean readOnly)
Sets read-only attribute.

Specified by:
setCacheReadOnly in interface CacheAdministration
Parameters:
readOnly - New read-only value.

getCacheReadOnly

public boolean getCacheReadOnly()
Returns read-only attribute.

Specified by:
getCacheReadOnly in interface CacheAdministration
Returns:
read-only attribute

setInitialQueryCache

public void setInitialQueryCache(java.lang.String initQ)
Sets initialQueryCache attribute.

Specified by:
setInitialQueryCache in interface CacheAdministration
Parameters:
initQ - New initialQueryCache.

getInitialQueryCache

public java.lang.String getInitialQueryCache()
Returns initialQueryCache.

Specified by:
getInitialQueryCache in interface CacheAdministration
Returns:
initialQueryCache.

isFull

public boolean isFull()
Returns

Specified by:
isFull in interface CacheAdministration
Returns:

isMulti

public boolean isMulti()
Specified by:
isMulti in interface QueryCache
Returns:
true if multi caching is used, otherwise false.

setMulti

public void setMulti(boolean newMulti)
Specified by:
setMulti in interface QueryCache
Parameters:
newMulti - new value for multi

getCache

public LRUCache getCache()
Returns cache.

Returns:
Cache.

toReconfigure

public boolean toReconfigure()
Checks wheather cache reconfiguration needs to be done.

Specified by:
toReconfigure in interface QueryCache
Returns:
true if cache reconfiguration needs to be done, otherwise false.

readConfiguration

public void readConfiguration(com.lutris.util.Config config,
                              com.lutris.util.Config globalConfig)
Read cache configuration from application's configuration file.

Parameters:
config - configuration for this cache.
globalConfig - default configuration for all application's caches.

checkFull

protected void checkFull()
Checks if this is special type of caching - full caching and updates attribute fullCaching if necessary.


addDO

public GenericDO addDO(GenericDO newDO)
Specified by:
addDO in interface QueryCache

removeDO

public GenericDO removeDO(GenericDO DO)
Remove DO from cache.

Specified by:
removeDO in interface QueryCache
Returns:
removed DO object.

removeDO

public GenericDO removeDO(java.lang.String handle)
Remove DO from cache.

Specified by:
removeDO in interface QueryCache
Parameters:
handle - String representation of object Id that will be removed.
Returns:
removed DO object.

getCacheType

public java.lang.String getCacheType()
Get cache type.

Specified by:
getCacheType in interface CacheAdministration
Returns:
Cache type.

updateDO

public GenericDO updateDO(GenericDO DO)
Specified by:
updateDO in interface QueryCache

deleteDO

public GenericDO deleteDO(GenericDO DO)
Deletes DO from simpleQCache and complexQCache

Specified by:
deleteDO in interface QueryCache

newQueryCacheItemInstance

public QueryCacheItem newQueryCacheItemInstance(java.lang.String dbName)
Specified by:
newQueryCacheItemInstance in interface QueryCache

addSimpleQuery

public QueryCacheItem addSimpleQuery(QueryCacheItem queryItem)
Specified by:
addSimpleQuery in interface QueryCache

removeSimpleQuery

public QueryCacheItem removeSimpleQuery(QueryCacheItem queryItem)
Specified by:
removeSimpleQuery in interface QueryCache

addComplexQuery

public QueryCacheItem addComplexQuery(QueryCacheItem queryItem)
Specified by:
addComplexQuery in interface QueryCache

removeComplexQuery

public QueryCacheItem removeComplexQuery(QueryCacheItem queryItem)
Specified by:
removeComplexQuery in interface QueryCache

getDOByHandle

public GenericDO getDOByHandle(java.lang.String handle)
Specified by:
getDOByHandle in interface QueryCache
Parameters:
handle -
Returns:

getSimpleQueryResults

public QueryResult getSimpleQueryResults(java.lang.String dbName,
                                         java.lang.String query)
Specified by:
getSimpleQueryResults in interface QueryCache

getComplexQueryResults

public QueryResult getComplexQueryResults(java.lang.String dbName,
                                          java.lang.String query)
Specified by:
getComplexQueryResults in interface QueryCache

getQueryResults

public QueryResult getQueryResults(java.lang.String dbName,
                                   java.lang.String query)
Specified by:
getQueryResults in interface QueryCache

show

public void show()
Shows content of this class. Can be used for debugging.


toString

public java.lang.String toString()
Shows content of this class. Can be used for debugging.

Overrides:
toString in class java.lang.Object

DODS 5.1 API