Package org.apache.hadoop.fs.s3a.impl
Class CallableSupplier<T>
java.lang.Object
org.apache.hadoop.fs.s3a.impl.CallableSupplier<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
ConstructorsConstructorDescriptionCallableSupplier(Callable<T> call) Create.CallableSupplier(org.apache.hadoop.fs.store.audit.AuditSpan auditSpan, Callable<T> call) Create. -
Method Summary
Modifier and TypeMethodDescriptionget()Active any span and then call the supplied callable.static <T> Optional<T>maybeAwaitCompletion(CompletableFuture<T> 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> CompletableFuture<T>Submit a callable into a completable future.static <T> TwaitForCompletion(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> Optional<T>Wait for a single of future to complete, ignoring exceptions raised.
-
Constructor Details
-
CallableSupplier
Create.- Parameters:
call- call to invoke.
-
CallableSupplier
Create.- Parameters:
auditSpan- audit span (or null)call- call to invoke.
-
-
Method Details
-
get
Active any span and then call the supplied callable. -
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
-
submit
public static <T> CompletableFuture<T> submit(Executor executor, org.apache.hadoop.fs.store.audit.AuditSpan auditSpan, Callable<T> call) 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.auditSpan- audit span (or null)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- type- 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- type- Parameters:
future- future to wait for.- Returns:
- the result
- Throws:
IOException- if one of the called futures raised an IOE.RuntimeException- if one of the futures raised one.
-
waitForCompletionIgnoringExceptions
public static <T> Optional<T> waitForCompletionIgnoringExceptions(@Nullable CompletableFuture<T> future) Wait for a single of future to complete, ignoring exceptions raised.- Type Parameters:
T- type- Parameters:
future- future to wait for.- Returns:
- the outcome if successfully retrieved.
-
maybeAwaitCompletion
public static <T> Optional<T> maybeAwaitCompletion(@Nullable CompletableFuture<T> future) throws IOException Block awaiting completion for any non-null future passed in; No-op if a null arg was supplied.- Type Parameters:
T- return type- Parameters:
future- future- Returns:
- the outcome; is empty if the future was null/had no return value
- Throws:
IOException- if one of the called futures raised an IOE.RuntimeException- if one of the futures raised one.
-