org.apache.ignite.internal.executor

## Class GridExecutorService

- java.lang.Object
- - org.apache.ignite.internal.executor.GridExecutorService

All Implemented Interfaces:
  Externalizable, Serializable, Executor, ExecutorService

    public class GridExecutorService
    extends Object
    implements ExecutorService, Externalizable

An `ExecutorService` that executes each submitted task in grid through `Ignite` instance, normally configured using `Ignite.executorService()` method. `GridExecutorService` delegates commands execution to already started `Ignite` instance. Every submitted task will be serialized and transferred to any node in grid.

All submitted tasks must implement `Serializable` interface.

Note, that GridExecutorService implements ExecutorService from JDK 1.5. If you have problems with compilation for JDK 1.6 and above you need to apply some changes (see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6267833)

Change signature for methods `invokeAll(Collection)`, `invokeAll(Collection, long, TimeUnit)`, `invokeAny(Collection)`, `invokeAny(Collection, long, TimeUnit)` to

     public class GridExecutorService implements ExecutorService {
     ...
         public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException {
             ...
         }

         public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
             throws InterruptedException {
             ...
         }

         public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException {
             ...
         }

         public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
             throws InterruptedException, ExecutionException, TimeoutException {
         }
         ...
     }

See Also:
  Serialized Form

### Constructor Summary

Constructors
Constructor and Description
`GridExecutorService()` No-arg constructor is required by externalization.
`GridExecutorService(ClusterGroupAdapter prj, GridKernalContext ctx)` Creates executor service.

### Method Summary

All Methods Instance Methods Concrete Methods
`boolean` `awaitTermination(long timeout, TimeUnit unit)`
`void` `execute(Runnable cmd)`
`<T> List<Future<T>>` `invokeAll(Collection<? extends Callable<T>> tasks)` Note, for compilation with JDK 1.6 necessary to change method signature (note the {@code <?
`<T> List<Future<T>>` `invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)` Note, for compilation with JDK 1.6 necessary to change method signature (note the {@code <?
`<T> T` `invokeAny(Collection<? extends Callable<T>> tasks)` Note, for compilation with JDK 1.6 necessary to change method signature (note the {@code <?
`<T> T` `invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)` Note, for compilation with JDK 1.6 necessary to change method signature (note the {@code <?
`boolean` `isShutdown()`
`boolean` `isTerminated()`
`void` `readExternal(ObjectInput in)`
`protected Object` `readResolve()` Reconstructs object on unmarshalling.
`void` `shutdown()`
`List<Runnable>` `shutdownNow()`
`<T> Future<T>` `submit(Callable<T> task)`
`Future<?>` `submit(Runnable task)`
`<T> Future<T>` `submit(Runnable task, T res)`
`void` `writeExternal(ObjectOutput out)`

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

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

### Constructor Detail

#### GridExecutorService

    public GridExecutorService()

No-arg constructor is required by externalization.

#### GridExecutorService

    public GridExecutorService(ClusterGroupAdapter prj,
                               GridKernalContext ctx)

Creates executor service.

Parameters:
  `prj` - Projection.
  `ctx` - Grid logger.

### Method Detail

#### writeExternal

    public void writeExternal(ObjectOutput out)
                       throws IOException

Specified by:
  `writeExternal` in interface `Externalizable`
Throws:
  `IOException`

#### readExternal

    public void readExternal(ObjectInput in)
                      throws IOException,
                             ClassNotFoundException

Specified by:
  `readExternal` in interface `Externalizable`
Throws:
  `IOException`
  `ClassNotFoundException`

#### readResolve

    protected Object readResolve()
                          throws ObjectStreamException

Reconstructs object on unmarshalling.

Returns:
  Reconstructed object.
Throws:
  `ObjectStreamException` - Thrown in case of unmarshalling error.

#### shutdown

    public void shutdown()

Specified by:
  `shutdown` in interface `ExecutorService`

#### shutdownNow

    public List<Runnable> shutdownNow()

Specified by:
  `shutdownNow` in interface `ExecutorService`

#### isShutdown

    public boolean isShutdown()

Specified by:
  `isShutdown` in interface `ExecutorService`

#### isTerminated

    public boolean isTerminated()

Specified by:
  `isTerminated` in interface `ExecutorService`

#### awaitTermination

    public boolean awaitTermination(long timeout,
                                    TimeUnit unit)
                             throws InterruptedException

Specified by:
  `awaitTermination` in interface `ExecutorService`
Throws:
  `InterruptedException`

#### submit

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

Specified by:
  `submit` in interface `ExecutorService`

#### submit

    public <T> Future<T> submit(Runnable task,
                                T res)

Specified by:
  `submit` in interface `ExecutorService`

#### submit

    public Future<?> submit(Runnable task)

Specified by:
  `submit` in interface `ExecutorService`

#### invokeAll

    public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks)
                                  throws InterruptedException

Note, for compilation with JDK 1.6 necessary to change method signature (note the `&lt;? extends T&gt;` clause).

         ...
         public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException {
             // Method body.
         }
         ...

Specified by:
  `invokeAll` in interface `ExecutorService`
Throws:
  `InterruptedException`

#### invokeAll

    public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks,
                                         long timeout,
                                         TimeUnit unit)
                                  throws InterruptedException

Note, for compilation with JDK 1.6 necessary to change method signature (note the `&lt;? extends T&gt;` clause).

         public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
             throws InterruptedException {
             ...
         }

Specified by:
  `invokeAll` in interface `ExecutorService`
Throws:
  `InterruptedException`

#### invokeAny

    public <T> T invokeAny(Collection<? extends Callable<T>> tasks)
                    throws InterruptedException,
                           ExecutionException

Note, for compilation with JDK 1.6 necessary to change method signature (note the `&lt;? extends T&gt;` clause).

         ...
         public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException {
             // Method body.
         }
         ...

Specified by:
  `invokeAny` in interface `ExecutorService`
Throws:
  `InterruptedException`
  `ExecutionException`

#### invokeAny

    public <T> T invokeAny(Collection<? extends Callable<T>> tasks,
                           long timeout,
                           TimeUnit unit)
                    throws InterruptedException,
                           ExecutionException,
                           TimeoutException

Note, for compilation with JDK 1.6 necessary to change method signature (note the `&lt;? extends T&gt;` clause).

         ...
         public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
             throws InterruptedException, ExecutionException, TimeoutException {
         }
         ...

Specified by:
  `invokeAny` in interface `ExecutorService`
Throws:
  `InterruptedException`
  `ExecutionException`
  `TimeoutException`

#### execute

    public void execute(Runnable cmd)

Specified by:
  `execute` in interface `Executor`

2018 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 2.5.0
Release Date | : May 23 2018