use of io.airlift.http.client.StatusResponseHandler.StatusResponse in project presto by prestodb.
the class StatementClient method cancelLeafStage.
public boolean cancelLeafStage(Duration timeout) {
checkState(!isClosed(), "client is closed");
URI uri = current().getPartialCancelUri();
if (uri == null) {
return false;
}
Request request = prepareRequest(prepareDelete(), uri).build();
HttpResponseFuture<StatusResponse> response = httpClient.executeAsync(request, createStatusResponseHandler());
try {
StatusResponse status = response.get(timeout.toMillis(), MILLISECONDS);
return familyForStatusCode(status.getStatusCode()) == Family.SUCCESSFUL;
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw Throwables.propagate(e);
} catch (ExecutionException e) {
throw Throwables.propagate(e.getCause());
} catch (TimeoutException e) {
return false;
}
}
Aggregations