HADOOP-9686. Easy access to final parameters in Configuration (Jason Lowe via jeagles)
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1516009 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
20b49d292c
commit
017bbeade1
|
@ -1808,6 +1808,9 @@ Release 0.23.10 - UNRELEASED
|
|||
|
||||
IMPROVEMENTS
|
||||
|
||||
HADOOP-9686. Easy access to final parameters in Configuration (Jason Lowe
|
||||
via jeagles)
|
||||
|
||||
OPTIMIZATIONS
|
||||
|
||||
BUG FIXES
|
||||
|
|
|
@ -1910,6 +1910,15 @@ public class Configuration implements Iterable<Map.Entry<String,String>>,
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the set of parameters marked final.
|
||||
*
|
||||
* @return final parameter set.
|
||||
*/
|
||||
public Set<String> getFinalParameters() {
|
||||
return new HashSet<String>(finalParameters);
|
||||
}
|
||||
|
||||
protected synchronized Properties getProps() {
|
||||
if (properties == null) {
|
||||
properties = new Properties();
|
||||
|
|
|
@ -1180,7 +1180,23 @@ public class TestConfiguration extends TestCase {
|
|||
Class<?> clazz = config.getClassByNameOrNull("java.lang.Object");
|
||||
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 {
|
||||
junit.textui.TestRunner.main(new String[]{
|
||||
TestConfiguration.class.getName()
|
||||
|
|
Loading…
Reference in New Issue