Configuration of system parameters. html
主要做用爲配置系統參數 java
Interface Summary apache |
|
Configurable api |
Something that may be configured with a Configuration. app |
Class Summary less |
|
Configuration ide |
Provides access to configuration parameters. oop |
A class that represents a set of positive integer ranges. ui |
|
Base class for things that may be configured with a Configuration. |
org.apache.hadoop.conf
Interface Configurable
All Known Subinterfaces:
SequenceFileInputFilter.Filter, Tool
All Known Implementing Classes:
。。。。
public interface Configurable
Something that may be configured with a Configuration.
getConf() |
|
void |
setConf(Configuration conf) |
org.apache.hadoop.conf
Class Configuration
java.lang.Object
org.apache.hadoop.conf.Configuration
All Implemented Interfaces:
Iterable<Map.Entry<String,String>>, Writable
Direct Known Subclasses:
public class Configuration
extends Object
implements Iterable<Map.Entry<String,String>>, Writable
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 aStringor by a Path. If named by aString, then the classpath is examined for a file with that name. If named by aPath, then the local filesystem is examined directly, without referring to the classpath.
Configuration須要指定資源,資源文件包含一系列鍵值對在xml文件中。每一個資源文件名稱爲字符串或路徑。若是爲字符串,設置環境變量中查找文件名稱。若是名稱爲路徑,直接檢測本地文件系統,不參考環境變量
Unless explicitly turned off, Hadoop by default specifies two resources, loaded in-order from the classpath:
除非設置關閉,hadoop默認指定兩個資源文件,加載時按照環境變量設置的順序。
Applications may add additional resources, which are loaded subsequent to these resources in the order they are added.
應用程序能夠加載本身的資源文件,加載時按照資源文件添加順序
Final ParametersConfiguration 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:
Configuration參數能夠聲明爲final,一旦一個資源文件的value值聲明爲final,後來加載的資源文件沒法改變其值(默認後來加載的資源文件會覆蓋相同的以前加載文件的屬性),例以下面例子
<property>
<name>dfs.client.buffer.dir</name>
<value>/tmp/hadoop/dfs/client</value>
<final>true</final>
</property>
Administrators typically define parameters as final incore-site.xmlfor values that user applications may not alter.
管理員能夠定義參數final在core-site.xml中值,應用程序沒法改變它
Variable ExpansionValue strings are first processed for variable expansion. The available properties are:
值字符串第一次爲可擴展變量,有效屬性爲
其餘屬性定義在這個配置中,並且名稱沒有在這裏定義
屬性經過System.getProerties()設定
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>
Whenconf.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.
當調用conf.get(「tempdir」),這是${basedir}將會解析爲另外一個屬性對於本次配置,然而${user.name}經常被根據名字系統設置的值
static class |
Configuration.IntegerRanges |
Constructor Summary |
|
Configuration() |
|
Configuration(boolean loadDefaults) |
|
Configuration(Configuration other) |
|
Method Summary |
||
static void |
addDefaultResource(String name) |
|
void |
addResource(InputStream in) |
|
void |
addResource(Path file) |
|
void |
addResource(String name) |
|
void |
addResource(URL url) |
|
void |
clear() |
|
get(String name) |
||
get(String name, String defaultValue) |
||
boolean |
getBoolean(String name, boolean defaultValue) |
|
Class<?> |
getClass(String name, Class<?> defaultValue) |
|
|
getClass(String name, Class<? extends U> defaultValue, Class<U> xface) |
|
Class<?> |
getClassByName(String name) |
|
Class<?>[] |
getClasses(String name, Class<?>... defaultValue) |
|
getClassLoader() |
||
getConfResourceAsInputStream(String name) |
||
getConfResourceAsReader(String name) |
||
getFile(String dirsProp, String path) |
||
float |
getFloat(String name, float defaultValue) |
|
int |
getInt(String name, int defaultValue) |
|
getLocalPath(String dirsProp, String path) |
||
long |
getLong(String name, long defaultValue) |
|
getRange(String name, String defaultValue) |
||
getRaw(String name) |
||
getResource(String name) |
||
getStringCollection(String name) |
||
String[] |
getStrings(String name) |
|
String[] |
getStrings(String name, String... defaultValue) |
|
iterator() |
||
static void |
||
void |
readFields(DataInput in) |
|
void |
reloadConfiguration() |
|
void |
set(String name, String value) |
|
void |
setBoolean(String name, boolean value) |
|
void |
setBooleanIfUnset(String name, boolean value) |
|
void |
setClass(String name, Class<?> theClass, Class<?> xface) |
|
void |
setClassLoader(ClassLoader classLoader) |
|
void |
setFloat(String name, float value) |
|
void |
setIfUnset(String name, String value) |
|
void |
setInt(String name, int value) |
|
void |
setLong(String name, long value) |
|
void |
setQuietMode(boolean quietmode) |
|
void |
setStrings(String name, String... values) |
|
int |
size() |
|
toString() |
||
void |
write(DataOutput out) |
|
void |
writeXml(OutputStream out) |
java.lang.Object
org.apache.hadoop.conf.Configured
All Implemented Interfaces:
Direct Known Subclasses:
。。。。
public class Configured
extends Object
implements Configurable
Base class for things that may be configured with a Configuration.
Constructor Summary |
|
Configured() |
|
Configured(Configuration conf) |
|
Method Summary |
|
getConf() |
|
void |
setConf(Configuration conf) |
同Configurable很類似是Configurable的實現類。瞭解很少
java.lang.Object
org.apache.hadoop.conf.Configuration.IntegerRanges
Enclosing class:(就是爲下面類的內部類,也即嵌套類)
public static class Configuration.IntegerRanges
extends Object
A class that represents a set of positive integer ranges. It parses strings of the form: "2-3,5,7-" where ranges are separated by comma and the lower/upper bounds are separated by dash. Either the lower or upper bound may be omitted meaning all values up to or over. So the string above means 2, 3, 5, and 7, 8, 9, ...
一個類表示了一系列肯定的整數範圍,它解析字符串表單「2-3,5,7-」逗號分隔範圍,邊界用-分隔。若是其中一個邊界省略沒有寫那麼表明沒有限制。上面例子解析爲
2, 3, 5, and 7, 8, 9, ..
Constructor Summary |
|
|
|
Configuration.IntegerRanges(String newValue) |
|
Method Summary |
|
boolean |
isIncluded(int value) |
toString() |
體會。
Configurable:實現這個接口的類,成爲可配置的,能夠讀取配置文件,進行控制
能夠這樣理解你想指定,參數,指定配置,應該讓它實現Configurable接口
Configuration:此類具體讀取和設置配置信息、
讀取和配置文件的具體操做類,當從哪一個xml文件讀取和設置時應該用到它。
xml文件中沒有保存類型(type)信息,即屬性再被讀取的時候,能夠被解釋爲指定的類型。
Configuration.IntegerRanges:爲內部類,定義了整數範圍。
爲Configuration提供服務,內部提供整數範圍,測試是否包含在範圍中