HADOOP-14213. Move Configuration runtime check for hadoop-site.xml to initialization. Contributed by Jonathan Eagles

This commit is contained in:
Ravi Prakash 2017-03-23 09:28:10 -07:00
parent a5a4867f3b
commit 595f62e362
1 changed files with 8 additions and 10 deletions

View File

@ -668,21 +668,24 @@ private void handleDeprecation() {
} }
} }
static{ static {
//print deprecation warning if hadoop-site.xml is found in classpath // Add default resources
addDefaultResource("core-default.xml");
addDefaultResource("core-site.xml");
// print deprecation warning if hadoop-site.xml is found in classpath
ClassLoader cL = Thread.currentThread().getContextClassLoader(); ClassLoader cL = Thread.currentThread().getContextClassLoader();
if (cL == null) { if (cL == null) {
cL = Configuration.class.getClassLoader(); cL = Configuration.class.getClassLoader();
} }
if(cL.getResource("hadoop-site.xml")!=null) { if (cL.getResource("hadoop-site.xml") != null) {
LOG.warn("DEPRECATED: hadoop-site.xml found in the classpath. " + LOG.warn("DEPRECATED: hadoop-site.xml found in the classpath. " +
"Usage of hadoop-site.xml is deprecated. Instead use core-site.xml, " "Usage of hadoop-site.xml is deprecated. Instead use core-site.xml, "
+ "mapred-site.xml and hdfs-site.xml to override properties of " + + "mapred-site.xml and hdfs-site.xml to override properties of " +
"core-default.xml, mapred-default.xml and hdfs-default.xml " + "core-default.xml, mapred-default.xml and hdfs-default.xml " +
"respectively"); "respectively");
addDefaultResource("hadoop-site.xml");
} }
addDefaultResource("core-default.xml");
addDefaultResource("core-site.xml");
} }
private Properties properties; private Properties properties;
@ -2638,11 +2641,6 @@ private void loadResources(Properties properties,
for (String resource : defaultResources) { for (String resource : defaultResources) {
loadResource(properties, new Resource(resource), quiet); loadResource(properties, new Resource(resource), quiet);
} }
//support the hadoop-site.xml as a deprecated case
if(getResource("hadoop-site.xml")!=null) {
loadResource(properties, new Resource("hadoop-site.xml"), quiet);
}
} }
for (int i = 0; i < resources.size(); i++) { for (int i = 0; i < resources.size(); i++) {