Java 类net.sf.ehcache.Statistics 实例源码

项目:proxyma    文件:EhcacheCacheProvider.java   
/**
 * This method does nothing.
 * @return always the same message
 */
@Override
public String getStatistics() {
    Statistics ehcacheStats = theCache.getStatistics();
    StringBuffer stats = new StringBuffer();
    stats.append("---- Proxyma EhcacheProvider Plugin Statisctics ----");
    stats.append("\nCache instance Name: ");
    stats.append(theCache.getName());
    stats.append("\nCache status: ");
    stats.append(theCache.getStatus());
    stats.append("\nNumber of elements currently on the cache: ");
    stats.append(theCache.getSize());
    stats.append("\nNumber of elements into the Memory Store: ");
    stats.append(theCache.getMemoryStoreSize());
    stats.append("\nNumber of elements into the Disk Store: ");
    stats.append(theCache.getDiskStoreSize());
    stats.append("\nNumber of Cache HITS: ");
    stats.append(ehcacheStats.getCacheHits());
    stats.append("\nNumber of Cache MISS: ");
    stats.append(ehcacheStats.getCacheMisses());
    stats.append("\n---- End of EhcacheProvider Plugin Statisctics ----\n");
    return stats.toString();
}
项目:tesora-dve-pub    文件:CatalogDAO.java   
public static void shutdown() {
    if (Boolean.getBoolean("CatalogDAO.printCacheStatistics")) {
        CacheManager cm = CacheManager.getInstance();
        for (String s : cm.getCacheNames()) {
            if (s.matches("com.tesora.dve.*")) {
                Statistics stats = cm.getCache(s).getStatistics();
                System.out.println("Cache " + s + ": " + stats.getObjectCount() +
                        " items (" + stats.getCacheHits() + " hits, " + stats.getCacheMisses() + " misses)");
            }
        }
    }
    INSTANCE.lookupCacheMap.clear();
    if (INSTANCE.emf != null)
        INSTANCE.emf.close();
    INSTANCE.emf = null;
}
项目:iaf    文件:IbisCacheManager.java   
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);
    }
}
项目:document-management-system    文件:CacheStatsServlet.java   
/**
 * View log
 */
private void view(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
    log.debug("view({}, {})", request, response);
    refresh();

    List<Map<String, String>> cacheStats = new ArrayList<Map<String, String>>();

    for (String cache : cacheStatistics.keySet()) {
        Statistics stats = cacheStatistics.get(cache);

        Map<String, String> stat = new HashMap<String, String>();
        stat.put("cache", cache);
        stat.put("cacheHits", Long.toString(stats.getCacheHits()));
        stat.put("cacheMisses", Long.toString(stats.getCacheMisses()));
        stat.put("objectCount", Long.toString(stats.getObjectCount()));
        stat.put("inMemoryHits", Long.toString(stats.getInMemoryHits()));
        stat.put("inMemoryMisses", Long.toString(stats.getInMemoryMisses()));
        stat.put("memoryStoreObjectCount", Long.toString(stats.getMemoryStoreObjectCount()));
        stat.put("onDiskHits", Long.toString(stats.getOnDiskHits()));
        stat.put("onDiskMisses", Long.toString(stats.getOnDiskMisses()));
        stat.put("diskStoreObjectCount", Long.toString(stats.getDiskStoreObjectCount()));

        cacheStats.add(stat);
    }

    ServletContext sc = getServletContext();
    sc.setAttribute("cacheStats", cacheStats);
    sc.setAttribute("statsEnabled", statsEnabled);
    sc.getRequestDispatcher("/admin/cache_stats.jsp").forward(request, response);

    // Activity log
    UserActivity.log(request.getRemoteUser(), "ADMIN_CACHE_STATS", null, null, null);

    log.debug("view: void");
}
项目:api-gateway    文件:CacheMetricGenerator.java   
private Map<String, Long> buildCacheResult(Cache cache) {
    Statistics cacheStatistics = cache.getStatistics();
    LiveCacheStatistics liveCacheStatistics = cache.getLiveCacheStatistics();

    Map<String, Long> cacheData = new LinkedHashMap<>();

    cacheData.put("size", liveCacheStatistics.getSize());
    cacheData.put("cacheHits", cacheStatistics.getCacheHits());
    cacheData.put("cacheMisses", cacheStatistics.getCacheMisses());
    cacheData.put("putCount", liveCacheStatistics.getPutCount());
    cacheData.put("evictionCount", cacheStatistics.getEvictionCount());

    cacheData.put("averageSearchTime", cacheStatistics.getAverageSearchTime());
    cacheData.put("inMemoryHits", cacheStatistics.getInMemoryHits());
    cacheData.put("inMemoryMisses", cacheStatistics.getInMemoryMisses());
    cacheData.put("objectCount", cacheStatistics.getObjectCount());
    cacheData.put("offHeapHits", cacheStatistics.getOffHeapHits());
    cacheData.put("offHeapMisses", cacheStatistics.getOffHeapMisses());
    cacheData.put("onDiskHits", cacheStatistics.getOnDiskHits());
    cacheData.put("onDiskMisses", cacheStatistics.getOnDiskMisses());
    cacheData.put("searchesPerSecond", cacheStatistics.getSearchesPerSecond());

    cacheData.put("expiredCount", liveCacheStatistics.getExpiredCount());
    cacheData.put("localHeapSize", liveCacheStatistics.getLocalHeapSize());
    cacheData.put("localOffHeapSize", liveCacheStatistics.getLocalOffHeapSize());
    cacheData.put("removedCount", liveCacheStatistics.getRemovedCount());
    cacheData.put("updateCount", liveCacheStatistics.getUpdateCount());

    cacheData.put("maxGetTimeMillis", liveCacheStatistics.getMaxGetTimeNanos() / 1000000L);
    return cacheData;
}
项目:FinanceAnalytics    文件:DebugStatistics.java   
private void report(final Cache cache) {
  final Statistics stats = cache.getStatistics();
  final long hits = stats.getCacheHits();
  final long misses = stats.getCacheMisses();
  final double ratio = (misses != 0) ? (double) hits / (double) misses : 0d;
  _logger.info("Cache {} hits = {}, misses = {}, ratio = {}", new Object[] {cache.getName(), hits, misses, ratio});
}
项目:incubator-rya    文件:NamespaceManager.java   
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());
    }
}
项目:proxyma    文件:EhcacheCacheProvider.java   
/**
 * Initialize the cache manager singleton of ecache.
 * @param context the proxyma context
 */
private synchronized void initializeCacheManager(ProxymaContext context) {
    try {
        if (ehCacheManager == null) {
            ehCacheManager = new CacheManager(new ByteArrayInputStream(forgeEhcacheConfiguration(context)));
            ehCacheManager.addCache(context.getName());
            Cache addedCache = ehCacheManager.getCache(context.getName());
            addedCache.setStatisticsAccuracy(Statistics.STATISTICS_ACCURACY_BEST_EFFORT);
            log.info("Ehcahe subsystem for context \"" + context.getName() + "\" initialized..");
        }
    } catch (UnsupportedEncodingException ex) {
        log.log(Level.SEVERE, "Unable to initialize ehcache subsystem!", ex);
    }
}
项目:cqrs4j    文件:NoCache.java   
/**
 * {@inheritDoc}
 */
@Override
public CacheStatistics getCacheStatistics() {
    return new JCacheStatistics(new Statistics(null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
}