java.io.Closeable, java.lang.AutoCloseable, LifecycleComponent, Releasablepublic final class MockTransportService extends TransportService
| Modifier and Type | Class | Description |
|---|---|---|
static class |
MockTransportService.ClearableTransport |
The delegate transport instances defined in this class mock various kinds of disruption types.
|
static class |
MockTransportService.DelegateTransport |
A pure delegate transport.
|
static class |
MockTransportService.TestPlugin |
|
static class |
MockTransportService.Tracer |
TransportService.ContextRestoreResponseHandler<T extends TransportResponse>, TransportService.HandshakeResponsedeprecationLogger, logger, settingslifecycleclusterName, DIRECT_RESPONSE_PROFILE, HANDSHAKE_ACTION_NAME, NOOP_TRANSPORT_INTERCEPTOR, taskManager, threadPool, TRACE_LOG_EXCLUDE_SETTING, TRACE_LOG_INCLUDE_SETTING, transport| Constructor | Description |
|---|---|
MockTransportService(Settings settings,
Transport transport,
ThreadPool threadPool,
TransportInterceptor interceptor,
java.util.function.Function<BoundTransportAddress,DiscoveryNode> localNodeFactory,
ClusterSettings clusterSettings,
java.util.Set<java.lang.String> taskHeaders) |
Build the service.
|
MockTransportService(Settings settings,
Transport transport,
ThreadPool threadPool,
TransportInterceptor interceptor,
ClusterSettings clusterSettings) |
Build the service.
|
| Modifier and Type | Method | Description |
|---|---|---|
boolean |
addDelegate(TransportAddress transportAddress,
MockTransportService.DelegateTransport transport) |
Adds a new delegate transport that is used for communication with the given transport address.
|
boolean |
addDelegate(TransportService transportService,
MockTransportService.DelegateTransport transport) |
Adds a new delegate transport that is used for communication with the given transport service.
|
void |
addFailToSendNoConnectRule(TransportAddress transportAddress) |
Adds a rule that will cause every send request to fail, and each new connect since the rule
is added to fail as well.
|
void |
addFailToSendNoConnectRule(TransportAddress transportAddress,
java.lang.String... blockedActions) |
Adds a rule that will cause matching operations to throw ConnectTransportExceptions
|
void |
addFailToSendNoConnectRule(TransportAddress transportAddress,
java.util.Set<java.lang.String> blockedActions) |
Adds a rule that will cause matching operations to throw ConnectTransportExceptions
|
void |
addFailToSendNoConnectRule(TransportService transportService) |
Adds a rule that will cause every send request to fail, and each new connect since the rule
is added to fail as well.
|
void |
addFailToSendNoConnectRule(TransportService transportService,
java.lang.String... blockedActions) |
Adds a rule that will cause matching operations to throw ConnectTransportExceptions
|
void |
addFailToSendNoConnectRule(TransportService transportService,
java.util.Set<java.lang.String> blockedActions) |
Adds a rule that will cause matching operations to throw ConnectTransportExceptions
|
void |
addTracer(MockTransportService.Tracer tracer) |
|
void |
addUnresponsiveRule(TransportAddress transportAddress) |
Adds a rule that will cause ignores each send request, simulating an unresponsive node
and failing to connect once the rule was added.
|
void |
addUnresponsiveRule(TransportAddress transportAddress,
TimeValue duration) |
Adds a rule that will cause ignores each send request, simulating an unresponsive node
and failing to connect once the rule was added.
|
void |
addUnresponsiveRule(TransportService transportService) |
Adds a rule that will cause ignores each send request, simulating an unresponsive node
and failing to connect once the rule was added.
|
void |
addUnresponsiveRule(TransportService transportService,
TimeValue duration) |
Adds a rule that will cause ignores each send request, simulating an unresponsive node
and failing to connect once the rule was added.
|
void |
clearAllRules() |
Clears all the registered rules.
|
void |
clearRule(TransportAddress transportAddress) |
Clears the rule associated with the provided transport address.
|
void |
clearRule(TransportService transportService) |
Clears the rule associated with the provided transport service.
|
void |
clearTracers() |
|
static MockTransportService |
createNewService(Settings settings,
Transport transport,
Version version,
ThreadPool threadPool,
ClusterSettings clusterSettings,
java.util.Set<java.lang.String> taskHeaders) |
|
static MockTransportService |
createNewService(Settings settings,
Version version,
ThreadPool threadPool,
ClusterSettings clusterSettings) |
|
protected TaskManager |
createTaskManager(Settings settings,
ThreadPool threadPool,
java.util.Set<java.lang.String> taskHeaders) |
|
protected void |
doClose() |
|
static TransportAddress[] |
extractTransportAddresses(TransportService transportService) |
|
protected java.util.concurrent.ExecutorService |
getExecutorService() |
|
DiscoveryNode |
getLocalDiscoNode() |
|
Transport |
getOriginalTransport() |
|
Transport.Connection |
openConnection(DiscoveryNode node,
ConnectionProfile profile) |
|
Transport |
original() |
Returns the original Transport service wrapped by this mock transport service.
|
boolean |
removeTracer(MockTransportService.Tracer tracer) |
|
void |
setExecutorName(java.lang.String executorName) |
|
protected boolean |
traceEnabled() |
|
protected void |
traceReceivedRequest(long requestId,
java.lang.String action) |
|
protected void |
traceReceivedResponse(long requestId,
DiscoveryNode sourceNode,
java.lang.String action) |
|
protected void |
traceRequestSent(DiscoveryNode node,
long requestId,
java.lang.String action,
TransportRequestOptions options) |
|
protected void |
traceResponseSent(long requestId,
java.lang.String action) |
|
protected void |
traceResponseSent(long requestId,
java.lang.String action,
java.lang.Exception e) |
logDeprecatedSetting, logRemovedSetting, nodeNameaddLifecycleListener, close, lifecycleState, removeLifecycleListener, start, stopclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitacceptIncomingRequests, addConnectionListener, addressesFromString, boundAddress, connectToNode, connectToNode, disconnectFromNode, doStart, doStop, getConnection, getLocalAddresses, getLocalNode, getRemoteClusterService, getRequestHandler, getTaskManager, getThreadPool, handshake, handshake, info, nodeConnected, onNodeDisconnected, onResponseReceived, registerRequestHandler, registerRequestHandler, registerRequestHandler, registerRequestHandler, removeConnectionListener, sendChildRequest, sendChildRequest, sendChildRequest, sendRequest, sendRequest, sendRequest, stats, submitRequest, submitRequest, traceUnresolvedResponsepublic MockTransportService(Settings settings, Transport transport, ThreadPool threadPool, TransportInterceptor interceptor, @Nullable ClusterSettings clusterSettings)
clusterSettings - if non null the TransportService will register with the ClusterSettings for settings
updates for TransportService.TRACE_LOG_EXCLUDE_SETTING and TransportService.TRACE_LOG_INCLUDE_SETTING.public MockTransportService(Settings settings, Transport transport, ThreadPool threadPool, TransportInterceptor interceptor, java.util.function.Function<BoundTransportAddress,DiscoveryNode> localNodeFactory, @Nullable ClusterSettings clusterSettings, java.util.Set<java.lang.String> taskHeaders)
clusterSettings - if non null the TransportService will register with the ClusterSettings for settings
updates for TransportService.TRACE_LOG_EXCLUDE_SETTING and TransportService.TRACE_LOG_INCLUDE_SETTING.public static MockTransportService createNewService(Settings settings, Version version, ThreadPool threadPool, @Nullable ClusterSettings clusterSettings)
public static MockTransportService createNewService(Settings settings, Transport transport, Version version, ThreadPool threadPool, @Nullable ClusterSettings clusterSettings, java.util.Set<java.lang.String> taskHeaders)
public static TransportAddress[] extractTransportAddresses(TransportService transportService)
protected TaskManager createTaskManager(Settings settings, ThreadPool threadPool, java.util.Set<java.lang.String> taskHeaders)
createTaskManager in class TransportServicepublic void setExecutorName(java.lang.String executorName)
protected java.util.concurrent.ExecutorService getExecutorService()
getExecutorService in class TransportServicepublic void clearAllRules()
public void clearRule(TransportService transportService)
public void clearRule(TransportAddress transportAddress)
public Transport original()
public void addFailToSendNoConnectRule(TransportService transportService)
public void addFailToSendNoConnectRule(TransportAddress transportAddress)
public void addFailToSendNoConnectRule(TransportService transportService, java.lang.String... blockedActions)
public void addFailToSendNoConnectRule(TransportAddress transportAddress, java.lang.String... blockedActions)
public void addFailToSendNoConnectRule(TransportService transportService, java.util.Set<java.lang.String> blockedActions)
public void addFailToSendNoConnectRule(TransportAddress transportAddress, java.util.Set<java.lang.String> blockedActions)
public void addUnresponsiveRule(TransportService transportService)
public void addUnresponsiveRule(TransportAddress transportAddress)
public void addUnresponsiveRule(TransportService transportService, TimeValue duration)
duration - the amount of time to delay sending and connecting.public void addUnresponsiveRule(TransportAddress transportAddress, TimeValue duration)
duration - the amount of time to delay sending and connecting.public boolean addDelegate(TransportService transportService, MockTransportService.DelegateTransport transport)
public boolean addDelegate(TransportAddress transportAddress, MockTransportService.DelegateTransport transport)
public void addTracer(MockTransportService.Tracer tracer)
public boolean removeTracer(MockTransportService.Tracer tracer)
public void clearTracers()
protected boolean traceEnabled()
traceEnabled in class TransportServiceprotected void traceReceivedRequest(long requestId,
java.lang.String action)
traceReceivedRequest in class TransportServiceprotected void traceResponseSent(long requestId,
java.lang.String action)
traceResponseSent in class TransportServiceprotected void traceResponseSent(long requestId,
java.lang.String action,
java.lang.Exception e)
traceResponseSent in class TransportServiceprotected void traceReceivedResponse(long requestId,
DiscoveryNode sourceNode,
java.lang.String action)
traceReceivedResponse in class TransportServiceprotected void traceRequestSent(DiscoveryNode node, long requestId, java.lang.String action, TransportRequestOptions options)
traceRequestSent in class TransportServicepublic Transport getOriginalTransport()
public Transport.Connection openConnection(DiscoveryNode node, ConnectionProfile profile) throws java.io.IOException
openConnection in class TransportServicejava.io.IOExceptionprotected void doClose()
throws java.io.IOException
doClose in class TransportServicejava.io.IOExceptionpublic DiscoveryNode getLocalDiscoNode()