SMILA (incubation) API documentation

org.eclipse.smila.taskmanager.internal
Class TaskManagerImpl

java.lang.Object
  extended by org.eclipse.smila.taskmanager.internal.TaskManagerImpl
All Implemented Interfaces:
TaskManager

public class TaskManagerImpl
extends java.lang.Object
implements TaskManager

The TaskManager implementation.


Field Summary
 
Fields inherited from interface org.eclipse.smila.taskmanager.TaskManager
CONFIGURATION_BUNDLE, FINISHING_TASKS_WORKER, PREFIX_INTERNAL, TASKERROR_TIME_TO_LIVE
 
Constructor Summary
TaskManagerImpl()
           
 
Method Summary
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.
 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)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TaskManagerImpl

public TaskManagerImpl()
Method Detail

activate

protected void activate(ComponentContext context)
OSGi Declarative Services service activation method.

Parameters:
context - OSGi service component context.

addTask

public void addTask(Task task)
             throws TaskmanagerException

Specified by:
addTask in interface TaskManager
Parameters:
task - the task to add to the todo queue of its worker (contained in task)
Throws:
TaskmanagerException

addTasks

public void addTasks(java.util.Collection<Task> taskList)
              throws TaskmanagerException
add tasks to the system (e.g. for manually triggered tasks).

Specified by:
addTasks in interface TaskManager
Parameters:
taskList - the list of tasks to add.
Throws:
TaskmanagerException

addInProgressTask

public void addInProgressTask(Task task)
                       throws TaskmanagerException

Specified by:
addInProgressTask in interface TaskManager
Parameters:
task - the task to add to the in progress queue of its worker (contained in task)
Throws:
TaskmanagerException

getTask

public Task getTask(java.lang.String workerName,
                    java.lang.String host)
             throws TaskmanagerException
Get next task for worker with name workerName.

Specified by:
getTask in interface TaskManager
Parameters:
workerName - the worker name
host - the host name where the worker is running that requested the task
Returns:
next task for worker with name workerName
Throws:
TaskmanagerException - an error while looking up or returning the task for the given worker.
See Also:
TaskManager#getTask(String, Collection)

getTask

public Task getTask(java.lang.String workerName,
                    java.lang.String host,
                    java.util.Collection<java.lang.String> qualifiers)
             throws TaskmanagerException
Get next task for worker with name workerName that match the given qualifiers.

Specified by:
getTask in interface TaskManager
Parameters:
workerName - the worker name
host - the host name where the worker is running that requested the task
qualifiers - qualifiers to describe the task.
Returns:
Next task for worker with name workerName that match the given qualifiers.
Throws:
TaskmanagerException - an error while looking up or returning the task for the given worker.

finishTask

public void finishTask(java.lang.String workerName,
                       java.lang.String taskId,
                       ResultDescription resultDescription)
                throws TaskmanagerException
Remove task from in-progress and put it into finishing queue.

Specified by:
finishTask in interface TaskManager
Parameters:
workerName - the worker name
taskId - the id of the task to be finished
resultDescription - the result description for the task to be finished.
Throws:
TaskmanagerException - an error occurred while trying to finish the task.

keepAlive

public void keepAlive(java.lang.String workerName,
                      java.lang.String taskId)
               throws TaskmanagerException
Prevent rollback of task due to exceeded time-to-live.

Specified by:
keepAlive in interface TaskManager
Parameters:
workerName - the worker name.
taskId - the ID of the task.
Throws:
TaskmanagerException - an error occurred while trying to send keep alive for this task.

finishTasks

public void finishTasks(java.lang.String workerName,
                        java.util.Collection<java.lang.String> qualifiers,
                        ResultDescription resultDescription)
                 throws TaskmanagerException
Finish all qualified tasks matching the qualifier condition. Lock qualifiers

Specified by:
finishTasks in interface TaskManager
Parameters:
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.
Throws:
TaskmanagerException - an exception occurred while trying to delete the tasks.

removeTasks

public void removeTasks(AnyMap filterMap)
                 throws TaskmanagerException
Remove canceled tasks identified by the filter map.

Specified by:
removeTasks in interface TaskManager
Parameters:
filterMap - map to identify tasks to be removed
Throws:
TaskmanagerException - an exception if something went wrong

addTaskQueue

public void addTaskQueue(java.lang.String workerName)
                  throws TaskmanagerException

Specified by:
addTaskQueue in interface TaskManager
Parameters:
workerName - worker for which to add a task queue with given name.
Throws:
TaskmanagerException

getTaskCounters

public java.util.Map<java.lang.String,TaskCounter> getTaskCounters()
                                                            throws TaskmanagerException
Get number of tasks in all current queues.

Specified by:
getTaskCounters in interface TaskManager
Returns:
task counters
Throws:
TaskmanagerException - counting fails

getTaskList

public TaskList getTaskList(java.lang.String workerName,
                            java.lang.String section,
                            int maxCount)
                     throws TaskmanagerException
Get task list for current task pipe and sub-type.

Specified by:
getTaskList in interface TaskManager
Parameters:
workerName - name/id as string
section - task pipe sub-type: "inprogress" or "todo".
maxCount - max. number of tasks in return list
Returns:
task list
Throws:
TaskmanagerException - if accessing task list fails

getTaskInfo

public Any getTaskInfo(java.lang.String workerName,
                       java.lang.String section,
                       java.lang.String taskName)
                throws TaskmanagerException
Prepares information on a task stored in the task storage.

Specified by:
getTaskInfo in interface TaskManager
Parameters:
workerName - pipe in which the task is stored
section - queue section ("todo" or "inprogress")
taskName - task identifier
Returns:
task information
Throws:
TaskmanagerException - on error

getFailSafetyLevel

public long getFailSafetyLevel()

Specified by:
getFailSafetyLevel in interface TaskManager
Returns:
number of nodes that may fail before tasks get lost.

getMaxScaleUp

public long getMaxScaleUp()

Specified by:
getMaxScaleUp in interface TaskManager
Returns:
maximum number of tasks that should be delivered to a host. (scale up control)

getScaleUpCounters

public java.util.Map<java.lang.String,java.lang.Integer> getScaleUpCounters()
                                                                     throws TaskmanagerException

Specified by:
getScaleUpCounters in interface TaskManager
Returns:
number of tasks in progress on different hosts.
Throws:
TaskmanagerException - on error.

setTaskStorage

public void setTaskStorage(TaskStorage taskStorage)
Parameters:
taskStorage - the new task storage

unsetTaskStorage

public void unsetTaskStorage(TaskStorage taskStorage)
Parameters:
taskStorage - the task storage

setClusterConfigService

public void setClusterConfigService(ClusterConfigService ccs)
needed to get cluster configuration.


unsetClusterConfigService

public void unsetClusterConfigService(ClusterConfigService ccs)
Parameters:
ccs - the cluster config service to unset

SMILA (incubation) API documentation