HADOOP-7993. Hadoop ignores old-style config options for enabling compressed output. (Anupam Seth via mahadev)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1236506 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mahadev Konar 2012-01-27 03:42:36 +00:00
parent c5caed914d
commit c8bb6f59b8
3 changed files with 35 additions and 2 deletions

View File

@ -295,6 +295,9 @@ Release 0.23.1 - Unreleased
HADOOP-7997. SequenceFile.createWriter(...createParent...) no HADOOP-7997. SequenceFile.createWriter(...createParent...) no
longer works on existing file. (Gregory Chanan via eli) longer works on existing file. (Gregory Chanan via eli)
HADOOP-7993. Hadoop ignores old-style config options for enabling compressed
output. (Anupam Seth via mahadev)
Release 0.23.0 - 2011-11-01 Release 0.23.0 - 2011-11-01
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -346,6 +346,16 @@ private String handleDeprecation(String name) {
return name; return name;
} }
private void handleDeprecation() {
LOG.debug("Handling deprecation for all properties in config...");
Set<Object> keys = new HashSet<Object>();
keys.addAll(getProps().keySet());
for (Object item: keys) {
LOG.debug("Handling deprecation for " + (String)item);
handleDeprecation((String)item);
}
}
static{ static{
//print deprecation warning if hadoop-site.xml is found in classpath //print deprecation warning if hadoop-site.xml is found in classpath
ClassLoader cL = Thread.currentThread().getContextClassLoader(); ClassLoader cL = Thread.currentThread().getContextClassLoader();
@ -1667,7 +1677,7 @@ private synchronized Document asXmlDocument() throws IOException {
Element conf = doc.createElement("configuration"); Element conf = doc.createElement("configuration");
doc.appendChild(conf); doc.appendChild(conf);
conf.appendChild(doc.createTextNode("\n")); conf.appendChild(doc.createTextNode("\n"));
getProps(); // ensure properties is set handleDeprecation(); //ensure properties is set and deprecation is handled
for (Enumeration e = properties.keys(); e.hasMoreElements();) { for (Enumeration e = properties.keys(); e.hasMoreElements();) {
String name = (String)e.nextElement(); String name = (String)e.nextElement();
Object object = properties.get(name); Object object = properties.get(name);

View File

@ -18,6 +18,8 @@
package org.apache.hadoop.conf; package org.apache.hadoop.conf;
import java.io.ByteArrayOutputStream;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.CommonConfigurationKeys; import org.apache.hadoop.fs.CommonConfigurationKeys;
@ -32,4 +34,22 @@ public void testDeprecatedKeys() throws Exception {
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")) ;
} }
//Tests reading / writing a conf file with deprecation after setting
public void testReadWriteWithDeprecatedKeys() throws Exception {
Configuration conf = new Configuration();
conf.setBoolean("old.config.yet.to.be.deprecated", true);
Configuration.addDeprecation("old.config.yet.to.be.deprecated",
new String[]{"new.conf.to.replace.deprecated.conf"});
ByteArrayOutputStream out=new ByteArrayOutputStream();
String fileContents;
try {
conf.writeXml(out);
fileContents = out.toString();
} finally {
out.close();
}
assertTrue(fileContents.contains("old.config.yet.to.be.deprecated"));
assertTrue(fileContents.contains("new.conf.to.replace.deprecated.conf"));
}
} }