Configuration类是用来访问hadoop的配置参数的。
Configuration类首先会通过静态代码段加载hadoop的配置文件core-default.xml和和core-site.xml,相关代码如下:
static{
//print deprecation warning if hadoop-site.xml is found in classpath
ClassLoader cL = Thread.currentThread().getContextClassLoader();
if (cL == null) {
cL = Configuration.class.getClassLoader();
}
if(cL.getResource("hadoop-site.xml")!=null) {
LOG.warn("DEPRECATED: hadoop-site.xml found in the classpath. " +
"Usage of hadoop-site.xml is deprecated. Instead use core-site.xml, "
+ "mapred-site.xml and hdfs-site.xml to override properties of " +
"core-default.xml, mapred-default.xml and hdfs-default.xml " +
"respectively");
}
addDefaultResource("core-default.xml");
addDefaultResource("core-site.xml");
}
defaultResources是一个ArrayList,用来保存默认的配置文件路径。如果一个默认的配置文件路径不在defaultResource里面,就添加进去,这个逻辑是在
addDefaultResource方法中实现的。

本文深入剖析了Hadoop作业提交的过程,包括Configuration类加载配置文件、JobConf设置作业信息、JobClient提交作业的详细步骤,如创建staging目录、分配job id、拷贝文件、设置分区等,揭示了Hadoop作业提交背后的工作原理。
最低0.47元/天 解锁文章
235

被折叠的 条评论
为什么被折叠?



