diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java index 7285846f91f..6bb9091bf3e 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java @@ -75,7 +75,6 @@ public class HTableDescriptor implements TableDescriptor, Comparable new Bytes(Bytes.toBytes(s))).forEach(RESERVED_KEYWORDS::add); @@ -897,12 +891,11 @@ public class TableDescriptorBuilder { /** * Check if normalization enable flag of the table is true. If flag is false * then no region normalizer won't attempt to normalize this table. - * * @return true if region normalization is enabled for this table - */ + **/ @Override public boolean isNormalizationEnabled() { - return getOrDefault(NORMALIZATION_ENABLED_KEY, Boolean::valueOf, DEFAULT_NORMALIZATION_ENABLED); + return getOrDefault(NORMALIZATION_ENABLED_KEY, Boolean::valueOf, false); } /** diff --git a/hbase-common/src/main/resources/hbase-default.xml b/hbase-common/src/main/resources/hbase-default.xml index 453e0153bad..ce4a13e9522 100644 --- a/hbase-common/src/main/resources/hbase-default.xml +++ b/hbase-common/src/main/resources/hbase-default.xml @@ -661,6 +661,13 @@ possible configurations would overwhelm and obscure the important. The minimum size for a region to be considered for a merge, in whole MBs. + + hbase.table.normalization.enabled + false + This config is used to set default behaviour of normalizer at table level. + To override this at table level one can set NORMALIZATION_ENABLED at table descriptor level + and that property will be honored + hbase.server.thread.wakefrequency 10000 diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/normalizer/RegionNormalizerWorker.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/normalizer/RegionNormalizerWorker.java index 59d2f465341..0c9508189a2 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/normalizer/RegionNormalizerWorker.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/normalizer/RegionNormalizerWorker.java @@ -26,6 +26,7 @@ import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.client.RegionInfo; import org.apache.hadoop.hbase.client.TableDescriptor; +import org.apache.hadoop.hbase.client.TableDescriptorBuilder; import org.apache.hadoop.hbase.conf.ConfigurationManager; import org.apache.hadoop.hbase.conf.ConfigurationObserver; import org.apache.hadoop.hbase.conf.PropagatingConfigurationObserver; @@ -43,6 +44,8 @@ import org.apache.hbase.thirdparty.org.apache.commons.collections4.CollectionUti */ @InterfaceAudience.Private class RegionNormalizerWorker implements PropagatingConfigurationObserver, Runnable { + public static final String HBASE_TABLE_NORMALIZATION_ENABLED = + "hbase.table.normalization.enabled"; private static final Logger LOG = LoggerFactory.getLogger(RegionNormalizerWorker.class); static final String RATE_LIMIT_BYTES_PER_SEC_KEY = @@ -55,6 +58,7 @@ class RegionNormalizerWorker implements PropagatingConfigurationObserver, Runnab private final RateLimiter rateLimiter; private final long[] skippedCount; + private final boolean defaultNormalizerTableLevel; private long splitPlanCount; private long mergePlanCount; @@ -71,6 +75,12 @@ class RegionNormalizerWorker implements PropagatingConfigurationObserver, Runnab this.splitPlanCount = 0; this.mergePlanCount = 0; this.rateLimiter = loadRateLimiter(configuration); + this.defaultNormalizerTableLevel = extractDefaultNormalizerValue(configuration); + } + + private boolean extractDefaultNormalizerValue(final Configuration configuration) { + String s = configuration.get(HBASE_TABLE_NORMALIZATION_ENABLED); + return Boolean.parseBoolean(s); } @Override @@ -181,10 +191,20 @@ class RegionNormalizerWorker implements PropagatingConfigurationObserver, Runnab final TableDescriptor tblDesc; try { tblDesc = masterServices.getTableDescriptors().get(tableName); - if (tblDesc != null && !tblDesc.isNormalizationEnabled()) { - LOG.debug("Skipping table {} because normalization is disabled in its table properties.", - tableName); - return Collections.emptyList(); + boolean normalizationEnabled; + if (tblDesc != null) { + String defined = tblDesc.getValue(TableDescriptorBuilder.NORMALIZATION_ENABLED); + if(defined != null) { + normalizationEnabled = tblDesc.isNormalizationEnabled(); + } else { + normalizationEnabled = this.defaultNormalizerTableLevel; + } + if (!normalizationEnabled) { + LOG.debug("Skipping table {} because normalization is disabled in its table properties " + + "and normalization is also disabled at table level by default", + tableName); + return Collections.emptyList(); + } } } catch (IOException e) { LOG.debug("Skipping table {} because unable to access its table descriptor.", tableName, e);