Search in sources :

Example 1 with StatusResponse

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;
    }
}
Also used : Request(io.airlift.http.client.Request) StatusResponse(io.airlift.http.client.StatusResponseHandler.StatusResponse) ExecutionException(java.util.concurrent.ExecutionException) URI(java.net.URI) TimeoutException(java.util.concurrent.TimeoutException)

Aggregations

Request (io.airlift.http.client.Request)1 StatusResponse (io.airlift.http.client.StatusResponseHandler.StatusResponse)1 URI (java.net.URI)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1