Top Description Fields Constructors Methods
net.sf.ehcache.management

public Class CacheStatistics

extends Object
implements CacheStatisticsMBean, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, net.sf.ehcache.management.CacheStatisticsMBean
Imports
net.sf.ehcache.CacheException, .Ehcache, net.sf.ehcache.hibernate.management.impl.EhcacheHibernateMbeanNames, net.sf.ehcache.statistics.StatisticsGateway, javax.management.MalformedObjectNameException, .ObjectName, 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.

Author
Greg Luck
Since
1.3
Version
$Id: CacheStatistics.java 10789 2018-04-26 02:08:13Z adahanne $

Field Summary

Modifier and TypeField and Description
private transient Ehcache
private final ObjectName
private static final long
private StatisticsGateway

Constructor Summary

AccessConstructor and Description
public
CacheStatistics(Ehcache
the backing ehcache
ehcache
)

Constructs an object from an ehcache statistics object

Method Summary

Modifier and TypeMethod and Description
pack-priv static ObjectName
createObjectName(String cacheManagerName, String cacheName)

Creates an object name using the scheme "net.sf.ehcache:type=CacheStatistics,CacheManager=<cachemanagername>,name=<cachename>"

public String

Returns:

the name of the Ehcache, or null is there no associated cache
getAssociatedCacheName
()

Implements net.sf.ehcache.management.CacheStatisticsMBean.getAssociatedCacheName.

public double
getCacheHitPercentage()

Implements net.sf.ehcache.management.CacheStatisticsMBean.getCacheHitPercentage.

Returns the percentage of cache accesses that found a requested item in the cache.
public long
getCacheHits()

Implements net.sf.ehcache.management.CacheStatisticsMBean.getCacheHits.

The number of times a requested item was found in the cache.
public long

Returns:

the number of times a requested element was not found in the cache
getCacheMisses
()

Implements net.sf.ehcache.management.CacheStatisticsMBean.getCacheMisses.

Warning.
public double
getCacheMissPercentage()

Implements net.sf.ehcache.management.CacheStatisticsMBean.getCacheMissPercentage.

Returns the percentage of cache accesses that did not find a requested element in the cache.
public long

Returns:

the DiskStore size which is always a count unadjusted for duplicates or expiries
getDiskStoreObjectCount
()

Implements net.sf.ehcache.management.CacheStatisticsMBean.getDiskStoreObjectCount.

Gets the number of objects in the DiskStore
public Ehcache

Returns:

the backing cache, if one is connected. On Serialization the transient Ehcache reference is dropped.
getEhcache
()

Return the backing cache.

public double
getInMemoryHitPercentage()

Implements net.sf.ehcache.management.CacheStatisticsMBean.getInMemoryHitPercentage.

Returns the percentage of cache accesses that found a requested item cached in-memory.
public long

Returns:

the number of times a requested item was found in memory
getInMemoryHits
()

Implements net.sf.ehcache.management.CacheStatisticsMBean.getInMemoryHits.

Number of times a requested item was found in the Memory Store.
public long
public long

Returns:

the MemoryStore size which is always a count unadjusted for duplicates or expiries
getMemoryStoreObjectCount
()

Implements net.sf.ehcache.management.CacheStatisticsMBean.getMemoryStoreObjectCount.

Gets the number of objects in the MemoryStore
public long

Returns:

the number of elements in the ehcache, with a varying degree of accuracy, depending on accuracy setting.
getObjectCount
()

Implements net.sf.ehcache.management.CacheStatisticsMBean.getObjectCount.

pack-priv ObjectName

Returns:

the object name for this MBean
getObjectName
()

public double
getOffHeapHitPercentage()

Implements net.sf.ehcache.management.CacheStatisticsMBean.getOffHeapHitPercentage.

Returns the percentage of cache accesses that found a requested item cached off-heap.
public long

Returns:

the number of times a requested item was found in off-heap
getOffHeapHits
()

Implements net.sf.ehcache.management.CacheStatisticsMBean.getOffHeapHits.

Number of times a requested item was found in the off-heap store.
public long
public long
public double
getOnDiskHitPercentage()

Implements net.sf.ehcache.management.CacheStatisticsMBean.getOnDiskHitPercentage.

Returns the percentage of cache accesses that found a requested item cached on disk.
public long

Returns:

the number of times a requested item was found on Disk, or 0 if there is no disk storage configured.
getOnDiskHits
()

Implements net.sf.ehcache.management.CacheStatisticsMBean.getOnDiskHits.

Number of times a requested item was found in the Disk Store.
public long
private static double
getPercentage(long number, long total)

public int
getWriterMaxQueueSize()

Implements net.sf.ehcache.management.CacheStatisticsMBean.getWriterMaxQueueSize.

Gets the maximum size of the write-behind queue, if any.
public long

Returns:

Elements waiting to be processed by the write behind writer. -1 if no write-behind
getWriterQueueLength
()

Implements net.sf.ehcache.management.CacheStatisticsMBean.getWriterQueueLength.

Gets the size of the write-behind queue, if any.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ehcacheback to summary
private transient Ehcache ehcache
objectNameback to summary
private final ObjectName objectName
serialVersionUIDback to summary
private static final long serialVersionUID
statisticsback to summary
private StatisticsGateway statistics

Constructor Detail

CacheStatisticsback to summary
public CacheStatistics(Ehcache ehcache)

Constructs an object from an ehcache statistics object

Parameters
ehcache:Ehcache

the backing ehcache

Method Detail

createObjectNameback to summary
pack-priv static ObjectName createObjectName(String cacheManagerName, String cacheName)

Creates an object name using the scheme "net.sf.ehcache:type=CacheStatistics,CacheManager=,name="

getAssociatedCacheNameback to summary
public String getAssociatedCacheName()

Implements net.sf.ehcache.management.CacheStatisticsMBean.getAssociatedCacheName.

Returns:String

the name of the Ehcache, or null is there no associated cache

getCacheHitPercentageback to summary
public double getCacheHitPercentage()

Implements net.sf.ehcache.management.CacheStatisticsMBean.getCacheHitPercentage.

Doc from net.sf.ehcache.management.CacheStatisticsMBean.getCacheHitPercentage.

Returns the percentage of cache accesses that found a requested item in the cache.

Returns:double

the percentage of successful hits

getCacheHitsback to summary
public long getCacheHits()

Implements net.sf.ehcache.management.CacheStatisticsMBean.getCacheHits.

Doc from net.sf.ehcache.management.CacheStatisticsMBean.getCacheHits.

The number of times a requested item was found in the cache.

Returns:long

the number of times a requested item was found in the cache

Annotations
@Override
getCacheMissesback to summary
public long getCacheMisses()

Implements net.sf.ehcache.management.CacheStatisticsMBean.getCacheMisses.

Warning. This statistic is recorded as a long. If the statistic is large than Integer#MAX_VALUE precision will be lost.

Returns:long

the number of times a requested element was not found in the cache

getCacheMissPercentageback to summary
public double getCacheMissPercentage()

Implements net.sf.ehcache.management.CacheStatisticsMBean.getCacheMissPercentage.

Doc from net.sf.ehcache.management.CacheStatisticsMBean.getCacheMissPercentage.

Returns the percentage of cache accesses that did not find a requested element in the cache.

Returns:double

the percentage of accesses that failed to find anything

getDiskStoreObjectCountback to summary
public long getDiskStoreObjectCount()

Implements net.sf.ehcache.management.CacheStatisticsMBean.getDiskStoreObjectCount.

Gets the number of objects in the DiskStore

Returns:long

the DiskStore size which is always a count unadjusted for duplicates or expiries

getEhcacheback to summary
public Ehcache getEhcache()

Return the backing cache.

Returns:Ehcache

the backing cache, if one is connected. On Serialization the transient Ehcache reference is dropped.

getInMemoryHitPercentageback to summary
public double getInMemoryHitPercentage()

Implements net.sf.ehcache.management.CacheStatisticsMBean.getInMemoryHitPercentage.

Doc from net.sf.ehcache.management.CacheStatisticsMBean.getInMemoryHitPercentage.

Returns the percentage of cache accesses that found a requested item cached in-memory.

Returns:double

the percentage of successful hits from the MemoryStore

getInMemoryHitsback to summary
public long getInMemoryHits()

Implements net.sf.ehcache.management.CacheStatisticsMBean.getInMemoryHits.

Number of times a requested item was found in the Memory Store.

Returns:long

the number of times a requested item was found in memory

getInMemoryMissesback to summary
public long getInMemoryMisses()

Implements net.sf.ehcache.management.CacheStatisticsMBean.getInMemoryMisses.

Returns:long

Doc from net.sf.ehcache.management.CacheStatisticsMBean.getInMemoryMisses.

the number of times a requested element was not found in the memory cache

getMemoryStoreObjectCountback to summary
public long getMemoryStoreObjectCount()

Implements net.sf.ehcache.management.CacheStatisticsMBean.getMemoryStoreObjectCount.

Gets the number of objects in the MemoryStore

Returns:long

the MemoryStore size which is always a count unadjusted for duplicates or expiries

getObjectCountback to summary
public long getObjectCount()

Implements net.sf.ehcache.management.CacheStatisticsMBean.getObjectCount.

Returns:long

the number of elements in the ehcache, with a varying degree of accuracy, depending on accuracy setting.

getObjectNameback to summary
pack-priv ObjectName getObjectName()
Returns:ObjectName

the object name for this MBean

getOffHeapHitPercentageback to summary
public double getOffHeapHitPercentage()

Implements net.sf.ehcache.management.CacheStatisticsMBean.getOffHeapHitPercentage.

Doc from net.sf.ehcache.management.CacheStatisticsMBean.getOffHeapHitPercentage.

Returns the percentage of cache accesses that found a requested item cached off-heap.

Returns:double

the percentage of successful hits from the OffHeapStore

getOffHeapHitsback to summary
public long getOffHeapHits()

Implements net.sf.ehcache.management.CacheStatisticsMBean.getOffHeapHits.

Number of times a requested item was found in the off-heap store.

Returns:long

the number of times a requested item was found in off-heap

getOffHeapMissesback to summary
public long getOffHeapMisses()

Implements net.sf.ehcache.management.CacheStatisticsMBean.getOffHeapMisses.

Returns:long

Doc from net.sf.ehcache.management.CacheStatisticsMBean.getOffHeapMisses.

the number of times a requested element was not found in the off-heap cache

getOffHeapStoreObjectCountback to summary
public long getOffHeapStoreObjectCount()

Implements net.sf.ehcache.management.CacheStatisticsMBean.getOffHeapStoreObjectCount.

Doc from net.sf.ehcache.management.CacheStatisticsMBean.getOffHeapStoreObjectCount.

Gets the number of objects in the OffHeapStore

Returns:long

the OffHeapStore size which is always a count unadjusted for duplicates or expiries

getOnDiskHitPercentageback to summary
public double getOnDiskHitPercentage()

Implements net.sf.ehcache.management.CacheStatisticsMBean.getOnDiskHitPercentage.

Doc from net.sf.ehcache.management.CacheStatisticsMBean.getOnDiskHitPercentage.

Returns the percentage of cache accesses that found a requested item cached on disk.

Returns:double

the percentage of successful hits from the DiskStore.

getOnDiskHitsback to summary
public long getOnDiskHits()

Implements net.sf.ehcache.management.CacheStatisticsMBean.getOnDiskHits.

Number of times a requested item was found in the Disk Store.

Returns:long

the number of times a requested item was found on Disk, or 0 if there is no disk storage configured.

getOnDiskMissesback to summary
public long getOnDiskMisses()

Implements net.sf.ehcache.management.CacheStatisticsMBean.getOnDiskMisses.

Returns:long

Doc from net.sf.ehcache.management.CacheStatisticsMBean.getOnDiskMisses.

the number of times a requested element was not found in the disk cache

getPercentageback to summary
private static double getPercentage(long number, long total)
getWriterMaxQueueSizeback to summary
public int getWriterMaxQueueSize()

Implements net.sf.ehcache.management.CacheStatisticsMBean.getWriterMaxQueueSize.

Doc from net.sf.ehcache.management.CacheStatisticsMBean.getWriterMaxQueueSize.

Gets the maximum size of the write-behind queue, if any.

Returns:int

Maximum elements waiting to be processed by the write behind writer. -1 if no write-behind

getWriterQueueLengthback to summary
public long getWriterQueueLength()

Implements net.sf.ehcache.management.CacheStatisticsMBean.getWriterQueueLength.

Gets the size of the write-behind queue, if any. The value is for all local buckets

Returns:long

Elements waiting to be processed by the write behind writer. -1 if no write-behind