Search in sources :

Example 6 with Instance

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));
}
Also used : Instance(org.apache.whirr.Cluster.Instance) Cluster(org.apache.whirr.Cluster) ZooKeeperCluster(org.apache.whirr.service.zookeeper.ZooKeeperCluster) ClusterSpec(org.apache.whirr.ClusterSpec) InetAddress(java.net.InetAddress)

Example 7 with Instance

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";
}
Also used : Configuration(org.apache.commons.configuration.Configuration) Instance(org.apache.whirr.Cluster.Instance)

Example 8 with Instance

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;
}
Also used : Processor(org.jclouds.compute.domain.Processor) Configuration(org.apache.commons.configuration.Configuration) CompositeConfiguration(org.apache.commons.configuration.CompositeConfiguration) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) Instance(org.apache.whirr.Cluster.Instance) Hardware(org.jclouds.compute.domain.Hardware) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 9 with Instance

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;
}
Also used : Configuration(org.apache.commons.configuration.Configuration) CompositeConfiguration(org.apache.commons.configuration.CompositeConfiguration) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) Instance(org.apache.whirr.Cluster.Instance) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 10 with Instance

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));
}
Also used : Instance(org.apache.whirr.Cluster.Instance) Cluster(org.apache.whirr.Cluster)

Aggregations

Instance (org.apache.whirr.Cluster.Instance)36 Cluster (org.apache.whirr.Cluster)19 ClusterSpec (org.apache.whirr.ClusterSpec)14 Configuration (org.apache.commons.configuration.Configuration)10 IOException (java.io.IOException)9 InetAddress (java.net.InetAddress)6 ZooKeeperCluster (org.apache.whirr.service.zookeeper.ZooKeeperCluster)6 Test (org.junit.Test)6 ConfigurationException (org.apache.commons.configuration.ConfigurationException)4 StatementBuilder (org.apache.whirr.service.jclouds.StatementBuilder)4 VisibleForTesting (com.google.common.annotations.VisibleForTesting)3 Properties (java.util.Properties)3 ExecutionException (java.util.concurrent.ExecutionException)3 Future (java.util.concurrent.Future)3 CompositeConfiguration (org.apache.commons.configuration.CompositeConfiguration)3 PropertiesConfiguration (org.apache.commons.configuration.PropertiesConfiguration)3 InstanceTemplate (org.apache.whirr.InstanceTemplate)3 ClusterActionEvent (org.apache.whirr.service.ClusterActionEvent)3 NodeMetadata (org.jclouds.compute.domain.NodeMetadata)3 Cassandra (org.apache.cassandra.thrift.Cassandra)2