Search in sources :

Example 1 with ServiceDescriptorsRepresentation

use of com.facebook.airlift.discovery.client.ServiceDescriptorsRepresentation 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();
}
Also used : ServiceDescriptorsRepresentation(com.facebook.airlift.discovery.client.ServiceDescriptorsRepresentation) ServiceDescriptor(com.facebook.airlift.discovery.client.ServiceDescriptor) ImmutableList(com.google.common.collect.ImmutableList) Request(com.facebook.airlift.http.client.Request) URI(java.net.URI)

Aggregations

ServiceDescriptor (com.facebook.airlift.discovery.client.ServiceDescriptor)1 ServiceDescriptorsRepresentation (com.facebook.airlift.discovery.client.ServiceDescriptorsRepresentation)1 Request (com.facebook.airlift.http.client.Request)1 ImmutableList (com.google.common.collect.ImmutableList)1 URI (java.net.URI)1