Class AcceptRateLimit

java.lang.Object
org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.server.AcceptRateLimit
All Implemented Interfaces:
Runnable, EventListener, org.eclipse.jetty.io.SelectorManager.AcceptListener, org.eclipse.jetty.io.SelectorManager.SelectorManagerListener, org.eclipse.jetty.util.component.LifeCycle

@ManagedObject public class AcceptRateLimit extends org.eclipse.jetty.util.component.AbstractLifeCycle implements org.eclipse.jetty.io.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:
  • SelectorManager.AcceptListener
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

    org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListener, org.eclipse.jetty.util.component.AbstractLifeCycle.StopException

    Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle

    org.eclipse.jetty.util.component.LifeCycle.Listener
  • Field Summary

    Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

    FAILED, STARTED, STARTING, STOPPED, STOPPING
  • Constructor Summary

    Constructors
    Constructor
    Description
    AcceptRateLimit(int limit, long period, TimeUnit units, Connector... connectors)
     
    AcceptRateLimit(int acceptRateLimit, long period, TimeUnit units, Server server)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    age(long period, TimeUnit units)
     
    protected void
     
    protected void
     
    int
     
    long
     
    long
     
    int
     
     
    protected void
     
    void
     
    void
     
    void
    run()
     
    protected void
     

    Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

    addEventListener, getEventListeners, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeEventListener, setEventListeners, start, stop, toString

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.eclipse.jetty.io.SelectorManager.AcceptListener

    onAccepted, onAcceptFailed, onClosed
  • Constructor Details

    • AcceptRateLimit

      public AcceptRateLimit(@Name("acceptRateLimit") int acceptRateLimit, @Name("period") long period, @Name("units") TimeUnit units, @Name("server") Server server)
    • AcceptRateLimit

      public AcceptRateLimit(@Name("limit") int limit, @Name("period") long period, @Name("units") TimeUnit units, @Name("connectors") Connector... connectors)
  • Method Details

    • getAcceptRateLimit

      @ManagedAttribute("The accept rate limit") public int getAcceptRateLimit()
    • getPeriod

      @ManagedAttribute("The accept rate period") public long getPeriod()
    • getUnits

      @ManagedAttribute("The accept rate period units") public TimeUnit getUnits()
    • getRate

      @ManagedAttribute("The current accept rate") public int getRate()
    • getMaxRate

      @ManagedAttribute("The maximum accept rate achieved") public long getMaxRate()
    • reset

      @ManagedOperation(value="Resets the accept rate", impact="ACTION") public void reset()
    • age

      protected void age(long period, TimeUnit units)
    • doStart

      protected void doStart() throws Exception
      Overrides:
      doStart in class org.eclipse.jetty.util.component.AbstractLifeCycle
      Throws:
      Exception
    • doStop

      protected void doStop() throws Exception
      Overrides:
      doStop in class org.eclipse.jetty.util.component.AbstractLifeCycle
      Throws:
      Exception
    • limit

      protected void limit()
    • unlimit

      protected void unlimit()
    • onAccepting

      public void onAccepting(SelectableChannel channel)
      Specified by:
      onAccepting in interface org.eclipse.jetty.io.SelectorManager.AcceptListener
    • run

      public void run()
      Specified by:
      run in interface Runnable