A Listener that limits the number of Connections.
This listener applies a limit to the number of connections, which when
exceeded results in a call to AbstractConnector#setAccepting(boolean)
to prevent further connections being received. It can be applied to an
entire server or to a specific connector by adding it via Container#addBean(Object)
Usage:
Server server = new Server(); server.addBean(new ConnectionLimit(5000,server)); ... server.start();
LowResourceMonitor, Connection.Listener , SelectorManager.AcceptListener
| Modifier and Type | Field and Description |
|---|---|
| private final Set | |
| private int | |
| private final List | |
| private long | |
| private boolean | |
| private final AutoLock | |
| private int | |
| private final Server | |
| private static final Logger |
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected void | |
| protected void | doStart()
Overrides org. Method to override to start the lifecycle |
| protected void | doStop()
Overrides org. Method to override to stop the lifecycle |
| public int | |
| public long | getIdleTimeout()
Returns: If >= 0, the endpoint idle timeout in ms to apply when the connection limit is reached |
| public int | |
| protected void | |
| public void | onAccepted(SelectableChannel
the accepted channel channel)Overrides default org. Called after the accepted channel has been allocated an |
| public void | onAcceptFailed(SelectableChannel
the accepted channel channel, Throwable the cause of the failure cause)Overrides default org. Called if the processing of the accepted channel fails prior to calling
|
| public void | onAccepting(SelectableChannel
the accepted channel channel)Overrides default org. Called immediately after a new SelectableChannel is accepted, but
before it has been submitted to the |
| public void | |
| public void | |
| public void | setIdleTimeout(long
If >= 0 the endpoint idle timeout in ms to apply when the connection limit is reached idleTimeout)
|
| public void | |
| protected void |
| _accepting | back to summary |
|---|---|
| private final Set<SelectableChannel> _accepting | |
| _connections | back to summary |
|---|---|
| private int _connections | |
| _connectors | back to summary |
|---|---|
| private final List<AbstractConnector> _connectors | |
| _idleTimeout | back to summary |
|---|---|
| private long _idleTimeout | |
| _limiting | back to summary |
|---|---|
| private boolean _limiting | |
| _lock | back to summary |
|---|---|
| private final AutoLock _lock Hides org. | |
| _maxConnections | back to summary |
|---|---|
| private int _maxConnections | |
| _server | back to summary |
|---|---|
| private final Server _server | |
| LOG | back to summary |
|---|---|
| private static final Logger LOG Hides org. | |
| ConnectionLimit | back to summary |
|---|---|
| public ConnectionLimit(int maxConnections, Server server) | |
| ConnectionLimit | back to summary |
|---|---|
| public ConnectionLimit(int maxConnections, Connector... connectors) | |
| check | back to summary |
|---|---|
| protected void check() | |
| doStart | back to summary |
|---|---|
| protected void doStart() throws Exception Overrides org. Doc from org. Method to override to start the lifecycle | |
| doStop | back to summary |
|---|---|
| protected void doStop() throws Exception Overrides org. Doc from org. Method to override to stop the lifecycle | |
| getConnections | back to summary |
|---|---|
public int getConnections()
| |
| getIdleTimeout | back to summary |
|---|---|
public long getIdleTimeout()
| |
| getMaxConnections | back to summary |
|---|---|
public int getMaxConnections()
| |
| limit | back to summary |
|---|---|
| protected void limit() | |
| onAccepted | back to summary |
|---|---|
| public void onAccepted(SelectableChannel channel) Overrides default org. Doc from org. Called after the accepted channel has been allocated an
| |
| onAcceptFailed | back to summary |
|---|---|
| public void onAcceptFailed(SelectableChannel channel, Throwable cause) Overrides default org. Doc from org. Called if the processing of the accepted channel fails prior to calling
| |
| onAccepting | back to summary |
|---|---|
| public void onAccepting(SelectableChannel channel) Overrides default org. Doc from org. Called immediately after a new SelectableChannel is accepted, but
before it has been submitted to the
| |
| onClosed | back to summary |
|---|---|
| public void onClosed(Connection connection) Overrides default org.
| |
| onOpened | back to summary |
|---|---|
| public void onOpened(Connection connection) Overrides default org.
| |
| setIdleTimeout | back to summary |
|---|---|
public void setIdleTimeout(long idleTimeout)
| |
| setMaxConnections | back to summary |
|---|---|
| public void setMaxConnections(int max) | |
| unlimit | back to summary |
|---|---|
| protected void unlimit() | |