Search in sources :

Example 1 with Statistics

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;
}
Also used : TreeMap(java.util.TreeMap) Statistics(net.sf.ehcache.Statistics) CacheConfiguration(net.sf.ehcache.config.CacheConfiguration) Cache(net.sf.ehcache.Cache)

Example 2 with Statistics

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));
}
Also used : CacheManager(net.sf.ehcache.CacheManager) Statistics(net.sf.ehcache.Statistics) MarkupCache(org.apache.wicket.markup.MarkupCache) Cache(net.sf.ehcache.Cache)

Example 3 with Statistics

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);
    }
}
Also used : Ehcache(net.sf.ehcache.Ehcache) Statistics(net.sf.ehcache.Statistics)

Example 4 with Statistics

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());
    }
}
Also used : Statistics(net.sf.ehcache.Statistics)

Example 5 with Statistics

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));
}
Also used : CacheManager(net.sf.ehcache.CacheManager) Statistics(net.sf.ehcache.Statistics) MarkupCache(org.apache.wicket.markup.MarkupCache) Cache(net.sf.ehcache.Cache)

Aggregations

Statistics (net.sf.ehcache.Statistics)7 Cache (net.sf.ehcache.Cache)4 CacheManager (net.sf.ehcache.CacheManager)2 CacheConfiguration (net.sf.ehcache.config.CacheConfiguration)2 MarkupCache (org.apache.wicket.markup.MarkupCache)2 Column (com.github.mpjct.jmpjct.mysql.proto.Column)1 ERR (com.github.mpjct.jmpjct.mysql.proto.ERR)1 OK (com.github.mpjct.jmpjct.mysql.proto.OK)1 ResultSet (com.github.mpjct.jmpjct.mysql.proto.ResultSet)1 Row (com.github.mpjct.jmpjct.mysql.proto.Row)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 TreeMap (java.util.TreeMap)1 Ehcache (net.sf.ehcache.Ehcache)1 Element (net.sf.ehcache.Element)1 Strategy (net.sf.ehcache.config.PersistenceConfiguration.Strategy)1 TerracottaClientConfiguration (net.sf.ehcache.config.TerracottaClientConfiguration)1 TerracottaNotRunningException (net.sf.ehcache.terracotta.TerracottaNotRunningException)1