HADOOP-9686. Easy access to final parameters in Configuration (Jason Lowe via jeagles)
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1515984 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b7a6c5ebb4
commit
2cd6064195
@ -2074,6 +2074,9 @@ Release 0.23.10 - UNRELEASED
|
|||||||
|
|
||||||
IMPROVEMENTS
|
IMPROVEMENTS
|
||||||
|
|
||||||
|
HADOOP-9686. Easy access to final parameters in Configuration (Jason Lowe
|
||||||
|
via jeagles)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
BUG FIXES
|
BUG FIXES
|
||||||
|
@ -1918,6 +1918,15 @@ public Reader getConfResourceAsReader(String name) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the set of parameters marked final.
|
||||||
|
*
|
||||||
|
* @return final parameter set.
|
||||||
|
*/
|
||||||
|
public Set<String> getFinalParameters() {
|
||||||
|
return new HashSet<String>(finalParameters);
|
||||||
|
}
|
||||||
|
|
||||||
protected synchronized Properties getProps() {
|
protected synchronized Properties getProps() {
|
||||||
if (properties == null) {
|
if (properties == null) {
|
||||||
properties = new Properties();
|
properties = new Properties();
|
||||||
|
@ -1273,6 +1273,22 @@ public void testGetClassByNameOrNull() throws Exception {
|
|||||||
assertNotNull(clazz);
|
assertNotNull(clazz);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testGetFinalParameters() throws Exception {
|
||||||
|
out=new BufferedWriter(new FileWriter(CONFIG));
|
||||||
|
startConfig();
|
||||||
|
declareProperty("my.var", "x", "x", true);
|
||||||
|
endConfig();
|
||||||
|
Path fileResource = new Path(CONFIG);
|
||||||
|
Configuration conf = new Configuration();
|
||||||
|
Set<String> finalParameters = conf.getFinalParameters();
|
||||||
|
assertFalse("my.var already exists", finalParameters.contains("my.var"));
|
||||||
|
conf.addResource(fileResource);
|
||||||
|
assertEquals("my.var is undefined", "x", conf.get("my.var"));
|
||||||
|
assertFalse("finalparams not copied", finalParameters.contains("my.var"));
|
||||||
|
finalParameters = conf.getFinalParameters();
|
||||||
|
assertTrue("my.var is not final", finalParameters.contains("my.var"));
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String[] argv) throws Exception {
|
public static void main(String[] argv) throws Exception {
|
||||||
junit.textui.TestRunner.main(new String[]{
|
junit.textui.TestRunner.main(new String[]{
|
||||||
TestConfiguration.class.getName()
|
TestConfiguration.class.getName()
|
||||||
|
Loading…
Reference in New Issue
Block a user