Package org.apache.solr.search
Class MemAllowedLimit
- java.lang.Object
-
- org.apache.solr.search.MemAllowedLimit
-
- All Implemented Interfaces:
org.apache.lucene.index.QueryTimeout
,QueryLimit
public class MemAllowedLimit extends Object implements QueryLimit
Enforces a memory-based limit on a given SolrQueryRequest, as specified by thememAllowed
query parameter.This class tracks per-thread memory allocations during a request using its own ThreadLocal. It records the current thread allocation when the instance was created (typically at the start of SolrQueryRequest processing) as a starting point, and then on every call to
shouldExit()
it accumulates the amount of reported allocated memory since the previous call, and compares the accumulated amount to the configured threshold, expressed in mebi-bytes.NOTE: this class accesses
com.sun.management.ThreadMXBean#getCurrentThreadAllocatedBytes
using reflection. On JVM-s where this implementation is not available an exception will be thrown when attempting to use thememAllowed
parameter.
-
-
Constructor Summary
Constructors Constructor Description MemAllowedLimit(SolrQueryRequest req)
-
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()
-
-
-
Constructor Detail
-
MemAllowedLimit
public MemAllowedLimit(SolrQueryRequest req)
-
-
Method Detail
-
shouldExit
public boolean shouldExit()
- 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.
-
-