diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/HBaseConfiguration.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/HBaseConfiguration.java index 8d8b7accc67..02c36ab4526 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/HBaseConfiguration.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/HBaseConfiguration.java @@ -169,6 +169,32 @@ public class HBaseConfiguration extends Configuration { return isShowConf; } + /** + * Get the value of the name property as an int, possibly referring to + * the deprecated name of the configuration property. If no such property exists, the provided + * default value is returned, or if the specified value is not a valid int, then an + * error is thrown. + * @param name property name. + * @param deprecatedName a deprecatedName for the property to use if non-deprecated name is not + * used + * @param defaultValue default value. + * @throws NumberFormatException when the value is invalid + * @return property value as an int, or defaultValue. + * @deprecated it will be removed in 3.0.0. Use + * {@link Configuration#addDeprecation(String, String)} instead. + */ + @Deprecated + public static int getInt(Configuration conf, String name, + String deprecatedName, int defaultValue) { + if (conf.get(deprecatedName) != null) { + LOG.warn(String.format("Config option \"%s\" is deprecated. Instead, use \"%s\"" + , deprecatedName, name)); + return conf.getInt(deprecatedName, defaultValue); + } else { + return conf.getInt(name, defaultValue); + } + } + /** * Get the password from the Configuration instance using the * getPassword method if it exists. If not, then fall back to the