public final class ExecutionUtil extends Object
DistributedExecutorService
and its subordinate classes.Modifier and Type | Method and Description |
---|---|
static boolean |
cancel(List<? extends Future<?>> futures,
boolean mayInterruptIfRunning)
Cancels all of the provided futures
|
static <T> List<T> |
flatten(List<List<T>> lists)
Flattens a list of lists into a single list.
|
static <T> List<T> |
getResults(List<? extends Future<T>> futures)
Invokes
Future.get() on each element in the provided
list of futures, returning a list of results or throwing an exception if there are any failures. |
static <T> List<T> |
getResults(List<? extends Future<T>> futures,
long timeout,
TimeUnit timeunit)
Invokes
Future.get() or Future.get(long, TimeUnit) on each element in the provided
list of futures, returning a list of results or throwing an exception if there are any failures. |
static <S> List<S> |
getStatus(List<? extends MonitoredFuture<S>> futures)
Invokes
MonitoredFuture.getStatus() on each element in the provided
list of futures, returning a list of results or throwing an exception if there are any failures. |
static boolean |
isCancelled(List<? extends Future<?>> futures)
Returns true if all of the futures are cancelled, false otherwise.
|
static boolean |
isDone(List<? extends Future<?>> futures)
Returns true if all of the futures are done, false otherwise.
|
public static <T> List<T> flatten(List<List<T>> lists)
T
- the element type of the listslists
- the list of listspublic static <T> List<T> getResults(List<? extends Future<T>> futures) throws DistributedExecutionException, InterruptedException
Future.get()
on each element in the provided
list of futures, returning a list of results or throwing an exception if there are any failures.T
- the result typefutures
- the list of futuresDistributedExecutionException
- containing all of the errors. Any BatchExecutionException
's will be
flattened.InterruptedException
- if interrupted while waitingCancellationException
- if any were canceledpublic static boolean isCancelled(List<? extends Future<?>> futures)
futures
- the futurespublic static boolean isDone(List<? extends Future<?>> futures)
futures
- the futurespublic static boolean cancel(List<? extends Future<?>> futures, boolean mayInterruptIfRunning)
futures
- the futuresmayInterruptIfRunning
- whether we can interrupt a future that has already started runningpublic static <T> List<T> getResults(List<? extends Future<T>> futures, long timeout, TimeUnit timeunit) throws DistributedExecutionException, TimeoutException, InterruptedException, CancellationException
Future.get()
or Future.get(long, TimeUnit)
on each element in the provided
list of futures, returning a list of results or throwing an exception if there are any failures.T
- the result typefutures
- the list of futurestimeout
- the timeout; ignored if timeunit is nulltimeunit
- the timeunit or null for no timeoutDistributedExecutionException
- containing all of the errors. Any BatchExecutionException
's will be
flattened.TimeoutException
- if a timeout occurs. Will only be thrown if timeunit is non-null.InterruptedException
- if interrupted while waitingCancellationException
- if any were canceledpublic static <S> List<S> getStatus(List<? extends MonitoredFuture<S>> futures) throws DistributedExecutionException, InterruptedException
MonitoredFuture.getStatus()
on each element in the provided
list of futures, returning a list of results or throwing an exception if there are any failures.S
- the result typefutures
- the list of futuresDistributedExecutionException
- containing all of the errors. Any BatchExecutionException
's will be
flattened.InterruptedException
- if interrupted while waitingCancellationException
- if any were canceledCopyright © 2024 Actian Corporation. All rights reserved.