org.apache.ignite.internal.util

## Class StripedExecutor

- java.lang.Object
- - org.apache.ignite.internal.util.StripedExecutor

All Implemented Interfaces:
  Executor, ExecutorService

    public class StripedExecutor
    extends Object
    implements ExecutorService

Striped executor.

### Nested Class Summary

Nested Classes
`static class` `StripedExecutor.Stripe` Stripe.

### Constructor Summary

Constructors
Constructor and Description
`StripedExecutor(int cnt, String igniteInstanceName, String poolName, IgniteLogger log, IgniteInClosure<Throwable> errHnd, boolean stealTasks, GridWorkerListener gridWorkerLsnr, long failureDetectionTimeout)`
`StripedExecutor(int cnt, String igniteInstanceName, String poolName, IgniteLogger log, IgniteInClosure<Throwable> errHnd, GridWorkerListener gridWorkerLsnr, long failureDetectionTimeout)`

### Method Summary

All Methods Instance Methods Concrete Methods
`int` `activeStripesCount()`
`void` `awaitComplete(int... stripes)` Method for await all task completion in some specific striped indexes or all.
`boolean` `awaitTermination(long timeout, @NotNull TimeUnit unit)`
`long` `completedTasks()`
`boolean` `detectStarvation()` Checks starvation in striped pool.
`void` `execute(int idx, Runnable cmd)` Execute command.
`void` `execute(@NotNull Runnable cmd)`
`<T> @NotNull List<Future<T>>` `invokeAll(@NotNull Collection<? extends Callable<T>> tasks)` Operation not supported.
`<T> @NotNull List<Future<T>>` `invokeAll(@NotNull Collection<? extends Callable<T>> tasks, long timeout, @NotNull TimeUnit unit)` Operation not supported.
`<T> T` `invokeAny(@NotNull Collection<? extends Callable<T>> tasks)` Operation not supported.
`<T> T` `invokeAny(@NotNull Collection<? extends Callable<T>> tasks, long timeout, @NotNull TimeUnit unit)` Operation not supported.
`boolean` `isShutdown()`
`boolean` `isTerminated()`
`int` `queueSize()`
`void` `shutdown()`
`@NotNull List<Runnable>` `shutdownNow()`
`void` `stop()` Stops executor.
`StripedExecutor.Stripe[]` `stripes()`
`boolean[]` `stripesActiveStatuses()`
`long[]` `stripesCompletedTasks()`
`int` `stripesCount()`
`int[]` `stripesQueueSizes()`
`<T> @NotNull Future<T>` `submit(@NotNull Callable<T> task)` Operation not supported.
`@NotNull Future<?>` `submit(@NotNull Runnable task)` Operation not supported.
`<T> @NotNull Future<T>` `submit(@NotNull Runnable task, T res)` Operation not supported.
`String` `toString()`

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

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

### Constructor Detail

#### StripedExecutor

    public StripedExecutor(int cnt,
                           String igniteInstanceName,
                           String poolName,
                           IgniteLogger log,
                           IgniteInClosure<Throwable> errHnd,
                           GridWorkerListener gridWorkerLsnr,
                           long failureDetectionTimeout)

Parameters:
  `cnt` - Count.
  `igniteInstanceName` - Node name.
  `poolName` - Pool name.
  `log` - Logger.
  `errHnd` - Critical failure handler.
  `gridWorkerLsnr` - Listener to link with every stripe worker.

#### StripedExecutor

    public StripedExecutor(int cnt,
                           String igniteInstanceName,
                           String poolName,
                           IgniteLogger log,
                           IgniteInClosure<Throwable> errHnd,
                           boolean stealTasks,
                           GridWorkerListener gridWorkerLsnr,
                           long failureDetectionTimeout)

Parameters:
  `cnt` - Count.
  `igniteInstanceName` - Node name.
  `poolName` - Pool name.
  `log` - Logger.
  `errHnd` - Critical failure handler.
  `stealTasks` - `True` to steal tasks.
  `gridWorkerLsnr` - listener to link with every stripe worker.

### Method Detail

#### detectStarvation

    public boolean detectStarvation()

Checks starvation in striped pool. Maybe too verbose but this is needed to faster debug possible issues.

Returns:
  Flag representing presence of possible starvation in striped pool.

#### stripesCount

    public int stripesCount()

Returns:
  Stripes count.

#### stripes

    public StripedExecutor.Stripe[] stripes()

Returns:
  Stripes of this executor.

#### execute

    public void execute(int idx,
                        Runnable cmd)

Execute command.

Parameters:
  `idx` - Index.
  `cmd` - Command.

#### shutdown

    public void shutdown()

Specified by:
  `shutdown` in interface `ExecutorService`

#### execute

    public void execute(@NotNull
                        @NotNull Runnable cmd)

Specified by:
  `execute` in interface `Executor`

#### shutdownNow

    @NotNull
    public @NotNull List<Runnable> shutdownNow()

Specified by:
  `shutdownNow` in interface `ExecutorService`
Returns:
  Empty list (always).

#### awaitTermination

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

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

#### isShutdown

    public boolean isShutdown()

Specified by:
  `isShutdown` in interface `ExecutorService`

#### isTerminated

    public boolean isTerminated()

Specified by:
  `isTerminated` in interface `ExecutorService`

#### stop

    public void stop()

Stops executor.

#### queueSize

    public int queueSize()

Returns:
  Return total queue size of all stripes.

#### completedTasks

    public long completedTasks()

Returns:
  Completed tasks count.

#### stripesCompletedTasks

    public long[] stripesCompletedTasks()

Returns:
  Completed tasks per stripe count.

#### stripesActiveStatuses

    public boolean[] stripesActiveStatuses()

Returns:
  Number of active tasks per stripe.

#### activeStripesCount

    public int activeStripesCount()

Returns:
  Number of active tasks.

#### stripesQueueSizes

    public int[] stripesQueueSizes()

Returns:
  Size of queue per stripe.

#### submit

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

Operation not supported.

Specified by:
  `submit` in interface `ExecutorService`

#### submit

    @NotNull
    public @NotNull Future<?> submit(@NotNull
                                              @NotNull Runnable task)

Operation not supported.

Specified by:
  `submit` in interface `ExecutorService`

#### submit

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

Operation not supported.

Specified by:
  `submit` in interface `ExecutorService`

#### invokeAll

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

Operation not supported.

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

#### invokeAll

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

Operation not supported.

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

#### invokeAny

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

Operation not supported.

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

#### invokeAny

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

Operation not supported.

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

#### awaitComplete

    public void awaitComplete(int... stripes)
                       throws InterruptedException

Method for await all task completion in some specific striped indexes or all. The method guarantees what all tasks which were passed before this call will be completed before method return control.

Parameters:
  `stripes` - Striped idxs for await. Empty params means await all stripes.
Throws:
  `InterruptedException`

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.8.0
Release Date | : February 27 2020