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).
|
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 TaskManager
task
- the task to add to the todo queue of its worker (contained in task)TaskmanagerException
public void addTasks(java.util.Collection<Task> taskList) throws TaskmanagerException
addTasks
in interface TaskManager
taskList
- the list of tasks to add.TaskmanagerException
public void addInProgressTask(Task task) throws TaskmanagerException
addInProgressTask
in interface TaskManager
task
- the task to add to the in progress queue of its worker (contained in task)TaskmanagerException
public Task getTask(java.lang.String workerName, java.lang.String host) throws TaskmanagerException
getTask
in interface TaskManager
workerName
- 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 TaskManager
workerName
- 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 TaskManager
workerName
- 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 TaskManager
workerName
- 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 TaskManager
workerName
- 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 TaskManager
filterMap
- map to identify tasks to be removedTaskmanagerException
- an exception if something went wrongpublic void addTaskQueue(java.lang.String workerName) throws TaskmanagerException
addTaskQueue
in interface TaskManager
workerName
- worker for which to add a task queue with given name.TaskmanagerException
public java.util.Map<java.lang.String,TaskCounter> getTaskCounters() throws TaskmanagerException
getTaskCounters
in interface TaskManager
TaskmanagerException
- counting failspublic TaskList getTaskList(java.lang.String workerName, java.lang.String section, int maxCount) throws TaskmanagerException
getTaskList
in interface TaskManager
workerName
- 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 TaskManager
workerName
- pipe in which the task is storedsection
- queue section ("todo" or "inprogress")taskName
- task identifierTaskmanagerException
- on errorpublic long getFailSafetyLevel()
getFailSafetyLevel
in interface TaskManager
public long getMaxScaleUp()
getMaxScaleUp
in interface TaskManager
public java.util.Map<java.lang.String,java.lang.Integer> getScaleUpCounters() throws TaskmanagerException
getScaleUpCounters
in interface TaskManager
TaskmanagerException
- on error.public 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