public class Statistics
extends java.lang.Object
implements java.io.Serializable
Cache.getStatisticsAccuracy()
at the time the statistic was computed. This can be changed by setting Cache.setStatisticsAccuracy(int)
.
Because this class maintains a reference to an Ehcache, any references held to this class will prevent the Ehcache
from getting garbage collected.
todo Add missCountExpired. Request from user.Modifier and Type | Field and Description |
---|---|
private float |
averageGetTime |
private long |
averageSearchTime |
private Ehcache |
cache |
private long |
cacheHits |
private java.lang.String |
cacheName |
private long |
diskStoreSize |
private long |
evictionCount |
private long |
inMemoryHits |
private long |
inMemoryMisses |
private long |
memoryStoreSize |
private long |
misses |
private long |
offHeapHits |
private long |
offHeapMisses |
private long |
offHeapStoreSize |
private long |
onDiskHits |
private long |
onDiskMisses |
private long |
searchesPerSecond |
private static long |
serialVersionUID |
private long |
size |
static int |
STATISTICS_ACCURACY_BEST_EFFORT
Best efforts accuracy setting.
|
static int |
STATISTICS_ACCURACY_GUARANTEED
Guaranteed accuracy setting.
|
static int |
STATISTICS_ACCURACY_NONE
Fast but not accurate setting.
|
private int |
statisticsAccuracy |
private long |
writerQueueLength |
Constructor and Description |
---|
Statistics(Ehcache cache,
int statisticsAccuracy,
long cacheHits,
long onDiskHits,
long offHeapHits,
long inMemoryHits,
long misses,
long onDiskMisses,
long offHeapMisses,
long inMemoryMisses,
long size,
float averageGetTime,
long evictionCount,
long memoryStoreSize,
long offHeapStoreSize,
long diskStoreSize,
long searchesPerSecond,
long averageSearchTime,
long writerQueueLength)
Creates a new statistics object, associated with a Cache
|
Modifier and Type | Method and Description |
---|---|
void |
clearStatistics()
Clears the statistic counters to 0 for the associated Cache.
|
Ehcache |
getAssociatedCache() |
java.lang.String |
getAssociatedCacheName() |
float |
getAverageGetTime()
The average get time.
|
long |
getAverageSearchTime()
Gets the average execution time (in milliseconds) within the last sample period
|
long |
getCacheHits()
The number of times a requested item was found in the cache.
|
long |
getCacheMisses() |
long |
getDiskStoreObjectCount() |
long |
getEvictionCount()
Gets the number of cache evictions, since the cache was created, or statistics were cleared.
|
long |
getInMemoryHits()
Number of times a requested item was found in the Memory Store.
|
long |
getInMemoryMisses()
Number of times a requested item was not found in the Memory Store.
|
long |
getMemoryStoreObjectCount() |
long |
getObjectCount()
Gets the number of elements stored in the cache.
|
long |
getOffHeapHits()
Number of times a requested item was found in the off-heap store.
|
long |
getOffHeapMisses()
Number of times a requested item was not found in the off-heap store.
|
long |
getOffHeapStoreObjectCount() |
long |
getOnDiskHits()
Number of times a requested item was found in the Disk Store.
|
long |
getOnDiskMisses()
Number of times a requested item was not found in the Disk Store.
|
long |
getSearchesPerSecond()
Get the number of search executions that have completed in the last second
|
int |
getStatisticsAccuracy()
Accurately measuring statistics can be expensive.
|
java.lang.String |
getStatisticsAccuracyDescription()
Accurately measuring statistics can be expensive.
|
long |
getWriterQueueSize()
Gets the size of the write-behind queue, if any.
|
static boolean |
isValidStatisticsAccuracy(int statisticsAccuracy)
Utility method to determine if a given value is a valid statistics
accuracy value or not
|
java.lang.String |
toString()
Returns a
String representation of the Ehcache statistics. |
public static final int STATISTICS_ACCURACY_NONE
public static final int STATISTICS_ACCURACY_BEST_EFFORT
public static final int STATISTICS_ACCURACY_GUARANTEED
private static final long serialVersionUID
private transient Ehcache cache
private final java.lang.String cacheName
private final int statisticsAccuracy
private final long cacheHits
private final long onDiskHits
private final long offHeapHits
private final long inMemoryHits
private final long misses
private final long onDiskMisses
private final long offHeapMisses
private final long inMemoryMisses
private final long size
private final long memoryStoreSize
private final long offHeapStoreSize
private final long diskStoreSize
private final float averageGetTime
private final long evictionCount
private final long searchesPerSecond
private final long averageSearchTime
private long writerQueueLength
public Statistics(Ehcache cache, int statisticsAccuracy, long cacheHits, long onDiskHits, long offHeapHits, long inMemoryHits, long misses, long onDiskMisses, long offHeapMisses, long inMemoryMisses, long size, float averageGetTime, long evictionCount, long memoryStoreSize, long offHeapStoreSize, long diskStoreSize, long searchesPerSecond, long averageSearchTime, long writerQueueLength)
cache
- The cache that clearStatistics()
will call, if not disconnectedstatisticsAccuracy
- cacheHits
- onDiskHits
- offHeapHits
- inMemoryHits
- misses
- size
- public void clearStatistics()
public long getCacheHits()
public long getInMemoryHits()
public long getOffHeapHits()
public long getOnDiskHits()
public long getCacheMisses()
public long getInMemoryMisses()
public long getOffHeapMisses()
public long getOnDiskMisses()
public long getObjectCount()
STATISTICS_ACCURACY_BEST_EFFORT
.
The size is the number of Element
s in the MemoryStore
plus
the number of Element
s in the DiskStore
.
This number is the actual number of elements, including expired elements that have
not been removed. Any duplicates between stores are accounted for.
Expired elements are removed from the the memory store when
getting an expired element, or when attempting to spool an expired element to
disk.
Expired elements are removed from the disk store when getting an expired element,
or when the expiry thread runs, which is once every five minutes.
STATISTICS_ACCURACY_GUARANTEED
.
This method accounts for elements which might be expired or duplicated between stores. It take approximately
200ms per 1000 elements to execute.
STATISTICS_ACCURACY_NONE
.
The number given may contain expired elements. In addition if the DiskStore is used it may contain some double
counting of elements. It takes 6ms for 1000 elements to execute. Time to execute is O(log n). 50,000 elements take
36ms.public long getMemoryStoreObjectCount()
public long getOffHeapStoreObjectCount()
public long getDiskStoreObjectCount()
public int getStatisticsAccuracy()
public java.lang.String getStatisticsAccuracyDescription()
public java.lang.String getAssociatedCacheName()
public Ehcache getAssociatedCache()
public final java.lang.String toString()
String
representation of the Ehcache
statistics.toString
in class java.lang.Object
public float getAverageGetTime()
public long getEvictionCount()
public long getAverageSearchTime()
public long getSearchesPerSecond()
public static boolean isValidStatisticsAccuracy(int statisticsAccuracy)
statisticsAccuracy
- STATISTICS_ACCURACY_BEST_EFFORT
,
STATISTICS_ACCURACY_GUARANTEED
,
STATISTICS_ACCURACY_NONE
public long getWriterQueueSize()