CommonCallableSupplier (Apache Hadoop Common 3.5.0 API)
Description: declaration: package: org.apache.hadoop.util.functional, class: CommonCallableSupplier

Package org.apache.hadoop.util.functional

# Class CommonCallableSupplier<T>

java.lang.Object
org.apache.hadoop.util.functional.CommonCallableSupplier<T>

Type Parameters:
  `T` - return type.

All Implemented Interfaces:
  `Supplier<T>`

public final class CommonCallableSupplier<T> extends Object implements Supplier<T>
A bridge from Callable to Supplier; catching exceptions raised by the callable and wrapping them as appropriate.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `CommonCallableSupplier(Callable<T> call)`
  Create.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `T`
  `get()`
  `static void`
  `maybeAwaitCompletion(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(Executor executor, Callable<T> call)`
  Submit a callable into a completable future.
  `static <T> void`
  `waitForCompletion(CompletableFuture<T> future)`
  Wait for a single of future to complete, extracting IOEs afterwards.
  `static <T> void`
  `waitForCompletion(List<CompletableFuture<T>> futures)`
  Wait for a list of futures to complete.
  `static <T> void`
  `waitForCompletionIgnoringExceptions(CompletableFuture<T> future)`
  Wait for a single of future to complete, ignoring exceptions raised.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### CommonCallableSupplier

    public CommonCallableSupplier(Callable<T> call)
    Create.
    Parameters:
      `call` - call to invoke.

- ## Method Details

  - ### get

    public T get()
    Specified by:
      `get` in interface `Supplier<T>`

  - ### submit

    public static <T> CompletableFuture<T> submit(Executor executor, Callable<T> call)
    Submit a callable into a completable future. RTEs are rethrown. Non RTEs are caught and wrapped; IOExceptions to `RuntimeIOException` instances.
    Type Parameters:
      `T` - type
    Parameters:
      `executor` - executor.
      `call` - call to invoke
    Returns:
      the future to wait for

  - ### waitForCompletion

    public static <T> void waitForCompletion(List<CompletableFuture<T>> futures) throws IOException
    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

    public static <T> void waitForCompletion(CompletableFuture<T> future) throws IOException
    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

    public static <T> void waitForCompletionIgnoringExceptions(@Nullable CompletableFuture<T> future)
    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.