@Test public void testBucketAllocator() throws BucketAllocatorException { BucketAllocator mAllocator = cache.getAllocator(); final List<Integer> BLOCKSIZES = Arrays.asList(4 * 1024, 8 * 1024, 64 * 1024, 96 * 1024); boolean full = false; ArrayList<Long> allocations = new ArrayList<Long>(); List<Integer> tmp = new ArrayList<Integer>(BLOCKSIZES); for (int i = 0; !full; i++) { Integer blockSize = null; try { blockSize = randFrom(tmp); allocations.add(mAllocator.allocateBlock(blockSize)); } catch (CacheFullException cfe) { tmp.remove(blockSize); if (tmp.isEmpty()) full = true; } } for (Integer blockSize : BLOCKSIZES) { BucketSizeInfo bucketSizeInfo = mAllocator.roundUpToBucketSizeInfo(blockSize); IndexStatistics indexStatistics = bucketSizeInfo.statistics(); assertEquals( "unexpected freeCount for " + bucketSizeInfo, 0, indexStatistics.freeCount()); } for (long offset : allocations) { assertEquals(mAllocator.sizeOfAllocation(offset), mAllocator.freeBlock(offset)); } assertEquals(0, mAllocator.getUsedSize()); }
public BucketAllocator getAllocator() { return this.bucketAllocator; }
BucketCache implements BlockCache, HeapSize { public BucketAllocator getAllocator() { return this.bucketAllocator; } }
BucketCache implements BlockCache, HeapSize { public BucketAllocator getAllocator() { return this.bucketAllocator; } BucketCache(String ioEngineName, long capacity, int blockSize, int[] bucketSizes,
      int writerThreadNum, int writerQLen, String persistencePath);  BucketCache(String ioEngineName, long capacity, int blockSize, int[] bucketSizes,
      int writerThreadNum, int writerQLen, String persistencePath, int ioErrorsTolerationDuration); }
BucketCache implements BlockCache, HeapSize { public BucketAllocator getAllocator() { return this.bucketAllocator; } BucketCache(String ioEngineName, long capacity, int blockSize, int[] bucketSizes,
      int writerThreadNum, int writerQLen, String persistencePath);  BucketCache(String ioEngineName, long capacity, int blockSize, int[] bucketSizes,
      int writerThreadNum, int writerQLen, String persistencePath, int ioErrorsTolerationDuration); String getIoEngine(); @Override void cacheBlock(BlockCacheKey cacheKey, Cacheable buf); @Override void cacheBlock(BlockCacheKey cacheKey, Cacheable cachedItem, boolean inMemory); void cacheBlockWithWait(BlockCacheKey cacheKey, Cacheable cachedItem,
      boolean inMemory, boolean wait); @Override Cacheable getBlock(BlockCacheKey key, boolean caching, boolean repeat,
      boolean updateCacheMetrics); @Override boolean evictBlock(BlockCacheKey cacheKey); void logStats(); long getFailedBlockAdditions(); long getRealCacheSize(); @Override void shutdown(); @Override CacheStats getStats(); BucketAllocator getAllocator(); @Override long heapSize(); @Override long size(); @Override long getFreeSize(); @Override long getBlockCount(); @Override long getCurrentSize(); @Override int evictBlocksByHfileName(String hfileName); @Override Iterator<CachedBlock> iterator(); @Override BlockCache[] getBlockCaches(); }
BucketCache implements BlockCache, HeapSize { public BucketAllocator getAllocator() { return this.bucketAllocator; } BucketCache(String ioEngineName, long capacity, int blockSize, int[] bucketSizes,
      int writerThreadNum, int writerQLen, String persistencePath);  BucketCache(String ioEngineName, long capacity, int blockSize, int[] bucketSizes,
      int writerThreadNum, int writerQLen, String persistencePath, int ioErrorsTolerationDuration); String getIoEngine(); @Override void cacheBlock(BlockCacheKey cacheKey, Cacheable buf); @Override void cacheBlock(BlockCacheKey cacheKey, Cacheable cachedItem, boolean inMemory); void cacheBlockWithWait(BlockCacheKey cacheKey, Cacheable cachedItem,
      boolean inMemory, boolean wait); @Override Cacheable getBlock(BlockCacheKey key, boolean caching, boolean repeat,
      boolean updateCacheMetrics); @Override boolean evictBlock(BlockCacheKey cacheKey); void logStats(); long getFailedBlockAdditions(); long getRealCacheSize(); @Override void shutdown(); @Override CacheStats getStats(); BucketAllocator getAllocator(); @Override long heapSize(); @Override long size(); @Override long getFreeSize(); @Override long getBlockCount(); @Override long getCurrentSize(); @Override int evictBlocksByHfileName(String hfileName); @Override Iterator<CachedBlock> iterator(); @Override BlockCache[] getBlockCaches(); static final int DEFAULT_ERROR_TOLERATION_DURATION; }