Search in sources :

Example 31 with CompositeConfiguration

use of org.apache.commons.configuration.CompositeConfiguration in project whirr by apache.

the class SolrServiceTest method beforeClass.

@BeforeClass
public static void beforeClass() throws ConfigurationException, JSchException, IOException, InterruptedException {
    String solrConfigTarballDestination = "target/solrconfig.tar.gz";
    Tarball.createFromDirectory("src/test/resources/conf", solrConfigTarballDestination);
    LOG.info("Created Solr config tarball at " + solrConfigTarballDestination);
    CompositeConfiguration config = new CompositeConfiguration();
    if (System.getProperty("conf") != null) {
        config.addConfiguration(new PropertiesConfiguration(System.getProperty("conf")));
    }
    config.addConfiguration(new PropertiesConfiguration("whirr-solr-test.properties"));
    clusterSpec = ClusterSpec.withTemporaryKeys(config);
    controller = new ClusterController();
    cluster = controller.launchCluster(clusterSpec);
}
Also used : ClusterController(org.apache.whirr.ClusterController) CompositeConfiguration(org.apache.commons.configuration.CompositeConfiguration) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) BeforeClass(org.junit.BeforeClass)

Example 32 with CompositeConfiguration

use of org.apache.commons.configuration.CompositeConfiguration in project whirr by apache.

the class Cdh3HadoopServiceTest method setUp.

@BeforeClass
public static void setUp() throws Exception {
    CompositeConfiguration config = new CompositeConfiguration();
    if (System.getProperty("config") != null) {
        config.addConfiguration(new PropertiesConfiguration(System.getProperty("config")));
    }
    config.addConfiguration(new PropertiesConfiguration(getPropertiesFilename()));
    clusterSpec = ClusterSpec.withTemporaryKeys(config);
    controller = new ClusterController();
    cluster = controller.launchCluster(clusterSpec);
    proxy = new HadoopProxy(clusterSpec, cluster);
    proxy.start();
}
Also used : ClusterController(org.apache.whirr.ClusterController) CompositeConfiguration(org.apache.commons.configuration.CompositeConfiguration) HadoopProxy(org.apache.whirr.service.hadoop.HadoopProxy) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) BeforeClass(org.junit.BeforeClass)

Example 33 with CompositeConfiguration

use of org.apache.commons.configuration.CompositeConfiguration in project whirr by apache.

the class CdhYarnServiceTest method setUp.

@BeforeClass
public static void setUp() throws Exception {
    CompositeConfiguration config = new CompositeConfiguration();
    if (System.getProperty("config") != null) {
        config.addConfiguration(new PropertiesConfiguration(System.getProperty("config")));
    }
    config.addConfiguration(new PropertiesConfiguration(getPropertiesFilename()));
    clusterSpec = ClusterSpec.withTemporaryKeys(config);
    controller = new ClusterController();
    cluster = controller.launchCluster(clusterSpec);
    proxy = new HadoopProxy(clusterSpec, cluster);
    proxy.start();
}
Also used : ClusterController(org.apache.whirr.ClusterController) CompositeConfiguration(org.apache.commons.configuration.CompositeConfiguration) HadoopProxy(org.apache.whirr.service.hadoop.HadoopProxy) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) BeforeClass(org.junit.BeforeClass)

Example 34 with CompositeConfiguration

use of org.apache.commons.configuration.CompositeConfiguration in project whirr by apache.

the class DryRunModuleTest method testNoInitScriptsAfterConfigurationStartedAndNoConfigScriptsAfterDestroy.

/**
 * Simple test that tests dry run module and at the same time enforces clear
 * separation of script execution phases.
 */
@Test
public void testNoInitScriptsAfterConfigurationStartedAndNoConfigScriptsAfterDestroy() throws ConfigurationException, JSchException, IOException, InterruptedException {
    final List<String> expectedExecutionOrder = ImmutableList.of("bootstrap", "configure", "start", "destroy");
    CompositeConfiguration config = new CompositeConfiguration();
    config.setProperty("whirr.provider", "stub");
    config.setProperty("whirr.cluster-name", "stub-test");
    config.setProperty("whirr.instance-templates", "10 noop+noop3,10 noop2+noop,10 noop3+noop2");
    config.setProperty("whirr.state-store", "memory");
    ClusterSpec clusterSpec = ClusterSpec.withTemporaryKeys(config);
    ClusterController controller = new ClusterController();
    DryRun dryRun = getDryRunInControllerForCluster(controller, clusterSpec);
    dryRun.reset();
    controller.launchCluster(clusterSpec);
    controller.destroyCluster(clusterSpec);
    ListMultimap<NodeMetadata, Statement> perNodeExecutions = dryRun.getExecutions();
    List<StatementOnNode> totalExecutions = dryRun.getTotallyOrderedExecutions();
    for (Entry<NodeMetadata, Collection<Statement>> entry : perNodeExecutions.asMap().entrySet()) {
        assertSame("An incorrect number of scripts was executed in the node: " + entry.getValue(), entry.getValue().size(), expectedExecutionOrder.size());
        List<Statement> asList = Lists.newArrayList(entry.getValue());
        int count = 0;
        for (String phase : expectedExecutionOrder) {
            String scriptName = getScriptName(asList.get(count));
            assertTrue("The '" + phase + "' script was executed in the wrong order, found: " + scriptName, scriptName.startsWith(phase));
            count += 1;
        }
    }
    // This tests the barrier by making sure that once a configure
    // script is executed no more setup scripts are executed
    Stack<String> executedPhases = new Stack<String>();
    for (StatementOnNode script : totalExecutions) {
        String[] parts = getScriptName(script.getStatement()).split("-");
        if ((!executedPhases.empty() && !executedPhases.peek().equals(parts[0])) || executedPhases.empty()) {
            executedPhases.push(parts[0]);
        }
    }
    // Assert that all scripts executed in the right order with no overlaps
    assertEquals(expectedExecutionOrder.size(), executedPhases.size());
    for (String phaseName : Lists.reverse(expectedExecutionOrder)) {
        assertEquals(executedPhases.pop(), phaseName);
    }
}
Also used : Statement(org.jclouds.scriptbuilder.domain.Statement) CompositeConfiguration(org.apache.commons.configuration.CompositeConfiguration) DryRun(org.apache.whirr.service.DryRunModule.DryRun) ClusterSpec(org.apache.whirr.ClusterSpec) StatementOnNode(org.jclouds.compute.events.StatementOnNode) Stack(java.util.Stack) NodeMetadata(org.jclouds.compute.domain.NodeMetadata) ClusterController(org.apache.whirr.ClusterController) Collection(java.util.Collection) Test(org.junit.Test)

Example 35 with CompositeConfiguration

use of org.apache.commons.configuration.CompositeConfiguration in project whirr by apache.

the class DryRunModuleTest method testExecuteOnlyBootstrapForNoopWithListener.

@Test
public void testExecuteOnlyBootstrapForNoopWithListener() throws Exception {
    CompositeConfiguration config = new CompositeConfiguration();
    config.setProperty("whirr.provider", "stub");
    config.setProperty("whirr.cluster-name", "stub-test");
    config.setProperty("whirr.instance-templates", "1 noop");
    config.setProperty("whirr.state-store", "memory");
    ClusterSpec clusterSpec = ClusterSpec.withTemporaryKeys(config);
    MockClusterActionHandlerListener listener = new MockClusterActionHandlerListener();
    clusterSpec.setHandlerListener(listener);
    ClusterController controller = new ClusterController();
    DryRun dryRun = getDryRunInControllerForCluster(controller, clusterSpec);
    dryRun.reset();
    controller.launchCluster(clusterSpec);
    controller.destroyCluster(clusterSpec);
    ListMultimap<NodeMetadata, Statement> perNodeExecutions = dryRun.getExecutions();
    for (Entry<NodeMetadata, Collection<Statement>> entry : perNodeExecutions.asMap().entrySet()) {
        assertSame("An incorrect number of scripts was executed in the node " + entry, entry.getValue().size(), 1);
    }
    assertEquals("beforeCalls should be 4", listener.beforeCalls, 4);
    assertEquals("afterCalls should be 4", listener.afterCalls, 4);
}
Also used : NodeMetadata(org.jclouds.compute.domain.NodeMetadata) ClusterController(org.apache.whirr.ClusterController) Statement(org.jclouds.scriptbuilder.domain.Statement) CompositeConfiguration(org.apache.commons.configuration.CompositeConfiguration) DryRun(org.apache.whirr.service.DryRunModule.DryRun) Collection(java.util.Collection) ClusterSpec(org.apache.whirr.ClusterSpec) Test(org.junit.Test)

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