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; } 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()), "")); } }
/** * Method to get the stats about the cache. * * @return */ public String getStats() { StringBuilder stringBuilder = new StringBuilder(); CacheStats cacheStats = cacheResource.getCacheStats().minus(relativeCacheStats); stringBuilder.append( String.format("Total succesful loaded values: %d %n", cacheStats.loadSuccessCount())); stringBuilder.append(String.format("Total requests: %d %n", cacheStats.requestCount())); stringBuilder.append( String.format( "Hits ratio: %d/%d - %.3f %n", cacheStats.hitCount(), cacheStats.missCount(), cacheStats.hitRate())); stringBuilder.append( String.format( "Average time spent loading new values (nanoseconds): %.3f %n", cacheStats.averageLoadPenalty())); stringBuilder.append( String.format("Number of cache evictions: %d %n", cacheStats.evictionCount())); return stringBuilder.toString(); }
@Override protected void run() { nw = columns - 50; 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(); }