java.lang.Runnable, java.util.EventListener, org.eclipse.jetty.io.SelectorManager.AcceptListener@ManagedObject
public class AcceptRateLimit
extends org.eclipse.jetty.util.component.AbstractLifeCycle
implements org.eclipse.jetty.io.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.AcceptListener| Constructor | 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 | 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) |
|
void |
reset() |
|
void |
run() |
|
protected void |
unlimit() |
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, setStopTimeout, start, stop, toStringpublic AcceptRateLimit(@Name("acceptRateLimit")
int acceptRateLimit,
@Name("period")
long period,
@Name("units")
java.util.concurrent.TimeUnit units,
@Name("server")
Server server)
public AcceptRateLimit(@Name("limit")
int limit,
@Name("period")
long period,
@Name("units")
java.util.concurrent.TimeUnit units,
@Name("connectors")
Connector... connectors)
@ManagedAttribute("The accept rate limit")
public int getAcceptRateLimit()
@ManagedAttribute("The accept rate period")
public long getPeriod()
@ManagedAttribute("The accept rate period units")
public java.util.concurrent.TimeUnit getUnits()
@ManagedAttribute("The current accept rate")
public int getRate()
@ManagedAttribute("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 org.eclipse.jetty.util.component.AbstractLifeCyclejava.lang.Exceptionprotected void doStop()
throws java.lang.Exception
doStop in class org.eclipse.jetty.util.component.AbstractLifeCyclejava.lang.Exceptionprotected void limit()
protected void unlimit()
public void onAccepting(java.nio.channels.SelectableChannel channel)
onAccepting in interface org.eclipse.jetty.io.SelectorManager.AcceptListenerpublic void run()
run in interface java.lang.RunnableCopyright © 1995–2018 Webtide. All rights reserved.