Search in sources :

Example 1 with Instance

use of org.apache.whirr.Cluster.Instance 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 Instance

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

the class CassandraClusterActionHandler method setInitialTokensAsEnvironmentVariables.

private void setInitialTokensAsEnvironmentVariables(ClusterActionEvent event, Set<Instance> instances) {
    List<String> tokens = computeInitialTokens(instances.size());
    StatementBuilder statementBuilder = event.getStatementBuilder();
    Iterator it = tokens.iterator();
    for (Instance instance : instances) {
        statementBuilder.addExportPerInstance(instance.getId(), "cassandraInitialToken", (String) it.next());
    }
}
Also used : Instance(org.apache.whirr.Cluster.Instance) StatementBuilder(org.apache.whirr.service.jclouds.StatementBuilder) Iterator(java.util.Iterator)

Example 3 with Instance

use of org.apache.whirr.Cluster.Instance 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)

Example 4 with Instance

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

the class GangliaServiceTest method test.

@Test(timeout = TestConstants.ITEST_TIMEOUT)
public void test() throws Exception {
    Instance metad = cluster.getInstanceMatching(RolePredicates.role(GangliaMetadClusterActionHandler.GANGLIA_METAD_ROLE));
    String metadHostname = metad.getPublicHostName();
    assertNotNull(metadHostname);
    HttpClient client = new HttpClient();
    GetMethod getIndex = new GetMethod(String.format("http://%s/ganglia/", metadHostname));
    int statusCode = client.executeMethod(getIndex);
    assertEquals("Status code should be 200", HttpStatus.SC_OK, statusCode);
    String indexPageHTML = getIndex.getResponseBodyAsString();
    assertTrue("The string 'Ganglia' should appear on the index page", indexPageHTML.contains("Ganglia"));
    assertTrue("The string 'WhirrGrid' should appear on the index page", indexPageHTML.contains("WhirrGrid"));
    // Now check the xml produced when connecting to the ganglia monitor port on all instances.
    for (Instance instance : cluster.getInstancesMatching(anyRoleIn(Sets.<String>newHashSet(GANGLIA_METAD_ROLE, GANGLIA_MONITOR_ROLE)))) {
        testMonitorResponse(instance);
    }
}
Also used : Instance(org.apache.whirr.Cluster.Instance) HttpClient(org.apache.commons.httpclient.HttpClient) GetMethod(org.apache.commons.httpclient.methods.GetMethod) Test(org.junit.Test)

Example 5 with Instance

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

the class HadoopClusterActionHandler method getMetricsTemplate.

private String getMetricsTemplate(ClusterActionEvent event, ClusterSpec clusterSpec, Cluster cluster) {
    Configuration conf = clusterSpec.getConfiguration();
    if (conf.containsKey("hadoop-metrics.template")) {
        return conf.getString("hadoop-metrics.template");
    }
    Set<Instance> gmetadInstances = cluster.getInstancesMatching(RolePredicates.role("ganglia-metad"));
    if (!gmetadInstances.isEmpty()) {
        return "hadoop-metrics-ganglia.properties.vm";
    }
    return "hadoop-metrics-null.properties.vm";
}
Also used : Configuration(org.apache.commons.configuration.Configuration) Instance(org.apache.whirr.Cluster.Instance)

Aggregations

Instance (org.apache.whirr.Cluster.Instance)36 Cluster (org.apache.whirr.Cluster)19 ClusterSpec (org.apache.whirr.ClusterSpec)14 Configuration (org.apache.commons.configuration.Configuration)10 IOException (java.io.IOException)9 InetAddress (java.net.InetAddress)6 ZooKeeperCluster (org.apache.whirr.service.zookeeper.ZooKeeperCluster)6 Test (org.junit.Test)6 ConfigurationException (org.apache.commons.configuration.ConfigurationException)4 StatementBuilder (org.apache.whirr.service.jclouds.StatementBuilder)4 VisibleForTesting (com.google.common.annotations.VisibleForTesting)3 Properties (java.util.Properties)3 ExecutionException (java.util.concurrent.ExecutionException)3 Future (java.util.concurrent.Future)3 CompositeConfiguration (org.apache.commons.configuration.CompositeConfiguration)3 PropertiesConfiguration (org.apache.commons.configuration.PropertiesConfiguration)3 InstanceTemplate (org.apache.whirr.InstanceTemplate)3 ClusterActionEvent (org.apache.whirr.service.ClusterActionEvent)3 NodeMetadata (org.jclouds.compute.domain.NodeMetadata)3 Cassandra (org.apache.cassandra.thrift.Cassandra)2