org.opends.server.tools.tasks
Class TaskTool

java.lang.Object
  extended by org.opends.server.tools.tasks.TaskTool
All Implemented Interfaces:
TaskScheduleInformation
Direct Known Subclasses:
BackUpDB, ExportLDIF, ImportLDIF, RestoreDB

public abstract class TaskTool
extends java.lang.Object
implements TaskScheduleInformation

Base class for tools that are capable of operating either by running local within this JVM or by scheduling a task to perform the same action running within the directory server through the tasks interface.


Field Summary
static java.lang.String NOW
          Magic value used to indicate that the user would like to schedule this operation to run immediately as a task as opposed to running the operation in the local VM.
 
Constructor Summary
TaskTool()
           
 
Method Summary
protected  LDAPConnectionArgumentParser createArgParser(java.lang.String className, Message toolDescription)
          Creates an argument parser prepopulated with arguments for processing input for scheduling tasks with the task backend.
 java.util.List<java.lang.String> getDependencyIds()
          Gets a list of task IDs upon which this task is dependent.
 FailedDependencyAction getFailedDependencyAction()
          Gets the action to take should one of the dependent task fail.
 java.util.List<java.lang.String> getNotifyUponCompletionEmailAddresses()
          Gets a list of email address to which an email will be sent when this task completes.
 java.util.List<java.lang.String> getNotifyUponErrorEmailAddresses()
          Gets a list of email address to which an email will be sent if this task encounters an error during execution.
 java.util.Date getStartDateTime()
          Gets the date at which this task should be scheduled to start.
protected  int process(LDAPConnectionArgumentParser argParser, boolean initializeServer, java.io.PrintStream out, java.io.PrintStream err)
          Either invokes initiates this tool's local action or schedule this tool using the tasks interface based on user input.
protected abstract  int processLocal(boolean initializeServer, java.io.PrintStream out, java.io.PrintStream err)
          Called when this utility should perform its actions locally in this JVM.
protected  void validateTaskArgs()
          Validates arguments related to task scheduling.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.opends.server.tools.tasks.TaskScheduleInformation
addTaskAttributes, getTaskClass, getTaskObjectclass
 

Field Detail

NOW

public static final java.lang.String NOW
Magic value used to indicate that the user would like to schedule this operation to run immediately as a task as opposed to running the operation in the local VM.

See Also:
Constant Field Values
Constructor Detail

TaskTool

public TaskTool()
Method Detail

processLocal

protected abstract int processLocal(boolean initializeServer,
                                    java.io.PrintStream out,
                                    java.io.PrintStream err)
Called when this utility should perform its actions locally in this JVM.

Parameters:
initializeServer - indicates whether or not to initialize the directory server in the case of a local action
out - stream to write messages; may be null
err - stream to write messages; may be null
Returns:
int indicating the result of this action

createArgParser

protected LDAPConnectionArgumentParser createArgParser(java.lang.String className,
                                                       Message toolDescription)
Creates an argument parser prepopulated with arguments for processing input for scheduling tasks with the task backend.

Parameters:
className - of this tool
toolDescription - of this tool
Returns:
LDAPConnectionArgumentParser for processing CLI input

validateTaskArgs

protected void validateTaskArgs()
                         throws ArgumentException
Validates arguments related to task scheduling. This should be called after the ArgumentParser.parseArguments has been called.

Throws:
ArgumentException - if there is a problem with the arguments

getStartDateTime

public java.util.Date getStartDateTime()
Gets the date at which this task should be scheduled to start.

Specified by:
getStartDateTime in interface TaskScheduleInformation
Returns:
date/time at which the task should be scheduled

getDependencyIds

public java.util.List<java.lang.String> getDependencyIds()
Gets a list of task IDs upon which this task is dependent.

Specified by:
getDependencyIds in interface TaskScheduleInformation
Returns:
list of task IDs

getFailedDependencyAction

public FailedDependencyAction getFailedDependencyAction()
Gets the action to take should one of the dependent task fail.

Specified by:
getFailedDependencyAction in interface TaskScheduleInformation
Returns:
action to take

getNotifyUponCompletionEmailAddresses

public java.util.List<java.lang.String> getNotifyUponCompletionEmailAddresses()
Gets a list of email address to which an email will be sent when this task completes.

Specified by:
getNotifyUponCompletionEmailAddresses in interface TaskScheduleInformation
Returns:
list of email addresses

getNotifyUponErrorEmailAddresses

public java.util.List<java.lang.String> getNotifyUponErrorEmailAddresses()
Gets a list of email address to which an email will be sent if this task encounters an error during execution.

Specified by:
getNotifyUponErrorEmailAddresses in interface TaskScheduleInformation
Returns:
list of email addresses

process

protected int process(LDAPConnectionArgumentParser argParser,
                      boolean initializeServer,
                      java.io.PrintStream out,
                      java.io.PrintStream err)
Either invokes initiates this tool's local action or schedule this tool using the tasks interface based on user input.

Parameters:
argParser - used to parse user arguments
initializeServer - indicates whether or not to initialize the directory server in the case of a local action
out - stream to write messages; may be null
err - stream to write messages; may be null
Returns:
int indicating the result of this action