Class RequestLimitConfig
- All Implemented Interfaces:
Serializable
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
The default maximum number of active requests.static final int
The default limit on the number of requests, as a percentage of the requested maximum active requests.static final int
The default threshold for activating request limiting, as a percentage of the requested maximum active requests. -
Constructor Summary
ConstructorDescriptionRequestLimitConfig
(int maxActiveRequests, int requestThresholdPercent, int nodeLimitPercent) Creates a request limiting configuration. -
Method Summary
Modifier and TypeMethodDescriptionstatic RequestLimitConfig
Returns an instance that uses the default values.int
Returns the maximum number of active requests permitted by the KVS client.int
Returns the maximum number of requests that may be active at a node.int
Returns the percentage used to compute the maximum number of requests that may be active at a node.int
Returns the threshold number of requests above which the request limiting mechanism is activated.int
Returns the percentage used to compute the active request threshold above which the request limiting mechanism is activated.toString()
-
Field Details
-
DEFAULT_MAX_ACTIVE_REQUESTS
public static final int DEFAULT_MAX_ACTIVE_REQUESTSThe default maximum number of active requests.- See Also:
-
DEFAULT_REQUEST_THRESHOLD_PERCENT
public static final int DEFAULT_REQUEST_THRESHOLD_PERCENTThe default threshold for activating request limiting, as a percentage of the requested maximum active requests.- See Also:
-
DEFAULT_NODE_LIMIT_PERCENT
public static final int DEFAULT_NODE_LIMIT_PERCENTThe default limit on the number of requests, as a percentage of the requested maximum active requests.- See Also:
-
-
Constructor Details
-
RequestLimitConfig
public RequestLimitConfig(int maxActiveRequests, int requestThresholdPercent, int nodeLimitPercent) Creates a request limiting configuration. The request limiting mechanism is only activated when the number of active requests exceeds the threshold specified by the parameterrequestThresholdPercent
. Both the threshold and limit parameters below are expressed as a percentage ofmaxActiveRequests
.When the mechanism is active the number of active requests to a node is not allowed to exceed
nodeRequestLimitPercent
. Any new requests that would exceed this limit are rejected and aRequestLimitException
is thrown.For example, consider a configuration with maxActiveRequests=10, requestThresholdPercent=80 and nodeLimitPercent=50. If 8 requests are already active at the client, and a 9th request is received that would be directed at a node which already has 5 active requests, it would result in a
RequestLimitException
being thrown. If only 7 requests were active at the client, the 8th request would be directed at the node with 5 active requests and the request would be processed normally.- Parameters:
maxActiveRequests
- the maximum number of active requests permitted by the KV client. This number is typically derived from the maximum number of threads that the client has set aside for processing requests. The default is 100. Note that the KVStore does not actually enforce this maximum directly. It only uses this parameter as the basis for calculating the requests limits to be enforced at a node.requestThresholdPercent
- the threshold computed as a percentage ofmaxActiveRequests
at which requests are limited. The default is 90.nodeLimitPercent
- determines the maximum number of active requests that can be associated with a node when the request limiting mechanism is active. The default is 80.- Throws:
IllegalArgumentException
- if any argument is 0 or less, ifrequestThresholdPercent
is greater than 100, or ifnodeLimitPercent
is greater thanrequestThresholdPercent
-
-
Method Details
-
getMaxActiveRequests
public int getMaxActiveRequests()Returns the maximum number of active requests permitted by the KVS client.The default value is 100.
-
getRequestThresholdPercent
public int getRequestThresholdPercent()Returns the percentage used to compute the active request threshold above which the request limiting mechanism is activated.The default value is 90.
-
getRequestThreshold
public int getRequestThreshold()Returns the threshold number of requests above which the request limiting mechanism is activated. -
getNodeLimitPercent
public int getNodeLimitPercent()Returns the percentage used to compute the maximum number of requests that may be active at a node.The default value is 80.
-
getNodeLimit
public int getNodeLimit()Returns the maximum number of requests that may be active at a node. -
toString
-
getDefault
Returns an instance that uses the default values.
-