java.lang.Object
co.elastic.clients.transport.rest5_client.low_level.sniffer.Sniffer
All Implemented Interfaces:
Closeable, AutoCloseable

public class Sniffer extends Object implements Closeable
Class responsible for sniffing nodes from some source (default is elasticsearch itself) and setting them to a provided instance of Rest5Client. 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 Rest5Client instance. It is possible to perform sniffing on failure by creating a SniffOnFailureListener and providing it as an argument to Rest5ClientBuilder.setFailureListener(Rest5Client.FailureListener). The Sniffer implementation needs to be lazily set to the previously created SniffOnFailureListener through SniffOnFailureListener.setSniffer(Sniffer).
  • 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:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • builder

      public static SnifferBuilder builder(Rest5Client restClient)
      Returns a new SnifferBuilder to help with Sniffer creation.
      Parameters:
      restClient - the client that gets its hosts set (via Rest5Client.setNodes(Collection)) once they are fetched
      Returns:
      a new instance of SnifferBuilder