Package com.google.common.cache

Examples of com.google.common.cache.CacheStats


  }

  @Override
  public void addMetrics(MetricTreeObject tree) {
    long size = cache.size();
    CacheStats stats = cache.stats();

    MetricTreeObject subtree = tree.getSubtree(key);

    subtree.addInt("size", size);
    subtree.addInt("evictionCount", stats.evictionCount());
    subtree.addInt("hitCount", stats.hitCount());
    subtree.addInt("loadCount", stats.loadCount());
    subtree.addInt("loadExceptionCount", stats.loadExceptionCount());
    subtree.addInt("loadSuccessCount", stats.loadSuccessCount());
    subtree.addInt("missCount", stats.missCount());
    subtree.addInt("requestCount", stats.requestCount());
    subtree.addInt("totalLoadTime", stats.totalLoadTime());

    subtree.addFloat("averageLoadPenalty", stats.averageLoadPenalty());
    subtree.addFloat("hitRate", stats.hitRate());
    subtree.addFloat("loadExceptionRate", stats.loadExceptionRate());
    subtree.addFloat("missRate", stats.missRate());
  }
View Full Code Here


            loadSuccessCount += s.loadSuccessCount;
            loadExceptionCount += s.loadExceptionCount;
            totalLoadTime += s.totalLoadTime;
            evictionCount += s.evictionCount;
        }
        CacheStats stats = new CacheStats(hitCount, missCount, loadSuccessCount,
                loadExceptionCount, totalLoadTime, evictionCount);
        return stats;
    }
View Full Code Here

            loadSuccessCount += s.loadSuccessCount;
            loadExceptionCount += s.loadExceptionCount;
            totalLoadTime += s.totalLoadTime;
            evictionCount += s.evictionCount;
        }
        CacheStats stats = new CacheStats(hitCount, missCount, loadSuccessCount,
                loadExceptionCount, totalLoadTime, evictionCount);
        return stats;
    }
View Full Code Here

    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) {
View Full Code Here

      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()),
          ""));
    }
  }
View Full Code Here

    client.flush().join();
    timing = (System.nanoTime() - timing) / 1000000;
    final int nrpcs = nthreads * ICV_PER_ROW * NUM_ROWS;
    LOG.info(nrpcs + " increments in " + timing + "ms = "
             + (nrpcs * 1000L / timing) + "/s");
    final CacheStats stats = client.stats().incrementBufferStats();
    LOG.info("Increments coalesced: " + stats.hitCount());
    LOG.info("Increments sent to HBase: " + stats.missCount());
    LOG.info("  due to cache evictions: " + stats.evictionCount());

    LOG.info("Reading all counters back from HBase and checking values...");
    final Scanner scanner = client.newScanner(table);
    scanner.setStartKey(key(0));
    scanner.setStopKey(key(NUM_ROWS));
View Full Code Here

            // which we do care about.
            if (notification.getCause() == RemovalCause.SIZE) {
                evictions++;
                if (evictions >= nextLogThreshold) {
                    Logger logger = Logger.getLogger(ConfigAdapterImpl.class);
                    CacheStats stats = cache.stats();
                    logger.info(String.format(
                        "Cache %s evicted %d entries for size pressure, hit rate=%.3f, evictions=%d, loads=%d %s",
                        name, evictions, stats.hitRate(), stats.evictionCount(),
                        stats.loadCount(), stats.toString()));
                    // We want to log every 10 until 100, every 100 until 1000, every 1000 thereafter
                    if (nextLogThreshold == 1) {
                        nextLogThreshold = 10;
                    } else if (nextLogThreshold < 100) {
                        nextLogThreshold += 10;
                    } else if (nextLogThreshold < 1000) {
                        nextLogThreshold += 100;
                    } else {
                        nextLogThreshold += 1000;
                    }
                }
            }
            if (System.currentTimeMillis() >= lastFull + ONE_DAY) {
                Logger logger = Logger.getLogger(ConfigAdapterImpl.class);
                CacheStats stats = cache.stats();
                logger.info(String.format("Cache %s has hit rate=%.3f, stats %s\n",
                        name, stats.hitRate(), stats.toString()));
            }
        }
View Full Code Here

            loadSuccessCount += s.loadSuccessCount;
            loadExceptionCount += s.loadExceptionCount;
            totalLoadTime += s.totalLoadTime;
            evictionCount += s.evictionCount;
        }
        CacheStats stats = new CacheStats(hitCount, missCount, loadSuccessCount,
                loadExceptionCount, totalLoadTime, evictionCount);
        return stats;
    }
View Full Code Here

     *
     * @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();
    }
View Full Code Here

      executor.scheduleWithFixedDelay(new Runnable() {

        @Override
        public void run() {
          CacheStats cacheStats = cacheResource.getCacheStats().minus(relativeCacheStats);

          String csvStats = String.format("%.3f, %.3f, %d %n", cacheStats.hitRate(), cacheStats.averageLoadPenalty(), cacheStats.evictionCount());
          try {
            com.google.common.io.Files.append(csvStats, cacheLog, Charset.defaultCharset());
          } catch (IOException e) {
          }
        }
View Full Code Here

TOP

Related Classes of com.google.common.cache.CacheStats

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.