|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
org.opends.server.api.DirectoryThread
org.opends.server.backends.task.TaskScheduler
public class TaskScheduler
This class defines a task scheduler for the Directory Server that will control the execution of scheduled tasks and other administrative functions that need to occur on a regular basis.
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 | |
---|---|
TaskScheduler(TaskBackend taskBackend)
Creates a new task scheduler that will be used to ensure that tasks are invoked at the appropriate times. |
Method Summary | |
---|---|
void |
addCompletedTask(Task completedTask)
Adds the provided task to the set of completed tasks associated with the scheduler. |
void |
addRecurringTask(RecurringTask recurringTask,
boolean scheduleIteration)
Adds a recurring task to the scheduler, optionally scheduling the first iteration for processing. |
Task |
cancelTask(java.lang.String taskID)
Attempts to cancel the task with the given task ID. |
RecurringTask |
entryToRecurringTask(Entry entry)
Decodes the contents of the provided entry as a recurring task. |
Task |
entryToScheduledTask(Entry entry,
Operation operation)
Decodes the contents of the provided entry as a scheduled task. |
java.util.LinkedHashMap<java.lang.String,java.lang.String> |
getAlerts()
Retrieves information about the set of alerts that this generator may produce. |
java.lang.String |
getClassName()
Retrieves the fully-qualified name of the Java class for this alert generator implementation. |
DN |
getComponentEntryDN()
Retrieves the DN of the configuration entry with which this alert generator is associated. |
long |
getEntryCount()
Retrieves the total number of entries in the task backend. |
RecurringTask |
getRecurringTask(DN recurringTaskEntryDN)
Retrieves the recurring task with the given recurring task ID. |
RecurringTask |
getRecurringTask(java.lang.String recurringTaskID)
Retrieves the recurring task with the given recurring task ID. |
long |
getRecurringTaskCount()
Retrieves the number of recurring tasks in the task backend. |
Entry |
getRecurringTaskEntry(DN recurringTaskEntryDN)
Retrieves the recurring task entry with the provided DN. |
Entry |
getRecurringTaskParentEntry()
Retrieves the entry that is the immediate parent for all recurring task entries in the task backend. |
Task |
getScheduledTask(DN taskEntryDN)
Retrieves the scheduled task created from the specified entry. |
Task |
getScheduledTask(java.lang.String taskID)
Retrieves the scheduled task with the given task ID. |
long |
getScheduledTaskCount()
Retrieves the number of scheduled tasks in the task backend. |
Entry |
getScheduledTaskEntry(DN scheduledTaskEntryDN)
Retrieves the scheduled task entry with the provided DN. |
Entry |
getScheduledTaskParentEntry()
Retrieves the entry that is the immediate parent for all scheduled task entries in the task backend. |
TaskBackend |
getTaskBackend()
Retrieves the task backend with which this scheduler is associated. |
Entry |
getTaskRootEntry()
Retrieves the root entry that is the common ancestor for all entries in the task backend. |
void |
interruptRunningTasks(TaskState interruptState,
Message interruptReason,
boolean waitForStop)
Attempts to interrupt any tasks that are actively running. |
Task |
removeCompletedTask(java.lang.String taskID)
Removes the specified completed task. |
Task |
removePendingTask(java.lang.String taskID)
Removes the specified pending task. |
RecurringTask |
removeRecurringTask(java.lang.String recurringTaskID)
Removes the recurring task with the given ID. |
void |
run()
Operates in a loop, launching tasks at the appropriate time and performing any necessary periodic cleanup. |
void |
scheduleTask(Task task,
boolean writeState)
Schedules the provided task for execution. |
boolean |
searchRecurringTasks(SearchOperation searchOperation)
Compares the filter in the provided search operation against each of the recurring task entries, returning any that match. |
boolean |
searchScheduledTasks(SearchOperation searchOperation)
Compares the filter in the provided search operation against each of the task entries, returning any that match. |
void |
stopScheduler()
Stops the scheduler so that it will not start any scheduled tasks. |
boolean |
threadDone(TaskThread taskThread,
Task completedTask)
Indicates that processing has completed on the provided task thread and that it is now available for processing other tasks. |
void |
writeState()
Writes state information about all tasks and recurring tasks to disk. |
Methods inherited from class org.opends.server.api.DirectoryThread |
---|
getAssociatedTask, getCreationStackTrace, getDebugProperties, 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 |
---|
public TaskScheduler(TaskBackend taskBackend) throws InitializationException
taskBackend
- The task backend with which this scheduler is
associated.
InitializationException
- If a problem occurs while initializing
the scheduler from the backing file.Method Detail |
---|
public void addRecurringTask(RecurringTask recurringTask, boolean scheduleIteration) throws DirectoryException
recurringTask
- The recurring task to add to the scheduler.scheduleIteration
- Indicates whether to schedule an iteration of
the recurring task.
DirectoryException
- If a problem occurs while trying to add the
recurring task (e.g., there's already another
recurring task defined with the same ID).public RecurringTask removeRecurringTask(java.lang.String recurringTaskID) throws DirectoryException
recurringTaskID
- The ID of the recurring task to remove.
null
if there
was no such recurring task.
DirectoryException
- If there is currently a pending or running
iteration of the associated recurring task.public void scheduleTask(Task task, boolean writeState) throws DirectoryException
task
- The task to be scheduled.writeState
- Indicates whether the current state information for
the scheduler should be persisted to disk once the
task is scheduled.
DirectoryException
- If a problem occurs while trying to schedule
the task (e.g., there's already another task
defined with the same ID).public Task cancelTask(java.lang.String taskID)
taskID
- The task ID of the task to cancel.
null
if there is no
such task.public Task removePendingTask(java.lang.String taskID) throws DirectoryException
taskID
- The task ID of the pending task to remove.
DirectoryException
- If the requested task is not in the pending
queue.public Task removeCompletedTask(java.lang.String taskID) throws DirectoryException
taskID
- The task ID of the completed task to remove.
DirectoryException
- If the requested task could not be found.public boolean threadDone(TaskThread taskThread, Task completedTask)
taskThread
- The thread that has completed processing on its
previously-assigned task.completedTask
- The task for which processing has been completed.
true
if the thread should continue running and
wait for the next task to process, or false
if it
should exit immediately.public void addCompletedTask(Task completedTask)
completedTask
- The task for which processing has completed.public void stopScheduler()
public void interruptRunningTasks(TaskState interruptState, Message interruptReason, boolean waitForStop)
interruptState
- The state that should be assigned to the tasks if
they are successfully interrupted.interruptReason
- A message indicating the reason that the tasks
are to be interrupted.waitForStop
- Indicates whether this method should wait until
all active tasks have stopped before returning.public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
public void writeState()
public long getEntryCount()
public long getScheduledTaskCount()
public long getRecurringTaskCount()
public TaskBackend getTaskBackend()
public Entry getTaskRootEntry()
public Entry getScheduledTaskParentEntry()
public Entry getRecurringTaskParentEntry()
public Task getScheduledTask(java.lang.String taskID)
taskID
- The task ID for the scheduled task to retrieve.
null
if there is no
such task.public Task getScheduledTask(DN taskEntryDN)
taskEntryDN
- The DN of the task configuration entry associated
with the task to retrieve.
null
if there is no
such task.public Entry getScheduledTaskEntry(DN scheduledTaskEntryDN)
scheduledTaskEntryDN
- The entry DN that indicates which scheduled
task entry to retrieve.
null
if no scheduled task has the provided DN.public boolean searchScheduledTasks(SearchOperation searchOperation) throws DirectoryException
searchOperation
- The search operation to use when performing the
search.
true
if processing should continue on the search
operation, or false
if it should not for some reason
(e.g., a size or time limit was reached).
DirectoryException
- If a problem occurs while processing the
search operation against the scheduled tasks.public RecurringTask getRecurringTask(java.lang.String recurringTaskID)
recurringTaskID
- The recurring task ID for the recurring task to
retrieve.
null
if there is no
such recurring task.public RecurringTask getRecurringTask(DN recurringTaskEntryDN)
recurringTaskEntryDN
- The recurring task ID for the recurring task
to retrieve.
null
if there is no
such recurring task.public Entry getRecurringTaskEntry(DN recurringTaskEntryDN)
recurringTaskEntryDN
- The entry DN that indicates which recurring
task entry to retrieve.
null
if no recurring task has the provided DN.public boolean searchRecurringTasks(SearchOperation searchOperation) throws DirectoryException
searchOperation
- The search operation to use when performing the
search.
true
if processing should continue on the search
operation, or false
if it should not for some reason
(e.g., a size or time limit was reached).
DirectoryException
- If a problem occurs while processing the
search operation against the recurring tasks.public Task entryToScheduledTask(Entry entry, Operation operation) throws DirectoryException
entry
- The entry to decode as a scheduled task.operation
- The operation used to create this task in the server, or
null
if the operation is not available.
DirectoryException
- If the provided entry cannot be decoded as a
scheduled task.public RecurringTask entryToRecurringTask(Entry entry) throws DirectoryException
entry
- The entry to decode as a recurring task.
DirectoryException
- If the provided entry cannot be decoded as a
recurring task.public DN getComponentEntryDN()
getComponentEntryDN
in interface AlertGenerator
public java.lang.String getClassName()
getClassName
in interface AlertGenerator
public java.util.LinkedHashMap<java.lang.String,java.lang.String> getAlerts()
getAlerts
in interface AlertGenerator
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |