Search in sources :

Example 21 with ClusterSpec

use of org.apache.whirr.ClusterSpec 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 22 with ClusterSpec

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

the class ChefServiceDryRunTest method testChefWithAttributes.

/**
 * Tests that a simple recipe (the default recipe in a cookbook without any
 * configuration parameters) is correctly loaded and executed.
 */
@Test
public void testChefWithAttributes() throws Exception {
    ClusterSpec cookbookWithSpecificRecipe = newClusterSpecForProperties(ImmutableMap.of("whirr.instance-templates", "1 chef:java:sun"));
    DryRun dryRun = launchWithClusterSpec(cookbookWithSpecificRecipe);
    assertScriptPredicateOnPhase(dryRun, "bootstrap", bootstrapPredicate());
    // chef execution with a default cookbook recipe should contain a
    // particular string
    assertScriptPredicateOnPhase(dryRun, "configure", containsPattern("chef-solo -j /tmp/java::sun"));
}
Also used : DryRun(org.apache.whirr.service.DryRunModule.DryRun) ClusterSpec(org.apache.whirr.ClusterSpec) Test(org.junit.Test) BaseServiceDryRunTest(org.apache.whirr.service.BaseServiceDryRunTest)

Example 23 with ClusterSpec

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

the class ChefServiceDryRunTest method testChefOnly.

/**
 * Tests that a simple recipe (the default recipe in a cookbook without any
 * configuration parameters) is correctly loaded and executed.
 */
@Test
public void testChefOnly() throws Exception {
    ClusterSpec chefOnly = newClusterSpecForProperties(ImmutableMap.of("whirr.instance-templates", "1 chef"));
    DryRun dryRun = launchWithClusterSpec(chefOnly);
    assertScriptPredicateOnPhase(dryRun, "bootstrap", bootstrapPredicate());
// We now have iptables calls by default in the configure phase.
}
Also used : DryRun(org.apache.whirr.service.DryRunModule.DryRun) ClusterSpec(org.apache.whirr.ClusterSpec) Test(org.junit.Test) BaseServiceDryRunTest(org.apache.whirr.service.BaseServiceDryRunTest)

Example 24 with ClusterSpec

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

the class DruidClusterActionHandler method beforeBootstrap.

@Override
protected void beforeBootstrap(ClusterActionEvent event) throws IOException {
    ClusterSpec clusterSpec = event.getClusterSpec();
    Configuration conf = getConfiguration(clusterSpec);
    addStatement(event, call("install_openjdk"));
    addStatement(event, call("retry_helpers"));
    addStatement(event, call("configure_hostnames"));
    // addStatement(event, call(getInstallFunction(conf, "java", "install_oracle_jdk7")));
    // Get the right version of druid and map this to the tarUrl
    String druidVersion = (String) conf.getProperty("whirr.druid.version");
    LOG.info("whirr.druid.version: " + druidVersion);
    String tarUrl = DruidCluster.getDownloadUrl(druidVersion);
    LOG.info("whirr tarUrl: " + tarUrl);
    addStatement(event, call("install_druid", tarUrl));
}
Also used : Configuration(org.apache.commons.configuration.Configuration) ClusterSpec(org.apache.whirr.ClusterSpec)

Example 25 with ClusterSpec

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

the class DruidClusterActionHandler method beforeConfigure.

// Always over-ridden in subclass
@Override
protected void beforeConfigure(ClusterActionEvent event) throws IOException {
    ClusterSpec clusterSpec = event.getClusterSpec();
    Cluster cluster = event.getCluster();
    Configuration conf = getConfiguration(clusterSpec);
    LOG.info("Role: [" + getRole() + "] Port: [" + getPort() + "]");
    // Open a port for the service
    event.getFirewallManager().addRule(FirewallManager.Rule.create().destination(role(getRole())).port(getPort()));
    handleFirewallRules(event);
    // Zookeeper quorum
    String quorum = ZooKeeperCluster.getHosts(cluster, true);
    LOG.info("ZookeeperCluster.getHosts(cluster): " + quorum);
    // Get MySQL Server address
    String mysqlAddress = DruidCluster.getMySQLPublicAddress(cluster);
    LOG.info("DruidCluster.getMySQLPublicAddress(cluster).getHostAddress(): " + mysqlAddress);
    // Get Blobstore and bucket
    Map<String, String> env = System.getenv();
    String identity = clusterSpec.getBlobStoreIdentity();
    String credential = clusterSpec.getBlobStoreCredential();
    String s3Bucket = conf.getString("whirr.druid.pusher.s3.bucket");
    LOG.info("whirr.druid.pusher.s3.bucket: " + s3Bucket);
    addStatement(event, call("retry_helpers"));
    addStatement(event, call("configure_hostnames"));
    addStatement(event, call("configure_druid", getRole(), quorum, getPort().toString(), mysqlAddress, identity, credential, s3Bucket));
    // Configure the realtime spec for realtime nodes
    if (getRole().equals("druid-realtime")) {
        String specPath = (String) conf.getProperty("whirr.druid.realtime.spec.path");
        LOG.info("whirr.druid.realtime.spec.path" + specPath);
        if (specPath == null || specPath.equals("")) {
            // Default to the included realtime.spec
            specPath = DruidClusterActionHandler.class.getResource("/" + "realtime.spec").getPath();
        // prepareRemoteFileUrl(event, specPath);
        }
        // Quorum is a variable in the realtime.spec
        String realtimeSpec = "'" + readFile(specPath) + "'";
        addStatement(event, call("configure_realtime", quorum, realtimeSpec));
    }
}
Also used : Configuration(org.apache.commons.configuration.Configuration) Cluster(org.apache.whirr.Cluster) ZooKeeperCluster(org.apache.whirr.service.zookeeper.ZooKeeperCluster) ClusterSpec(org.apache.whirr.ClusterSpec)

Aggregations

ClusterSpec (org.apache.whirr.ClusterSpec)98 Configuration (org.apache.commons.configuration.Configuration)39 Cluster (org.apache.whirr.Cluster)35 Test (org.junit.Test)34 PropertiesConfiguration (org.apache.commons.configuration.PropertiesConfiguration)16 Instance (org.apache.whirr.Cluster.Instance)14 ClusterController (org.apache.whirr.ClusterController)10 InetAddress (java.net.InetAddress)9 DryRun (org.apache.whirr.service.DryRunModule.DryRun)9 OptionSet (joptsimple.OptionSet)8 CompositeConfiguration (org.apache.commons.configuration.CompositeConfiguration)8 ZooKeeperCluster (org.apache.whirr.service.zookeeper.ZooKeeperCluster)8 IOException (java.io.IOException)7 ComputeService (org.jclouds.compute.ComputeService)7 File (java.io.File)6 ClusterControllerFactory (org.apache.whirr.ClusterControllerFactory)6 ComputeServiceContext (org.jclouds.compute.ComputeServiceContext)6 Set (java.util.Set)5 Stack (java.util.Stack)5 Matchers.containsString (org.hamcrest.Matchers.containsString)5