|
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.DOCache
org.enhydra.dods.cache.TransactionQueryCache
org.enhydra.dods.cache.TransactionCacheImpl
public class TransactionCacheImpl
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 DODSHashMap |
cache
HashMap for storing data objects. |
protected CacheAdministration[] |
cacheAdministration
Attribute cacheAdministration is array of three objects of the class CacheAdministration. |
protected double |
cachePercentage
|
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 int |
oldComplexMaxCacheSize
Old max complex 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 | |
|---|---|
TransactionCacheImpl()
Constructor(). |
|
TransactionCacheImpl(int maxSQSize,
int maxCQSize)
Constructor(int, int). |
|
| Method Summary | |
|---|---|
QueryCacheItem |
addComplexQuery(QueryCacheItem queryItem)
Adds complex query to complex query cache. |
GenericDO |
addDO(GenericDO newDO)
Adds DO (data object) to the 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. |
GenericDO |
deleteDO(GenericDO DO)
Deletes DO from the cache. |
void |
emptyEntries(java.lang.Class tableClass)
Dumps data structs for all instances of tableClass in transaction cache. |
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. |
GenericDO |
getDOByHandle(java.lang.String handle)
Returns data 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. |
QueryResult |
getQueryResults(java.lang.String dbName,
java.lang.String query)
Returns query results from simple or complex 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 |
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. |
DOCache |
newInstance()
Creates TransactionCacheImpl 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. |
GenericDO |
removeDO(GenericDO DO)
Removes DO (data object) from the cache. |
GenericDO |
removeDO(java.lang.String handle)
Removes DO (data object) from the cache. |
void |
removeEntries(java.lang.Class tableClass)
|
void |
removeEntries(java.util.Vector vec)
|
QueryCacheItem |
removeSimpleQuery(QueryCacheItem queryItem)
Removes simple query from simple query cache. |
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. |
GenericDO |
updateDO(GenericDO DO)
Updates cached DO, or inserts DO in the cache if it didn't exist in the cache. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected DODSHashMap cache
protected DODSCache simpleQCache
protected DODSCache complexQCache
protected CacheAdministration[] cacheAdministration
protected TableConfiguration tableConf
protected java.lang.String initialQueryCache
protected boolean fullCachingOn
protected boolean completeCachingOn
protected boolean multi
protected Statistics statistics
protected int oldSimpleMaxCacheSize
protected int oldComplexMaxCacheSize
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.
protected double cachePercentage
| Constructor Detail |
|---|
public TransactionCacheImpl(int maxSQSize,
int maxCQSize)
throws CacheObjectException
maxSQSize - maximal data (or DataStruct) object cache size.maxCQSize - maximal data (or DataStruct) object cache size.
CacheObjectException
public TransactionCacheImpl()
throws CacheObjectException
CacheObjectException| Method Detail |
|---|
public CacheAdministration getCacheAdministration(int cacheType)
getCacheAdministration in class ConfigurationAdministrationcacheType - 0 - for data object (or DataStruct object),
1 for simple query and 2 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 Statistics getStatistics()
getStatistics in class ConfigurationAdministrationpublic void refreshStatistics()
refreshStatistics in class ConfigurationAdministrationpublic void checkFull()
ConfigurationAdministration
checkFull in class ConfigurationAdministrationpublic boolean isFull()
isFull in class ConfigurationAdministrationpublic boolean isComplete()
isComplete in class ConfigurationAdministrationpublic 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 DOCache newInstance()
throws CacheObjectException
newInstance in class DOCacheCacheObjectExceptionprotected void init()
public java.util.Map getCacheContent()
getCacheContent in class DOCacheMap of data (or DataStruct) objects.public boolean isMulti()
isMulti in class DOCachepublic boolean toReconfigure()
toReconfigure in class DOCachepublic GenericDO addDO(GenericDO newDO)
addDO in class DOCachenewDO - Data object that will be added to the cache.
public GenericDO removeDO(GenericDO DO)
removeDO in class DOCacheDO - Data object that will be removed from the cache.
public GenericDO removeDO(java.lang.String handle)
removeDO in class DOCachehandle - Cache handle of DO (data object) that will be removed from
the cache. The form of cache handle is:
"public GenericDO updateDO(GenericDO DO)
updateDO in class DOCacheDO - Data object that will be updated (or inserted if didn't
exist in the cache).
public GenericDO deleteDO(GenericDO DO)
deleteDO in class DOCacheDO - Data object that will be deleted from the cache.
public GenericDO getDOByHandle(java.lang.String handle)
getDOByHandle in class DOCachehandle - String representation of OID of object that is being
searched in the cache.
public QueryCacheItem newQueryCacheItemInstance(java.lang.String dbName)
newQueryCacheItemInstance in class TransactionQueryCachedbName - Database name.
public QueryCacheItem getSimpleQueryCacheItem(java.lang.String dbName,
java.lang.String query)
getSimpleQueryCacheItem in class TransactionQueryCachedbName - Database name.query - Query in form of String.
public QueryCacheItem getComplexQueryCacheItem(java.lang.String dbName,
java.lang.String query)
getComplexQueryCacheItem in class TransactionQueryCachedbName - Database name.query - Query in form of String.
public QueryCacheItem addSimpleQuery(QueryCacheItem queryItem)
addSimpleQuery in class TransactionQueryCachequeryItem - Query that will be added to simple query cache.
public QueryCacheItem removeSimpleQuery(QueryCacheItem queryItem)
removeSimpleQuery in class TransactionQueryCachequeryItem - Query that will be removed from simple query cache.
public QueryCacheItem addComplexQuery(QueryCacheItem queryItem)
addComplexQuery in class TransactionQueryCachequeryItem - Query that will be added to complex query cache.
public QueryCacheItem removeComplexQuery(QueryCacheItem queryItem)
removeComplexQuery in class TransactionQueryCachequeryItem - Query that will be removed from complex query cache.
public QueryResult getSimpleQueryResults(java.lang.String dbName,
java.lang.String query)
getSimpleQueryResults in class TransactionQueryCachedbName - 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 TransactionQueryCachedbName - 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 TransactionQueryCachedbName - 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 TransactionQueryCachedbName - 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 TransactionQueryCachedbName - 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 TransactionQueryCachedbName - 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 getQueryResults(java.lang.String dbName,
java.lang.String query)
getQueryResults in class TransactionQueryCachedbName - Database name.query - Query for which are results searched in simple and complex
query cache.
public java.lang.String toString()
toString in class java.lang.Objectpublic void removeEntries(java.util.Vector vec)
removeEntries in class TransactionQueryCachepublic void removeEntries(java.lang.Class tableClass)
removeEntries in class TransactionQueryCachetableClass - -
public void emptyEntries(java.util.Vector vec,
boolean incrementVersion)
emptyEntries in class TransactionQueryCachepublic void emptyEntries(java.lang.Class tableClass)
emptyEntries in class TransactionQueryCachetableClass - - Class object whose instances will be emptiedpublic 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()
ConfigurationAdministration
getAsynchLoadPriority in class ConfigurationAdministrationprotected void setAsynchLoadPriority(int priority)
ConfigurationAdministration
setAsynchLoadPriority in class ConfigurationAdministrationpriority - priority of asynchronous cache initialization.public int getSimpleCacheRowCountLimit()
ConfigurationAdministration
getSimpleCacheRowCountLimit in class ConfigurationAdministrationprotected void setSimpleCacheRowCountLimit(int rowCount)
ConfigurationAdministration
setSimpleCacheRowCountLimit in class ConfigurationAdministrationrowCount - public int getSynchLoadRowCountLimit()
ConfigurationAdministration
getSynchLoadRowCountLimit in class ConfigurationAdministrationprotected void setSynchLoadRowCountLimit(int rowCount)
ConfigurationAdministration
setSynchLoadRowCountLimit in class ConfigurationAdministrationrowCount - public int getMaxExecuteTimeCacheInit()
ConfigurationAdministration
getMaxExecuteTimeCacheInit in class ConfigurationAdministrationprotected void setMaxExecuteTimeCacheInit(int maxExeTime)
ConfigurationAdministration
setMaxExecuteTimeCacheInit in class ConfigurationAdministrationmaxExeTime - public int getQueryTimeLimitCacheInit()
ConfigurationAdministration
getQueryTimeLimitCacheInit in class ConfigurationAdministrationprotected void setQueryTimeLimitCacheInit(int timeLimit)
ConfigurationAdministration
setQueryTimeLimitCacheInit in class ConfigurationAdministrationtimeLimit - public int getQueryTimeoutCacheInit()
ConfigurationAdministration
getQueryTimeoutCacheInit in class ConfigurationAdministrationprotected void setQueryTimeoutCacheInit(int timeout)
ConfigurationAdministration
setQueryTimeoutCacheInit in class ConfigurationAdministrationtimeout -
|
DODS 7.5 API | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||