Interface Transport

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      io.netty.buffer.ByteBuf allocateSendBuffer​(int size)
      Request that the Transport provide an output buffer sized for the given value.
      void close()
      Close the Transport, no additional send operations are accepted.
      java.util.concurrent.ScheduledExecutorService connect​(java.lang.Runnable initRoutine, javax.net.ssl.SSLContext sslContextOverride)
      Performs the connect operation for the implemented Transport type such as a TCP socket connection, SSL/TLS handshake etc.
      void flush()
      Request a flush of all pending writes to the underlying connection.
      java.security.Principal getLocalPrincipal()  
      int getMaxFrameSize()
      Returns the currently configured maximum frame size setting.
      java.net.URI getRemoteLocation()  
      java.util.concurrent.ThreadFactory getThreadFactory()  
      TransportListener getTransportListener()
      Gets the currently set TransportListener instance
      TransportOptions getTransportOptions()  
      boolean isConnected()  
      boolean isSecure()  
      void setMaxFrameSize​(int maxFrameSize)
      Sets the Maximum Frame Size the transport should accept from the remote.
      void setThreadFactory​(java.util.concurrent.ThreadFactory factory)
      Sets the ThreadFactory that the Transport should use when creating the Transport IO thread for processing.
      void setTransportListener​(TransportListener listener)
      Sets the Transport Listener instance that will be notified of incoming data or error events.
      void write​(io.netty.buffer.ByteBuf output)
      Writes a chunk of data over the Transport connection without performing an explicit flush on the transport.
      void writeAndFlush​(io.netty.buffer.ByteBuf output)
      Writes a chunk of data over the Transport connection and requests a flush of all pending queued write operations
    • Method Detail

      • connect

        java.util.concurrent.ScheduledExecutorService connect​(java.lang.Runnable initRoutine,
                                                              javax.net.ssl.SSLContext sslContextOverride)
                                                       throws java.io.IOException
        Performs the connect operation for the implemented Transport type such as a TCP socket connection, SSL/TLS handshake etc.
        Parameters:
        initRoutine - a runnable initialization method that is executed in the context of the transport's IO thread to allow thread safe setup of resources that will be run from the transport executor service.
        sslContextOverride - a user-provided SSLContext to use if establishing a secure connection, overrides applicable URI configuration
        Returns:
        A ScheduledThreadPoolExecutor that can run work on the Transport IO thread.
        Throws:
        java.io.IOException - if an error occurs while attempting the connect.
      • isConnected

        boolean isConnected()
        Returns:
        true if transport is connected or false if the connection is down.
      • isSecure

        boolean isSecure()
        Returns:
        true if transport is connected using a secured channel (SSL).
      • close

        void close()
            throws java.io.IOException
        Close the Transport, no additional send operations are accepted.
        Throws:
        java.io.IOException - if an error occurs while closing the connection.
      • allocateSendBuffer

        io.netty.buffer.ByteBuf allocateSendBuffer​(int size)
                                            throws java.io.IOException
        Request that the Transport provide an output buffer sized for the given value.
        Parameters:
        size - the size necessary to hold the outgoing bytes.
        Returns:
        a new ByteBuf allocated for sends operations.
        Throws:
        java.io.IOException - if an error occurs while allocating the send buffer.
      • write

        void write​(io.netty.buffer.ByteBuf output)
            throws java.io.IOException
        Writes a chunk of data over the Transport connection without performing an explicit flush on the transport.
        Parameters:
        output - The buffer of data that is to be transmitted.
        Throws:
        java.io.IOException - if an error occurs during the write operation.
      • writeAndFlush

        void writeAndFlush​(io.netty.buffer.ByteBuf output)
                    throws java.io.IOException
        Writes a chunk of data over the Transport connection and requests a flush of all pending queued write operations
        Parameters:
        output - The buffer of data that is to be transmitted.
        Throws:
        java.io.IOException - if an error occurs during the write operation.
      • flush

        void flush()
            throws java.io.IOException
        Request a flush of all pending writes to the underlying connection.
        Throws:
        java.io.IOException - if an error occurs during the flush operation.
      • getTransportListener

        TransportListener getTransportListener()
        Gets the currently set TransportListener instance
        Returns:
        the current TransportListener or null if none set.
      • setTransportListener

        void setTransportListener​(TransportListener listener)
        Sets the Transport Listener instance that will be notified of incoming data or error events.
        Parameters:
        listener - The new TransportListener instance to use (cannot be null).
        Throws:
        java.lang.IllegalArgumentException - if the given listener is null.
      • getThreadFactory

        java.util.concurrent.ThreadFactory getThreadFactory()
        Returns:
        the ThreadFactory used to create the IO thread for this Transport
      • setThreadFactory

        void setThreadFactory​(java.util.concurrent.ThreadFactory factory)
        Sets the ThreadFactory that the Transport should use when creating the Transport IO thread for processing.
        Parameters:
        factory - The ThreadFactory
        Throws:
        java.lang.IllegalStateException - if called after a call to connect(Runnable, SSLContext)
      • getTransportOptions

        TransportOptions getTransportOptions()
        Returns:
        the TransportOptions instance that holds the configuration for this Transport.
      • getRemoteLocation

        java.net.URI getRemoteLocation()
        Returns:
        the URI of the remote peer that this Transport connects to.
      • getLocalPrincipal

        java.security.Principal getLocalPrincipal()
        Returns:
        the local principal for a Transport that is using a secure connection.
      • setMaxFrameSize

        void setMaxFrameSize​(int maxFrameSize)
        Sets the Maximum Frame Size the transport should accept from the remote. This option is not applicable to all transport types, those that support validating the incoming frame size should apply the configured value.
        Parameters:
        maxFrameSize - The maximum frame size to accept from the remote.
      • getMaxFrameSize

        int getMaxFrameSize()
        Returns the currently configured maximum frame size setting.
        Returns:
        the current max frame size setting for this transport.