Package org.apache.solr.search
Class TimeAllowedLimit
java.lang.Object
org.apache.solr.search.TimeAllowedLimit
- All Implemented Interfaces:
org.apache.lucene.index.QueryTimeout,QueryLimit
Enforces a wall clock based timeout on a given SolrQueryRequest. This class holds the logic for
the
timeAllowed query parameter. Note that timeAllowed will be ignored for
local processing of sub-queries in cases where the parent query already
has timeAllowed set. Essentially only one timeAllowed can be specified for any thread
executing a query. This is to ensure that subqueries don't escape from the intended limit.
Distributed requests will approximately track the original starting point of the parent
request. Shard requests may be skipped if the limit would run out shortly after they are sent -
this in-flight allowance is determined by INFLIGHT_PARAM in milliseconds, with the
default value of DEFAULT_INFLIGHT_MS.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreate an object to represent a time limit for the current request. -
Method Summary
Modifier and TypeMethodDescriptionbooleanadjustShardRequestLimit(ShardRequest sreq, String shard, org.apache.solr.common.params.ModifiableSolrParams params) Allow limit to adjust shard request parameters if needed.Return elapsed time in nanoseconds since this limit was started.booleanReturn true if a max limit value is set and the current usage has exceeded the limit.
-
Field Details
-
USED_PARAM
- See Also:
-
INFLIGHT_PARAM
- See Also:
-
DEFAULT_INFLIGHT_MS
public static final long DEFAULT_INFLIGHT_MSArbitrary small amount of time to account for network flight time in ms- See Also:
-
-
Constructor Details
-
TimeAllowedLimit
Create an object to represent a time limit for the current request.- Parameters:
req- A solr request that has a value fortimeAllowed- Throws:
IllegalArgumentException- if the request does not contain timeAllowed parameter. This should be validated withhasTimeLimit(SolrQueryRequest)prior to constructing this object
-
-
Method Details
-
adjustShardRequestLimit
public boolean adjustShardRequestLimit(ShardRequest sreq, String shard, org.apache.solr.common.params.ModifiableSolrParams params) Description copied from interface:QueryLimitAllow limit to adjust shard request parameters if needed.- Specified by:
adjustShardRequestLimitin interfaceQueryLimit- Returns:
- true if the shard request should be skipped because a limit will be tripped after sending, during execution.
-
shouldExit
public boolean shouldExit()Return true if a max limit value is set and the current usage has exceeded the limit.- Specified by:
shouldExitin interfaceorg.apache.lucene.index.QueryTimeout
-
currentValue
Return elapsed time in nanoseconds since this limit was started.- Specified by:
currentValuein interfaceQueryLimit- Returns:
- an expression of the amount of the limit used so far, numeric if possible, if non-numeric it should have toString() suitable for logging or similar expression to the user.
-