Search in sources :

Example 1 with SSHResult

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;
}
Also used : SSHResult(org.apache.hive.ptest.execution.ssh.SSHResult) SSHCommand(org.apache.hive.ptest.execution.ssh.SSHCommand) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) Callable(java.util.concurrent.Callable)

Aggregations

ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 Callable (java.util.concurrent.Callable)1 SSHCommand (org.apache.hive.ptest.execution.ssh.SSHCommand)1 SSHResult (org.apache.hive.ptest.execution.ssh.SSHResult)1