Search in sources :

Example 26 with Cluster

use of org.apache.whirr.Cluster 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 27 with Cluster

use of org.apache.whirr.Cluster 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 28 with Cluster

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

the class VoldemortClusterActionHandler method afterConfigure.

@Override
protected void afterConfigure(ClusterActionEvent event) {
    ClusterSpec clusterSpec = event.getClusterSpec();
    Cluster cluster = event.getCluster();
    String servers = Joiner.on(' ').join(getPrivateIps(cluster.getInstances()));
    LOG.info("Completed setup of Voldemort {} with servers {}", clusterSpec.getClusterName(), servers);
}
Also used : Cluster(org.apache.whirr.Cluster) ClusterSpec(org.apache.whirr.ClusterSpec)

Example 29 with Cluster

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

the class VoldemortClusterActionHandler method beforeConfigure.

@Override
protected void beforeConfigure(ClusterActionEvent event) throws IOException, InterruptedException {
    Cluster cluster = event.getCluster();
    LOG.info("Authorizing firewall");
    event.getFirewallManager().addRule(Rule.create().destination(cluster.getInstancesMatching(role(ROLE))).ports(CLIENT_PORT, ADMIN_PORT, HTTP_PORT));
    handleFirewallRules(event);
    String servers = Joiner.on(' ').join(getPrivateIps(cluster.getInstances()));
    Configuration config = event.getClusterSpec().getConfiguration();
    int partitionsPerNode = config.getInt(PARAM_PARTITIONS_PER_NODE, 10);
    addStatement(event, call("retry_helpers"));
    addStatement(event, call(FUNCTION_CONFIGURE, PARAM_PARTITIONS_PER_NODE, Integer.toString(partitionsPerNode), servers));
}
Also used : Configuration(org.apache.commons.configuration.Configuration) Cluster(org.apache.whirr.Cluster)

Example 30 with Cluster

use of org.apache.whirr.Cluster 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

Cluster (org.apache.whirr.Cluster)52 ClusterSpec (org.apache.whirr.ClusterSpec)35 Instance (org.apache.whirr.Cluster.Instance)19 Configuration (org.apache.commons.configuration.Configuration)16 IOException (java.io.IOException)9 InetAddress (java.net.InetAddress)9 ZooKeeperCluster (org.apache.whirr.service.zookeeper.ZooKeeperCluster)9 Test (org.junit.Test)8 PropertiesConfiguration (org.apache.commons.configuration.PropertiesConfiguration)7 Credentials (org.jclouds.domain.Credentials)7 ClusterController (org.apache.whirr.ClusterController)5 Properties (java.util.Properties)4 ConfigurationException (org.apache.commons.configuration.ConfigurationException)4 InstanceTemplate (org.apache.whirr.InstanceTemplate)4 ClusterActionEvent (org.apache.whirr.service.ClusterActionEvent)4 StatementBuilder (org.apache.whirr.service.jclouds.StatementBuilder)4 Matchers.containsString (org.hamcrest.Matchers.containsString)4 File (java.io.File)3 ExecutionException (java.util.concurrent.ExecutionException)3 Future (java.util.concurrent.Future)3