java.lang.Object
org.elasticsearch.common.component.AbstractLifecycleComponent
org.elasticsearch.transport.TcpTransport
- All Implemented Interfaces:
Closeable,AutoCloseable,LifecycleComponent,Releasable,Transport
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA helper exception to mark an incoming connection as potentially being HTTP so an appropriate error code can be returnedfinal classstatic final classRepresentation of a transport profile settings for atransport.profiles.$profilename.*Nested classes/interfaces inherited from interface org.elasticsearch.transport.Transport
Transport.Connection, Transport.RequestHandlers, Transport.ResponseContext<T extends TransportResponse>, Transport.ResponseHandlers -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final NetworkServiceprotected final Set<TcpTransport.ProfileSettings> protected final Recycler<org.apache.lucene.util.BytesRef> protected final booleanprotected final Settingsprotected final ThreadPoolstatic final StringFields inherited from class org.elasticsearch.common.component.AbstractLifecycleComponent
lifecycle -
Constructor Summary
ConstructorsConstructorDescriptionTcpTransport(Settings settings, TransportVersion version, ThreadPool threadPool, PageCacheRecycler pageCacheRecycler, CircuitBreakerService circuitBreakerService, NamedWriteableRegistry namedWriteableRegistry, NetworkService networkService) -
Method Summary
Modifier and TypeMethodDescriptionaddressesFromString(String address) Returns an address from its string representation.protected abstract TcpServerChannelbind(String name, InetSocketAddress address) Binds to the givenInetSocketAddressprotected voidbindServer(TcpTransport.ProfileSettings profileSettings) The address the transport is bound on.The address the Remote Access port is bound on, ornullif it is not bound.protected Recycler<org.apache.lucene.util.BytesRef> createRecycler(Settings settings, PageCacheRecycler pageCacheRecycler) protected final voiddoClose()Close this component.protected final voiddoStop()Stop this component.voidexecuteHandshake(DiscoveryNode node, TcpChannel channel, ConnectionProfile profile, ActionListener<TransportVersion> listener) Returns a list of all local addresses for this transportstatic Set<TcpTransport.ProfileSettings> getProfileSettings(Settings settings) Returns all profile settings for the given settings objectfinal TransportStatsgetStats()booleanOnly used in tests, seeIGNORE_DESERIALIZATION_ERRORS_SETTING.voidinboundMessage(TcpChannel channel, InboundMessage message) Handles inbound message that has been decoded.protected abstract TcpChannelinitiateChannel(DiscoveryNode node, ConnectionProfile connectionProfile) Initiate a single tcp socket channel.protected static ConnectionProfilemaybeOverrideConnectionProfile(ConnectionProfile connectionProfile) voidonException(TcpChannel channel, Exception e) protected static voidonServerException(TcpServerChannel channel, Exception e) voidopenConnection(DiscoveryNode node, ConnectionProfile profile, ActionListener<Transport.Connection> listener) Opens a new connection to the given node.Further profile bound addressesstatic intreadMessageLength(BytesReference networkBytes) Validates the first 6 bytes of the message header and returns the length of the message.protected voidserverAcceptedChannel(TcpChannel channel) voidsetMessageListener(TransportMessageListener listener) voidsetSlowLogThreshold(TimeValue slowLogThreshold) protected abstract voidCalled to tear down internal resourcesMethods inherited from class org.elasticsearch.common.component.AbstractLifecycleComponent
addLifecycleListener, close, doStart, lifecycleState, start, stopMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.elasticsearch.common.component.LifecycleComponent
addLifecycleListener, lifecycleState, start, stopMethods inherited from interface org.elasticsearch.core.Releasable
closeMethods inherited from interface org.elasticsearch.transport.Transport
isSecure, registerRequestHandler
-
Field Details
-
TRANSPORT_WORKER_THREAD_NAME_PREFIX
- See Also:
-
settings
-
threadPool
-
recycler
-
networkService
-
profileSettingsSet
-
rstOnClose
protected final boolean rstOnClose
-
-
Constructor Details
-
TcpTransport
public TcpTransport(Settings settings, TransportVersion version, ThreadPool threadPool, PageCacheRecycler pageCacheRecycler, CircuitBreakerService circuitBreakerService, NamedWriteableRegistry namedWriteableRegistry, NetworkService networkService)
-
-
Method Details
-
getStatsTracker
-
getThreadPool
-
getInflightBreaker
-
setMessageListener
- Specified by:
setMessageListenerin interfaceTransport
-
setSlowLogThreshold
- Specified by:
setSlowLogThresholdin interfaceTransport
-
ignoreDeserializationErrors
public boolean ignoreDeserializationErrors()Only used in tests, seeIGNORE_DESERIALIZATION_ERRORS_SETTING. -
maybeOverrideConnectionProfile
protected static ConnectionProfile maybeOverrideConnectionProfile(ConnectionProfile connectionProfile) -
createRecycler
protected Recycler<org.apache.lucene.util.BytesRef> createRecycler(Settings settings, PageCacheRecycler pageCacheRecycler) -
openConnection
public void openConnection(DiscoveryNode node, ConnectionProfile profile, ActionListener<Transport.Connection> listener) Description copied from interface:TransportOpens a new connection to the given node. When the connection is fully connected, the listener is called. The ActionListener will be called on the calling thread or the generic thread pool.- Specified by:
openConnectionin interfaceTransport
-
boundAddress
Description copied from interface:TransportThe address the transport is bound on.- Specified by:
boundAddressin interfaceTransport
-
boundRemoteIngressAddress
Description copied from interface:TransportThe address the Remote Access port is bound on, ornullif it is not bound.- Specified by:
boundRemoteIngressAddressin interfaceTransport
-
profileBoundAddresses
Description copied from interface:TransportFurther profile bound addresses- Specified by:
profileBoundAddressesin interfaceTransport- Returns:
nulliff profiles are unsupported, otherwise a map with name of profile and its bound transport address
-
getDefaultSeedAddresses
Description copied from interface:TransportReturns a list of all local addresses for this transport- Specified by:
getDefaultSeedAddressesin interfaceTransport
-
bindServer
-
addressesFromString
Description copied from interface:TransportReturns an address from its string representation.- Specified by:
addressesFromStringin interfaceTransport- Throws:
UnknownHostException
-
doClose
protected final void doClose()Description copied from class:AbstractLifecycleComponentClose this component. Typically that means doing the reverse of whatever happened during initialization, such as releasing resources acquired there.This method is called while synchronized on
AbstractLifecycleComponent.lifecycle. It is called once in the lifetime of a component. If the component was started then it will be stopped before it is closed, and once it is closed it will not be started or stopped.- Specified by:
doClosein classAbstractLifecycleComponent
-
doStop
protected final void doStop()Description copied from class:AbstractLifecycleComponentStop this component. Typically that means doing the reverse of whateverAbstractLifecycleComponent.doStart()does.This method is called while synchronized on
AbstractLifecycleComponent.lifecycle. It is only called once in the lifetime of a component, after callingAbstractLifecycleComponent.doStart(), although it will not be called at all if this component did not successfully start.- Specified by:
doStopin classAbstractLifecycleComponent
-
onException
-
onServerException
-
serverAcceptedChannel
-
bind
Binds to the givenInetSocketAddress- Parameters:
name- the profile nameaddress- the address to bind to- Throws:
IOException
-
initiateChannel
protected abstract TcpChannel initiateChannel(DiscoveryNode node, ConnectionProfile connectionProfile) throws IOException Initiate a single tcp socket channel.- Parameters:
node- for the initiated connectionconnectionProfile- the connection profile to use when connecting to the node- Returns:
- the pending connection
- Throws:
IOException- if an I/O exception occurs while opening the channel
-
stopInternal
protected abstract void stopInternal()Called to tear down internal resources -
inboundMessage
Handles inbound message that has been decoded.- Parameters:
channel- the channel the message is frommessage- the message
-
readMessageLength
Validates the first 6 bytes of the message header and returns the length of the message. If 6 bytes are not available, it returns -1.- Parameters:
networkBytes- the will be read- Returns:
- the length of the message
- Throws:
StreamCorruptedException- if the message header format is not recognizedTcpTransport.HttpRequestOnTransportException- if the message header appears to be an HTTP messageIllegalArgumentException- if the message length is greater that the maximum allowed frame size. This is dependent on the available memory.IOException
-
executeHandshake
public void executeHandshake(DiscoveryNode node, TcpChannel channel, ConnectionProfile profile, ActionListener<TransportVersion> listener) -
newNetworkBytesStream
- Specified by:
newNetworkBytesStreamin interfaceTransport
-
getStats
-
getProfileSettings
Returns all profile settings for the given settings object -
getResponseHandlers
- Specified by:
getResponseHandlersin interfaceTransport
-
getRequestHandlers
- Specified by:
getRequestHandlersin interfaceTransport
-