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));
}
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());
}
}
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));
}
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);
}
}
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";
}
Aggregations