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(); }