use of org.apache.camel.component.etcd.EtcdConfiguration in project camel by apache.
the class EtcdServiceDiscovery method getServices.
protected List<ServiceDefinition> getServices(Predicate<EtcdServiceDefinition> filter) {
List<ServiceDefinition> servers = Collections.emptyList();
if (isRunAllowed()) {
try {
final EtcdConfiguration conf = getConfiguration();
final EtcdKeyGetRequest request = getClient().get(conf.getServicePath()).recursive();
if (conf.hasTimeout()) {
request.timeout(conf.getTimeout(), TimeUnit.SECONDS);
}
final EtcdKeysResponse response = request.send().get();
if (Objects.nonNull(response.node) && !response.node.nodes.isEmpty()) {
servers = response.node.nodes.stream().map(node -> node.value).filter(ObjectHelper::isNotEmpty).map(this::nodeFromString).filter(Objects::nonNull).filter(filter).sorted(EtcdServiceDefinition.COMPARATOR).collect(Collectors.toList());
}
} catch (Exception e) {
throw new RuntimeCamelException(e);
}
}
return servers;
}
Aggregations