@Test public void testBlockCache() throws IOException, InterruptedException, ExecutionException { int blocksPerSlab = 1024; int slabs = 4; final int blocksInTest = (blocksPerSlab * slabs) * 2; final int blockSize = BlockCache._8K; int slabSize = blockSize * blocksPerSlab; long totalMemory = slabs * (long) slabSize; final BlockCache blockCache = new BlockCache(true, totalMemory, slabSize); final int threads = 4; ExecutorService pool = Executors.newFixedThreadPool(threads); List<Future<Boolean>> futures = new ArrayList<Future<Boolean>>(); final int testSpace = blocksInTest / threads; for (int g = 0; g < threads; g++) { final int file = g; futures.add(pool.submit(new Callable<Boolean>() { @Override public Boolean call() throws Exception { return runTest(blockSize, file, testSpace, blockCache); } })); } for (Future<Boolean> future : futures) { if (!future.get()) { fail(); } } blockCache.close(); }
public BlockCache(boolean directAllocation, long totalMemory) { this(directAllocation, totalMemory, _128M); }
BlockCache implements Closeable { public BlockCache(boolean directAllocation, long totalMemory) { this(directAllocation, totalMemory, _128M); } }
BlockCache implements Closeable { public BlockCache(boolean directAllocation, long totalMemory) { this(directAllocation, totalMemory, _128M); } BlockCache(boolean directAllocation, long totalMemory);  BlockCache(boolean directAllocation, long totalMemory, int slabSize); }
BlockCache implements Closeable { public BlockCache(boolean directAllocation, long totalMemory) { this(directAllocation, totalMemory, _128M); } BlockCache(boolean directAllocation, long totalMemory);  BlockCache(boolean directAllocation, long totalMemory, int slabSize); boolean store(BlockCacheKey blockCacheKey, int blockOffset, byte[] data, int offset, int length); boolean fetch(BlockCacheKey blockCacheKey, byte[] buffer, int blockOffset, int off, int length); boolean fetch(BlockCacheKey blockCacheKey, byte[] buffer); int getSize(); void close(); }
BlockCache implements Closeable { public BlockCache(boolean directAllocation, long totalMemory) { this(directAllocation, totalMemory, _128M); } BlockCache(boolean directAllocation, long totalMemory);  BlockCache(boolean directAllocation, long totalMemory, int slabSize); boolean store(BlockCacheKey blockCacheKey, int blockOffset, byte[] data, int offset, int length); boolean fetch(BlockCacheKey blockCacheKey, byte[] buffer, int blockOffset, int off, int length); boolean fetch(BlockCacheKey blockCacheKey, byte[] buffer); int getSize(); void close(); static final boolean UNMAP_SUPPORTED; static final int _128M; static final int _8K; }