use of org.apache.whirr.ClusterSpec in project whirr by apache.
the class HadoopNameNodeClusterActionHandler method afterConfigure.
@Override
protected void afterConfigure(ClusterActionEvent event) throws IOException {
ClusterSpec clusterSpec = event.getClusterSpec();
Cluster cluster = event.getCluster();
// TODO: wait for TTs to come up (done in test for the moment)
LOG.info("Completed configuration of {} role {}", clusterSpec.getClusterName(), getRole());
InetAddress namenodePublicAddress = HadoopCluster.getNamenodePublicAddress(cluster);
InetAddress jobtrackerPublicAddress = HadoopCluster.getJobTrackerPublicAddress(cluster);
LOG.info("Namenode web UI available at http://{}:{}", namenodePublicAddress.getHostName(), HadoopCluster.NAMENODE_WEB_UI_PORT);
Properties config = createClientSideProperties(clusterSpec, namenodePublicAddress, jobtrackerPublicAddress);
createClientSideHadoopSiteFile(clusterSpec, config);
createProxyScript(clusterSpec, cluster);
Properties combined = new Properties();
combined.putAll(cluster.getConfiguration());
combined.putAll(config);
event.setCluster(new Cluster(cluster.getInstances(), combined));
}
use of org.apache.whirr.ClusterSpec in project whirr by apache.
the class HadoopJobTrackerClusterActionHandler method afterConfigure.
@Override
protected void afterConfigure(ClusterActionEvent event) throws IOException {
ClusterSpec clusterSpec = event.getClusterSpec();
Cluster cluster = event.getCluster();
LOG.info("Completed configuration of {} role {}", clusterSpec.getClusterName(), getRole());
InetAddress jobtrackerPublicAddress = HadoopCluster.getJobTrackerPublicAddress(cluster);
LOG.info("Jobtracker web UI available at http://{}:{}", jobtrackerPublicAddress.getHostName(), HadoopCluster.JOBTRACKER_WEB_UI_PORT);
}
use of org.apache.whirr.ClusterSpec in project whirr by apache.
the class BootstrapClusterAction method doAction.
@Override
protected void doAction(Map<InstanceTemplate, ClusterActionEvent> eventMap) throws IOException, InterruptedException {
LOG.info("Bootstrapping cluster");
ExecutorService executorService = Executors.newCachedThreadPool();
Map<InstanceTemplate, Future<Set<? extends NodeMetadata>>> futures = Maps.newHashMap();
// initialize startup processes per InstanceTemplates
for (Entry<InstanceTemplate, ClusterActionEvent> entry : eventMap.entrySet()) {
final InstanceTemplate instanceTemplate = entry.getKey();
final ClusterSpec clusterSpec = entry.getValue().getClusterSpec();
final int maxNumberOfRetries = clusterSpec.getMaxStartupRetries();
StatementBuilder statementBuilder = entry.getValue().getStatementBuilder();
ComputeServiceContext computeServiceContext = getCompute().apply(clusterSpec);
final ComputeService computeService = computeServiceContext.getComputeService();
final Template template = BootstrapTemplate.build(clusterSpec, computeService, statementBuilder, entry.getKey());
Future<Set<? extends NodeMetadata>> nodesFuture = executorService.submit(new StartupProcess(clusterSpec.getClusterName(), instanceTemplate.getNumberOfInstances(), instanceTemplate.getMinNumberOfInstances(), maxNumberOfRetries, instanceTemplate.getRoles(), computeService, template, executorService, nodeStarterFactory));
futures.put(instanceTemplate, nodesFuture);
}
Set<Instance> instances = Sets.newLinkedHashSet();
for (Entry<InstanceTemplate, Future<Set<? extends NodeMetadata>>> entry : futures.entrySet()) {
Set<? extends NodeMetadata> nodes;
try {
nodes = entry.getValue().get();
} catch (ExecutionException e) {
// nodes after retries
throw new IOException(e);
}
Set<String> roles = entry.getKey().getRoles();
instances.addAll(getInstances(roles, nodes));
}
Cluster cluster = new Cluster(instances);
for (ClusterActionEvent event : eventMap.values()) {
event.setCluster(cluster);
}
}
use of org.apache.whirr.ClusterSpec in project whirr by apache.
the class DestroyClusterCommandTest method testAllOptions.
@Test
public void testAllOptions() throws Exception {
ClusterControllerFactory factory = mock(ClusterControllerFactory.class);
ClusterController controller = mock(ClusterController.class);
when(factory.create((String) any())).thenReturn(controller);
DestroyClusterCommand command = new DestroyClusterCommand(factory);
Map<String, File> keys = KeyPair.generateTemporaryFiles();
int rc = command.run(null, out, null, Lists.newArrayList("--instance-templates", "1 noop", "--service-name", "test-service", "--cluster-name", "test-cluster", "--provider", "rackspace", "--identity", "myusername", "--credential", "mypassword", "--private-key-file", keys.get("private").getAbsolutePath(), "--version", "version-string"));
assertThat(rc, is(0));
Configuration conf = new PropertiesConfiguration();
conf.addProperty("whirr.version", "version-string");
conf.addProperty("whirr.instance-templates", "1 noop");
ClusterSpec expectedClusterSpec = ClusterSpec.withTemporaryKeys(conf);
expectedClusterSpec.setServiceName("test-service");
expectedClusterSpec.setProvider("rackspace");
expectedClusterSpec.setIdentity("myusername");
expectedClusterSpec.setCredential("mypassword");
expectedClusterSpec.setClusterName("test-cluster");
expectedClusterSpec.setPrivateKey(keys.get("private"));
expectedClusterSpec.setPublicKey(keys.get("public"));
verify(factory).create("test-service");
verify(controller).destroyCluster(expectedClusterSpec);
}
use of org.apache.whirr.ClusterSpec in project whirr by apache.
the class ClusterActionHandlerSupport method handleFirewallRules.
/**
* Handles firewall rules for a given event.
*/
public static void handleFirewallRules(ClusterActionEvent event) {
ClusterSpec clusterSpec = event.getClusterSpec();
for (Statement statement : event.getFirewallManager().getRulesAsStatements()) {
addStatement(event, statement);
}
event.getFirewallManager().authorizeAllRules();
}
Aggregations