From 40e1c9e31031eec5f909e52fbee19bcab7ccefc4 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Wed, 4 Dec 2019 13:55:53 +0900 Subject: [PATCH] HBASE-22529 Add sanity check for in-memory compaction policy Signed-off-by: Toshihiro Suzuki --- .../apache/hadoop/hbase/util/TableDescriptorChecker.java | 7 +++++++ .../hadoop/hbase/client/TestIllegalTableDescriptor.java | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/TableDescriptorChecker.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/TableDescriptorChecker.java index a2ee1ff2559..3852a417751 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/TableDescriptorChecker.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/TableDescriptorChecker.java @@ -188,6 +188,13 @@ public final class TableDescriptorChecker { " must be greater than zero."; warnOrThrowExceptionForFailure(logWarn, message, null); } + + // check in-memory compaction + try { + hcd.getInMemoryCompaction(); + } catch (IllegalArgumentException e) { + warnOrThrowExceptionForFailure(logWarn, e.getMessage(), e); + } } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestIllegalTableDescriptor.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestIllegalTableDescriptor.java index e7bc8b3d4b2..e55f3ff6bcc 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestIllegalTableDescriptor.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestIllegalTableDescriptor.java @@ -151,6 +151,11 @@ public class TestIllegalTableDescriptor { hcd.setScope(0); checkTableIsLegal(htd); + hcd.setValue(ColumnFamilyDescriptorBuilder.IN_MEMORY_COMPACTION, "INVALID"); + checkTableIsIllegal(htd); + hcd.setValue(ColumnFamilyDescriptorBuilder.IN_MEMORY_COMPACTION, "NONE"); + checkTableIsLegal(htd); + try { hcd.setDFSReplication((short) -1); fail("Illegal value for setDFSReplication did not throw");