Provides access to configuration parameters.
Resources
Configurations are specified by resources. A resource contains a set of name/value pairs as XML data. Each resource is named by either a String
or by a {@link Path}. If named by a String
, then the classpath is examined for a file with that name. If named by a Path
, then the local filesystem is examined directly, without referring to the classpath.
Unless explicitly turned off, Hadoop by default specifies two resources, loaded in-order from the classpath:
- core-default.xml : Read-only defaults for hadoop.
- core-site.xml: Site-specific configuration for a given hadoop installation.
Applications may add additional resources, which are loaded subsequent to these resources in the order they are added.
Final Parameters
Configuration parameters may be declared final. Once a resource declares a value final, no subsequently-loaded resource can alter that value. For example, one might define a final parameter with: <property> <name>dfs.hosts.include</name> <value>/etc/hadoop/conf/hosts.include</value> <final>true</final> </property>
Administrators typically define parameters as final in core-site.xml for values that user applications may not alter.
Variable Expansion
Value strings are first processed for variable expansion. The available properties are:
- Other properties defined in this Configuration; and, if a name is undefined here,
- Properties in {@link System#getProperties()}.
For example, if a configuration resource contains the following property definitions: <property> <name>basedir</name> <value>/user/${user.name}</value> </property> <property> <name>tempdir</name> <value>${basedir}/tmp</value> </property>
When conf.get("tempdir") is called, then ${basedir} will be resolved to another property in this Configuration, while ${user.name} would then ordinarily be resolved to the value of the System property with that name.