com.alachisoft.ncache.jsr107.NCacheStatisticsMXBean Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ncache-professional-client Show documentation
Show all versions of ncache-professional-client Show documentation
NCache Professional client for java.
package com.alachisoft.ncache.jsr107;
import javax.cache.management.CacheStatisticsMXBean;
public class NCacheStatisticsMXBean extends NCacheMXBean implements CacheStatisticsMXBean {
/**
* @param jCache
*/
public NCacheStatisticsMXBean(final NCacheCache jCache) {
super(jCache, "Statistics");
}
/**
* Clears the statistics counters to 0 for the associated Cache.
*/
@Override
public void clear() {
//throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
jCache.clear();
}
/**
* The number of get requests that were satisfied by the cache.
*
* @return
*/
@Override
public long getCacheHits() {
//throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
return Math.round(getTayzGrid().getHitsPerSec());
}
/**
* This is a measure of cache efficiency.
*
* @return
*/
@Override
public float getCacheHitPercentage() {
//throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
double val = Math.round(getTayzGrid().getHitsRatioSec());
if (Double.isNaN(val)) {
return getTayzGrid().getHitsPerSec() == 0 ? 0f : 100f;
}
return (float) val * 100;
}
/**
* A miss is a get request that is not satisfied.
*
* @return
*/
@Override
public long getCacheMisses() {
//throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
return Math.round(getTayzGrid().getCount());
}
/**
* Returns the percentage of cache accesses that did not find a requested entry in the cache.
*
* @return
*/
@Override
public float getCacheMissPercentage() {
//throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
final double v = getTayzGrid().getHitsRatioSec();
if (Double.isNaN(v)) {
return 0f;
}
return (float) (1 - v) * 100;
}
/**
* The total number of requests to the cache. This will be equal to the sum of the hits and misses.
*
* @return
*/
@Override
public long getCacheGets() {
//throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
return (long) getTayzGrid().getGetsPerSec();
}
/**
* The total number of puts to the cache.
*
* @return
*/
@Override
public long getCachePuts() {
//throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
return (long) getTayzGrid().getInsertsPerSec();
}
/**
* The total number of removals from the cache. This does not include evictions, where the cache itself initiates the removal to make space.
*
* @return
*/
@Override
public long getCacheRemovals() {
//throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
return (long) getTayzGrid().getDelsPerSec();
}
/**
* 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.
*
* @return
*/
@Override
public long getCacheEvictions() {
//throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
return (long) getTayzGrid().getEvictionPerSec();
}
/**
* The mean time to execute gets.
*
* @return
*/
@Override
public float getAverageGetTime() {
//throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
return (long) getTayzGrid().getGetsPerSec();
}
/**
* The mean time to execute puts.
*
* @return
*/
@Override
public float getAveragePutTime() {
//throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
return (long) getTayzGrid().getInsertsPerSec();
}
/**
* The mean time to execute removes.
*
* @return
*/
@Override
public float getAverageRemoveTime() {
//throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
return (long) getTayzGrid().getDelsPerSec();
}
}