Class TestBucketCacheRefCnt
java.lang.Object
org.apache.hadoop.hbase.io.hfile.bucket.TestBucketCacheRefCnt
-
Nested Class Summary
Modifier and TypeClassDescription(package private) static class
(package private) static class
-
Field Summary
Modifier and TypeFieldDescriptionprivate static final int
private static final int[]
private org.apache.hadoop.hbase.io.hfile.bucket.BucketCache
private static final long
static final HBaseClassTestRule
private static final org.apache.hadoop.hbase.io.hfile.HFileContext
private static final String
private static final String
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate 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
private static TestBucketCacheRefCnt.MyBucketCache
createMyBucketCache
(int writerSize, int queueSize) private static TestBucketCacheRefCnt.MyBucketCache2
createMyBucketCache2
(int writerSize, int queueSize) private void
private static org.apache.hadoop.hbase.nio.ByteBuff
getOverwriteByteBuff
(org.apache.hadoop.hbase.io.hfile.bucket.BucketEntry bucketEntry) void
void
void
This test also is for HBASE-26281, test three threads for evicting Block,caching Block and getting Block execute concurrently.void
void
void
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)
-
Field Details
-
CLASS_RULE
-
IO_ENGINE
- See Also:
-
CAPACITY_SIZE
- See Also:
-
BLOCK_SIZE
- See Also:
-
BLOCK_SIZE_ARRAY
-
PERSISTENCE_PATH
-
CONTEXT
-
cache
-
-
Constructor Details
-
TestBucketCacheRefCnt
public TestBucketCacheRefCnt()
-
-
Method Details
-
create
private static org.apache.hadoop.hbase.io.hfile.bucket.BucketCache create(int writerSize, int queueSize) throws IOException - Throws:
IOException
-
createMyBucketCache
private static TestBucketCacheRefCnt.MyBucketCache createMyBucketCache(int writerSize, int queueSize) throws IOException - Throws:
IOException
-
createMyBucketCache2
private static TestBucketCacheRefCnt.MyBucketCache2 createMyBucketCache2(int writerSize, int queueSize) throws IOException - Throws:
IOException
-
createBlock
-
createBlock
private static org.apache.hadoop.hbase.io.hfile.HFileBlock createBlock(int offset, int size, org.apache.hadoop.hbase.io.ByteBuffAllocator alloc) -
createKey
-
disableWriter
-
testBlockInRAMCache
- Throws:
IOException
-
waitUntilFlushedToCache
private static void waitUntilFlushedToCache(org.apache.hadoop.hbase.io.hfile.bucket.BucketCache bucketCache, org.apache.hadoop.hbase.io.hfile.BlockCacheKey blockCacheKey) throws InterruptedException - Throws:
InterruptedException
-
testBlockInBackingMap
- Throws:
Exception
-
testInBucketCache
- Throws:
IOException
-
testMarkStaleAsEvicted
- Throws:
Exception
-
testReplacingBlockAndGettingBlockConcurrently
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,the
RefCnt
of Block1 is 1. 2. Thread1 caching the sameBlockCacheKey
with 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, theRefCnt
of 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 whichRefCnt
is 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.- Throws:
Exception
-
testEvictingBlockCachingBlockGettingBlockConcurrently
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 after
BucketCache.putIntoBackingMap(org.apache.hadoop.hbase.io.hfile.BlockCacheKey, org.apache.hadoop.hbase.io.hfile.bucket.BucketEntry)
, theRefCnt
of 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, theRefCnt
of 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 whichRefCnt
is 2 and the Block1 is still used by Thread3.- Throws:
Exception
-
getOverwriteByteBuff
private static org.apache.hadoop.hbase.nio.ByteBuff getOverwriteByteBuff(org.apache.hadoop.hbase.io.hfile.bucket.BucketEntry bucketEntry)
-