com.hazelcast.util.executor

## Class StripedExecutor

- java.lang.Object
- - com.hazelcast.util.executor.StripedExecutor

- All Implemented Interfaces:
    Executor

      public final class StripedExecutor
      extends Object
      implements Executor

  The StripedExecutor internally uses a stripe of queues and each queue has its own private worker-thread. When a task is 'executed' on the StripedExecutor, the task is checked if it is a StripedRunnable. If it is, the right worker is looked up and the task put in the queue of that worker. If the task is not a StripedRunnable, a random worker is looked up.

  If the queue is full and the runnable implements TimeoutRunnable, then a configurable amount of blocking is done on the queue. If the runnable doesn't implement TimeoutRunnable or when the blocking times out, then the task is rejected and a RejectedExecutionException is thrown.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static AtomicLong` | `THREAD_ID_GENERATOR`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `StripedExecutor(ILogger logger, String threadNamePrefix, int threadCount, int queueCapacity)`
    `StripedExecutor(ILogger logger, String threadNamePrefix, int threadCount, int queueCapacity, boolean lazyThreads)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `execute(Runnable task)`
    `List<BlockingQueue<Runnable>>` | `getTaskQueues()`
    `int` | `getWorkQueueSize()` Returns the total number of tasks pending to be executed.
    `boolean` | `isLive()` Checks if this StripedExecutor is alive (so not shut down).
    `long` | `processedCount()` Returns the total number of processed events.
    `void` | `shutdown()` Shuts down this StripedExecutor.

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

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

- - ### Field Detail

    - #### THREAD_ID_GENERATOR

          public static final AtomicLong THREAD_ID_GENERATOR

  - ### Constructor Detail

    - #### StripedExecutor

          public StripedExecutor(ILogger logger,
                                 String threadNamePrefix,
                                 int threadCount,
                                 int queueCapacity)

    - #### StripedExecutor

          public StripedExecutor(ILogger logger,
                                 String threadNamePrefix,
                                 int threadCount,
                                 int queueCapacity,
                                 boolean lazyThreads)

  - ### Method Detail

    - #### getWorkQueueSize

          public int getWorkQueueSize()

      Returns the total number of tasks pending to be executed.
      Returns:
        total work queue size.

    - #### processedCount

          public long processedCount()

      Returns the total number of processed events.

    - #### shutdown

          public void shutdown()

      Shuts down this StripedExecutor.

      No checking is done to see if the StripedExecutor already is shut down, so it should be called only once.

      If there is any pending work, it will be thrown away.

    - #### isLive

          public boolean isLive()

      Checks if this StripedExecutor is alive (so not shut down).
      Returns:
        live (true)

    - #### execute

          public void execute(Runnable task)

      Specified by:
        `execute` in interface `Executor`

    - #### getTaskQueues

          public List<BlockingQueue<Runnable>> getTaskQueues()

Copyright © 2019. All rights reserved.