Package org.elasticsearch.client.sniff
Class Sniffer
- java.lang.Object
-
- org.elasticsearch.client.sniff.Sniffer
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class Sniffer extends java.lang.Object implements java.io.Closeable
Class responsible for sniffing nodes from some source (default is elasticsearch itself) and setting them to a provided instance ofRestClient
. Must be created viaSnifferBuilder
, which allows to set all of the different options or rely on defaults. A background task fetches the nodes through theNodesSniffer
and sets them to theRestClient
instance. It is possible to perform sniffing on failure by creating aSniffOnFailureListener
and providing it as an argument toRestClientBuilder.setFailureListener(RestClient.FailureListener)
. The Sniffer implementation needs to be lazily set to the previously created SniffOnFailureListener throughSniffOnFailureListener.setSniffer(Sniffer)
.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SnifferBuilder
builder(RestClient restClient)
Returns a newSnifferBuilder
to help withSniffer
creation.void
close()
void
sniffOnFailure()
Schedule sniffing to run as soon as possible if it isn't already running.
-
-
-
Method Detail
-
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:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
-
builder
public static SnifferBuilder builder(RestClient restClient)
Returns a newSnifferBuilder
to help withSniffer
creation.- Parameters:
restClient
- the client that gets its hosts set (viaRestClient.setNodes(Collection)
) once they are fetched- Returns:
- a new instance of
SnifferBuilder
-
-