Package org.apache.solr.search
Class MemAllowedLimit
java.lang.Object
org.apache.solr.search.MemAllowedLimit
- All Implemented Interfaces:
org.apache.lucene.index.QueryTimeout,QueryLimit
Enforces a memory-based limit on a given SolrQueryRequest, as specified by the
memAllowed
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 the
memAllowed parameter.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionA value representing the portion of the specified limit that has been consumed.booleanMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.solr.search.QueryLimit
adjustShardRequestLimit
-
Constructor Details
-
MemAllowedLimit
-
-
Method Details
-
shouldExit
public boolean shouldExit()- Specified by:
shouldExitin interfaceorg.apache.lucene.index.QueryTimeout
-
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.
-