Class IgniteStripedThreadPoolExecutor

  • All Implemented Interfaces:
    Executor, ExecutorService, org.apache.ignite.internal.processors.pool.MetricsAwareExecutorService

    public class IgniteStripedThreadPoolExecutor
    extends Object
    implements ExecutorService, org.apache.ignite.internal.processors.pool.MetricsAwareExecutorService
    An ExecutorService that executes submitted tasks using pooled grid threads.
    • Constructor Detail

      • IgniteStripedThreadPoolExecutor

        public IgniteStripedThreadPoolExecutor​(int concurrentLvl,
                                               String igniteInstanceName,
                                               String threadNamePrefix,
                                               Thread.UncaughtExceptionHandler eHnd,
                                               boolean allowCoreThreadTimeOut,
                                               long keepAliveTime)
        Create striped thread pool.
        Parameters:
        concurrentLvl - Concurrency level.
        igniteInstanceName - Node name.
        threadNamePrefix - Thread name prefix.
        allowCoreThreadTimeOut - Sets the policy governing whether core threads may time out and terminate if no tasks arrive within the keep-alive time.
        keepAliveTime - When the number of threads is greater than the core, this is the maximum time that excess idle threads will wait for new tasks before terminating.
        eHnd - Uncaught exception handler.
    • Method Detail

      • execute

        public void execute​(Runnable task,
                            int idx)
        Executes the given command at some time in the future. The command with the same index will be executed in the same thread.
        Parameters:
        task - the runnable task
        idx - Striped index.
        Throws:
        RejectedExecutionException - if this task cannot be accepted for execution.
        NullPointerException - If command is null
      • threadId

        public int threadId​(int idx)
        Parameters:
        idx - Index.
        Returns:
        Stripped thread ID.
      • registerMetrics

        public void registerMetrics​(org.apache.ignite.internal.processors.metric.MetricRegistryImpl mreg)
        Register thread pool metrics.
        Specified by:
        registerMetrics in interface org.apache.ignite.internal.processors.pool.MetricsAwareExecutorService
        Parameters:
        mreg - Metrics registry.
      • queueEmpty

        public boolean queueEmpty()
        Returns:
        True if task queue is empty..
      • completedTaskCount

        public long completedTaskCount()
        Returns:
        Approximate total number of tasks that have completed execution. Because the states of tasks and threads may change dynamically during computation, the returned value is only an approximation, but one that does not ever decrease across successive calls.
      • activeCount

        public int activeCount()
        Returns:
        Approximate number of threads that are actively executing tasks.
      • poolSize

        public int poolSize()
        Returns:
        current number of threads in the pool.