Package com.unboundid.ldap.listener
Class RateLimiterRequestHandler
- java.lang.Object
-
- com.unboundid.ldap.listener.LDAPListenerRequestHandler
-
- com.unboundid.ldap.listener.RateLimiterRequestHandler
-
@NotMutable @ThreadSafety(level=COMPLETELY_THREADSAFE) public final class RateLimiterRequestHandler extends LDAPListenerRequestHandler
This class provides an implementation of an LDAP listener request handler that can be used to apply rate limiting to client requests. It uses one or moreFixedRateBarrier
instances to enforce the rate limiting, and provides the ability to control rate limiting on a per-operation-type basis.
-
-
Constructor Summary
Constructors Constructor Description RateLimiterRequestHandler(LDAPListenerRequestHandler downstreamRequestHandler, int maxPerSecond)
Creates a new rate limiter request handler that will limit the rate of operations to the specified maximum number per second.RateLimiterRequestHandler(LDAPListenerRequestHandler downstreamRequestHandler, FixedRateBarrier rateLimiter)
Creates a new rate limiter request handler that will use the providedFixedRateBarrier
to perform rate limiting for all types of operations except abandon and unbind.RateLimiterRequestHandler(LDAPListenerRequestHandler downstreamRequestHandler, FixedRateBarrier abandonRateLimiter, FixedRateBarrier addRateLimiter, FixedRateBarrier bindRateLimiter, FixedRateBarrier compareRateLimiter, FixedRateBarrier deleteRateLimiter, FixedRateBarrier extendedRateLimiter, FixedRateBarrier modifyRateLimiter, FixedRateBarrier modifyDNRateLimiter, FixedRateBarrier searchRateLimiter)
Creates a new rate limiter request handler that can use the providedFixedRateBarrier
instances to perform rate limiting for different types of operations.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RateLimiterRequestHandler
newInstance(LDAPListenerClientConnection connection)
Creates a new instance of this request handler that will be used to process requests read by the provided connection.void
processAbandonRequest(int messageID, AbandonRequestProtocolOp request, java.util.List<Control> controls)
Performs any processing necessary for the provided abandon request.LDAPMessage
processAddRequest(int messageID, AddRequestProtocolOp request, java.util.List<Control> controls)
Performs any processing necessary for the provided add request.LDAPMessage
processBindRequest(int messageID, BindRequestProtocolOp request, java.util.List<Control> controls)
Performs any processing necessary for the provided bind request.LDAPMessage
processCompareRequest(int messageID, CompareRequestProtocolOp request, java.util.List<Control> controls)
Performs any processing necessary for the provided compare request.LDAPMessage
processDeleteRequest(int messageID, DeleteRequestProtocolOp request, java.util.List<Control> controls)
Performs any processing necessary for the provided delete request.LDAPMessage
processExtendedRequest(int messageID, ExtendedRequestProtocolOp request, java.util.List<Control> controls)
Performs any processing necessary for the provided extended request.LDAPMessage
processModifyDNRequest(int messageID, ModifyDNRequestProtocolOp request, java.util.List<Control> controls)
Performs any processing necessary for the provided modify DN request.LDAPMessage
processModifyRequest(int messageID, ModifyRequestProtocolOp request, java.util.List<Control> controls)
Performs any processing necessary for the provided modify request.LDAPMessage
processSearchRequest(int messageID, SearchRequestProtocolOp request, java.util.List<Control> controls)
Performs any processing necessary for the provided search request.-
Methods inherited from class com.unboundid.ldap.listener.LDAPListenerRequestHandler
closeInstance, processUnbindRequest
-
-
-
-
Constructor Detail
-
RateLimiterRequestHandler
public RateLimiterRequestHandler(LDAPListenerRequestHandler downstreamRequestHandler, int maxPerSecond)
Creates a new rate limiter request handler that will limit the rate of operations to the specified maximum number per second. The rate limiting will be enforced for all types of operations except abandon and unbind. No rate limiting will be enforced for abandon or unbind operations.- Parameters:
downstreamRequestHandler
- The downstream request handler that will be used to actually process the requests after any appropriate rate limiting has been performed. It must not benull
.maxPerSecond
- The maximum number of operations that will be allowed per second, across all types of operations except abandon and unbind. It must be greater than zero.
-
RateLimiterRequestHandler
public RateLimiterRequestHandler(LDAPListenerRequestHandler downstreamRequestHandler, FixedRateBarrier rateLimiter)
Creates a new rate limiter request handler that will use the providedFixedRateBarrier
to perform rate limiting for all types of operations except abandon and unbind. No rate limiting will be enforced for abandon or unbind operations.- Parameters:
downstreamRequestHandler
- The downstream request handler that will be used to actually process the requests after any appropriate rate limiting has been performed. It must not benull
.rateLimiter
- The fixed-rate barrier that will be used to achieve the rate limiting for all types of operations except abandon and unbind. It may benull
if no rate limiting should be performed for any operation types.
-
RateLimiterRequestHandler
public RateLimiterRequestHandler(LDAPListenerRequestHandler downstreamRequestHandler, FixedRateBarrier abandonRateLimiter, FixedRateBarrier addRateLimiter, FixedRateBarrier bindRateLimiter, FixedRateBarrier compareRateLimiter, FixedRateBarrier deleteRateLimiter, FixedRateBarrier extendedRateLimiter, FixedRateBarrier modifyRateLimiter, FixedRateBarrier modifyDNRateLimiter, FixedRateBarrier searchRateLimiter)
Creates a new rate limiter request handler that can use the providedFixedRateBarrier
instances to perform rate limiting for different types of operations. The same barrier instance can be provided for multiple operation types if performance for those operations should be limited in aggregate rather than individually (e.g., if you don't want the total combined rate of search and modify operations to exceed a given threshold, then you could provide the same barrier instance for themodifyRateLimiter
andsearchRateLimiter
arguments).- Parameters:
downstreamRequestHandler
- The downstream request handler that will be used to actually process the requests after any appropriate rate limiting has been performed. It must not benull
.abandonRateLimiter
- The fixed-rate barrier to use when processing abandon operations. It may benull
if no rate limiting should be enforced for abandon operations.addRateLimiter
- The fixed-rate barrier to use when processing add operations. It may benull
if no rate limiting should be enforced for add operations.bindRateLimiter
- The fixed-rate barrier to use when processing bind operations. It may benull
if no rate limiting should be enforced for bind operations.compareRateLimiter
- The fixed-rate barrier to use when processing compare operations. It may benull
if no rate limiting should be enforced for compare operations.deleteRateLimiter
- The fixed-rate barrier to use when processing delete operations. It may benull
if no rate limiting should be enforced for delete operations.extendedRateLimiter
- The fixed-rate barrier to use when processing extended operations. It may benull
if no rate limiting should be enforced for extended operations.modifyRateLimiter
- The fixed-rate barrier to use when processing modify operations. It may benull
if no rate limiting should be enforced for modify operations.modifyDNRateLimiter
- The fixed-rate barrier to use when processing modify DN operations. It may benull
if no rate limiting should be enforced for modify DN operations.searchRateLimiter
- The fixed-rate barrier to use when processing search operations. It may benull
if no rate limiting should be enforced for search operations.
-
-
Method Detail
-
newInstance
public RateLimiterRequestHandler newInstance(LDAPListenerClientConnection connection) throws LDAPException
Creates a new instance of this request handler that will be used to process requests read by the provided connection.- Specified by:
newInstance
in classLDAPListenerRequestHandler
- Parameters:
connection
- The connection with which this request handler instance will be associated.- Returns:
- The request handler instance that will be used for the provided connection.
- Throws:
LDAPException
- If the connection should not be accepted.
-
processAbandonRequest
public void processAbandonRequest(int messageID, AbandonRequestProtocolOp request, java.util.List<Control> controls)
Performs any processing necessary for the provided abandon request.- Overrides:
processAbandonRequest
in classLDAPListenerRequestHandler
- Parameters:
messageID
- The message ID of the LDAP message containing the abandon request.request
- The abandon request that was included in the LDAP message that was received.controls
- The set of controls included in the LDAP message. It may be empty if there were no controls, but will not benull
.
-
processAddRequest
public LDAPMessage processAddRequest(int messageID, AddRequestProtocolOp request, java.util.List<Control> controls)
Performs any processing necessary for the provided add request.- Specified by:
processAddRequest
in classLDAPListenerRequestHandler
- Parameters:
messageID
- The message ID of the LDAP message containing the add request.request
- The add request that was included in the LDAP message that was received.controls
- The set of controls included in the LDAP message. It may be empty if there were no controls, but will not benull
.- Returns:
- The
LDAPMessage
containing the response to send to the client. The protocol op in theLDAPMessage
must be anAddResponseProtocolOp
.
-
processBindRequest
public LDAPMessage processBindRequest(int messageID, BindRequestProtocolOp request, java.util.List<Control> controls)
Performs any processing necessary for the provided bind request.- Specified by:
processBindRequest
in classLDAPListenerRequestHandler
- Parameters:
messageID
- The message ID of the LDAP message containing the bind request.request
- The bind request that was included in the LDAP message that was received.controls
- The set of controls included in the LDAP message. It may be empty if there were no controls, but will not benull
.- Returns:
- The
LDAPMessage
containing the response to send to the client. The protocol op in theLDAPMessage
must be aBindResponseProtocolOp
.
-
processCompareRequest
public LDAPMessage processCompareRequest(int messageID, CompareRequestProtocolOp request, java.util.List<Control> controls)
Performs any processing necessary for the provided compare request.- Specified by:
processCompareRequest
in classLDAPListenerRequestHandler
- Parameters:
messageID
- The message ID of the LDAP message containing the compare request.request
- The compare request that was included in the LDAP message that was received.controls
- The set of controls included in the LDAP message. It may be empty if there were no controls, but will not benull
.- Returns:
- The
LDAPMessage
containing the response to send to the client. The protocol op in theLDAPMessage
must be aCompareResponseProtocolOp
.
-
processDeleteRequest
public LDAPMessage processDeleteRequest(int messageID, DeleteRequestProtocolOp request, java.util.List<Control> controls)
Performs any processing necessary for the provided delete request.- Specified by:
processDeleteRequest
in classLDAPListenerRequestHandler
- Parameters:
messageID
- The message ID of the LDAP message containing the delete request.request
- The delete request that was included in the LDAP message that was received.controls
- The set of controls included in the LDAP message. It may be empty if there were no controls, but will not benull
.- Returns:
- The
LDAPMessage
containing the response to send to the client. The protocol op in theLDAPMessage
must be aDeleteResponseProtocolOp
.
-
processExtendedRequest
public LDAPMessage processExtendedRequest(int messageID, ExtendedRequestProtocolOp request, java.util.List<Control> controls)
Performs any processing necessary for the provided extended request.- Specified by:
processExtendedRequest
in classLDAPListenerRequestHandler
- Parameters:
messageID
- The message ID of the LDAP message containing the extended request.request
- The extended request that was included in the LDAP message that was received.controls
- The set of controls included in the LDAP message. It may be empty if there were no controls, but will not benull
.- Returns:
- The
LDAPMessage
containing the response to send to the client. The protocol op in theLDAPMessage
must be anExtendedResponseProtocolOp
.
-
processModifyRequest
public LDAPMessage processModifyRequest(int messageID, ModifyRequestProtocolOp request, java.util.List<Control> controls)
Performs any processing necessary for the provided modify request.- Specified by:
processModifyRequest
in classLDAPListenerRequestHandler
- Parameters:
messageID
- The message ID of the LDAP message containing the modify request.request
- The modify request that was included in the LDAP message that was received.controls
- The set of controls included in the LDAP message. It may be empty if there were no controls, but will not benull
.- Returns:
- The
LDAPMessage
containing the response to send to the client. The protocol op in theLDAPMessage
must be anModifyResponseProtocolOp
.
-
processModifyDNRequest
public LDAPMessage processModifyDNRequest(int messageID, ModifyDNRequestProtocolOp request, java.util.List<Control> controls)
Performs any processing necessary for the provided modify DN request.- Specified by:
processModifyDNRequest
in classLDAPListenerRequestHandler
- Parameters:
messageID
- The message ID of the LDAP message containing the modify DN request.request
- The modify DN request that was included in the LDAP message that was received.controls
- The set of controls included in the LDAP message. It may be empty if there were no controls, but will not benull
.- Returns:
- The
LDAPMessage
containing the response to send to the client. The protocol op in theLDAPMessage
must be anModifyDNResponseProtocolOp
.
-
processSearchRequest
public LDAPMessage processSearchRequest(int messageID, SearchRequestProtocolOp request, java.util.List<Control> controls)
Performs any processing necessary for the provided search request.- Specified by:
processSearchRequest
in classLDAPListenerRequestHandler
- Parameters:
messageID
- The message ID of the LDAP message containing the search request.request
- The search request that was included in the LDAP message that was received.controls
- The set of controls included in the LDAP message. It may be empty if there were no controls, but will not benull
.- Returns:
- The
LDAPMessage
containing the response to send to the client. The protocol op in theLDAPMessage
must be anSearchResultDoneProtocolOp
.
-
-