SMILA (incubation) API documentation

org.eclipse.smila.taskmanager.persistence
Interface TaskStorage

All Known Implementing Classes:
TaskStorageZk

public interface TaskStorage

Implementors of this interface implement the storage of tasks in so-called workerNames which can be seen as virtual queues. There may be but needn't to be a physical queue representation for a concrete worker. Received tasks are not removed from the workerName directly, but marked as "in process". Tasks "in process" will not be redelivered, as long as they aren't set unprocessed. A client should surround consecutive calls with #startSession() and #endOfSession(String) calls to get better performance.


Method Summary
 void clear()
          remove all tasks from storage and reset all counters.
 void createTaskQueue(java.lang.String name)
           
 void deleteTask(java.lang.String workerName, java.lang.String taskId)
          Remove the task from the inprogress part of the workers queue.
 long getFailSafetyLevel()
           
 Task getInProgressTask(java.lang.String workerName, java.lang.String taskId)
          read the task content of an in-progress task.
 long getMaxNoOfTasksPerHost()
           
 java.util.Map<java.lang.String,java.lang.Integer> getScaleUpCounters()
           
 Task getTask(java.lang.String workerName, java.lang.String workerHost, java.util.Collection<java.lang.String> qualifiers)
          Returns a task that's not "in process" from the given workerName for the given messageCondition.
 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.
 boolean hasTaskQueue(java.lang.String name)
           
 boolean isLockedQualifier(java.lang.String workerName, java.lang.String qualifier)
          check if a lock exists for given worker and qualifier.
 void keepAlive(java.lang.String workerName, java.lang.String taskId)
          Signals that the worker processing the given task is still alive.
 void lockQualifiers(java.lang.String workerName, java.util.Collection<java.lang.String> qualifiers)
          prevent new todo tasks from being added for the given worker and qualifiers.
 void purge(java.lang.String workerName)
          Remove all tasks from the given task pipe.
 void removeTasks(AnyMap filterMap)
          Remove canceled tasks identified by the filter map from todo and in-progress queue.
 void setMaxNoOfTasksPerHost(long maxTasks)
           
 void storeInProgressTask(Task task)
          Stores a new task to the inprogress queue of the given task's worker.
 void storeTask(java.lang.String workerName, Task task)
          Stores a new task to the todo queue of the given workerName.
 void storeTask(Task task)
          Stores a new task to the todo queue of the given task's worker.
 

Method Detail

storeTask

void storeTask(Task task)
               throws TaskmanagerException
Stores a new task to the todo queue of the given task's worker.

Parameters:
task - the task to store, contains the worker name
Throws:
TaskmanagerException - if send fails

storeTask

void storeTask(java.lang.String workerName,
               Task task)
               throws TaskmanagerException
Stores a new task to the todo queue of the given workerName. The worker name stored in the task will be ignored.

Parameters:
task - the task to store.
workerName - the worker for which to store the task.
Throws:
TaskmanagerException - if send fails

storeInProgressTask

void storeInProgressTask(Task task)
                         throws TaskmanagerException
Stores a new task to the inprogress queue of the given task's worker.

Parameters:
task - the task to store, contains the worker name
Throws:
TaskmanagerException - if send fails

getTask

Task getTask(java.lang.String workerName,
             java.lang.String workerHost,
             java.util.Collection<java.lang.String> qualifiers)
             throws TaskmanagerException
Returns a task that's not "in process" from the given workerName for the given messageCondition. The returned task will be marked as "in process".

Parameters:
workerName - the workerName where to get the task from.
workerHost - the host name where the worker is running that requested the task
qualifiers - if not null, allowed qualifiers of returned task.
Returns:
a task from the workerName for the given messageCondition (if any) or null if there is none available.
Throws:
TaskmanagerException - if receive fails

getInProgressTask

Task getInProgressTask(java.lang.String workerName,
                       java.lang.String taskId)
                       throws TaskmanagerException
read the task content of an in-progress task.

Parameters:
workerName - name of worker
taskId - task Id
Returns:
task contents or null if no such task exists.
Throws:
TaskmanagerException - if task is not in-progress or other errors.

deleteTask

void deleteTask(java.lang.String workerName,
                java.lang.String taskId)
                throws TaskmanagerException
Remove the task from the inprogress part of the workers queue.

Parameters:
workerName - the workerName from where the task was originally get.
taskId - the task identifier.
Throws:
TaskmanagerException - if taskId is invalid or not marked as finishing

keepAlive

void keepAlive(java.lang.String workerName,
               java.lang.String taskId)
               throws TaskmanagerException
Signals that the worker processing the given task is still alive.

Parameters:
workerName - name/id as string
taskId - task id that is currently processed as string
Throws:
TaskmanagerException - if any error occurs

purge

void purge(java.lang.String workerName)
           throws TaskmanagerException
Remove all tasks from the given task pipe.

Parameters:
workerName - name/id as string
Throws:
TaskmanagerException - if any error occurs

lockQualifiers

void lockQualifiers(java.lang.String workerName,
                    java.util.Collection<java.lang.String> qualifiers)
prevent new todo tasks from being added for the given worker and qualifiers. Used by org.eclipse.smila.taskmanager.TaskManager#finishTasks to prevent tasks (re-)entering the cleared qualifiers for the some time. The locks should be kept active by the TaskStorage implementation for at least some minutes, afterwards they may be cleaned up.

Parameters:
workerName - a worker's name
qualifiers - a list of qualifiers to lock

isLockedQualifier

boolean isLockedQualifier(java.lang.String workerName,
                          java.lang.String qualifier)
                          throws TaskmanagerException
check if a lock exists for given worker and qualifier.

Throws:
TaskmanagerException

getTaskCounters

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

Returns:
task counters
Throws:
TaskmanagerException - counting fails

getTaskList

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

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

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.

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

long getFailSafetyLevel()
Returns:
number of nodes that may fail before tasks get lost.

clear

void clear()
           throws TaskmanagerException
remove all tasks from storage and reset all counters.

Throws:
TaskmanagerException - error

setMaxNoOfTasksPerHost

void setMaxNoOfTasksPerHost(long maxTasks)
Parameters:
maxTasks - maximum number of tasks that should be delivered to a host. (scale up control)

getMaxNoOfTasksPerHost

long getMaxNoOfTasksPerHost()
Returns:
maximum number of tasks that should be delivered to a host. (scale up control)

getScaleUpCounters

java.util.Map<java.lang.String,java.lang.Integer> getScaleUpCounters()
                                                                     throws TaskmanagerException
Returns:
number of tasks in progress on different hosts.
Throws:
TaskmanagerException - on error.

removeTasks

void removeTasks(AnyMap filterMap)
                 throws TaskmanagerException
Remove canceled tasks identified by the filter map from todo and in-progress queue.

Parameters:
filterMap - map to identify tasks to be removed
Throws:
TaskmanagerException - an exception if something went wrong

createTaskQueue

void createTaskQueue(java.lang.String name)
                     throws TaskmanagerException
Parameters:
name - the name of the task queue to create.
Throws:
TaskmanagerException

hasTaskQueue

boolean hasTaskQueue(java.lang.String name)
                     throws TaskmanagerException
Parameters:
name - the task queue name to check
Returns:
'true' if task for given name exists, 'false' otherwise.
Throws:
TaskmanagerException

SMILA (incubation) API documentation