Package org.restlet.ext.nio
Class ConnectionHelper<T extends Connector>
- java.lang.Object
-
- org.restlet.engine.Helper
-
- org.restlet.engine.RestletHelper<T>
-
- org.restlet.engine.connector.ConnectorHelper<T>
-
- org.restlet.ext.nio.BaseHelper<T>
-
- org.restlet.ext.nio.ConnectionHelper<T>
-
- 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 Summary
Fields Modifier and Type Field Description private ConnectionPool<T>connectionPoolDeprecated.The connection pool.private java.util.List<Connection<T>>connectionsDeprecated.The set of active connections.-
Fields inherited from class org.restlet.ext.nio.BaseHelper
clientSide, controller, inboundMessages, outboundMessages
-
-
Constructor Summary
Constructors Constructor Description ConnectionHelper(T connector, boolean clientSide)Deprecated.Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddOutboundMessage(Response response)Deprecated.Add the outbound message to the queue and wake up the IO controller.voidcheckin(Connection<?> connection)Deprecated.Checks in the connection back into the pool.Connection<T>checkout(java.nio.channels.SocketChannel socketChannel, ConnectionController controller, java.net.InetSocketAddress socketAddress)Deprecated.Checks out a connection associated to the given socket from the pool.voidconfigure(java.net.Socket socket)Deprecated.Configures a given socket based on the helper parameters.abstract Connection<T>createConnection(java.nio.channels.SocketChannel socketChannel, ConnectionController controller, java.net.InetSocketAddress socketAddress)Deprecated.Creates a connection associated to the given socket.voidcreateConnectionPool()Deprecated.Creates the connection pool.abstract InboundWaycreateInboundWay(Connection<T> connection, int bufferSize)Deprecated.Creates an inbound way for the given connection.abstract OutboundWaycreateOutboundWay(Connection<T> connection, int bufferSize)Deprecated.Creates an outbound way for the given connection.protected voiddoFinishStop()Deprecated.Finish stopping the helper.protected voiddoGracefulStop()Deprecated.Do a graceful stop first.ConnectionPool<T>getConnectionPool()Deprecated.Returns the connection pool.java.util.List<Connection<T>>getConnections()Deprecated.Returns the set of active connections.intgetInitialConnections()Deprecated.Returns the initial number of connections pre-created in the connections pool.intgetMaxConnectionsPerHost()Deprecated.Returns the maximum concurrent connections per host (IP address).intgetMaxTotalConnections()Deprecated.Returns the maximum number of concurrent connections allowed.intgetSocketLingerTimeMs()Deprecated.Returns the time to block when a socket close is requested or -1 to not block at all.intgetSocketReceiveBufferSize()Deprecated.Returns the hinted size of the underlying TCP buffers used by the platform for inbound network I/O.intgetSocketSendBufferSize()Deprecated.Returns the hinted size of the underlying TCP buffers used by the platform for outbound network I/O.intgetSocketTrafficClass()Deprecated.Returns the type of service to set in IP packets.booleanisPersistingConnections()Deprecated.Indicates if persistent connections should be used if possible.booleanisPipeliningConnections()Deprecated.Indicates if pipelining connections are supported.booleanisPooledConnection()Deprecated.Indicates if the connection objects should be pooled to save instantiation time.abstract booleanisProxying()Deprecated.Indicates if the helper is going through a client proxy or is a server proxy.booleanisSocketKeepAlive()Deprecated.Indicates if a TCP connection should be automatically kept alive after 2 hours of inactivity.booleanisSocketNoDelay()Deprecated.Enables Nagle's algorithm if set to false, preventing sending of small TCP packets.booleanisSocketOobInline()Deprecated.Indicates if urgent TCP data received on the socket will be received through the socket input stream.booleanisSocketReuseAddress()Deprecated.Indicates if sockets can be reused right away even if they are busy (in TIME_WAIT or 2MSL wait state).-
Methods inherited from class org.restlet.ext.nio.BaseHelper
control, createController, createControllerService, createRequest, createWorkerService, doHandleInbound, doHandleOutbound, execute, getController, getControllerSleepTimeMs, getInboundBufferSize, getInboundMessages, getLowThreads, getMaxIoIdleTimeMs, getMaxQueued, getMaxThreadIdleTimeMs, getMaxThreads, getMinThreads, getOutboundBufferSize, getOutboundMessages, getRequest, getThrottleTimeMs, getTraceStream, getTransport, getWorkerService, handleInbound, handleInbound, handleOutbound, handleOutbound, hasWorkerThreads, isClientSide, isControllerDaemon, isDirectBuffers, isServerSide, isTracing, isWorkerServiceOverloaded, onInboundError, onOutboundError, start, stop, traceWorkerService
-
Methods inherited from class org.restlet.engine.connector.ConnectorHelper
getConnectorService, getContext, getProtocols, update
-
Methods inherited from class org.restlet.engine.RestletHelper
getAttributes, getHelped, getHelpedParameters, getLogger, getMetadataService, handle, setHelped
-
-
-
-
Field Detail
-
connectionPool
private volatile ConnectionPool<T extends Connector> connectionPool
Deprecated.The connection pool.
-
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.SocketExceptionDeprecated.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.
-
doFinishStop
protected void doFinishStop()
Deprecated.Description copied from class:BaseHelperFinish stopping the helper.- Overrides:
doFinishStopin classBaseHelper<T extends Connector>
-
doGracefulStop
protected void doGracefulStop()
Deprecated.Description copied from class:BaseHelperDo a graceful stop first.- Overrides:
doGracefulStopin classBaseHelper<T extends Connector>
-
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).
-
-