Class TransportOptions

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class TransportOptions
    extends java.lang.Object
    implements java.lang.Cloneable
    Encapsulates all the Transport options in one configuration object.
    • Field Detail

      • DEFAULT_SEND_BUFFER_SIZE

        public static final int DEFAULT_SEND_BUFFER_SIZE
        See Also:
        Constant Field Values
      • DEFAULT_RECEIVE_BUFFER_SIZE

        public static final int DEFAULT_RECEIVE_BUFFER_SIZE
        See Also:
        Constant Field Values
      • DEFAULT_TCP_KEEP_ALIVE

        public static final boolean DEFAULT_TCP_KEEP_ALIVE
        See Also:
        Constant Field Values
      • DEFAULT_CONNECT_TIMEOUT

        public static final int DEFAULT_CONNECT_TIMEOUT
        See Also:
        Constant Field Values
      • DEFAULT_ALLOW_NATIVE_IO

        public static final boolean DEFAULT_ALLOW_NATIVE_IO
        See Also:
        Constant Field Values
      • DEFAULT_USE_WEBSOCKETS

        public static final boolean DEFAULT_USE_WEBSOCKETS
        See Also:
        Constant Field Values
      • DEFAULT_WEBSOCKET_MAX_FRAME_SIZE

        public static final int DEFAULT_WEBSOCKET_MAX_FRAME_SIZE
        See Also:
        Constant Field Values
      • DEFAULT_NATIVEIO_PREFERENCES

        public static final java.util.List<java.lang.String> DEFAULT_NATIVEIO_PREFERENCES
    • Constructor Detail

      • TransportOptions

        public TransportOptions()
    • Method Detail

      • clone

        public TransportOptions clone()
        Overrides:
        clone in class java.lang.Object
      • sendBufferSize

        public int sendBufferSize()
        Returns:
        the currently set send buffer size in bytes.
      • sendBufferSize

        public TransportOptions sendBufferSize​(int sendBufferSize)
        Sets the send buffer size in bytes, the value must be greater than zero or an IllegalArgumentException will be thrown.
        Parameters:
        sendBufferSize - the new send buffer size for the TCP Transport.
        Returns:
        this options instance.
        Throws:
        java.lang.IllegalArgumentException - if the value given is not in the valid range.
      • receiveBufferSize

        public int receiveBufferSize()
        Returns:
        the currently configured receive buffer size in bytes.
      • receiveBufferSize

        public TransportOptions receiveBufferSize​(int receiveBufferSize)
        Sets the receive buffer size in bytes, the value must be greater than zero or an IllegalArgumentException will be thrown.
        Parameters:
        receiveBufferSize - the new receive buffer size for the TCP Transport.
        Returns:
        this options instance.
        Throws:
        java.lang.IllegalArgumentException - if the value given is not in the valid range.
      • trafficClass

        public int trafficClass()
        Returns:
        the currently configured traffic class value.
      • trafficClass

        public TransportOptions trafficClass​(int trafficClass)
        Sets the traffic class value used by the TCP connection, valid range is between 0 and 255.
        Parameters:
        trafficClass - the new traffic class value.
        Returns:
        this options instance.
        Throws:
        java.lang.IllegalArgumentException - if the value given is not in the valid range.
      • soTimeout

        public int soTimeout()
        Returns:
        the configured value for the socket level soTimeout option.
      • soTimeout

        public TransportOptions soTimeout​(int soTimeout)
        Sets the value to use when configuring the socket level soTimeout option.
        Parameters:
        soTimeout - the soTimeout value to configure on the newly create socket.
        Returns:
        this TransportOptions instance.
      • tcpNoDelay

        public boolean tcpNoDelay()
        Returns:
        the configured value for the socket level tcpNoDelay option.
      • tcpNoDelay

        public TransportOptions tcpNoDelay​(boolean tcpNoDelay)
        Configure the underlying connection to use the tcpNoDelay option.
        Parameters:
        tcpNoDelay - controls if the underlying connection configures tcpNoDelay.
        Returns:
        this TransportOptions instance.
      • soLinger

        public int soLinger()
        Returns:
        the configured value for the socket level soLinger option.
      • soLinger

        public TransportOptions soLinger​(int soLinger)
        Configures the soLinger value that should be configured on the connection socket.
        Parameters:
        soLinger - The soLinger value to use for the underlying socket.
        Returns:
        this TransportOptions instance.
      • tcpKeepAlive

        public boolean tcpKeepAlive()
        Returns:
        the configured value for the socket level tcpKeepAlive option.
      • tcpKeepAlive

        public TransportOptions tcpKeepAlive​(boolean keepAlive)
        Configures the TCP socket keep-alive value that should be used for a connection.
        Parameters:
        keepAlive - The TCP/IP keep-alive value to use for the connection.
        Returns:
        this TransportOptions instance.
      • connectTimeout

        public int connectTimeout()
        Returns:
        the configured value for the socket level connection timeout option.
      • connectTimeout

        public TransportOptions connectTimeout​(int connectTimeout)
        A transport layer connection timeout value that controls how long a connection attempt can block before giving up and throwing a connection error.
        Parameters:
        connectTimeout - connection timeout in milliseconds.
        Returns:
        this TransportOptions instance.
      • defaultTcpPort

        public int defaultTcpPort()
        Returns:
        the configured value for the socket level default port to use for connection if none is provided.
      • defaultTcpPort

        public TransportOptions defaultTcpPort​(int defaultTcpPort)
        The default unsecured connection port to use when none has been specified by the user.
        Parameters:
        defaultTcpPort - the default port to use for non-SSL connection if none provided.
        Returns:
        this TransportOptions instance.
      • localAddress

        public java.lang.String localAddress()
        Returns:
        the configured value for the socket level localAddress option.
      • localAddress

        public TransportOptions localAddress​(java.lang.String localAddress)
        The local address to bind to when attempting a remote connection.
        Parameters:
        localAddress - the local address to bind to.
        Returns:
        this TransportOptions instance.
      • localPort

        public int localPort()
        Returns:
        the configured value for the socket level localPort option.
      • localPort

        public TransportOptions localPort​(int localPort)
        Configures the local port value to bind to when connecting to the remote, if that port is already in use this can lead to a connection error.
        Parameters:
        localPort - local port value to use when making a remote connection.
        Returns:
        this TransportOptions instance.
      • allowNativeIO

        public boolean allowNativeIO()
        Returns:
        true if an native IO library can be used if available on this platform instead of the JDK IO.
      • allowNativeIO

        public TransportOptions allowNativeIO​(boolean allowNativeIO)
        Determines if the a native IO implementation is preferred to the JDK based IO.
        Parameters:
        allowNativeIO - should use of available native transport be allowed if one is available.
        Returns:
        this TransportOptions instance.
      • nativeIOPreference

        public java.lang.String[] nativeIOPreference()
        Returns:
        the nativeIOPreference
      • nativeIOPreference

        public void nativeIOPreference​(java.lang.String... nativeIOPreference)
        Parameters:
        nativeIOPreference - the nativeIOPreference to set
      • traceBytes

        public boolean traceBytes()
        Returns:
        true if the transport should enable byte tracing
      • traceBytes

        public TransportOptions traceBytes​(boolean traceBytes)
        Determines if the transport should add a logger for bytes in / out
        Parameters:
        traceBytes - should the transport log the bytes in and out.
        Returns:
        this TransportOptions instance.
      • useWebSockets

        public boolean useWebSockets()
        Returns:
        the configured state of WebSockets for client connections.
      • useWebSockets

        public TransportOptions useWebSockets​(boolean webSockets)
        Set to true to configure the transport layer as a WebSocket based connection.
        Parameters:
        webSockets - should the transport attempt connection using a WebSocket.
        Returns:
        this TransportOptions instance.
      • webSocketPath

        public java.lang.String webSocketPath()
        Returns:
        the configured value for the socket level WebSocket path option.
      • webSocketPath

        public TransportOptions webSocketPath​(java.lang.String webSocketPath)
        The optional path element to provide when connecting via a WebSocket.
        Parameters:
        webSocketPath - path value to use for WebSocket connections.
        Returns:
        this TransportOptions instance.
      • webSocketHeaders

        public java.util.Map<java.lang.String,​java.lang.String> webSocketHeaders()
        Returns:
        the configured value for the socket level WebSocket Headers option.
      • addWebSocketHeader

        public TransportOptions addWebSocketHeader​(java.lang.String key,
                                                   java.lang.String value)
        Additional headers to be passed along to the remote when performing a WebSocket based connect.
        Parameters:
        key - the header key to use with the provided value.
        value - the value to store under the provided key.
        Returns:
        this TransportOptions instance.
      • webSocketMaxFrameSize

        public int webSocketMaxFrameSize()
        Returns:
        the configured value for the socket level WebSocket max frame size option.
      • webSocketMaxFrameSize

        public TransportOptions webSocketMaxFrameSize​(int maxFrameSize)
        Configures the maximum size of each WebSocket frame, payloads larger than the max frame size are split into multiple frames during transmission.
        Parameters:
        maxFrameSize - the maximum WebSocket frame size before payloads are split.
        Returns:
        this TransportOptions instance.