use of org.apache.hive.ptest.execution.conf.Host in project hive by apache.
the class CloudExecutionContextProvider method replaceBadHosts.
@Override
public void replaceBadHosts(ExecutionContext executionContext) throws CreateHostsFailedException {
Set<String> hostsToTerminate = Sets.newHashSet();
Set<Host> hostsNotRemoved = Sets.newHashSet();
for (Host host : executionContext.getBadHosts()) {
hostsToTerminate.add(host.getName());
if (!executionContext.removeHost(host)) {
hostsNotRemoved.add(host);
}
}
executionContext.clearBadHosts();
if (!hostsToTerminate.isEmpty()) {
LOG.info("Replacing " + hostsToTerminate);
terminate(hostsToTerminate, true);
Set<NodeMetadata> nodes = createNodes(hostsToTerminate.size());
for (NodeMetadata node : nodes) {
executionContext.addHost(new Host(publicIp(node), mUser, mSlaveLocalDirs, mNumThreads));
}
}
Preconditions.checkState(hostsNotRemoved.isEmpty(), "Host " + hostsNotRemoved + " was in bad hosts but could not be removed");
}
use of org.apache.hive.ptest.execution.conf.Host 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.apache.hive.ptest.execution.conf.Host in project hive by apache.
the class CloudExecutionContextProvider method terminate.
@Override
public synchronized void terminate(ExecutionContext executionContext) {
Set<String> hostsToTerminate = Sets.newHashSet();
for (Host host : executionContext.getHosts()) {
hostsToTerminate.add(host.getName());
}
terminate(hostsToTerminate, true);
}
use of org.apache.hive.ptest.execution.conf.Host in project hive by apache.
the class TestCloudExecutionContextProvider method testRetry.
@org.junit.Test
public void testRetry() throws Exception {
when(cloudComputeService.createNodes(anyInt())).then(new Answer<Set<NodeMetadata>>() {
int count = 0;
@Override
public Set<NodeMetadata> answer(InvocationOnMock invocation) throws Throwable {
if (count++ == 0) {
throw runNodesException;
}
return Collections.singleton(node3);
}
});
CloudExecutionContextProvider provider = new CloudExecutionContextProvider(dataDir, NUM_NODES, cloudComputeService, sshCommandExecutor, workingDir, PRIVATE_KEY, USER, SLAVE_DIRS, 1, 0, 1);
ExecutionContext executionContext = provider.createExecutionContext();
Set<String> hosts = Sets.newHashSet();
for (Host host : executionContext.getHosts()) {
hosts.add(host.getName());
}
Assert.assertEquals(Sets.newHashSet("1.1.1.1", "1.1.1.3"), hosts);
}
use of org.apache.hive.ptest.execution.conf.Host in project hive by apache.
the class ExecutionPhase method replaceBadHosts.
private void replaceBadHosts(int expectedNumHosts) throws Exception {
Set<Host> goodHosts = Sets.newHashSet();
for (HostExecutor hostExecutor : ImmutableList.copyOf(hostExecutors)) {
if (hostExecutor.isBad()) {
logger.info("Removing host during execution phase: " + hostExecutor.getHost());
executionContext.addBadHost(hostExecutor.getHost());
hostExecutors.remove(hostExecutor);
} else {
goodHosts.add(hostExecutor.getHost());
}
}
long start = System.currentTimeMillis();
while (hostExecutors.size() < expectedNumHosts) {
if (System.currentTimeMillis() - start > FOUR_HOURS) {
throw new RuntimeException("Waited over fours for hosts, still have only " + hostExecutors.size() + " hosts out of an expected " + expectedNumHosts);
}
logger.warn("Only " + hostExecutors.size() + " hosts out of an expected " + expectedNumHosts + ", attempting to replace bad hosts");
TimeUnit.MINUTES.sleep(1);
executionContext.replaceBadHosts();
for (Host host : executionContext.getHosts()) {
if (!goodHosts.contains(host)) {
HostExecutor hostExecutor = hostExecutorBuilder.build(host);
initalizeHost(hostExecutor);
if (hostExecutor.isBad()) {
executionContext.addBadHost(hostExecutor.getHost());
} else {
logger.info("Adding new host during execution phase: " + host);
hostExecutors.add(hostExecutor);
}
}
}
}
}
Aggregations