Search in sources :

Example 21 with CompositeConfiguration

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"));
}
Also used : Configuration(org.apache.commons.configuration.Configuration) CompositeConfiguration(org.apache.commons.configuration.CompositeConfiguration) CompositeConfiguration(org.apache.commons.configuration.CompositeConfiguration) Test(org.junit.Test)

Example 22 with CompositeConfiguration

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);
}
Also used : CompositeConfiguration(org.apache.commons.configuration.CompositeConfiguration) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) ClusterControllerFactory(org.apache.whirr.ClusterControllerFactory) Before(org.junit.Before)

Example 23 with CompositeConfiguration

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);
}
Also used : ClusterController(org.apache.whirr.ClusterController) CompositeConfiguration(org.apache.commons.configuration.CompositeConfiguration) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) Before(org.junit.Before)

Example 24 with CompositeConfiguration

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;
}
Also used : ConfigurationException(org.apache.commons.configuration.ConfigurationException) CompositeConfiguration(org.apache.commons.configuration.CompositeConfiguration) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration)

Example 25 with CompositeConfiguration

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;
}
Also used : Configuration(org.apache.commons.configuration.Configuration) CompositeConfiguration(org.apache.commons.configuration.CompositeConfiguration) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) CompositeConfiguration(org.apache.commons.configuration.CompositeConfiguration)

Aggregations

CompositeConfiguration (org.apache.commons.configuration.CompositeConfiguration)89 PropertiesConfiguration (org.apache.commons.configuration.PropertiesConfiguration)46 Test (org.junit.Test)24 ClusterController (org.apache.whirr.ClusterController)22 Configuration (org.apache.commons.configuration.Configuration)21 File (java.io.File)17 Before (org.junit.Before)11 ForceField (ffx.potential.parameters.ForceField)10 ConfigurationException (org.apache.commons.configuration.ConfigurationException)9 HadoopProxy (org.apache.whirr.service.hadoop.HadoopProxy)9 BeforeClass (org.junit.BeforeClass)9 IOException (java.io.IOException)8 ClusterSpec (org.apache.whirr.ClusterSpec)8 MolecularAssembly (ffx.potential.MolecularAssembly)7 ForceFieldFilter (ffx.potential.parsers.ForceFieldFilter)7 PDBFilter (ffx.potential.parsers.PDBFilter)7 MapConfiguration (org.apache.commons.configuration.MapConfiguration)6 Crystal (ffx.crystal.Crystal)5 ReflectionList (ffx.crystal.ReflectionList)5 ForceFieldEnergy (ffx.potential.ForceFieldEnergy)5