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