Class RestClientHttpClient

java.lang.Object
co.elastic.clients.transport.rest_client.RestClientHttpClient
All Implemented Interfaces:
TransportHttpClient

public class RestClientHttpClient extends Object implements TransportHttpClient
  • Constructor Details

    • RestClientHttpClient

      public RestClientHttpClient(org.elasticsearch.client.RestClient restClient)
  • Method Details

    • restClient

      public org.elasticsearch.client.RestClient restClient()
      Returns the underlying low level Rest Client used by this transport.
    • createOptions

      public RestClientOptions createOptions(@Nullable TransportOptions options)
      Description copied from interface: TransportHttpClient
      Create a client-specific options value from an existing option object. If null, this must create the default options to which additional options can be added.

      This method allows implementations to return subclasses with more features (that applications can use by downcasting the result). By default, it will use DefaultTransportOptions.

      Specified by:
      createOptions in interface TransportHttpClient
    • performRequest

      public TransportHttpClient.Response performRequest(String endpointId, @Nullable TransportHttpClient.Node node, TransportHttpClient.Request request, TransportOptions options) throws IOException
      Description copied from interface: TransportHttpClient
      Perform a blocking request.
      Specified by:
      performRequest in interface TransportHttpClient
      Parameters:
      endpointId - the endpoint identifier. Can be used to have specific strategies depending on the endpoint.
      node - the node to send the request to. If null, the implementation has to choose which node to send the request to, or throw an IllegalArgumentException.
      request - the request
      options - additional options for the http client. Headers and request parameters set in the options have precedence over those defined by the request and should replace them in the final request sent.
      Returns:
      the response
      Throws:
      IOException
    • performRequestAsync

      public CompletableFuture<TransportHttpClient.Response> performRequestAsync(String endpointId, @Nullable TransportHttpClient.Node node, TransportHttpClient.Request request, TransportOptions options)
      Description copied from interface: TransportHttpClient
      Perform an asynchronous request.

      Implementations should return a CompletableFuture whose cancellation also cancels any http request in flight and frees the associated resources. This allows applications to implement scenarios like timeouts or "first to respond" fan-out without leaking resources.

      Specified by:
      performRequestAsync in interface TransportHttpClient
      Parameters:
      endpointId - the endpoint identifier. Can be used to have specific strategies depending on the endpoint.
      node - the node to send the request to. If null, the implementation has to choose which node to send the request to, or throw an IllegalArgumentException.
      request - the request
      options - additional options for the http client. Headers and request parameters set in the options have precedence over those defined by the request and should replace them in the final request sent.
      Returns:
      a future that will be completed with the response.
    • close

      public void close() throws IOException
      Description copied from interface: TransportHttpClient
      Close this client, freeing associated resources.
      Specified by:
      close in interface TransportHttpClient
      Throws:
      IOException