Search in sources :

Example 1 with SnifferBuilder

use of org.elasticsearch.client.sniff.SnifferBuilder in project quarkus by quarkusio.

the class RestClientBuilderHelper method createSniffer.

public static Sniffer createSniffer(RestClient client, ElasticsearchConfig config) {
    SnifferBuilder builder = Sniffer.builder(client).setSniffIntervalMillis((int) config.discovery.refreshInterval.toMillis());
    // https discovery support
    if ("https".equalsIgnoreCase(config.protocol)) {
        NodesSniffer hostsSniffer = new ElasticsearchNodesSniffer(client, // 1sec
        ElasticsearchNodesSniffer.DEFAULT_SNIFF_REQUEST_TIMEOUT, ElasticsearchNodesSniffer.Scheme.HTTPS);
        builder.setNodesSniffer(hostsSniffer);
    }
    return builder.build();
}
Also used : SnifferBuilder(org.elasticsearch.client.sniff.SnifferBuilder) NodesSniffer(org.elasticsearch.client.sniff.NodesSniffer) ElasticsearchNodesSniffer(org.elasticsearch.client.sniff.ElasticsearchNodesSniffer) ElasticsearchNodesSniffer(org.elasticsearch.client.sniff.ElasticsearchNodesSniffer)

Example 2 with SnifferBuilder

use of org.elasticsearch.client.sniff.SnifferBuilder 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

ElasticsearchNodesSniffer (org.elasticsearch.client.sniff.ElasticsearchNodesSniffer)2 NodesSniffer (org.elasticsearch.client.sniff.NodesSniffer)2 SnifferBuilder (org.elasticsearch.client.sniff.SnifferBuilder)2