java.lang.Object
org.elasticsearch.action.support.PlainActionFuture<T>
- All Implemented Interfaces:
Future<T>
,ActionFuture<T>
,ActionListener<T>
- Direct Known Subclasses:
UnsafePlainActionFuture
-
Constructor Summary
Constructors -
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.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
Complete this listener with an exceptional response.void
onResponse
(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 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
Complete this listener with a successful (or at least, non-exceptional) response.- Specified by:
onResponse
in interfaceActionListener<T>
-
onFailure
Description copied from interface:ActionListener
Complete this listener with an exceptional response.- 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.If the future completed exceptionally then this method throws an
ExecutionException
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:
ExecutionException
- if this future was completed exceptionally.CancellationException
- if this future was cancelled.IllegalStateException
- if this 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
-