HBASE-25861 Correct the usage of Configuration#addDeprecation (#3249)
Signed-off-by: Nick Dimiduk <ndimiduk@apache.org>
This commit is contained in:
parent
f6c3ecacdc
commit
d69d5c24b1
|
@ -36,6 +36,10 @@ import org.slf4j.LoggerFactory;
|
|||
public class HBaseConfiguration extends Configuration {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(HBaseConfiguration.class);
|
||||
|
||||
static {
|
||||
addDeprecatedKeys();
|
||||
}
|
||||
|
||||
private static void checkDefaultsVersion(Configuration conf) {
|
||||
if (conf.getBoolean("hbase.defaults.for.version.skip", Boolean.FALSE)) return;
|
||||
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) {
|
||||
conf.addResource("hbase-default.xml");
|
||||
conf.addResource("hbase-site.xml");
|
||||
|
|
|
@ -92,20 +92,6 @@ public class ByteBuffAllocator {
|
|||
@Deprecated
|
||||
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:
|
||||
* <p>
|
||||
|
@ -163,13 +149,6 @@ public class ByteBuffAllocator {
|
|||
* @return ByteBuffAllocator to manage the byte buffers.
|
||||
*/
|
||||
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);
|
||||
if (reservoirEnabled) {
|
||||
// The max number of buffers to be pooled in the ByteBufferPool. The default value been
|
||||
|
|
|
@ -59,7 +59,6 @@ public final class DNS {
|
|||
} catch (Exception e) {
|
||||
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 {
|
||||
|
|
|
@ -133,6 +133,23 @@ public class TestHBaseConfiguration {
|
|||
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 {
|
||||
public static final String HADOOP_CRED_PROVIDER_FACTORY_CLASS_NAME =
|
||||
"org.apache.hadoop.security.alias.JavaKeyStoreProvider$Factory";
|
||||
|
|
|
@ -29,6 +29,7 @@ import java.nio.ByteBuffer;
|
|||
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
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.MultiByteBuff;
|
||||
import org.apache.hadoop.hbase.nio.SingleByteBuff;
|
||||
|
@ -345,7 +346,7 @@ public class TestByteBuffAllocator {
|
|||
|
||||
@Test
|
||||
public void testDeprecatedConfigs() {
|
||||
Configuration conf = new Configuration();
|
||||
Configuration conf = HBaseConfiguration.create();
|
||||
conf.setInt(ByteBuffAllocator.DEPRECATED_MAX_BUFFER_COUNT_KEY, 10);
|
||||
conf.setInt(ByteBuffAllocator.DEPRECATED_BUFFER_SIZE_KEY, 1024);
|
||||
ByteBuffAllocator allocator = ByteBuffAllocator.create(conf, true);
|
||||
|
|
|
@ -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>
|
|
@ -82,14 +82,6 @@ public class WALPlayer extends Configured implements Tool {
|
|||
|
||||
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";
|
||||
|
||||
public WALPlayer() {
|
||||
|
|
|
@ -92,24 +92,10 @@ public final class BlockCacheFactory {
|
|||
@Deprecated
|
||||
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() {
|
||||
}
|
||||
|
||||
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);
|
||||
if (l1Cache == null) {
|
||||
return null;
|
||||
|
|
|
@ -65,11 +65,6 @@ public class MobFileCleanerChore extends ScheduledChore {
|
|||
private final HMaster master;
|
||||
private ExpiredMobFileCleaner cleaner;
|
||||
|
||||
static {
|
||||
Configuration.addDeprecation(MobConstants.DEPRECATED_MOB_CLEANER_PERIOD,
|
||||
MobConstants.MOB_CLEANER_PERIOD);
|
||||
}
|
||||
|
||||
public MobFileCleanerChore(HMaster master) {
|
||||
super(master.getServerName() + "-MobFileCleanerChore", master,
|
||||
master.getConfiguration().getInt(MobConstants.MOB_CLEANER_PERIOD,
|
||||
|
|
|
@ -487,15 +487,6 @@ public class HRegionServer extends Thread implements
|
|||
final static String UNSAFE_RS_HOSTNAME_DISABLE_MASTER_REVERSEDNS_KEY =
|
||||
"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.
|
||||
*/
|
||||
|
|
|
@ -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
|
||||
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`.
|
||||
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.
|
||||
|
||||
|
|
Loading…
Reference in New Issue