Package com.yahoo.search.searchchain
Class FutureResult
- java.lang.Object
-
- java.util.concurrent.FutureTask<Result>
-
- com.yahoo.search.searchchain.FutureResult
-
- All Implemented Interfaces:
Runnable
,Future<Result>
,RunnableFuture<Result>
public class FutureResult extends FutureTask<Result>
Extends aFutureTask<Result>
, with some added error handling- Author:
- bratseth
-
-
Constructor Summary
Constructors Constructor Description FutureResult(Callable<Result> callable, Execution execution, Query query)
-
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, TimeUnit timeunit)
Returns a Result containing the hits returned from this source, or an error otherwise.Execution
getExecution()
Returns the execution which creates thisOptional<Result>
getIfAvailable(long timeout, TimeUnit timeunit)
Same as get(timeout, timeunit) but returns Optional.empty instead of a result with error if the result is not available in timeQuery
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
-
-
-
-
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.
-
get
public Result get(long timeout, 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.
-
getIfAvailable
public Optional<Result> getIfAvailable(long timeout, 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
-
getExecution
public Execution getExecution()
Returns the execution which creates this
-
createTimeoutError
public ErrorMessage createTimeoutError()
-
-