List of usage examples for com.google.common.cache CacheStats totalLoadTime
long totalLoadTime
To view the source code for com.google.common.cache CacheStats totalLoadTime.
Click Source Link
From source file:org.mapsforge.map.writer.CB_MapFileWriter.java
/** * Writes the map file according to the given configuration using the given data processor. * // www. ja v a 2 s. c o m * @param configuration * the configuration * @param dataProcessor * the data processor * @throws IOException * thrown if any IO error occurs */ public static void writeFile(CB_MapWriterConfiguration configuration, CB_TileBasedDataProcessor dataProcessor) throws IOException { RandomAccessFile randomAccessFile = new RandomAccessFile(configuration.getOutputFile(), "rw"); int amountOfZoomIntervals = dataProcessor.getZoomIntervalConfiguration().getNumberOfZoomIntervals(); ByteBuffer containerHeaderBuffer = ByteBuffer.allocate(HEADER_BUFFER_SIZE); // CONTAINER HEADER int totalHeaderSize = writeHeaderBuffer(configuration, dataProcessor, containerHeaderBuffer); // set to mark where zoomIntervalConfig starts containerHeaderBuffer.reset(); final LoadingCache<CB_TDWay, Geometry> jtsGeometryCache = CacheBuilder.newBuilder() .maximumSize(JTS_GEOMETRY_CACHE_SIZE) .concurrencyLevel(Runtime.getRuntime().availableProcessors() * 2) .build(new JTSGeometryCacheLoader(dataProcessor)); // SUB FILES // for each zoom interval write a sub file long currentFileSize = totalHeaderSize; for (int i = 0; i < amountOfZoomIntervals; i++) { // SUB FILE INDEX AND DATA long subfileSize = writeSubfile(currentFileSize, i, dataProcessor, jtsGeometryCache, randomAccessFile, configuration); // SUB FILE META DATA IN CONTAINER HEADER writeSubfileMetaDataToContainerHeader(dataProcessor.getZoomIntervalConfiguration(), i, currentFileSize, subfileSize, containerHeaderBuffer); currentFileSize += subfileSize; } randomAccessFile.seek(0); randomAccessFile.write(containerHeaderBuffer.array(), 0, totalHeaderSize); // WRITE FILE SIZE TO HEADER long fileSize = randomAccessFile.length(); randomAccessFile.seek(OFFSET_FILE_SIZE); randomAccessFile.writeLong(fileSize); randomAccessFile.close(); CacheStats stats = jtsGeometryCache.stats(); LOGGER.info("JTS Geometry cache hit rate: " + stats.hitRate()); LOGGER.info("JTS Geometry total load time: " + stats.totalLoadTime() / 1000); LOGGER.info("Finished writing file."); }
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:org.mapsforge.map.writer.MapFileWriter.java
/** * Writes the map file according to the given configuration using the given data processor. * * @param configuration the configuration * @param dataProcessor the data processor * @throws IOException thrown if any IO error occurs *//* w ww. j ava2 s.c o m*/ public static void writeFile(MapWriterConfiguration configuration, TileBasedDataProcessor dataProcessor) throws IOException { EXECUTOR_SERVICE = Executors.newFixedThreadPool(configuration.getThreads()); RandomAccessFile randomAccessFile = new RandomAccessFile(configuration.getOutputFile(), "rw"); int amountOfZoomIntervals = dataProcessor.getZoomIntervalConfiguration().getNumberOfZoomIntervals(); ByteBuffer containerHeaderBuffer = ByteBuffer.allocate(HEADER_BUFFER_SIZE); // CONTAINER HEADER int totalHeaderSize = writeHeaderBuffer(configuration, dataProcessor, containerHeaderBuffer); // set to mark where zoomIntervalConfig starts containerHeaderBuffer.reset(); final LoadingCache<TDWay, Geometry> jtsGeometryCache = CacheBuilder.newBuilder() .maximumSize(JTS_GEOMETRY_CACHE_SIZE) .concurrencyLevel(Runtime.getRuntime().availableProcessors() * 2) .build(new JTSGeometryCacheLoader(dataProcessor)); // SUB FILES // for each zoom interval write a sub file long currentFileSize = totalHeaderSize; for (int i = 0; i < amountOfZoomIntervals; i++) { // SUB FILE INDEX AND DATA long subfileSize = writeSubfile(currentFileSize, i, dataProcessor, jtsGeometryCache, randomAccessFile, configuration); // SUB FILE META DATA IN CONTAINER HEADER writeSubfileMetaDataToContainerHeader(dataProcessor.getZoomIntervalConfiguration(), i, currentFileSize, subfileSize, containerHeaderBuffer); currentFileSize += subfileSize; } randomAccessFile.seek(0); randomAccessFile.write(containerHeaderBuffer.array(), 0, totalHeaderSize); // WRITE FILE SIZE TO HEADER long fileSize = randomAccessFile.length(); randomAccessFile.seek(OFFSET_FILE_SIZE); randomAccessFile.writeLong(fileSize); randomAccessFile.close(); CacheStats stats = jtsGeometryCache.stats(); LOGGER.fine("Tag values stats:\n" + OSMUtils.logValueTypeCount()); LOGGER.info("JTS Geometry cache hit rate: " + stats.hitRate()); LOGGER.info("JTS Geometry total load time: " + stats.totalLoadTime() / 1000); LOGGER.info("Finished writing file."); }
From source file:com.oneops.opamp.ws.OpampWsController.java
/** * Get the current WatchedByAttributeCache status. Returns the cumulative status of * <ul>/*from www .ja va2s. co m*/ * <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.facebook.buck.rules.keys.EventPostingRuleKeyCacheScope.java
@Override public final void close() { try (SimplePerfEvent.Scope scope = SimplePerfEvent.scope(buckEventBus, PerfEventId.of("rule_key_cache_cleanup"))) { // Log stats. CacheStats stats = cache.getStats().minus(startStats); buckEventBus.post(RuleKeyCacheStatsEvent.create(stats)); scope.update("hitRate", stats.hitRate()); scope.update("hits", stats.hitCount()); scope.update("misses", stats.missCount()); scope.update("requests", stats.requestCount()); scope.update("load_time_ns", stats.totalLoadTime()); // Run additional cleanup. cleanup(scope);//from ww w. j ava 2 s .c o m } }
From source file:com.oneops.antenna.ws.AntennaWsController.java
/** * Get the current sink cache status. Returns the cumulative status of * <ul>/*from w ww . j a v 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: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: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();/*w w w . jav a2s. c om*/ 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 ww . j av a 2s .c om*/ 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 w w w . ja va 2s. com*/ 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)); }