Class FutureResult

  • All Implemented Interfaces:
    java.lang.Runnable, java.util.concurrent.Future<Result>, java.util.concurrent.RunnableFuture<Result>

    public class FutureResult
    extends java.util.concurrent.FutureTask<Result>
    Extends a FutureTask&lt;Result&gt;, with some added error handling
    Author:
    bratseth
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      ErrorMessage createTimeoutError()  
      Result get()
      Returns a Result containing the hits returned from this source, or an error otherwise.
      Result get​(long timeout, java.util.concurrent.TimeUnit timeunit)
      Returns a Result containing the hits returned from this source, or an error otherwise.
      java.util.Optional<Result> getIfAvailable​(long timeout, java.util.concurrent.TimeUnit timeunit)
      Same as get(timeout, timeunit) but returns Optional.empty instead of a result with error if the result is not available in time
      Query getQuery()
      Returns the query used in this execution, never null
      • Methods inherited from class java.util.concurrent.FutureTask

        cancel, done, isCancelled, isDone, run, runAndReset, set, setException, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • FutureResult

        public FutureResult​(java.util.concurrent.Callable<Result> callable,
                            Execution execution,
                            Query query)
    • Method Detail

      • get

        public Result get()
        Returns a Result containing the hits returned from this source, or an error otherwise. This will block for however long it takes to get the result: Using this is a bad idea.
        Specified by:
        get in interface java.util.concurrent.Future<Result>
        Overrides:
        get in class java.util.concurrent.FutureTask<Result>
      • get

        public Result get​(long timeout,
                          java.util.concurrent.TimeUnit timeunit)
        Returns a Result containing the hits returned from this source, or an error otherwise. This blocks for at most the given timeout and returns a Result containing a timeout error if the result is not available within this time.
        Specified by:
        get in interface java.util.concurrent.Future<Result>
        Overrides:
        get in class java.util.concurrent.FutureTask<Result>
      • getIfAvailable

        public java.util.Optional<Result> getIfAvailable​(long timeout,
                                                         java.util.concurrent.TimeUnit timeunit)
        Same as get(timeout, timeunit) but returns Optional.empty instead of a result with error if the result is not available in time
      • getQuery

        public Query getQuery()
        Returns the query used in this execution, never null
      • createTimeoutError

        public ErrorMessage createTimeoutError()