Package org.opends.server.tools.tasks
Class TaskClient
java.lang.Object
org.opends.server.tools.tasks.TaskClient
Helper class for interacting with the task backend on behalf of utilities that are capable of being scheduled.
-
Constructor Summary
ConstructorDescriptionTaskClient
(Connection conn) Creates a new TaskClient for interacting with the task backend remotely. -
Method Summary
Modifier and TypeMethodDescriptionvoid
cancelTask
(String taskId) Changes that the state of the task in the backend to a canceled state.static Entry
createTask
(TaskScheduleInformation information) Creates anEntry
for the task described in the providedTaskScheduleInformation
.static String
Uses provided task entry attributes to create a DN for the provided task entry.Gets all the ds-task entries from the task root.getTaskEntry
(String taskId) Gets the entry of the task associated to the provided identifier.static String
Returns the ID of the provided task entry.schedule
(TaskScheduleInformation information) Schedule a task for execution by writing an entry to the task backend.waitUntilTaskIsDone
(String taskId, PrintStream stream) Wait until the task with the provided id is done.
-
Constructor Details
-
TaskClient
Creates a new TaskClient for interacting with the task backend remotely.- Parameters:
conn
- for accessing the task backend
-
-
Method Details
-
getTaskId
Returns the ID of the provided task entry.- Parameters:
taskEntry
- The taskEntry
.- Returns:
- the ID of the provided task
Entry
. - Throws:
IllegalArgumentException
- If the task ID cannot be retrieve from the providedEntry
.
-
getTaskDn
Uses provided task entry attributes to create a DN for the provided task entry. -
waitUntilTaskIsDone
public TaskEntry waitUntilTaskIsDone(String taskId, PrintStream stream) throws LdapException, TaskClientException Wait until the task with the provided id is done.The provided
taskClient
is used for retrieving task information. During the execution, tasks logs are printed on the providedstream
.- Parameters:
taskId
- A string representing the ID of the task to retrieve.stream
- The stream to use for printing task logs, may benull
.- Returns:
- A
task entry
object representing the task done. - Throws:
LdapException
- If an error occurs while retrieving task information from the server.TaskClientException
- If there is no task with the requested ID.
-
schedule
public TaskEntry schedule(TaskScheduleInformation information) throws LdapException, TaskClientException Schedule a task for execution by writing an entry to the task backend.- Parameters:
information
- to be scheduled- Returns:
- String task ID assigned the new task
- Throws:
LdapException
- if there is a problem getting information out to the directoryTaskClientException
- if there is a problem with the task entry
-
createTask
Creates anEntry
for the task described in the providedTaskScheduleInformation
.- Parameters:
information
- The scheduling information from which to create the task entry.- Returns:
- A new entry representing a task.
-
getTaskEntries
Gets all the ds-task entries from the task root.- Returns:
- list of entries from the task root
- Throws:
LdapException
- if there is a problem getting information out to the directory
-
getTaskEntry
Gets the entry of the task associated to the provided identifier.- Parameters:
taskId
- of the entry to retrieve- Returns:
- Entry for the task
- Throws:
LdapException
- if there is a problem getting information out to the directoryTaskClientException
- if there is no task with the requested id
-
cancelTask
Changes that the state of the task in the backend to a canceled state.- Parameters:
taskId
- if the task to cancel- Throws:
LdapException
- if there is a problem getting information out to the directoryTaskClientException
- if there is no task with the requested id or if the task has finished and cannot be completed
-