Class AbstractDataCacheInstrument

  • All Implemented Interfaces:
    DataCacheInstrument, org.apache.openjpa.lib.instrumentation.Instrument
    Direct Known Subclasses:
    DataCacheJMXInstrument

    public abstract class AbstractDataCacheInstrument
    extends org.apache.openjpa.lib.instrumentation.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

      Fields 
      Modifier and Type Field Description
      static long NO_STATS
      Value indicating that cache statistics are not available.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void cache​(java.lang.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)  
      java.lang.String getCacheName()
      Returns the name of the cache
      java.util.Map<java.lang.String,​long[]> getCacheStatistics()
      Returns the CacheStatistics for the cache.
      java.lang.String getConfigId()  
      java.lang.String getContextRef()  
      long getHitCount()
      Returns the hit count since cache statistics were last reset
      long getHitCount​(java.lang.String c)
      Gets number of total read requests that has been found in cache for the given class since last reset.
      org.apache.openjpa.lib.instrumentation.InstrumentationLevel getLevel()  
      long getReadCount()
      Returns the read count since cache statistics were last reset
      long getReadCount​(java.lang.String c)
      Gets number of total read requests for the given class since last reset.
      java.lang.Boolean getStatisticsEnabled()
      Returns true if cache statistics are currently being calculated.
      long getTotalHitCount()
      Returns the total hits since start.
      long getTotalHitCount​(java.lang.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​(java.lang.String c)
      Gets number of total read requests for the given class since start.
      long getTotalWriteCount()
      Returns the total writes since start.
      long getTotalWriteCount​(java.lang.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​(java.lang.String c)
      Gets number of total write requests for the given class since last reset.
      java.util.Map<java.lang.String,​java.lang.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​(java.lang.String cid)  
      void setContextRef​(java.lang.String cref)  
      void setDataCache​(DataCache dc)  
      void setDataCacheManager​(DataCacheManager dcm)  
      java.util.Date sinceDate()
      Returns date since cache statistics collection were last reset.
      java.util.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​(java.lang.String cid)
      • setContextRef

        public void setContextRef​(java.lang.String cref)
      • getConfigId

        public java.lang.String getConfigId()
      • getContextRef

        public java.lang.String getContextRef()
      • getWriteCount

        public long getWriteCount​(java.lang.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
      • getTotalHitCount

        public long getTotalHitCount​(java.lang.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​(java.lang.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​(java.lang.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 org.apache.openjpa.lib.instrumentation.InstrumentationLevel getLevel()
        Specified by:
        getLevel in interface org.apache.openjpa.lib.instrumentation.Instrument
        Overrides:
        getLevel in class org.apache.openjpa.lib.instrumentation.AbstractInstrument
      • cache

        public void cache​(java.lang.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 java.util.Map<java.lang.String,​java.lang.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.
      • getCacheStatistics

        public java.util.Map<java.lang.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