You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by vj...@apache.org on 2021/07/19 09:59:43 UTC
[hbase] branch branch-2.4 updated: HBASE-25986 set default value of
normalization enabled from hbase site (#3476) (#3372)
This is an automated email from the ASF dual-hosted git repository.
vjasani pushed a commit to branch branch-2.4
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2.4 by this push:
new 02c796c HBASE-25986 set default value of normalization enabled from hbase site (#3476) (#3372)
02c796c is described below
commit 02c796ca0efa4eb326027f647268b82fc65c4e3b
Author: Aman Poonia <am...@gmail.com>
AuthorDate: Mon Jul 19 15:26:52 2021 +0530
HBASE-25986 set default value of normalization enabled from hbase site (#3476) (#3372)
Signed-off-by: Viraj Jasani <vj...@apache.org>
---
.../org/apache/hadoop/hbase/HTableDescriptor.java | 1 -
.../hadoop/hbase/client/TableDescriptor.java | 2 +-
.../hbase/client/TableDescriptorBuilder.java | 11 ++-------
hbase-common/src/main/resources/hbase-default.xml | 7 ++++++
.../master/normalizer/RegionNormalizerWorker.java | 28 ++++++++++++++++++----
5 files changed, 34 insertions(+), 15 deletions(-)
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 250e393..ff3e83e 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
@@ -74,7 +74,6 @@ public class HTableDescriptor implements TableDescriptor, Comparable<HTableDescr
public static final String PRIORITY = TableDescriptorBuilder.PRIORITY;
public static final boolean DEFAULT_READONLY = TableDescriptorBuilder.DEFAULT_READONLY;
public static final boolean DEFAULT_COMPACTION_ENABLED = TableDescriptorBuilder.DEFAULT_COMPACTION_ENABLED;
- public static final boolean DEFAULT_NORMALIZATION_ENABLED = TableDescriptorBuilder.DEFAULT_NORMALIZATION_ENABLED;
public static final long DEFAULT_MEMSTORE_FLUSH_SIZE = TableDescriptorBuilder.DEFAULT_MEMSTORE_FLUSH_SIZE;
public static final int DEFAULT_REGION_REPLICATION = TableDescriptorBuilder.DEFAULT_REGION_REPLICATION;
public static final boolean DEFAULT_REGION_MEMSTORE_REPLICATION = TableDescriptorBuilder.DEFAULT_REGION_MEMSTORE_REPLICATION;
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/TableDescriptor.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/TableDescriptor.java
index 02015e8..789c044 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/TableDescriptor.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/TableDescriptor.java
@@ -290,7 +290,7 @@ public interface TableDescriptor {
/**
* 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.
+ * then region normalizer won't attempt to normalize this table.
*
* @return true if region normalization is enabled for this table
*/
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/TableDescriptorBuilder.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/TableDescriptorBuilder.java
index 90b4cbf..91dd6a3 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/TableDescriptorBuilder.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/TableDescriptorBuilder.java
@@ -220,11 +220,6 @@ public class TableDescriptorBuilder {
public static final boolean DEFAULT_MERGE_ENABLED = true;
/**
- * Constant that denotes whether the table is normalized by default.
- */
- public static final boolean DEFAULT_NORMALIZATION_ENABLED = false;
-
- /**
* Constant that denotes the maximum default size of the memstore in bytes after which
* the contents are flushed to the store files.
*/
@@ -245,7 +240,6 @@ public class TableDescriptorBuilder {
String.valueOf(DEFAULT_MEMSTORE_FLUSH_SIZE));
DEFAULT_VALUES.put(DURABILITY, DEFAULT_DURABLITY.name()); //use the enum name
DEFAULT_VALUES.put(REGION_REPLICATION, String.valueOf(DEFAULT_REGION_REPLICATION));
- DEFAULT_VALUES.put(NORMALIZATION_ENABLED, String.valueOf(DEFAULT_NORMALIZATION_ENABLED));
DEFAULT_VALUES.put(PRIORITY, String.valueOf(DEFAULT_PRIORITY));
DEFAULT_VALUES.keySet().stream()
.map(s -> new Bytes(Bytes.toBytes(s))).forEach(RESERVED_KEYWORDS::add);
@@ -874,12 +868,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 8af16b4..b73274a 100644
--- a/hbase-common/src/main/resources/hbase-default.xml
+++ b/hbase-common/src/main/resources/hbase-default.xml
@@ -655,6 +655,13 @@ possible configurations would overwhelm and obscure the important.
MBs.</description>
</property>
<property>
+ <name>hbase.table.normalization.enabled</name>
+ <value>false</value>
+ <description>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</description>
+ </property>
+ <property>
<name>hbase.server.thread.wakefrequency</name>
<value>10000</value>
<description>Time to sleep in between searches for work (in milliseconds).
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 59d2f46..0c95081 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);