Class ConnectionHelper<T extends Connector>

  • Direct Known Subclasses:
    ClientConnectionHelper, ServerConnectionHelper

    @Deprecated
    public abstract class ConnectionHelper<T extends Connector>
    extends BaseHelper<T>
    Deprecated.
    Will be removed to favor lower-level network extensions allowing more control at the Restlet API level.
    Connector helper using network connections. Here is the list of parameters that are supported. They should be set in the connector's context before it is started:
    Parameter name Value type Default value Description
    maxConnectionsPerHost int -1 Maximum number of concurrent connections per host (IP address).
    initialConnections int 100 Initial number of connections pre-created in the connections pool. This saves time during establishment of new connections as heavy byte buffers are simply reused.
    maxTotalConnections int -1 Maximum number of concurrent connections in total.
    persistingConnections boolean true Indicates if connections should be kept alive after a call.
    pipeliningConnections boolean false Indicates if pipelining connections are supported.
    pooledConnections boolean true Indicates if connections should be pooled to save instantiation time.
    socketKeepAlive boolean true Indicates if a TCP connection should be automatically kept alive after 2 hours of inactivity.
    socketOobInline boolean false Indicates if urgent TCP data received on the socket will be received through the socket input stream.
    socketLingerTimeMs int -1 Time to block when a socket close is requested or -1 to not block at all.
    socketNoDelay boolean false Enables Nagle's algorithm if set to false, preventing sending of small TCP packets.
    socketReceiveBufferSize int 8192 The hinted size of the underlying TCP buffers used by the platform for inbound network I/O.
    socketReuseAddress boolean true Indicates if sockets can be reused right away even if they are busy (in TIME_WAIT or 2MSL wait state).
    socketSendBufferSize int 8192 The hinted size of the underlying TCP buffers used by the platform for outbound network I/O.
    socketTrafficClass int 0 Type of service to set in IP packets.
    • Field Detail

      • connections

        private final java.util.List<Connection<T extends Connector>> connections
        Deprecated.
        The set of active connections.
    • Constructor Detail

      • ConnectionHelper

        public ConnectionHelper​(T connector,
                                boolean clientSide)
        Deprecated.
        Constructor.
        Parameters:
        connector - The helped connector.
        clientSide - True if it is helping a client connector.
    • Method Detail

      • addOutboundMessage

        public void addOutboundMessage​(Response response)
        Deprecated.
        Add the outbound message to the queue and wake up the IO controller.
        Parameters:
        response - The outbound message.
      • checkin

        public void checkin​(Connection<?> connection)
        Deprecated.
        Checks in the connection back into the pool.
        Parameters:
        connection - The connection to check in.
      • checkout

        public Connection<T> checkout​(java.nio.channels.SocketChannel socketChannel,
                                      ConnectionController controller,
                                      java.net.InetSocketAddress socketAddress)
                               throws java.io.IOException
        Deprecated.
        Checks out a connection associated to the given socket from the pool.
        Parameters:
        socketChannel - The underlying NIO socket channel.
        controller - The underlying IO controller.
        socketAddress - The associated IP address.
        Returns:
        The new connection.
        Throws:
        java.io.IOException
      • configure

        public void configure​(java.net.Socket socket)
                       throws java.net.SocketException
        Deprecated.
        Configures a given socket based on the helper parameters.
        Parameters:
        socket - The socket to configure.
        Throws:
        java.net.SocketException
      • createConnection

        public abstract Connection<T> createConnection​(java.nio.channels.SocketChannel socketChannel,
                                                       ConnectionController controller,
                                                       java.net.InetSocketAddress socketAddress)
                                                throws java.io.IOException
        Deprecated.
        Creates a connection associated to the given socket.
        Parameters:
        socketChannel - The underlying NIO socket channel.
        controller - The underlying IO controller.
        socketAddress - The associated IP address.
        Returns:
        The new connection.
        Throws:
        java.io.IOException
      • createConnectionPool

        public void createConnectionPool()
        Deprecated.
        Creates the connection pool.
      • createInboundWay

        public abstract InboundWay createInboundWay​(Connection<T> connection,
                                                    int bufferSize)
        Deprecated.
        Creates an inbound way for the given connection.
        Parameters:
        connection - The parent connection.
        bufferSize - The byte buffer size.
        Returns:
        The inbound way created.
      • createOutboundWay

        public abstract OutboundWay createOutboundWay​(Connection<T> connection,
                                                      int bufferSize)
        Deprecated.
        Creates an outbound way for the given connection.
        Parameters:
        connection - The parent connection.
        bufferSize - The byte buffer size.
        Returns:
        The outbound way created.
      • getConnectionPool

        public ConnectionPool<T> getConnectionPool()
        Deprecated.
        Returns the connection pool.
        Returns:
        The connection pool.
      • getConnections

        public java.util.List<Connection<T>> getConnections()
        Deprecated.
        Returns the set of active connections.
        Returns:
        The set of active connections.
      • getInitialConnections

        public int getInitialConnections()
        Deprecated.
        Returns the initial number of connections pre-created in the connections pool.
        Returns:
        The initial number of connections pre-created in the connections pool.
      • getMaxConnectionsPerHost

        public int getMaxConnectionsPerHost()
        Deprecated.
        Returns the maximum concurrent connections per host (IP address). By default, it is unbounded.
        Returns:
        Maximum number of concurrent connections per host (IP address).
      • getMaxTotalConnections

        public int getMaxTotalConnections()
        Deprecated.
        Returns the maximum number of concurrent connections allowed. By default, it is unbounded.
        Returns:
        The maximum number of concurrent connections allowed.
      • getSocketLingerTimeMs

        public int getSocketLingerTimeMs()
        Deprecated.
        Returns the time to block when a socket close is requested or -1 to not block at all.
        Returns:
        The time to block when a socket close is requested or -1 to not block at all.
      • getSocketReceiveBufferSize

        public int getSocketReceiveBufferSize()
        Deprecated.
        Returns the hinted size of the underlying TCP buffers used by the platform for inbound network I/O.
        Returns:
        The hinted size of the underlying TCP buffers used by the platform for inbound network I/O.
      • getSocketSendBufferSize

        public int getSocketSendBufferSize()
        Deprecated.
        Returns the hinted size of the underlying TCP buffers used by the platform for outbound network I/O.
        Returns:
        The hinted size of the underlying TCP buffers used by the platform for outbound network I/O.
      • getSocketTrafficClass

        public int getSocketTrafficClass()
        Deprecated.
        Returns the type of service to set in IP packets.
        Returns:
        The type of service to set in IP packets.
      • isPersistingConnections

        public boolean isPersistingConnections()
        Deprecated.
        Indicates if persistent connections should be used if possible.
        Returns:
        True if persistent connections should be used if possible.
      • isPipeliningConnections

        public boolean isPipeliningConnections()
        Deprecated.
        Indicates if pipelining connections are supported.
        Returns:
        True if pipelining connections are supported.
      • isPooledConnection

        public boolean isPooledConnection()
        Deprecated.
        Indicates if the connection objects should be pooled to save instantiation time.
        Returns:
        True if the connection objects should be pooled.
      • isProxying

        public abstract boolean isProxying()
        Deprecated.
        Indicates if the helper is going through a client proxy or is a server proxy.
        Returns:
        True if the helper is going through a client proxy or is a server proxy.
      • isSocketKeepAlive

        public boolean isSocketKeepAlive()
        Deprecated.
        Indicates if a TCP connection should be automatically kept alive after 2 hours of inactivity.
        Returns:
        True if a TCP connection should be automatically kept alive after 2 hours of inactivity.
      • isSocketNoDelay

        public boolean isSocketNoDelay()
        Deprecated.
        Enables Nagle's algorithm if set to false, preventing sending of small TCP packets.
        Returns:
        True if Nagle's algorithm should be disabled.
      • isSocketOobInline

        public boolean isSocketOobInline()
        Deprecated.
        Indicates if urgent TCP data received on the socket will be received through the socket input stream.
        Returns:
        True if urgent TCP data received on the socket will be received through the socket input stream.
      • isSocketReuseAddress

        public boolean isSocketReuseAddress()
        Deprecated.
        Indicates if sockets can be reused right away even if they are busy (in TIME_WAIT or 2MSL wait state).
        Returns:
        True if sockets can be reused right away even if they are busy (in TIME_WAIT or 2MSL wait state).