@Override public long size() { return getMaxSize(); }
@Override public long getFreeSize() { return getMaxSize() - getCurrentSize(); }
@Override public long getMaxSize() { return onHeapCache.getMaxSize() + l2Cache.getMaxSize(); }
private void doBucketCacheConfigTest() { final int bcSize = 100; this.conf.setInt(HConstants.BUCKET_CACHE_SIZE_KEY, bcSize); CacheConfig cc = new CacheConfig(this.conf); BlockCache blockCache = BlockCacheFactory.createBlockCache(this.conf); basicBlockCacheOps(blockCache, cc, false, false); assertTrue(blockCache instanceof CombinedBlockCache); // TODO: Assert sizes allocated are right and proportions. CombinedBlockCache cbc = (CombinedBlockCache) blockCache; BlockCache[] bcs = cbc.getBlockCaches(); assertTrue(bcs[0] instanceof LruBlockCache); LruBlockCache lbc = (LruBlockCache) bcs[0]; assertEquals(MemorySizeUtil.getOnHeapCacheSize(this.conf), lbc.getMaxSize()); assertTrue(bcs[1] instanceof BucketCache); BucketCache bc = (BucketCache) bcs[1]; // getMaxSize comes back in bytes but we specified size in MB assertEquals(bcSize, bc.getMaxSize() / (1024 * 1024)); }
LruBlockCache disabledBlockCache = (LruBlockCache) cc.getBlockCache().get(); LOG.info("disabledBlockCache=" + disabledBlockCache); assertEquals("test inconsistency detected.", maxSize, disabledBlockCache.getMaxSize()); assertTrue("eviction thread spawned unintentionally.", disabledBlockCache.getEvictionThread() == null); LruBlockCache enabledBlockCache = (LruBlockCache) cc.getBlockCache().get(); LOG.info("enabledBlockCache=" + enabledBlockCache); assertEquals("test inconsistency detected", maxSize, enabledBlockCache.getMaxSize()); assertTrue("eviction thread spawned unintentionally.", enabledBlockCache.getEvictionThread() == null);
@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(); }
assertEquals(lruExpectedSize, lbc.getMaxSize()); BlockCache bc = cbc.l2Cache;
@Override public long size() { return getMaxSize(); }
/** * Get the current size of this cache. * @return current size in bytes */ public long getFreeSize() { return getMaxSize() - getCurrentSize(); }
@Override public long getFreeSize() { return getMaxSize() - getCurrentSize(); }
@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(); }
private void doBucketCacheConfigTest() { final int bcSize = 100; this.conf.setInt(HConstants.BUCKET_CACHE_SIZE_KEY, bcSize); CacheConfig.instantiateBlockCache(this.conf); CacheConfig cc = new CacheConfig(this.conf); basicBlockCacheOps(cc, false, false); assertTrue(cc.getBlockCache() instanceof CombinedBlockCache); // TODO: Assert sizes allocated are right and proportions. CombinedBlockCache cbc = (CombinedBlockCache)cc.getBlockCache(); BlockCache [] bcs = cbc.getBlockCaches(); assertTrue(bcs[0] instanceof LruBlockCache); LruBlockCache lbc = (LruBlockCache)bcs[0]; assertEquals(MemorySizeUtil.getOnHeapCacheSize(this.conf), lbc.getMaxSize()); assertTrue(bcs[1] instanceof BucketCache); BucketCache bc = (BucketCache)bcs[1]; // getMaxSize comes back in bytes but we specified size in MB assertEquals(bcSize, bc.getMaxSize() / (1024 * 1024)); }
LruBlockCache disabledBlockCache = (LruBlockCache) cc.getBlockCache(); LOG.info("disabledBlockCache=" + disabledBlockCache); assertEquals("test inconsistency detected.", maxSize, disabledBlockCache.getMaxSize()); assertTrue("eviction thread spawned unintentionally.", disabledBlockCache.getEvictionThread() == null); LruBlockCache enabledBlockCache = (LruBlockCache) cc.getBlockCache(); LOG.info("enabledBlockCache=" + enabledBlockCache); assertEquals("test inconsistency detected", maxSize, enabledBlockCache.getMaxSize()); assertTrue("eviction thread spawned unintentionally.", enabledBlockCache.getEvictionThread() == null);
assertEquals(lruExpectedSize, lbc.getMaxSize()); BlockCache bc = cbc.l2Cache;