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));
}
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"));
}
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.
}
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));
}
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));
}
}
Aggregations