event.setTemplateBuilderStrategy(new HadoopTemplateBuilderStrategy());
}
@Override
protected void beforeConfigure(ClusterActionEvent event) throws IOException, InterruptedException {
ClusterSpec clusterSpec = event.getClusterSpec();
Cluster cluster = event.getCluster();
LOG.info("Authorizing firewall");
Instance instance = cluster.getInstanceMatching(role(ROLE));
InetAddress namenodePublicAddress = instance.getPublicAddress();
InetAddress jobtrackerPublicAddress = namenodePublicAddress;
ComputeServiceContext computeServiceContext =
ComputeServiceContextBuilder.build(clusterSpec);
FirewallSettings.authorizeIngress(computeServiceContext, instance, clusterSpec,
WEB_PORT);
FirewallSettings.authorizeIngress(computeServiceContext, instance, clusterSpec,
NAMENODE_WEB_UI_PORT);
FirewallSettings.authorizeIngress(computeServiceContext, instance, clusterSpec,
JOBTRACKER_WEB_UI_PORT);
FirewallSettings.authorizeIngress(computeServiceContext, instance, clusterSpec,
namenodePublicAddress.getHostAddress(), NAMENODE_PORT);
FirewallSettings.authorizeIngress(computeServiceContext, instance, clusterSpec,
namenodePublicAddress.getHostAddress(), JOBTRACKER_PORT);
if (!namenodePublicAddress.equals(jobtrackerPublicAddress)) {
FirewallSettings.authorizeIngress(computeServiceContext, instance, clusterSpec,
jobtrackerPublicAddress.getHostAddress(), NAMENODE_PORT);
FirewallSettings.authorizeIngress(computeServiceContext, instance, clusterSpec,
jobtrackerPublicAddress.getHostAddress(), JOBTRACKER_PORT);
}
String hadoopConfigureRunUrl = clusterSpec.getConfiguration().getString(
"whirr.hadoop-configure-runurl", "apache/hadoop/post-configure");
addRunUrl(event, hadoopConfigureRunUrl,
"nn,jt",
"-n", DnsUtil.resolveAddress(namenodePublicAddress.getHostAddress()),
"-j", DnsUtil.resolveAddress(jobtrackerPublicAddress.getHostAddress()),
"-c", clusterSpec.getProvider());
}