- All Implemented Interfaces:
Future<T>
,ActionFuture<T>
,ActionListener<T>
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionSimilar toFuture.get()
, just catching theInterruptedException
and throwing anIllegalStateException
instead.Similar toFuture.get(long, java.util.concurrent.TimeUnit)
, just catching theInterruptedException
and throwing anIllegalStateException
instead.Similar toFuture.get(long, java.util.concurrent.TimeUnit)
, just catching theInterruptedException
and throwing anIllegalStateException
instead.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 boolean
boolean
cancel
(boolean mayInterruptIfRunning) protected void
done
(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) boolean
boolean
isDone()
void
A failure caused by an exception at some phase of the task.void
onResponse
(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 boolean
Subclasses 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, wait
Methods inherited from interface org.elasticsearch.action.ActionListener
delegateFailure, delegateFailureAndWrap, delegateResponse, map, safeMap
-
Constructor Details
-
PlainActionFuture
public PlainActionFuture()
-
-
Method Details
-
onResponse
Description copied from interface:ActionListener
Handle action response. This response may constitute a failure or a success but it is up to the listener to make that decision.- Specified by:
onResponse
in interfaceActionListener<T>
-
onFailure
Description copied from interface:ActionListener
A failure caused by an exception at some phase of the task.- Specified by:
onFailure
in interfaceActionListener<T>
-
get
public T get(long timeout, TimeUnit unit) throws InterruptedException, TimeoutException, ExecutionException The default
PlainActionFuture
implementation throwsInterruptedException
if the current thread is interrupted before or during the call, even if the value is already available.- Specified by:
get
in interfaceFuture<T>
- Throws:
InterruptedException
- if the current thread was interrupted before or during the call (optional but recommended).CancellationException
TimeoutException
ExecutionException
-
get
The default
PlainActionFuture<Object>
implementation throwsInterruptedException
if the current thread is interrupted before or during the call, even if the value is already available.- Specified by:
get
in interfaceFuture<T>
- Throws:
InterruptedException
- if the current thread was interrupted before or during the call (optional but recommended).CancellationException
ExecutionException
-
blockingAllowed
protected boolean blockingAllowed() -
isDone
public boolean isDone() -
isCancelled
public boolean isCancelled()- Specified by:
isCancelled
in 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.COMPLETED
and 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. Thesuccess
boolean 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:ActionFuture
Similar toFuture.get()
, just catching theInterruptedException
and throwing anIllegalStateException
instead. Also catchesExecutionException
and throws the actual cause instead.- Specified by:
actionGet
in interfaceActionFuture<T>
-
actionGet
Description copied from interface:ActionFuture
Similar toFuture.get(long, java.util.concurrent.TimeUnit)
, just catching theInterruptedException
and throwing anIllegalStateException
instead. Also catchesExecutionException
and throws the actual cause instead.- Specified by:
actionGet
in interfaceActionFuture<T>
-
actionGet
Description copied from interface:ActionFuture
Similar toFuture.get(long, java.util.concurrent.TimeUnit)
, just catching theInterruptedException
and throwing anIllegalStateException
instead. Also catchesExecutionException
and throws the actual cause instead.- Specified by:
actionGet
in 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 aRuntimeException
then this method throws that exception, but if the future completed exceptionally with an exception that is not aRuntimeException
then this method throws anUncategorizedExecutionException
whose cause is anExecutionException
whose 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
-