addStatement(event, call(hadoopInstallFunction, "-c", clusterSpec.getProvider()));
}
@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,
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);
}
try {
event.getStatementBuilder().addStatements(
buildCommon("/tmp/core-site.xml", clusterSpec, cluster),
buildHdfs("/tmp/hdfs-site.xml", clusterSpec, cluster),
buildMapReduce("/tmp/mapred-site.xml", clusterSpec, cluster)
);
} catch (ConfigurationException e) {
throw new IOException(e);
}
String hadoopConfigureFunction = clusterSpec.getConfiguration().getString(
"whirr.hadoop-configure-function", "configure_hadoop");
addStatement(event, call(hadoopConfigureFunction,
"hadoop-namenode,hadoop-jobtracker",
"-c", clusterSpec.getProvider()
));
}