Package org.elasticsearch.transport
Class TcpTransport
java.lang.Object
org.elasticsearch.common.component.AbstractLifecycleComponent
org.elasticsearch.transport.TcpTransport
- All Implemented Interfaces:
Closeable
,AutoCloseable
,LifecycleComponent
,org.elasticsearch.core.Releasable
,Transport
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
A helper exception to mark an incoming connection as potentially being HTTP so an appropriate error code can be returnedclass
static class
Representation 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
Modifier and TypeFieldDescriptionprotected NetworkService
protected PageCacheRecycler
protected Set<TcpTransport.ProfileSettings>
protected Settings
protected ThreadPool
static String
Fields inherited from class org.elasticsearch.common.component.AbstractLifecycleComponent
lifecycle
-
Constructor Summary
ConstructorDescriptionTcpTransport(Settings settings, Version 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 TcpServerChannel
bind(String name, InetSocketAddress address)
Binds to the givenInetSocketAddress
protected void
bindServer(TcpTransport.ProfileSettings profileSettings)
The address the transport is bound on.protected void
doClose()
protected void
doStart()
protected void
doStop()
void
executeHandshake(DiscoveryNode node, TcpChannel channel, ConnectionProfile profile, ActionListener<Version> 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 objectgetStats()
void
inboundMessage(TcpChannel channel, InboundMessage message)
Handles inbound message that has been decoded.protected abstract TcpChannel
initiateChannel(DiscoveryNode node)
Initiate a single tcp socket channel.protected ConnectionProfile
maybeOverrideConnectionProfile(ConnectionProfile connectionProfile)
void
onException(TcpChannel channel, Exception e)
protected void
onServerException(TcpServerChannel channel, Exception e)
void
openConnection(DiscoveryNode node, ConnectionProfile profile, ActionListener<Transport.Connection> listener)
Opens a new connection to the given node.Further profile bound addressesstatic int
readMessageLength(BytesReference networkBytes)
Validates the first 6 bytes of the message header and returns the length of the message.protected void
serverAcceptedChannel(TcpChannel channel)
void
setMessageListener(TransportMessageListener listener)
void
setSlowLogThreshold(org.elasticsearch.core.TimeValue slowLogThreshold)
protected abstract void
Called to tear down internal resourcesMethods inherited from class org.elasticsearch.common.component.AbstractLifecycleComponent
addLifecycleListener, close, lifecycleState, removeLifecycleListener, start, stop
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.elasticsearch.common.component.LifecycleComponent
addLifecycleListener, lifecycleState, removeLifecycleListener, start, stop
Methods inherited from interface org.elasticsearch.core.Releasable
close
Methods inherited from interface org.elasticsearch.transport.Transport
isSecure, registerRequestHandler
-
Field Details
-
TRANSPORT_WORKER_THREAD_NAME_PREFIX
- See Also:
- Constant Field Values
-
settings
-
threadPool
-
pageCacheRecycler
-
networkService
-
profileSettings
-
-
Constructor Details
-
TcpTransport
public TcpTransport(Settings settings, Version version, ThreadPool threadPool, PageCacheRecycler pageCacheRecycler, CircuitBreakerService circuitBreakerService, NamedWriteableRegistry namedWriteableRegistry, NetworkService networkService)
-
-
Method Details
-
getVersion
-
getStatsTracker
-
getThreadPool
-
getInflightBreaker
-
doStart
protected void doStart()- Specified by:
doStart
in classAbstractLifecycleComponent
-
setMessageListener
- Specified by:
setMessageListener
in interfaceTransport
-
setSlowLogThreshold
public void setSlowLogThreshold(org.elasticsearch.core.TimeValue slowLogThreshold)- Specified by:
setSlowLogThreshold
in interfaceTransport
-
maybeOverrideConnectionProfile
-
openConnection
public void openConnection(DiscoveryNode node, ConnectionProfile profile, ActionListener<Transport.Connection> listener)Description copied from interface:Transport
Opens 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:
openConnection
in interfaceTransport
-
boundAddress
Description copied from interface:Transport
The address the transport is bound on.- Specified by:
boundAddress
in interfaceTransport
-
profileBoundAddresses
Description copied from interface:Transport
Further profile bound addresses- Specified by:
profileBoundAddresses
in interfaceTransport
- Returns:
null
iff profiles are unsupported, otherwise a map with name of profile and its bound transport address
-
getDefaultSeedAddresses
Description copied from interface:Transport
Returns a list of all local addresses for this transport- Specified by:
getDefaultSeedAddresses
in interfaceTransport
-
bindServer
-
addressesFromString
Description copied from interface:Transport
Returns an address from its string representation.- Specified by:
addressesFromString
in interfaceTransport
- Throws:
UnknownHostException
-
doClose
protected final void doClose()- Specified by:
doClose
in classAbstractLifecycleComponent
-
doStop
protected final void doStop()- Specified by:
doStop
in classAbstractLifecycleComponent
-
onException
-
onServerException
-
serverAcceptedChannel
-
bind
protected abstract TcpServerChannel bind(String name, InetSocketAddress address) throws IOExceptionBinds to the givenInetSocketAddress
- Parameters:
name
- the profile nameaddress
- the address to bind to- Throws:
IOException
-
initiateChannel
Initiate a single tcp socket channel.- Parameters:
node
- for the initiated connection- 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<Version> listener) -
getStats
-
getProfileSettings
Returns all profile settings for the given settings object -
getResponseHandlers
- Specified by:
getResponseHandlers
in interfaceTransport
-
getRequestHandlers
- Specified by:
getRequestHandlers
in interfaceTransport
-