List of usage examples for org.apache.commons.configuration CompositeConfiguration CompositeConfiguration
public CompositeConfiguration()
From source file:org.apache.whirr.ClusterSpec.java
private Configuration composeWithDefaults(Configuration userConfig) throws ConfigurationException { CompositeConfiguration composed = new CompositeConfiguration(); composed.addConfiguration(userConfig); composed.addConfiguration(/*from w w w . ja va 2 s . c o m*/ new PropertiesConfiguration(getClass().getClassLoader().getResource(DEFAULT_PROPERTIES))); return composed; }
From source file:org.apache.whirr.ClusterSpecTest.java
@Test public void testApplySubroleAliases() throws ConfigurationException { CompositeConfiguration c = new CompositeConfiguration(); Configuration config = new PropertiesConfiguration(); config.addProperty("whirr.instance-templates", "1 puppet:somepup::pet+something-else, 1 something-else-only"); c.addConfiguration(config);//from w w w. j a v a 2 s . c o m InstanceTemplate template = InstanceTemplate.parse(c).get(0); Set<String> expected = Sets .newLinkedHashSet(Arrays.asList(new String[] { "puppet:somepup::pet", "something-else" })); assertThat(template.getRoles(), is(expected)); InstanceTemplate template2 = InstanceTemplate.parse(c).get(1); Set<String> expected2 = Sets.newLinkedHashSet(Arrays.asList(new String[] { "something-else-only" })); assertThat(template2.getRoles(), is(expected2)); }
From source file:org.apache.whirr.command.AbstractClusterCommand.java
/** * Load the cluster spec by parsing the command line option set *///from w w w . ja v a 2 s .c o m protected ClusterSpec getClusterSpec(OptionSet optionSet) throws ConfigurationException { Configuration optionsConfig = new PropertiesConfiguration(); for (Map.Entry<Property, OptionSpec<?>> entry : optionSpecs.entrySet()) { Property property = entry.getKey(); OptionSpec<?> option = entry.getValue(); Object value; if (property.hasMultipleArguments()) { value = optionSet.valuesOf(option); } else { value = optionSet.valueOf(option); } if (value != null) { optionsConfig.setProperty(property.getConfigName(), value); } } CompositeConfiguration config = new CompositeConfiguration(); config.addConfiguration(optionsConfig); if (optionSet.has(configOption)) { Configuration defaults = new PropertiesConfiguration(optionSet.valueOf(configOption)); config.addConfiguration(defaults); } ClusterSpec clusterSpec = new ClusterSpec(config); for (Property required : EnumSet.of(CLUSTER_NAME, PROVIDER, IDENTITY, CREDENTIAL, INSTANCE_TEMPLATES, PRIVATE_KEY_FILE)) { if (clusterSpec.getConfiguration().getString(required.getConfigName()) == null) { throw new IllegalArgumentException(String.format("Option '%s' not set.", required.getSimpleName())); } } return clusterSpec; }
From source file:org.apache.whirr.compute.BootstrapTemplateTest.java
private ClusterSpec buildClusterSpecWith(Map<String, String> overrides) throws Exception { CompositeConfiguration config = new CompositeConfiguration(); config.setProperty("whirr.image-id", "us-east-1/ami-123"); for (String key : overrides.keySet()) { config.setProperty(key, overrides.get(key)); }// www . ja v a2s .c om return ClusterSpec.withTemporaryKeys(config); }
From source file:org.apache.whirr.service.accumulo.AccumuloConfigurationBuilder.java
private static Configuration build(ClusterSpec clusterSpec, Cluster cluster, Configuration defaults, String prefix) throws ConfigurationException { CompositeConfiguration config = new CompositeConfiguration(); Configuration sub = clusterSpec.getConfigurationForKeysWithPrefix(prefix); config.addConfiguration(sub.subset(prefix)); // remove prefix config.addConfiguration(defaults.subset(prefix)); return config; }
From source file:org.apache.whirr.service.cassandra.integration.CassandraServiceTest.java
@Before public void setUp() throws Exception { CompositeConfiguration config = new CompositeConfiguration(); if (System.getProperty("config") != null) { config.addConfiguration(new PropertiesConfiguration(System.getProperty("config"))); }//from w w w . j a va 2 s .c om config.addConfiguration(new PropertiesConfiguration("whirr-cassandra-test.properties")); clusterSpec = ClusterSpec.withTemporaryKeys(config); controller = new ClusterController(); cluster = controller.launchCluster(clusterSpec); waitForCassandra(); }
From source file:org.apache.whirr.service.cdh.integration.Cdh3HadoopServiceTest.java
@BeforeClass public static void setUp() throws Exception { CompositeConfiguration config = new CompositeConfiguration(); if (System.getProperty("config") != null) { config.addConfiguration(new PropertiesConfiguration(System.getProperty("config"))); }/*www. j av a2 s .c om*/ config.addConfiguration(new PropertiesConfiguration(getPropertiesFilename())); clusterSpec = ClusterSpec.withTemporaryKeys(config); controller = new ClusterController(); cluster = controller.launchCluster(clusterSpec); proxy = new HadoopProxy(clusterSpec, cluster); proxy.start(); }
From source file:org.apache.whirr.service.cdh.integration.Cdh3ZooKeeperServiceTest.java
@Before public void setUp() throws Exception { CompositeConfiguration config = new CompositeConfiguration(); if (System.getProperty("config") != null) { config.addConfiguration(new PropertiesConfiguration(System.getProperty("config"))); }//w w w . j a v a2 s.co m config.addConfiguration(new PropertiesConfiguration("whirr-zookeeper-cdh3-test.properties")); clusterSpec = ClusterSpec.withTemporaryKeys(config); controller = new ClusterController(); cluster = controller.launchCluster(clusterSpec); hosts = ZooKeeperCluster.getHosts(cluster); }
From source file:org.apache.whirr.service.cdh.integration.CdhZooKeeperServiceTest.java
@Before public void setUp() throws Exception { CompositeConfiguration config = new CompositeConfiguration(); if (System.getProperty("config") != null) { config.addConfiguration(new PropertiesConfiguration(System.getProperty("config"))); }/*from w w w .j av a2 s .c o m*/ config.addConfiguration(new PropertiesConfiguration("whirr-zookeeper-cdh-test.properties")); clusterSpec = ClusterSpec.withTemporaryKeys(config); controller = new ClusterController(); cluster = controller.launchCluster(clusterSpec); hosts = ZooKeeperCluster.getHosts(cluster); }
From source file:org.apache.whirr.service.chef.integration.ChefServiceTest.java
@BeforeClass public static void setUp() throws Exception { CompositeConfiguration config = new CompositeConfiguration(); if (System.getProperty("config") != null) { config.addConfiguration(new PropertiesConfiguration(System.getProperty("config"))); }//from w w w .j ava 2 s . c o m config.addConfiguration(new PropertiesConfiguration("whirr-chef-test.properties")); clusterSpec = ClusterSpec.withTemporaryKeys(config); controller = new ClusterController(); controller.launchCluster(clusterSpec); }