@InterfaceStability.Evolving public abstract class KafkaFuture<T> extends Object implements Future<T>
Modifier and Type | Class and Description |
---|---|
static interface |
KafkaFuture.BaseFunction<A,B>
A function which takes objects of type A and returns objects of type B.
|
static interface |
KafkaFuture.BiConsumer<A,B>
A consumer of two different types of object.
|
static class |
KafkaFuture.Function<A,B>
A function which takes objects of type A and returns objects of type B.
|
Constructor and Description |
---|
KafkaFuture() |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
addWaiter(KafkaFuture.BiConsumer<? super T,? super Throwable> action) |
static KafkaFuture<Void> |
allOf(KafkaFuture<?>... futures)
Returns a new KafkaFuture that is completed when all the given futures have completed.
|
abstract boolean |
cancel(boolean mayInterruptIfRunning)
If not already completed, completes this future with a CancellationException.
|
protected abstract boolean |
complete(T newValue)
If not already completed, sets the value returned by get() and related methods to the given
value.
|
static <U> KafkaFuture<U> |
completedFuture(U value)
Returns a new KafkaFuture that is already completed with the given value.
|
protected abstract boolean |
completeExceptionally(Throwable newException)
If not already completed, causes invocations of get() and related methods to throw the given
exception.
|
abstract T |
get()
Waits if necessary for this future to complete, and then returns its result.
|
abstract T |
get(long timeout,
TimeUnit unit)
Waits if necessary for at most the given time for this future to complete, and then returns
its result, if available.
|
abstract T |
getNow(T valueIfAbsent)
Returns the result value (or throws any encountered exception) if completed, else returns
the given valueIfAbsent.
|
abstract boolean |
isCancelled()
Returns true if this CompletableFuture was cancelled before it completed normally.
|
abstract boolean |
isCompletedExceptionally()
Returns true if this CompletableFuture completed exceptionally, in any way.
|
abstract boolean |
isDone()
Returns true if completed in any fashion: normally, exceptionally, or via cancellation.
|
abstract <R> KafkaFuture<R> |
thenApply(KafkaFuture.BaseFunction<T,R> function)
Returns a new KafkaFuture that, when this future completes normally, is executed with this
futures's result as the argument to the supplied function.
|
abstract <R> KafkaFuture<R> |
thenApply(KafkaFuture.Function<T,R> function) |
abstract KafkaFuture<T> |
whenComplete(KafkaFuture.BiConsumer<? super T,? super Throwable> action)
Returns a new KafkaFuture with the same result or exception as this future, that executes the given action
when this future completes.
|
public static <U> KafkaFuture<U> completedFuture(U value)
public static KafkaFuture<Void> allOf(KafkaFuture<?>... futures)
public abstract <R> KafkaFuture<R> thenApply(KafkaFuture.BaseFunction<T,R> function)
thenApply
or it may be invoked by the thread that
completes the future.public abstract <R> KafkaFuture<R> thenApply(KafkaFuture.Function<T,R> function)
public abstract KafkaFuture<T> whenComplete(KafkaFuture.BiConsumer<? super T,? super Throwable> action)
whenComplete
or it may be invoked by the thread that
completes the future.action
- the action to preformprotected abstract void addWaiter(KafkaFuture.BiConsumer<? super T,? super Throwable> action)
protected abstract boolean complete(T newValue)
protected abstract boolean completeExceptionally(Throwable newException)
public abstract boolean cancel(boolean mayInterruptIfRunning)
public abstract T get() throws InterruptedException, ExecutionException
get
in interface Future<T>
InterruptedException
ExecutionException
public abstract T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
get
in interface Future<T>
InterruptedException
ExecutionException
TimeoutException
public abstract T getNow(T valueIfAbsent) throws InterruptedException, ExecutionException
public abstract boolean isCancelled()
isCancelled
in interface Future<T>
public abstract boolean isCompletedExceptionally()