Search in sources :

Example 21 with Instance

use of org.apache.whirr.Cluster.Instance in project whirr by apache.

the class HBaseMasterClusterActionHandler method beforeConfigure.

@Override
protected void beforeConfigure(ClusterActionEvent event) throws IOException, InterruptedException {
    ClusterSpec clusterSpec = event.getClusterSpec();
    Cluster cluster = event.getCluster();
    Configuration conf = getConfiguration(clusterSpec);
    LOG.info("Authorizing firewall");
    Instance instance = cluster.getInstanceMatching(role(ROLE));
    InetAddress masterPublicAddress = instance.getPublicAddress();
    event.getFirewallManager().addRules(Rule.create().destination(instance).ports(MASTER_WEB_UI_PORT, MASTER_PORT));
    // Velocity is assuming flat classloaders or TCCL to load templates.
    // This doesn't work in OSGi unless we set the TCCL to the bundle classloader before invocation
    ClassLoader oldTccl = Thread.currentThread().getContextClassLoader();
    handleFirewallRules(event);
    try {
        Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
        event.getStatementBuilder().addStatements(buildHBaseSite("/tmp/hbase-site.xml", clusterSpec, cluster), buildHBaseEnv("/tmp/hbase-env.sh", clusterSpec, cluster), TemplateUtils.createFileFromTemplate("/tmp/hbase-hadoop-metrics.properties", event.getTemplateEngine(), getMetricsTemplate(event, clusterSpec, cluster), clusterSpec, cluster));
    } catch (ConfigurationException e) {
        throw new IOException(e);
    } finally {
        Thread.currentThread().setContextClassLoader(oldTccl);
    }
    String master = masterPublicAddress.getHostName();
    String quorum = ZooKeeperCluster.getHosts(cluster);
    String tarurl = prepareRemoteFileUrl(event, conf.getString(HBaseConstants.KEY_TARBALL_URL));
    addStatement(event, call("retry_helpers"));
    addStatement(event, call(getConfigureFunction(conf), ROLE, HBaseConstants.PARAM_MASTER, master, HBaseConstants.PARAM_QUORUM, quorum, HBaseConstants.PARAM_TARBALL_URL, tarurl));
}
Also used : Configuration(org.apache.commons.configuration.Configuration) Instance(org.apache.whirr.Cluster.Instance) ConfigurationException(org.apache.commons.configuration.ConfigurationException) Cluster(org.apache.whirr.Cluster) ZooKeeperCluster(org.apache.whirr.service.zookeeper.ZooKeeperCluster) ClusterSpec(org.apache.whirr.ClusterSpec) IOException(java.io.IOException) InetAddress(java.net.InetAddress)

Example 22 with Instance

use of org.apache.whirr.Cluster.Instance in project whirr by apache.

the class YarnConfigurationBuilder method buildConfiguration.

@VisibleForTesting
static Configuration buildConfiguration(ClusterSpec clusterSpec, Cluster cluster, String role, Configuration defaults) throws ConfigurationException, IOException {
    Configuration config = build(clusterSpec, cluster, defaults, "hadoop-yarn");
    if (role.equals(YarnResourceManagerHandler.ROLE)) {
        config.setProperty("yarn.resourcemanager.address", "0.0.0.0:8040");
        config.setProperty("yarn.resourcemanager.scheduler.address", "0.0.0.0:8030");
        config.setProperty("yarn.resourcemanager.resource-tracker.address", "0.0.0.0:8025");
    } else {
        Instance resourceManager = cluster.getInstanceMatching(role(YarnResourceManagerHandler.ROLE));
        String resourceManagerPrivateAddress = resourceManager.getPrivateAddress().getHostName();
        config.setProperty("yarn.resourcemanager.address", String.format("%s:8040", resourceManagerPrivateAddress));
        config.setProperty("yarn.resourcemanager.scheduler.address", String.format("%s:8030", resourceManagerPrivateAddress));
        config.setProperty("yarn.resourcemanager.resource-tracker.address", String.format("%s:8025", resourceManagerPrivateAddress));
    }
    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 23 with Instance

use of org.apache.whirr.Cluster.Instance in project whirr by apache.

the class YarnResourceManagerHandler method beforeConfigure.

@Override
protected void beforeConfigure(ClusterActionEvent event) throws IOException, InterruptedException {
    ClusterSpec clusterSpec = event.getClusterSpec();
    Configuration conf = getConfiguration(clusterSpec);
    Cluster cluster = event.getCluster();
    Instance resourceManager = cluster.getInstanceMatching(role(ROLE));
    event.getFirewallManager().addRules(Rule.create().destination(resourceManager).ports(RESOURCE_MANAGER_RPC_PORT, RESOURCE_MANAGER_WEB_UI_PORT), Rule.create().source(resourceManager.getPublicIp()).destination(resourceManager).ports(RESOURCE_MANAGER_RPC_PORT));
    handleFirewallRules(event);
    try {
        event.getStatementBuilder().addStatements(build("/tmp/yarn-site.xml", clusterSpec, cluster, ROLE));
    } catch (ConfigurationException e) {
        throw new IOException(e);
    }
    addStatement(event, call(getConfigureFunction(conf)));
    addStatement(event, call(getStartFunction(conf), "resourcemanager"));
}
Also used : Configuration(org.apache.commons.configuration.Configuration) AbstractConfiguration(org.apache.commons.configuration.AbstractConfiguration) Instance(org.apache.whirr.Cluster.Instance) ConfigurationException(org.apache.commons.configuration.ConfigurationException) Cluster(org.apache.whirr.Cluster) ClusterSpec(org.apache.whirr.ClusterSpec) IOException(java.io.IOException)

Example 24 with Instance

use of org.apache.whirr.Cluster.Instance in project whirr by apache.

the class ZooKeeperClusterActionHandler method beforeConfigure.

@Override
protected void beforeConfigure(ClusterActionEvent event) throws IOException, InterruptedException {
    ClusterSpec clusterSpec = event.getClusterSpec();
    Cluster cluster = event.getCluster();
    event.getFirewallManager().addRule(Rule.create().destination(role(ZOOKEEPER_ROLE)).port(CLIENT_PORT));
    handleFirewallRules(event);
    // Pass list of all servers in ensemble to configure script.
    // Position is significant: i-th server has id i.
    Set<Instance> ensemble = cluster.getInstancesMatching(role(ZOOKEEPER_ROLE));
    String servers = Joiner.on(' ').join(getPrivateIps(ensemble));
    Configuration config = getConfiguration(clusterSpec);
    addStatement(event, call("retry_helpers"));
    addStatement(event, call(getConfigureFunction(config), servers));
}
Also used : Configuration(org.apache.commons.configuration.Configuration) Instance(org.apache.whirr.Cluster.Instance) Cluster(org.apache.whirr.Cluster) ClusterSpec(org.apache.whirr.ClusterSpec)

Example 25 with Instance

use of org.apache.whirr.Cluster.Instance in project whirr by apache.

the class HBaseRegionServerClusterActionHandler method beforeConfigure.

@Override
protected void beforeConfigure(ClusterActionEvent event) throws IOException, InterruptedException {
    ClusterSpec clusterSpec = event.getClusterSpec();
    Cluster cluster = event.getCluster();
    Configuration conf = getConfiguration(clusterSpec);
    Instance instance = cluster.getInstanceMatching(role(HBaseMasterClusterActionHandler.ROLE));
    InetAddress masterPublicAddress = instance.getPublicAddress();
    event.getFirewallManager().addRules(Rule.create().destination(instance).ports(REGIONSERVER_WEB_UI_PORT, REGIONSERVER_PORT));
    // Velocity is assuming flat classloaders or TCCL to load templates.
    // This doesn't work in OSGi unless we set the TCCL to the bundle classloader before invocation
    ClassLoader oldTccl = Thread.currentThread().getContextClassLoader();
    handleFirewallRules(event);
    try {
        Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
        event.getStatementBuilder().addStatements(buildHBaseSite("/tmp/hbase-site.xml", clusterSpec, cluster), buildHBaseEnv("/tmp/hbase-env.sh", clusterSpec, cluster), TemplateUtils.createFileFromTemplate("/tmp/hbase-hadoop-metrics.properties", event.getTemplateEngine(), getMetricsTemplate(event, clusterSpec, cluster), clusterSpec, cluster));
    } catch (ConfigurationException e) {
        throw new IOException(e);
    } finally {
        Thread.currentThread().setContextClassLoader(oldTccl);
    }
    String master = masterPublicAddress.getHostName();
    String quorum = ZooKeeperCluster.getHosts(cluster);
    String tarurl = prepareRemoteFileUrl(event, conf.getString(HBaseConstants.KEY_TARBALL_URL));
    addStatement(event, call("retry_helpers"));
    addStatement(event, call(getConfigureFunction(conf), ROLE, HBaseConstants.PARAM_MASTER, master, HBaseConstants.PARAM_QUORUM, quorum, HBaseConstants.PARAM_TARBALL_URL, tarurl));
}
Also used : Configuration(org.apache.commons.configuration.Configuration) Instance(org.apache.whirr.Cluster.Instance) ConfigurationException(org.apache.commons.configuration.ConfigurationException) Cluster(org.apache.whirr.Cluster) ZooKeeperCluster(org.apache.whirr.service.zookeeper.ZooKeeperCluster) ClusterSpec(org.apache.whirr.ClusterSpec) IOException(java.io.IOException) InetAddress(java.net.InetAddress)

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