Class JCacheStatisticsMXBean
- java.lang.Object
-
- com.github.benmanes.caffeine.jcache.management.JCacheStatisticsMXBean
-
- All Implemented Interfaces:
javax.cache.management.CacheStatisticsMXBean
public final class JCacheStatisticsMXBean extends java.lang.Object implements javax.cache.management.CacheStatisticsMXBean
Caffeine JCache statistics.
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
enabled
private java.util.concurrent.atomic.LongAdder
evictions
private java.util.concurrent.atomic.LongAdder
getTimeNanos
private java.util.concurrent.atomic.LongAdder
hits
private java.util.concurrent.atomic.LongAdder
misses
private java.util.concurrent.atomic.LongAdder
puts
private java.util.concurrent.atomic.LongAdder
putTimeNanos
private java.util.concurrent.atomic.LongAdder
removals
private java.util.concurrent.atomic.LongAdder
removeTimeNanos
-
Constructor Summary
Constructors Constructor Description JCacheStatisticsMXBean()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static float
average(long requestCount, long opsTimeNanos)
void
clear()
void
enable(boolean enabled)
Sets whether the statistic collection is enabled.float
getAverageGetTime()
float
getAveragePutTime()
float
getAverageRemoveTime()
long
getCacheEvictions()
long
getCacheGets()
float
getCacheHitPercentage()
long
getCacheHits()
long
getCacheMisses()
float
getCacheMissPercentage()
long
getCachePuts()
long
getCacheRemovals()
boolean
isEnabled()
void
recordEvictions(@org.checkerframework.checker.index.qual.NonNegative long count)
Records cache evictions.void
recordGetTime(long durationNanos)
Records the time to execute get operations.void
recordHits(@org.checkerframework.checker.index.qual.NonNegative long count)
Records cache hits.void
recordMisses(@org.checkerframework.checker.index.qual.NonNegative long count)
Records cache misses.void
recordPuts(@org.checkerframework.checker.index.qual.NonNegative long count)
Records cache insertion and updates.void
recordPutTime(long durationNanos)
Records the time to execute put operations.void
recordRemovals(@org.checkerframework.checker.index.qual.NonNegative long count)
Records cache removals.void
recordRemoveTime(long durationNanos)
Records the time to execute remove operations.
-
-
-
Field Detail
-
puts
private final java.util.concurrent.atomic.LongAdder puts
-
hits
private final java.util.concurrent.atomic.LongAdder hits
-
misses
private final java.util.concurrent.atomic.LongAdder misses
-
removals
private final java.util.concurrent.atomic.LongAdder removals
-
evictions
private final java.util.concurrent.atomic.LongAdder evictions
-
putTimeNanos
private final java.util.concurrent.atomic.LongAdder putTimeNanos
-
getTimeNanos
private final java.util.concurrent.atomic.LongAdder getTimeNanos
-
removeTimeNanos
private final java.util.concurrent.atomic.LongAdder removeTimeNanos
-
enabled
private volatile boolean enabled
-
-
Method Detail
-
isEnabled
public boolean isEnabled()
- Returns:
- if statistic collection is enabled.
-
enable
public void enable(boolean enabled)
Sets whether the statistic collection is enabled.- Parameters:
enabled
- whether to collect statistics
-
clear
public void clear()
- Specified by:
clear
in interfacejavax.cache.management.CacheStatisticsMXBean
-
getCacheHits
public long getCacheHits()
- Specified by:
getCacheHits
in interfacejavax.cache.management.CacheStatisticsMXBean
-
getCacheHitPercentage
public float getCacheHitPercentage()
- Specified by:
getCacheHitPercentage
in interfacejavax.cache.management.CacheStatisticsMXBean
-
recordHits
public void recordHits(@org.checkerframework.checker.index.qual.NonNegative long count)
Records cache hits. This should be called when a cache request returns a cached value.- Parameters:
count
- the number of hits to record
-
getCacheMisses
public long getCacheMisses()
- Specified by:
getCacheMisses
in interfacejavax.cache.management.CacheStatisticsMXBean
-
getCacheMissPercentage
public float getCacheMissPercentage()
- Specified by:
getCacheMissPercentage
in interfacejavax.cache.management.CacheStatisticsMXBean
-
recordMisses
public void recordMisses(@org.checkerframework.checker.index.qual.NonNegative long count)
Records cache misses. This should be called when a cache request returns a value that was not found in the cache.- Parameters:
count
- the number of misses to record
-
getCacheGets
public long getCacheGets()
- Specified by:
getCacheGets
in interfacejavax.cache.management.CacheStatisticsMXBean
-
getCachePuts
public long getCachePuts()
- Specified by:
getCachePuts
in interfacejavax.cache.management.CacheStatisticsMXBean
-
recordPuts
public void recordPuts(@org.checkerframework.checker.index.qual.NonNegative long count)
Records cache insertion and updates.- Parameters:
count
- the number of writes to record
-
getCacheRemovals
public long getCacheRemovals()
- Specified by:
getCacheRemovals
in interfacejavax.cache.management.CacheStatisticsMXBean
-
recordRemovals
public void recordRemovals(@org.checkerframework.checker.index.qual.NonNegative long count)
Records cache removals.- Parameters:
count
- the number of removals to record
-
getCacheEvictions
public long getCacheEvictions()
- Specified by:
getCacheEvictions
in interfacejavax.cache.management.CacheStatisticsMXBean
-
recordEvictions
public void recordEvictions(@org.checkerframework.checker.index.qual.NonNegative long count)
Records cache evictions.- Parameters:
count
- the number of evictions to record
-
getAverageGetTime
public float getAverageGetTime()
- Specified by:
getAverageGetTime
in interfacejavax.cache.management.CacheStatisticsMXBean
-
recordGetTime
public void recordGetTime(long durationNanos)
Records the time to execute get operations. This time does not include the time it takes to load an entry on a cache miss, as specified by the specification.- Parameters:
durationNanos
- the amount of time in nanoseconds
-
getAveragePutTime
public float getAveragePutTime()
- Specified by:
getAveragePutTime
in interfacejavax.cache.management.CacheStatisticsMXBean
-
recordPutTime
public void recordPutTime(long durationNanos)
Records the time to execute put operations.- Parameters:
durationNanos
- the amount of time in nanoseconds
-
getAverageRemoveTime
public float getAverageRemoveTime()
- Specified by:
getAverageRemoveTime
in interfacejavax.cache.management.CacheStatisticsMXBean
-
recordRemoveTime
public void recordRemoveTime(long durationNanos)
Records the time to execute remove operations.- Parameters:
durationNanos
- the amount of time in nanoseconds
-
average
private static float average(long requestCount, long opsTimeNanos)
-
-