Class 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.
    • 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.
        plc - GridIoPolicy policy.
        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.
        Parameters:
        holdsTopLock - Whether to hold topology lock.
      • 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.