List of usage examples for com.google.common.cache CacheStats evictionCount
long evictionCount
To view the source code for com.google.common.cache CacheStats evictionCount.
Click Source Link
From source file:com.google.devtools.build.lib.runtime.CacheFileDigestsModule.java
/** * Adds a line to the log with cache statistics. * * @param message message to prefix to the written line * @param stats the cache statistics to be logged *//*w w w . j a v a2 s. co m*/ private static void logStats(String message, CacheStats stats) { log.info(message + ": hit count=" + stats.hitCount() + ", miss count=" + stats.missCount() + ", hit rate=" + stats.hitRate() + ", eviction count=" + stats.evictionCount()); }
From source file:com.google.gerrit.server.cache.CacheMetrics.java
@Inject public CacheMetrics(MetricMaker metrics, DynamicMap<Cache<?, ?>> cacheMap) { Field<String> F_NAME = Field.ofString("cache_name"); CallbackMetric1<String, Long> memEnt = metrics.newCallbackMetric("caches/memory_cached", Long.class, new Description("Memory entries").setGauge().setUnit("entries"), F_NAME); CallbackMetric1<String, Double> memHit = metrics.newCallbackMetric("caches/memory_hit_ratio", Double.class, new Description("Memory hit ratio").setGauge().setUnit("percent"), F_NAME); CallbackMetric1<String, Long> memEvict = metrics.newCallbackMetric("caches/memory_eviction_count", Long.class, new Description("Memory eviction count").setGauge().setUnit("evicted entries"), F_NAME); CallbackMetric1<String, Long> perDiskEnt = metrics.newCallbackMetric("caches/disk_cached", Long.class, new Description("Disk entries used by persistent cache").setGauge().setUnit("entries"), F_NAME); CallbackMetric1<String, Double> perDiskHit = metrics.newCallbackMetric("caches/disk_hit_ratio", Double.class, new Description("Disk hit ratio for persistent cache").setGauge().setUnit("percent"), F_NAME);/* w ww .ja v a2 s. com*/ Set<CallbackMetric<?>> cacheMetrics = ImmutableSet.<CallbackMetric<?>>of(memEnt, memHit, memEvict, perDiskEnt, perDiskHit); metrics.newTrigger(cacheMetrics, () -> { for (DynamicMap.Entry<Cache<?, ?>> e : cacheMap) { Cache<?, ?> c = e.getProvider().get(); String name = metricNameOf(e); CacheStats cstats = c.stats(); memEnt.set(name, c.size()); memHit.set(name, cstats.hitRate() * 100); memEvict.set(name, cstats.evictionCount()); if (c instanceof PersistentCache) { PersistentCache.DiskStats d = ((PersistentCache) c).diskStats(); perDiskEnt.set(name, d.size()); perDiskHit.set(name, hitRatio(d)); } } cacheMetrics.forEach(CallbackMetric::prune); }); }
From source file:uk.ac.ed.inf.ace.utils.InstrumentedCache.java
private void emitStats() { int thisRequestCount = requestCount.getAndIncrement(); if (thisRequestCount > 0 && thisRequestCount % REQUEST_COUNT_EMIT_GAP == 0) { CacheStats stats = cache.stats(); LOGGER.log(Level.INFO, "{0} stats (C-H-M-E-S-F): {1} - {2} - {3} - {4} - {5} - {6}", new Object[] { name, thisRequestCount, stats.hitCount(), stats.missCount(), stats.evictionCount(), stats.loadSuccessCount(), stats.loadExceptionCount() }); }//from w w w . ja va 2s. c o m }
From source file:ca.exprofesso.guava.jcache.GuavaCacheStatisticsMXBean.java
@Override public void clear() { CacheStats cacheStats = cache.unwrap(GuavaCache.class).stats(); snapshot = new CacheStats(cacheStats.hitCount(), cacheStats.missCount(), cacheStats.loadSuccessCount(), cacheStats.loadExceptionCount(), cacheStats.totalLoadTime(), cacheStats.evictionCount()); }
From source file:com.github.benmanes.caffeine.guava.CaffeinatedGuavaCache.java
@Override public CacheStats stats() { com.github.benmanes.caffeine.cache.stats.CacheStats stats = cache.stats(); return new CacheStats(stats.hitCount(), stats.missCount(), stats.loadSuccessCount(), stats.loadFailureCount(), stats.totalLoadTime(), stats.evictionCount()); }
From source file:com.oneops.opamp.ws.OpampWsController.java
/** * Get the current WatchedByAttributeCache status. Returns the cumulative status of * <ul>/*from w w w. jav a 2s .c om*/ * <li>hitCount * <li>missCount; * <li>loadSuccessCount; * <li>loadExceptionCount; * <li>totalLoadTime; * <li>evictionCount; * </ul> * * @return cache status map. */ @RequestMapping(value = "/cache/stats", method = RequestMethod.GET) @ResponseBody public Map<String, Object> getCacheStats() { Map<String, Object> stat = new LinkedHashMap<>(5); stat.put("status", "ok"); stat.put("maxSize", cache.getMaxSize()); stat.put("currentSize", cache.instance().size()); stat.put("timeout", cache.getTimeout()); CacheStats cs = cache.instance().stats(); stat.put("hitCount", cs.hitCount()); stat.put("missCount", cs.missCount()); stat.put("loadSuccessCount", cs.loadSuccessCount()); stat.put("totalLoadTime", TimeUnit.SECONDS.convert(cs.totalLoadTime(), TimeUnit.NANOSECONDS)); stat.put("loadExceptionCount", cs.loadExceptionCount()); stat.put("evictionCount", cs.evictionCount()); return stat; }
From source file:com.oneops.antenna.ws.AntennaWsController.java
/** * Get the current sink cache status. Returns the cumulative status of * <ul>// w w w . jav a 2s .c o m * <li>hitCount * <li>missCount; * <li>loadSuccessCount; * <li>loadExceptionCount; * <li>totalLoadTime; * <li>evictionCount; * </ul> * * @return cache status map. */ @RequestMapping(value = "/cache/stats", method = GET) @ResponseBody public Map<String, Object> getCacheStats() { Map<String, Object> stat = new LinkedHashMap<>(5); stat.put("status", "ok"); stat.put("maxSize", cache.getMaxSize()); stat.put("currentSize", cache.instance().size()); stat.put("timeout", cache.getTimeout()); CacheStats cs = cache.instance().stats(); stat.put("hitCount", cs.hitCount()); stat.put("missCount", cs.missCount()); stat.put("loadSuccessCount", cs.loadSuccessCount()); stat.put("totalLoadTime", SECONDS.convert(cs.totalLoadTime(), NANOSECONDS)); stat.put("loadExceptionCount", cs.loadExceptionCount()); stat.put("evictionCount", cs.evictionCount()); return stat; }
From source file:rickbw.incubator.cache.MultiCache.java
@Override public final CacheStats stats() { long hitCount = 0L; long missCount = 0L; long loadSuccessCount = 0L; long loadExceptionCount = 0L; long totalLoadTime = 0L; long evictionCount = 0L; for (final Cache<?, ?> delegate : this.delegates.values()) { final CacheStats stats = delegate.stats(); hitCount += stats.hitCount();//from w w w.j a v a 2s. c o m missCount += stats.missCount(); loadSuccessCount += stats.loadSuccessCount(); loadExceptionCount += stats.loadExceptionCount(); totalLoadTime += stats.totalLoadTime(); evictionCount += stats.evictionCount(); } return new CacheStats(hitCount, missCount, loadSuccessCount, loadExceptionCount, totalLoadTime, evictionCount); }
From source file:it.geosolutions.geofence.cache.rest.RESTCacheStats.java
@Override public void handleGet() { // Representation representation = new StringRepresentation(stats.toString()); // getResponse().setEntity(representation); CacheStats stats = crr.getStats(); StringBuilder sb = new StringBuilder().append("RuleStats[").append(" size:").append(crr.getCacheSize()) .append("/").append(crr.getCacheInitParams().getSize()).append(" hitCount:") .append(stats.hitCount()).append(" missCount:").append(stats.missCount()) .append(" loadSuccessCount:").append(stats.loadSuccessCount()).append(" loadExceptionCount:") .append(stats.loadExceptionCount()).append(" totalLoadTime:").append(stats.totalLoadTime()) .append(" evictionCount:").append(stats.evictionCount()).append("] \n"); stats = crr.getUserStats();//from w w w. ja v a 2 s . com sb.append("UserStats[").append(" size:").append(crr.getUserCacheSize()).append("/") .append(crr.getCacheInitParams().getSize()).append(" hitCount:").append(stats.hitCount()) .append(" missCount:").append(stats.missCount()).append(" loadSuccessCount:") .append(stats.loadSuccessCount()).append(" loadExceptionCount:").append(stats.loadExceptionCount()) .append(" totalLoadTime:").append(stats.totalLoadTime()).append(" evictionCount:") .append(stats.evictionCount()).append("] \n"); getResponse().setEntity(new StringRepresentation(sb)); }
From source file:org.geoserver.geofence.cache.rest.RESTCacheStats.java
@Override public void handleGet() { // Representation representation = new StringRepresentation(stats.toString()); // getResponse().setEntity(representation); CacheStats stats = crr.getStats(); StringBuilder sb = new StringBuilder().append("RuleStats[").append(" size:").append(crr.getCacheSize()) .append("/").append(crr.getCacheInitParams().getSize()).append(" hitCount:") .append(stats.hitCount()).append(" missCount:").append(stats.missCount()) .append(" loadSuccessCount:").append(stats.loadSuccessCount()).append(" loadExceptionCount:") .append(stats.loadExceptionCount()).append(" totalLoadTime:").append(stats.totalLoadTime()) .append(" evictionCount:").append(stats.evictionCount()).append("] \n"); stats = crr.getAdminAuthStats();//from www. jav a2 s.c o m sb.append("AdminAuthStats[").append(" size:").append(crr.getCacheSize()).append("/") .append(crr.getCacheInitParams().getSize()).append(" hitCount:").append(stats.hitCount()) .append(" missCount:").append(stats.missCount()).append(" loadSuccessCount:") .append(stats.loadSuccessCount()).append(" loadExceptionCount:").append(stats.loadExceptionCount()) .append(" totalLoadTime:").append(stats.totalLoadTime()).append(" evictionCount:") .append(stats.evictionCount()).append("] \n"); stats = crr.getUserStats(); sb.append("UserStats[").append(" size:").append(crr.getUserCacheSize()).append("/") .append(crr.getCacheInitParams().getSize()).append(" hitCount:").append(stats.hitCount()) .append(" missCount:").append(stats.missCount()).append(" loadSuccessCount:") .append(stats.loadSuccessCount()).append(" loadExceptionCount:").append(stats.loadExceptionCount()) .append(" totalLoadTime:").append(stats.totalLoadTime()).append(" evictionCount:") .append(stats.evictionCount()).append("] \n"); getResponse().setEntity(new StringRepresentation(sb)); }