Search in sources :

Example 1 with Cluster

use of org.apache.whirr.Cluster in project whirr by apache.

the class CassandraClusterActionHandler method beforeConfigure.

@Override
protected void beforeConfigure(final ClusterActionEvent event) throws IOException, InterruptedException {
    Cluster cluster = event.getCluster();
    Set<Instance> instances = cluster.getInstancesMatching(role(CASSANDRA_ROLE));
    event.getFirewallManager().addRule(Rule.create().destination(instances).ports(CLIENT_PORT, JMX_PORT));
    handleFirewallRules(event);
    setInitialTokensAsEnvironmentVariables(event, instances);
    List<Instance> seeds = getSeeds(instances);
    String seedServers = Joiner.on(' ').join(getPrivateIps(seeds));
    addStatement(event, call("configure_cassandra", seedServers));
}
Also used : Instance(org.apache.whirr.Cluster.Instance) Cluster(org.apache.whirr.Cluster)

Example 2 with Cluster

use of org.apache.whirr.Cluster in project whirr by apache.

the class ScriptBasedClusterActionTest method testEmptyInstanceTemplates.

@Test(expected = IllegalArgumentException.class)
public void testEmptyInstanceTemplates() throws Exception {
    T action = newClusterActionInstance(EMPTYSET, EMPTYSET);
    DryRun dryRun = getDryRunForAction(action).reset();
    ClusterSpec tempSpec = ClusterSpec.withTemporaryKeys();
    tempSpec.setClusterName("test-cluster-for-script-exection");
    tempSpec.setProvider("stub");
    tempSpec.setIdentity("dummy");
    tempSpec.setStateStore("none");
    ClusterController controller = new ClusterController();
    Cluster tempCluster = controller.launchCluster(tempSpec);
    action.execute(tempSpec, tempCluster);
    List<StatementOnNode> executions = dryRun.getTotallyOrderedExecutions();
}
Also used : ClusterController(org.apache.whirr.ClusterController) DryRun(org.apache.whirr.service.DryRunModule.DryRun) Cluster(org.apache.whirr.Cluster) ClusterSpec(org.apache.whirr.ClusterSpec) StatementOnNode(org.jclouds.compute.events.StatementOnNode) Test(org.junit.Test)

Example 3 with Cluster

use of org.apache.whirr.Cluster in project whirr by apache.

the class FirewallManagerTest method setUpClass.

@Before
public void setUpClass() throws Exception {
    clusterSpec = getTestClusterSpec();
    context = ComputeCache.INSTANCE.apply(clusterSpec);
    /* create a dummy instance for testing */
    instances = Sets.newHashSet(new Cluster.Instance(new Credentials("dummy", "dummy"), Sets.newHashSet("dummy-role"), "50.0.0.1", "10.0.0.1", region + "/i-dummy", null));
    manager = new FirewallManager(context, clusterSpec, new Cluster(instances));
}
Also used : FirewallManager(org.apache.whirr.service.FirewallManager) Cluster(org.apache.whirr.Cluster) Credentials(org.jclouds.domain.Credentials) Before(org.junit.Before)

Example 4 with Cluster

use of org.apache.whirr.Cluster in project whirr by apache.

the class TemplateUtilsTest method testProcessTemplate.

@Test
public void testProcessTemplate() throws Exception {
    Credentials credentials = new Credentials("dummy", "dummy");
    Cluster.Instance instance = new Cluster.Instance(credentials, Sets.newHashSet("foo"), "127.0.0.1", "127.0.0.1", "id-0", null);
    ClusterSpec clusterSpec = ClusterSpec.withTemporaryKeys(new PropertiesConfiguration("whirr-core-test.properties"));
    Cluster cluster = new Cluster(Sets.newHashSet(instance));
    VelocityEngine ve = TemplateUtils.newVelocityEngine();
    String result = TemplateUtils.processTemplate(ve, "template-test.txt.vm", clusterSpec, cluster);
    Assert.assertEquals("instance ip: 127.0.0.1", result);
}
Also used : VelocityEngine(org.apache.velocity.app.VelocityEngine) Cluster(org.apache.whirr.Cluster) ClusterSpec(org.apache.whirr.ClusterSpec) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) Credentials(org.jclouds.domain.Credentials) Test(org.junit.Test)

Example 5 with Cluster

use of org.apache.whirr.Cluster in project whirr by apache.

the class HadoopTaskTrackerClusterActionHandler method doBeforeConfigure.

@Override
protected void doBeforeConfigure(ClusterActionEvent event) throws IOException {
    Cluster cluster = event.getCluster();
    Instance jobtracker = cluster.getInstanceMatching(role(HadoopJobTrackerClusterActionHandler.ROLE));
    event.getFirewallManager().addRules(Rule.create().destination(jobtracker).ports(HadoopCluster.JOBTRACKER_WEB_UI_PORT), Rule.create().source(HadoopCluster.getNamenodePublicAddress(cluster).getHostAddress()).destination(jobtracker).ports(HadoopCluster.JOBTRACKER_PORT));
}
Also used : Instance(org.apache.whirr.Cluster.Instance) Cluster(org.apache.whirr.Cluster)

Aggregations

Cluster (org.apache.whirr.Cluster)52 ClusterSpec (org.apache.whirr.ClusterSpec)35 Instance (org.apache.whirr.Cluster.Instance)19 Configuration (org.apache.commons.configuration.Configuration)16 IOException (java.io.IOException)9 InetAddress (java.net.InetAddress)9 ZooKeeperCluster (org.apache.whirr.service.zookeeper.ZooKeeperCluster)9 Test (org.junit.Test)8 PropertiesConfiguration (org.apache.commons.configuration.PropertiesConfiguration)7 Credentials (org.jclouds.domain.Credentials)7 ClusterController (org.apache.whirr.ClusterController)5 Properties (java.util.Properties)4 ConfigurationException (org.apache.commons.configuration.ConfigurationException)4 InstanceTemplate (org.apache.whirr.InstanceTemplate)4 ClusterActionEvent (org.apache.whirr.service.ClusterActionEvent)4 StatementBuilder (org.apache.whirr.service.jclouds.StatementBuilder)4 Matchers.containsString (org.hamcrest.Matchers.containsString)4 File (java.io.File)3 ExecutionException (java.util.concurrent.ExecutionException)3 Future (java.util.concurrent.Future)3