java.util.EventListener, org.eclipse.jetty.io.Connection.Listener, org.eclipse.jetty.io.SelectorManager.AcceptListener@ManagedObject
public class ConnectionLimit
extends org.eclipse.jetty.util.component.AbstractLifeCycle
implements org.eclipse.jetty.io.Connection.Listener, org.eclipse.jetty.io.SelectorManager.AcceptListener
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. 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 ConnectionLimit(5000,server)); ... server.start();
LowResourceMonitor,
Connection.Listener,
SelectorManager.AcceptListenerorg.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListener| Constructor | Description |
|---|---|
ConnectionLimit(int maxConnections,
Connector... connectors) |
|
ConnectionLimit(int maxConnections,
Server server) |
| Modifier and Type | Method | Description |
|---|---|---|
protected void |
check() |
|
protected void |
doStart() |
|
protected void |
doStop() |
|
int |
getConnections() |
|
long |
getIdleTimeout() |
|
int |
getMaxConnections() |
|
protected void |
limit() |
|
void |
onAccepted(java.nio.channels.SelectableChannel channel) |
|
void |
onAcceptFailed(java.nio.channels.SelectableChannel channel,
java.lang.Throwable cause) |
|
void |
onAccepting(java.nio.channels.SelectableChannel channel) |
|
void |
onClosed(org.eclipse.jetty.io.Connection connection) |
|
void |
onOpened(org.eclipse.jetty.io.Connection connection) |
|
void |
setIdleTimeout(long idleTimeout) |
|
void |
setMaxConnections(int max) |
|
protected void |
unlimit() |
public ConnectionLimit(@Name("maxConnections")
int maxConnections,
@Name("server")
Server server)
public ConnectionLimit(@Name("maxConnections")
int maxConnections,
@Name("connectors")
Connector... connectors)
@ManagedAttribute("The endpoint idle timeout in ms to apply when the connection limit is reached")
public long getIdleTimeout()
public void setIdleTimeout(long idleTimeout)
idleTimeout - If >= 0 the endpoint idle timeout in ms to apply when the connection limit is reached@ManagedAttribute("The maximum number of connections allowed")
public int getMaxConnections()
public void setMaxConnections(int max)
@ManagedAttribute("The current number of connections ")
public int getConnections()
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 check()
protected void limit()
protected void unlimit()
public void onAccepting(java.nio.channels.SelectableChannel channel)
onAccepting in interface org.eclipse.jetty.io.SelectorManager.AcceptListenerpublic void onAcceptFailed(java.nio.channels.SelectableChannel channel,
java.lang.Throwable cause)
onAcceptFailed in interface org.eclipse.jetty.io.SelectorManager.AcceptListenerpublic void onAccepted(java.nio.channels.SelectableChannel channel)
onAccepted in interface org.eclipse.jetty.io.SelectorManager.AcceptListenerpublic void onOpened(org.eclipse.jetty.io.Connection connection)
onOpened in interface org.eclipse.jetty.io.Connection.Listenerpublic void onClosed(org.eclipse.jetty.io.Connection connection)
onClosed in interface org.eclipse.jetty.io.Connection.ListenerCopyright © 1995–2018 Webtide. All rights reserved.