Class TaskThread

  • All Implemented Interfaces:
    Runnable

    public class TaskThread
    extends DirectoryThread
    This class defines a thread that will be used to execute a scheduled task within the server and provide appropriate notification that the task is complete.
    • Constructor Detail

      • TaskThread

        public TaskThread​(TaskScheduler taskScheduler,
                          int threadID)
        Creates a new task thread with the provided information.
        Parameters:
        taskScheduler - The reference to the task scheduler with which this thread is associated.
        threadID - The ID assigned to this task thread.
    • Method Detail

      • getTask

        public Task getTask()
        Retrieves the task currently being processed by this thread, if it is active.
        Returns:
        The task currently being processed by this thread, or null if it is not processing any task.
      • setTask

        public void setTask​(Task task)
        Provides a new task for processing by this thread. This does not do any check to ensure that no task is already in process.
        Parameters:
        task - The task to be processed.
      • interruptTask

        public void interruptTask​(TaskState interruptState,
                                  org.forgerock.i18n.LocalizableMessage interruptReason,
                                  boolean exitThread)
        Attempts to interrupt processing on the task in progress.
        Parameters:
        interruptState - The state to use for the task if it is successfully interrupted.
        interruptReason - The human-readable reason that the task is to be interrupted.
        exitThread - Indicates whether this thread should exit when processing on the active task has completed.
      • run

        public void run()
        Operates in a loop, sleeping until there is no work to do, then processing the task and returning to the scheduler for more work.
        Specified by:
        run in interface Runnable
        Overrides:
        run in class Thread
      • getDebugProperties

        public Map<String,​String> getDebugProperties()
        Retrieves any relevant debug information with which this tread is associated so they can be included in debug messages.
        Overrides:
        getDebugProperties in class DirectoryThread
        Returns:
        debug information about this thread as a string.