use of org.jclouds.compute.domain.NodeMetadata in project hive by apache.
the class CloudExecutionContextProvider method createNodes.
private Set<NodeMetadata> createNodes(final int numHosts) throws CreateHostsFailedException {
Set<NodeMetadata> result = Sets.newHashSet();
int attempts = 0;
int numRequired = numHosts;
// pause so we don't get banned
try {
TimeUnit.SECONDS.sleep(mRetrySleepInterval);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
do {
boolean error = false;
LOG.info("Attempting to create " + numRequired + " nodes");
try {
result.addAll(mCloudComputeService.createNodes(Math.min(mMaxHostsPerCreateRequest, numRequired)));
} catch (RunNodesException e) {
error = true;
LOG.warn("Error creating nodes", e);
terminateInternal(e.getNodeErrors().keySet());
result.addAll(e.getSuccessfulNodes());
}
result = verifyHosts(result);
for (NodeMetadata node : result) {
mLiveHosts.put(publicIpOrHostname(node), System.currentTimeMillis());
}
LOG.info("Successfully created " + result.size() + " nodes");
numRequired = numHosts - result.size();
if (numRequired > 0) {
long sleepTime = mRetrySleepInterval;
if (error) {
sleepTime *= ++attempts;
}
LOG.info("Pausing creation process for " + sleepTime + " seconds");
try {
TimeUnit.SECONDS.sleep(sleepTime);
} catch (InterruptedException e) {
throw new CreateHostsFailedException("Interrupted while trying to create hosts", e);
}
}
} while (numRequired > 0);
Preconditions.checkState(result.size() >= numHosts, "Results should always be >= numHosts " + numHosts + " => " + result.size());
return result;
}
use of org.jclouds.compute.domain.NodeMetadata in project hive by apache.
the class CloudExecutionContextProvider method createExecutionContext.
@Override
public synchronized ExecutionContext createExecutionContext() throws CreateHostsFailedException, ServiceNotAvailableException {
try {
Set<NodeMetadata> nodes = createNodes(mNumHosts);
Set<Host> hosts = Sets.newHashSet();
for (NodeMetadata node : nodes) {
hosts.add(new Host(publicIp(node), mUser, mSlaveLocalDirs, mNumThreads));
}
return new ExecutionContext(this, hosts, mWorkingDir.getAbsolutePath(), mPrivateKey);
} finally {
syncLog();
}
}
use of org.jclouds.compute.domain.NodeMetadata in project hive by apache.
the class CloudExecutionContextProvider method getRunningNodes.
private Set<NodeMetadata> getRunningNodes() {
Set<NodeMetadata> result = Sets.newHashSet();
Set<NodeMetadata> computes = mCloudComputeService.listRunningNodes();
for (NodeMetadata node : computes) {
result.add(node);
}
return result;
}
use of org.jclouds.compute.domain.NodeMetadata in project whirr by apache.
the class CassandraService method launchCluster.
@Override
public Cluster launchCluster(ClusterSpec clusterSpec) throws IOException {
ComputeServiceContext computeServiceContext = ComputeServiceContextBuilder.build(clusterSpec);
ComputeService computeService = computeServiceContext.getComputeService();
byte[] bootScript = RunUrlBuilder.runUrls("sun/java/install", "apache/cassandra/install");
TemplateBuilder templateBuilder = computeService.templateBuilder().osFamily(UBUNTU).options(runScript(bootScript).installPrivateKey(clusterSpec.readPrivateKey()).authorizePublicKey(clusterSpec.readPublicKey()));
// TODO extract this logic elsewhere
if (clusterSpec.getProvider().equals("ec2"))
templateBuilder.imageNameMatches(".*10\\.?04.*").osDescriptionMatches("^ubuntu-images.*").architecture(Architecture.X86_32);
Template template = templateBuilder.build();
InstanceTemplate instanceTemplate = clusterSpec.getInstanceTemplate(CASSANDRA_ROLE);
checkNotNull(instanceTemplate);
int clusterSize = instanceTemplate.getNumberOfInstances();
Set<? extends NodeMetadata> nodeMap;
try {
nodeMap = computeService.runNodesWithTag(clusterSpec.getClusterName(), clusterSize, template);
} catch (RunNodesException e) {
// TODO: can we do better here
throw new IOException(e);
}
FirewallSettings.authorizeIngress(computeServiceContext, nodeMap, clusterSpec, CLIENT_PORT);
List<NodeMetadata> nodes = Lists.newArrayList(nodeMap);
List<NodeMetadata> seeds = getSeeds(nodes);
// Pass list of all servers in cluster to configure script.
String servers = Joiner.on(' ').join(getPrivateIps(seeds));
byte[] configureScript = RunUrlBuilder.runUrls("apache/cassandra/post-configure " + servers);
try {
Map<? extends NodeMetadata, ExecResponse> responses = computeService.runScriptOnNodesMatching(runningWithTag(clusterSpec.getClusterName()), configureScript);
assert responses.size() > 0 : "no nodes matched " + clusterSpec.getClusterName();
} catch (RunScriptOnNodesException e) {
// TODO: retry
throw new IOException(e);
}
return new Cluster(getInstances(nodes));
}
use of org.jclouds.compute.domain.NodeMetadata in project SimianArmy by Netflix.
the class AWSClient method connectSsh.
@Override
public SshClient connectSsh(String instanceId, LoginCredentials credentials) {
ComputeService computeService = getJcloudsComputeService();
String jcloudsId = getJcloudsId(instanceId);
NodeMetadata node = getJcloudsNode(computeService, jcloudsId);
node = NodeMetadataBuilder.fromNodeMetadata(node).credentials(credentials).build();
Utils utils = computeService.getContext().utils();
SshClient ssh = utils.sshForNode().apply(node);
ssh.connect();
return ssh;
}
Aggregations