Class FailedAsyncFuture<T>
java.lang.Object
com.linkedin.alpini.base.concurrency.impl.AbstractAsyncFuture<T>
com.linkedin.alpini.base.concurrency.impl.FailedAsyncFuture<T>
- All Implemented Interfaces:
AsyncFuture<T>,AsyncPromise<T>,CompletionStage<T>,Future<T>
- Direct Known Subclasses:
CancelledAsyncFuture
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.linkedin.alpini.base.concurrency.AsyncFuture
AsyncFuture.Status -
Field Summary
Fields inherited from interface com.linkedin.alpini.base.concurrency.AsyncFuture
NULL_SUCCESS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionacceptEither(CompletionStage<? extends T> other, Consumer<? super T> action) acceptEitherAsync(CompletionStage<? extends T> other, Consumer<? super T> action) acceptEitherAsync(CompletionStage<? extends T> other, Consumer<? super T> action, Executor executor) final AsyncPromise<T>addListener(AsyncFutureListener<T> listener) Adds the specified listener to this future.final AsyncPromise<T>addListener(AsyncPromise<T> listener) Adds the specified future as a listener to this future.<U> CompletionStage<U>applyToEither(CompletionStage<? extends T> other, Function<? super T, U> fn) <U> CompletionStage<U>applyToEitherAsync(CompletionStage<? extends T> other, Function<? super T, U> fn) <U> CompletionStage<U>applyToEitherAsync(CompletionStage<? extends T> other, Function<? super T, U> fn, Executor executor) final AsyncFuture<T>await()Waits for this future to be completed.final booleanWaits for this future to be completed within the specified time limit.final AsyncFuture<T>Waits for this future to be completed without interruption.final booleanawaitUninterruptibly(long timeout, TimeUnit unit) Waits for this future to be completed within the specified time limit without interruption.final booleancancel(boolean mayInterruptIfRunning) Attempts to cancel execution of this task.final Tget()Waits if necessary for the computation to complete, and then retrieves its result.final TWaits if necessary for at most the given time for the computation to complete, and then retrieves its result, if available.final ThrowablegetCause()Returns the cause of the failed I/O operation if the I/O operation has failed.final TgetNow()Non-blocking variant ofFuture.get()booleanReturnstrueif this task was cancelled before it completed normally.final booleanisDone()Returnstrueif this task completed.final booleanReturnstrueif and only if the I/O operation was completed successfully.runAfterBoth(CompletionStage<?> other, Runnable action) runAfterBothAsync(CompletionStage<?> other, Runnable action) runAfterBothAsync(CompletionStage<?> other, Runnable action, Executor executor) runAfterEither(CompletionStage<?> other, Runnable action) runAfterEitherAsync(CompletionStage<?> other, Runnable action) runAfterEitherAsync(CompletionStage<?> other, Runnable action, Executor executor) final booleansetFailure(Throwable cause) Marks this future as a failure and notifies all listeners.final booleansetSuccess(T result) Marks this future as a success and notifies all listeners.thenAccept(Consumer<? super T> action) thenAcceptAsync(Consumer<? super T> action) thenAcceptAsync(Consumer<? super T> action, Executor executor) <U> CompletionStage<Void>thenAcceptBoth(CompletionStage<? extends U> other, BiConsumer<? super T, ? super U> action) <U> CompletionStage<Void>thenAcceptBothAsync(CompletionStage<? extends U> other, BiConsumer<? super T, ? super U> action) <U> CompletionStage<Void>thenAcceptBothAsync(CompletionStage<? extends U> other, BiConsumer<? super T, ? super U> action, Executor executor) <U> CompletionStage<U><U> CompletionStage<U>thenApplyAsync(Function<? super T, ? extends U> fn) <U> CompletionStage<U>thenApplyAsync(Function<? super T, ? extends U> fn, Executor executor) <U,V> CompletionStage<V> thenCombine(CompletionStage<? extends U> other, BiFunction<? super T, ? super U, ? extends V> fn) <U,V> CompletionStage<V> thenCombineAsync(CompletionStage<? extends U> other, BiFunction<? super T, ? super U, ? extends V> fn) <U,V> CompletionStage<V> thenCombineAsync(CompletionStage<? extends U> other, BiFunction<? super T, ? super U, ? extends V> fn, Executor executor) <U> CompletionStage<U>thenCompose(Function<? super T, ? extends CompletionStage<U>> fn) <U> CompletionStage<U>thenComposeAsync(Function<? super T, ? extends CompletionStage<U>> fn) <U> CompletionStage<U>thenComposeAsync(Function<? super T, ? extends CompletionStage<U>> fn, Executor executor) thenRunAsync(Runnable action) thenRunAsync(Runnable action, Executor executor) Methods inherited from class com.linkedin.alpini.base.concurrency.impl.AbstractAsyncFuture
exceptionally, handle, handleAsync, handleAsync, whenComplete, whenCompleteAsync, whenCompleteAsyncMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.linkedin.alpini.base.concurrency.AsyncPromise
setCompleteMethods inherited from interface java.util.concurrent.CompletionStage
exceptionally, exceptionallyAsync, exceptionallyAsync, exceptionallyCompose, exceptionallyComposeAsync, exceptionallyComposeAsync, handle, handleAsync, handleAsync, whenComplete, whenCompleteAsync, whenCompleteAsync
-
Constructor Details
-
FailedAsyncFuture
-
-
Method Details
-
isSuccess
public final boolean isSuccess()Returnstrueif and only if the I/O operation was completed successfully.- Specified by:
isSuccessin interfaceAsyncFuture<T>
-
getCause
Returns the cause of the failed I/O operation if the I/O operation has failed.- Specified by:
getCausein interfaceAsyncFuture<T>- Returns:
- the cause of the failure.
nullif succeeded or this future is not completed yet.
-
setSuccess
Marks this future as a success and notifies all listeners.- Specified by:
setSuccessin interfaceAsyncPromise<T>- Parameters:
result-- Returns:
trueif and only if successfully marked this future as a success. Otherwisefalsebecause this future is already marked as either a success or a failure.
-
setFailure
Marks this future as a failure and notifies all listeners.- Specified by:
setFailurein interfaceAsyncPromise<T>- Parameters:
cause-- Returns:
trueif and only if successfully marked this future as a failure. Otherwisefalsebecause this future is already marked as either a success or a failure.
-
addListener
Adds the specified listener to this future. The specified listener is notified when this future is done. If this future is already completed, the specified listener is notified immediately.- Specified by:
addListenerin interfaceAsyncFuture<T>- Specified by:
addListenerin interfaceAsyncPromise<T>- Parameters:
listener-- Returns:
thisto permit chaining of operations.
-
addListener
Adds the specified future as a listener to this future. The specified future is notified when this future is done. If this future is already completed, the specified future is notified immediately.- Specified by:
addListenerin interfaceAsyncFuture<T>- Specified by:
addListenerin interfaceAsyncPromise<T>- Parameters:
listener-- Returns:
thisto permit chaining of operations.
-
await
Waits for this future to be completed.- Specified by:
awaitin interfaceAsyncFuture<T>- Throws:
InterruptedException- if the current thread was interrupted
-
awaitUninterruptibly
Waits for this future to be completed without interruption. This method catches anInterruptedExceptionand discards it silently.- Specified by:
awaitUninterruptiblyin interfaceAsyncFuture<T>
-
await
Waits for this future to be completed within the specified time limit.- Specified by:
awaitin interfaceAsyncFuture<T>- Parameters:
timeout-unit-- Returns:
trueif and only if the future was completed within the specified time limit- Throws:
InterruptedException- if the current thread was interrupted
-
awaitUninterruptibly
Waits for this future to be completed within the specified time limit without interruption. This method catches anInterruptedExceptionand discards it silently.- Specified by:
awaitUninterruptiblyin interfaceAsyncFuture<T>- Parameters:
timeout-unit-- Returns:
trueif and only if the future was completed within the specified time limit
-
cancel
public final boolean cancel(boolean mayInterruptIfRunning) Attempts to cancel execution of this task. This attempt will fail if the task has already completed, has already been cancelled, or could not be cancelled for some other reason. If successful, and this task has not started whencancelis called, this task should never run. If the task has already started, then themayInterruptIfRunningparameter determines whether the thread executing this task should be interrupted in an attempt to stop the task.After this method returns, subsequent calls to
isDone()will always returntrue. Subsequent calls toisCancelled()will always returntrueif this method returnedtrue.- Specified by:
cancelin interfaceFuture<T>- Parameters:
mayInterruptIfRunning-trueif the thread executing this task should be interrupted; otherwise, in-progress tasks are allowed to complete- Returns:
falseif the task could not be cancelled, typically because it has already completed normally;trueotherwise
-
isCancelled
public boolean isCancelled()Returnstrueif this task was cancelled before it completed normally.- Specified by:
isCancelledin interfaceFuture<T>- Returns:
trueif this task was cancelled before it completed
-
isDone
public final boolean isDone()Returnstrueif this task completed.Completion may be due to normal termination, an exception, or cancellation -- in all of these cases, this method will return
true. -
get
Waits if necessary for the computation to complete, and then retrieves its result.- Specified by:
getin interfaceFuture<T>- Returns:
- the computed result
- Throws:
CancellationException- if the computation was cancelledExecutionException- if the computation threw an exceptionInterruptedException- if the current thread was interrupted while waiting
-
get
public final T get(long timeout, @Nonnull TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException Waits if necessary for at most the given time for the computation to complete, and then retrieves its result, if available.- Specified by:
getin interfaceFuture<T>- Parameters:
timeout- the maximum time to waitunit- the time unit of the timeout argument- Returns:
- the computed result
- Throws:
CancellationException- if the computation was cancelledExecutionException- if the computation threw an exceptionInterruptedException- if the current thread was interrupted while waitingTimeoutException- if the wait timed out
-
getNow
Description copied from interface:AsyncFutureNon-blocking variant ofFuture.get()- Specified by:
getNowin interfaceAsyncFuture<T>- Returns:
- value or
null
-
thenApply
- Specified by:
thenApplyin interfaceCompletionStage<T>- Overrides:
thenApplyin classAbstractAsyncFuture<T>
-
thenApplyAsync
- Specified by:
thenApplyAsyncin interfaceCompletionStage<T>- Overrides:
thenApplyAsyncin classAbstractAsyncFuture<T>
-
thenApplyAsync
- Specified by:
thenApplyAsyncin interfaceCompletionStage<T>- Overrides:
thenApplyAsyncin classAbstractAsyncFuture<T>
-
thenAccept
- Specified by:
thenAcceptin interfaceCompletionStage<T>- Overrides:
thenAcceptin classAbstractAsyncFuture<T>
-
thenAcceptAsync
- Specified by:
thenAcceptAsyncin interfaceCompletionStage<T>- Overrides:
thenAcceptAsyncin classAbstractAsyncFuture<T>
-
thenAcceptAsync
- Specified by:
thenAcceptAsyncin interfaceCompletionStage<T>- Overrides:
thenAcceptAsyncin classAbstractAsyncFuture<T>
-
thenRun
- Specified by:
thenRunin interfaceCompletionStage<T>- Overrides:
thenRunin classAbstractAsyncFuture<T>
-
thenRunAsync
- Specified by:
thenRunAsyncin interfaceCompletionStage<T>- Overrides:
thenRunAsyncin classAbstractAsyncFuture<T>
-
thenRunAsync
- Specified by:
thenRunAsyncin interfaceCompletionStage<T>- Overrides:
thenRunAsyncin classAbstractAsyncFuture<T>
-
thenCombine
public <U,V> CompletionStage<V> thenCombine(CompletionStage<? extends U> other, BiFunction<? super T, ? super U, ? extends V> fn) - Specified by:
thenCombinein interfaceCompletionStage<T>- Overrides:
thenCombinein classAbstractAsyncFuture<T>
-
thenCombineAsync
public <U,V> CompletionStage<V> thenCombineAsync(CompletionStage<? extends U> other, BiFunction<? super T, ? super U, ? extends V> fn) - Specified by:
thenCombineAsyncin interfaceCompletionStage<T>- Overrides:
thenCombineAsyncin classAbstractAsyncFuture<T>
-
thenCombineAsync
public <U,V> CompletionStage<V> thenCombineAsync(CompletionStage<? extends U> other, BiFunction<? super T, ? super U, ? extends V> fn, Executor executor) - Specified by:
thenCombineAsyncin interfaceCompletionStage<T>- Overrides:
thenCombineAsyncin classAbstractAsyncFuture<T>
-
thenAcceptBoth
public <U> CompletionStage<Void> thenAcceptBoth(CompletionStage<? extends U> other, BiConsumer<? super T, ? super U> action) - Specified by:
thenAcceptBothin interfaceCompletionStage<T>- Overrides:
thenAcceptBothin classAbstractAsyncFuture<T>
-
thenAcceptBothAsync
public <U> CompletionStage<Void> thenAcceptBothAsync(CompletionStage<? extends U> other, BiConsumer<? super T, ? super U> action) - Specified by:
thenAcceptBothAsyncin interfaceCompletionStage<T>- Overrides:
thenAcceptBothAsyncin classAbstractAsyncFuture<T>
-
thenAcceptBothAsync
public <U> CompletionStage<Void> thenAcceptBothAsync(CompletionStage<? extends U> other, BiConsumer<? super T, ? super U> action, Executor executor) - Specified by:
thenAcceptBothAsyncin interfaceCompletionStage<T>- Overrides:
thenAcceptBothAsyncin classAbstractAsyncFuture<T>
-
runAfterBoth
- Specified by:
runAfterBothin interfaceCompletionStage<T>- Overrides:
runAfterBothin classAbstractAsyncFuture<T>
-
runAfterBothAsync
- Specified by:
runAfterBothAsyncin interfaceCompletionStage<T>- Overrides:
runAfterBothAsyncin classAbstractAsyncFuture<T>
-
runAfterBothAsync
public CompletionStage<Void> runAfterBothAsync(CompletionStage<?> other, Runnable action, Executor executor) - Specified by:
runAfterBothAsyncin interfaceCompletionStage<T>- Overrides:
runAfterBothAsyncin classAbstractAsyncFuture<T>
-
applyToEither
public <U> CompletionStage<U> applyToEither(CompletionStage<? extends T> other, Function<? super T, U> fn) - Specified by:
applyToEitherin interfaceCompletionStage<T>- Overrides:
applyToEitherin classAbstractAsyncFuture<T>
-
applyToEitherAsync
public <U> CompletionStage<U> applyToEitherAsync(CompletionStage<? extends T> other, Function<? super T, U> fn) - Specified by:
applyToEitherAsyncin interfaceCompletionStage<T>- Overrides:
applyToEitherAsyncin classAbstractAsyncFuture<T>
-
applyToEitherAsync
public <U> CompletionStage<U> applyToEitherAsync(CompletionStage<? extends T> other, Function<? super T, U> fn, Executor executor) - Specified by:
applyToEitherAsyncin interfaceCompletionStage<T>- Overrides:
applyToEitherAsyncin classAbstractAsyncFuture<T>
-
acceptEither
public CompletionStage<Void> acceptEither(CompletionStage<? extends T> other, Consumer<? super T> action) - Specified by:
acceptEitherin interfaceCompletionStage<T>- Overrides:
acceptEitherin classAbstractAsyncFuture<T>
-
acceptEitherAsync
public CompletionStage<Void> acceptEitherAsync(CompletionStage<? extends T> other, Consumer<? super T> action) - Specified by:
acceptEitherAsyncin interfaceCompletionStage<T>- Overrides:
acceptEitherAsyncin classAbstractAsyncFuture<T>
-
acceptEitherAsync
public CompletionStage<Void> acceptEitherAsync(CompletionStage<? extends T> other, Consumer<? super T> action, Executor executor) - Specified by:
acceptEitherAsyncin interfaceCompletionStage<T>- Overrides:
acceptEitherAsyncin classAbstractAsyncFuture<T>
-
runAfterEither
- Specified by:
runAfterEitherin interfaceCompletionStage<T>- Overrides:
runAfterEitherin classAbstractAsyncFuture<T>
-
runAfterEitherAsync
- Specified by:
runAfterEitherAsyncin interfaceCompletionStage<T>- Overrides:
runAfterEitherAsyncin classAbstractAsyncFuture<T>
-
runAfterEitherAsync
public CompletionStage<Void> runAfterEitherAsync(CompletionStage<?> other, Runnable action, Executor executor) - Specified by:
runAfterEitherAsyncin interfaceCompletionStage<T>- Overrides:
runAfterEitherAsyncin classAbstractAsyncFuture<T>
-
thenCompose
- Specified by:
thenComposein interfaceCompletionStage<T>- Overrides:
thenComposein classAbstractAsyncFuture<T>
-
thenComposeAsync
- Specified by:
thenComposeAsyncin interfaceCompletionStage<T>- Overrides:
thenComposeAsyncin classAbstractAsyncFuture<T>
-
thenComposeAsync
public <U> CompletionStage<U> thenComposeAsync(Function<? super T, ? extends CompletionStage<U>> fn, Executor executor) - Specified by:
thenComposeAsyncin interfaceCompletionStage<T>- Overrides:
thenComposeAsyncin classAbstractAsyncFuture<T>
-
toCompletableFuture
- Specified by:
toCompletableFuturein interfaceCompletionStage<T>
-