use of io.netty.handler.timeout.TimeoutException in project druid by druid-io.
the class WorkerTaskRunnerQueryAdapter method sendRequestToWorker.
private void sendRequestToWorker(String workerHost, WorkerTaskRunner.ActionType action) {
WorkerTaskRunner workerTaskRunner = getWorkerTaskRunner();
if (workerTaskRunner == null) {
throw new RE("Task Runner does not support enable/disable worker actions");
}
Optional<ImmutableWorkerInfo> workerInfo = Iterables.tryFind(workerTaskRunner.getWorkers(), entry -> entry.getWorker().getHost().equals(workerHost));
if (!workerInfo.isPresent()) {
throw new RE("Worker on host %s does not exists", workerHost);
}
String actionName = WorkerTaskRunner.ActionType.ENABLE.equals(action) ? "enable" : "disable";
final URL workerUrl = TaskRunnerUtils.makeWorkerURL(workerInfo.get().getWorker(), "/druid/worker/v1/%s", actionName);
try {
final StatusResponseHolder response = httpClient.go(new Request(HttpMethod.POST, workerUrl), StatusResponseHandler.getInstance()).get();
log.info("Sent %s action request to worker: %s, status: %s, response: %s", action, workerHost, response.getStatus(), response.getContent());
if (!HttpResponseStatus.OK.equals(response.getStatus())) {
throw new RE("Action [%s] failed for worker [%s] with status %s(%s)", action, workerHost, response.getStatus().getCode(), response.getStatus().getReasonPhrase());
}
} catch (ExecutionException | InterruptedException | TimeoutException e) {
Throwables.propagate(e);
}
}
Aggregations