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

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

Introduction

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

Prototype

public double averageLoadPenalty() 

Source Link

Document

Returns the average time spent loading new values.

Usage

From source file:it.units.malelab.ege.core.listener.collector.CacheStatistics.java

@Override
public Map<String, Object> collect(GenerationEvent generationEvent) {
    CacheStats mappingStats = (CacheStats) generationEvent.getData().get(StandardEvolver.MAPPING_CACHE_NAME);
    CacheStats fitnessStats = (CacheStats) generationEvent.getData().get(StandardEvolver.FITNESS_CACHE_NAME);
    Map<String, Object> map = new LinkedHashMap<>();
    map.put("cache.mapping.miss.count", mappingStats.missCount());
    map.put("cache.mapping.hit.rate", mappingStats.hitRate());
    map.put("cache.mapping.avg.load.penalty", mappingStats.averageLoadPenalty() / 1000);
    map.put("cache.fitness.miss.count", fitnessStats.missCount());
    map.put("cache.fitness.hit.rate", fitnessStats.hitRate());
    map.put("cache.fitness.avg.load.penalty", fitnessStats.averageLoadPenalty() / 1000);
    return map;//from   w  w w.j a va  2  s  .  c  om
}

From source file:com.google.gerrit.sshd.commands.ShowCaches.java

private void printMemoryCaches(Map<String, H2CacheImpl<?, ?>> disks, Map<String, Cache<?, ?>> caches) {
    for (Map.Entry<String, Cache<?, ?>> entry : caches.entrySet()) {
        Cache<?, ?> cache = entry.getValue();
        if (cache instanceof H2CacheImpl) {
            disks.put(entry.getKey(), (H2CacheImpl<?, ?>) cache);
            continue;
        }//ww w . j a  v  a 2  s . c o  m
        CacheStats stat = cache.stats();
        stdout.print(String.format("  %-" + nw + "s|%6s %6s %7s| %7s |%4s %4s|\n", entry.getKey(),
                count(cache.size()), "", "", duration(stat.averageLoadPenalty()),
                percent(stat.hitCount(), stat.requestCount()), ""));
    }
}

From source file:com.google.gerrit.sshd.commands.ShowCaches.java

@Override
protected void run() {
    nw = columns - 50;//from  w ww . j a  v a  2s. com
    Date now = new Date();
    stdout.format("%-25s %-20s      now  %16s\n", "Gerrit Code Review",
            Version.getVersion() != null ? Version.getVersion() : "",
            new SimpleDateFormat("HH:mm:ss   zzz").format(now));
    stdout.format("%-25s %-20s   uptime %16s\n", "", "", uptime(now.getTime() - serverStarted));
    stdout.print('\n');

    stdout.print(String.format(//
            "%1s %-" + nw + "s|%-21s|  %-5s |%-9s|\n" //
            , "" //
            , "Name" //
            , "Entries" //
            , "AvgGet" //
            , "Hit Ratio" //
    ));
    stdout.print(String.format(//
            "%1s %-" + nw + "s|%6s %6s %7s|  %-5s  |%-4s %-4s|\n" //
            , "" //
            , "" //
            , "Mem" //
            , "Disk" //
            , "Space" //
            , "" //
            , "Mem" //
            , "Disk" //
    ));
    stdout.print("--");
    for (int i = 0; i < nw; i++) {
        stdout.print('-');
    }
    stdout.print("+---------------------+---------+---------+\n");

    Map<String, H2CacheImpl<?, ?>> disks = Maps.newTreeMap();
    printMemoryCaches(disks, sortedCoreCaches());
    printMemoryCaches(disks, sortedPluginCaches());
    for (Map.Entry<String, H2CacheImpl<?, ?>> entry : disks.entrySet()) {
        H2CacheImpl<?, ?> cache = entry.getValue();
        CacheStats stat = cache.stats();
        H2CacheImpl.DiskStats disk = cache.diskStats();
        stdout.print(String.format("D %-" + nw + "s|%6s %6s %7s| %7s |%4s %4s|\n", entry.getKey(),
                count(cache.size()), count(disk.size()), bytes(disk.space()),
                duration(stat.averageLoadPenalty()), percent(stat.hitCount(), stat.requestCount()),
                percent(disk.hitCount(), disk.requestCount())));
    }
    stdout.print('\n');

    if (gc) {
        System.gc();
        System.runFinalization();
        System.gc();
    }

    sshSummary();
    taskSummary();
    memSummary();

    if (showJVM) {
        jvmSummary();
    }

    stdout.flush();
}

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  . ja  v a 2  s  .  co 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);
}

From source file:tv.dyndns.kishibe.qmaclone.server.database.CachedDatabase.java

private void writeCacheStatsToLog() {
    for (Entry<String, Cache<?, ?>> e : caches.entrySet()) {
        String name = e.getKey();
        CacheStats stats = e.getValue().stats();
        double averageLoadPenalty = stats.averageLoadPenalty();
        double hitRate = stats.hitRate();
        String message = String.format("%s hitRate=%.2f averageLoadPenalty=%.2f %s", name, hitRate,
                averageLoadPenalty, stats.toString());
        logger.log(Level.INFO, message);
    }/*from   w  ww  .  j ava 2 s .  c  o  m*/
}

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 .  j  a  v a 2  s .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;
}