HBASE-21540 when set property "hbase.systemtables.compacting.memstore.type" to "basic" or "eager" will cause an exception

Signed-off-by: Duo Zhang <zhangduo@apache.org>
This commit is contained in:
李小保 2019-02-27 19:30:02 +08:00 committed by Duo Zhang
parent 6f6d331f9f
commit 699fad39a4
2 changed files with 16 additions and 2 deletions

View File

@ -344,8 +344,8 @@ public class HStore implements Store, HeapSize, StoreConfigInformation, Propagat
// Check if in-memory-compaction configured. Note MemoryCompactionPolicy is an enum!
MemoryCompactionPolicy inMemoryCompaction = null;
if (this.getTableName().isSystemTable()) {
inMemoryCompaction = MemoryCompactionPolicy.valueOf(
conf.get("hbase.systemtables.compacting.memstore.type", "NONE"));
inMemoryCompaction = MemoryCompactionPolicy
.valueOf(conf.get("hbase.systemtables.compacting.memstore.type", "NONE").toUpperCase());
} else {
inMemoryCompaction = family.getInMemoryCompaction();
}

View File

@ -68,6 +68,7 @@ import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.MemoryCompactionPolicy;
import org.apache.hadoop.hbase.NamespaceDescriptor;
import org.apache.hadoop.hbase.PrivateCellUtil;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptor;
@ -1662,6 +1663,19 @@ public class TestHStore {
assertFalse(heap.equals(heap2));
}
@Test
public void testInMemoryCompactionTypeWithLowerCase() throws IOException, InterruptedException {
Configuration conf = HBaseConfiguration.create();
conf.set("hbase.systemtables.compacting.memstore.type", "eager");
init(name.getMethodName(), conf,
TableDescriptorBuilder.newBuilder(
TableName.valueOf(NamespaceDescriptor.SYSTEM_NAMESPACE_NAME, "meta".getBytes())),
ColumnFamilyDescriptorBuilder.newBuilder(family)
.setInMemoryCompaction(MemoryCompactionPolicy.NONE).build());
assertTrue(((MemStoreCompactor) ((CompactingMemStore) store.memstore).compactor).toString()
.startsWith("eager".toUpperCase()));
}
private static class MyThread extends Thread {
private StoreScanner scanner;
private KeyValueHeap heap;