public class TransportService extends AbstractLifecycleComponent
Modifier and Type | Class and Description |
---|---|
static class |
TransportService.ContextRestoreResponseHandler<T extends TransportResponse>
This handler wrapper ensures that the response thread executes with the correct thread context.
|
static class |
TransportService.HandshakeResponse |
Modifier and Type | Field and Description |
---|---|
protected ClusterName |
clusterName |
static java.lang.String |
DIRECT_RESPONSE_PROFILE |
static java.lang.String |
HANDSHAKE_ACTION_NAME |
static TransportInterceptor |
NOOP_TRANSPORT_INTERCEPTOR |
protected TaskManager |
taskManager |
protected ThreadPool |
threadPool |
static Setting<java.util.List<java.lang.String>> |
TRACE_LOG_EXCLUDE_SETTING |
static Setting<java.util.List<java.lang.String>> |
TRACE_LOG_INCLUDE_SETTING |
protected Transport |
transport |
lifecycle
deprecationLogger, logger, settings
Constructor and Description |
---|
TransportService(Settings settings,
Transport transport,
ThreadPool threadPool,
TransportInterceptor transportInterceptor,
java.util.function.Function<BoundTransportAddress,DiscoveryNode> localNodeFactory,
ClusterSettings clusterSettings)
Build the service.
|
Modifier and Type | Method and Description |
---|---|
void |
acceptIncomingRequests()
start accepting incoming requests.
|
void |
addConnectionListener(TransportConnectionListener listener) |
TransportAddress[] |
addressesFromString(java.lang.String address,
int perAddressLimit) |
BoundTransportAddress |
boundAddress() |
void |
connectToNode(DiscoveryNode node) |
void |
connectToNode(DiscoveryNode node,
ConnectionProfile connectionProfile)
Connect to the specified node with the given connection profile
|
protected TaskManager |
createTaskManager() |
void |
disconnectFromNode(DiscoveryNode node) |
protected void |
doClose() |
protected void |
doStart() |
protected void |
doStop() |
Transport.Connection |
getConnection(DiscoveryNode node)
Returns either a real transport connection or a local node connection if we are using the local node optimization.
|
protected java.util.concurrent.ExecutorService |
getExecutorService()
The executor service for this transport service.
|
java.util.List<java.lang.String> |
getLocalAddresses() |
DiscoveryNode |
getLocalNode() |
RemoteClusterService |
getRemoteClusterService() |
RequestHandlerRegistry |
getRequestHandler(java.lang.String action) |
TaskManager |
getTaskManager() |
ThreadPool |
getThreadPool()
Returns the internal thread pool
|
DiscoveryNode |
handshake(Transport.Connection connection,
long handshakeTimeout)
Executes a high-level handshake using the given connection
and returns the discovery node of the node the connection
was established with.
|
DiscoveryNode |
handshake(Transport.Connection connection,
long handshakeTimeout,
java.util.function.Predicate<ClusterName> clusterNamePredicate)
Executes a high-level handshake using the given connection
and returns the discovery node of the node the connection
was established with.
|
TransportInfo |
info() |
boolean |
nodeConnected(DiscoveryNode node)
Returns
true iff the given node is already connected. |
void |
onNodeDisconnected(DiscoveryNode node) |
TransportResponseHandler |
onResponseReceived(long requestId)
called by the
Transport implementation when a response or an exception has been received for a previously
sent request (before any processing or deserialization was done). |
Transport.Connection |
openConnection(DiscoveryNode node,
ConnectionProfile profile)
Establishes and returns a new connection to the given node.
|
<Request extends TransportRequest> |
registerRequestHandler(java.lang.String action,
java.util.function.Supplier<Request> request,
java.lang.String executor,
boolean forceExecution,
boolean canTripCircuitBreaker,
TransportRequestHandler<Request> handler)
Registers a new request handler
|
<Request extends TransportRequest> |
registerRequestHandler(java.lang.String action,
java.util.function.Supplier<Request> requestFactory,
java.lang.String executor,
TransportRequestHandler<Request> handler)
Registers a new request handler
|
void |
removeConnectionListener(TransportConnectionListener listener) |
<T extends TransportResponse> |
sendChildRequest(DiscoveryNode node,
java.lang.String action,
TransportRequest request,
Task parentTask,
TransportRequestOptions options,
TransportResponseHandler<T> handler) |
<T extends TransportResponse> |
sendChildRequest(Transport.Connection connection,
java.lang.String action,
TransportRequest request,
Task parentTask,
TransportRequestOptions options,
TransportResponseHandler<T> handler) |
<T extends TransportResponse> |
sendChildRequest(Transport.Connection connection,
java.lang.String action,
TransportRequest request,
Task parentTask,
TransportResponseHandler<T> handler) |
<T extends TransportResponse> |
sendRequest(DiscoveryNode node,
java.lang.String action,
TransportRequest request,
TransportRequestOptions options,
TransportResponseHandler<T> handler) |
<T extends TransportResponse> |
sendRequest(DiscoveryNode node,
java.lang.String action,
TransportRequest request,
TransportResponseHandler<T> handler) |
<T extends TransportResponse> |
sendRequest(Transport.Connection connection,
java.lang.String action,
TransportRequest request,
TransportRequestOptions options,
TransportResponseHandler<T> handler) |
TransportStats |
stats() |
<T extends TransportResponse> |
submitRequest(DiscoveryNode node,
java.lang.String action,
TransportRequest request,
TransportRequestOptions options,
TransportResponseHandler<T> handler) |
<T extends TransportResponse> |
submitRequest(DiscoveryNode node,
java.lang.String action,
TransportRequest request,
TransportResponseHandler<T> handler) |
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) |
protected void |
traceUnresolvedResponse(long requestId) |
addLifecycleListener, close, lifecycleState, removeLifecycleListener, start, stop
logDeprecatedSetting, logRemovedSetting, nodeName
public static final java.lang.String DIRECT_RESPONSE_PROFILE
public static final java.lang.String HANDSHAKE_ACTION_NAME
protected final Transport transport
protected final ThreadPool threadPool
protected final ClusterName clusterName
protected final TaskManager taskManager
public static final TransportInterceptor NOOP_TRANSPORT_INTERCEPTOR
public static final Setting<java.util.List<java.lang.String>> TRACE_LOG_INCLUDE_SETTING
public static final Setting<java.util.List<java.lang.String>> TRACE_LOG_EXCLUDE_SETTING
public TransportService(Settings settings, Transport transport, ThreadPool threadPool, TransportInterceptor transportInterceptor, 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 TRACE_LOG_EXCLUDE_SETTING
and TRACE_LOG_INCLUDE_SETTING
.public RemoteClusterService getRemoteClusterService()
public DiscoveryNode getLocalNode()
public TaskManager getTaskManager()
protected TaskManager createTaskManager()
protected java.util.concurrent.ExecutorService getExecutorService()
protected void doStart()
doStart
in class AbstractLifecycleComponent
protected void doStop()
doStop
in class AbstractLifecycleComponent
protected void doClose() throws java.io.IOException
doClose
in class AbstractLifecycleComponent
java.io.IOException
public final void acceptIncomingRequests()
public TransportInfo info()
public TransportStats stats()
public BoundTransportAddress boundAddress()
public java.util.List<java.lang.String> getLocalAddresses()
public boolean nodeConnected(DiscoveryNode node)
true
iff the given node is already connected.public void connectToNode(DiscoveryNode node) throws ConnectTransportException
ConnectTransportException
public void connectToNode(DiscoveryNode node, ConnectionProfile connectionProfile)
node
- the node to connect toconnectionProfile
- the connection profile to use when connecting to this nodepublic Transport.Connection openConnection(DiscoveryNode node, ConnectionProfile profile) throws java.io.IOException
node
- the node to connect toprofile
- the connection profile to usejava.io.IOException
public DiscoveryNode handshake(Transport.Connection connection, long handshakeTimeout) throws ConnectTransportException
connection
- the connection to a specific nodehandshakeTimeout
- handshake timeoutConnectTransportException
- if the connection failedjava.lang.IllegalStateException
- if the handshake failedpublic DiscoveryNode handshake(Transport.Connection connection, long handshakeTimeout, java.util.function.Predicate<ClusterName> clusterNamePredicate) throws ConnectTransportException
connection
- the connection to a specific nodehandshakeTimeout
- handshake timeoutclusterNamePredicate
- cluster name validation predicateConnectTransportException
- if the connection failedjava.lang.IllegalStateException
- if the handshake failedpublic void disconnectFromNode(DiscoveryNode node)
public void addConnectionListener(TransportConnectionListener listener)
public void removeConnectionListener(TransportConnectionListener listener)
public <T extends TransportResponse> TransportFuture<T> submitRequest(DiscoveryNode node, java.lang.String action, TransportRequest request, TransportResponseHandler<T> handler) throws TransportException
TransportException
public <T extends TransportResponse> TransportFuture<T> submitRequest(DiscoveryNode node, java.lang.String action, TransportRequest request, TransportRequestOptions options, TransportResponseHandler<T> handler) throws TransportException
TransportException
public <T extends TransportResponse> void sendRequest(DiscoveryNode node, java.lang.String action, TransportRequest request, TransportResponseHandler<T> handler)
public final <T extends TransportResponse> void sendRequest(DiscoveryNode node, java.lang.String action, TransportRequest request, TransportRequestOptions options, TransportResponseHandler<T> handler)
public final <T extends TransportResponse> void sendRequest(Transport.Connection connection, java.lang.String action, TransportRequest request, TransportRequestOptions options, TransportResponseHandler<T> handler)
public Transport.Connection getConnection(DiscoveryNode node)
NodeNotConnectedException
- if the given node is not connectedpublic final <T extends TransportResponse> void sendChildRequest(DiscoveryNode node, java.lang.String action, TransportRequest request, Task parentTask, TransportRequestOptions options, TransportResponseHandler<T> handler)
public <T extends TransportResponse> void sendChildRequest(Transport.Connection connection, java.lang.String action, TransportRequest request, Task parentTask, TransportResponseHandler<T> handler)
public <T extends TransportResponse> void sendChildRequest(Transport.Connection connection, java.lang.String action, TransportRequest request, Task parentTask, TransportRequestOptions options, TransportResponseHandler<T> handler)
public TransportAddress[] addressesFromString(java.lang.String address, int perAddressLimit) throws java.net.UnknownHostException
java.net.UnknownHostException
public <Request extends TransportRequest> void registerRequestHandler(java.lang.String action, java.util.function.Supplier<Request> requestFactory, java.lang.String executor, TransportRequestHandler<Request> handler)
action
- The action the request handler is associated withrequestFactory
- a callable to be used construct new instances for streamingexecutor
- The executor the request handling will be executed onhandler
- The handler itself that implements the request handlingpublic <Request extends TransportRequest> void registerRequestHandler(java.lang.String action, java.util.function.Supplier<Request> request, java.lang.String executor, boolean forceExecution, boolean canTripCircuitBreaker, TransportRequestHandler<Request> handler)
action
- The action the request handler is associated withrequest
- The request class that will be used to construct new instances for streamingexecutor
- The executor the request handling will be executed onforceExecution
- Force execution on the executor queue and never reject itcanTripCircuitBreaker
- Check the request size and raise an exception in case the limit is breached.handler
- The handler itself that implements the request handlingprotected boolean traceEnabled()
protected void traceResponseSent(long requestId, java.lang.String action, java.lang.Exception e)
public RequestHandlerRegistry getRequestHandler(java.lang.String action)
public TransportResponseHandler onResponseReceived(long requestId)
Transport
implementation when a response or an exception has been received for a previously
sent request (before any processing or deserialization was done). Returns the appropriate response handler or null if not
found.public void onNodeDisconnected(DiscoveryNode node)
protected void traceReceivedRequest(long requestId, java.lang.String action)
protected void traceResponseSent(long requestId, java.lang.String action)
protected void traceReceivedResponse(long requestId, DiscoveryNode sourceNode, java.lang.String action)
protected void traceUnresolvedResponse(long requestId)
protected void traceRequestSent(DiscoveryNode node, long requestId, java.lang.String action, TransportRequestOptions options)
public ThreadPool getThreadPool()