Top Description Inners Fields Constructors Methods
org.eclipse.jetty.server.handler

public Class ThreadLimitHandler

extends Abstract
Class Inheritance
Imports
java.net.InetSocketAddress, java.nio.ByteBuffer, java.nio.channels.WritePendingException, java.util.ArrayDeque, .Deque, .Objects, java.util.concurrent.CompletableFuture, .ConcurrentHashMap, .ConcurrentMap, .Executor, java.util.concurrent.atomic.AtomicReference, java.util.function.Consumer, org.eclipse.jetty.http.HostPortHttpField, .HttpField, .HttpHeader, .HttpStatus, .QuotedCSV, org.eclipse.jetty.server.ForwardedRequestCustomizer, .Handler, .Request, .Response, org.eclipse.jetty.util.Callback, .StringUtil, org.eclipse.jetty.util.annotation.ManagedAttribute, .ManagedOperation, .Name, org.eclipse.jetty.util.thread.AutoLock, org.slf4j.Logger, .LoggerFactory

Handler to limit the threads per IP address for DOS protection

The ThreadLimitHandler applies a limit to the number of Threads that can be used simultaneously per remote IP address.

The handler makes a determination of the remote IP separately to any that may be made by the ForwardedRequestCustomizer or similar:

Requests in excess of the limit will be asynchronously suspended until a thread is available.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class
private static class
private static class
private static class
private static interface
private static class
private static class

Field Summary

Modifier and TypeField and Description
private volatile boolean
private final String
private final ConcurrentMap<String, ThreadLimitHandler.Remote>
private final boolean
private int
private static final Logger

Constructor Summary

AccessConstructor and Description
public
public
ThreadLimitHandler(String forwardedHeader)

public
ThreadLimitHandler(String forwardedHeader, boolean rfc7239)

public
ThreadLimitHandler(Handler handler, String forwardedHeader, boolean rfc7239)

Method Summary

Modifier and TypeMethod and Description
protected void
doStart()

Overrides org.eclipse.jetty.server.handler.ConditionalHandler.doStart.

Starts the managed lifecycle beans in the order they were added.
public void
exclude(String inetAddressPattern)

private String
private ThreadLimitHandler.Remote
getRemote(Request baseRequest)

protected String
getRemoteIP(Request baseRequest)

public int
protected int
private String
public void
include(String inetAddressPattern)

public boolean
public boolean
onConditionsMet(Request
The request to handle
request
,
Response
The response to generate
response
,
Callback
The callback for completion
callback
)

Implements abstract org.eclipse.jetty.server.handler.ConditionalHandler.onConditionsMet.

Handle a request that has met the conditions.
protected boolean
onConditionsNotMet(Request
The request to handle
request
,
Response
The response to generate
response
,
Callback
The callback for completion
callback
)

Implements abstract org.eclipse.jetty.server.handler.ConditionalHandler.onConditionsNotMet.

This method is called when the request has not met the conditions and is not to be handled by this handler.
public void
setEnabled(boolean enabled)

public void
setThreadLimit(int threadLimit)