org.opends.server.backends.task
Class TaskThread

java.lang.Object
  extended by java.lang.Thread
      extended by org.opends.server.api.DirectoryThread
          extended by org.opends.server.backends.task.TaskThread
All Implemented Interfaces:
java.lang.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 java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
TaskThread(TaskScheduler taskScheduler, int threadID)
          Creates a new task thread with the provided information.
 
Method Summary
 java.util.Map<java.lang.String,java.lang.String> getDebugProperties()
          Retrieves any relevent debug information with which this tread is associated so they can be included in debug messages.
 Task getTask()
          Retrieves the task currently being processed by this thread, if it is active.
 void interruptTask(TaskState interruptState, Message interruptReason, boolean exitThread)
          Attempts to interrupt processing on the task in progress.
 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.
 void setTask(Task task)
          Provides a new task for processing by this thread.
 
Methods inherited from class org.opends.server.api.DirectoryThread
getAssociatedTask, getCreationStackTrace, getParentThread, setAssociatedTask
 
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, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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,
                          Message 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 java.lang.Runnable
Overrides:
run in class java.lang.Thread

getDebugProperties

public java.util.Map<java.lang.String,java.lang.String> getDebugProperties()
Retrieves any relevent 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.