Search in sources :

Example 21 with Cluster

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

the class HBaseConfigurationBuilder method buildHBaseSiteConfiguration.

static Configuration buildHBaseSiteConfiguration(ClusterSpec clusterSpec, Cluster cluster, Configuration defaults) throws ConfigurationException, IOException {
    Configuration config = build(clusterSpec, cluster, defaults, "hbase-site");
    Cluster.Instance master = cluster.getInstanceMatching(role(HBaseMasterClusterActionHandler.ROLE));
    String masterHostName = master.getPublicHostName();
    config.setProperty("hbase.rootdir", String.format("hdfs://%s:8020/hbase", masterHostName));
    config.setProperty("hbase.zookeeper.quorum", ZooKeeperCluster.getHosts(cluster));
    return config;
}
Also used : Configuration(org.apache.commons.configuration.Configuration) CompositeConfiguration(org.apache.commons.configuration.CompositeConfiguration) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) Cluster(org.apache.whirr.Cluster) ZooKeeperCluster(org.apache.whirr.service.zookeeper.ZooKeeperCluster)

Example 22 with Cluster

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

the class BasicServerClusterActionHandler method beforeConfigure.

@Override
protected void beforeConfigure(ClusterActionEvent event) throws IOException, InterruptedException {
    ClusterSpec clusterSpec = event.getClusterSpec();
    Cluster cluster = event.getCluster();
    int port = defaultPort;
    if (configKeyPort != null) {
        port = getConfiguration(clusterSpec).getInt(configKeyPort, defaultPort);
    }
    Cluster.Instance instance = cluster.getInstanceMatching(role(role));
    InetAddress masterPublicAddress = instance.getPublicAddress();
    event.getFirewallManager().addRule(Rule.create().destination(instance).port(port));
    handleFirewallRules(event);
    String master = masterPublicAddress.getHostName();
    String quorum = ZooKeeperCluster.getHosts(cluster);
    String tarurl = prepareRemoteFileUrl(event, getConfiguration(clusterSpec).getString(HBaseConstants.KEY_TARBALL_URL));
    addStatement(event, call("retry_helpers"));
    addStatement(event, call(getConfigureFunction(getConfiguration(clusterSpec)), role, HBaseConstants.PARAM_MASTER, master, HBaseConstants.PARAM_QUORUM, quorum, HBaseConstants.PARAM_PORT, Integer.toString(port), HBaseConstants.PARAM_TARBALL_URL, tarurl));
}
Also used : Cluster(org.apache.whirr.Cluster) ZooKeeperCluster(org.apache.whirr.service.zookeeper.ZooKeeperCluster) ClusterSpec(org.apache.whirr.ClusterSpec) InetAddress(java.net.InetAddress)

Example 23 with Cluster

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

the class HBaseMasterClusterActionHandler method afterConfigure.

@Override
protected void afterConfigure(ClusterActionEvent event) throws IOException {
    ClusterSpec clusterSpec = event.getClusterSpec();
    Cluster cluster = event.getCluster();
    // TODO: wait for regionservers to come up?
    LOG.info("Completed configuration of {}", clusterSpec.getClusterName());
    Instance instance = cluster.getInstanceMatching(role(ROLE));
    InetAddress masterPublicAddress = instance.getPublicAddress();
    LOG.info("Web UI available at http://{}", masterPublicAddress.getHostName());
    String quorum = ZooKeeperCluster.getHosts(cluster);
    Properties config = createClientSideProperties(masterPublicAddress, quorum);
    createClientSideHadoopSiteFile(clusterSpec, config);
    createProxyScript(clusterSpec, cluster);
    event.setCluster(new Cluster(cluster.getInstances(), config));
}
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) Properties(java.util.Properties) InetAddress(java.net.InetAddress)

Example 24 with Cluster

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

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

the class SolrClusterActionHandler method afterStart.

@Override
protected void afterStart(ClusterActionEvent event) throws IOException {
    ClusterSpec clusterSpec = event.getClusterSpec();
    Cluster cluster = event.getCluster();
    Configuration config = getConfiguration(clusterSpec, SOLR_DEFAULT_CONFIG);
    int jettyPort = config.getInt(SOLR_JETTY_PORT);
    LOG.info("Completed configuration of {}", clusterSpec.getClusterName());
    LOG.info("Solr Hosts: {}", getHosts(cluster.getInstancesMatching(role(SOLR_ROLE)), jettyPort));
}
Also used : Configuration(org.apache.commons.configuration.Configuration) Cluster(org.apache.whirr.Cluster) ClusterSpec(org.apache.whirr.ClusterSpec)

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