Class TcpTransport

    • Method Detail

      • 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
      • 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
      • 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,
                                   BytesReference message)
        Handles inbound message that has been decoded.
        Parameters:
        channel - the channel the message is from
        message - the message
      • consumeNetworkReads

        public int consumeNetworkReads​(TcpChannel channel,
                                       BytesReference bytesReference)
                                throws java.io.IOException
        Consumes bytes that are available from network reads. This method returns the number of bytes consumed in this call.
        Parameters:
        channel - the channel read from
        bytesReference - the bytes available to consume
        Returns:
        the number of bytes consumed
        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
      • 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
      • getProfileSettings

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

        public final RequestHandlerRegistry<? extends TransportRequest> getRequestHandler​(java.lang.String action)
        Description copied from interface: Transport
        Returns the registered request handler registry for the given action or null if it's not registered
        Specified by:
        getRequestHandler in interface Transport
        Parameters:
        action - the action to look up