Infinispan Distribution 5.2.6.Final-redhat-2

org.infinispan.distexec
Class DistributedExecutionCompletionService<V>

java.lang.Object
  extended by org.infinispan.distexec.DistributedExecutionCompletionService<V>
All Implemented Interfaces:
CompletionService<V>

public class DistributedExecutionCompletionService<V>
extends Object
implements CompletionService<V>

A 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.

Author:
William Burns, Vladimir Blagojevic

Nested Class Summary
protected  class DistributedExecutionCompletionService.QueueingListener
           
 
Field Summary
protected  BlockingQueue<NotifyingFuture<V>> completionQueue
           
protected  DistributedExecutorService executor
           
protected  DistributedExecutionCompletionService.QueueingListener listener
           
 
Constructor Summary
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<NotifyingFuture<V>> completionQueue)
          Creates an ExecutorCompletionService using the supplied executor for base task execution and the supplied queue as its completion queue.
 
Method Summary
 NotifyingFuture<V> poll()
          
 NotifyingFuture<V> poll(long timeout, TimeUnit unit)
          
 Future<V> submit(Callable<V> task)
          
<K> Future<V>
submit(Callable<V> task, K... input)
           
 Future<V> submit(Runnable task, V result)
          
 List<Future<V>> submitEverywhere(Callable<V> task)
           
<K> List<Future<V>>
submitEverywhere(Callable<V> task, K... input)
           
 NotifyingFuture<V> take()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

executor

protected final DistributedExecutorService executor

completionQueue

protected final BlockingQueue<NotifyingFuture<V>> completionQueue

listener

protected final DistributedExecutionCompletionService.QueueingListener listener
Constructor Detail

DistributedExecutionCompletionService

public DistributedExecutionCompletionService(DistributedExecutorService executor)
Creates an ExecutorCompletionService using the supplied executor for base task execution and a LinkedBlockingQueue as a completion queue.

Parameters:
executor - the executor to use
Throws:
NullPointerException - if executor is null

DistributedExecutionCompletionService

public DistributedExecutionCompletionService(DistributedExecutorService executor,
                                             BlockingQueue<NotifyingFuture<V>> completionQueue)
Creates an ExecutorCompletionService using the supplied executor for base task execution and the supplied queue as its completion queue. Note: 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.

Parameters:
executor - the executor to use
completionQueue - the queue to use as the completion queue normally one dedicated for use by this service
Throws:
NullPointerException - if executor is null
Method Detail

submit

public Future<V> submit(Callable<V> task)

This future object may not be used as a NotifyingFuture. That is because internally this class sets the listener to provide ability to add to the queue.

Specified by:
submit in interface CompletionService<V>

submit

public Future<V> submit(Runnable task,
                        V result)

This future object may not be used as a NotifyingFuture. That is because internally this class sets the listener to provide ability to add to the queue.

Specified by:
submit in interface CompletionService<V>

take

public NotifyingFuture<V> take()
                        throws InterruptedException

This future may safely be used as a NotifyingFuture if desired. This is because if it tries to set a listener it will be called immediately since the task has already been completed.

Specified by:
take in interface CompletionService<V>
Throws:
InterruptedException

poll

public NotifyingFuture<V> poll()

This future may safely be used as a NotifyingFuture if desired. This is because if it tries to set a listener it will be called immediately since the task has already been completed.

Specified by:
poll in interface CompletionService<V>

poll

public NotifyingFuture<V> poll(long timeout,
                               TimeUnit unit)
                        throws InterruptedException

This future may safely be used as a NotifyingFuture if desired. This is because if it tries to set a listener it will be called immediately since the task has already been completed.

Specified by:
poll in interface CompletionService<V>
Throws:
InterruptedException

submit

public <K> Future<V> submit(Callable<V> task,
                            K... input)

submitEverywhere

public List<Future<V>> submitEverywhere(Callable<V> task)

submitEverywhere

public <K> List<Future<V>> submitEverywhere(Callable<V> task,
                                            K... input)

Infinispan Distribution 5.2.6.Final-redhat-2

Copyright © 2013 JBoss, a division of Red Hat. All Rights Reserved.