Class TcpTransport

java.lang.Object
org.elasticsearch.common.component.AbstractLifecycleComponent
org.elasticsearch.transport.TcpTransport
All Implemented Interfaces:
java.io.Closeable, java.lang.AutoCloseable, LifecycleComponent, Releasable, Transport

public abstract class TcpTransport
extends AbstractLifecycleComponent
implements Transport
  • Field Details

  • Constructor Details

  • Method Details

    • getVersion

      public Version getVersion()
    • getStatsTracker

      public StatsTracker getStatsTracker()
    • getThreadPool

      public ThreadPool getThreadPool()
    • getInflightBreaker

      public java.util.function.Supplier<CircuitBreaker> getInflightBreaker()
    • doStart

      protected void doStart()
      Specified by:
      doStart in class AbstractLifecycleComponent
    • setMessageListener

      public void setMessageListener​(TransportMessageListener listener)
      Specified by:
      setMessageListener in interface Transport
    • setSlowLogThreshold

      public void setSlowLogThreshold​(org.elasticsearch.common.unit.TimeValue slowLogThreshold)
      Specified by:
      setSlowLogThreshold in interface Transport
    • maybeOverrideConnectionProfile

      protected ConnectionProfile maybeOverrideConnectionProfile​(ConnectionProfile connectionProfile)
    • 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 interface Transport
    • boundAddress

      public BoundTransportAddress boundAddress()
      Description copied from interface: Transport
      The address the transport is bound on.
      Specified by:
      boundAddress in interface Transport
    • profileBoundAddresses

      public java.util.Map<java.lang.String,​BoundTransportAddress> profileBoundAddresses()
      Description copied from interface: Transport
      Further profile bound addresses
      Specified by:
      profileBoundAddresses in interface Transport
      Returns:
      null iff profiles are unsupported, otherwise a map with name of profile and its bound transport address
    • getDefaultSeedAddresses

      public java.util.List<java.lang.String> getDefaultSeedAddresses()
      Description copied from interface: Transport
      Returns a list of all local addresses for this transport
      Specified by:
      getDefaultSeedAddresses in interface Transport
    • bindServer

      protected void bindServer​(TcpTransport.ProfileSettings profileSettings)
    • addressesFromString

      public TransportAddress[] addressesFromString​(java.lang.String address) throws java.net.UnknownHostException
      Description copied from interface: Transport
      Returns an address from its string representation.
      Specified by:
      addressesFromString in interface Transport
      Throws:
      java.net.UnknownHostException
    • doClose

      protected final void doClose()
      Specified by:
      doClose in class AbstractLifecycleComponent
    • doStop

      protected final void doStop()
      Specified by:
      doStop in class AbstractLifecycleComponent
    • onException

      public void onException​(TcpChannel channel, java.lang.Exception e)
    • onServerException

      protected void onServerException​(TcpServerChannel channel, java.lang.Exception e)
    • serverAcceptedChannel

      protected void serverAcceptedChannel​(TcpChannel channel)
    • bind

      protected abstract TcpServerChannel bind​(java.lang.String name, java.net.InetSocketAddress address) throws java.io.IOException
      Binds to the given InetSocketAddress
      Parameters:
      name - the profile name
      address - the address to bind to
      Throws:
      java.io.IOException
    • initiateChannel

      protected abstract TcpChannel initiateChannel​(DiscoveryNode node) throws java.io.IOException
      Initiate a single tcp socket channel.
      Parameters:
      node - for the initiated connection
      Returns:
      the pending connection
      Throws:
      java.io.IOException - if an I/O exception occurs while opening the channel
    • stopInternal

      protected abstract void stopInternal()
      Called to tear down internal resources
    • inboundMessage

      public void inboundMessage​(TcpChannel channel, InboundMessage message)
      Handles inbound message that has been decoded.
      Parameters:
      channel - the channel the message is from
      message - the message
    • readMessageLength

      public static int readMessageLength​(BytesReference networkBytes) throws java.io.IOException
      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:
      java.io.StreamCorruptedException - if the message header format is not recognized
      TcpTransport.HttpRequestOnTransportException - if the message header appears to be an HTTP message
      java.lang.IllegalArgumentException - if the message length is greater that the maximum allowed frame size. This is dependent on the available memory.
      java.io.IOException
    • executeHandshake

      public void executeHandshake​(DiscoveryNode node, TcpChannel channel, ConnectionProfile profile, ActionListener<Version> listener)
    • getStats

      public final TransportStats getStats()
      Specified by:
      getStats in interface Transport
    • getProfileSettings

      public static java.util.Set<TcpTransport.ProfileSettings> getProfileSettings​(Settings settings)
      Returns all profile settings for the given settings object
    • getResponseHandlers

      public final Transport.ResponseHandlers getResponseHandlers()
      Specified by:
      getResponseHandlers in interface Transport
    • getRequestHandlers

      public final Transport.RequestHandlers getRequestHandlers()
      Specified by:
      getRequestHandlers in interface Transport