use of org.apache.whirr.Cluster.Instance in project whirr by apache.
the class HamaGroomServerClusterActionHandler method beforeConfigure.
@Override
protected void beforeConfigure(ClusterActionEvent event) throws IOException, InterruptedException {
ClusterSpec clusterSpec = event.getClusterSpec();
Cluster cluster = event.getCluster();
Instance instance = cluster.getInstanceMatching(role(HamaMasterClusterActionHandler.ROLE));
InetAddress masterPublicAddress = instance.getPublicAddress();
event.getFirewallManager().addRules(Rule.create().destination(instance).ports(GROOMSERVER_PORT));
handleFirewallRules(event);
String hamaConfigureFunction = getConfiguration(clusterSpec).getString(HamaConstants.KEY_CONFIGURE_FUNCTION, HamaConstants.FUNCTION_POST_CONFIGURE);
String master = masterPublicAddress.getHostName();
String quorum = ZooKeeperCluster.getHosts(cluster);
String tarurl = prepareRemoteFileUrl(event, getConfiguration(clusterSpec).getString(HamaConstants.KEY_TARBALL_URL));
addStatement(event, call("retry_helpers"));
addStatement(event, call(hamaConfigureFunction, ROLE, HamaConstants.PARAM_MASTER, master, HamaConstants.PARAM_QUORUM, quorum, HamaConstants.PARAM_TARBALL_URL, tarurl));
String hamaStartFunction = getConfiguration(clusterSpec).getString(HamaConstants.KEY_START_FUNCTION, HamaConstants.FUNCTION_START);
addStatement(event, call(hamaStartFunction, ROLE, HamaConstants.PARAM_TARBALL_URL, tarurl));
}
use of org.apache.whirr.Cluster.Instance in project whirr by apache.
the class HBaseClusterActionHandler method getMetricsTemplate.
protected String getMetricsTemplate(ClusterActionEvent event, ClusterSpec clusterSpec, Cluster cluster) {
Configuration conf = clusterSpec.getConfiguration();
if (conf.containsKey("hbase-metrics.template")) {
return conf.getString("hbase-metrics.template");
}
Set<Instance> gmetadInstances = cluster.getInstancesMatching(RolePredicates.role("ganglia-metad"));
if (!gmetadInstances.isEmpty()) {
return "hbase-metrics-ganglia.properties.vm";
}
return "hbase-metrics-null.properties.vm";
}
use of org.apache.whirr.Cluster.Instance in project whirr by apache.
the class HadoopConfigurationBuilder method buildMapReduceConfiguration.
@VisibleForTesting
static Configuration buildMapReduceConfiguration(ClusterSpec clusterSpec, Cluster cluster, Configuration defaults, Set<String> dataDirectories) throws ConfigurationException, IOException {
Configuration config = build(clusterSpec, cluster, defaults, "hadoop-mapreduce");
setIfAbsent(config, "mapred.local.dir", appendToDataDirectories(dataDirectories, "/hadoop/mapred/local"));
Set<Instance> taskTrackers = cluster.getInstancesMatching(role(HadoopTaskTrackerClusterActionHandler.ROLE));
if (!taskTrackers.isEmpty()) {
Hardware hardware = Iterables.getFirst(taskTrackers, null).getNodeMetadata().getHardware();
/* null when using the BYON jclouds compute provider */
if (hardware != null) {
int coresPerNode = 0;
for (Processor processor : hardware.getProcessors()) {
coresPerNode += processor.getCores();
}
int mapTasksPerNode = (int) Math.ceil(coresPerNode * 1.0);
int reduceTasksPerNode = (int) Math.ceil(coresPerNode * 0.75);
setIfAbsent(config, "mapred.tasktracker.map.tasks.maximum", mapTasksPerNode + "");
setIfAbsent(config, "mapred.tasktracker.reduce.tasks.maximum", reduceTasksPerNode + "");
int clusterReduceSlots = taskTrackers.size() * reduceTasksPerNode;
setIfAbsent(config, "mapred.reduce.tasks", clusterReduceSlots + "");
}
}
Set<Instance> jobtracker = cluster.getInstancesMatching(role(HadoopJobTrackerClusterActionHandler.ROLE));
if (!jobtracker.isEmpty()) {
config.setProperty("mapred.job.tracker", String.format("%s:8021", Iterables.getOnlyElement(jobtracker).getPublicHostName()));
}
return config;
}
use of org.apache.whirr.Cluster.Instance in project whirr by apache.
the class HadoopConfigurationBuilder method buildCommonConfiguration.
@VisibleForTesting
static Configuration buildCommonConfiguration(ClusterSpec clusterSpec, Cluster cluster, Configuration defaults) throws ConfigurationException, IOException {
Configuration config = build(clusterSpec, cluster, defaults, "hadoop-common");
Instance namenode = cluster.getInstanceMatching(role(HadoopNameNodeClusterActionHandler.ROLE));
LOG.debug("hadoop building common configuration, with hostname " + namenode.getPublicHostName());
config.setProperty("fs.default.name", String.format("hdfs://%s:8020/", namenode.getPublicHostName()));
return config;
}
use of org.apache.whirr.Cluster.Instance in project whirr by apache.
the class HadoopNameNodeClusterActionHandler method doBeforeConfigure.
@Override
protected void doBeforeConfigure(ClusterActionEvent event) throws IOException {
Cluster cluster = event.getCluster();
Instance namenode = cluster.getInstanceMatching(role(ROLE));
event.getFirewallManager().addRules(Rule.create().destination(namenode).ports(HadoopCluster.NAMENODE_WEB_UI_PORT), Rule.create().source(namenode.getPublicAddress().getHostAddress()).destination(namenode).ports(HadoopCluster.NAMENODE_PORT, HadoopCluster.JOBTRACKER_PORT));
}
Aggregations