Class 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 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
    • 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 for timeAllowed
        Throws:
        IllegalArgumentException - if the request does not contain timeAllowed parameter. This should be validated with hasTimeLimit(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 interface org.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 interface QueryLimit
        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.