org.apache.ignite.thread

## Class IgniteThread

- java.lang.Object
- - java.lang.Thread
  - - org.apache.ignite.thread.IgniteThread

- All Implemented Interfaces:
    Runnable
  Direct Known Subclasses:
    IgniteSpiThread

      public class IgniteThread
      extends Thread

  This class adds some necessary plumbing on top of the `Thread` class. Specifically, it adds:
  - Consistent naming of threads
  - Dedicated parent thread group
  - Backing interrupted flag
  - Name of the grid this thread belongs to
  Note: this class is intended for internal use only.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class java.lang.Thread

      `Thread.State, Thread.UncaughtExceptionHandler`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `GRP_IDX_UNASSIGNED` Index for unassigned thread.
    `protected String` | `igniteInstanceName` The name of the Ignite instance this thread belongs to.

    - ### Fields inherited from class java.lang.Thread

      `MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `` | `IgniteThread(org.apache.ignite.internal.util.worker.GridWorker worker)` Creates thread with given worker.
    `` | `IgniteThread(String igniteInstanceName, String threadName)` Creates grid thread with given name for a given Ignite instance.
    `` | `IgniteThread(String igniteInstanceName, String threadName, Runnable r)` Creates grid thread with given name for a given Ignite instance.
    `` | `IgniteThread(String igniteInstanceName, String threadName, Runnable r, int grpIdx, int stripe, byte plc)` Creates grid thread with given name for a given Ignite instance with specified thread group.
    `protected` | `IgniteThread(String igniteInstanceName, ThreadGroup threadGrp, String threadName)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `cachePoolThread()`
    `int` | `compositeRwLockIndex()`
    `void` | `compositeRwLockIndex(int compositeRwLockIdx)`
    `protected static String` | `createName(long num, String threadName, String igniteInstanceName)` Creates new thread name.
    `static IgniteThread` | `current()`
    `static boolean` | `currentThreadCanRequestBinaryMetadata()`
    `String` | `getIgniteInstanceName()` Gets name of the Ignite instance this thread belongs to.
    `boolean` | `isForbiddenToRequestBinaryMetadata()`
    `static void` | `onEntryProcessorEntered(boolean holdsTopLock)` Callback before entry processor execution is started.
    `static void` | `onEntryProcessorLeft()` Callback after entry processor execution is finished.
    `static void` | `onForbidBinaryMetadataRequestSectionEntered()` Callback on entering critical section where binary metadata requests are forbidden.
    `static void` | `onForbidBinaryMetadataRequestSectionLeft()` Callback on leaving critical section where binary metadata requests are forbidden.
    `byte` | `policy()`
    `int` | `stripe()`
    `String` | `toString()`

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

      `activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, run, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, yield`

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

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

- - ### Field Detail

    - #### GRP_IDX_UNASSIGNED

          public static final int GRP_IDX_UNASSIGNED

      Index for unassigned thread.
      See Also:
        Constant Field Values

    - #### igniteInstanceName

          protected final String igniteInstanceName

      The name of the Ignite instance this thread belongs to.

  - ### Constructor Detail

    - #### IgniteThread

          public IgniteThread(org.apache.ignite.internal.util.worker.GridWorker worker)

      Creates thread with given worker.
      Parameters:
        `worker` - Runnable to create thread with.

    - #### IgniteThread

          public IgniteThread(String igniteInstanceName,
                              String threadName)

      Creates grid thread with given name for a given Ignite instance.
      Parameters:
        `igniteInstanceName` - Name of the Ignite instance this thread is created for.
        `threadName` - Name of thread.

    - #### IgniteThread

          public IgniteThread(String igniteInstanceName,
                              String threadName,
                              Runnable r)

      Creates grid thread with given name for a given Ignite instance.
      Parameters:
        `igniteInstanceName` - Name of the Ignite instance this thread is created for.
        `threadName` - Name of thread.
        `r` - Runnable to execute.

    - #### IgniteThread

          public IgniteThread(String igniteInstanceName,
                              String threadName,
                              Runnable r,
                              int grpIdx,
                              int stripe,
                              byte plc)

      Creates grid thread with given name for a given Ignite instance with specified thread group.
      Parameters:
        `igniteInstanceName` - Name of the Ignite instance this thread is created for.
        `threadName` - Name of thread.
        `r` - Runnable to execute.
        `grpIdx` - Thread index within a group.
        `stripe` - Non-negative stripe number if this thread is striped pool thread.

    - #### IgniteThread

          protected IgniteThread(String igniteInstanceName,
                                 ThreadGroup threadGrp,
                                 String threadName)

      Parameters:
        `igniteInstanceName` - Name of the Ignite instance this thread is created for.
        `threadGrp` - Thread group.
        `threadName` - Name of thread.

  - ### Method Detail

    - #### policy

          public byte policy()

      Returns:
        Related `GridIoPolicy` for internal Ignite pools.

    - #### stripe

          public int stripe()

      Returns:
        Non-negative stripe number if this thread is striped pool thread.

    - #### cachePoolThread

          public boolean cachePoolThread()

      Returns:
        `True` if thread belongs to pool processing cache operations.

    - #### getIgniteInstanceName

          public String getIgniteInstanceName()

      Gets name of the Ignite instance this thread belongs to.
      Returns:
        Name of the Ignite instance this thread belongs to.

    - #### compositeRwLockIndex

          public int compositeRwLockIndex()

      Returns:
        Composite RW lock index.

    - #### compositeRwLockIndex

          public void compositeRwLockIndex(int compositeRwLockIdx)

      Parameters:
        `compositeRwLockIdx` - Composite RW lock index.

    - #### isForbiddenToRequestBinaryMetadata

          public boolean isForbiddenToRequestBinaryMetadata()

      Returns:
        `True` if thread is not allowed to request binary metadata to avoid potential deadlock.

    - #### currentThreadCanRequestBinaryMetadata

          public static boolean currentThreadCanRequestBinaryMetadata()

      Returns:
        `True` if thread is not allowed to request binary metadata to avoid potential deadlock.

    - #### onEntryProcessorEntered

          public static void onEntryProcessorEntered(boolean holdsTopLock)

      Callback before entry processor execution is started.

    - #### onEntryProcessorLeft

          public static void onEntryProcessorLeft()

      Callback after entry processor execution is finished.

    - #### onForbidBinaryMetadataRequestSectionEntered

          public static void onForbidBinaryMetadataRequestSectionEntered()

      Callback on entering critical section where binary metadata requests are forbidden.

    - #### onForbidBinaryMetadataRequestSectionLeft

          public static void onForbidBinaryMetadataRequestSectionLeft()

      Callback on leaving critical section where binary metadata requests are forbidden.

    - #### current

          public static IgniteThread current()

      Returns:
        IgniteThread or `null` if current thread is not an instance of IgniteThread.

    - #### createName

          protected static String createName(long num,
                                             String threadName,
                                             String igniteInstanceName)

      Creates new thread name.
      Parameters:
        `num` - Thread number.
        `threadName` - Thread name.
        `igniteInstanceName` - Ignite instance name.
      Returns:
        New thread name.

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Thread`

2021 Copyright © Apache Software Foundation
| Follow @ApacheIgnite
Ignite Database and Caching Platform | : ver. 2.11.0
Release Date | : September 11 2021