public class TestBucketCacheRefCnt extends Object
| Modifier and Type | Class and Description |
|---|---|
(package private) static class |
TestBucketCacheRefCnt.MyBucketCache |
(package private) static class |
TestBucketCacheRefCnt.MyBucketCache2 |
| Modifier and Type | Field and Description |
|---|---|
private static int |
BLOCK_SIZE |
private static int[] |
BLOCK_SIZE_ARRAY |
private org.apache.hadoop.hbase.io.hfile.bucket.BucketCache |
cache |
private static long |
CAPACITY_SIZE |
static HBaseClassTestRule |
CLASS_RULE |
private static org.apache.hadoop.hbase.io.hfile.HFileContext |
CONTEXT |
private static String |
IO_ENGINE |
private static String |
PERSISTENCE_PATH |
| Constructor and Description |
|---|
TestBucketCacheRefCnt() |
| Modifier and Type | Method and Description |
|---|---|
private static org.apache.hadoop.hbase.io.hfile.bucket.BucketCache |
create(int writerSize,
int queueSize) |
private static org.apache.hadoop.hbase.io.hfile.HFileBlock |
createBlock(int offset,
int size) |
private static org.apache.hadoop.hbase.io.hfile.HFileBlock |
createBlock(int offset,
int size,
org.apache.hadoop.hbase.io.ByteBuffAllocator alloc) |
private static org.apache.hadoop.hbase.io.hfile.BlockCacheKey |
createKey(String hfileName,
long offset) |
private static TestBucketCacheRefCnt.MyBucketCache |
createMyBucketCache(int writerSize,
int queueSize) |
private static TestBucketCacheRefCnt.MyBucketCache2 |
createMyBucketCache2(int writerSize,
int queueSize) |
private void |
disableWriter() |
private static org.apache.hadoop.hbase.nio.ByteBuff |
getOverwriteByteBuff(org.apache.hadoop.hbase.io.hfile.bucket.BucketEntry bucketEntry) |
void |
testBlockInBackingMap() |
void |
testBlockInRAMCache() |
void |
testEvictingBlockCachingBlockGettingBlockConcurrently()
This test also is for HBASE-26281,
test three threads for evicting Block,caching Block and getting Block
execute concurrently.
|
void |
testInBucketCache() |
void |
testMarkStaleAsEvicted() |
void |
testReplacingBlockAndGettingBlockConcurrently()
This test is for HBASE-26281,
test two threads for replacing Block and getting Block execute concurrently.
|
private static void |
waitUntilFlushedToCache(org.apache.hadoop.hbase.io.hfile.bucket.BucketCache bucketCache,
org.apache.hadoop.hbase.io.hfile.BlockCacheKey blockCacheKey) |
public static final HBaseClassTestRule CLASS_RULE
private static final String IO_ENGINE
private static final long CAPACITY_SIZE
private static final int BLOCK_SIZE
private static final int[] BLOCK_SIZE_ARRAY
private static final String PERSISTENCE_PATH
private static final org.apache.hadoop.hbase.io.hfile.HFileContext CONTEXT
private org.apache.hadoop.hbase.io.hfile.bucket.BucketCache cache
public TestBucketCacheRefCnt()
private static org.apache.hadoop.hbase.io.hfile.bucket.BucketCache create(int writerSize, int queueSize) throws IOException
IOExceptionprivate static TestBucketCacheRefCnt.MyBucketCache createMyBucketCache(int writerSize, int queueSize) throws IOException
IOExceptionprivate static TestBucketCacheRefCnt.MyBucketCache2 createMyBucketCache2(int writerSize, int queueSize) throws IOException
IOExceptionprivate static org.apache.hadoop.hbase.io.hfile.HFileBlock createBlock(int offset, int size)
private static org.apache.hadoop.hbase.io.hfile.HFileBlock createBlock(int offset, int size, org.apache.hadoop.hbase.io.ByteBuffAllocator alloc)
private static org.apache.hadoop.hbase.io.hfile.BlockCacheKey createKey(String hfileName, long offset)
private void disableWriter()
public void testBlockInRAMCache() throws IOException
IOExceptionprivate static void waitUntilFlushedToCache(org.apache.hadoop.hbase.io.hfile.bucket.BucketCache bucketCache, org.apache.hadoop.hbase.io.hfile.BlockCacheKey blockCacheKey) throws InterruptedException
InterruptedExceptionpublic void testBlockInBackingMap() throws Exception
Exceptionpublic void testInBucketCache() throws IOException
IOExceptionpublic void testMarkStaleAsEvicted() throws Exception
Exceptionpublic void testReplacingBlockAndGettingBlockConcurrently() throws Exception
This test is for HBASE-26281, test two threads for replacing Block and getting Block execute concurrently. The threads sequence is: 1. Block1 was cached successfully,thenRefCntof Block1 is 1. 2. Thread1 caching the sameBlockCacheKeywith Block2 satisfiedBlockCacheUtil.shouldReplaceExistingCacheBlock(org.apache.hadoop.hbase.io.hfile.BlockCache, org.apache.hadoop.hbase.io.hfile.BlockCacheKey, org.apache.hadoop.hbase.io.hfile.Cacheable), so Block2 would replace Block1, but thread1 stopping beforeBucketCache.cacheBlockWithWaitInternal(org.apache.hadoop.hbase.io.hfile.BlockCacheKey, org.apache.hadoop.hbase.io.hfile.Cacheable, boolean, boolean)3. Thread2 invokingBucketCache.getBlock(org.apache.hadoop.hbase.io.hfile.BlockCacheKey, boolean, boolean, boolean)with the sameBlockCacheKey, which returned Block1, theRefCntof Block1 is 2. 4. Thread1 continues caching Block2, inBucketCache.putIntoBackingMap(org.apache.hadoop.hbase.io.hfile.BlockCacheKey, org.apache.hadoop.hbase.io.hfile.bucket.BucketEntry), the old Block1 is freed directly whichRefCntis 2, but the Block1 is still used by Thread2 and the content of Block1 would be overwritten after it is freed, which may cause a serious error.
Exceptionpublic void testEvictingBlockCachingBlockGettingBlockConcurrently() throws Exception
This test also is for HBASE-26281, test three threads for evicting Block,caching Block and getting Block execute concurrently. 1. Thread1 caching Block1, stopping afterBucketCache.putIntoBackingMap(org.apache.hadoop.hbase.io.hfile.BlockCacheKey, org.apache.hadoop.hbase.io.hfile.bucket.BucketEntry), theRefCntof Block1 is 1. 2. Thread2 invokingBucketCache.evictBlock(org.apache.hadoop.hbase.io.hfile.BlockCacheKey)with the sameBlockCacheKey, but stopping afterBucketCache.removeFromRamCache(org.apache.hadoop.hbase.io.hfile.BlockCacheKey). 3. Thread3 invokingBucketCache.getBlock(org.apache.hadoop.hbase.io.hfile.BlockCacheKey, boolean, boolean, boolean)with the sameBlockCacheKey, which returned Block1, theRefCntof Block1 is 2. 4. Thread1 continues caching block1,but finding thatBucketCache.RAMCache.remove(org.apache.hadoop.hbase.io.hfile.BlockCacheKey)returning false, so invokingBucketCache.blockEvicted(org.apache.hadoop.hbase.io.hfile.BlockCacheKey, org.apache.hadoop.hbase.io.hfile.bucket.BucketEntry, boolean, boolean)to free the the Block1 directly whichRefCntis 2 and the Block1 is still used by Thread3.
Exceptionprivate static org.apache.hadoop.hbase.nio.ByteBuff getOverwriteByteBuff(org.apache.hadoop.hbase.io.hfile.bucket.BucketEntry bucketEntry)
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.