|
DODS 7.5 API | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.enhydra.dods.cache.ConfigurationAdministration
org.enhydra.dods.cache.DataStructCache
org.enhydra.dods.cache.QueryCache
org.enhydra.dods.cache.QueryCacheImpl
public class QueryCacheImpl
This class contains data and mechanisms needed for caching data objects (or DataStruct objects) and queries and provides cache configuration and administration.
| Field Summary | |
|---|---|
protected DODSCache |
cache
LRU cache for storing data (or DataStruct) objects. |
protected CacheAdministration[] |
cacheAdministration
Attribute cacheAdministration is array of three objects of the class CacheAdministration. |
protected boolean |
completeCachingOn
This attribute is true if the cache is complete, otherwise false. |
protected DODSCache |
complexQCache
LRU cache for storing complex queries. |
protected boolean |
fullCachingOn
This attribute is true if the cache is full, otherwise false. |
protected java.lang.String |
initialQueryCache
Initial query statement. |
protected boolean |
multi
This attribute contains information if multi databases are used. |
protected DODSCache |
multiJoinQCache
LRU cache for storing multi join queries. |
protected java.util.HashMap |
nonVisibleList
List of objects that are unvisible in the cache at the moment. |
protected int |
oldComplexMaxCacheSize
Old max complex cache size. |
protected int |
oldMultiJoinMaxCacheSize
Old max multi join cache size. |
protected int |
oldSimpleMaxCacheSize
Old max simple cache size. |
protected double |
reserveFactor
This attribute is used in query caching. |
protected DODSCache |
simpleQCache
LRU cache for storing simple queries. |
protected Statistics |
statistics
Table and cache statictics. |
protected TableConfiguration |
tableConf
TableConfiguration attribute handles configuration settings about table of this cache. |
| Constructor Summary | |
|---|---|
QueryCacheImpl()
Constructor(). |
|
QueryCacheImpl(int maxCSize)
Constructor(int). |
|
| Method Summary | |
|---|---|
QueryCacheItem |
addComplexQuery(QueryCacheItem queryItem)
Adds complex query to complex query cache. |
CoreDataStruct |
addDataStruct(CoreDataStruct newDS)
Adds DataStruct object to the cache. |
QueryCacheItem |
addMultiJoinQuery(QueryCacheItem queryItem)
Adds multi join query to multi join query cache. |
QueryCacheItem |
addSimpleQuery(QueryCacheItem queryItem)
Adds simple query to simple query cache. |
void |
checkFull()
Checks if cache is full or not and updates apropriate internal variables. |
CoreDataStruct |
deleteDataStruct(CoreDataStruct data)
Deletes DataStruct object from the cache. |
void |
emptyEntries()
|
void |
emptyEntries(java.util.Vector vec,
boolean incrementVersion)
|
int |
getAsynchLoadPriority()
Returns priority of asynchronous cache initialization. |
CacheAdministration |
getCacheAdministration(int cacheType)
Returns CacheAdministration for data object (or DataStruct object) cache, simple, or complex query cache. |
java.util.Map |
getCacheContent()
Returns cache (data or DataStruct) content. |
double |
getCachePercentage()
Read cache configuration from application's configuration file. |
java.lang.String |
getCacheType()
Returns data object (or DataStruct object) cache type. |
QueryCacheItem |
getComplexQueryCacheItem(java.lang.String dbName,
java.lang.String query)
Returns QueryCacheItem object for specified database and complex query, if exists, otherwise null. |
QueryResult |
getComplexQueryResults(java.lang.String dbName,
java.lang.String query)
Returns query results from complex query cache. |
QueryResult |
getComplexQueryResults(java.lang.String dbName,
java.lang.String query,
int limit,
int maxdb)
Returns query results from complex query cache. |
QueryResult |
getComplexQueryResults(java.lang.String dbName,
java.lang.String query,
int limit,
int maxdb,
boolean unique)
Returns query results from complex query cache. |
CoreDataStruct |
getDataStructByHandle(java.lang.String cacheHandle)
Returns DataStruct object whose String representation of OID is parameter handle. |
int |
getInitialCacheFetchSize()
|
int |
getInitialDSCacheSize()
|
java.lang.String |
getInitialQueryCache()
Returns initialQueryCache. |
int |
getLevelOfCaching()
Returns caching level. |
int |
getMaxExecuteTimeCacheInit()
Returns the max time for which the query is not printed in application's log file durung the cache initialization. |
QueryCacheItem |
getMultiJoinQueryCacheItem(java.lang.String dbName,
java.lang.String query)
Returns QueryCacheItem object for specified database and multi join query, if exists, otherwise null. |
QueryResult |
getMultiJoinQueryResults(java.lang.String dbName,
java.lang.String query)
Returns query results from multi join query cache. |
QueryResult |
getMultiJoinQueryResults(java.lang.String dbName,
java.lang.String query,
int limit,
int maxdb)
Returns query results from multi join query cache. |
QueryResult |
getMultiJoinQueryResults(java.lang.String dbName,
java.lang.String query,
int limit,
int maxdb,
boolean unique)
Returns query results from multi join query cache. |
QueryResult |
getQueryResults(java.lang.String dbName,
java.lang.String query)
Returns query results from simple, complex or multi join query cache. |
int |
getQueryTimeLimitCacheInit()
Returns max number of milliseconds for which the query for cache initialization should be executed and the resulset read from ResultSet. |
int |
getQueryTimeoutCacheInit()
Returns max number of seconds for which the query for cache initialization should be executed. |
double |
getReserveFactor()
Returns reserveFactor. |
int |
getSimpleCacheRowCountLimit()
Returns max number of rows in the table for which is simple cache still used. |
QueryCacheItem |
getSimpleQueryCacheItem(java.lang.String dbName,
java.lang.String query)
Returns QueryCacheItem object for specified database and simple query, if exists, otherwise null. |
QueryResult |
getSimpleQueryResults(java.lang.String dbName,
java.lang.String query)
Returns query results from simple query cache. |
QueryResult |
getSimpleQueryResults(java.lang.String dbName,
java.lang.String query,
int limit,
int maxdb)
Returns query results from simple query cache. |
QueryResult |
getSimpleQueryResults(java.lang.String dbName,
java.lang.String query,
int limit,
int maxdb,
boolean unique)
Returns query results from simple query cache. |
Statistics |
getStatistics()
Returns statistics of used table and caches. |
int |
getSynchLoadRowCountLimit()
Returns the max number of rows in the table for which the synchronous cache load is performed if defined by configuration. |
TableConfiguration |
getTableConfiguration()
Returns object TableConfiguration. |
protected void |
init()
Creates array of three CacheAdministration objects. |
boolean |
isComplete()
Returns information if data object (or DataStruct object) cache if "complete". |
boolean |
isCompleteCachingOn()
Returns information if data object (or DataStruct object) cache was in last check (call of isComplete() method) "complete". |
boolean |
isDisabled()
Returns information whether caching is disabled. |
boolean |
isFull()
Returns information if data object (or DataStruct object) cache if "full". |
boolean |
isMulti()
Returns information if multi databases are supported. |
void |
loadCache(java.lang.Class DOClass,
java.lang.Class QueryClass,
java.lang.String root)
|
void |
makeInvisible(java.lang.String cacheHandle)
|
void |
makeVisible(java.lang.String cacheHandle)
|
DataStructCache |
newInstance()
Creates QueryCacheImpl instance. |
QueryCacheItem |
newQueryCacheItemInstance(java.lang.String dbName)
Creates new QueryCacheItem instance. |
void |
readConfiguration(Config tableConfig,
Config cacheConfig,
java.lang.String dbName)
Reads table and cache configuration from application's configuration file. |
void |
refreshStatistics()
Refreshes statistics. |
QueryCacheItem |
removeComplexQuery(QueryCacheItem queryItem)
Removes complex query from complex query cache. |
CoreDataStruct |
removeDataStruct(CoreDataStruct data)
Removes DataStruct object from the cache. |
CoreDataStruct |
removeDataStruct(java.lang.String handle)
Removes DataStruct object from the cache. |
void |
removeEntries()
|
void |
removeEntries(java.util.Vector vec)
|
QueryCacheItem |
removeMultiJoinQuery(QueryCacheItem queryItem)
Removes multi join query from multi join query cache. |
QueryCacheItem |
removeSimpleQuery(QueryCacheItem queryItem)
Removes simple query from simple query cache. |
void |
saveCache(java.lang.Class DOClass,
java.lang.String root)
|
protected void |
setAsynchLoadPriority(int priority)
Sets priority of asynchronous cache initialization. |
protected void |
setCachePercentage(double percent)
|
void |
setInitialCacheFetchSize(int i)
|
void |
setInitialDSCacheSize(int i)
|
protected void |
setInitialQueryCache(java.lang.String initQ)
Sets initialQueryCache attribute. |
protected void |
setMaxExecuteTimeCacheInit(int maxExeTime)
Sets the max time for which the query is not printed in application's log file durung the cache initialization. |
protected void |
setQueryTimeLimitCacheInit(int timeLimit)
Sets max number of milliseconds for which the query for cache initialization should be executed and the resulset read from ResultSet. |
protected void |
setQueryTimeoutCacheInit(int timeout)
Sets max number of seconds for which the query for cache initialization should be executed. |
protected void |
setReserveFactor(double res)
Sets reserveFactor. |
protected void |
setSimpleCacheRowCountLimit(int rowCount)
Sets the max number of rows in the table for which is simple cache still used. |
protected void |
setSynchLoadRowCountLimit(int rowCount)
Sets the max number of rows in the table for which the synchronous cache load is performed if defined by configuration. |
boolean |
toReconfigure()
Checks wheather cache reconfiguration needs to be done. |
java.lang.String |
toString()
Shows content of this class. |
CoreDataStruct |
updateDataStruct(CoreDataStruct data)
Updates cached DataStruct object, or inserts it in the cache if it didn't exist in the cache. |
| Methods inherited from class org.enhydra.dods.cache.QueryCache |
|---|
isLockedMultiJoinQCache, isLockedSimpleComplexQCache |
| Methods inherited from class org.enhydra.dods.cache.DataStructCache |
|---|
isLocked |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected DODSCache cache
protected DODSCache simpleQCache
protected DODSCache complexQCache
protected DODSCache multiJoinQCache
protected CacheAdministration[] cacheAdministration
protected TableConfiguration tableConf
protected java.lang.String initialQueryCache
protected boolean multi
protected boolean fullCachingOn
protected boolean completeCachingOn
protected Statistics statistics
protected java.util.HashMap nonVisibleList
protected int oldSimpleMaxCacheSize
protected int oldComplexMaxCacheSize
protected int oldMultiJoinMaxCacheSize
protected double reserveFactor
num is number of needed results, then it is
used num+ DEFAULT_RESERVE_FACTOR *num of objects for
estimating what is quicker: go to database for all object that are not in the cache,
or run again query on database. This value is given in percents, as number between 0
and 1 (0.25 means 25%). For example, if DEFAULT_RESERVE_FACTOR is 0.5, and wanted
number of results is 50, the estimation will be done on 75 (50 + 0.5 * 50) objects.
The value of CacheConstants.DEFAULT_RESERVE_FACTOR is 0.5.
| Constructor Detail |
|---|
public QueryCacheImpl(int maxCSize)
throws CacheObjectException
maxCSize and simple and complex query caches with their default
maximal sizes. The value of CacheConstants.DEFAULT_MAX_SIMPLE_QUERY_CACHE_SIZE is 0.
The value of CacheConstants.DEFAULT_MAX_COMPLEX_QUERY_CACHE_SIZE is 0.
maxCSize - maximal data (or DataStruct) object cache size.
CacheObjectException
public QueryCacheImpl()
throws CacheObjectException
CacheObjectException| Method Detail |
|---|
public CacheAdministration getCacheAdministration(int cacheType)
getCacheAdministration in class QueryCachecacheType - 0 - for data object (or DataStruct object), 1 for simple query, 2
for complex query cache and 3 for complex query cache.public java.lang.String getInitialQueryCache()
getInitialQueryCache in class ConfigurationAdministrationprotected void setInitialQueryCache(java.lang.String initQ)
setInitialQueryCache in class ConfigurationAdministrationinitQ - New value of initialQueryCache attribute.public void makeInvisible(java.lang.String cacheHandle)
makeInvisible in class QueryCachepublic void makeVisible(java.lang.String cacheHandle)
makeVisible in class QueryCachepublic Statistics getStatistics()
getStatistics in class ConfigurationAdministrationpublic void refreshStatistics()
refreshStatistics in class ConfigurationAdministrationpublic void checkFull()
checkFull in class ConfigurationAdministrationpublic boolean isFull()
isFull in class ConfigurationAdministrationpublic boolean isComplete()
isComplete in class ConfigurationAdministrationpublic boolean isCompleteCachingOn()
public java.lang.String getCacheType()
getCacheType in class ConfigurationAdministrationpublic int getLevelOfCaching()
getLevelOfCaching in class ConfigurationAdministrationpublic TableConfiguration getTableConfiguration()
getTableConfiguration in class ConfigurationAdministrationpublic double getReserveFactor()
num is
number of needed results, then it is used num+
DEFAULT_RESERVE_FACTOR *num of objects for estimating what is
quicker: go to database for all object that are not in the cache, or run again query
on database. This value is given in percents, as number between 0 and 1 (0.25 means
25%). For example, if DEFAULT_RESERVE_FACTOR is 0.5, and wanted number of results is
50, the estimation will be done on 75 (50 + 0.5 * 50) objects.
getReserveFactor in class ConfigurationAdministrationprotected void setReserveFactor(double res)
num is
number of needed results, then it is used num+
DEFAULT_RESERVE_FACTOR *num of objects for estimating what is
quicker: go to database for all object that are not in the cache, or run again query
on database. This value is given in percents, as number between 0 and 1 (0.25 means
25%). For example, if DEFAULT_RESERVE_FACTOR is 0.5, and wanted number of results is
50, the estimation will be done on 75 (50 + 0.5 * 50) objects.
setReserveFactor in class ConfigurationAdministrationres - New reserveFactor.protected void setCachePercentage(double percent)
setCachePercentage in class ConfigurationAdministrationpublic double getCachePercentage()
ConfigurationAdministration
getCachePercentage in class ConfigurationAdministrationpublic boolean isDisabled()
isDisabled in class ConfigurationAdministration
public void readConfiguration(Config tableConfig,
Config cacheConfig,
java.lang.String dbName)
throws CacheObjectException
readConfiguration in class ConfigurationAdministrationtableConfig - configuration for table of this cache.cacheConfig - configuration for this cache.
CacheObjectException
public DataStructCache newInstance()
throws CacheObjectException
newInstance in class DataStructCacheCacheObjectExceptionprotected void init()
public java.util.Map getCacheContent()
getCacheContent in class DataStructCacheMap of data (or DataStruct) objects.public boolean isMulti()
isMulti in class DataStructCachepublic boolean toReconfigure()
toReconfigure in class DataStructCachepublic CoreDataStruct addDataStruct(CoreDataStruct newDS)
addDataStruct in class DataStructCachenewDS - DataStruct object that will be added to the cache.
public CoreDataStruct removeDataStruct(CoreDataStruct data)
removeDataStruct in class DataStructCachedata - DataStruct object that will be removed from the cache.
public CoreDataStruct removeDataStruct(java.lang.String handle)
removeDataStruct in class DataStructCachehandle - Cache handle of DataStruct object that will be removed from the cache.
The form of cache handle is: " public CoreDataStruct updateDataStruct(CoreDataStruct data)
updateDataStruct in class DataStructCachedata - DataStruct object that will be updated (or inserted if didn't exist in
the cache).
public CoreDataStruct deleteDataStruct(CoreDataStruct data)
deleteDataStruct in class DataStructCachedata - DataStruct object that will be deleted from the cache.
public CoreDataStruct getDataStructByHandle(java.lang.String cacheHandle)
getDataStructByHandle in class DataStructCachecacheHandle - String representation of OID of DataStruct object that is being
searched in the cache.
public QueryCacheItem newQueryCacheItemInstance(java.lang.String dbName)
newQueryCacheItemInstance in class QueryCachedbName - Database name.
public QueryCacheItem getSimpleQueryCacheItem(java.lang.String dbName,
java.lang.String query)
getSimpleQueryCacheItem in class QueryCachedbName - Database name.query - Query in form of String.
public QueryCacheItem getComplexQueryCacheItem(java.lang.String dbName,
java.lang.String query)
getComplexQueryCacheItem in class QueryCachedbName - Database name.query - Query in form of String.
public QueryCacheItem getMultiJoinQueryCacheItem(java.lang.String dbName,
java.lang.String query)
getMultiJoinQueryCacheItem in class QueryCachedbName - Database name.query - Query in form of String.
public QueryCacheItem addSimpleQuery(QueryCacheItem queryItem)
addSimpleQuery in class QueryCachequeryItem - Query that will be added to simple query cache.
public QueryCacheItem removeSimpleQuery(QueryCacheItem queryItem)
removeSimpleQuery in class QueryCachequeryItem - Query that will be removed from simple query cache.
public QueryCacheItem addComplexQuery(QueryCacheItem queryItem)
addComplexQuery in class QueryCachequeryItem - Query that will be added to complex query cache.
public QueryCacheItem removeComplexQuery(QueryCacheItem queryItem)
removeComplexQuery in class QueryCachequeryItem - Query that will be removed from complex query cache.
public QueryCacheItem addMultiJoinQuery(QueryCacheItem queryItem)
addMultiJoinQuery in class QueryCachequeryItem - Query that will be added to multi join query cache.
public QueryCacheItem removeMultiJoinQuery(QueryCacheItem queryItem)
removeMultiJoinQuery in class QueryCachequeryItem - Query that will be removed from multi join query cache.
public QueryResult getSimpleQueryResults(java.lang.String dbName,
java.lang.String query)
getSimpleQueryResults in class QueryCachedbName - Database name.query - Query for which are results searched in simple query cache.
public QueryResult getSimpleQueryResults(java.lang.String dbName,
java.lang.String query,
int limit,
int maxdb)
getSimpleQueryResults in class QueryCachedbName - Database name.query - Query for which are results searched in simple query cache.limit - Specified number of results (database limit and read skip).maxdb - Number of rows retrieved from database (or cache).
public QueryResult getSimpleQueryResults(java.lang.String dbName,
java.lang.String query,
int limit,
int maxdb,
boolean unique)
getSimpleQueryResults in class QueryCachedbName - Database name.query - Query for which are results searched in simple query cache.limit - Specified number of results (database limit and read skip).maxdb - Number of rows retrieved from database (or cache).unique - If true, only unique results are returned.
public QueryResult getComplexQueryResults(java.lang.String dbName,
java.lang.String query)
getComplexQueryResults in class QueryCachedbName - Database name.query - Query for which are results searched in complex query cache.
public QueryResult getComplexQueryResults(java.lang.String dbName,
java.lang.String query,
int limit,
int maxdb)
getComplexQueryResults in class QueryCachedbName - Database name.query - Query for which are results searched in complex query cache.limit - Specified number of results (database limit and read skip).maxdb - Number of rows retrieved from database (or cache).
public QueryResult getComplexQueryResults(java.lang.String dbName,
java.lang.String query,
int limit,
int maxdb,
boolean unique)
getComplexQueryResults in class QueryCachedbName - Database name.query - Query for which are results searched in complex query cache.limit - Specified number of results (database limit and read skip).maxdb - Number of rows retrieved from database (or cache).unique - If true, only unique results are returned.
public QueryResult getMultiJoinQueryResults(java.lang.String dbName,
java.lang.String query)
getMultiJoinQueryResults in class QueryCachedbName - Database name.query - Query for which are results searched in multi join query cache.
public QueryResult getMultiJoinQueryResults(java.lang.String dbName,
java.lang.String query,
int limit,
int maxdb)
getMultiJoinQueryResults in class QueryCachedbName - Database name.query - Query for which are results searched in multi join query cache.limit - Specified number of results (database limit and read skip).maxdb - Number of rows retrieved from database (or cache).
public QueryResult getMultiJoinQueryResults(java.lang.String dbName,
java.lang.String query,
int limit,
int maxdb,
boolean unique)
getMultiJoinQueryResults in class QueryCachedbName - Database name.query - Query for which are results searched in multi join query cache.limit - Specified number of results (database limit and read skip).maxdb - Number of rows retrieved from database (or cache).unique - If true, only unique results are returned.
public QueryResult getQueryResults(java.lang.String dbName,
java.lang.String query)
getQueryResults in class QueryCachedbName - Database name.query - Query for which are results searched in simple, complex or multi join
query cache.
public java.lang.String toString()
toString in class java.lang.Objectpublic void removeEntries(java.util.Vector vec)
removeEntries in class QueryCachepublic void removeEntries()
removeEntries in class QueryCache
public void emptyEntries(java.util.Vector vec,
boolean incrementVersion)
emptyEntries in class QueryCachepublic void emptyEntries()
emptyEntries in class QueryCachepublic int getInitialCacheFetchSize()
getInitialCacheFetchSize in class ConfigurationAdministrationpublic int getInitialDSCacheSize()
getInitialDSCacheSize in class ConfigurationAdministrationpublic void setInitialCacheFetchSize(int i)
setInitialCacheFetchSize in class ConfigurationAdministrationi - public void setInitialDSCacheSize(int i)
setInitialDSCacheSize in class ConfigurationAdministrationi - public int getAsynchLoadPriority()
getAsynchLoadPriority in class ConfigurationAdministrationprotected void setAsynchLoadPriority(int priority)
setAsynchLoadPriority in class ConfigurationAdministrationpriority - priority of asynchronous cache initialization.public int getSimpleCacheRowCountLimit()
getSimpleCacheRowCountLimit in class ConfigurationAdministrationprotected void setSimpleCacheRowCountLimit(int rowCount)
setSimpleCacheRowCountLimit in class ConfigurationAdministrationrowCount - max number of rows in the table for which is simple cache still
used.public int getSynchLoadRowCountLimit()
getSynchLoadRowCountLimit in class ConfigurationAdministrationprotected void setSynchLoadRowCountLimit(int rowCount)
setSynchLoadRowCountLimit in class ConfigurationAdministrationrowCount - the max number of rows in the table for which the synchronous cache
load is performed if defined by configuration.public int getMaxExecuteTimeCacheInit()
getMaxExecuteTimeCacheInit in class ConfigurationAdministrationprotected void setMaxExecuteTimeCacheInit(int maxExeTime)
setMaxExecuteTimeCacheInit in class ConfigurationAdministrationmaxExeTime - new value for max execution time for the cache initialization.public int getQueryTimeLimitCacheInit()
getQueryTimeLimitCacheInit in class ConfigurationAdministrationprotected void setQueryTimeLimitCacheInit(int timeLimit)
setQueryTimeLimitCacheInit in class ConfigurationAdministrationtimeLimit - new value for time limit for cache initialization.public int getQueryTimeoutCacheInit()
getQueryTimeoutCacheInit in class ConfigurationAdministrationprotected void setQueryTimeoutCacheInit(int timeout)
setQueryTimeoutCacheInit in class ConfigurationAdministrationtimeout - new value for query timeout for cache initialization.
public void saveCache(java.lang.Class DOClass,
java.lang.String root)
public void loadCache(java.lang.Class DOClass,
java.lang.Class QueryClass,
java.lang.String root)
|
DODS 7.5 API | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||