You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by GitBox <gi...@apache.org> on 2021/05/06 04:43:25 UTC
[GitHub] [hbase] ZhaoBQ commented on pull request #3139: HBASE-25745 Deprecate/Rename config `hbase.normalizer.min.region.coun…
ZhaoBQ commented on pull request #3139:
URL: https://github.com/apache/hbase/pull/3139#issuecomment-833219457
Here is my test for Configuration.addDeprecation().
Suppose we define the following configuration:
hbase-site.xml: <property><name>deprecate.conf</name><value>99</value></property>
hbase-default.xml: <property><name>new.conf</name><value>42</value></property>
Test 1, create a Configuration object first:
`
public class TestConfiguration {
@Deprecated
static final String DEPRECATED_KEY = "deprecate.conf";
static final String NEW_KEY = "new.conf";
public static void main(String[] args) {
Configuration conf = HBaseConfiguration.create();
System.out.println(conf.get(DEPRECATED_KEY)); // 99
System.out.println(conf.get(NEW_KEY)); // 42
Configuration.addDeprecation(DEPRECATED_KEY, NEW_KEY);
System.out.println(conf.get(DEPRECATED_KEY)); // 42
System.out.println(conf.get(NEW_KEY)); // 42
conf.set(DEPRECATED_KEY, "120");
System.out.println(conf.get(DEPRECATED_KEY)); //120
System.out.println(conf.get(NEW_KEY)); // 120
conf.set(NEW_KEY, "150");
System.out.println(conf.get(DEPRECATED_KEY)); // 150
System.out.println(conf.get(NEW_KEY)); //150
}
}
`
Test 2, call Configuration.addDeprecation() first:
`
public class TestConfiguration {
@Deprecated
static final String DEPRECATED_KEY = "deprecate.conf";
static final String NEW_KEY = "new.conf";
public static void main(String[] args) {
Configuration.addDeprecation(DEPRECATED_KEY, NEW_KEY);
Configuration conf = HBaseConfiguration.create();
System.out.println(conf.get(DEPRECATED_KEY)); // 99
System.out.println(conf.get(NEW_KEY)); // 99
conf.set(DEPRECATED_KEY, "120");
System.out.println(conf.get(DEPRECATED_KEY)); // 120
System.out.println(conf.get(NEW_KEY)); // 120
conf.set(NEW_KEY, "150");
System.out.println(conf.get(DEPRECATED_KEY)); // 150
System.out.println(conf.get(NEW_KEY)); //150
}
}
Test 2 is what I expected, even if the deprecated configuration in the configuration file is not changed to a new configuration, it can still run correctly. But we should call Configuration.addDeprecation before create configuration object.
`
Test 3, hbase-default.xml is empty, and hbase-site.xml has:<property><name>deprecate.conf</name><value>99</value></property> <property><name>new.conf</name><value>42</value></property>
`
public static void main(String[] args) {
Configuration.addDeprecation(DEPRECATED_KEY, NEW_KEY);
Configuration conf = HBaseConfiguration.create();
System.out.println(conf.get(DEPRECATED_KEY)); // 42
System.out.println(conf.get(NEW_KEY)); // 42
conf.set(DEPRECATED_KEY, "120");
System.out.println(conf.get(DEPRECATED_KEY)); // 120
System.out.println(conf.get(NEW_KEY)); // 120
conf.set(NEW_KEY, "150");
System.out.println(conf.get(DEPRECATED_KEY)); // 150
System.out.println(conf.get(NEW_KEY)); // 150
}
`
Then change the order of deprecate.conf and new.conf in hbase-site.xml: <property><name>new.conf</name><value>42</value></property> <property><name>deprecate.conf</name><value>99</value></property>
`
public static void main(String[] args) {
Configuration.addDeprecation(DEPRECATED_KEY, NEW_KEY);
Configuration conf = HBaseConfiguration.create();
System.out.println(conf.get(DEPRECATED_KEY)); // 99
System.out.println(conf.get(NEW_KEY)); // 99
conf.set(DEPRECATED_KEY, "120");
System.out.println(conf.get(DEPRECATED_KEY)); // 120
System.out.println(conf.get(NEW_KEY)); // 120
conf.set(NEW_KEY, "150");
System.out.println(conf.get(DEPRECATED_KEY)); // 150
System.out.println(conf.get(NEW_KEY)); // 150
}
`
The user should not configure the deprecated and new configuration at the same time, so Test3 and Test4 can be ignored.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org