java.lang.Object
org.elasticsearch.action.support.PlainActionFuture<T>
- All Implemented Interfaces:
Future<T>,ActionFuture<T>,ActionListener<T>
- Direct Known Subclasses:
UnsafePlainActionFuture
-
Nested Class Summary
Nested classes/interfaces inherited from interface java.util.concurrent.Future
Future.State -
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.protected booleanbooleancancel(boolean mayInterruptIfRunning) protected voiddone(boolean success) Called when thePlainActionFuture<Object>is completed.get()booleanbooleanisDone()voidComplete this listener with an exceptional response.voidonResponse(T result) Complete this listener with a successful (or at least, non-exceptional) 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, delegateFailureIgnoreResponseAndWrap, delegateResponse, map, safeMapMethods inherited from interface java.util.concurrent.Future
exceptionNow, resultNow, state
-
Constructor Details
-
PlainActionFuture
public PlainActionFuture()
-
-
Method Details
-
onResponse
Description copied from interface:ActionListenerComplete this listener with a successful (or at least, non-exceptional) response.- Specified by:
onResponsein interfaceActionListener<T>
-
onFailure
Description copied from interface:ActionListenerComplete this listener with an exceptional response.- 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. -
get
The default
PlainActionFuture<Object>implementation throwsInterruptedExceptionif the current thread is interrupted before or during the call, even if the value is already available. -
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.If the future completed exceptionally then this method throws an
ExecutionExceptionwhose 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:
ExecutionException- if this future was completed exceptionally.CancellationException- if this future was cancelled.IllegalStateException- if this future is incomplete.
-