Skip to content

Commit fcec908

Browse files
committed
HBASE-25861 Correct the usage of Configuration#addDeprecation
1 parent 2b6a91a commit fcec908

File tree

9 files changed

+75
-46
lines changed

9 files changed

+75
-46
lines changed

hbase-common/src/main/java/org/apache/hadoop/hbase/HBaseConfiguration.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
public class HBaseConfiguration extends Configuration {
3737
private static final Logger LOG = LoggerFactory.getLogger(HBaseConfiguration.class);
3838

39+
static {
40+
addDeprecatedKeys();
41+
}
42+
3943
private static void checkDefaultsVersion(Configuration conf) {
4044
if (conf.getBoolean("hbase.defaults.for.version.skip", Boolean.FALSE)) return;
4145
String defaultsVersion = conf.get("hbase.defaults.for.version");
@@ -47,6 +51,27 @@ private static void checkDefaultsVersion(Configuration conf) {
4751
}
4852
}
4953

54+
private static void addDeprecatedKeys() {
55+
Configuration.addDeprecations(new DeprecationDelta[]{
56+
new DeprecationDelta("hbase.regionserver.hostname", "hbase.unsafe.regionserver.hostname"),
57+
new DeprecationDelta("hbase.regionserver.hostname.disable.master.reversedns",
58+
"hbase.unsafe.regionserver.hostname.disable.master.reversedns"),
59+
new DeprecationDelta("hbase.offheapcache.minblocksize",
60+
"hbase.blockcache.minblocksize"),
61+
new DeprecationDelta("hbase.ipc.server.reservoir.enabled",
62+
"hbase.server.allocator.pool.enabled"),
63+
new DeprecationDelta("hbase.ipc.server.reservoir.initial.max",
64+
"hbase.server.allocator.max.buffer.count"),
65+
new DeprecationDelta("hbase.ipc.server.reservoir.initial.buffer.size",
66+
"hbase.server.allocator.buffer.size"),
67+
new DeprecationDelta("hlog.bulk.output", "wal.bulk.output"),
68+
new DeprecationDelta("hlog.input.tables", "wal.input.tables"),
69+
new DeprecationDelta("hlog.input.tablesmap", "wal.input.tablesmap"),
70+
new DeprecationDelta("hbase.master.mob.ttl.cleaner.period",
71+
"hbase.master.mob.cleaner.period")
72+
});
73+
}
74+
5075
public static Configuration addHbaseResources(Configuration conf) {
5176
conf.addResource("hbase-default.xml");
5277
conf.addResource("hbase-site.xml");

hbase-common/src/main/java/org/apache/hadoop/hbase/io/ByteBuffAllocator.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -92,20 +92,6 @@ public class ByteBuffAllocator {
9292
@Deprecated
9393
static final String DEPRECATED_BUFFER_SIZE_KEY = "hbase.ipc.server.reservoir.initial.buffer.size";
9494

95-
/**
96-
* The hbase.ipc.server.reservoir.initial.max and hbase.ipc.server.reservoir.initial.buffer.size
97-
* were introduced in HBase2.0.0, while in HBase3.0.0 the two config keys will be replaced by
98-
* {@link ByteBuffAllocator#MAX_BUFFER_COUNT_KEY} and {@link ByteBuffAllocator#BUFFER_SIZE_KEY}.
99-
* Also the hbase.ipc.server.reservoir.enabled will be replaced by
100-
* hbase.server.allocator.pool.enabled. Keep the three old config keys here for HBase2.x
101-
* compatibility.
102-
*/
103-
static {
104-
Configuration.addDeprecation(DEPRECATED_ALLOCATOR_POOL_ENABLED_KEY, ALLOCATOR_POOL_ENABLED_KEY);
105-
Configuration.addDeprecation(DEPRECATED_MAX_BUFFER_COUNT_KEY, MAX_BUFFER_COUNT_KEY);
106-
Configuration.addDeprecation(DEPRECATED_BUFFER_SIZE_KEY, BUFFER_SIZE_KEY);
107-
}
108-
10995
/**
11096
* There're some reasons why better to choose 65KB(rather than 64KB) as the default buffer size:
11197
* <p>

hbase-common/src/main/java/org/apache/hadoop/hbase/util/DNS.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ public final class DNS {
5959
} catch (Exception e) {
6060
HAS_NEW_DNS_GET_DEFAULT_HOST_API = false; // FindBugs: Causes REC_CATCH_EXCEPTION. Suppressed
6161
}
62-
Configuration.addDeprecation(RS_HOSTNAME_KEY, UNSAFE_RS_HOSTNAME_KEY);
6362
}
6463

6564
public enum ServerType {

hbase-common/src/test/java/org/apache/hadoop/hbase/TestHBaseConfiguration.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,23 @@ public void testGetConfigOfShortcircuitRead() throws Exception {
133133
assertEquals("/var/lib/hadoop-hdfs/dn_socket", conf.get("dfs.domain.socket.path"));
134134
}
135135

136+
@Test
137+
public void testDeprecatedConfigurations() {
138+
// when addDeprecations before create Configuration object,
139+
Configuration.addDeprecations(new Configuration.DeprecationDelta[]{
140+
new Configuration.DeprecationDelta("hbase.deprecated.conf", "hbase.new.conf")
141+
});
142+
Configuration conf = HBaseConfiguration.create();
143+
conf.addResource("hbase-deprecated-conf.xml");
144+
assertEquals("1000", conf.get("hbase.new.conf"));
145+
146+
//
147+
Configuration.addDeprecations(new Configuration.DeprecationDelta[]{
148+
new Configuration.DeprecationDelta("hbase.deprecated.conf2", "hbase.new.conf2")
149+
});
150+
assertNull(conf.get("hbase.new.conf2"));
151+
}
152+
136153
private static class ReflectiveCredentialProviderClient {
137154
public static final String HADOOP_CRED_PROVIDER_FACTORY_CLASS_NAME =
138155
"org.apache.hadoop.security.alias.JavaKeyStoreProvider$Factory";
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0"?>
2+
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
3+
<!--
4+
/**
5+
* Licensed to the Apache Software Foundation (ASF) under one
6+
* or more contributor license agreements. See the NOTICE file
7+
* distributed with this work for additional information
8+
* regarding copyright ownership. The ASF licenses this file
9+
* to you under the Apache License, Version 2.0 (the
10+
* "License"); you may not use this file except in compliance
11+
* with the License. You may obtain a copy of the License at
12+
*
13+
* http://www.apache.org/licenses/LICENSE-2.0
14+
*
15+
* Unless required by applicable law or agreed to in writing, software
16+
* distributed under the License is distributed on an "AS IS" BASIS,
17+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
* See the License for the specific language governing permissions and
19+
* limitations under the License.
20+
*/
21+
-->
22+
23+
<configuration>
24+
<property>
25+
<name>hbase.deprecated.conf</name>
26+
<value>1000</value>
27+
</property>
28+
29+
<property>
30+
<name>hbase.deprecated.conf2</name>
31+
<value>1000</value>
32+
</property>
33+
</configuration>

hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/WALPlayer.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,6 @@ public class WALPlayer extends Configured implements Tool {
8282

8383
protected static final String tableSeparator = ";";
8484

85-
// This relies on Hadoop Configuration to handle warning about deprecated configs and
86-
// to set the correct non-deprecated configs when an old one shows up.
87-
static {
88-
Configuration.addDeprecation("hlog.bulk.output", BULK_OUTPUT_CONF_KEY);
89-
Configuration.addDeprecation("hlog.input.tables", TABLES_KEY);
90-
Configuration.addDeprecation("hlog.input.tablesmap", TABLE_MAP_KEY);
91-
}
92-
9385
private final static String JOB_NAME_CONF_KEY = "mapreduce.job.name";
9486

9587
public WALPlayer() {

hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/BlockCacheFactory.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,6 @@ public final class BlockCacheFactory {
9292
@Deprecated
9393
static final String DEPRECATED_BLOCKCACHE_BLOCKSIZE_KEY = "hbase.offheapcache.minblocksize";
9494

95-
/**
96-
* The config point hbase.offheapcache.minblocksize is completely wrong, which is replaced by
97-
* {@link BlockCacheFactory#BLOCKCACHE_BLOCKSIZE_KEY}. Keep the old config key here for backward
98-
* compatibility.
99-
*/
100-
static {
101-
Configuration.addDeprecation(DEPRECATED_BLOCKCACHE_BLOCKSIZE_KEY, BLOCKCACHE_BLOCKSIZE_KEY);
102-
}
103-
10495
private BlockCacheFactory() {
10596
}
10697

hbase-server/src/main/java/org/apache/hadoop/hbase/mob/MobFileCleanerChore.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,6 @@ public class MobFileCleanerChore extends ScheduledChore {
6565
private final HMaster master;
6666
private ExpiredMobFileCleaner cleaner;
6767

68-
static {
69-
Configuration.addDeprecation(MobConstants.DEPRECATED_MOB_CLEANER_PERIOD,
70-
MobConstants.MOB_CLEANER_PERIOD);
71-
}
72-
7368
public MobFileCleanerChore(HMaster master) {
7469
super(master.getServerName() + "-MobFileCleanerChore", master,
7570
master.getConfiguration().getInt(MobConstants.MOB_CLEANER_PERIOD,

hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -487,15 +487,6 @@ public class HRegionServer extends Thread implements
487487
final static String UNSAFE_RS_HOSTNAME_DISABLE_MASTER_REVERSEDNS_KEY =
488488
"hbase.unsafe.regionserver.hostname.disable.master.reversedns";
489489

490-
/**
491-
* HBASE-24667: This config hbase.regionserver.hostname.disable.master.reversedns will be replaced by
492-
* hbase.unsafe.regionserver.hostname.disable.master.reversedns. Keep the old config keys here for backward
493-
* compatibility.
494-
*/
495-
static {
496-
Configuration.addDeprecation(RS_HOSTNAME_DISABLE_MASTER_REVERSEDNS_KEY, UNSAFE_RS_HOSTNAME_DISABLE_MASTER_REVERSEDNS_KEY);
497-
}
498-
499490
/**
500491
* This servers startcode.
501492
*/

0 commit comments

Comments
 (0)