Class OpenSearchNodesSniffer

java.lang.Object
org.opensearch.client.sniff.OpenSearchNodesSniffer
All Implemented Interfaces:
NodesSniffer

public final class OpenSearchNodesSniffer
extends java.lang.Object
implements NodesSniffer
Class responsible for sniffing the http hosts from opensearch through the nodes info api and returning them back.
  • Nested Class Summary

    Nested Classes 
    Modifier and Type Class Description
    static class  OpenSearchNodesSniffer.Scheme  
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static long DEFAULT_SNIFF_REQUEST_TIMEOUT  
  • Constructor Summary

    Constructors 
    Constructor Description
    OpenSearchNodesSniffer​(org.opensearch.client.RestClient restClient)
    Creates a new instance of the OpenSearch sniffer.
    OpenSearchNodesSniffer​(org.opensearch.client.RestClient restClient, long sniffRequestTimeoutMillis, OpenSearchNodesSniffer.Scheme scheme)
    Creates a new instance of the OpenSearch sniffer.
  • Method Summary

    Modifier and Type Method Description
    java.util.List<org.opensearch.client.Node> sniff()
    Calls the opensearch nodes info api, parses the response and returns all the found http hosts

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • OpenSearchNodesSniffer

      public OpenSearchNodesSniffer​(org.opensearch.client.RestClient restClient)
      Creates a new instance of the OpenSearch sniffer. It will use the provided 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.
      Parameters:
      restClient - client used to fetch the hosts from opensearch 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.
    • OpenSearchNodesSniffer

      public OpenSearchNodesSniffer​(org.opensearch.client.RestClient restClient, long sniffRequestTimeoutMillis, OpenSearchNodesSniffer.Scheme scheme)
      Creates a new instance of the OpenSearch sniffer. It will use the provided RestClient 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 opensearch 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 opensearch. 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 opensearch)
  • Method Details

    • sniff

      public java.util.List<org.opensearch.client.Node> sniff() throws java.io.IOException
      Calls the opensearch nodes info api, parses the response and returns all the found http hosts
      Specified by:
      sniff in interface NodesSniffer
      Throws:
      java.io.IOException