Package org.elasticsearch.test.transport
Class MockTransport
java.lang.Object
org.elasticsearch.test.transport.StubbableTransport
org.elasticsearch.test.transport.MockTransport
- All Implemented Interfaces:
Closeable
,AutoCloseable
,org.elasticsearch.common.component.LifecycleComponent
,org.elasticsearch.core.Releasable
,org.elasticsearch.transport.Transport
- Direct Known Subclasses:
CapturingTransport
,DisruptableMockTransport
A basic transport implementation that allows to intercept requests that have been sent
-
Nested Class Summary
Nested classes/interfaces inherited from class org.elasticsearch.test.transport.StubbableTransport
StubbableTransport.OpenConnectionBehavior, StubbableTransport.RequestHandlingBehavior<Request extends org.elasticsearch.transport.TransportRequest>, StubbableTransport.SendRequestBehavior, StubbableTransport.WrappedConnection
Nested classes/interfaces inherited from interface org.elasticsearch.transport.Transport
org.elasticsearch.transport.Transport.Connection, org.elasticsearch.transport.Transport.RequestHandlers, org.elasticsearch.transport.Transport.ResponseContext<T extends org.elasticsearch.transport.TransportResponse>, org.elasticsearch.transport.Transport.ResponseHandlers
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionorg.elasticsearch.transport.Transport.Connection
createConnection
(org.elasticsearch.cluster.node.DiscoveryNode node) org.elasticsearch.transport.TransportService
createTransportService
(org.elasticsearch.common.settings.Settings settings, org.elasticsearch.threadpool.ThreadPool threadPool, org.elasticsearch.transport.TransportInterceptor interceptor, Function<org.elasticsearch.common.transport.BoundTransportAddress, org.elasticsearch.cluster.node.DiscoveryNode> localNodeFactory, org.elasticsearch.common.settings.ClusterSettings clusterSettings, Set<String> taskHeaders) void
handleError
(long requestId, org.elasticsearch.transport.TransportException e) simulate an error for the given requestId, unlikehandleLocalError(long, Throwable)
andhandleRemoteError(long, Throwable)
, the provided exception will not be wrapped but will be delivered to the transport layer as isvoid
handleLocalError
(long requestId, Throwable t) simulate a local error for the given requestId, will be wrapped by aSendRequestTransportException
void
handleRemoteError
(long requestId, Throwable t) simulate a remote error for the given requestId, will be wrapped by aRemoteTransportException
<Response extends org.elasticsearch.transport.TransportResponse>
voidhandleResponse
(long requestId, Response response) simulate a response for the given requestIdprotected void
onSendRequest
(long requestId, String action, org.elasticsearch.transport.TransportRequest request, org.elasticsearch.cluster.node.DiscoveryNode node) void
setMessageListener
(org.elasticsearch.transport.TransportMessageListener messageListener) protected org.elasticsearch.common.io.stream.NamedWriteableRegistry
Methods inherited from class org.elasticsearch.test.transport.StubbableTransport
addLifecycleListener, addressesFromString, boundAddress, close, getDefaultSeedAddresses, getRequestHandlers, getResponseHandlers, getStats, lifecycleState, newNetworkBytesStream, openConnection, profileBoundAddresses, removeLifecycleListener, setDefaultConnectBehavior, start, stop
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.elasticsearch.transport.Transport
isSecure, registerRequestHandler, setSlowLogThreshold
-
Constructor Details
-
MockTransport
public MockTransport()
-
-
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, Function<org.elasticsearch.common.transport.BoundTransportAddress, org.elasticsearch.cluster.node.DiscoveryNode> localNodeFactory, @Nullable org.elasticsearch.common.settings.ClusterSettings clusterSettings, Set<String> taskHeaders) -
handleResponse
public <Response extends org.elasticsearch.transport.TransportResponse> void handleResponse(long requestId, Response response) simulate a response for the given requestId -
handleLocalError
simulate a local error for the given requestId, will be wrapped by aSendRequestTransportException
- Parameters:
requestId
- the id corresponding to the captured send requestt
- the failure to wrap
-
handleRemoteError
simulate a remote error for the given requestId, will be wrapped by aRemoteTransportException
- Parameters:
requestId
- the id corresponding to the captured send requestt
- the failure to wrap
-
handleError
public void handleError(long requestId, org.elasticsearch.transport.TransportException e) simulate an error for the given requestId, unlikehandleLocalError(long, Throwable)
andhandleRemoteError(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 requeste
- the failure
-
createConnection
public org.elasticsearch.transport.Transport.Connection createConnection(org.elasticsearch.cluster.node.DiscoveryNode node) -
onSendRequest
protected void onSendRequest(long requestId, String action, org.elasticsearch.transport.TransportRequest request, org.elasticsearch.cluster.node.DiscoveryNode node) -
setMessageListener
public void setMessageListener(org.elasticsearch.transport.TransportMessageListener messageListener) - Specified by:
setMessageListener
in interfaceorg.elasticsearch.transport.Transport
- Overrides:
setMessageListener
in classStubbableTransport
-
writeableRegistry
protected org.elasticsearch.common.io.stream.NamedWriteableRegistry writeableRegistry()
-