public class LocalTransport extends AbstractLifecycleComponent implements Transport
Transport.Connection| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
LOCAL_TRANSPORT_THREAD_NAME_PREFIX |
protected NamedWriteableRegistry |
namedWriteableRegistry |
static java.lang.String |
TRANSPORT_LOCAL_ADDRESS |
static java.lang.String |
TRANSPORT_LOCAL_QUEUE |
static java.lang.String |
TRANSPORT_LOCAL_WORKERS |
lifecycledeprecationLogger, logger, settingsTRANSPORT_TCP_COMPRESS| Constructor and Description |
|---|
LocalTransport(Settings settings,
ThreadPool threadPool,
NamedWriteableRegistry namedWriteableRegistry,
CircuitBreakerService circuitBreakerService) |
| Modifier and Type | Method and Description |
|---|---|
TransportAddress[] |
addressesFromString(java.lang.String address,
int perAddressLimit)
Returns an address from its string representation.
|
boolean |
addressSupported(java.lang.Class<? extends TransportAddress> address)
Is the address type supported.
|
BoundTransportAddress |
boundAddress()
The address the transport is bound on.
|
void |
connectToNode(DiscoveryNode node,
ConnectionProfile connectionProfile,
CheckedBiConsumer<Transport.Connection,ConnectionProfile,java.io.IOException> connectionValidator)
Connects to a node with the given connection profile.
|
void |
disconnectFromNode(DiscoveryNode node)
Disconnected from the given node, if not connected, will do nothing.
|
protected void |
doClose() |
protected void |
doStart() |
protected void |
doStop() |
Transport.Connection |
getConnection(DiscoveryNode node)
Returns a connection for the given node if the node is connected.
|
java.util.List<java.lang.String> |
getLocalAddresses() |
protected Version |
getVersion() |
protected void |
handleParsedResponse(TransportResponse response,
TransportResponseHandler handler) |
protected void |
handleResponse(StreamInput buffer,
LocalTransport sourceTransport,
TransportResponseHandler handler) |
long |
newRequestId()
Returns a new request ID to use when sending a message via
Transport.Connection.sendRequest(long, String,
TransportRequest, TransportRequestOptions) |
boolean |
nodeConnected(DiscoveryNode node)
Returns true if the node is connected.
|
Transport.Connection |
openConnection(DiscoveryNode node,
ConnectionProfile profile)
Opens a new connection to the given node and returns it.
|
protected void |
processReceivedMessage(byte[] data,
java.lang.String action,
LocalTransport sourceTransport,
Version version,
java.lang.Long sendRequestId)
processes received messages, assuming thread passing and thread context have all been dealt with
|
java.util.Map<java.lang.String,BoundTransportAddress> |
profileBoundAddresses()
Further profile bound addresses
|
void |
receiveMessage(Version version,
byte[] data,
java.lang.String action,
java.lang.Long requestId,
LocalTransport sourceTransport)
entry point for incoming messages
|
protected void |
sendRequest(LocalTransport targetTransport,
DiscoveryNode node,
long requestId,
java.lang.String action,
TransportRequest request,
TransportRequestOptions options) |
long |
serverOpen()
Returns count of currently open connections
|
void |
transportServiceAdapter(TransportServiceAdapter transportServiceAdapter) |
addLifecycleListener, close, lifecycleState, removeLifecycleListener, start, stoplogDeprecatedSetting, logRemovedSetting, nodeNameclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetInFlightRequestBreakeraddLifecycleListener, lifecycleState, removeLifecycleListener, start, stopclosepublic static final java.lang.String LOCAL_TRANSPORT_THREAD_NAME_PREFIX
protected final NamedWriteableRegistry namedWriteableRegistry
public static final java.lang.String TRANSPORT_LOCAL_ADDRESS
public static final java.lang.String TRANSPORT_LOCAL_WORKERS
public static final java.lang.String TRANSPORT_LOCAL_QUEUE
public LocalTransport(Settings settings, ThreadPool threadPool, NamedWriteableRegistry namedWriteableRegistry, CircuitBreakerService circuitBreakerService)
public TransportAddress[] addressesFromString(java.lang.String address, int perAddressLimit)
TransportaddressesFromString in interface Transportpublic boolean addressSupported(java.lang.Class<? extends TransportAddress> address)
TransportaddressSupported in interface Transportprotected void doStart()
doStart in class AbstractLifecycleComponentprotected void doStop()
doStop in class AbstractLifecycleComponentprotected void doClose()
doClose in class AbstractLifecycleComponentpublic void transportServiceAdapter(TransportServiceAdapter transportServiceAdapter)
transportServiceAdapter in interface Transportpublic BoundTransportAddress boundAddress()
TransportboundAddress in interface Transportpublic java.util.Map<java.lang.String,BoundTransportAddress> profileBoundAddresses()
TransportprofileBoundAddresses in interface Transportnull iff profiles are unsupported, otherwise a map with name of profile and its bound transport addresspublic boolean nodeConnected(DiscoveryNode node)
TransportnodeConnected in interface Transportpublic void connectToNode(DiscoveryNode node, ConnectionProfile connectionProfile, CheckedBiConsumer<Transport.Connection,ConnectionProfile,java.io.IOException> connectionValidator) throws ConnectTransportException
TransportconnectToNode in interface TransportConnectTransportExceptionpublic void disconnectFromNode(DiscoveryNode node)
TransportdisconnectFromNode in interface Transportpublic long serverOpen()
TransportserverOpen in interface Transportpublic Transport.Connection getConnection(DiscoveryNode node)
TransportgetConnection in interface TransportTransport.connectToNode(DiscoveryNode, ConnectionProfile, CheckedBiConsumer)public Transport.Connection openConnection(DiscoveryNode node, ConnectionProfile profile) throws java.io.IOException
TransportTransport.connectToNode(DiscoveryNode, ConnectionProfile, CheckedBiConsumer) the returned connection is not managed by
the transport implementation. This connection must be closed once it's not needed anymore.
This connection type can be used to execute a handshake between two nodes before the node will be published via
Transport.connectToNode(DiscoveryNode, ConnectionProfile, CheckedBiConsumer).openConnection in interface Transportjava.io.IOExceptionprotected void sendRequest(LocalTransport targetTransport, DiscoveryNode node, long requestId, java.lang.String action, TransportRequest request, TransportRequestOptions options) throws java.io.IOException, TransportException
java.io.IOExceptionTransportExceptionpublic void receiveMessage(Version version, byte[] data, java.lang.String action, @Nullable java.lang.Long requestId, LocalTransport sourceTransport)
version - the version used to serialize the messagedata - message dataaction - the action associated with this message (only used for error handling when data is not parsable)requestId - requestId if the message is request (only used for error handling when data is not parsable)sourceTransport - the source transport to respond to.protected void processReceivedMessage(byte[] data,
java.lang.String action,
LocalTransport sourceTransport,
Version version,
@Nullable
java.lang.Long sendRequestId)
protected void handleResponse(StreamInput buffer, LocalTransport sourceTransport, TransportResponseHandler handler)
protected void handleParsedResponse(TransportResponse response, TransportResponseHandler handler)
public java.util.List<java.lang.String> getLocalAddresses()
getLocalAddresses in interface Transportpublic long newRequestId()
TransportTransport.Connection.sendRequest(long, String,
TransportRequest, TransportRequestOptions)newRequestId in interface Transportprotected Version getVersion()