use of org.apache.hive.ptest.execution.ssh.SSHResult in project hive by apache.
the class HostExecutor method execInstances.
private List<ListenableFuture<RemoteCommandResult>> execInstances(List<Drone> drones, final String cmd) throws InterruptedException, IOException {
List<ListenableFuture<RemoteCommandResult>> result = Lists.newArrayList();
for (final Drone drone : ImmutableList.copyOf(drones)) {
result.add(mExecutor.submit(new Callable<RemoteCommandResult>() {
@Override
public RemoteCommandResult call() throws Exception {
Map<String, String> templateVariables = Maps.newHashMap(mTemplateDefaults);
templateVariables.put("instanceName", drone.getInstanceName());
templateVariables.put("localDir", drone.getLocalDirectory());
String command = Templates.getTemplateResult(cmd, templateVariables);
SSHResult result = new SSHCommand(mSSHCommandExecutor, drone.getPrivateKey(), drone.getUser(), drone.getHost(), drone.getInstance(), command, true).call();
if (result.getExitCode() != Constants.EXIT_CODE_SUCCESS) {
// return value not checked due to concurrent access
mDrones.remove(drone);
mLogger.error("Aborting drone during exec " + command, new AbortDroneException("Drone " + drone + " exited with " + result.getExitCode() + ": " + result));
return null;
} else {
return result;
}
}
}));
}
return result;
}
Aggregations