Class CommonCallableSupplier<T>
java.lang.Object
org.apache.hadoop.util.functional.CommonCallableSupplier<T>
- Type Parameters:
T- return type.
- All Implemented Interfaces:
Supplier<T>
A bridge from Callable to Supplier; catching exceptions
raised by the callable and wrapping them as appropriate.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionget()static voidmaybeAwaitCompletion(CompletableFuture<Void> future) Block awaiting completion for any non-null future passed in; No-op if a null arg was supplied.static <T> CompletableFuture<T>Submit a callable into a completable future.static <T> voidwaitForCompletion(CompletableFuture<T> future) Wait for a single of future to complete, extracting IOEs afterwards.static <T> voidwaitForCompletion(List<CompletableFuture<T>> futures) Wait for a list of futures to complete.static <T> voidWait for a single of future to complete, ignoring exceptions raised.
-
Constructor Details
-
CommonCallableSupplier
Create.- Parameters:
call- call to invoke.
-
-
Method Details
-
get
-
submit
Submit a callable into a completable future. RTEs are rethrown. Non RTEs are caught and wrapped; IOExceptions toRuntimeIOExceptioninstances.- Type Parameters:
T- type- Parameters:
executor- executor.call- call to invoke- Returns:
- the future to wait for
-
waitForCompletion
Wait for a list of futures to complete. If the list is empty, return immediately.- Type Parameters:
T- Generics Type T.- Parameters:
futures- list of futures.- Throws:
IOException- if one of the called futures raised an IOE.RuntimeException- if one of the futures raised one.
-
waitForCompletion
Wait for a single of future to complete, extracting IOEs afterwards.- Type Parameters:
T- Generics Type T.- Parameters:
future- future to wait for.- Throws:
IOException- if one of the called futures raised an IOE.RuntimeException- if one of the futures raised one.
-
waitForCompletionIgnoringExceptions
Wait for a single of future to complete, ignoring exceptions raised.- Type Parameters:
T- Generics Type T.- Parameters:
future- future to wait for.
-
maybeAwaitCompletion
public static void maybeAwaitCompletion(@Nullable CompletableFuture<Void> future) throws IOException Block awaiting completion for any non-null future passed in; No-op if a null arg was supplied.- Parameters:
future- future- Throws:
IOException- if one of the called futures raised an IOE.RuntimeException- if one of the futures raised one.
-