Skip to content

Commit a0eb31c

Browse files
committed
HBASE-25986 set default value of normalization enabled from hbase site
1 parent 3b3ec32 commit a0eb31c

File tree

4 files changed

+32
-10
lines changed

4 files changed

+32
-10
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,6 @@ public class HTableDescriptor implements WritableComparable<HTableDescriptor> {
280280
String.valueOf(DEFAULT_DEFERRED_LOG_FLUSH));
281281
DEFAULT_VALUES.put(DURABILITY, DEFAULT_DURABLITY.name()); //use the enum name
282282
DEFAULT_VALUES.put(REGION_REPLICATION, String.valueOf(DEFAULT_REGION_REPLICATION));
283-
DEFAULT_VALUES.put(NORMALIZATION_ENABLED, String.valueOf(DEFAULT_NORMALIZATION_ENABLED));
284283
DEFAULT_VALUES.put(PRIORITY, String.valueOf(DEFAULT_PRIORITY));
285284
for (String s : DEFAULT_VALUES.keySet()) {
286285
RESERVED_KEYWORDS.add(new ImmutableBytesWritable(Bytes.toBytes(s)));
@@ -684,7 +683,7 @@ public HTableDescriptor setCompactionEnabled(final boolean isEnable) {
684683
* @return true if region normalization is enabled for this table
685684
*/
686685
public boolean isNormalizationEnabled() {
687-
return isSomething(NORMALIZATION_ENABLED_KEY, DEFAULT_NORMALIZATION_ENABLED);
686+
return isSomething(NORMALIZATION_ENABLED_KEY, false);
688687
}
689688

690689
/**

hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWatcher.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ public class ZooKeeperWatcher implements Watcher, Abortable, Closeable {
190190
* @throws IOException
191191
* @throws ZooKeeperConnectionException
192192
*/
193-
public ZooKeeperWatcher(Configuration conf, String identifier,
193+
public ZooKeeperWatcher(Configuration conf, String identifier,
194194
Abortable abortable) throws ZooKeeperConnectionException, IOException {
195195
this(conf, identifier, abortable, false);
196196
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,13 @@ possible configurations would overwhelm and obscure the important.
642642
<description>The minimum size for a region to be considered for a merge, in whole MBs.
643643
</description>
644644
</property>
645+
<property>
646+
<name>hbase.table.normalization.enabled</name>
647+
<value>false</value>
648+
<description>This config is used to set default behaviour of normalizer at table level. To override this at table
649+
level one can set NORMALIZATION_ENABLED at table descriptor level and that property will be honored
650+
</description>
651+
</property>
645652
<property>
646653
<name>hbase.server.thread.wakefrequency</name>
647654
<value>10000</value>

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

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,8 @@
205205
@SuppressWarnings("deprecation")
206206
public class HMaster extends HRegionServer implements MasterServices, Server {
207207
private static final Log LOG = LogFactory.getLog(HMaster.class.getName());
208-
208+
public static final String HBASE_TABLE_NORMALIZATION_ENABLED =
209+
"hbase.table.normalization.enabled";
209210
/**
210211
* Protection against zombie master. Started once Master accepts active responsibility and
211212
* starts taking over responsibilities. Allows a finite time window before giving up ownership.
@@ -381,6 +382,7 @@ public void run() {
381382

382383
private long splitPlanCount;
383384
private long mergePlanCount;
385+
private boolean defaultNormalizerTableLevel;
384386

385387
/** flag used in test cases in order to simulate RS failures during master initialization */
386388
private volatile boolean initializationBeforeMetaAssignment = false;
@@ -529,6 +531,7 @@ public HMaster(final Configuration conf, CoordinatedStateManager csm)
529531
activeMasterManager = null;
530532
}
531533
cachedClusterId = new CachedClusterId(conf);
534+
this.defaultNormalizerTableLevel = extractDefaultNormalizerValue(conf);
532535
}
533536

534537
// return the actual infoPort, -1 means disable info server.
@@ -1117,6 +1120,11 @@ void assignMeta(MonitoredTask status, Set<ServerName> previouslyFailedMetaRSs, i
11171120
status.setStatus("META assigned.");
11181121
}
11191122

1123+
private boolean extractDefaultNormalizerValue(final Configuration configuration) {
1124+
String s = configuration.get(HBASE_TABLE_NORMALIZATION_ENABLED);
1125+
return Boolean.parseBoolean(s);
1126+
}
1127+
11201128
private void assignMetaZkLess(RegionStates regionStates, RegionState regionState, long timeout,
11211129
Set<ServerName> previouslyFailedRs) throws IOException, KeeperException {
11221130
ServerName currentServer = regionState.getServerName();
@@ -1692,12 +1700,20 @@ public boolean normalizeRegions() throws IOException, CoordinatedStateException
16921700
if (table.isSystemTable()) {
16931701
continue;
16941702
}
1695-
1703+
boolean normalizationEnabled;
16961704
HTableDescriptor tableDescriptor = getTableDescriptors().get(table);
1697-
if (tableDescriptor != null && !tableDescriptor.isNormalizationEnabled()) {
1698-
LOG.debug("Skipping normalization for table: " + table
1699-
+ ", as it doesn't have auto normalization turned on");
1700-
continue;
1705+
if (tableDescriptor != null) {
1706+
String defined = tableDescriptor.getValue(HTableDescriptor.NORMALIZATION_ENABLED);
1707+
if (defined != null) {
1708+
normalizationEnabled = tableDescriptor.isNormalizationEnabled();
1709+
} else {
1710+
normalizationEnabled = this.defaultNormalizerTableLevel;
1711+
}
1712+
if (!normalizationEnabled) {
1713+
LOG.debug("Skipping table " + table + " because normalization is disabled in its table " +
1714+
"properties and normalization is also disabled at table level by default");
1715+
continue;
1716+
}
17011717
}
17021718
// make one last check that the cluster isn't shutting down before proceeding.
17031719
if (skipRegionManagementAction("region normalizer")) {
@@ -1720,7 +1736,7 @@ public boolean normalizeRegions() throws IOException, CoordinatedStateException
17201736
}
17211737
}
17221738
} finally {
1723-
normalizationInProgressLock.unlock();
1739+
normalizationInProgressLock.unlock();
17241740
}
17251741
// If Region did not generate any plans, it means the cluster is already balanced.
17261742
// Return true indicating a success.

0 commit comments

Comments
 (0)