use of net.sf.ehcache.Statistics in project uPortal by Jasig.
the class CacheManagementHelper method getAllCacheStatistics.
public Map<String, CacheStatistics> getAllCacheStatistics() {
final Map<String, CacheStatistics> allCacheStatistics = new TreeMap<String, CacheStatistics>(CaseInsenstivieStringComparator.INSTANCE);
for (final String cacheName : this.cacheManager.getCacheNames()) {
final Cache cache = this.cacheManager.getCache(cacheName);
if (null != cache && Status.STATUS_ALIVE.equals(cache.getStatus())) {
final CacheConfiguration cacheConfiguration = cache.getCacheConfiguration();
final Statistics statistics = cache.getStatistics();
final CacheStatistics cacheStatistics = new CacheStatistics();
cacheStatistics.hits = statistics.getCacheHits();
cacheStatistics.misses = statistics.getCacheMisses();
cacheStatistics.size = statistics.getObjectCount();
cacheStatistics.maxSize = cacheConfiguration.getMaxElementsInMemory() + cacheConfiguration.getMaxElementsOnDisk();
allCacheStatistics.put(cacheName, cacheStatistics);
}
}
return allCacheStatistics;
}
use of net.sf.ehcache.Statistics in project oc-explorer by devgateway.
the class MarkupCacheService method getReportsStat.
/**
* Display some statistics about reports cache
*/
public void getReportsStat() {
CacheManager cm = CacheManager.getInstance();
// get the reports cache "reportsCache", declared in ehcache.xml
Cache cache = cm.getCache("reportsCache");
@SuppressWarnings("unchecked") List<String> cacheKeys = cache.getKeys();
long size = 0;
for (String k : cacheKeys) {
logger.info("key: " + k);
byte[] buf = (byte[]) cache.get(k).getObjectValue();
size += buf.length;
}
Statistics stats = cache.getStatistics();
StringBuffer sb = new StringBuffer();
sb.append(String.format("%s objects, %s hits, %s misses\n", stats.getObjectCount(), stats.getCacheHits(), stats.getCacheMisses()));
logger.info(String.valueOf(sb));
logger.info("cache total size: " + FileUtils.byteCountToDisplaySize(size));
}
use of net.sf.ehcache.Statistics in project iaf by ibissource.
the class IbisCacheManager method iterateOverStatistics.
public static void iterateOverStatistics(StatisticsKeeperIterationHandler hski, Object data, int action) throws SenderException {
if (self == null) {
return;
}
String[] cacheNames = self.cacheManager.getCacheNames();
for (int i = 0; i < cacheNames.length; i++) {
Object subdata = hski.openGroup(data, cacheNames[i], "cache");
Ehcache cache = self.cacheManager.getEhcache(cacheNames[i]);
Statistics stats = cache.getStatistics();
stats.getAverageGetTime();
hski.handleScalar(subdata, "CacheHits", stats.getCacheHits());
hski.handleScalar(subdata, "CacheMisses", stats.getCacheMisses());
hski.handleScalar(subdata, "EvictionCount", stats.getEvictionCount());
hski.handleScalar(subdata, "InMemoryHits", stats.getInMemoryHits());
hski.handleScalar(subdata, "ObjectCount", stats.getObjectCount());
hski.handleScalar(subdata, "OnDiskHits", stats.getOnDiskHits());
hski.closeGroup(subdata);
}
}
use of net.sf.ehcache.Statistics in project incubator-rya by apache.
the class NamespaceManager method printStatistics.
public void printStatistics() {
Statistics statistics = namespaceCache.getStatistics();
if (statistics != null) {
// TODO: use a logger please
System.out.println("Namespace Cache Statisitics: ");
System.out.println("--Hits: \t" + statistics.getCacheHits());
System.out.println("--Misses: \t" + statistics.getCacheMisses());
System.out.println("--Total Count: \t" + statistics.getObjectCount());
}
}
use of net.sf.ehcache.Statistics in project ocvn by devgateway.
the class MarkupCacheService method getReportsStat.
/**
* Display some statistics about reports cache
*/
public void getReportsStat() {
CacheManager cm = CacheManager.getInstance();
// get the reports cache "reportsCache", declared in ehcache.xml
Cache cache = cm.getCache("reportsCache");
@SuppressWarnings("unchecked") List<String> cacheKeys = cache.getKeys();
long size = 0;
for (String k : cacheKeys) {
logger.info("key: " + k);
byte[] buf = (byte[]) cache.get(k).getObjectValue();
size += buf.length;
}
Statistics stats = cache.getStatistics();
StringBuffer sb = new StringBuffer();
sb.append(String.format("%s objects, %s hits, %s misses\n", stats.getObjectCount(), stats.getCacheHits(), stats.getCacheMisses()));
logger.info(String.valueOf(sb));
logger.info("cache total size: " + FileUtils.byteCountToDisplaySize(size));
}
Aggregations