Package org.apache.solr.search
Class CpuAllowedLimit
- java.lang.Object
-
- org.apache.solr.search.CpuAllowedLimit
-
- All Implemented Interfaces:
org.apache.lucene.index.QueryTimeout,QueryLimit
@NotThreadSafe public class CpuAllowedLimit extends Object implements QueryLimit
Enforces a CPU-time based timeout on a given SolrQueryRequest, as specified by thecpuAllowedquery parameter.Since this class uses
ThreadCpuTimerit is irrevocably lock-hostile and can never be exposed to multiple threads, even if guarded by synchronization. Normally this is attached to objects ultimately held by a ThreadLocal inSolrRequestInfoto provide safe usage on the assumption that such objects are not shared to other threads.- See Also:
ThreadCpuTimer
-
-
Field Summary
Fields Modifier and Type Field Description static StringTIMING_CONTEXT
-
Constructor Summary
Constructors Constructor Description CpuAllowedLimit(SolrQueryRequest req)Create an object to represent a CPU time limit for the current request.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ObjectcurrentValue()A value representing the portion of the specified limit that has been consumed.booleanshouldExit()Return true if usage has exceeded the limit.
-
-
-
Field Detail
-
TIMING_CONTEXT
public static final String TIMING_CONTEXT
-
-
Constructor Detail
-
CpuAllowedLimit
public CpuAllowedLimit(SolrQueryRequest req)
Create an object to represent a CPU time limit for the current request. NOTE: this implementation will attempt to obtain an existing thread CPU time monitor, created whenQueryLimits(SolrQueryRequest, SolrQueryResponse)is called.- Parameters:
req- solr request with acpuAllowedparameter
-
-
Method Detail
-
shouldExit
public boolean shouldExit()
Return true if usage has exceeded the limit.- Specified by:
shouldExitin interfaceorg.apache.lucene.index.QueryTimeout
-
currentValue
public Object currentValue()
Description copied from interface:QueryLimitA 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:
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.
-
-