org.apache.hadoop.conf.configuration:
1、初始化调用,一般来说都是调用的无参构造函数,无参构造默认是加在default的配置,除非是传入boolean参数为false,表示不加在default的配置。
/** A new configuration. */ public Configuration() { this(true); }
2、默认资源的加在顺序是首先在加载core-default.xml,然后加载addDefaultResource("core-site.xml");如果在当前环境中还有hadoop-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"); }
3、添加配置资源的方重写了4种,列出来public void addResource(String name) { addResourceObject(name); } public void addResource(URL url) { addResourceObject(url); } public void addResource(Path file) { addResourceObject(file); } public void addResource(InputStream in) { addResourceObject(in); }