@ManagedObject public class AcceptRateLimit extends AbstractLifeCycle implements SelectorManager.AcceptListener, 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.AcceptListener
AbstractLifeCycle.AbstractLifeCycleListener
LifeCycle.Listener
Constructor and Description |
---|
AcceptRateLimit(int limit,
long period,
TimeUnit units,
Connector... connectors) |
AcceptRateLimit(int acceptRateLimit,
long period,
TimeUnit units,
Server server) |
Modifier and Type | Method and Description |
---|---|
int |
getAcceptRateLimit() |
long |
getMaxRate() |
long |
getPeriod() |
int |
getRate() |
TimeUnit |
getUnits() |
void |
onAccepting(SelectableChannel channel)
Called immediately after a new SelectableChannel is accepted, but
before it has been submitted to the
SelectorManager . |
void |
reset() |
void |
run() |
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, setStopTimeout, start, stop, toString
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
onAccepted, onAcceptFailed
public AcceptRateLimit(@Name(value="acceptRateLimit") int acceptRateLimit, @Name(value="period") long period, @Name(value="units") 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 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()
public void onAccepting(SelectableChannel channel)
SelectorManager.AcceptListener
SelectorManager
.onAccepting
in interface SelectorManager.AcceptListener
channel
- the accepted channelCopyright © 2010 - 2020 Adobe. All Rights Reserved