org.apache.openjpa.instrumentation
Class AbstractDataCacheInstrument

java.lang.Object
  extended by org.apache.openjpa.lib.instrumentation.AbstractInstrument
      extended by org.apache.openjpa.instrumentation.AbstractDataCacheInstrument
All Implemented Interfaces:
DataCacheInstrument, Instrument
Direct Known Subclasses:
DataCacheJMXInstrument

public abstract class AbstractDataCacheInstrument
extends AbstractInstrument
implements DataCacheInstrument

Provides a basic instrument implementation wrapper for the data cache. This class can be extended to create a provider specific instrument for the data cache.


Field Summary
static long NO_STATS
          Value indicating that cache statistics are not available.
 
Constructor Summary
AbstractDataCacheInstrument()
           
 
Method Summary
 void cache(String className, boolean enable)
          This method is used to enable/disable caching for the specified className.
 void clear()
          Clears all data from the DataCache.
 void collectStatistics(boolean enable)
           
 String getCacheName()
          Returns the name of the cache
 Map<String,long[]> getCacheStatistics()
          Returns the CacheStatistics for the cache.
 String getConfigId()
           
 String getContextRef()
           
 long getHitCount()
          Returns the hit count since cache statistics were last reset
 long getHitCount(String c)
          Gets number of total read requests that has been found in cache for the given class since last reset.
 InstrumentationLevel getLevel()
          Gets the instrumentation level of this instrument.
 long getReadCount()
          Returns the read count since cache statistics were last reset
 long getReadCount(String c)
          Gets number of total read requests for the given class since last reset.
 Boolean getStatisticsEnabled()
          Returns true if cache statistics are currently being calculated.
 long getTotalHitCount()
          Returns the total hits since start.
 long getTotalHitCount(String c)
          Gets number of total read requests that has been found in cache for the given class since start.
 long getTotalReadCount()
          Returns the total reads since start.
 long getTotalReadCount(String c)
          Gets number of total read requests for the given class since start.
 long getTotalWriteCount()
          Returns the total writes since start.
 long getTotalWriteCount(String c)
          Gets number of total write requests for the given class since start.
 long getWriteCount()
          Returns the write count since cache statistics were last reset
 long getWriteCount(String c)
          Gets number of total write requests for the given class since last reset.
 Map<String,Boolean> listKnownTypes()
          Returns the names of classes that are known to the cache and whether or not they are currently being cached.
 void reset()
          Resets cache statistics
 void setConfigId(String cid)
           
 void setContextRef(String cref)
           
 void setDataCache(DataCache dc)
           
 void setDataCacheManager(DataCacheManager dcm)
           
 Date sinceDate()
          Returns date since cache statistics collection were last reset.
 Date startDate()
          Returns date cache statistics collection started.
 
Methods inherited from class org.apache.openjpa.lib.instrumentation.AbstractInstrument
getContext, getName, getOptions, getProvider, initialize, isStarted, restart, setContext, setOptions, setProvider, setStarted
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.openjpa.lib.instrumentation.Instrument
start, stop
 

Field Detail

NO_STATS

public static final long NO_STATS
Value indicating that cache statistics are not available.

See Also:
Constant Field Values
Constructor Detail

AbstractDataCacheInstrument

public AbstractDataCacheInstrument()
Method Detail

setDataCache

public void setDataCache(DataCache dc)

setDataCacheManager

public void setDataCacheManager(DataCacheManager dcm)

setConfigId

public void setConfigId(String cid)

setContextRef

public void setContextRef(String cref)

getHitCount

public long getHitCount()
Description copied from interface: DataCacheInstrument
Returns the hit count since cache statistics were last reset

Specified by:
getHitCount in interface DataCacheInstrument

getReadCount

public long getReadCount()
Description copied from interface: DataCacheInstrument
Returns the read count since cache statistics were last reset

Specified by:
getReadCount in interface DataCacheInstrument

getTotalHitCount

public long getTotalHitCount()
Description copied from interface: DataCacheInstrument
Returns the total hits since start.

Specified by:
getTotalHitCount in interface DataCacheInstrument

getTotalReadCount

public long getTotalReadCount()
Description copied from interface: DataCacheInstrument
Returns the total reads since start.

Specified by:
getTotalReadCount in interface DataCacheInstrument

getTotalWriteCount

public long getTotalWriteCount()
Description copied from interface: DataCacheInstrument
Returns the total writes since start.

Specified by:
getTotalWriteCount in interface DataCacheInstrument

getWriteCount

public long getWriteCount()
Description copied from interface: DataCacheInstrument
Returns the write count since cache statistics were last reset

Specified by:
getWriteCount in interface DataCacheInstrument

reset

public void reset()
Description copied from interface: DataCacheInstrument
Resets cache statistics

Specified by:
reset in interface DataCacheInstrument

sinceDate

public Date sinceDate()
Description copied from interface: DataCacheInstrument
Returns date since cache statistics collection were last reset.

Specified by:
sinceDate in interface DataCacheInstrument

startDate

public Date startDate()
Description copied from interface: DataCacheInstrument
Returns date cache statistics collection started.

Specified by:
startDate in interface DataCacheInstrument

getConfigId

public String getConfigId()

getContextRef

public String getContextRef()

getCacheName

public String getCacheName()
Description copied from interface: DataCacheInstrument
Returns the name of the cache

Specified by:
getCacheName in interface DataCacheInstrument

getWriteCount

public long getWriteCount(String c)
Description copied from interface: DataCacheInstrument
Gets number of total write requests for the given class since last reset.

Specified by:
getWriteCount in interface DataCacheInstrument

getTotalWriteCount

public long getTotalWriteCount(String c)
Description copied from interface: DataCacheInstrument
Gets number of total write requests for the given class since start.

Specified by:
getTotalWriteCount in interface DataCacheInstrument

getTotalReadCount

public long getTotalReadCount(String c)
Description copied from interface: DataCacheInstrument
Gets number of total read requests for the given class since start.

Specified by:
getTotalReadCount in interface DataCacheInstrument

getTotalHitCount

public long getTotalHitCount(String c)
Description copied from interface: DataCacheInstrument
Gets number of total read requests that has been found in cache for the given class since start.

Specified by:
getTotalHitCount in interface DataCacheInstrument

getReadCount

public long getReadCount(String c)
Description copied from interface: DataCacheInstrument
Gets number of total read requests for the given class since last reset.

Specified by:
getReadCount in interface DataCacheInstrument

getHitCount

public long getHitCount(String c)
Description copied from interface: DataCacheInstrument
Gets number of total read requests that has been found in cache for the given class since last reset.

Specified by:
getHitCount in interface DataCacheInstrument

getLevel

public InstrumentationLevel getLevel()
Description copied from interface: Instrument
Gets the instrumentation level of this instrument. The instrumentation level determines if and when the instrument will automatically start and stop.

Specified by:
getLevel in interface Instrument
Overrides:
getLevel in class AbstractInstrument
Returns:
the instrumentation level of the instrument

cache

public void cache(String className,
                  boolean enable)
Description copied from interface: DataCacheInstrument
This method is used to enable/disable caching for the specified className.

Specified by:
cache in interface DataCacheInstrument

listKnownTypes

public Map<String,Boolean> listKnownTypes()
Description copied from interface: DataCacheInstrument
Returns the names of classes that are known to the cache and whether or not they are currently being cached.

Specified by:
listKnownTypes in interface DataCacheInstrument

collectStatistics

public void collectStatistics(boolean enable)
Specified by:
collectStatistics in interface DataCacheInstrument
Parameters:
enable - - If true, the cache will start collecting statistics. Else cache statistics will not be collected.

getStatisticsEnabled

public Boolean getStatisticsEnabled()
Description copied from interface: DataCacheInstrument
Returns true if cache statistics are currently being calculated. False otherwise.

Specified by:
getStatisticsEnabled in interface DataCacheInstrument

getCacheStatistics

public Map<String,long[]> getCacheStatistics()
Description copied from interface: DataCacheInstrument
Returns the CacheStatistics for the cache. The format for this map is: Type(String) => Enabled(Boolean),Read(Long),Hit(Long),Write(Long)

Specified by:
getCacheStatistics in interface DataCacheInstrument

clear

public void clear()
Description copied from interface: DataCacheInstrument
Clears all data from the DataCache.

Specified by:
clear in interface DataCacheInstrument


Copyright © 2006-2012 Apache Software Foundation. All Rights Reserved.