Package org.infinispan.distexec
Class DistributedExecutionCompletionService<V>
- java.lang.Object
-
- org.infinispan.distexec.DistributedExecutionCompletionService<V>
-
- All Implemented Interfaces:
java.util.concurrent.CompletionService<V>
public class DistributedExecutionCompletionService<V> extends java.lang.Object implements java.util.concurrent.CompletionService<V>ACompletionServicethat uses a suppliedDistributedExecutorServiceto 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
ExecutorCompletionServiceprovided from java.util.concurrent package. TheExecutorCompletionServicemay not be used since it requires the use of a non serializable RunnableFuture object.- Author:
- William Burns, Vladimir Blagojevic
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.concurrent.BlockingQueue<java.util.concurrent.CompletableFuture<V>>completionQueueprotected DistributedExecutorServiceexecutor
-
Constructor Summary
Constructors Constructor Description DistributedExecutionCompletionService(DistributedExecutorService executor)Creates an ExecutorCompletionService using the supplied executor for base task execution and aLinkedBlockingQueueas a completion queue.DistributedExecutionCompletionService(DistributedExecutorService executor, java.util.concurrent.BlockingQueue<java.util.concurrent.CompletableFuture<V>> completionQueue)Creates an ExecutorCompletionService using the supplied executor for base task execution and the supplied queue as its completion queue.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.concurrent.CompletableFuture<V>poll(){@inheritDoc CompletionService}java.util.concurrent.CompletableFuture<V>poll(long timeout, java.util.concurrent.TimeUnit unit){@inheritDoc CompletionService}java.util.concurrent.CompletableFuture<V>submit(java.lang.Runnable task, V result){@inheritDoc CompletionService}java.util.concurrent.CompletableFuture<V>submit(java.util.concurrent.Callable<V> task){@inheritDoc CompletionService}<K> java.util.concurrent.Future<V>submit(java.util.concurrent.Callable<V> task, K... input)<K> java.util.concurrent.CompletableFuture<V>submit(Address target, java.util.concurrent.Callable<V> task)java.util.List<java.util.concurrent.CompletableFuture<V>>submitEverywhere(java.util.concurrent.Callable<V> task)<K> java.util.List<java.util.concurrent.CompletableFuture<V>>submitEverywhere(java.util.concurrent.Callable<V> task, K... input)java.util.concurrent.CompletableFuture<V>take(){@inheritDoc CompletionService}
-
-
-
Field Detail
-
executor
protected final DistributedExecutorService executor
-
completionQueue
protected final java.util.concurrent.BlockingQueue<java.util.concurrent.CompletableFuture<V>> completionQueue
-
-
Constructor Detail
-
DistributedExecutionCompletionService
public DistributedExecutionCompletionService(DistributedExecutorService executor)
Creates an ExecutorCompletionService using the supplied executor for base task execution and aLinkedBlockingQueueas a completion queue.- Parameters:
executor- the executor to use- Throws:
java.lang.NullPointerException- if executor is null
-
DistributedExecutionCompletionService
public DistributedExecutionCompletionService(DistributedExecutorService executor, java.util.concurrent.BlockingQueue<java.util.concurrent.CompletableFuture<V>> completionQueue)
Creates an ExecutorCompletionService using the supplied executor for base task execution and the supplied queue as its completion queue. Note:PriorityBlockingQueuefor completionQueue can only be used with accompanyingComparatoras our internal implementation ofFuturefor 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.- Parameters:
executor- the executor to usecompletionQueue- the queue to use as the completion queue normally one dedicated for use by this service- Throws:
java.lang.NullPointerException- if executor is null
-
-
Method Detail
-
submit
public java.util.concurrent.CompletableFuture<V> submit(java.util.concurrent.Callable<V> task)
{@inheritDoc CompletionService}- Specified by:
submitin interfacejava.util.concurrent.CompletionService<V>
-
submit
public java.util.concurrent.CompletableFuture<V> submit(java.lang.Runnable task, V result)
{@inheritDoc CompletionService}- Specified by:
submitin interfacejava.util.concurrent.CompletionService<V>
-
take
public java.util.concurrent.CompletableFuture<V> take() throws java.lang.InterruptedException
{@inheritDoc CompletionService}- Specified by:
takein interfacejava.util.concurrent.CompletionService<V>- Throws:
java.lang.InterruptedException
-
poll
public java.util.concurrent.CompletableFuture<V> poll()
{@inheritDoc CompletionService}- Specified by:
pollin interfacejava.util.concurrent.CompletionService<V>
-
poll
public java.util.concurrent.CompletableFuture<V> poll(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
{@inheritDoc CompletionService}- Specified by:
pollin interfacejava.util.concurrent.CompletionService<V>- Throws:
java.lang.InterruptedException
-
submit
public <K> java.util.concurrent.Future<V> submit(java.util.concurrent.Callable<V> task, K... input)
-
submitEverywhere
public java.util.List<java.util.concurrent.CompletableFuture<V>> submitEverywhere(java.util.concurrent.Callable<V> task)
-
submitEverywhere
public <K> java.util.List<java.util.concurrent.CompletableFuture<V>> submitEverywhere(java.util.concurrent.Callable<V> task, K... input)
-
-