HADOOP-8197. Configuration logs WARNs on every use of a deprecated key (tucu)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1303884 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Alejandro Abdelnur 2012-03-22 16:46:48 +00:00
parent 76817c28a2
commit a8ebdaeb08
3 changed files with 11 additions and 11 deletions

View File

@ -260,6 +260,8 @@ Release 0.23.3 - UNRELEASED
HADOOP-8157. Fix race condition in Configuration that could cause spurious HADOOP-8157. Fix race condition in Configuration that could cause spurious
ClassNotFoundExceptions after a GC. (todd) ClassNotFoundExceptions after a GC. (todd)
HADOOP-8197. Configuration logs WARNs on every use of a deprecated key (tucu)
BREAKDOWN OF HADOOP-7454 SUBTASKS BREAKDOWN OF HADOOP-7454 SUBTASKS
HADOOP-7455. HA: Introduce HA Service Protocol Interface. (suresh) HADOOP-7455. HA: Introduce HA Service Protocol Interface. (suresh)

View File

@ -347,9 +347,7 @@ public class Configuration implements Iterable<Map.Entry<String,String>>,
private String handleDeprecation(String name) { private String handleDeprecation(String name) {
if (isDeprecated(name)) { if (isDeprecated(name)) {
DeprecatedKeyInfo keyInfo = deprecatedKeyMap.get(name); DeprecatedKeyInfo keyInfo = deprecatedKeyMap.get(name);
if (!keyInfo.accessed) { warnOnceIfDeprecated(name);
LOG.warn(keyInfo.getWarningMessage(name));
}
for (String newKey : keyInfo.newKeys) { for (String newKey : keyInfo.newKeys) {
if(newKey != null) { if(newKey != null) {
name = newKey; name = newKey;
@ -362,11 +360,6 @@ public class Configuration implements Iterable<Map.Entry<String,String>>,
getOverlay().containsKey(deprecatedKey)) { getOverlay().containsKey(deprecatedKey)) {
getProps().setProperty(name, getOverlay().getProperty(deprecatedKey)); getProps().setProperty(name, getOverlay().getProperty(deprecatedKey));
getOverlay().setProperty(name, getOverlay().getProperty(deprecatedKey)); getOverlay().setProperty(name, getOverlay().getProperty(deprecatedKey));
DeprecatedKeyInfo keyInfo = deprecatedKeyMap.get(deprecatedKey);
if (!keyInfo.accessed) {
LOG.warn(keyInfo.getWarningMessage(deprecatedKey));
}
} }
return name; return name;
} }
@ -662,8 +655,12 @@ public class Configuration implements Iterable<Map.Entry<String,String>>,
getOverlay().setProperty(altName, value); getOverlay().setProperty(altName, value);
getProps().setProperty(altName, value); getProps().setProperty(altName, value);
} }
if (isDeprecated(name)) { warnOnceIfDeprecated(name);
}
private void warnOnceIfDeprecated(String name) {
DeprecatedKeyInfo keyInfo = deprecatedKeyMap.get(name); DeprecatedKeyInfo keyInfo = deprecatedKeyMap.get(name);
if (keyInfo != null && !keyInfo.accessed) {
LOG.warn(keyInfo.getWarningMessage(name)); LOG.warn(keyInfo.getWarningMessage(name));
} }
} }

View File

@ -31,6 +31,7 @@ public class TestDeprecatedKeys extends TestCase {
public void testDeprecatedKeys() throws Exception { public void testDeprecatedKeys() throws Exception {
Configuration conf = new Configuration(); Configuration conf = new Configuration();
conf.set("topology.script.file.name", "xyz"); conf.set("topology.script.file.name", "xyz");
conf.set("topology.script.file.name", "xyz");
String scriptFile = conf.get(CommonConfigurationKeys.NET_TOPOLOGY_SCRIPT_FILE_NAME_KEY); String scriptFile = conf.get(CommonConfigurationKeys.NET_TOPOLOGY_SCRIPT_FILE_NAME_KEY);
assertTrue(scriptFile.equals("xyz")) ; assertTrue(scriptFile.equals("xyz")) ;
} }