public final class JdkFutures extends Object
Future
interface.
Use of JDK Future should generally be avoid, but is prevalent in ODL because the Java Bindings (v1) generated code uses them for all RPC return types.
Any new hand written code should never use the old Future interface anymore,
but instead use either a Guava ListenableFuture
, or a Java 8 CompletionStage
.
Modifier and Type | Method and Description |
---|---|
static <V> void |
addErrorLogging(Future<V> future,
org.slf4j.Logger logger,
String message)
Adds a callback to a Future which logs any failures.
|
static <V> void |
addErrorLogging(Future<V> future,
org.slf4j.Logger logger,
String format,
Object... args) |
static <V> void |
addErrorLogging(Future<V> future,
org.slf4j.Logger logger,
String format,
Object arg) |
static <V> CompletionStage<V> |
toCompletionStage(Future<V> future)
Converts a Java 5
Future to a Java 8 CompletionStage . |
static <V> com.google.common.util.concurrent.ListenableFuture<V> |
toListenableFuture(Future<V> future)
Converts a Java 5
Future to a Guava ListenableFuture . |
static <V> com.google.common.util.concurrent.ListenableFuture<V> |
toListenableFuture(Future<V> future,
Executor executor)
Converts a Java 5
Future to a Guava ListenableFuture , using your own Executor. |
public static <V> com.google.common.util.concurrent.ListenableFuture<V> toListenableFuture(Future<V> future)
Future
to a Guava ListenableFuture
.
See also Guava's JdkFutureAdapters
utility, which is used internally here
(with an Executor that would log any possible issues, and which will be metric monitored).
public static <V> com.google.common.util.concurrent.ListenableFuture<V> toListenableFuture(Future<V> future, Executor executor)
Future
to a Guava ListenableFuture
, using your own Executor.
It's typically a bad idea to pass a directExector here, because then the
ListenableFuture.addListener(Runnable, Executor)
will become blocking
and one might as well just use the Future's blocking get() instead of this.
public static <V> CompletionStage<V> toCompletionStage(Future<V> future)
Future
to a Java 8 CompletionStage
.public static <V> void addErrorLogging(Future<V> future, org.slf4j.Logger logger, String message)
public static <V> void addErrorLogging(Future<V> future, org.slf4j.Logger logger, String format, Object arg)
Copyright © 2019 OpenDaylight. All rights reserved.