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
IOException
private static TestBucketCacheRefCnt.MyBucketCache createMyBucketCache(int writerSize, int queueSize) throws IOException
IOException
private static TestBucketCacheRefCnt.MyBucketCache2 createMyBucketCache2(int writerSize, int queueSize) throws IOException
IOException
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 void disableWriter()
public void testBlockInRAMCache() throws IOException
IOException
private static void waitUntilFlushedToCache(org.apache.hadoop.hbase.io.hfile.bucket.BucketCache bucketCache, org.apache.hadoop.hbase.io.hfile.BlockCacheKey blockCacheKey) throws InterruptedException
InterruptedException
public void testBlockInBackingMap() throws Exception
Exception
public void testInBucketCache() throws IOException
IOException
public void testMarkStaleAsEvicted() throws Exception
Exception
public 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,thenRefCnt
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.
Exception
public 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)
, 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.
Exception
private 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.