public class TaskManagerImpl extends java.lang.Object implements TaskManager
CONFIGURATION_BUNDLE, FINISHING_TASKS_WORKER, PREFIX_INTERNAL, TASKERROR_TIME_TO_LIVE| Constructor and Description |
|---|
TaskManagerImpl() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
activate(ComponentContext context)
OSGi Declarative Services service activation method.
|
void |
addInProgressTask(Task task) |
void |
addTask(Task task) |
void |
addTaskQueue(java.lang.String workerName) |
void |
addTasks(java.util.Collection<Task> taskList)
add tasks to the system (e.g. for manually triggered tasks).
|
java.util.List<Task> |
filterDuplicates(java.util.List<Task> tasksToBeAdded)
return new list of tasks with only those tasks from the given task list
that do not have property
Task.PROPERTY_UNIQUENESS_TAG set or
for which currently no task is in the Todo queue that has the same uniqueness tag. |
void |
finishTask(java.lang.String workerName,
java.lang.String taskId,
ResultDescription resultDescription)
Remove task from in-progress and put it into finishing queue.
|
void |
finishTasks(java.lang.String workerName,
java.util.Collection<java.lang.String> qualifiers,
ResultDescription resultDescription)
Finish all qualified tasks matching the qualifier condition.
|
long |
getFailSafetyLevel() |
long |
getMaxScaleUp() |
java.util.Map<java.lang.String,java.lang.Integer> |
getScaleUpCounters() |
Task |
getTask(java.lang.String workerName,
java.lang.String host)
Get next task for worker with name workerName.
|
Task |
getTask(java.lang.String workerName,
java.lang.String host,
java.util.Collection<java.lang.String> qualifiers)
Get next task for worker with name workerName that match the given qualifiers.
|
java.util.Map<java.lang.String,TaskCounter> |
getTaskCounters()
Get number of tasks in all current queues.
|
Any |
getTaskInfo(java.lang.String workerName,
java.lang.String section,
java.lang.String taskName)
Prepares information on a task stored in the task storage.
|
TaskList |
getTaskList(java.lang.String workerName,
java.lang.String section,
int maxCount)
Get task list for current task pipe and sub-type.
|
void |
keepAlive(java.lang.String workerName,
java.lang.String taskId)
Prevent rollback of task due to exceeded time-to-live.
|
void |
removeTasks(AnyMap filterMap)
Remove canceled tasks identified by the filter map.
|
void |
setClusterConfigService(ClusterConfigService ccs)
needed to get cluster configuration.
|
void |
setTaskStorage(TaskStorage taskStorage) |
void |
unsetClusterConfigService(ClusterConfigService ccs) |
void |
unsetTaskStorage(TaskStorage taskStorage) |
protected void activate(ComponentContext context)
context - OSGi service component context.public void addTask(Task task) throws TaskmanagerException
addTask in interface TaskManagertask - the task to add to the todo queue of its worker (contained in task)TaskmanagerExceptionpublic void addTasks(java.util.Collection<Task> taskList) throws TaskmanagerException
addTasks in interface TaskManagertaskList - the list of tasks to add.TaskmanagerExceptionpublic void addInProgressTask(Task task) throws TaskmanagerException
addInProgressTask in interface TaskManagertask - the task to add to the in progress queue of its worker (contained in task)TaskmanagerExceptionpublic Task getTask(java.lang.String workerName, java.lang.String host) throws TaskmanagerException
getTask in interface TaskManagerworkerName - the worker namehost - the host name where the worker is running that requested the taskTaskmanagerException - an error while looking up or returning the task for the given worker.TaskManager#getTask(String, Collection)public Task getTask(java.lang.String workerName, java.lang.String host, java.util.Collection<java.lang.String> qualifiers) throws TaskmanagerException
getTask in interface TaskManagerworkerName - the worker namehost - the host name where the worker is running that requested the taskqualifiers - qualifiers to describe the task.TaskmanagerException - an error while looking up or returning the task for the given worker.public void finishTask(java.lang.String workerName,
java.lang.String taskId,
ResultDescription resultDescription)
throws TaskmanagerException
finishTask in interface TaskManagerworkerName - the worker nametaskId - the id of the task to be finishedresultDescription - the result description for the task to be finished.TaskmanagerException - an error occurred while trying to finish the task.public void keepAlive(java.lang.String workerName,
java.lang.String taskId)
throws TaskmanagerException
keepAlive in interface TaskManagerworkerName - the worker name.taskId - the ID of the task.TaskmanagerException - an error occurred while trying to send keep alive for this task.public void finishTasks(java.lang.String workerName,
java.util.Collection<java.lang.String> qualifiers,
ResultDescription resultDescription)
throws TaskmanagerException
finishTasks in interface TaskManagerworkerName - the worker name.qualifiers - qualifiers describing the condition. Must not be null. If it is empty, nothing is done.resultDescription - the result description for the tasks to be finished.TaskmanagerException - an exception occurred while trying to delete the tasks.public void removeTasks(AnyMap filterMap) throws TaskmanagerException
removeTasks in interface TaskManagerfilterMap - map to identify tasks to be removedTaskmanagerException - an exception if something went wrongpublic void addTaskQueue(java.lang.String workerName)
throws TaskmanagerException
addTaskQueue in interface TaskManagerworkerName - worker for which to add a task queue with given name.TaskmanagerExceptionpublic java.util.Map<java.lang.String,TaskCounter> getTaskCounters() throws TaskmanagerException
getTaskCounters in interface TaskManagerTaskmanagerException - counting failspublic TaskList getTaskList(java.lang.String workerName, java.lang.String section, int maxCount) throws TaskmanagerException
getTaskList in interface TaskManagerworkerName - name/id as stringsection - task pipe sub-type: "inprogress" or "todo".maxCount - max. number of tasks in return listTaskmanagerException - if accessing task list failspublic Any getTaskInfo(java.lang.String workerName, java.lang.String section, java.lang.String taskName) throws TaskmanagerException
getTaskInfo in interface TaskManagerworkerName - pipe in which the task is storedsection - queue section ("todo" or "inprogress")taskName - task identifierTaskmanagerException - on errorpublic long getFailSafetyLevel()
getFailSafetyLevel in interface TaskManagerpublic long getMaxScaleUp()
getMaxScaleUp in interface TaskManagerpublic java.util.Map<java.lang.String,java.lang.Integer> getScaleUpCounters()
throws TaskmanagerException
getScaleUpCounters in interface TaskManagerTaskmanagerException - on error.public java.util.List<Task> filterDuplicates(java.util.List<Task> tasksToBeAdded) throws TaskmanagerException
TaskManagerTask.PROPERTY_UNIQUENESS_TAG set or
filterDuplicates in interface TaskManagertasksToBeAdded - tasks created as follow-up tasks but not yet added to the task managerTaskmanagerExceptionpublic void setTaskStorage(TaskStorage taskStorage)
taskStorage - the new task storagepublic void unsetTaskStorage(TaskStorage taskStorage)
taskStorage - the task storagepublic void setClusterConfigService(ClusterConfigService ccs)
public void unsetClusterConfigService(ClusterConfigService ccs)
ccs - the cluster config service to unset