Class MockTransport

java.lang.Object
org.elasticsearch.test.transport.StubbableTransport
org.elasticsearch.test.transport.MockTransport
All Implemented Interfaces:
java.io.Closeable, java.lang.AutoCloseable, org.elasticsearch.common.component.LifecycleComponent, org.elasticsearch.common.lease.Releasable, org.elasticsearch.transport.Transport
Direct Known Subclasses:
CapturingTransport, DisruptableMockTransport

public class MockTransport
extends StubbableTransport
A basic transport implementation that allows to intercept requests that have been sent
  • Constructor Details

  • Method Details

    • createTransportService

      public org.elasticsearch.transport.TransportService createTransportService​(org.elasticsearch.common.settings.Settings settings, org.elasticsearch.threadpool.ThreadPool threadPool, org.elasticsearch.transport.TransportInterceptor interceptor, java.util.function.Function<org.elasticsearch.common.transport.BoundTransportAddress,​org.elasticsearch.cluster.node.DiscoveryNode> localNodeFactory, @Nullable org.elasticsearch.common.settings.ClusterSettings clusterSettings, java.util.Set<java.lang.String> taskHeaders)
    • handleResponse

      public <Response extends org.elasticsearch.transport.TransportResponse> void handleResponse​(long requestId, Response response)
      simulate a response for the given requestId
    • handleLocalError

      public void handleLocalError​(long requestId, java.lang.Throwable t)
      simulate a local error for the given requestId, will be wrapped by a SendRequestTransportException
      Parameters:
      requestId - the id corresponding to the captured send request
      t - the failure to wrap
    • handleRemoteError

      public void handleRemoteError​(long requestId, java.lang.Throwable t)
      simulate a remote error for the given requestId, will be wrapped by a RemoteTransportException
      Parameters:
      requestId - the id corresponding to the captured send request
      t - the failure to wrap
    • handleError

      public void handleError​(long requestId, org.elasticsearch.transport.TransportException e)
      simulate an error for the given requestId, unlike handleLocalError(long, Throwable) and handleRemoteError(long, Throwable), the provided exception will not be wrapped but will be delivered to the transport layer as is
      Parameters:
      requestId - the id corresponding to the captured send request
      e - the failure
    • createConnection

      public org.elasticsearch.transport.Transport.Connection createConnection​(org.elasticsearch.cluster.node.DiscoveryNode node)
    • onSendRequest

      protected void onSendRequest​(long requestId, java.lang.String action, org.elasticsearch.transport.TransportRequest request, org.elasticsearch.cluster.node.DiscoveryNode node)
    • setMessageListener

      public void setMessageListener​(org.elasticsearch.transport.TransportMessageListener listener)
      Specified by:
      setMessageListener in interface org.elasticsearch.transport.Transport
      Overrides:
      setMessageListener in class StubbableTransport
    • writeableRegistry

      protected org.elasticsearch.common.io.stream.NamedWriteableRegistry writeableRegistry()