com.hazelcast.cache.impl
Class CacheStatisticsImpl

java.lang.Object
  extended by com.hazelcast.cache.impl.CacheStatisticsImpl
All Implemented Interfaces:
CacheStatistics, DataSerializable

public class CacheStatisticsImpl
extends Object
implements DataSerializable, CacheStatistics

CacheStatistics implementation for ICache.

Statistics accumulated in this data object is published through MxBean as defined by spec.

See Also:
CacheMXBeanImpl

Constructor Summary
CacheStatisticsImpl()
           
 
Method Summary
 CacheStatisticsImpl accumulate(CacheStatisticsImpl other)
          Simple CacheStatistics adder.
 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()
           
 void increaseCacheEvictions(long number)
          Increases the counter by the number specified.
 void increaseCacheExpiries(long number)
          Increases the counter by the number specified.
 void increaseCacheHits(long number)
          Increases the counter by the number specified.
 void increaseCacheMisses(long number)
          Increases the counter by the number specified.
 void increaseCachePuts(long number)
          Increases the counter by the number specified.
 void increaseCacheRemovals(long number)
          Increases the counter by the number specified.
 void readData(ObjectDataInput in)
          Reads fields from the input stream
 void writeData(ObjectDataOutput out)
          Writes object fields to output stream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CacheStatisticsImpl

public CacheStatisticsImpl()
Method Detail

getCacheRemovals

public long getCacheRemovals()
Description copied from interface: CacheStatistics
The total number of removals from the cache. This does not include evictions, where the cache itself initiates the removal to make space.

Specified by:
getCacheRemovals in interface CacheStatistics
Returns:
the number of removals

getCacheExpiries

public long getCacheExpiries()
The total number of expiries from the cache. An expiry may or may not be evicted. This number represents the entries that fail evaluation and may not include the entries which are not yet evaluated for expiry or not accessed.

Returns:
the number of expiries.

getCacheGets

public long getCacheGets()
Description copied from interface: CacheStatistics
The total number of requests to the cache. This will be equal to the sum of the hits and misses.

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.

Specified by:
getCacheGets in interface CacheStatistics
Returns:
the number of gets

getCachePuts

public long getCachePuts()
Description copied from interface: CacheStatistics
The total number of puts to the cache.

A put is counted even if it is immediately evicted.

Replaces, where a put occurs which overrides an existing mapping is counted as a put.

Specified by:
getCachePuts in interface CacheStatistics
Returns:
the number of puts

getCacheHits

public long getCacheHits()
Description copied from interface: CacheStatistics
The number of get requests that were satisfied by the cache.

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.

Specified by:
getCacheHits in interface CacheStatistics
Returns:
the number of hits

getCacheMisses

public long getCacheMisses()
Description copied from interface: CacheStatistics
A miss is a get request that is not satisfied.

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.

Specified by:
getCacheMisses in interface CacheStatistics
Returns:
the number of misses

getCacheEvictions

public long getCacheEvictions()
Description copied from interface: CacheStatistics
The total number of evictions from the cache. An eviction is a removal initiated by the cache itself to free up space. An eviction is not treated as a removal and does not appear in the removal counts.

Specified by:
getCacheEvictions in interface CacheStatistics
Returns:
the number of evictions

getCachePutTimeTakenNanos

public long getCachePutTimeTakenNanos()

getCacheGetTimeTakenNanos

public long getCacheGetTimeTakenNanos()

getCacheRemoveTimeTakenNanos

public long getCacheRemoveTimeTakenNanos()

getCacheHitPercentage

public float getCacheHitPercentage()
Description copied from interface: CacheStatistics
This is a measure of cache efficiency.

It is calculated as: CacheStatistics.getCacheHits() divided by () * 100.

Specified by:
getCacheHitPercentage in interface CacheStatistics
Returns:
the percentage of successful hits, as a decimal, e.g 75

getCacheMissPercentage

public float getCacheMissPercentage()
Description copied from interface: CacheStatistics
Returns the percentage of cache accesses that did not find a requested entry in the cache.

This is calculated as CacheStatistics.getCacheMisses() divided by CacheStatistics.getCacheGets() * 100.

Specified by:
getCacheMissPercentage in interface CacheStatistics
Returns:
the percentage of accesses that failed to find anything

getAverageGetTime

public float getAverageGetTime()
Description copied from interface: CacheStatistics
The mean time to execute gets.

In a read-through cache, the time taken to load an entry on miss is not included in get time.

Specified by:
getAverageGetTime in interface CacheStatistics
Returns:
the time in µs

getAveragePutTime

public float getAveragePutTime()
Description copied from interface: CacheStatistics
The mean time to execute puts.

Specified by:
getAveragePutTime in interface CacheStatistics
Returns:
the time in µs

getAverageRemoveTime

public float getAverageRemoveTime()
Description copied from interface: CacheStatistics
The mean time to execute removes.

Specified by:
getAverageRemoveTime in interface CacheStatistics
Returns:
the time in µs

clear

public void clear()
Implementation of CacheStatisticsMXBean.clear().

See Also:
CacheStatisticsMXBean.clear()

increaseCacheRemovals

public void increaseCacheRemovals(long number)
Increases the counter by the number specified.

Parameters:
number - the number by which the counter is increased.

increaseCacheExpiries

public void increaseCacheExpiries(long number)
Increases the counter by the number specified.

Parameters:
number - the number by which the counter is increased.

increaseCachePuts

public void increaseCachePuts(long number)
Increases the counter by the number specified.

Parameters:
number - the number by which the counter is increased.

increaseCacheHits

public void increaseCacheHits(long number)
Increases the counter by the number specified.

Parameters:
number - the number by which the counter is increased.

increaseCacheMisses

public void increaseCacheMisses(long number)
Increases the counter by the number specified.

Parameters:
number - the number by which the counter is increased.

increaseCacheEvictions

public void increaseCacheEvictions(long number)
Increases the counter by the number specified.

Parameters:
number - the number by which the counter is increased.

addGetTimeNanos

public void addGetTimeNanos(long duration)
Increments the getCache time accumulator.

Parameters:
duration - the time taken in nanoseconds.

addPutTimeNanos

public void addPutTimeNanos(long duration)
Increments the put time accumulator.

Parameters:
duration - the time taken in nanoseconds.

addRemoveTimeNanos

public void addRemoveTimeNanos(long duration)
Increments the remove time accumulator.

Parameters:
duration - the time taken in nanoseconds.

accumulate

public CacheStatisticsImpl accumulate(CacheStatisticsImpl other)
Simple CacheStatistics adder. Can be used to merge two statistics data, such as the ones collected from multiple nodes.

Parameters:
other - CacheStatisticsImpl to be merged.
Returns:
CacheStatisticsImpl with merged data.

writeData

public void writeData(ObjectDataOutput out)
               throws IOException
Description copied from interface: DataSerializable
Writes object fields to output stream

Specified by:
writeData in interface DataSerializable
Parameters:
out - output
Throws:
IOException

readData

public void readData(ObjectDataInput in)
              throws IOException
Description copied from interface: DataSerializable
Reads fields from the input stream

Specified by:
readData in interface DataSerializable
Parameters:
in - input
Throws:
IOException


Copyright © 2015 Hazelcast, Inc.. All Rights Reserved.