public class DistributedExecutionCompletionService<V> extends Object implements CompletionService<V>
CompletionService that uses a supplied DistributedExecutorService to execute
tasks. This class arranges that submitted tasks are, upon completion, placed on a queue
accessible using take. The class is lightweight enough to be suitable for transient use
when processing groups of tasks.
This class must be used instead of a ExecutorCompletionService provided from
java.util.concurrent package. The ExecutorCompletionService may not be used since it
requires the use of a non serializable RunnableFuture object.
| Modifier and Type | Field and Description |
|---|---|
protected BlockingQueue<CompletableFuture<V>> |
completionQueue |
protected DistributedExecutorService |
executor |
| Constructor and Description |
|---|
DistributedExecutionCompletionService(DistributedExecutorService executor)
Creates an ExecutorCompletionService using the supplied executor for base task execution and a
LinkedBlockingQueue as a completion queue. |
DistributedExecutionCompletionService(DistributedExecutorService executor,
BlockingQueue<CompletableFuture<V>> completionQueue)
Creates an ExecutorCompletionService using the supplied executor for base task execution and
the supplied queue as its completion queue.
|
| Modifier and Type | Method and Description |
|---|---|
CompletableFuture<V> |
poll() |
CompletableFuture<V> |
poll(long timeout,
TimeUnit unit) |
<K> CompletableFuture<V> |
submit(Address target,
Callable<V> task) |
CompletableFuture<V> |
submit(Callable<V> task) |
<K> Future<V> |
submit(Callable<V> task,
K... input) |
CompletableFuture<V> |
submit(Runnable task,
V result) |
List<CompletableFuture<V>> |
submitEverywhere(Callable<V> task) |
<K> List<CompletableFuture<V>> |
submitEverywhere(Callable<V> task,
K... input) |
CompletableFuture<V> |
take() |
protected final DistributedExecutorService executor
protected final BlockingQueue<CompletableFuture<V>> completionQueue
public DistributedExecutionCompletionService(DistributedExecutorService executor)
LinkedBlockingQueue as a completion queue.executor - the executor to useNullPointerException - if executor is nullpublic DistributedExecutionCompletionService(DistributedExecutorService executor, BlockingQueue<CompletableFuture<V>> completionQueue)
PriorityBlockingQueue for completionQueue can only be used with accompanying
Comparator as our internal implementation of Future for each subtask does not
implement Comparable interface. Note that we do not provide any guarantees about which
particular internal class implements Future interface and these APIs will remain internal.executor - the executor to usecompletionQueue - the queue to use as the completion queue normally one dedicated for use by this
serviceNullPointerException - if executor is nullpublic CompletableFuture<V> submit(Callable<V> task)
submit in interface CompletionService<V>public CompletableFuture<V> submit(Runnable task, V result)
submit in interface CompletionService<V>public CompletableFuture<V> take() throws InterruptedException
take in interface CompletionService<V>InterruptedExceptionpublic CompletableFuture<V> poll()
poll in interface CompletionService<V>public CompletableFuture<V> poll(long timeout, TimeUnit unit) throws InterruptedException
poll in interface CompletionService<V>InterruptedExceptionpublic List<CompletableFuture<V>> submitEverywhere(Callable<V> task)
public <K> List<CompletableFuture<V>> submitEverywhere(Callable<V> task, K... input)
public <K> CompletableFuture<V> submit(Address target, Callable<V> task)
Copyright © 2017 JBoss, a division of Red Hat. All rights reserved.