use of io.airlift.discovery.client.ServiceDescriptors in project airlift by airlift.
the class InMemoryDiscoveryClient method getServices.
@Override
public CheckedFuture<ServiceDescriptors, DiscoveryException> getServices(String type, String pool) {
requireNonNull(type, "type is null");
requireNonNull(pool, "pool is null");
ImmutableList.Builder<ServiceDescriptor> builder = ImmutableList.builder();
for (ServiceDescriptor serviceDescriptor : this.announcements.get()) {
if (serviceDescriptor.getType().equals(type) && serviceDescriptor.getPool().equals(pool)) {
builder.add(serviceDescriptor);
}
}
for (ServiceDescriptor serviceDescriptor : this.discovered.values()) {
if (serviceDescriptor.getType().equals(type) && serviceDescriptor.getPool().equals(pool)) {
builder.add(serviceDescriptor);
}
}
return Futures.immediateCheckedFuture(new ServiceDescriptors(type, pool, builder.build(), maxAge, UUID.randomUUID().toString()));
}
use of io.airlift.discovery.client.ServiceDescriptors in project airlift by airlift.
the class SimpleServiceSelector method selectAllServices.
@Override
public List<ServiceDescriptor> selectAllServices() {
try {
ListenableFuture<ServiceDescriptors> future = lookupClient.getServices(type, pool);
ServiceDescriptors serviceDescriptors = getFutureValue(future, DiscoveryException.class);
return serviceDescriptors.getServiceDescriptors();
} catch (DiscoveryException e) {
log.error(e);
return ImmutableList.of();
}
}
Aggregations