use of com.facebook.airlift.http.client.Request in project presto by prestodb.
the class DistributedResourceGroupInfoResource method getResourceGroupInfoFromCoordinator.
private ListenableFuture<ResourceGroupInfo> getResourceGroupInfoFromCoordinator(UriInfo uriInfo, InternalNode coordinatorNode) throws IOException {
String scheme = uriInfo.getRequestUri().getScheme();
URI uri = uriInfo.getRequestUriBuilder().queryParam("includeLocalInfoOnly", true).scheme(scheme).host(coordinatorNode.getHostAndPort().toInetAddress().getHostName()).port(coordinatorNode.getInternalUri().getPort()).build();
Request request = prepareGet().setUri(uri).build();
return httpClient.executeAsync(request, createJsonResponseHandler(jsonCodec));
}
use of com.facebook.airlift.http.client.Request in project presto by prestodb.
the class TestQueryStateInfoResource method setup.
@BeforeClass
public void setup() {
Request request1 = preparePost().setUri(uriBuilderFrom(server.getBaseUrl()).replacePath("/v1/statement").build()).setBodyGenerator(createStaticBodyGenerator(LONG_LASTING_QUERY, UTF_8)).setHeader(PRESTO_USER, "user1").build();
queryResults = client.execute(request1, createJsonResponseHandler(QUERY_RESULTS_JSON_CODEC));
client.execute(prepareGet().setUri(queryResults.getNextUri()).build(), createJsonResponseHandler(QUERY_RESULTS_JSON_CODEC));
Request request2 = preparePost().setUri(uriBuilderFrom(server.getBaseUrl()).replacePath("/v1/statement").build()).setBodyGenerator(createStaticBodyGenerator(LONG_LASTING_QUERY, UTF_8)).setHeader(PRESTO_USER, "user2").build();
QueryResults queryResults2 = client.execute(request2, createJsonResponseHandler(jsonCodec(QueryResults.class)));
client.execute(prepareGet().setUri(queryResults2.getNextUri()).build(), createJsonResponseHandler(QUERY_RESULTS_JSON_CODEC));
// queries are started in the background, so they may not all be immediately visible
while (true) {
List<BasicQueryInfo> queryInfos = client.execute(prepareGet().setUri(uriBuilderFrom(server.getBaseUrl()).replacePath("/v1/query").build()).build(), createJsonResponseHandler(listJsonCodec(BasicQueryInfo.class)));
if ((queryInfos.size() == 2) && queryInfos.stream().allMatch(info -> info.getState() == RUNNING)) {
break;
}
}
}
use of com.facebook.airlift.http.client.Request in project presto by prestodb.
the class HttpRpcShuffleClient method acknowledgeResultsAsync.
@Override
public void acknowledgeResultsAsync(long nextToken) {
URI uri = uriBuilderFrom(location).appendPath(String.valueOf(nextToken)).appendPath("acknowledge").build();
httpClient.executeAsync(prepareGet().setUri(uri).build(), new ResponseHandler<Void, RuntimeException>() {
@Override
public Void handleException(Request request, Exception exception) {
log.debug(exception, "Acknowledge request failed: %s", uri);
return null;
}
@Override
public Void handle(Request request, Response response) {
if (familyForStatusCode(response.getStatusCode()) != HttpStatus.Family.SUCCESSFUL) {
log.debug("Unexpected acknowledge response code: %s", response.getStatusCode());
}
return null;
}
});
}
use of com.facebook.airlift.http.client.Request in project presto by prestodb.
the class BenchmarkQueryRunner method getAllNodes.
private List<URI> getAllNodes(URI server) {
Request request = prepareGet().setUri(uriBuilderFrom(server).replacePath("/v1/service/presto").build()).build();
JsonResponseHandler<ServiceDescriptorsRepresentation> responseHandler = createJsonResponseHandler(jsonCodec(ServiceDescriptorsRepresentation.class));
ServiceDescriptorsRepresentation serviceDescriptors = httpClient.execute(request, responseHandler);
ImmutableList.Builder<URI> addresses = ImmutableList.builder();
for (ServiceDescriptor serviceDescriptor : serviceDescriptors.getServiceDescriptors()) {
String httpUri = serviceDescriptor.getProperties().get("http");
if (httpUri != null) {
addresses.add(URI.create(httpUri));
}
}
return addresses.build();
}
use of com.facebook.airlift.http.client.Request in project presto by prestodb.
the class DistributedQueryInfoResource method getQueryStateFromCoordinator.
private ListenableFuture<List<QueryStateInfo>> getQueryStateFromCoordinator(UriInfo uriInfo, InternalNode coordinatorNode) throws IOException {
URI uri = uriInfo.getRequestUriBuilder().queryParam("includeLocalQueryOnly", true).scheme(coordinatorNode.getInternalUri().getScheme()).host(coordinatorNode.getHostAndPort().toInetAddress().getHostName()).port(coordinatorNode.getInternalUri().getPort()).build();
Request request = prepareGet().setUri(uri).build();
return httpClient.executeAsync(request, createJsonResponseHandler(jsonCodec));
}
Aggregations