Skip to content

Commit 02c796c

Browse files
mnpooniavirajjasani
authored andcommitted
HBASE-25986 set default value of normalization enabled from hbase site (#3476) (#3372)
Signed-off-by: Viraj Jasani <vjasani@apache.org>
1 parent 6ab6d6f commit 02c796c

File tree

5 files changed

+34
-15
lines changed

5 files changed

+34
-15
lines changed

hbase-client/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ public class HTableDescriptor implements TableDescriptor, Comparable<HTableDescr
7474
public static final String PRIORITY = TableDescriptorBuilder.PRIORITY;
7575
public static final boolean DEFAULT_READONLY = TableDescriptorBuilder.DEFAULT_READONLY;
7676
public static final boolean DEFAULT_COMPACTION_ENABLED = TableDescriptorBuilder.DEFAULT_COMPACTION_ENABLED;
77-
public static final boolean DEFAULT_NORMALIZATION_ENABLED = TableDescriptorBuilder.DEFAULT_NORMALIZATION_ENABLED;
7877
public static final long DEFAULT_MEMSTORE_FLUSH_SIZE = TableDescriptorBuilder.DEFAULT_MEMSTORE_FLUSH_SIZE;
7978
public static final int DEFAULT_REGION_REPLICATION = TableDescriptorBuilder.DEFAULT_REGION_REPLICATION;
8079
public static final boolean DEFAULT_REGION_MEMSTORE_REPLICATION = TableDescriptorBuilder.DEFAULT_REGION_MEMSTORE_REPLICATION;

hbase-client/src/main/java/org/apache/hadoop/hbase/client/TableDescriptor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ default Collection<String> getCoprocessors() {
290290

291291
/**
292292
* Check if normalization enable flag of the table is true. If flag is false
293-
* then no region normalizer won't attempt to normalize this table.
293+
* then region normalizer won't attempt to normalize this table.
294294
*
295295
* @return true if region normalization is enabled for this table
296296
*/

hbase-client/src/main/java/org/apache/hadoop/hbase/client/TableDescriptorBuilder.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -219,11 +219,6 @@ public class TableDescriptorBuilder {
219219
*/
220220
public static final boolean DEFAULT_MERGE_ENABLED = true;
221221

222-
/**
223-
* Constant that denotes whether the table is normalized by default.
224-
*/
225-
public static final boolean DEFAULT_NORMALIZATION_ENABLED = false;
226-
227222
/**
228223
* Constant that denotes the maximum default size of the memstore in bytes after which
229224
* the contents are flushed to the store files.
@@ -245,7 +240,6 @@ public class TableDescriptorBuilder {
245240
String.valueOf(DEFAULT_MEMSTORE_FLUSH_SIZE));
246241
DEFAULT_VALUES.put(DURABILITY, DEFAULT_DURABLITY.name()); //use the enum name
247242
DEFAULT_VALUES.put(REGION_REPLICATION, String.valueOf(DEFAULT_REGION_REPLICATION));
248-
DEFAULT_VALUES.put(NORMALIZATION_ENABLED, String.valueOf(DEFAULT_NORMALIZATION_ENABLED));
249243
DEFAULT_VALUES.put(PRIORITY, String.valueOf(DEFAULT_PRIORITY));
250244
DEFAULT_VALUES.keySet().stream()
251245
.map(s -> new Bytes(Bytes.toBytes(s))).forEach(RESERVED_KEYWORDS::add);
@@ -874,12 +868,11 @@ public ModifyableTableDescriptor setMergeEnabled(final boolean isEnable) {
874868
/**
875869
* Check if normalization enable flag of the table is true. If flag is false
876870
* then no region normalizer won't attempt to normalize this table.
877-
*
878871
* @return true if region normalization is enabled for this table
879-
*/
872+
**/
880873
@Override
881874
public boolean isNormalizationEnabled() {
882-
return getOrDefault(NORMALIZATION_ENABLED_KEY, Boolean::valueOf, DEFAULT_NORMALIZATION_ENABLED);
875+
return getOrDefault(NORMALIZATION_ENABLED_KEY, Boolean::valueOf, false);
883876
}
884877

885878
/**

hbase-common/src/main/resources/hbase-default.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,13 @@ possible configurations would overwhelm and obscure the important.
654654
<description>The minimum size for a region to be considered for a merge, in whole
655655
MBs.</description>
656656
</property>
657+
<property>
658+
<name>hbase.table.normalization.enabled</name>
659+
<value>false</value>
660+
<description>This config is used to set default behaviour of normalizer at table level.
661+
To override this at table level one can set NORMALIZATION_ENABLED at table descriptor level
662+
and that property will be honored</description>
663+
</property>
657664
<property>
658665
<name>hbase.server.thread.wakefrequency</name>
659666
<value>10000</value>

hbase-server/src/main/java/org/apache/hadoop/hbase/master/normalizer/RegionNormalizerWorker.java

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.apache.hadoop.hbase.TableName;
2727
import org.apache.hadoop.hbase.client.RegionInfo;
2828
import org.apache.hadoop.hbase.client.TableDescriptor;
29+
import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
2930
import org.apache.hadoop.hbase.conf.ConfigurationManager;
3031
import org.apache.hadoop.hbase.conf.ConfigurationObserver;
3132
import org.apache.hadoop.hbase.conf.PropagatingConfigurationObserver;
@@ -43,6 +44,8 @@
4344
*/
4445
@InterfaceAudience.Private
4546
class RegionNormalizerWorker implements PropagatingConfigurationObserver, Runnable {
47+
public static final String HBASE_TABLE_NORMALIZATION_ENABLED =
48+
"hbase.table.normalization.enabled";
4649
private static final Logger LOG = LoggerFactory.getLogger(RegionNormalizerWorker.class);
4750

4851
static final String RATE_LIMIT_BYTES_PER_SEC_KEY =
@@ -55,6 +58,7 @@ class RegionNormalizerWorker implements PropagatingConfigurationObserver, Runnab
5558
private final RateLimiter rateLimiter;
5659

5760
private final long[] skippedCount;
61+
private final boolean defaultNormalizerTableLevel;
5862
private long splitPlanCount;
5963
private long mergePlanCount;
6064

@@ -71,6 +75,12 @@ class RegionNormalizerWorker implements PropagatingConfigurationObserver, Runnab
7175
this.splitPlanCount = 0;
7276
this.mergePlanCount = 0;
7377
this.rateLimiter = loadRateLimiter(configuration);
78+
this.defaultNormalizerTableLevel = extractDefaultNormalizerValue(configuration);
79+
}
80+
81+
private boolean extractDefaultNormalizerValue(final Configuration configuration) {
82+
String s = configuration.get(HBASE_TABLE_NORMALIZATION_ENABLED);
83+
return Boolean.parseBoolean(s);
7484
}
7585

7686
@Override
@@ -181,10 +191,20 @@ private List<NormalizationPlan> calculatePlans(final TableName tableName) {
181191
final TableDescriptor tblDesc;
182192
try {
183193
tblDesc = masterServices.getTableDescriptors().get(tableName);
184-
if (tblDesc != null && !tblDesc.isNormalizationEnabled()) {
185-
LOG.debug("Skipping table {} because normalization is disabled in its table properties.",
186-
tableName);
187-
return Collections.emptyList();
194+
boolean normalizationEnabled;
195+
if (tblDesc != null) {
196+
String defined = tblDesc.getValue(TableDescriptorBuilder.NORMALIZATION_ENABLED);
197+
if(defined != null) {
198+
normalizationEnabled = tblDesc.isNormalizationEnabled();
199+
} else {
200+
normalizationEnabled = this.defaultNormalizerTableLevel;
201+
}
202+
if (!normalizationEnabled) {
203+
LOG.debug("Skipping table {} because normalization is disabled in its table properties " +
204+
"and normalization is also disabled at table level by default",
205+
tableName);
206+
return Collections.emptyList();
207+
}
188208
}
189209
} catch (IOException e) {
190210
LOG.debug("Skipping table {} because unable to access its table descriptor.", tableName, e);

0 commit comments

Comments
 (0)