A Listener that limits the rate at which new connections are accepted
If the limits are exceeded, accepting is suspended until the rate is again below the limit, so incoming connections are held in the operating system accept queue (no syn ack sent), where they may either timeout or wait for the server to resume accepting.
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 AcceptLimit(100,5,TimeUnit.SECONDS,server)); ... server.start();
SelectorManager.AcceptListener
| Modifier and Type | Class and Description |
|---|---|
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private final int | |
| private final List | |
| private boolean | |
| private final AutoLock | |
| private final AcceptRateLimit. | |
| private final Server | |
| private Scheduler. | |
| 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 | |
| public long | |
| public int | |
| public TimeUnit | |
| protected void | |
| 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 | |
| private void | |
| protected void |
| _acceptRateLimit | back to summary |
|---|---|
| private final int _acceptRateLimit | |
| _connectors | back to summary |
|---|---|
| private final List<AbstractConnector> _connectors | |
| _limiting | back to summary |
|---|---|
| private boolean _limiting | |
| _lock | back to summary |
|---|---|
| private final AutoLock _lock Hides org. | |
| _rate | back to summary |
|---|---|
| private final AcceptRateLimit. | |
| _server | back to summary |
|---|---|
| private final Server _server | |
| _task | back to summary |
|---|---|
| private Scheduler. | |
| LOG | back to summary |
|---|---|
| private static final Logger LOG Hides org. | |
| AcceptRateLimit | back to summary |
|---|---|
| public AcceptRateLimit(int acceptRateLimit, long period, TimeUnit units, Server server) | |
| AcceptRateLimit | back to summary |
|---|---|
| public AcceptRateLimit(int limit, long period, TimeUnit units, Connector... connectors) | |
| age | back to summary |
|---|---|
| protected void age(long period, TimeUnit units) | |
| 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 | |
| getAcceptRateLimit | back to summary |
|---|---|
public int getAcceptRateLimit()
| |
| getMaxRate | back to summary |
|---|---|
public long getMaxRate()
| |
| getPeriod | back to summary |
|---|---|
public long getPeriod()
| |
| getRate | back to summary |
|---|---|
public int getRate()
| |
| getUnits | back to summary |
|---|---|
public TimeUnit getUnits()
| |
| limit | back to summary |
|---|---|
| protected void limit() | |
| 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
| |
| reset | back to summary |
|---|---|
public void reset()
| |
| run | back to summary |
|---|---|
| public void run() Implements java. Doc from java. Runs this operation.
| |
| schedule | back to summary |
|---|---|
| private void schedule() | |
| unlimit | back to summary |
|---|---|
| protected void unlimit() | |
| Modifier and Type | Method and Description |
|---|---|
| protected void |
| Rate | back to summary |
|---|---|
| private Rate(long period, TimeUnit units) | |
| age | back to summary |
|---|---|
| protected void age(long period, TimeUnit units) Overrides org.
| |