Package org.apache.solr.search
Class TimeAllowedLimit
- java.lang.Object
-
- org.apache.solr.search.TimeAllowedLimit
-
- All Implemented Interfaces:
org.apache.lucene.index.QueryTimeout
,QueryLimit
public class TimeAllowedLimit extends Object implements QueryLimit
Enforces a wall clock based timeout on a given SolrQueryRequest. This class holds the logic for thetimeAllowed
query parameter. Note that timeAllowed will be ignored for local processing of sub-queries in cases where the parent query already hastimeAllowed
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
-
-
Constructor Summary
Constructors Constructor Description TimeAllowedLimit(SolrQueryRequest req)
Create an object to represent a time limit for the current request.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
currentValue()
A value representing the portion of the specified limit that has been consumed.boolean
shouldExit()
Return true if a max limit value is set and the current usage has exceeded the limit.
-
-
-
Constructor Detail
-
TimeAllowedLimit
public TimeAllowedLimit(SolrQueryRequest req)
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 Detail
-
shouldExit
public boolean shouldExit()
Return true if a max limit value is set and the current usage has exceeded the limit.- Specified by:
shouldExit
in interfaceorg.apache.lucene.index.QueryTimeout
-
currentValue
public Object currentValue()
Description copied from interface:QueryLimit
A value representing the portion of the specified limit that has been consumed. Reading this value should never affect the outcome (other than the time it takes to do it).- Specified by:
currentValue
in 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.
-
-