public BlockBucket(String name, long bytesToFree, long blockSize, long bucketSize) { this.name = name; this.bucketSize = bucketSize; queue = new LruCachedBlockQueue(bytesToFree, blockSize); totalSize = 0; }
public void add(LruCachedBlock block) { totalSize += block.heapSize(); queue.add(block); }
public long free(long toFree) { if (LOG.isTraceEnabled()) { LOG.trace("freeing " + StringUtils.byteDesc(toFree) + " from " + this); } LruCachedBlock cb; long freedBytes = 0; while ((cb = queue.pollLast()) != null) { freedBytes += evictBlock(cb, true); if (freedBytes >= toFree) { return freedBytes; } } if (LOG.isTraceEnabled()) { LOG.trace("freed " + StringUtils.byteDesc(freedBytes) + " from " + this); } return freedBytes; }
CachedBlock cb10 = new CachedBlock(1500, "cb10", 10); LruCachedBlockQueue queue = new LruCachedBlockQueue(10000,1000); queue.add(cb1); queue.add(cb2); queue.add(cb3); queue.add(cb4); queue.add(cb5); queue.add(cb6); queue.add(cb7); queue.add(cb8); queue.add(cb9); queue.add(cb10); cb8.heapSize(); assertEquals(queue.heapSize(), expectedSize); assertEquals(queue.pollLast().getCacheKey().getHfileName(), "cb"+i);
CachedBlock cb10 = new CachedBlock(1500, "cb10", 10); LruCachedBlockQueue queue = new LruCachedBlockQueue(10000,1000); queue.add(cb1); queue.add(cb2); queue.add(cb3); queue.add(cb4); queue.add(cb5); queue.add(cb6); queue.add(cb7); queue.add(cb8); queue.add(cb9); queue.add(cb10); queue.add(cb0); cb8.heapSize() + cb0.heapSize(); assertEquals(queue.heapSize(), expectedSize); assertEquals(queue.pollLast().getCacheKey().getHfileName(), "cb"+i);
CachedBlock cb10 = new CachedBlock(1500, "cb10", 10); LruCachedBlockQueue queue = new LruCachedBlockQueue(10000,1000); queue.add(cb1); queue.add(cb2); queue.add(cb3); queue.add(cb4); queue.add(cb5); queue.add(cb6); queue.add(cb7); queue.add(cb8); queue.add(cb9); queue.add(cb10); cb8.heapSize(); assertEquals(queue.heapSize(), expectedSize); assertEquals(queue.pollLast().getCacheKey().getHfileName(), "cb"+i);
public BlockBucket(String name, long bytesToFree, long blockSize, long bucketSize) { this.name = name; this.bucketSize = bucketSize; queue = new LruCachedBlockQueue(bytesToFree, blockSize); totalSize = 0; }
public void add(LruCachedBlock block) { totalSize += block.heapSize(); queue.add(block); }
public long free(long toFree) { if (LOG.isTraceEnabled()) { LOG.trace("freeing " + StringUtils.byteDesc(toFree) + " from " + this); } LruCachedBlock cb; long freedBytes = 0; while ((cb = queue.pollLast()) != null) { freedBytes += evictBlock(cb, true); if (freedBytes >= toFree) { return freedBytes; } } if (LOG.isTraceEnabled()) { LOG.trace("freed " + StringUtils.byteDesc(freedBytes) + " from " + this); } return freedBytes; }
CachedBlock cb10 = new CachedBlock(1500, "cb10", 10); LruCachedBlockQueue queue = new LruCachedBlockQueue(10000,1000); queue.add(cb1); queue.add(cb2); queue.add(cb3); queue.add(cb4); queue.add(cb5); queue.add(cb6); queue.add(cb7); queue.add(cb8); queue.add(cb9); queue.add(cb10); queue.add(cb0); cb8.heapSize() + cb0.heapSize(); assertEquals(queue.heapSize(), expectedSize); assertEquals(queue.pollLast().getCacheKey().getHfileName(), "cb"+i);