- All Implemented Interfaces:
Future<T>,ActionFuture<T>,ActionListener<T>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSimilar toFuture.get(), just catching theInterruptedExceptionand throwing anIllegalStateExceptioninstead.Similar toFuture.get(long, java.util.concurrent.TimeUnit), just catching theInterruptedExceptionand throwing anIllegalStateExceptioninstead.Similar toFuture.get(long, java.util.concurrent.TimeUnit), just catching theInterruptedExceptionand throwing anIllegalStateExceptioninstead.Return the result of this future, if it has been completed successfully, or unwrap and throw the exception with which it was completed exceptionally.protected booleanbooleancancel(boolean mayInterruptIfRunning) protected voiddone(boolean success) Called when thePlainActionFuture<Object>is completed.get()static <T,E extends Exception>
Tget(CheckedConsumer<PlainActionFuture<T>, E> e) static <T,E extends Exception>
Tget(CheckedConsumer<PlainActionFuture<T>, E> e, long timeout, TimeUnit unit) booleanbooleanisDone()voidA failure caused by an exception at some phase of the task.voidonResponse(T result) Handle action response.result()Return the result of this future, similarly toFutureUtils.get(java.util.concurrent.Future<T>)with a zero timeout except that this method ignores the interrupted status of the calling thread.protected final booleanSubclasses should invoke this method to set the result of the computation tovalue.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.elasticsearch.action.ActionListener
delegateFailure, delegateFailureAndWrap, delegateResponse, map, safeMap
-
Constructor Details
-
PlainActionFuture
public PlainActionFuture()
-
-
Method Details
-
onResponse
Description copied from interface:ActionListenerHandle action response. This response may constitute a failure or a success but it is up to the listener to make that decision.- Specified by:
onResponsein interfaceActionListener<T>
-
onFailure
Description copied from interface:ActionListenerA failure caused by an exception at some phase of the task.- Specified by:
onFailurein interfaceActionListener<T>
-
get
public T get(long timeout, TimeUnit unit) throws InterruptedException, TimeoutException, ExecutionException The default
PlainActionFutureimplementation throwsInterruptedExceptionif the current thread is interrupted before or during the call, even if the value is already available.- Specified by:
getin interfaceFuture<T>- Throws:
InterruptedException- if the current thread was interrupted before or during the call (optional but recommended).CancellationExceptionTimeoutExceptionExecutionException
-
get
The default
PlainActionFuture<Object>implementation throwsInterruptedExceptionif the current thread is interrupted before or during the call, even if the value is already available.- Specified by:
getin interfaceFuture<T>- Throws:
InterruptedException- if the current thread was interrupted before or during the call (optional but recommended).CancellationExceptionExecutionException
-
blockingAllowed
protected boolean blockingAllowed() -
isDone
public boolean isDone() -
isCancelled
public boolean isCancelled()- Specified by:
isCancelledin interfaceFuture<T>
-
cancel
public boolean cancel(boolean mayInterruptIfRunning) -
set
Subclasses should invoke this method to set the result of the computation tovalue. This will set the state of the future toPlainActionFuture.Sync.COMPLETEDand calldone(boolean)if the state was successfully changed.- Parameters:
value- the value that was the result of the task.- Returns:
- true if the state was successfully changed.
-
done
protected void done(boolean success) Called when thePlainActionFuture<Object>is completed. Thesuccessboolean indicates if thePlainActionFuture<Object>was successfully completed (the value istrue). In the cases thePlainActionFuture<Object>was completed with an error or cancelled the value isfalse.- Parameters:
success- indicates if thePlainActionFuture<Object>was completed with success (true); in other cases it equals false
-
actionGet
Description copied from interface:ActionFutureSimilar toFuture.get(), just catching theInterruptedExceptionand throwing anIllegalStateExceptioninstead. Also catchesExecutionExceptionand throws the actual cause instead.- Specified by:
actionGetin interfaceActionFuture<T>
-
actionGet
Description copied from interface:ActionFutureSimilar toFuture.get(long, java.util.concurrent.TimeUnit), just catching theInterruptedExceptionand throwing anIllegalStateExceptioninstead. Also catchesExecutionExceptionand throws the actual cause instead.- Specified by:
actionGetin interfaceActionFuture<T>
-
actionGet
Description copied from interface:ActionFutureSimilar toFuture.get(long, java.util.concurrent.TimeUnit), just catching theInterruptedExceptionand throwing anIllegalStateExceptioninstead. Also catchesExecutionExceptionand throws the actual cause instead.- Specified by:
actionGetin interfaceActionFuture<T>
-
result
Return the result of this future, similarly toFutureUtils.get(java.util.concurrent.Future<T>)with a zero timeout except that this method ignores the interrupted status of the calling thread.As with
FutureUtils.get(java.util.concurrent.Future<T>), if the future completed exceptionally with aRuntimeExceptionthen this method throws that exception, but if the future completed exceptionally with an exception that is not aRuntimeExceptionthen this method throws anUncategorizedExecutionExceptionwhose cause is anExecutionExceptionwhose cause is the completing exception.It is not valid to call this method if the future is incomplete.
- Returns:
- the result of this future, if it has been completed successfully.
- Throws:
RuntimeException- if this future was completed exceptionally, wrapping checked exceptions as described above.CancellationException- if this future was cancelled.
-
actionResult
Return the result of this future, if it has been completed successfully, or unwrap and throw the exception with which it was completed exceptionally. It is not valid to call this method if the future is incomplete. -
get
- Throws:
E extends Exception
-
get
public static <T,E extends Exception> T get(CheckedConsumer<PlainActionFuture<T>, E> e, long timeout, TimeUnit unit) throws E- Throws:
E extends Exception
-