Package net.sf.ehcache.management
Class CacheStatistics
- java.lang.Object
-
- net.sf.ehcache.management.CacheStatistics
-
- All Implemented Interfaces:
java.io.Serializable,CacheStatisticsMBean
public class CacheStatistics extends java.lang.Object implements CacheStatisticsMBean, java.io.Serializable
A JMX CacheStatistics decorator for an ehcache Statistics class.An immutable Cache statistics implementation}
This is like a value object, with the added ability to clear cache statistics on the cache. That ability does not survive any Serialization of this class. On deserialization the cache can be considered disconnected.
The accuracy of these statistics are determined by the value of {#getStatisticsAccuracy()} at the time the statistic was computed.
Because this class maintains a reference to an Ehcache, any references held to this class will precent the Ehcache from getting garbage collected.
- Since:
- 1.3
- Version:
- $Id$
- Author:
- Greg Luck
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description CacheStatistics(Ehcache ehcache)Constructs an object from an ehcache statistics object
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetAssociatedCacheName()doublegetCacheHitPercentage()Returns the percentage of cache accesses that found a requested item in the cache.longgetCacheHits()The number of times a requested item was found in the cache.longgetCacheMisses()Warning.doublegetCacheMissPercentage()Returns the percentage of cache accesses that did not find a requested element in the cache.longgetDiskStoreObjectCount()Gets the number of objects in the DiskStoreEhcachegetEhcache()Return the backing cache.doublegetInMemoryHitPercentage()Returns the percentage of cache accesses that found a requested item cached in-memory.longgetInMemoryHits()Number of times a requested item was found in the Memory Store.longgetInMemoryMisses()longgetMemoryStoreObjectCount()Gets the number of objects in the MemoryStorelonggetObjectCount()doublegetOffHeapHitPercentage()Returns the percentage of cache accesses that found a requested item cached off-heap.longgetOffHeapHits()Number of times a requested item was found in the off-heap store.longgetOffHeapMisses()longgetOffHeapStoreObjectCount()Gets the number of objects in the OffHeapStoredoublegetOnDiskHitPercentage()Returns the percentage of cache accesses that found a requested item cached on disk.longgetOnDiskHits()Number of times a requested item was found in the Disk Store.longgetOnDiskMisses()intgetWriterMaxQueueSize()Gets the maximum size of the write-behind queue, if any.longgetWriterQueueLength()Gets the size of the write-behind queue, if any.
-
-
-
Constructor Detail
-
CacheStatistics
public CacheStatistics(Ehcache ehcache)
Constructs an object from an ehcache statistics object- Parameters:
ehcache- the backing ehcache
-
-
Method Detail
-
getAssociatedCacheName
public java.lang.String getAssociatedCacheName()
- Specified by:
getAssociatedCacheNamein interfaceCacheStatisticsMBean- Returns:
- the name of the Ehcache, or null is there no associated cache
-
getInMemoryHits
public long getInMemoryHits()
Number of times a requested item was found in the Memory Store.- Specified by:
getInMemoryHitsin interfaceCacheStatisticsMBean- Returns:
- the number of times a requested item was found in memory
-
getOffHeapHits
public long getOffHeapHits()
Number of times a requested item was found in the off-heap store.- Specified by:
getOffHeapHitsin interfaceCacheStatisticsMBean- Returns:
- the number of times a requested item was found in off-heap
-
getOnDiskHits
public long getOnDiskHits()
Number of times a requested item was found in the Disk Store.- Specified by:
getOnDiskHitsin interfaceCacheStatisticsMBean- Returns:
- the number of times a requested item was found on Disk, or 0 if there is no disk storage configured.
-
getCacheMisses
public long getCacheMisses()
Warning. This statistic is recorded as a long. If the statistic is large than Integer#MAX_VALUE precision will be lost.- Specified by:
getCacheMissesin interfaceCacheStatisticsMBean- Returns:
- the number of times a requested element was not found in the cache
-
getInMemoryMisses
public long getInMemoryMisses()
- Specified by:
getInMemoryMissesin interfaceCacheStatisticsMBean- Returns:
- the number of times a requested element was not found in the memory cache
-
getOffHeapMisses
public long getOffHeapMisses()
- Specified by:
getOffHeapMissesin interfaceCacheStatisticsMBean- Returns:
- the number of times a requested element was not found in the off-heap cache
-
getOnDiskMisses
public long getOnDiskMisses()
- Specified by:
getOnDiskMissesin interfaceCacheStatisticsMBean- Returns:
- the number of times a requested element was not found in the disk cache
-
getObjectCount
public long getObjectCount()
- Specified by:
getObjectCountin interfaceCacheStatisticsMBean- Returns:
- the number of elements in the ehcache, with a varying degree of accuracy, depending on accuracy setting.
-
getWriterQueueLength
public long getWriterQueueLength()
Gets the size of the write-behind queue, if any. The value is for all local buckets- Specified by:
getWriterQueueLengthin interfaceCacheStatisticsMBean- Returns:
- Elements waiting to be processed by the write behind writer. -1 if no write-behind
-
getWriterMaxQueueSize
public int getWriterMaxQueueSize()
Gets the maximum size of the write-behind queue, if any.- Specified by:
getWriterMaxQueueSizein interfaceCacheStatisticsMBean- Returns:
- Maximum elements waiting to be processed by the write behind writer. -1 if no write-behind
-
getMemoryStoreObjectCount
public long getMemoryStoreObjectCount()
Gets the number of objects in the MemoryStore- Specified by:
getMemoryStoreObjectCountin interfaceCacheStatisticsMBean- Returns:
- the MemoryStore size which is always a count unadjusted for duplicates or expiries
-
getOffHeapStoreObjectCount
public long getOffHeapStoreObjectCount()
Gets the number of objects in the OffHeapStore- Specified by:
getOffHeapStoreObjectCountin interfaceCacheStatisticsMBean- Returns:
- the OffHeapStore size which is always a count unadjusted for duplicates or expiries
-
getDiskStoreObjectCount
public long getDiskStoreObjectCount()
Gets the number of objects in the DiskStore- Specified by:
getDiskStoreObjectCountin interfaceCacheStatisticsMBean- Returns:
- the DiskStore size which is always a count unadjusted for duplicates or expiries
-
getEhcache
public Ehcache getEhcache()
Return the backing cache.- Returns:
- the backing cache, if one is connected. On Serialization the transient Ehcache reference is dropped.
-
getCacheHitPercentage
public double getCacheHitPercentage()
Returns the percentage of cache accesses that found a requested item in the cache.- Specified by:
getCacheHitPercentagein interfaceCacheStatisticsMBean- Returns:
- the percentage of successful hits
-
getCacheMissPercentage
public double getCacheMissPercentage()
Returns the percentage of cache accesses that did not find a requested element in the cache.- Specified by:
getCacheMissPercentagein interfaceCacheStatisticsMBean- Returns:
- the percentage of accesses that failed to find anything
-
getInMemoryHitPercentage
public double getInMemoryHitPercentage()
Returns the percentage of cache accesses that found a requested item cached in-memory.- Specified by:
getInMemoryHitPercentagein interfaceCacheStatisticsMBean- Returns:
- the percentage of successful hits from the MemoryStore
-
getOffHeapHitPercentage
public double getOffHeapHitPercentage()
Returns the percentage of cache accesses that found a requested item cached off-heap.- Specified by:
getOffHeapHitPercentagein interfaceCacheStatisticsMBean- Returns:
- the percentage of successful hits from the OffHeapStore
-
getOnDiskHitPercentage
public double getOnDiskHitPercentage()
Returns the percentage of cache accesses that found a requested item cached on disk.- Specified by:
getOnDiskHitPercentagein interfaceCacheStatisticsMBean- Returns:
- the percentage of successful hits from the DiskStore.
-
getCacheHits
public long getCacheHits()
The number of times a requested item was found in the cache.- Specified by:
getCacheHitsin interfaceCacheStatisticsMBean- Returns:
- the number of times a requested item was found in the cache
-
-