HBASE-19658 make the test testFlatteningToJumboCellChunkMap() stable, by eliminating the possibility of third cell to be added while in-memory-flush is still in progress

This commit is contained in:
anastas 2018-02-05 11:29:10 +02:00
parent c2e3d52080
commit 514eadbe95
1 changed files with 12 additions and 7 deletions

View File

@ -754,9 +754,9 @@ public class TestCompactingToCellFlatMapMemStore extends TestCompactingMemStore
// set memstore to flat into CellChunkMap // set memstore to flat into CellChunkMap
MemoryCompactionPolicy compactionType = MemoryCompactionPolicy.BASIC; MemoryCompactionPolicy compactionType = MemoryCompactionPolicy.BASIC;
memstore.getConfiguration().set(CompactingMemStore.COMPACTING_MEMSTORE_TYPE_KEY, memstore.getConfiguration().set(CompactingMemStore.COMPACTING_MEMSTORE_TYPE_KEY,
String.valueOf(compactionType)); String.valueOf(compactionType));
((MyCompactingMemStore)memstore).initiateType(compactionType, memstore.getConfiguration()); ((MyCompactingMemStore) memstore).initiateType(compactionType, memstore.getConfiguration());
((CompactingMemStore)memstore).setIndexType(CompactingMemStore.IndexType.CHUNK_MAP); ((CompactingMemStore) memstore).setIndexType(CompactingMemStore.IndexType.CHUNK_MAP);
int numOfCells = 1; int numOfCells = 1;
char[] chars = new char[MemStoreLAB.CHUNK_SIZE_DEFAULT]; char[] chars = new char[MemStoreLAB.CHUNK_SIZE_DEFAULT];
@ -764,7 +764,7 @@ public class TestCompactingToCellFlatMapMemStore extends TestCompactingMemStore
chars[i] = 'A'; chars[i] = 'A';
} }
String bigVal = new String(chars); String bigVal = new String(chars);
String[] keys1 = { "A"}; String[] keys1 = {"A"};
// make one cell // make one cell
byte[] row = Bytes.toBytes(keys1[0]); byte[] row = Bytes.toBytes(keys1[0]);
@ -784,7 +784,7 @@ public class TestCompactingToCellFlatMapMemStore extends TestCompactingMemStore
assertEquals(totalCellsLen, regionServicesForStores.getMemStoreSize()); assertEquals(totalCellsLen, regionServicesForStores.getMemStoreSize());
assertEquals(totalHeapSize, ((CompactingMemStore) memstore).heapSize()); assertEquals(totalHeapSize, ((CompactingMemStore) memstore).heapSize());
((CompactingMemStore)memstore).flushInMemory(); // push keys to pipeline and flatten ((CompactingMemStore) memstore).flushInMemory(); // push keys to pipeline and flatten
while (((CompactingMemStore) memstore).isMemStoreFlushingInMemory()) { while (((CompactingMemStore) memstore).isMemStoreFlushingInMemory()) {
Threads.sleep(10); Threads.sleep(10);
} }
@ -809,12 +809,17 @@ public class TestCompactingToCellFlatMapMemStore extends TestCompactingMemStore
memstore.clearSnapshot(snapshot.getId()); memstore.clearSnapshot(snapshot.getId());
String[] keys2 = { "C", "D", "E"}; // Allocating two big cells (too big for being copied into a regular chunk).
String[] keys2 = {"C", "D"};
addRowsByKeys(memstore, keys2, val); addRowsByKeys(memstore, keys2, val);
while (((CompactingMemStore) memstore).isMemStoreFlushingInMemory()) { while (((CompactingMemStore) memstore).isMemStoreFlushingInMemory()) {
Threads.sleep(10); Threads.sleep(10);
} }
totalHeapSize = 1 * oneCellOnCSLMHeapSize + MutableSegment.DEEP_OVERHEAD
// The in-memory flush size is bigger than the size of a single cell,
// but smaller than the size of two cells.
// Therefore, the two created cells are flattened together.
totalHeapSize = MutableSegment.DEEP_OVERHEAD
+ CellChunkImmutableSegment.DEEP_OVERHEAD_CCM + CellChunkImmutableSegment.DEEP_OVERHEAD_CCM
+ 2 * oneCellOnCCMHeapSize; + 2 * oneCellOnCCMHeapSize;
assertEquals(totalHeapSize, ((CompactingMemStore) memstore).heapSize()); assertEquals(totalHeapSize, ((CompactingMemStore) memstore).heapSize());