Package org.elasticsearch.client.sniff
Class Sniffer
java.lang.Object
org.elasticsearch.client.sniff.Sniffer
- All Implemented Interfaces:
Closeable,AutoCloseable
Class responsible for sniffing nodes from some source (default is elasticsearch itself) and setting them to a provided instance of
RestClient. Must be created via SnifferBuilder, which allows to set all of the different options or rely on defaults.
A background task fetches the nodes through the NodesSniffer and sets them to the RestClient instance.
It is possible to perform sniffing on failure by creating a SniffOnFailureListener and providing it as an argument to
RestClientBuilder.setFailureListener(RestClient.FailureListener). The Sniffer implementation needs to be lazily set to the
previously created SniffOnFailureListener through SniffOnFailureListener.setSniffer(Sniffer).-
Method Summary
Modifier and TypeMethodDescriptionstatic SnifferBuilderbuilder(RestClient restClient) Returns a newSnifferBuilderto help withSniffercreation.voidclose()voidSchedule sniffing to run as soon as possible if it isn't already running.
-
Method Details
-
sniffOnFailure
public void sniffOnFailure()Schedule sniffing to run as soon as possible if it isn't already running. Once such sniffing round runs it will also schedule a new round after sniffAfterFailureDelay ms. -
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
builder
Returns a newSnifferBuilderto help withSniffercreation.- Parameters:
restClient- the client that gets its hosts set (viaRestClient.setNodes(Collection)) once they are fetched- Returns:
- a new instance of
SnifferBuilder
-