public class FutureUtils extends Object
| Constructor and Description |
|---|
FutureUtils() |
| Modifier and Type | Method and Description |
|---|---|
static <T> void |
chainFuture(CompletableFuture<? extends T> sourceFuture,
CompletableFuture<T> destinationFuture)
Complete a given destination future when a source future is completed.
|
static <T> CompletableFuture<T> |
failedFuture(Throwable ex)
Returns a new CompletableFuture that is already completed exceptionally with the given exception.
|
static <T> T |
waitWithLogging(org.slf4j.Logger log,
String prefix,
String action,
CompletableFuture<T> future,
Deadline deadline,
org.apache.kafka.common.utils.Time time)
Wait for a future until a specific time in the future, with copious logging.
|
public static <T> T waitWithLogging(org.slf4j.Logger log,
String prefix,
String action,
CompletableFuture<T> future,
Deadline deadline,
org.apache.kafka.common.utils.Time time)
throws Throwable
T - The type of the future.log - The slf4j object to use to log success and failure.action - The action we are waiting for.future - The future we are waiting for.deadline - The deadline in the future we are waiting for.time - The clock object.TimeoutException - If the future times out.Throwable - If the future fails. Note: we unwrap ExecutionException here.public static <T> void chainFuture(CompletableFuture<? extends T> sourceFuture, CompletableFuture<T> destinationFuture)
T - The destination future type.sourceFuture - The future to trigger off of.destinationFuture - The future to complete when the source future is completed.public static <T> CompletableFuture<T> failedFuture(Throwable ex)
ex - The exception.