use of org.apache.commons.configuration.CompositeConfiguration in project distributedlog by twitter.
the class TestConfUtils method testLoadConfiguration.
@Test
public void testLoadConfiguration() {
Configuration conf1 = new CompositeConfiguration();
conf1.setProperty("key1", "value1");
conf1.setProperty("key2", "value2");
conf1.setProperty("key3", "value3");
Configuration conf2 = new CompositeConfiguration();
conf2.setProperty("bkc.key1", "bkc.value1");
conf2.setProperty("bkc.key4", "bkc.value4");
assertEquals("value1", conf1.getString("key1"));
assertEquals("value2", conf1.getString("key2"));
assertEquals("value3", conf1.getString("key3"));
assertEquals(null, conf1.getString("key4"));
ConfUtils.loadConfiguration(conf1, conf2, "bkc.");
assertEquals("bkc.value1", conf1.getString("key1"));
assertEquals("value2", conf1.getString("key2"));
assertEquals("value3", conf1.getString("key3"));
assertEquals("bkc.value4", conf1.getString("key4"));
assertEquals(null, conf1.getString("bkc.key1"));
assertEquals(null, conf1.getString("bkc.key4"));
}
use of org.apache.commons.configuration.CompositeConfiguration in project whirr by apache.
the class GangliaServiceTest method setUp.
@Before
public void setUp() throws Exception {
CompositeConfiguration config = new CompositeConfiguration();
if (System.getProperty("config") != null) {
config.addConfiguration(new PropertiesConfiguration(System.getProperty("config")));
}
config.addConfiguration(new PropertiesConfiguration("whirr-ganglia-test.properties"));
clusterSpec = ClusterSpec.withTemporaryKeys(config);
controller = new ClusterControllerFactory().create(clusterSpec.getServiceName());
cluster = controller.launchCluster(clusterSpec);
}
use of org.apache.commons.configuration.CompositeConfiguration in project whirr by apache.
the class DruidServiceTest method setUp.
@Before
public void setUp() throws Exception {
CompositeConfiguration config = new CompositeConfiguration();
config.addConfiguration(new PropertiesConfiguration("whirr-druid-test.properties"));
if (System.getProperty("config") != null) {
config.addConfiguration(new PropertiesConfiguration(System.getProperty("config")));
}
clusterSpec = ClusterSpec.withTemporaryKeys(config);
controller = new ClusterController();
// controller = new ClusterControllerFactory().create(clusterSpec.getServiceName());
cluster = controller.launchCluster(clusterSpec);
}
use of org.apache.commons.configuration.CompositeConfiguration in project whirr by apache.
the class ElasticSearchConfigurationBuilder method buildConfig.
/**
* Build a configuration by adding the expected defaults
*/
public static Configuration buildConfig(ClusterSpec spec, Cluster cluster) {
CompositeConfiguration config = new CompositeConfiguration();
config.addConfiguration(spec.getConfiguration());
try {
config.addConfiguration(new PropertiesConfiguration(ElasticSearchConfigurationBuilder.class.getResource("/whirr-elasticsearch-default.properties")));
} catch (ConfigurationException e) {
// this should never happen
LOG.error("Configuration error", e);
}
if ("aws-ec2".equals(spec.getProvider()) || "ec2".equals(spec.getProvider())) {
addDefaultsForEC2(spec, config);
} else {
addDefaultsForUnicast(cluster, config);
}
if (!config.containsKey("es.cluster.name")) {
config.addProperty("es.cluster.name", spec.getClusterName());
}
return config;
}
use of org.apache.commons.configuration.CompositeConfiguration in project whirr by apache.
the class HadoopConfigurationBuilder method build.
private static Configuration build(ClusterSpec clusterSpec, Cluster cluster, Configuration defaults, String prefix) throws ConfigurationException {
CompositeConfiguration config = new CompositeConfiguration();
config.setDelimiterParsingDisabled(true);
Configuration sub = clusterSpec.getConfigurationForKeysWithPrefix(prefix);
// remove prefix
config.addConfiguration(sub.subset(prefix));
config.addConfiguration(defaults.subset(prefix));
return config;
}
Aggregations