Skip to content

Commit

Permalink
HBASE-25861 Correct the usage of Configuration#addDeprecation (#3249)
Browse files Browse the repository at this point in the history
Co-authored-by: Baiqiang Zhao <[email protected]>
Signed-off-by: Nick Dimiduk <[email protected]>
  • Loading branch information
ndimiduk and ZhaoBQ authored May 18, 2021
1 parent 8110b18 commit aab6e1d
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
public class HBaseConfiguration extends Configuration {
private static final Logger LOG = LoggerFactory.getLogger(HBaseConfiguration.class);

static {
addDeprecatedKeys();
}

/**
* Instantiating HBaseConfiguration() is deprecated. Please use
* HBaseConfiguration#create() to construct a plain Configuration
Expand Down Expand Up @@ -77,6 +81,37 @@ private static void checkDefaultsVersion(Configuration conf) {
}
}

/**
* 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")
});
}

public static Configuration addHbaseResources(Configuration conf) {
conf.addResource("hbase-default.xml");
conf.addResource("hbase-site.xml");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,20 +96,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>
Expand Down Expand Up @@ -167,13 +153,6 @@ public interface Recycler {
* @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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,23 @@ public void testGetConfigOfShortcircuitRead() throws Exception {
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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

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;
Expand Down Expand Up @@ -345,7 +346,7 @@ private void assertException(Runnable r) {

@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);
Expand Down
33 changes: 33 additions & 0 deletions hbase-common/src/test/resources/hbase-deprecated-conf.xml
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,6 @@ public class WALPlayer extends Configured implements Tool {
public final static String IGNORE_MISSING_FILES = "wal.input.ignore.missing.files";


// 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(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -492,15 +492,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.
*/
Expand Down
6 changes: 0 additions & 6 deletions src/main/asciidoc/_chapters/offheap_read_write.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit aab6e1d

Please sign in to comment.