Package org.eclipse.jetty.server
Class AcceptRateLimit
java.lang.Object
org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.server.AcceptRateLimit
- All Implemented Interfaces:
Runnable
,EventListener
,SelectorManager.AcceptListener
,LifeCycle
@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();
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListener
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.Listener
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final int
private final List
<AbstractConnector> private boolean
private final AcceptRateLimit.Rate
private final Server
private Scheduler.Task
private static final Logger
-
Constructor Summary
ConstructorsConstructorDescriptionAcceptRateLimit
(int limit, long period, TimeUnit units, Connector... connectors) AcceptRateLimit
(int acceptRateLimit, long period, TimeUnit units, Server server) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
protected void
doStart()
protected void
doStop()
int
long
long
int
getRate()
getUnits()
protected void
limit()
void
onAccepting
(SelectableChannel channel) Called immediately after a new SelectableChannel is accepted, but before it has been submitted to theSelectorManager
.void
reset()
void
run()
private void
schedule()
protected void
unlimit()
Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, setStopTimeout, start, stop, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.eclipse.jetty.io.SelectorManager.AcceptListener
onAccepted, onAcceptFailed
-
Field Details
-
LOG
-
_server
-
_connectors
-
_rate
-
_acceptRateLimit
private final int _acceptRateLimit -
_limiting
private boolean _limiting -
_task
-
-
Constructor Details
-
AcceptRateLimit
-
AcceptRateLimit
-
-
Method Details
-
getAcceptRateLimit
-
getPeriod
-
getUnits
-
getRate
-
getMaxRate
-
reset
-
age
-
doStart
- Overrides:
doStart
in classAbstractLifeCycle
- Throws:
Exception
-
doStop
- Overrides:
doStop
in classAbstractLifeCycle
- Throws:
Exception
-
limit
protected void limit() -
unlimit
protected void unlimit() -
onAccepting
Description copied from interface:SelectorManager.AcceptListener
Called immediately after a new SelectableChannel is accepted, but before it has been submitted to theSelectorManager
.- Specified by:
onAccepting
in interfaceSelectorManager.AcceptListener
- Parameters:
channel
- the accepted channel
-
schedule
private void schedule() -
run
public void run()
-