Package org.opends.server.tools.tasks
Class TaskTool
- java.lang.Object
-
- org.opends.server.tools.tasks.TaskTool
-
- All Implemented Interfaces:
TaskScheduleInformation
- Direct Known Subclasses:
BackUpDB,ExportLDIF,ImportLDIF,RebuildIndex,RestoreDB
public abstract class TaskTool extends 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
Fields Modifier and Type Field Description static StringNOWMagic 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.protected BooleanArgumentrunOfflineArgArgument used to know if the tool should be run in offline mode.
-
Constructor Summary
Constructors Constructor Description TaskTool()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidcheckVersion()Checks that binary version and instance version are the same.protected voidcleanup()Cleanup task environment after offline run.protected LDAPConnectionArgumentParsercreateArgParser(String className, org.forgerock.i18n.LocalizableMessage toolDescription)Creates an argument parser prepopulated with arguments for processing input for scheduling tasks with the task backend.List<String>getDependencyIds()Gets a list of task IDs upon which this task is dependent.FailedDependencyActiongetFailedDependencyAction()Gets the action to take should one of the dependent task fail.List<String>getNotifyUponCompletionEmailAddresses()Gets a list of email address to which an email will be sent when this task completes.List<String>getNotifyUponErrorEmailAddresses()Gets a list of email address to which an email will be sent if this task encounters an error during execution.protected org.forgerock.i18n.LocalizableMessagegetOfflineDescriptionMessage()StringgetRecurringDateTime()Gets the date/time pattern for recurring task schedule.DategetStartDateTime()Gets the date at which this task should be scheduled to start.protected intprocess(LDAPConnectionArgumentParser argParser, boolean initializeServer, PrintStream out, PrintStream err)Either invokes initiates this tool's local action or schedule this tool using the tasks interface based on user input.protected abstract intprocessLocal(boolean initializeServer, PrintStream out, PrintStream err)Called when this utility should perform its actions locally in this JVM.booleanrunOffline()Indicates whether we must return if the command must be run in off-line mode.protected voidvalidateTaskArgs()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, getTaskId, getTaskObjectclass
-
-
-
-
Field Detail
-
NOW
public static final 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
-
runOfflineArg
protected BooleanArgument runOfflineArg
Argument used to know if the tool should be run in offline mode.
-
-
Method Detail
-
processLocal
protected abstract int processLocal(boolean initializeServer, PrintStream out, PrintStream err)Called when this utility should perform its actions locally in this JVM.- Parameters:
initializeServer- indicates whether to initialize the directory server in the case of a local actionout- stream to write messages; may be nullerr- stream to write messages; may be null- Returns:
- int indicating the result of this action
-
cleanup
protected void cleanup()
Cleanup task environment after offline run. Default implementation does nothing. Tasks which initialize some static part of the DirectoryServer instance (e.g admin data local backends) must override this method to shutdown all needed component to prevent JVM environment alteration.
-
createArgParser
protected LDAPConnectionArgumentParser createArgParser(String className, org.forgerock.i18n.LocalizableMessage toolDescription)
Creates an argument parser prepopulated with arguments for processing input for scheduling tasks with the task backend.- Parameters:
className- of this tooltoolDescription- of this tool- Returns:
- LDAPConnectionArgumentParser for processing CLI input
-
getOfflineDescriptionMessage
protected org.forgerock.i18n.LocalizableMessage getOfflineDescriptionMessage()
-
validateTaskArgs
protected void validateTaskArgs() throws ArgumentException, ClientExceptionValidates arguments related to task scheduling. This should be called after theArgumentParser.parseArgumentshas been called.- Throws:
ArgumentException- if there is a problem with the arguments.ClientException- if there is a problem with one of the values provided by the user.
-
getStartDateTime
public Date getStartDateTime()
Gets the date at which this task should be scheduled to start.- Specified by:
getStartDateTimein interfaceTaskScheduleInformation- Returns:
- date/time at which the task should be scheduled
-
getRecurringDateTime
public String getRecurringDateTime()
Gets the date/time pattern for recurring task schedule.- Specified by:
getRecurringDateTimein interfaceTaskScheduleInformation- Returns:
- recurring date/time pattern at which the task should be scheduled.
-
getDependencyIds
public List<String> getDependencyIds()
Gets a list of task IDs upon which this task is dependent.- Specified by:
getDependencyIdsin interfaceTaskScheduleInformation- Returns:
- list of task IDs
-
getFailedDependencyAction
public FailedDependencyAction getFailedDependencyAction()
Gets the action to take should one of the dependent task fail.- Specified by:
getFailedDependencyActionin interfaceTaskScheduleInformation- Returns:
- action to take
-
getNotifyUponCompletionEmailAddresses
public List<String> getNotifyUponCompletionEmailAddresses()
Gets a list of email address to which an email will be sent when this task completes.- Specified by:
getNotifyUponCompletionEmailAddressesin interfaceTaskScheduleInformation- Returns:
- list of email addresses
-
getNotifyUponErrorEmailAddresses
public List<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:
getNotifyUponErrorEmailAddressesin interfaceTaskScheduleInformation- Returns:
- list of email addresses
-
process
protected int process(LDAPConnectionArgumentParser argParser, boolean initializeServer, PrintStream out, 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 argumentsinitializeServer- indicates whether to initialize the directory server in the case of a local actionout- stream to write messages; may be nullerr- stream to write messages; may be null- Returns:
- int indicating the result of this action
-
runOffline
public boolean runOffline()
Indicates whether we must return if the command must be run in off-line mode.- Returns:
trueif we must return if the command must be run in off-line mode andfalseotherwise.
-
checkVersion
protected void checkVersion() throws InitializationExceptionChecks that binary version and instance version are the same.- Throws:
InitializationException- If versions mismatch
-
-