/** * Execute against a cluster at a specific endpoint. */ private boolean run(final Namespace options, final Target target, final PrintStream out, final PrintStream err, final String username, final boolean json, final BufferedReader stdin) throws Exception { final HeliosClient client = Utils.getClient(target, err, username, options); if (client == null) { return false; } try { final int result = run(options, client, out, json, stdin); return result == 0; } catch (ExecutionException e) { final Throwable cause = e.getCause(); // if target is a domain, print message like // "Request timed out to master in ash.spotify.net (http://ash2-helios-a4.ash2.spotify.net)", // otherwise "Request timed out to master http://ash2-helios-a4.ash2.spotify.net:5800" if (cause instanceof TimeoutException) { err.println("Request timed out to master in " + target); } else { throw new RuntimeException(cause); } return false; } finally { client.close(); } }
throws ExecutionException, InterruptedException, IOException { final String name = options.getString(nameArg.getDest()); final List<HostSelector> hostSelectors = Utils.parseHostSelectors(options, hostSelectorsArg); final boolean quiet = options.getBoolean(quietArg.getDest());
final boolean confirmed = Utils.userConfirmed(out, stdin); if (!confirmed) { return 1;
options.getString(dockerCertPathArg.getDest())); final Map<String, String> envVars = argToStringMap(options, envArg); final Map<String, String> labels; try { labels = argToStringMap(options, labelsArg); } catch (IllegalArgumentException e) { throw new IllegalArgumentException(e.getMessage()
selectedLabels = argToStringMap(options, labelsArg); } catch (IllegalArgumentException e) { throw new IllegalArgumentException(e.getMessage() + sorted.putAll(allAsMap(statuses)); out.println(Json.asPrettyStringUnchecked(sorted)); } else {
@Override protected int runWithJob(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final Job job, final BufferedReader stdin) throws ExecutionException, InterruptedException, IOException { final JobId jobId = job.getId(); final List<String> hosts = options.getList(hostsArg.getDest()); final Deployment deployment = new Deployment.Builder() .setGoal(Goal.START) .setJobId(jobId) .build(); if (!json) { out.printf("Starting %s on %s%n", jobId, hosts); } return Utils.setGoalOnHosts(client, out, json, hosts, deployment, options.getString(tokenArg.getDest())); } }
private static Map<JobId, JobStatus> getStatuses(final HeliosClient client, final Set<JobId> jobIds) throws ExecutionException, InterruptedException { final Map<JobId, ListenableFuture<JobStatus>> futures = getJobsStatuses(client, jobIds); final Map<JobId, JobStatus> statuses = Maps.newTreeMap(); statuses.putAll(allAsMap(futures)); return statuses; } }
out.printf("Hostname: %s%n", job.getHostname()); out.printf("Command: %s%n", quote(job.getCommand())); printMap(out, "Env: ", QUOTE, job.getEnv()); out.printf("Health check: %s%n", formatHealthCheck(job.getHealthCheck())); out.printf("Grace period (seconds): %s%n", job.getGracePeriod()); out.printf("Time to wait before kill (seconds): %s%n", job.getSecondsToWaitBeforeKill()); printMap(out, "Metadata: ", QUOTE, job.getMetadata()); printMap(out, "Ports: ", FORMAT_PORTMAPPING, job.getPorts()); printMap(out, "Reg: ", FORMAT_SERVICE_PORTS, job.getRegistration()); out.printf("Security options: %s%n", job.getSecurityOpt()); out.printf("Network mode: %s%n", job.getNetworkMode());
public static HeliosClient getClient(final Target target, final PrintStream err, final String username, final Namespace options) { List<URI> endpoints = Collections.emptyList(); try { endpoints = target.getEndpointSupplier().get(); } catch (Exception ignore) { // TODO (dano): Nasty. Refactor target to propagate resolution failure in a checked manner. } if (endpoints.size() == 0) { err.println("Failed to resolve helios master in " + target); return null; } //argparse4j converts names like "--http-timeout" to dests of "http_timeout" final int httpTimeout = parseTimeout(options, "http_timeout", HTTP_TIMEOUT_ENV_VAR, DEFAULT_HTTP_TIMEOUT_SECS); final int retryTimeout = parseTimeout(options, "retry_timeout", TOTAL_TIMEOUT_ENV_VAR, DEFAULT_TOTAL_TIMEOUT_SECS); log.debug("using HeliosClient httpTimeout={}, retryTimeout={}", httpTimeout, retryTimeout); return HeliosClient.newBuilder() .setEndpointSupplier(Endpoints.of(target.getEndpointSupplier())) .setHttpTimeout(httpTimeout, TimeUnit.SECONDS) .setRetryTimeout(retryTimeout, TimeUnit.SECONDS) .setSslHostnameVerification(!options.getBoolean("insecure")) .setGoogleCredentialsEnabled(options.getBoolean("google_credentials")) .setUser(username) .build(); }
options.getString(dockerCertPathArg.getDest())); final Map<String, String> envVars = argToStringMap(options, envArg); final Map<String, String> labels; try { labels = argToStringMap(options, labelsArg); } catch (IllegalArgumentException e) { throw new IllegalArgumentException(e.getMessage() +
@Override protected int runWithJob(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final Job job, final BufferedReader stdin) throws ExecutionException, InterruptedException, IOException { final JobId jobId = job.getId(); final List<String> hosts = options.getList(hostsArg.getDest()); final Deployment deployment = new Deployment.Builder() .setGoal(Goal.STOP) .setJobId(jobId) .build(); if (!json) { out.printf("Stopping %s on %s%n", jobId, hosts); } return Utils.setGoalOnHosts(client, out, json, hosts, deployment, options.getString(tokenArg.getDest())); } }
JobStatusFetcher.getJobsStatuses(client, jobIds); final Map<JobId, JobStatus> statuses = Maps.newTreeMap(); statuses.putAll(allAsMap(futures));
final boolean confirmed = Utils.userConfirmed(out, stdin); if (!confirmed) { return 1;
final HeliosClient client = Utils.getClient(target, err, username, options); if (client == null) { return 1;
throws ExecutionException, InterruptedException, IOException { final String name = options.getString(nameArg.getDest()); final List<HostSelector> hostSelectors = Utils.parseHostSelectors(options, hostSelectorsArg); final boolean quiet = options.getBoolean(quietArg.getDest());
final boolean confirmed = Utils.userConfirmed(out, stdin); if (!confirmed) { return 1;
/** * Execute against a cluster at a specific endpoint * @param stdin TODO */ private boolean run(final Namespace options, final Target target, final PrintStream out, final PrintStream err, final String username, final boolean json, final BufferedReader stdin) throws InterruptedException, IOException { final HeliosClient client = Utils.getClient(target, err, username); if (client == null) { return false; } try { final int result = run(options, client, out, json, stdin); return result == 0; } catch (ExecutionException e) { final Throwable cause = e.getCause(); // if target is a domain, print message like // "Request timed out to master in ash.spotify.net (http://ash2-helios-a4.ash2.spotify.net)", // otherwise "Request timed out to master http://ash2-helios-a4.ash2.spotify.net:5800" if (cause instanceof TimeoutException) { err.println("Request timed out to master in " + target); } else { throw Throwables.propagate(cause); } return false; } finally { client.close(); } }
final boolean confirmed = Utils.userConfirmed(out, stdin); if (!confirmed) { return 1;
final HeliosClient client = Utils.getClient(target, err, username); if (client == null) { return 1;
final boolean confirmed = Utils.userConfirmed(out, stdin); if (!confirmed) { return 1;