Package org.elasticsearch.client.sniff
Class ElasticsearchNodesSniffer
- java.lang.Object
-
- org.elasticsearch.client.sniff.ElasticsearchNodesSniffer
-
- All Implemented Interfaces:
NodesSniffer
public final class ElasticsearchNodesSniffer extends java.lang.Object implements NodesSniffer
Class responsible for sniffing the http hosts from elasticsearch through the nodes info api and returning them back. Compatible with elasticsearch 2.x+.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ElasticsearchNodesSniffer.Scheme
-
Field Summary
Fields Modifier and Type Field Description static long
DEFAULT_SNIFF_REQUEST_TIMEOUT
-
Constructor Summary
Constructors Constructor Description ElasticsearchNodesSniffer(RestClient restClient)
Creates a new instance of the Elasticsearch sniffer.ElasticsearchNodesSniffer(RestClient restClient, long sniffRequestTimeoutMillis, ElasticsearchNodesSniffer.Scheme scheme)
Creates a new instance of the Elasticsearch sniffer.
-
-
-
Constructor Detail
-
ElasticsearchNodesSniffer
public ElasticsearchNodesSniffer(RestClient restClient)
Creates a new instance of the Elasticsearch sniffer. It will use the providedRestClient
to fetch the hosts, through the nodes info api, the default sniff request timeout valueDEFAULT_SNIFF_REQUEST_TIMEOUT
and http as the scheme for all the hosts.- Parameters:
restClient
- client used to fetch the hosts from elasticsearch through nodes info api. Usually the same instance that is also provided toSniffer.builder(RestClient)
, so that the hosts are set to the same client that was used to fetch them.
-
ElasticsearchNodesSniffer
public ElasticsearchNodesSniffer(RestClient restClient, long sniffRequestTimeoutMillis, ElasticsearchNodesSniffer.Scheme scheme)
Creates a new instance of the Elasticsearch sniffer. It will use the providedRestClient
to fetch the hosts through the nodes info api, the provided sniff request timeout value and scheme.- Parameters:
restClient
- client used to fetch the hosts from elasticsearch through nodes info api. Usually the same instance that is also provided toSniffer.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)
-
-
Method Detail
-
sniff
public java.util.List<Node> sniff() throws java.io.IOException
Calls the elasticsearch nodes info api, parses the response and returns all the found http hosts- Specified by:
sniff
in interfaceNodesSniffer
- Throws:
java.io.IOException
-
-