Class ConnectionLimit

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

@Deprecated(forRemoval=true, since="12.0.24") @ManagedObject public class ConnectionLimit extends org.eclipse.jetty.util.component.AbstractLifeCycle implements org.eclipse.jetty.io.Connection.Listener, org.eclipse.jetty.io.SelectorManager.AcceptListener
Deprecated, for removal: This API element is subject to removal in a future version.

A Listener that limits the number of Connections.

This listener applies a limit to the number of connections, which when exceeded results in a call to AbstractConnector.setAccepting(boolean) to prevent further connections being received. This listener can be applied to an entire Server or to a specific Connector by adding it via Container.addBean(Object).

When the number of connections is exceeded, the idle timeout of existing connections is changed with the value configured in this listener (typically a shorter value).

Usage:

  Server server = new Server();
  server.addBean(new ConnectionLimit(5000,server));
  ...
  server.start();
See Also:
  • 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
    ConnectionLimit(int maxConnections, Connector... connectors)
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    ConnectionLimit(int maxConnections, Server server)
    Deprecated, for removal: This API element is subject to removal in a future version.
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    protected void
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    int
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    long
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    int
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    int
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    protected void
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    void
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    void
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    void
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    void
    onClosed(org.eclipse.jetty.io.Connection connection)
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    void
    onOpened(org.eclipse.jetty.io.Connection connection)
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    void
    setIdleTimeout(long idleTimeout)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Sets the endpoint idle timeout in ms to apply when the connection limit is reached.
    void
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    protected void
    Deprecated, for removal: This API element is subject to removal in a future version.
     

    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

    onClosed
  • Constructor Details

    • ConnectionLimit

      public ConnectionLimit(@Name("maxConnections") int maxConnections, @Name("server") Server server)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • ConnectionLimit

      public ConnectionLimit(@Name("maxConnections") int maxConnections, @Name("connectors") Connector... connectors)
      Deprecated, for removal: This API element is subject to removal in a future version.
  • Method Details

    • getIdleTimeout

      @ManagedAttribute("The endpoint idle timeout in ms to apply when the connection limit is reached") public long getIdleTimeout()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns:
      the endpoint idle timeout in ms to apply when the connection limit is reached
    • setIdleTimeout

      public void setIdleTimeout(long idleTimeout)
      Deprecated, for removal: This API element is subject to removal in a future version.

      Sets the endpoint idle timeout in ms to apply when the connection limit is reached.

      A value less than or equal to zero will not change the existing idle timeout.

      Parameters:
      idleTimeout - the endpoint idle timeout in ms to apply when the connection limit is reached
    • getMaxConnections

      @ManagedAttribute("The maximum number of connections allowed") public int getMaxConnections()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • setMaxConnections

      public void setMaxConnections(int max)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getConnections

      @ManagedAttribute(value="The current number of connections", readonly=true) public int getConnections()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getPendingConnections

      @ManagedAttribute(value="The current number of pending connections", readonly=true) public int getPendingConnections()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • doStart

      protected void doStart() throws Exception
      Deprecated, for removal: This API element is subject to removal in a future version.
      Overrides:
      doStart in class org.eclipse.jetty.util.component.AbstractLifeCycle
      Throws:
      Exception
    • doStop

      protected void doStop() throws Exception
      Deprecated, for removal: This API element is subject to removal in a future version.
      Overrides:
      doStop in class org.eclipse.jetty.util.component.AbstractLifeCycle
      Throws:
      Exception
    • limit

      protected void limit()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • unlimit

      protected void unlimit()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • onAccepting

      public void onAccepting(SelectableChannel channel)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Specified by:
      onAccepting in interface org.eclipse.jetty.io.SelectorManager.AcceptListener
    • onAcceptFailed

      public void onAcceptFailed(SelectableChannel channel, Throwable cause)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Specified by:
      onAcceptFailed in interface org.eclipse.jetty.io.SelectorManager.AcceptListener
    • onAccepted

      public void onAccepted(SelectableChannel channel)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Specified by:
      onAccepted in interface org.eclipse.jetty.io.SelectorManager.AcceptListener
    • onOpened

      public void onOpened(org.eclipse.jetty.io.Connection connection)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Specified by:
      onOpened in interface org.eclipse.jetty.io.Connection.Listener
    • onClosed

      public void onClosed(org.eclipse.jetty.io.Connection connection)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Specified by:
      onClosed in interface org.eclipse.jetty.io.Connection.Listener