List of usage examples for org.apache.commons.configuration CompositeConfiguration CompositeConfiguration
public CompositeConfiguration()
From source file:org.apache.whirr.service.cinderella.integration.CinderellaServiceTest.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 a 2 s . c om config.addConfiguration(new PropertiesConfiguration("whirr-cinderella-test.properties")); config.addConfiguration(new PropertiesConfiguration("whirr-cinderella-default.properties")); clusterSpec = ClusterSpec.withTemporaryKeys(config); cinderellaConfig = new CommonsConfigurationToCinderellaConfig("cinderella", clusterSpec.getClusterUser()) .apply(config); controller = new ClusterController(); controller.destroyCluster(clusterSpec); cluster = controller.launchCluster(clusterSpec); }
From source file:org.apache.whirr.service.ClusterActionHandlerSupport.java
/** * Returns a composite configuration that is made up from the global * configuration coming from the Whirr core with the service default * properties.//w ww . j a v a 2 s . co m * * @param clusterSpec The cluster specification instance. * @return The composite configuration. */ protected Configuration getConfiguration(ClusterSpec clusterSpec, Configuration defaults) { CompositeConfiguration cc = new CompositeConfiguration(); cc.addConfiguration(clusterSpec.getConfiguration()); cc.addConfiguration(defaults); return cc; }
From source file:org.apache.whirr.service.DryRunModuleTest.java
@Test public void testExecuteOnlyBootstrapForNoop() 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); ClusterController controller = new ClusterController(); DryRun dryRun = getDryRunInControllerForCluster(controller, clusterSpec); dryRun.reset();/*from w w w . j a v a2 s .c o m*/ 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); } }
From source file:org.apache.whirr.service.DryRunModuleTest.java
/** * Simple test that tests dry run module and at the same time enforces clear * separation of script execution phases. *//*from w w w . java 2 s . c o m*/ @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(); // Assert that all nodes executed all three phases and in the right order 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); } }
From source file:org.apache.whirr.service.elasticsearch.ElasticSearchConfigurationBuilder.java
/** * Build a configuration by adding the expected defaults *///from w w w . j a v a 2s .c o m public static Configuration buildConfig(ClusterSpec spec, Cluster cluster) { CompositeConfiguration config = new CompositeConfiguration(); config.addConfiguration(spec.getConfiguration()); try { config.addConfiguration(new PropertiesConfiguration("whirr-elasticsearch-default.properties")); } catch (ConfigurationException e) { LOG.error("Configuration error", e); // this should never happen } 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; }
From source file:org.apache.whirr.service.elasticsearch.integration.ElasticSearchTest.java
@Before public void setUp() throws Exception { CompositeConfiguration config = new CompositeConfiguration(); config.addConfiguration(new PropertiesConfiguration("whirr-elasticsearch-test.properties")); if (System.getProperty("config") != null) { config.addConfiguration(new PropertiesConfiguration(System.getProperty("config"))); }/*from w w w .j av a2 s.c o m*/ clusterSpec = ClusterSpec.withTemporaryKeys(config); controller = new ClusterController(); cluster = controller.launchCluster(clusterSpec); }
From source file:org.apache.whirr.service.ganglia.integration.GangliaServiceTest.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 . jav a2 s . c om*/ config.addConfiguration(new PropertiesConfiguration("whirr-ganglia-test.properties")); clusterSpec = ClusterSpec.withTemporaryKeys(config); controller = new ClusterControllerFactory().create(clusterSpec.getServiceName()); cluster = controller.launchCluster(clusterSpec); }
From source file:org.apache.whirr.service.hadoop.integration.HadoopServiceController.java
public synchronized void startup() throws Exception { LOG.info("Starting up cluster..."); CompositeConfiguration config = new CompositeConfiguration(); if (System.getProperty("config") != null) { config.addConfiguration(new PropertiesConfiguration(System.getProperty("config"))); }//w w w.ja v a 2 s.c o m config.addConfiguration(configuration); clusterSpec = ClusterSpec.withTemporaryKeys(config); controller = new ClusterController(); cluster = controller.launchCluster(clusterSpec); proxy = new HadoopProxy(clusterSpec, cluster); proxy.start(); Configuration conf = getConfiguration(); JobConf job = new JobConf(conf, HadoopServiceTest.class); JobClient client = new JobClient(job); waitToExitSafeMode(client); waitForTaskTrackers(client); running = true; }
From source file:org.apache.whirr.service.hama.integration.HamaServiceController.java
public synchronized void startup() throws Exception { LOG.info("Starting up cluster..."); CompositeConfiguration config = new CompositeConfiguration(); if (System.getProperty("config") != null) { config.addConfiguration(new PropertiesConfiguration(System.getProperty("config"))); }//from w ww . ja v a 2s .c om config.addConfiguration(new PropertiesConfiguration("whirr-hama-test.properties")); clusterSpec = ClusterSpec.withTemporaryKeys(config); controller = new ClusterController(); cluster = controller.launchCluster(clusterSpec); proxy = new HadoopProxy(clusterSpec, cluster); proxy.start(); HamaConfiguration conf = getConfiguration(); BSPJobClient client = new BSPJobClient(conf); waitForGroomServers(client); running = true; }
From source file:org.apache.whirr.service.hbase.integration.HBaseServiceController.java
public synchronized void startup() throws Exception { LOG.info("Starting up cluster..."); CompositeConfiguration config = new CompositeConfiguration(); if (System.getProperty("config") != null) { config.addConfiguration(new PropertiesConfiguration(System.getProperty("config"))); }//from ww w . ja v a 2s . c o m config.addConfiguration(new PropertiesConfiguration(this.configResource)); clusterSpec = ClusterSpec.withTemporaryKeys(config); controller = new ClusterController(); cluster = controller.launchCluster(clusterSpec); proxy = new HadoopProxy(clusterSpec, cluster); proxy.start(); waitForMaster(); running = true; }