HostsSniffer
public final class ElasticsearchHostsSniffer extends java.lang.Object implements HostsSniffer
Modifier and Type | Class | Description |
---|---|---|
static class |
ElasticsearchHostsSniffer.Scheme |
Modifier and Type | Field | Description |
---|---|---|
static long |
DEFAULT_SNIFF_REQUEST_TIMEOUT |
Constructor | Description |
---|---|
ElasticsearchHostsSniffer(RestClient restClient) |
Creates a new instance of the Elasticsearch sniffer.
|
ElasticsearchHostsSniffer(RestClient restClient,
long sniffRequestTimeoutMillis,
ElasticsearchHostsSniffer.Scheme scheme) |
Creates a new instance of the Elasticsearch sniffer.
|
Modifier and Type | Method | Description |
---|---|---|
java.util.List<org.apache.http.HttpHost> |
sniffHosts() |
Calls the elasticsearch nodes info api, parses the response and returns all the found http hosts
|
public ElasticsearchHostsSniffer(RestClient restClient)
RestClient
to fetch the hosts,
through the nodes info api, the default sniff request timeout value DEFAULT_SNIFF_REQUEST_TIMEOUT
and http
as the scheme for all the hosts.restClient
- client used to fetch the hosts from elasticsearch through nodes info api. Usually the same instance
that is also provided to Sniffer.builder(RestClient)
, so that the hosts are set to the same
client that was used to fetch them.public ElasticsearchHostsSniffer(RestClient restClient, long sniffRequestTimeoutMillis, ElasticsearchHostsSniffer.Scheme scheme)
RestClient
to fetch the hosts
through the nodes info api, the provided sniff request timeout value and scheme.restClient
- client used to fetch the hosts from elasticsearch through nodes info api. Usually the same instance
that is also provided to Sniffer.builder(RestClient)
, so that the hosts are set to the same
client that was used to sniff them.sniffRequestTimeoutMillis
- the sniff request timeout (in milliseconds) to be passed in as a query string parameter
to elasticsearch. Allows to halt the request without any failure, as only the nodes
that have responded within this timeout will be returned.scheme
- the scheme to associate sniffed nodes with (as it is not returned by elasticsearch)public java.util.List<org.apache.http.HttpHost> sniffHosts() throws java.io.IOException
sniffHosts
in interface HostsSniffer
java.io.IOException