Class NetworkConnectionLimit

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

public class NetworkConnectionLimit extends AbstractLifeCycle implements SelectorManager.AcceptListener

A listener that limits the number of network connections.

This listener applies a limit to the number of network connections, which when exceeded results in a call to AbstractConnector.setAccepting(boolean) to prevent further network connections to be accepted.

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 network connections is exceeded, the idle timeout of existing EndPoints is changed to the value configured in this listener (typically a shorter value). When the number of network connections returns below the limit, as they are closed, the idle timeout of existing EndPoints is restored to that of the connector.

Typical usage:


 Server server = new Server();
 server.addBean(new NetworkConnectionLimit(5000, server));
 ...
 server.start();
 
See Also:
  • Constructor Details

    • NetworkConnectionLimit

      public NetworkConnectionLimit(@Name("maxNetworkConnectionCount") int maxNetworkConnections, @Name("server") Server server)
    • NetworkConnectionLimit

      public NetworkConnectionLimit(@Name("maxNetworkConnectionCount") int maxNetworkConnections, @Name("connectors") Connector... connectors)
  • Method Details