@Override public boolean evaluate() throws Exception { return cache.getBlockCount() == 0; }
@Override public long getBlockCount() { return onHeapCache.getBlockCount() + l2Cache.getBlockCount(); }
assertEquals(0, cache.getBlockCount()); assertEquals(cache.getOverhead(), cache.getCurrentSize());
public void logStats() { // Log size long totalSize = heapSize(); long freeSize = maxSize - totalSize; LruBlockCache.LOG.info("totalSize=" + StringUtils.byteDesc(totalSize) + ", " + "freeSize=" + StringUtils.byteDesc(freeSize) + ", " + "max=" + StringUtils.byteDesc(this.maxSize) + ", " + "blockCount=" + getBlockCount() + ", " + "accesses=" + stats.getRequestCount() + ", " + "hits=" + stats.getHitCount() + ", " + "hitRatio=" + (stats.getHitCount() == 0 ? "0" : (StringUtils.formatPercent(stats.getHitRatio(), 2)+ ", ")) + ", " + "cachingAccesses=" + stats.getRequestCachingCount() + ", " + "cachingHits=" + stats.getHitCachingCount() + ", " + "cachingHitsRatio=" + (stats.getHitCachingCount() == 0 ? "0,": (StringUtils.formatPercent(stats.getHitCachingRatio(), 2) + ", ")) + "evictions=" + stats.getEvictionCount() + ", " + "evicted=" + stats.getEvictedCount() + ", " + "evictedPerRun=" + stats.evictedPerEviction()); }
curCnt = cache.getBlockCount(); prevCnt != curCnt; prevCnt = curCnt, curCnt = cache.getBlockCount()) { Thread.sleep(200); assertTrue("Cache never stabilized.", n++ < 20);
long initialL1BlockCount = lbc.getBlockCount(); long initialL2BlockCount = bc.getBlockCount(); Cacheable c = new DataCacheEntry(); BlockCacheKey bck = new BlockCacheKey("bck", 0); lbc.cacheBlock(bck, c, false); assertEquals(initialL1BlockCount + 1, lbc.getBlockCount()); assertEquals(initialL2BlockCount, bc.getBlockCount()); while (initialL1BlockCount != lbc.getBlockCount()) Threads.sleep(10); assertEquals(initialL1BlockCount, lbc.getBlockCount());
disabledBlockCache.getEvictionThread() == null); assertEquals("freshly created blockcache contains blocks.", 0, disabledBlockCache.getBlockCount()); long disabledBlockCount = disabledBlockCache.getBlockCount(); assertTrue("blockcache should contain blocks. disabledBlockCount=" + disabledBlockCount, disabledBlockCount > 0); enabledBlockCache.getEvictionThread() == null); assertEquals("freshly created blockcache contains blocks.", 0, enabledBlockCache.getBlockCount()); long enabledBlockCount = enabledBlockCache.getBlockCount(); assertTrue("blockcache should contain blocks. enabledBlockCount=" + enabledBlockCount, enabledBlockCount > 0);
cache.cacheBlock(i.cacheKey, i); assertEquals(15,cache.getBlockCount()); for (CachedItem i:small) { assertNotNull(cache.getBlock(i.cacheKey, true, false, false));
@Override public String toString() { return MoreObjects.toStringHelper(this) .add("blockCount", getBlockCount()) .add("currentSize", StringUtils.byteDesc(getCurrentSize())) .add("freeSize", StringUtils.byteDesc(getFreeSize())) .add("maxSize", StringUtils.byteDesc(getMaxSize())) .add("heapSize", StringUtils.byteDesc(heapSize())) .add("minSize", StringUtils.byteDesc(minSize())) .add("minFactor", minFactor) .add("multiSize", StringUtils.byteDesc(multiSize())) .add("multiFactor", multiFactor) .add("singleSize", StringUtils.byteDesc(singleSize())) .add("singleFactor", singleFactor) .toString(); }
long expectedBlockCount = cache.getBlockCount(); for (CachedItem block : blocks) { cache.cacheBlock(block.cacheKey, block); expectedBlockCount, cache.getBlockCount());
assertEquals(7, cache.getBlockCount());
@Override public boolean evaluate() throws Exception { return cache.getBlockCount() == 0; }
@Override public long getBlockCount() { return lruCache.getBlockCount() + l2Cache.getBlockCount(); }
@Override public long getBlockCount() { return onHeapCache.getBlockCount() + offHeapCache.getBlockCount(); }
curCnt = cache.getBlockCount(); prevCnt != curCnt; prevCnt = curCnt, curCnt = cache.getBlockCount()) { Thread.sleep(200); assertTrue("Cache never stabilized.", n++ < 20);
long initialL1BlockCount = lbc.getBlockCount(); long initialL2BlockCount = bc.getBlockCount(); Cacheable c = new DataCacheEntry(); BlockCacheKey bck = new BlockCacheKey("bck", 0); lbc.cacheBlock(bck, c, false); assertEquals(initialL1BlockCount + 1, lbc.getBlockCount()); assertEquals(initialL2BlockCount, bc.getBlockCount()); while (initialL1BlockCount != lbc.getBlockCount()) Threads.sleep(10); assertEquals(initialL1BlockCount, lbc.getBlockCount());
@Override public String toString() { return Objects.toStringHelper(this) .add("blockCount", getBlockCount()) .add("currentSize", getCurrentSize()) .add("freeSize", getFreeSize()) .add("maxSize", getMaxSize()) .add("heapSize", heapSize()) .add("minSize", minSize()) .add("minFactor", minFactor) .add("multiSize", multiSize()) .add("multiFactor", multiFactor) .add("singleSize", singleSize()) .add("singleFactor", singleFactor) .toString(); }
public void logStats() { // Log size long totalSize = heapSize(); long freeSize = maxSize - totalSize; LruBlockCache.LOG.info("totalSize=" + StringUtils.byteDesc(totalSize) + ", " + "freeSize=" + StringUtils.byteDesc(freeSize) + ", " + "max=" + StringUtils.byteDesc(this.maxSize) + ", " + "blockCount=" + getBlockCount() + ", " + "accesses=" + stats.getRequestCount() + ", " + "hits=" + stats.getHitCount() + ", " + "hitRatio=" + (stats.getHitCount() == 0 ? "0" : (StringUtils.formatPercent(stats.getHitRatio(), 2)+ ", ")) + ", " + "cachingAccesses=" + stats.getRequestCachingCount() + ", " + "cachingHits=" + stats.getHitCachingCount() + ", " + "cachingHitsRatio=" + (stats.getHitCachingCount() == 0 ? "0,": (StringUtils.formatPercent(stats.getHitCachingRatio(), 2) + ", ")) + "evictions=" + stats.getEvictionCount() + ", " + "evicted=" + stats.getEvictedCount() + ", " + "evictedPerRun=" + stats.evictedPerEviction()); }
cache.cacheBlock(i.cacheKey, i); assertEquals(15,cache.getBlockCount()); for (CachedItem i:small) { assertNotNull(cache.getBlock(i.cacheKey, true, false, false));
long expectedBlockCount = cache.getBlockCount(); for (CachedItem block : blocks) { cache.cacheBlock(block.cacheKey, block); expectedBlockCount, cache.getBlockCount());