org.jgroups.blocks.executor

## Class ExecutionService

- java.lang.Object
- - java.util.concurrent.AbstractExecutorService
  - - org.jgroups.blocks.executor.ExecutionService

All Implemented Interfaces:
  java.util.concurrent.Executor, java.util.concurrent.ExecutorService

    public class ExecutionService
    extends java.util.concurrent.AbstractExecutorService

This is a jgroups implementation of an ExecutorService, where the consumers are running on any number of nodes. The nodes should run `ExecutionRunner` to start picking up requests.

Every future object returned will be a `NotifyingFuture` which allows for not having to query the future and have a callback instead. This can then be used as a workflow to submit other tasks sequentially or also to query the future for the value at that time.

Every callable or runnable submitted must be either `Serializable`, `Externalizable`, or `Streamable`. Also the value returned from a callable must `Serializable`, `Externalizable`, or `Streamable`. Unfortunately if the value returned is not serializable then a `NotSerializableException` will be thrown as the cause.

Since:
  2.12.0
Author:
  wburns

### Nested Class Summary

Nested Classes
`static class` `ExecutionService.DistributedFuture<V>` This is basically a copy of the FutureTask in java.util.concurrent but added serializable to it.
`protected static class` `ExecutionService.RunnableAdapter<T>` This is copied from `Executors` class which contains RunnableAdapter.

### Field Summary

Fields
`protected Executing` `_execProt`
`protected java.util.concurrent.atomic.AtomicBoolean` `_shutdown`
`protected java.util.concurrent.locks.Condition` `_unfinishedCondition`
`protected java.util.Set<java.util.concurrent.Future<?>>` `_unfinishedFutures`
`protected java.util.concurrent.locks.Lock` `_unfinishedLock`
`protected JChannel` `ch`

### Constructor Summary

Constructors
Constructor and Description
`ExecutionService()`
`ExecutionService(JChannel ch)`

### Method Summary

Methods
`boolean` `awaitTermination(long timeout, java.util.concurrent.TimeUnit unit)`
`void` `execute(java.lang.Runnable command)`
`boolean` `isShutdown()`
`boolean` `isTerminated()`
`protected <T> java.util.concurrent.RunnableFuture<T>` `newTaskFor(java.util.concurrent.Callable<T> callable)`
`protected <T> java.util.concurrent.RunnableFuture<T>` `newTaskFor(java.lang.Runnable runnable, T value)`
`void` `setChannel(JChannel ch)`
`void` `shutdown()`
`java.util.List<java.lang.Runnable>` `shutdownNow()`
`<T> NotifyingFuture<T>` `submit(java.util.concurrent.Callable<T> task)`
`<T> NotifyingFuture<T>` `submit(java.lang.Runnable task, T result)`

### Methods inherited from class java.util.concurrent.AbstractExecutorService

`invokeAll, invokeAll, invokeAny, invokeAny, submit`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### ch

    protected JChannel ch

#### _execProt

    protected Executing _execProt

#### _unfinishedLock

    protected java.util.concurrent.locks.Lock _unfinishedLock

#### _unfinishedCondition

    protected java.util.concurrent.locks.Condition _unfinishedCondition

#### _unfinishedFutures

    protected java.util.Set<java.util.concurrent.Future<?>> _unfinishedFutures

#### _shutdown

    protected java.util.concurrent.atomic.AtomicBoolean _shutdown

### Constructor Detail

#### ExecutionService

    public ExecutionService()

#### ExecutionService

    public ExecutionService(JChannel ch)

### Method Detail

#### setChannel

    public void setChannel(JChannel ch)

#### submit

    public <T> NotifyingFuture<T> submit(java.lang.Runnable task,
                                T result)

Specified by:
  `submit` in interface `java.util.concurrent.ExecutorService`
Overrides:
  `submit` in class `java.util.concurrent.AbstractExecutorService`

#### submit

    public <T> NotifyingFuture<T> submit(java.util.concurrent.Callable<T> task)

Specified by:
  `submit` in interface `java.util.concurrent.ExecutorService`
Overrides:
  `submit` in class `java.util.concurrent.AbstractExecutorService`

#### shutdown

    public void shutdown()

#### shutdownNow

    public java.util.List<java.lang.Runnable> shutdownNow()

#### isShutdown

    public boolean isShutdown()

#### isTerminated

    public boolean isTerminated()

#### awaitTermination

    public boolean awaitTermination(long timeout,
                           java.util.concurrent.TimeUnit unit)
                             throws java.lang.InterruptedException

Throws:
  `java.lang.InterruptedException`

#### execute

    public void execute(java.lang.Runnable command)

#### newTaskFor

    protected <T> java.util.concurrent.RunnableFuture<T> newTaskFor(java.lang.Runnable runnable,
                                                        T value)

Overrides:
  `newTaskFor` in class `java.util.concurrent.AbstractExecutorService`

#### newTaskFor

    protected <T> java.util.concurrent.RunnableFuture<T> newTaskFor(java.util.concurrent.Callable<T> callable)

Overrides:
  `newTaskFor` in class `java.util.concurrent.AbstractExecutorService`