Search in sources :

Example 1 with NoReachableHostException

use of org.springframework.data.elasticsearch.client.NoReachableHostException in project spring-data-elasticsearch by spring-projects.

the class SingleNodeHostProvider method lookupActiveHost.

/*
	 * (non-Javadoc)
	 * @see org.springframework.data.elasticsearch.client.reactive.HostProvider#lookupActiveHost(org.springframework.data.elasticsearch.client.reactive.HostProvider.Verification)
	 */
@Override
public Mono<InetSocketAddress> lookupActiveHost(Verification verification) {
    if (Verification.LAZY.equals(verification) && state.isOnline()) {
        return Mono.just(endpoint);
    }
    return clusterInfo().handle((information, sink) -> {
        ElasticsearchHost host = information.getNodes().iterator().next();
        if (host.isOnline()) {
            sink.next(host.getEndpoint());
            return;
        }
        sink.error(new NoReachableHostException(Collections.singleton(host)));
    });
}
Also used : ElasticsearchHost(org.springframework.data.elasticsearch.client.ElasticsearchHost) NoReachableHostException(org.springframework.data.elasticsearch.client.NoReachableHostException)

Aggregations

ElasticsearchHost (org.springframework.data.elasticsearch.client.ElasticsearchHost)1 NoReachableHostException (org.springframework.data.elasticsearch.client.NoReachableHostException)1