Search in sources :

Example 11 with NodesSniffer

use of org.elasticsearch.client.sniff.NodesSniffer in project hibernate-search by hibernate.

the class ElasticsearchClientFactoryImpl method createSniffer.

private Sniffer createSniffer(ConfigurationPropertySource propertySource, RestClient client, ServerUris hosts) {
    boolean discoveryEnabled = DISCOVERY_ENABLED.get(propertySource);
    if (discoveryEnabled) {
        SnifferBuilder builder = Sniffer.builder(client).setSniffIntervalMillis(DISCOVERY_REFRESH_INTERVAL.get(propertySource) * // The configured value is in seconds
        1_000);
        // https discovery support
        if (hosts.isSslEnabled()) {
            NodesSniffer hostsSniffer = new ElasticsearchNodesSniffer(client, // 1sec
            ElasticsearchNodesSniffer.DEFAULT_SNIFF_REQUEST_TIMEOUT, ElasticsearchNodesSniffer.Scheme.HTTPS);
            builder.setNodesSniffer(hostsSniffer);
        }
        return builder.build();
    } else {
        return null;
    }
}
Also used : SnifferBuilder(org.elasticsearch.client.sniff.SnifferBuilder) ElasticsearchNodesSniffer(org.elasticsearch.client.sniff.ElasticsearchNodesSniffer) NodesSniffer(org.elasticsearch.client.sniff.NodesSniffer) ElasticsearchNodesSniffer(org.elasticsearch.client.sniff.ElasticsearchNodesSniffer)

Aggregations

NodesSniffer (org.graylog.shaded.elasticsearch7.org.elasticsearch.client.sniff.NodesSniffer)8 Node (org.graylog.shaded.elasticsearch7.org.elasticsearch.client.Node)6 Test (org.junit.jupiter.api.Test)6 ElasticsearchNodesSniffer (org.elasticsearch.client.sniff.ElasticsearchNodesSniffer)3 NodesSniffer (org.elasticsearch.client.sniff.NodesSniffer)3 SnifferBuilder (org.elasticsearch.client.sniff.SnifferBuilder)2 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)1 UsernamePasswordCredentials (org.apache.http.auth.UsernamePasswordCredentials)1 CredentialsProvider (org.apache.http.client.CredentialsProvider)1 BasicCredentialsProvider (org.apache.http.impl.client.BasicCredentialsProvider)1 RestClientBuilder (org.elasticsearch.client.RestClientBuilder)1 RestHighLevelClient (org.elasticsearch.client.RestHighLevelClient)1 SniffOnFailureListener (org.elasticsearch.client.sniff.SniffOnFailureListener)1 Sniffer (org.elasticsearch.client.sniff.Sniffer)1 ElasticsearchNodesSniffer (org.graylog.shaded.elasticsearch7.org.elasticsearch.client.sniff.ElasticsearchNodesSniffer)1