public class CacheStatisticsImpl extends Object implements CacheStatistics
CacheStatistics
implementation for ICache
.
Statistics accumulated in this data object is published through MxBean as defined by spec.
CacheMXBeanImpl
Constructor and Description |
---|
CacheStatisticsImpl(long creationTime) |
CacheStatisticsImpl(long creationTime,
CacheEntryCountResolver cacheEntryCountResolver) |
Modifier and Type | Method and Description |
---|---|
void |
addGetTimeNanos(long duration)
Increments the getCache time accumulator.
|
void |
addPutTimeNanos(long duration)
Increments the put time accumulator.
|
void |
addRemoveTimeNanos(long duration)
Increments the remove time accumulator.
|
void |
clear()
Implementation of
CacheStatisticsMXBean.clear() . |
float |
getAverageGetTime()
The mean time to execute gets.
|
float |
getAveragePutTime()
The mean time to execute puts.
|
float |
getAverageRemoveTime()
The mean time to execute removes.
|
long |
getCacheEvictions()
The total number of evictions from the cache.
|
long |
getCacheExpiries()
The total number of expiries from the cache.
|
long |
getCacheGets()
The total number of requests to the cache.
|
long |
getCacheGetTimeTakenNanos() |
float |
getCacheHitPercentage()
This is a measure of cache efficiency.
|
long |
getCacheHits()
The number of get requests that were satisfied by the cache.
|
long |
getCacheMisses()
A miss is a get request that is not satisfied.
|
float |
getCacheMissPercentage()
Returns the percentage of cache accesses that did not find a requested entry
in the cache.
|
long |
getCachePuts()
The total number of puts to the cache.
|
long |
getCachePutTimeTakenNanos() |
long |
getCacheRemovals()
The total number of removals from the cache.
|
long |
getCacheRemoveTimeTakenNanos() |
long |
getCreationTime()
Gets the cache creation time.
|
long |
getLastAccessTime()
Gets the last access time to cache.
|
long |
getLastUpdateTime()
Gets the last update time to cache.
|
NearCacheStats |
getNearCacheStatistics()
Gets the Near Cache statistics.
|
long |
getOwnedEntryCount()
Returns the owned entry count in the cache.
|
void |
increaseCacheEvictions()
Increases the counter by `1`.
|
void |
increaseCacheEvictions(long number)
Increases the counter by the number specified.
|
void |
increaseCacheExpiries()
Increases the counter by `1`.
|
void |
increaseCacheExpiries(long number)
Increases the counter by the number specified.
|
void |
increaseCacheHits()
Increases the counter by `1`.
|
void |
increaseCacheHits(long number)
Increases the counter by the number specified.
|
void |
increaseCacheMisses()
Increases the counter by `1`.
|
void |
increaseCacheMisses(long number)
Increases the counter by the number specified.
|
void |
increaseCachePuts()
Increases the counter by `1`.
|
void |
increaseCachePuts(long number)
Increases the counter by the number specified.
|
void |
increaseCacheRemovals()
Increases the counter by `1`.
|
void |
increaseCacheRemovals(long number)
Increases the counter by the number specified.
|
void |
setLastAccessTime(long time)
Sets the cache last access time as atomic if the given time is bigger than it.
|
void |
setLastUpdateTime(long time)
Sets the cache last update time as atomic if the given time is bigger than it.
|
String |
toString() |
protected static final float FLOAT_HUNDRED
protected static final long NANOSECONDS_IN_A_MICROSECOND
protected static final AtomicLongFieldUpdater<CacheStatisticsImpl> LAST_ACCESS_TIME
protected static final AtomicLongFieldUpdater<CacheStatisticsImpl> LAST_UPDATE_TIME
protected static final AtomicLongFieldUpdater<CacheStatisticsImpl> REMOVALS
protected static final AtomicLongFieldUpdater<CacheStatisticsImpl> EXPIRIES
protected static final AtomicLongFieldUpdater<CacheStatisticsImpl> PUTS
protected static final AtomicLongFieldUpdater<CacheStatisticsImpl> HITS
protected static final AtomicLongFieldUpdater<CacheStatisticsImpl> MISSES
protected static final AtomicLongFieldUpdater<CacheStatisticsImpl> EVICTIONS
protected static final AtomicLongFieldUpdater<CacheStatisticsImpl> PUT_TIME_TAKEN_NANOS
protected static final AtomicLongFieldUpdater<CacheStatisticsImpl> GET_CACHE_TIME_TAKEN_NANOS
protected static final AtomicLongFieldUpdater<CacheStatisticsImpl> REMOVE_TIME_TAKEN_NANOS
protected long creationTime
protected volatile long lastAccessTime
protected volatile long lastUpdateTime
protected volatile long removals
protected volatile long expiries
protected volatile long puts
protected volatile long hits
protected volatile long misses
protected volatile long evictions
protected volatile long putTimeTakenNanos
protected volatile long getCacheTimeTakenNanos
protected volatile long removeTimeTakenNanos
protected final CacheEntryCountResolver cacheEntryCountResolver
public CacheStatisticsImpl(long creationTime)
public CacheStatisticsImpl(long creationTime, CacheEntryCountResolver cacheEntryCountResolver)
public long getCreationTime()
CacheStatistics
getCreationTime
in interface CacheStatistics
public long getLastAccessTime()
CacheStatistics
getLastAccessTime
in interface CacheStatistics
public long getLastUpdateTime()
CacheStatistics
getLastUpdateTime
in interface CacheStatistics
public long getOwnedEntryCount()
CacheStatistics
getOwnedEntryCount
in interface CacheStatistics
public long getCacheRemovals()
CacheStatistics
getCacheRemovals
in interface CacheStatistics
public long getCacheExpiries()
public long getCacheGets()
CacheStatistics
A "get" is an operation that returns the current or previous value. It does not include checking for the existence of a key.
In caches with multiple tiered storage, a get may be implemented as a get to the cache or to the first tier.
getCacheGets
in interface CacheStatistics
public long getCachePuts()
CacheStatistics
A put is counted even if it is immediately evicted.
Replaces are where a put occurs which overrides an existing mapping, and they are counted as a put.
getCachePuts
in interface CacheStatistics
public long getCacheHits()
CacheStatistics
Cache.containsKey(Object)
is not a get request for
statistics purposes.
In caches with multiple tiered storage, a hit may be implemented as a hit to the cache or to the first tier.
For an EntryProcessor
, a hit occurs when the
key exists and an entry processor can be invoked against it, even if no
methods of Cache.Entry
or
MutableEntry
are called.
getCacheHits
in interface CacheStatistics
public long getCacheMisses()
CacheStatistics
In a simple cache, a miss occurs when the cache does not satisfy the request.
Cache.containsKey(Object)
is not a get request for
statistics purposes.
For an EntryProcessor
, a miss occurs when the
key does not exist and therefore an entry processor cannot be invoked
against it.
In caches with multiple tiered storage, a miss may be implemented as a miss to the cache or to the first tier.
In a read-through cache, a miss is an absence of the key in the cache that will trigger a call to a CacheLoader. So it is still a miss even though the cache will load and return the value.
Refer to the implementation for precise semantics.
getCacheMisses
in interface CacheStatistics
public long getCacheEvictions()
CacheStatistics
getCacheEvictions
in interface CacheStatistics
public long getCachePutTimeTakenNanos()
public long getCacheGetTimeTakenNanos()
public long getCacheRemoveTimeTakenNanos()
public float getCacheHitPercentage()
CacheStatistics
It is calculated as:
CacheStatistics.getCacheHits()
divided by ()
* 100.
getCacheHitPercentage
in interface CacheStatistics
public float getCacheMissPercentage()
CacheStatistics
This is calculated as CacheStatistics.getCacheMisses()
divided by
CacheStatistics.getCacheGets()
* 100.
getCacheMissPercentage
in interface CacheStatistics
public float getAverageGetTime()
CacheStatistics
In a read-through cache, the time taken to load an entry on miss is not included in get time.
getAverageGetTime
in interface CacheStatistics
public float getAveragePutTime()
CacheStatistics
getAveragePutTime
in interface CacheStatistics
public float getAverageRemoveTime()
CacheStatistics
getAverageRemoveTime
in interface CacheStatistics
public void clear()
CacheStatisticsMXBean.clear()
.CacheStatisticsMXBean.clear()
public void setLastAccessTime(long time)
time
- time to set the cache last access timepublic void setLastUpdateTime(long time)
time
- time to set the cache last update timepublic void increaseCacheRemovals()
public void increaseCacheRemovals(long number)
number
- the number by which the counter is increased.public void increaseCacheExpiries()
public void increaseCacheExpiries(long number)
number
- the number by which the counter is increased.public void increaseCachePuts()
public void increaseCachePuts(long number)
number
- the number by which the counter is increased.public void increaseCacheHits()
public void increaseCacheHits(long number)
number
- the number by which the counter is increased.public void increaseCacheMisses()
public void increaseCacheMisses(long number)
number
- the number by which the counter is increased.public void increaseCacheEvictions()
public void increaseCacheEvictions(long number)
number
- the number by which the counter is increased.public void addGetTimeNanos(long duration)
duration
- the time taken in nanoseconds.public void addPutTimeNanos(long duration)
duration
- the time taken in nanoseconds.public void addRemoveTimeNanos(long duration)
duration
- the time taken in nanoseconds.public NearCacheStats getNearCacheStatistics()
CacheStatistics
getNearCacheStatistics
in interface CacheStatistics
Copyright © 2018 Hazelcast, Inc.. All Rights Reserved.