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
|
||||
|
||||
HADOOP-9686. Easy access to final parameters in Configuration (Jason Lowe
|
||||
via jeagles)
|
||||
|
||||
OPTIMIZATIONS
|
||||
|
||||
BUG FIXES
|
||||
|
|
|
@ -1918,6 +1918,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();
|
||||
|
|
|
@ -1272,7 +1272,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