Class TaskManager
java.lang.Object
com.unboundid.ldap.sdk.unboundidds.tasks.TaskManager
This class provides a number of utility methods for interacting with tasks in
Ping Identity, UnboundID, or Nokia/Alcatel-Lucent 8661 server instances.
It provides methods for the following:
NOTE: This class, and other classes within the
com.unboundid.ldap.sdk.unboundidds package structure, are only
supported for use against Ping Identity, UnboundID, and
Nokia/Alcatel-Lucent 8661 server products. These classes provide support
for proprietary functionality or for external specifications that are not
considered stable or mature enough to be guaranteed to work in an
interoperable way with other types of LDAP servers.
It provides methods for the following:
- Retrieving information about all scheduled, running, and recently-completed tasks in the server.
- Retrieving a specific task by its task ID.
- Scheduling a new task.
- Waiting for a scheduled task to complete.
- Canceling a scheduled task.
- Deleting a scheduled task.
Example
The following example demonstrates the process for retrieving information about all tasks within the server and printing their contents using the generic API:
List<Task> allTasks = TaskManager.getTasks(connection);
for (Task task : allTasks)
{
String taskID = task.getTaskID();
String taskName = task.getTaskName();
TaskState taskState = task.getState();
Map<TaskProperty,List<Object>> taskProperties =
task.getTaskPropertyValues();
}
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidcancelTask(String taskID, LDAPConnection connection) Submits a request to cancel the task with the specified task ID.static voidcancelTask(String taskID, LDAPInterface connection) Submits a request to cancel the task with the specified task ID.static voiddeleteTask(String taskID, LDAPConnection connection) Attempts to delete the task with the specified task ID.static voiddeleteTask(String taskID, LDAPInterface connection) Attempts to delete the task with the specified task ID.static TaskgetTask(String taskID, LDAPConnection connection) Retrieves the task with the specified task ID using the given connection.static TaskgetTask(String taskID, LDAPInterface connection) Retrieves the task with the specified task ID using the given connection.getTasks(LDAPConnection connection) Retrieves all of the tasks defined in the Directory Server using the provided connection.getTasks(LDAPInterface connection) Retrieves all of the tasks defined in the Directory Server using the provided connection.static TaskscheduleTask(Task task, LDAPConnection connection) Schedules a new instance of the provided task in the Directory Server.static TaskscheduleTask(Task task, LDAPInterface connection) Schedules a new instance of the provided task in the Directory Server.static TaskwaitForTask(String taskID, LDAPConnection connection, long pollFrequency, long maxWaitTime) Waits for the specified task to complete.static TaskwaitForTask(String taskID, LDAPInterface connection, long pollFrequency, long maxWaitTime) Waits for the specified task to complete.
-
Method Details
-
getTask
@Nullable public static Task getTask(@NotNull String taskID, @NotNull LDAPConnection connection) throws LDAPException, TaskException Retrieves the task with the specified task ID using the given connection.- Parameters:
taskID- The task ID for the task to retrieve. It must not benull.connection- The connection to the Directory Server from which to retrieve the task. It must not benull.- Returns:
- The requested task, or
nullif no such task exists in the server. An attempt will be made to instantiate the task as the most appropriate task type, but if this is not possible then it will be a genericTaskobject. - Throws:
LDAPException- If a problem occurs while communicating with the Directory Server over the provided connection.TaskException- If the retrieved entry cannot be parsed as a task.
-
getTask
@Nullable public static Task getTask(@NotNull String taskID, @NotNull LDAPInterface connection) throws LDAPException, TaskException Retrieves the task with the specified task ID using the given connection.- Parameters:
taskID- The task ID for the task to retrieve. It must not benull.connection- The connection to the Directory Server from which to retrieve the task. It must not benull.- Returns:
- The requested task, or
nullif no such task exists in the server. An attempt will be made to instantiate the task as the most appropriate task type, but if this is not possible then it will be a genericTaskobject. - Throws:
LDAPException- If a problem occurs while communicating with the Directory Server over the provided connection.TaskException- If the retrieved entry cannot be parsed as a task.
-
getTasks
Retrieves all of the tasks defined in the Directory Server using the provided connection.- Parameters:
connection- The connection to the Directory Server instance from which to retrieve the defined tasks.- Returns:
- A list of all tasks defined in the associated Directory Server.
- Throws:
LDAPException- If a problem occurs while communicating with the Directory Server over the provided connection.
-
getTasks
Retrieves all of the tasks defined in the Directory Server using the provided connection.- Parameters:
connection- The connection to the Directory Server instance from which to retrieve the defined tasks.- Returns:
- A list of all tasks defined in the associated Directory Server.
- Throws:
LDAPException- If a problem occurs while communicating with the Directory Server over the provided connection.
-
scheduleTask
@NotNull public static Task scheduleTask(@NotNull Task task, @NotNull LDAPConnection connection) throws LDAPException, TaskException Schedules a new instance of the provided task in the Directory Server.- Parameters:
task- The task to be scheduled.connection- The connection to the Directory Server in which the task is to be scheduled.- Returns:
- A
Taskobject representing the task that was scheduled and re-read from the server. - Throws:
LDAPException- If a problem occurs while communicating with the Directory Server, or if it rejects the task.TaskException- If the entry read back from the server after the task was created could not be parsed as a task.
-
scheduleTask
@NotNull public static Task scheduleTask(@NotNull Task task, @NotNull LDAPInterface connection) throws LDAPException, TaskException Schedules a new instance of the provided task in the Directory Server.- Parameters:
task- The task to be scheduled.connection- The connection to the Directory Server in which the task is to be scheduled.- Returns:
- A
Taskobject representing the task that was scheduled and re-read from the server. - Throws:
LDAPException- If a problem occurs while communicating with the Directory Server, or if it rejects the task.TaskException- If the entry read back from the server after the task was created could not be parsed as a task.
-
cancelTask
public static void cancelTask(@NotNull String taskID, @NotNull LDAPConnection connection) throws LDAPException Submits a request to cancel the task with the specified task ID. Note that some tasks may not support being canceled. Further, for tasks that do support being canceled it may take time for the cancel request to be processed and for the task to actually be canceled.- Parameters:
taskID- The task ID of the task to be canceled.connection- The connection to the Directory Server in which to perform the operation.- Throws:
LDAPException- If a problem occurs while communicating with the Directory Server.
-
cancelTask
public static void cancelTask(@NotNull String taskID, @NotNull LDAPInterface connection) throws LDAPException Submits a request to cancel the task with the specified task ID. Note that some tasks may not support being canceled. Further, for tasks that do support being canceled it may take time for the cancel request to be processed and for the task to actually be canceled.- Parameters:
taskID- The task ID of the task to be canceled.connection- The connection to the Directory Server in which to perform the operation.- Throws:
LDAPException- If a problem occurs while communicating with the Directory Server.
-
deleteTask
public static void deleteTask(@NotNull String taskID, @NotNull LDAPConnection connection) throws LDAPException Attempts to delete the task with the specified task ID.- Parameters:
taskID- The task ID of the task to be deleted.connection- The connection to the Directory Server in which to perform the operation.- Throws:
LDAPException- If a problem occurs while communicating with the Directory Server.
-
deleteTask
public static void deleteTask(@NotNull String taskID, @NotNull LDAPInterface connection) throws LDAPException Attempts to delete the task with the specified task ID.- Parameters:
taskID- The task ID of the task to be deleted.connection- The connection to the Directory Server in which to perform the operation.- Throws:
LDAPException- If a problem occurs while communicating with the Directory Server.
-
waitForTask
@NotNull public static Task waitForTask(@NotNull String taskID, @NotNull LDAPConnection connection, long pollFrequency, long maxWaitTime) throws LDAPException, TaskException Waits for the specified task to complete.- Parameters:
taskID- The task ID of the task to poll.connection- The connection to the Directory Server containing the desired task.pollFrequency- The minimum length of time in milliseconds between checks to see if the task has completed. A value less than or equal to zero will cause the client to check as quickly as possible.maxWaitTime- The maximum length of time in milliseconds to wait for the task to complete before giving up. A value less than or equal to zero indicates that it will keep checking indefinitely until the task has completed.- Returns:
- Task The decoded task after it has completed, or after the maximum wait time has expired.
- Throws:
LDAPException- If a problem occurs while communicating with the Directory Server.TaskException- If a problem occurs while attempting to parse the task entry as a task, or if the specified task entry could not be found.
-
waitForTask
@NotNull public static Task waitForTask(@NotNull String taskID, @NotNull LDAPInterface connection, long pollFrequency, long maxWaitTime) throws LDAPException, TaskException Waits for the specified task to complete.- Parameters:
taskID- The task ID of the task to poll.connection- The connection to the Directory Server containing the desired task.pollFrequency- The minimum length of time in milliseconds between checks to see if the task has completed. A value less than or equal to zero will cause the client to check as quickly as possible.maxWaitTime- The maximum length of time in milliseconds to wait for the task to complete before giving up. A value less than or equal to zero indicates that it will keep checking indefinitely until the task has completed.- Returns:
- Task The decoded task after it has completed, or after the maximum wait time has expired.
- Throws:
LDAPException- If a problem occurs while communicating with the Directory Server.TaskException- If a problem occurs while attempting to parse the task entry as a task, or if the specified task entry could not be found.
-