public final class MockTransportService extends TransportService
Modifier and Type | Class and 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.HandshakeResponse
clusterName, DIRECT_RESPONSE_PROFILE, HANDSHAKE_ACTION_NAME, NOOP_TRANSPORT_INTERCEPTOR, taskManager, threadPool, TRACE_LOG_EXCLUDE_SETTING, TRACE_LOG_INCLUDE_SETTING, transport
lifecycle
deprecationLogger, logger, settings
Constructor and Description |
---|
MockTransportService(Settings settings,
Transport transport,
ThreadPool threadPool,
TransportInterceptor interceptor,
ClusterSettings clusterSettings)
Build the service.
|
MockTransportService(Settings settings,
Transport transport,
ThreadPool threadPool,
TransportInterceptor interceptor,
java.util.function.Function<BoundTransportAddress,DiscoveryNode> localNodeFactory,
ClusterSettings clusterSettings)
Build the service.
|
Modifier and Type | Method and 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.util.Set<java.lang.String> blockedActions)
Adds a rule that will cause matching operations to throw ConnectTransportExceptions
|
void |
addFailToSendNoConnectRule(TransportAddress transportAddress,
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.util.Set<java.lang.String> blockedActions)
Adds a rule that will cause matching operations to throw ConnectTransportExceptions
|
void |
addFailToSendNoConnectRule(TransportService transportService,
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) |
static MockTransportService |
createNewService(Settings settings,
Version version,
ThreadPool threadPool,
ClusterSettings clusterSettings) |
protected TaskManager |
createTaskManager() |
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) |
acceptIncomingRequests, addConnectionListener, addressesFromString, boundAddress, connectToNode, connectToNode, disconnectFromNode, doStart, doStop, getConnection, getLocalAddresses, getLocalNode, getRemoteClusterService, getRequestHandler, getTaskManager, getThreadPool, handshake, handshake, info, nodeConnected, onNodeDisconnected, onResponseReceived, registerRequestHandler, registerRequestHandler, removeConnectionListener, sendChildRequest, sendChildRequest, sendChildRequest, sendRequest, sendRequest, sendRequest, stats, submitRequest, submitRequest, traceUnresolvedResponse
addLifecycleListener, close, lifecycleState, removeLifecycleListener, start, stop
logDeprecatedSetting, logRemovedSetting, nodeName
public 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)
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)
public static TransportAddress[] extractTransportAddresses(TransportService transportService)
protected TaskManager createTaskManager()
createTaskManager
in class TransportService
public void setExecutorName(java.lang.String executorName)
protected java.util.concurrent.ExecutorService getExecutorService()
getExecutorService
in class TransportService
public 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 TransportService
protected void traceReceivedRequest(long requestId, java.lang.String action)
traceReceivedRequest
in class TransportService
protected void traceResponseSent(long requestId, java.lang.String action)
traceResponseSent
in class TransportService
protected void traceResponseSent(long requestId, java.lang.String action, java.lang.Exception e)
traceResponseSent
in class TransportService
protected void traceReceivedResponse(long requestId, DiscoveryNode sourceNode, java.lang.String action)
traceReceivedResponse
in class TransportService
protected void traceRequestSent(DiscoveryNode node, long requestId, java.lang.String action, TransportRequestOptions options)
traceRequestSent
in class TransportService
public Transport getOriginalTransport()
public Transport.Connection openConnection(DiscoveryNode node, ConnectionProfile profile) throws java.io.IOException
openConnection
in class TransportService
java.io.IOException
protected void doClose() throws java.io.IOException
doClose
in class TransportService
java.io.IOException
public DiscoveryNode getLocalDiscoNode()