@ManagedObject public class AcceptRateLimit extends AbstractLifeCycle implements SelectorManager.AcceptListener, java.lang.Runnable
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.AcceptListenerAbstractLifeCycle.AbstractLifeCycleListenerLifeCycle.Listener| Constructor and Description |
|---|
AcceptRateLimit(int limit,
long period,
java.util.concurrent.TimeUnit units,
Connector... connectors) |
AcceptRateLimit(int acceptRateLimit,
long period,
java.util.concurrent.TimeUnit units,
Server server) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
age(long period,
java.util.concurrent.TimeUnit units) |
protected void |
doStart() |
protected void |
doStop() |
int |
getAcceptRateLimit() |
long |
getMaxRate() |
long |
getPeriod() |
int |
getRate() |
java.util.concurrent.TimeUnit |
getUnits() |
protected void |
limit() |
void |
onAccepting(java.nio.channels.SelectableChannel channel)
Called immediately after a new SelectableChannel is accepted, but
before it has been submitted to the
SelectorManager. |
void |
reset() |
void |
run() |
protected void |
unlimit() |
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, setStopTimeout, start, stop, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitonAccepted, onAcceptFailedpublic AcceptRateLimit(@Name(value="acceptRateLimit") int acceptRateLimit, @Name(value="period") long period, @Name(value="units") java.util.concurrent.TimeUnit units, @Name(value="server") Server server)
@ManagedAttribute(value="The accept rate limit") public int getAcceptRateLimit()
@ManagedAttribute(value="The accept rate period") public long getPeriod()
@ManagedAttribute(value="The accept rate period units") public java.util.concurrent.TimeUnit getUnits()
@ManagedAttribute(value="The current accept rate") public int getRate()
@ManagedAttribute(value="The maximum accept rate achieved") public long getMaxRate()
@ManagedOperation(value="Resets the accept rate", impact="ACTION") public void reset()
protected void age(long period,
java.util.concurrent.TimeUnit units)
protected void doStart()
throws java.lang.Exception
doStart in class AbstractLifeCyclejava.lang.Exceptionprotected void doStop()
throws java.lang.Exception
doStop in class AbstractLifeCyclejava.lang.Exceptionprotected void limit()
protected void unlimit()
public void onAccepting(java.nio.channels.SelectableChannel channel)
SelectorManager.AcceptListenerSelectorManager.onAccepting in interface SelectorManager.AcceptListenerchannel - the accepted channelpublic void run()
run in interface java.lang.RunnableCopyright © 1995–2021 Webtide. All rights reserved.