java.lang.Object
com.pervasive.datarush.cal.ExecutionUtil
Miscellaneous utilities related to
DistributedExecutorService and its
subordinate classes.-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanCancels all of the provided futuresstatic <T> List<T>Flattens a list of lists into a single list.static <T> List<T>getResults(List<? extends Future<T>> futures) InvokesFuture.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) InvokesFuture.get()orFuture.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) InvokesMonitoredFuture.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 booleanisCancelled(List<? extends Future<?>> futures) Returns true if all of the futures are cancelled, false otherwise.static booleanReturns true if all of the futures are done, false otherwise.
-
Method Details
-
flatten
Flattens a list of lists into a single list.- Type Parameters:
T- the element type of the lists- Parameters:
lists- the list of lists- Returns:
- a single list
-
getResults
public static <T> List<T> getResults(List<? extends Future<T>> futures) throws DistributedExecutionException, InterruptedException InvokesFuture.get()on each element in the provided list of futures, returning a list of results or throwing an exception if there are any failures.- Type Parameters:
T- the result type- Parameters:
futures- the list of futures- Returns:
- a list of results
- Throws:
DistributedExecutionException- containing all of the errors. AnyBatchExecutionException's will be flattened.InterruptedException- if interrupted while waitingCancellationException- if any were canceled
-
isCancelled
Returns true if all of the futures are cancelled, false otherwise.- Parameters:
futures- the futures- Returns:
- whether all were cancelled
-
isDone
Returns true if all of the futures are done, false otherwise.- Parameters:
futures- the futures- Returns:
- whether all are done
-
cancel
Cancels all of the provided futures- Parameters:
futures- the futuresmayInterruptIfRunning- whether we can interrupt a future that has already started running- Returns:
- true iff all were cancelled
-
getResults
public static <T> List<T> getResults(List<? extends Future<T>> futures, long timeout, TimeUnit timeunit) throws DistributedExecutionException, TimeoutException, InterruptedException, CancellationException InvokesFuture.get()orFuture.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.- Type Parameters:
T- the result type- Parameters:
futures- the list of futurestimeout- the timeout; ignored if timeunit is nulltimeunit- the timeunit or null for no timeout- Returns:
- a list of results
- Throws:
DistributedExecutionException- containing all of the errors. AnyBatchExecutionException'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 canceled
-
getStatus
public static <S> List<S> getStatus(List<? extends MonitoredFuture<S>> futures) throws DistributedExecutionException, InterruptedException InvokesMonitoredFuture.getStatus()on each element in the provided list of futures, returning a list of results or throwing an exception if there are any failures.- Type Parameters:
S- the result type- Parameters:
futures- the list of futures- Returns:
- a list of statuses
- Throws:
DistributedExecutionException- containing all of the errors. AnyBatchExecutionException's will be flattened.InterruptedException- if interrupted while waitingCancellationException- if any were canceled
-