Package org.opends.server.backends.task
Class TaskThread
- java.lang.Object
-
- java.lang.Thread
-
- org.opends.server.api.DirectoryThread
-
- org.opends.server.backends.task.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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.opends.server.api.DirectoryThread
DirectoryThread.Factory
-
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
-
-
Field Summary
-
Fields inherited from class org.opends.server.api.DirectoryThread
DIRECTORY_THREAD_GROUP
-
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
-
Constructor Summary
Constructors Constructor Description TaskThread(TaskScheduler taskScheduler, int threadID)Creates a new task thread with the provided information.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<String,String>getDebugProperties()Retrieves any relevant debug information with which this tread is associated so they can be included in debug messages.TaskgetTask()Retrieves the task currently being processed by this thread, if it is active.voidinterruptTask(TaskState interruptState, org.forgerock.i18n.LocalizableMessage interruptReason, boolean exitThread)Attempts to interrupt processing on the task in progress.voidrun()Operates in a loop, sleeping until there is no work to do, then processing the task and returning to the scheduler for more work.voidsetTask(Task task)Provides a new task for processing by this thread.-
Methods inherited from class org.opends.server.api.DirectoryThread
getAssociatedTask, getCreationStackTrace, getParentThread, initiateShutdown, isShutdownInitiated, setAssociatedTask, startWork, stopWork
-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
-
-
-
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
nullif 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.
-
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:
getDebugPropertiesin classDirectoryThread- Returns:
- debug information about this thread as a string.
-
-