private void asyncHealthcheck(final SingularityTask task) { final SingularityHealthcheckAsyncHandler handler = new SingularityHealthcheckAsyncHandler(exceptionNotifier, configuration, this, newTaskChecker, taskManager, task); final Optional<String> uri = getHealthcheckUri(task); if (!uri.isPresent()) { saveFailure(handler, "Invalid healthcheck uri or ports not present"); return; } final Integer timeoutSeconds = task.getTaskRequest().getDeploy().getHealthcheck().isPresent() ? task.getTaskRequest().getDeploy().getHealthcheck().get().getResponseTimeoutSeconds().or(configuration.getHealthcheckTimeoutSeconds()) : configuration.getHealthcheckTimeoutSeconds(); try { PerRequestConfig prc = new PerRequestConfig(); prc.setRequestTimeoutInMs((int) TimeUnit.SECONDS.toMillis(timeoutSeconds)); RequestBuilder builder = new RequestBuilder("GET"); builder.setFollowRedirects(true); builder.setUrl(uri.get()); builder.setPerRequestConfig(prc); LOG.trace("Issuing a healthcheck ({}) for task {} with timeout {}s", uri.get(), task.getTaskId(), timeoutSeconds); http.prepareRequest(builder.build()).execute(handler); } catch (Throwable t) { LOG.debug("Exception while preparing healthcheck ({}) for task ({})", uri, task.getTaskId(), t); exceptionNotifier.notify(String.format("Error preparing healthcheck (%s)", t.getMessage()), t, ImmutableMap.of("taskId", task.getTaskId().toString())); saveFailure(handler, String.format("Healthcheck failed due to exception: %s", t.getMessage())); } }
AsyncHttpClient.BoundRequestBuilder requestBuilder = asyncHttpClient.prepareRequest(builder.build());
private void asyncHealthcheck(final SingularityTask task) { final SingularityHealthcheckAsyncHandler handler = new SingularityHealthcheckAsyncHandler(exceptionNotifier, configuration, this, newTaskChecker, taskManager, task); final Optional<String> uri = getHealthcheckUri(task); if (!uri.isPresent()) { saveFailure(handler, "Invalid healthcheck uri or ports not present"); return; } final Integer timeoutSeconds = task.getTaskRequest().getDeploy().getHealthcheck().isPresent() ? task.getTaskRequest().getDeploy().getHealthcheck().get().getResponseTimeoutSeconds().or(configuration.getHealthcheckTimeoutSeconds()) : configuration.getHealthcheckTimeoutSeconds(); try { PerRequestConfig prc = new PerRequestConfig(); prc.setRequestTimeoutInMs((int) TimeUnit.SECONDS.toMillis(timeoutSeconds)); RequestBuilder builder = new RequestBuilder("GET"); builder.setFollowRedirects(true); builder.setUrl(uri.get()); builder.setPerRequestConfig(prc); LOG.trace("Issuing a healthcheck ({}) for task {} with timeout {}s", uri.get(), task.getTaskId(), timeoutSeconds); http.prepareRequest(builder.build()).execute(handler); } catch (Throwable t) { LOG.debug("Exception while preparing healthcheck ({}) for task ({})", uri, task.getTaskId(), t); exceptionNotifier.notify(String.format("Error preparing healthcheck (%s)", t.getMessage()), t, ImmutableMap.of("taskId", task.getTaskId().toString())); saveFailure(handler, String.format("Healthcheck failed due to exception: %s", t.getMessage())); } }
try { transportInUse.future(new FutureProxy<ListenableFuture>(this, options.runtime().prepareRequest(r.build()).execute((AsyncHandler<WebSocket>) transportInUse))); r.setUrl(httpUrl(request.uri())); transportInUse.future(new FutureProxy<ListenableFuture>(this, options.runtime().prepareRequest(r.build()).execute((AsyncHandler<String>) transportInUse)));
try { transportInUse.future(new FutureProxy<ListenableFuture>(this, options.runtime().prepareRequest(r.build()).execute((AsyncHandler<WebSocket>) transportInUse))); r.setUrl(httpUrl(request.uri())); transportInUse.future(new FutureProxy<ListenableFuture>(this, options.runtime().prepareRequest(r.build()).execute((AsyncHandler<String>) transportInUse)));
protected void doCloseRequest() { ((DefaultOptions) options).b.reconnect(false); List<String> uuid = decodeQueryString(request).get("X-Atmosphere-tracking-id"); if (!closedByProtocol.getAndSet(true)) { RequestBuilder r = new RequestBuilder(); FluentStringsMap f = new FluentStringsMap(); f.add("X-Atmosphere-Transport", "close").add("X-Atmosphere-tracking-id", uuid); r.setUrl(request.uri()) .setMethod("GET") .setHeaders(request.headers()) .setQueryParams(f); try { options.runtime().prepareRequest(r.build()).execute().get(); } catch (Exception e) { logger.debug("Was unable to send the close request {}", uuid); logger.trace("", e); } } }
protected void doCloseRequest() { ((DefaultOptions) options).b.reconnect(false); List<String> uuid = decodeQueryString(request).get("X-Atmosphere-tracking-id"); if (!closedByProtocol.getAndSet(true)) { RequestBuilder r = new RequestBuilder(); FluentStringsMap f = new FluentStringsMap(); f.add("X-Atmosphere-Transport", "close").add("X-Atmosphere-tracking-id", uuid); r.setUrl(request.uri()) .setMethod("GET") .setHeaders(request.headers()) .setQueryParams(f); try { options.runtime().prepareRequest(r.build()).execute().get(); } catch (Exception e) { logger.debug("Was unable to send the close request {}", uuid); logger.trace("", e); } } }