HBASE-25861 Correct the usage of Configuration#addDeprecation (#3249)

Signed-off-by: Nick Dimiduk <ndimiduk@apache.org>
This commit is contained in:
Baiqiang Zhao 2021-05-15 00:31:06 +08:00 committed by GitHub
parent f6c3ecacdc
commit d69d5c24b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 89 additions and 65 deletions

View File

@ -36,6 +36,10 @@ import org.slf4j.LoggerFactory;
public class HBaseConfiguration extends Configuration { public class HBaseConfiguration extends Configuration {
private static final Logger LOG = LoggerFactory.getLogger(HBaseConfiguration.class); private static final Logger LOG = LoggerFactory.getLogger(HBaseConfiguration.class);
static {
addDeprecatedKeys();
}
private static void checkDefaultsVersion(Configuration conf) { private static void checkDefaultsVersion(Configuration conf) {
if (conf.getBoolean("hbase.defaults.for.version.skip", Boolean.FALSE)) return; if (conf.getBoolean("hbase.defaults.for.version.skip", Boolean.FALSE)) return;
String defaultsVersion = conf.get("hbase.defaults.for.version"); String defaultsVersion = conf.get("hbase.defaults.for.version");
@ -47,6 +51,39 @@ public class HBaseConfiguration extends Configuration {
} }
} }
/**
* The hbase.ipc.server.reservoir.initial.max and hbase.ipc.server.reservoir.initial.buffer.size
* were introduced in HBase2.0.0, while in HBase3.0.0 the two config keys will be replaced by
* hbase.server.allocator.max.buffer.count and hbase.server.allocator.buffer.size.
* Also the hbase.ipc.server.reservoir.enabled will be replaced by
* hbase.server.allocator.pool.enabled. Keep the three old config keys here for HBase2.x
* compatibility.
* <br>
* HBASE-24667: This config hbase.regionserver.hostname.disable.master.reversedns will be
* replaced by hbase.unsafe.regionserver.hostname.disable.master.reversedns. Keep the old config
* keys here for backward compatibility.
*/
private static void addDeprecatedKeys() {
Configuration.addDeprecations(new DeprecationDelta[]{
new DeprecationDelta("hbase.regionserver.hostname", "hbase.unsafe.regionserver.hostname"),
new DeprecationDelta("hbase.regionserver.hostname.disable.master.reversedns",
"hbase.unsafe.regionserver.hostname.disable.master.reversedns"),
new DeprecationDelta("hbase.offheapcache.minblocksize",
"hbase.blockcache.minblocksize"),
new DeprecationDelta("hbase.ipc.server.reservoir.enabled",
"hbase.server.allocator.pool.enabled"),
new DeprecationDelta("hbase.ipc.server.reservoir.initial.max",
"hbase.server.allocator.max.buffer.count"),
new DeprecationDelta("hbase.ipc.server.reservoir.initial.buffer.size",
"hbase.server.allocator.buffer.size"),
new DeprecationDelta("hlog.bulk.output", "wal.bulk.output"),
new DeprecationDelta("hlog.input.tables", "wal.input.tables"),
new DeprecationDelta("hlog.input.tablesmap", "wal.input.tablesmap"),
new DeprecationDelta("hbase.master.mob.ttl.cleaner.period",
"hbase.master.mob.cleaner.period")
});
}
public static Configuration addHbaseResources(Configuration conf) { public static Configuration addHbaseResources(Configuration conf) {
conf.addResource("hbase-default.xml"); conf.addResource("hbase-default.xml");
conf.addResource("hbase-site.xml"); conf.addResource("hbase-site.xml");

View File

@ -92,20 +92,6 @@ public class ByteBuffAllocator {
@Deprecated @Deprecated
static final String DEPRECATED_BUFFER_SIZE_KEY = "hbase.ipc.server.reservoir.initial.buffer.size"; static final String DEPRECATED_BUFFER_SIZE_KEY = "hbase.ipc.server.reservoir.initial.buffer.size";
/**
* The hbase.ipc.server.reservoir.initial.max and hbase.ipc.server.reservoir.initial.buffer.size
* were introduced in HBase2.0.0, while in HBase3.0.0 the two config keys will be replaced by
* {@link ByteBuffAllocator#MAX_BUFFER_COUNT_KEY} and {@link ByteBuffAllocator#BUFFER_SIZE_KEY}.
* Also the hbase.ipc.server.reservoir.enabled will be replaced by
* hbase.server.allocator.pool.enabled. Keep the three old config keys here for HBase2.x
* compatibility.
*/
static {
Configuration.addDeprecation(DEPRECATED_ALLOCATOR_POOL_ENABLED_KEY, ALLOCATOR_POOL_ENABLED_KEY);
Configuration.addDeprecation(DEPRECATED_MAX_BUFFER_COUNT_KEY, MAX_BUFFER_COUNT_KEY);
Configuration.addDeprecation(DEPRECATED_BUFFER_SIZE_KEY, BUFFER_SIZE_KEY);
}
/** /**
* There're some reasons why better to choose 65KB(rather than 64KB) as the default buffer size: * There're some reasons why better to choose 65KB(rather than 64KB) as the default buffer size:
* <p> * <p>
@ -163,13 +149,6 @@ public class ByteBuffAllocator {
* @return ByteBuffAllocator to manage the byte buffers. * @return ByteBuffAllocator to manage the byte buffers.
*/ */
public static ByteBuffAllocator create(Configuration conf, boolean reservoirEnabled) { public static ByteBuffAllocator create(Configuration conf, boolean reservoirEnabled) {
if (conf.get(DEPRECATED_BUFFER_SIZE_KEY) != null
|| conf.get(DEPRECATED_MAX_BUFFER_COUNT_KEY) != null) {
LOG.warn("The config keys {} and {} are deprecated now, instead please use {} and {}. In "
+ "future release we will remove the two deprecated configs.",
DEPRECATED_BUFFER_SIZE_KEY, DEPRECATED_MAX_BUFFER_COUNT_KEY, BUFFER_SIZE_KEY,
MAX_BUFFER_COUNT_KEY);
}
int poolBufSize = conf.getInt(BUFFER_SIZE_KEY, DEFAULT_BUFFER_SIZE); int poolBufSize = conf.getInt(BUFFER_SIZE_KEY, DEFAULT_BUFFER_SIZE);
if (reservoirEnabled) { if (reservoirEnabled) {
// The max number of buffers to be pooled in the ByteBufferPool. The default value been // The max number of buffers to be pooled in the ByteBufferPool. The default value been

View File

@ -59,7 +59,6 @@ public final class DNS {
} catch (Exception e) { } catch (Exception e) {
HAS_NEW_DNS_GET_DEFAULT_HOST_API = false; // FindBugs: Causes REC_CATCH_EXCEPTION. Suppressed HAS_NEW_DNS_GET_DEFAULT_HOST_API = false; // FindBugs: Causes REC_CATCH_EXCEPTION. Suppressed
} }
Configuration.addDeprecation(RS_HOSTNAME_KEY, UNSAFE_RS_HOSTNAME_KEY);
} }
public enum ServerType { public enum ServerType {

View File

@ -133,6 +133,23 @@ public class TestHBaseConfiguration {
assertEquals("/var/lib/hadoop-hdfs/dn_socket", conf.get("dfs.domain.socket.path")); assertEquals("/var/lib/hadoop-hdfs/dn_socket", conf.get("dfs.domain.socket.path"));
} }
@Test
public void testDeprecatedConfigurations() {
// Configuration.addDeprecations before create Configuration object
Configuration.addDeprecations(new Configuration.DeprecationDelta[]{
new Configuration.DeprecationDelta("hbase.deprecated.conf", "hbase.new.conf")
});
Configuration conf = HBaseConfiguration.create();
conf.addResource("hbase-deprecated-conf.xml");
assertEquals("1000", conf.get("hbase.new.conf"));
// Configuration.addDeprecations after create Configuration object
Configuration.addDeprecations(new Configuration.DeprecationDelta[]{
new Configuration.DeprecationDelta("hbase.deprecated.conf2", "hbase.new.conf2")
});
assertNull(conf.get("hbase.new.conf2"));
}
private static class ReflectiveCredentialProviderClient { private static class ReflectiveCredentialProviderClient {
public static final String HADOOP_CRED_PROVIDER_FACTORY_CLASS_NAME = public static final String HADOOP_CRED_PROVIDER_FACTORY_CLASS_NAME =
"org.apache.hadoop.security.alias.JavaKeyStoreProvider$Factory"; "org.apache.hadoop.security.alias.JavaKeyStoreProvider$Factory";

View File

@ -29,6 +29,7 @@ import java.nio.ByteBuffer;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.nio.ByteBuff; import org.apache.hadoop.hbase.nio.ByteBuff;
import org.apache.hadoop.hbase.nio.MultiByteBuff; import org.apache.hadoop.hbase.nio.MultiByteBuff;
import org.apache.hadoop.hbase.nio.SingleByteBuff; import org.apache.hadoop.hbase.nio.SingleByteBuff;
@ -345,7 +346,7 @@ public class TestByteBuffAllocator {
@Test @Test
public void testDeprecatedConfigs() { public void testDeprecatedConfigs() {
Configuration conf = new Configuration(); Configuration conf = HBaseConfiguration.create();
conf.setInt(ByteBuffAllocator.DEPRECATED_MAX_BUFFER_COUNT_KEY, 10); conf.setInt(ByteBuffAllocator.DEPRECATED_MAX_BUFFER_COUNT_KEY, 10);
conf.setInt(ByteBuffAllocator.DEPRECATED_BUFFER_SIZE_KEY, 1024); conf.setInt(ByteBuffAllocator.DEPRECATED_BUFFER_SIZE_KEY, 1024);
ByteBuffAllocator allocator = ByteBuffAllocator.create(conf, true); ByteBuffAllocator allocator = ByteBuffAllocator.create(conf, true);

View File

@ -0,0 +1,33 @@
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<configuration>
<property>
<name>hbase.deprecated.conf</name>
<value>1000</value>
</property>
<property>
<name>hbase.deprecated.conf2</name>
<value>1000</value>
</property>
</configuration>

View File

@ -82,14 +82,6 @@ public class WALPlayer extends Configured implements Tool {
protected static final String tableSeparator = ";"; protected static final String tableSeparator = ";";
// This relies on Hadoop Configuration to handle warning about deprecated configs and
// to set the correct non-deprecated configs when an old one shows up.
static {
Configuration.addDeprecation("hlog.bulk.output", BULK_OUTPUT_CONF_KEY);
Configuration.addDeprecation("hlog.input.tables", TABLES_KEY);
Configuration.addDeprecation("hlog.input.tablesmap", TABLE_MAP_KEY);
}
private final static String JOB_NAME_CONF_KEY = "mapreduce.job.name"; private final static String JOB_NAME_CONF_KEY = "mapreduce.job.name";
public WALPlayer() { public WALPlayer() {

View File

@ -92,24 +92,10 @@ public final class BlockCacheFactory {
@Deprecated @Deprecated
static final String DEPRECATED_BLOCKCACHE_BLOCKSIZE_KEY = "hbase.offheapcache.minblocksize"; static final String DEPRECATED_BLOCKCACHE_BLOCKSIZE_KEY = "hbase.offheapcache.minblocksize";
/**
* The config point hbase.offheapcache.minblocksize is completely wrong, which is replaced by
* {@link BlockCacheFactory#BLOCKCACHE_BLOCKSIZE_KEY}. Keep the old config key here for backward
* compatibility.
*/
static {
Configuration.addDeprecation(DEPRECATED_BLOCKCACHE_BLOCKSIZE_KEY, BLOCKCACHE_BLOCKSIZE_KEY);
}
private BlockCacheFactory() { private BlockCacheFactory() {
} }
public static BlockCache createBlockCache(Configuration conf) { public static BlockCache createBlockCache(Configuration conf) {
if (conf.get(DEPRECATED_BLOCKCACHE_BLOCKSIZE_KEY) != null) {
LOG.warn("The config key {} is deprecated now, instead please use {}. In future release "
+ "we will remove the deprecated config.", DEPRECATED_BLOCKCACHE_BLOCKSIZE_KEY,
BLOCKCACHE_BLOCKSIZE_KEY);
}
FirstLevelBlockCache l1Cache = createFirstLevelCache(conf); FirstLevelBlockCache l1Cache = createFirstLevelCache(conf);
if (l1Cache == null) { if (l1Cache == null) {
return null; return null;

View File

@ -65,11 +65,6 @@ public class MobFileCleanerChore extends ScheduledChore {
private final HMaster master; private final HMaster master;
private ExpiredMobFileCleaner cleaner; private ExpiredMobFileCleaner cleaner;
static {
Configuration.addDeprecation(MobConstants.DEPRECATED_MOB_CLEANER_PERIOD,
MobConstants.MOB_CLEANER_PERIOD);
}
public MobFileCleanerChore(HMaster master) { public MobFileCleanerChore(HMaster master) {
super(master.getServerName() + "-MobFileCleanerChore", master, super(master.getServerName() + "-MobFileCleanerChore", master,
master.getConfiguration().getInt(MobConstants.MOB_CLEANER_PERIOD, master.getConfiguration().getInt(MobConstants.MOB_CLEANER_PERIOD,

View File

@ -487,15 +487,6 @@ public class HRegionServer extends Thread implements
final static String UNSAFE_RS_HOSTNAME_DISABLE_MASTER_REVERSEDNS_KEY = final static String UNSAFE_RS_HOSTNAME_DISABLE_MASTER_REVERSEDNS_KEY =
"hbase.unsafe.regionserver.hostname.disable.master.reversedns"; "hbase.unsafe.regionserver.hostname.disable.master.reversedns";
/**
* HBASE-24667: This config hbase.regionserver.hostname.disable.master.reversedns will be replaced by
* hbase.unsafe.regionserver.hostname.disable.master.reversedns. Keep the old config keys here for backward
* compatibility.
*/
static {
Configuration.addDeprecation(RS_HOSTNAME_DISABLE_MASTER_REVERSEDNS_KEY, UNSAFE_RS_HOSTNAME_DISABLE_MASTER_REVERSEDNS_KEY);
}
/** /**
* This servers startcode. * This servers startcode.
*/ */

View File

@ -165,12 +165,6 @@ because of link:https://issues.apache.org/jira/browse/HBASE-22532[HBASE-22532].
The three config keys -- `hbase.ipc.server.reservoir.enabled`, `hbase.ipc.server.reservoir.initial.buffer.size` and `hbase.ipc.server.reservoir.initial.max` -- introduced in hbase-2.x The three config keys -- `hbase.ipc.server.reservoir.enabled`, `hbase.ipc.server.reservoir.initial.buffer.size` and `hbase.ipc.server.reservoir.initial.max` -- introduced in hbase-2.x
have been renamed and deprecated in hbase-3.x/hbase-2.3.x. Please use the new config keys instead: have been renamed and deprecated in hbase-3.x/hbase-2.3.x. Please use the new config keys instead:
`hbase.server.allocator.pool.enabled`, `hbase.server.allocator.buffer.size` and `hbase.server.allocator.max.buffer.count`. `hbase.server.allocator.pool.enabled`, `hbase.server.allocator.buffer.size` and `hbase.server.allocator.max.buffer.count`.
If you still use the deprecated three config keys in hbase-3.x, you will get a WARN log message like:
[source]
----
The config keys hbase.ipc.server.reservoir.initial.buffer.size and hbase.ipc.server.reservoir.initial.max are deprecated now, instead please use hbase.server.allocator.buffer.size and hbase.server.allocator.max.buffer.count. In future release we will remove the two deprecated configs.
----
Next, we have some suggestions regards performance. Next, we have some suggestions regards performance.