Example usage for com.google.common.cache CacheStats missRate

List of usage examples for com.google.common.cache CacheStats missRate

Introduction

In this page you can find the example usage for com.google.common.cache CacheStats missRate.

Prototype

public double missRate() 

Source Link

Document

Returns the ratio of cache requests which were misses.

Usage

From source file:org.springframework.boot.actuate.cache.GuavaCacheStatisticsProvider.java

@Override
public CacheStatistics getCacheStatistics(CacheManager cacheManager, GuavaCache cache) {
    DefaultCacheStatistics statistics = new DefaultCacheStatistics();
    statistics.setSize(cache.getNativeCache().size());
    CacheStats guavaStats = cache.getNativeCache().stats();
    if (guavaStats.requestCount() > 0) {
        statistics.setHitRatio(guavaStats.hitRate());
        statistics.setMissRatio(guavaStats.missRate());
    }/* w w  w  .  j  ava 2 s .  c  o m*/
    return statistics;
}

From source file:com.comcast.cdn.traffic_control.traffic_router.core.util.DataExporter.java

private Map<String, Object> createCacheStatsMap(final CacheStats cacheStats) {
    final Map<String, Object> cacheStatsMap = new HashMap<String, Object>();
    cacheStatsMap.put("requestCount", cacheStats.requestCount());
    cacheStatsMap.put("hitCount", cacheStats.hitCount());
    cacheStatsMap.put("missCount", cacheStats.missCount());
    cacheStatsMap.put("hitRate", cacheStats.hitRate());
    cacheStatsMap.put("missRate", cacheStats.missRate());
    cacheStatsMap.put("evictionCount", cacheStats.evictionCount());
    cacheStatsMap.put("loadCount", cacheStats.loadCount());
    cacheStatsMap.put("loadSuccessCount", cacheStats.loadSuccessCount());
    cacheStatsMap.put("loadExceptionCount", cacheStats.loadExceptionCount());
    cacheStatsMap.put("loadExceptionRate", cacheStats.loadExceptionRate());
    cacheStatsMap.put("totalLoadTime", cacheStats.totalLoadTime());
    cacheStatsMap.put("averageLoadPenalty", cacheStats.averageLoadPenalty());
    return cacheStatsMap;
}

From source file:info.archinnov.achilles.internals.cache.StatementsCache.java

private void displayCacheStatistics() {

    long cacheSize = dynamicCache.size();
    CacheStats cacheStats = dynamicCache.stats();

    LOGGER.info("Total LRU cache size {}", cacheSize);
    if (cacheSize > (maxLRUCacheSize * 0.8)) {
        LOGGER.warn("Warning, the LRU prepared statements cache is over 80% full");
    }/*from   w w w .jav a2s .  co m*/

    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Cache statistics :");
        LOGGER.debug("\t\t- hits count : {}", cacheStats.hitCount());
        LOGGER.debug("\t\t- hits rate : {}", cacheStats.hitRate());
        LOGGER.debug("\t\t- miss count : {}", cacheStats.missCount());
        LOGGER.debug("\t\t- miss rate : {}", cacheStats.missRate());
        LOGGER.debug("\t\t- eviction count : {}", cacheStats.evictionCount());
        LOGGER.debug("\t\t- load count : {}", cacheStats.loadCount());
        LOGGER.debug("\t\t- load success count : {}", cacheStats.loadSuccessCount());
        LOGGER.debug("\t\t- load exception count : {}", cacheStats.loadExceptionCount());
        LOGGER.debug("\t\t- total load time : {}", cacheStats.totalLoadTime());
        LOGGER.debug("\t\t- average load penalty : {}", cacheStats.averageLoadPenalty());
        LOGGER.debug("");
        LOGGER.debug("");
    }
}

From source file:com.adobe.acs.commons.util.impl.AbstractGuavaCacheMBean.java

@Override
@SuppressWarnings("squid:S1192")
public final TabularData getCacheStats() throws OpenDataException {
    // Exposing all google guava stats.
    final CompositeType cacheEntryType = new CompositeType(JMX_PN_CACHESTATS, JMX_PN_CACHESTATS,
            new String[] { JMX_PN_STAT, JMX_PN_VALUE }, new String[] { JMX_PN_STAT, JMX_PN_VALUE },
            new OpenType[] { SimpleType.STRING, SimpleType.STRING });

    final TabularDataSupport tabularData = new TabularDataSupport(new TabularType(JMX_PN_CACHESTATS,
            JMX_PN_CACHESTATS, cacheEntryType, new String[] { JMX_PN_STAT }));

    CacheStats cacheStats = getCache().stats();

    final Map<String, Object> row = new HashMap<String, Object>();

    row.put(JMX_PN_STAT, "Request Count");
    row.put(JMX_PN_VALUE, String.valueOf(cacheStats.requestCount()));
    tabularData.put(new CompositeDataSupport(cacheEntryType, row));

    row.put(JMX_PN_STAT, "Hit Count");
    row.put(JMX_PN_VALUE, String.valueOf(cacheStats.hitCount()));
    tabularData.put(new CompositeDataSupport(cacheEntryType, row));

    row.put(JMX_PN_STAT, "Hit Rate");
    row.put(JMX_PN_VALUE, String.format("%.0f%%", cacheStats.hitRate() * 100));
    tabularData.put(new CompositeDataSupport(cacheEntryType, row));

    row.put(JMX_PN_STAT, "Miss Count");
    row.put(JMX_PN_VALUE, String.valueOf(cacheStats.missCount()));
    tabularData.put(new CompositeDataSupport(cacheEntryType, row));

    row.put(JMX_PN_STAT, "Miss Rate");
    row.put(JMX_PN_VALUE, String.format("%.0f%%", cacheStats.missRate() * 100));
    tabularData.put(new CompositeDataSupport(cacheEntryType, row));

    row.put(JMX_PN_STAT, "Eviction Count");
    row.put(JMX_PN_VALUE, String.valueOf(cacheStats.evictionCount()));
    tabularData.put(new CompositeDataSupport(cacheEntryType, row));

    row.put(JMX_PN_STAT, "Load Count");
    row.put(JMX_PN_VALUE, String.valueOf(cacheStats.loadCount()));
    tabularData.put(new CompositeDataSupport(cacheEntryType, row));

    row.put(JMX_PN_STAT, "Load Exception Count");
    row.put(JMX_PN_VALUE, String.valueOf(cacheStats.loadExceptionCount()));
    tabularData.put(new CompositeDataSupport(cacheEntryType, row));

    row.put(JMX_PN_STAT, "Load Exception Rate");
    row.put(JMX_PN_VALUE, String.format("%.0f%%", cacheStats.loadExceptionRate() * 100));
    tabularData.put(new CompositeDataSupport(cacheEntryType, row));

    row.put(JMX_PN_STAT, "Load Success Count");
    row.put(JMX_PN_VALUE, String.valueOf(cacheStats.loadSuccessCount()));
    tabularData.put(new CompositeDataSupport(cacheEntryType, row));

    row.put(JMX_PN_STAT, "Average Load Penalty");
    row.put(JMX_PN_VALUE, String.valueOf(cacheStats.averageLoadPenalty()));
    tabularData.put(new CompositeDataSupport(cacheEntryType, row));

    row.put(JMX_PN_STAT, "Total Load Time");
    row.put(JMX_PN_VALUE, String.valueOf(cacheStats.totalLoadTime()));
    tabularData.put(new CompositeDataSupport(cacheEntryType, row));

    return tabularData;
}

From source file:org.springframework.integration.jdbc.StoredProcExecutor.java

/**
 * Allows for the retrieval of metrics ({@link CacheStats}}) for the
 * {@link StoredProcExecutor#jdbcCallOperationsCache}.
 *
 * Provides the properties of {@link CacheStats} as a {@link Map}. This allows
 * for exposing the those properties easily via JMX.
 *
 * @return Map containing metrics of the JdbcCallOperationsCache
 *
 * @see StoredProcExecutor#getJdbcCallOperationsCacheStatistics()
 *//* w  ww  .j  av a2 s  . c  o  m*/
@ManagedMetric
public Map<String, Object> getJdbcCallOperationsCacheStatisticsAsMap() {
    final CacheStats cacheStats = this.getJdbcCallOperationsCacheStatistics();
    final Map<String, Object> cacheStatistics = new HashMap<String, Object>(11);
    cacheStatistics.put("averageLoadPenalty", cacheStats.averageLoadPenalty());
    cacheStatistics.put("evictionCount", cacheStats.evictionCount());
    cacheStatistics.put("hitCount", cacheStats.hitCount());
    cacheStatistics.put("hitRate", cacheStats.hitRate());
    cacheStatistics.put("loadCount", cacheStats.loadCount());
    cacheStatistics.put("loadExceptionCount", cacheStats.loadExceptionCount());
    cacheStatistics.put("loadExceptionRate", cacheStats.loadExceptionRate());
    cacheStatistics.put("loadSuccessCount", cacheStats.loadSuccessCount());
    cacheStatistics.put("missCount", cacheStats.missCount());
    cacheStatistics.put("missRate", cacheStats.missRate());
    cacheStatistics.put("totalLoadTime", cacheStats.totalLoadTime());
    return Collections.unmodifiableMap(cacheStatistics);
}