Search in sources :

Example 1 with ServiceDescriptorsRepresentation

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

Aggregations

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