Search in sources :

Example 46 with Cluster

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

the class ElasticSearchTest method getHealthInfo.

private String getHealthInfo() throws Exception {
    for (int i = 0; i < 20; i++) {
        try {
            Cluster.Instance instance = Iterables.get(cluster.getInstancesMatching(role(ElasticSearchHandler.ROLE)), 0);
            String address = instance.getPublicAddress().getHostAddress();
            URL url = new URL(String.format("http://%s:9200/_cluster/health", address));
            BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
            StringBuilder builder = new StringBuilder();
            String line;
            while ((line = in.readLine()) != null) {
                builder.append(line);
            }
            in.close();
            return builder.toString();
        } catch (IOException e) {
            try {
                Thread.sleep(5000);
            } catch (InterruptedException e1) {
            }
        }
    }
    throw new Exception("Unable to get cluster health info.");
}
Also used : InputStreamReader(java.io.InputStreamReader) BufferedReader(java.io.BufferedReader) Cluster(org.apache.whirr.Cluster) IOException(java.io.IOException) URL(java.net.URL) IOException(java.io.IOException)

Example 47 with Cluster

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

the class GangliaMetadClusterActionHandler method beforeConfigure.

@Override
protected void beforeConfigure(ClusterActionEvent event) throws IOException, InterruptedException {
    ClusterSpec clusterSpec = event.getClusterSpec();
    Cluster cluster = event.getCluster();
    // FIXME: the ganglia port is only opened so the ganglia xml dump can be checked in GangliaServiceTest
    event.getFirewallManager().addRule(Rule.create().destination(role(GANGLIA_METAD_ROLE)).ports(HTTP_PORT, GANGLIA_META_PORT));
    handleFirewallRules(event);
    Configuration config = getConfiguration(clusterSpec);
    String configureFunction = getConfigureFunction(config);
    // Call the configure function.
    String metadHost = cluster.getInstanceMatching(role(GANGLIA_METAD_ROLE)).getPrivateIp();
    addStatement(event, call("retry_helpers"));
    addStatement(event, call(configureFunction, "-m", metadHost));
}
Also used : Configuration(org.apache.commons.configuration.Configuration) Cluster(org.apache.whirr.Cluster) ClusterSpec(org.apache.whirr.ClusterSpec)

Example 48 with Cluster

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

the class GangliaMonitorClusterActionHandler method beforeConfigure.

@Override
protected void beforeConfigure(ClusterActionEvent event) throws IOException, InterruptedException {
    ClusterSpec clusterSpec = event.getClusterSpec();
    Cluster cluster = event.getCluster();
    event.getFirewallManager().addRule(Rule.create().destination(role(GANGLIA_MONITOR_ROLE)).port(GANGLIA_MONITOR_PORT));
    handleFirewallRules(event);
    Configuration config = getConfiguration(clusterSpec);
    String configureFunction = getConfigureFunction(config);
    // Call the configure function.
    String metadHost = cluster.getInstanceMatching(role(GANGLIA_METAD_ROLE)).getPrivateIp();
    addStatement(event, call("retry_helpers"));
    addStatement(event, call(configureFunction, "-m", metadHost));
}
Also used : Configuration(org.apache.commons.configuration.Configuration) Cluster(org.apache.whirr.Cluster) ClusterSpec(org.apache.whirr.ClusterSpec)

Example 49 with Cluster

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

the class GangliaMonitorClusterActionHandler method afterConfigure.

@Override
protected void afterConfigure(ClusterActionEvent event) {
    ClusterSpec clusterSpec = event.getClusterSpec();
    Cluster cluster = event.getCluster();
    LOG.info("Completed configuration of {}", clusterSpec.getClusterName());
    String hosts = Joiner.on(',').join(getHosts(cluster.getInstancesMatching(role(GANGLIA_MONITOR_ROLE))));
    LOG.info("Monitors: {}", hosts);
}
Also used : Cluster(org.apache.whirr.Cluster) ClusterSpec(org.apache.whirr.ClusterSpec)

Example 50 with Cluster

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

the class HadoopClusterActionHandler method beforeConfigure.

@Override
protected void beforeConfigure(ClusterActionEvent event) throws IOException, InterruptedException {
    ClusterSpec clusterSpec = event.getClusterSpec();
    Cluster cluster = event.getCluster();
    doBeforeConfigure(event);
    handleFirewallRules(event);
    createHadoopConfigFiles(event, clusterSpec, cluster);
    addStatement(event, call("retry_helpers"));
    addStatement(event, call(getConfigureFunction(getConfiguration(clusterSpec)), Joiner.on(",").join(event.getInstanceTemplate().getRoles()), "-c", clusterSpec.getProvider()));
}
Also used : Cluster(org.apache.whirr.Cluster) ClusterSpec(org.apache.whirr.ClusterSpec)

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