public class TaskStorageZk extends java.lang.Object implements TaskStorage
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
HOST_COUNTER_MAP_ZK_PATH
Zookeeper path to stored host counters.
|
static java.lang.String |
QUALIFIER_LOCKS_ZK_PATH
Zookeeper path to qualifier locks.
|
static long |
TASKSPERHOST_UNLIMITED
default value for
_maxNoOfTasksPerHost. |
| Constructor and Description |
|---|
TaskStorageZk() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
activate(ComponentContext context) |
void |
checkQualifierLockAge(long timeToLiveMs)
check age of qualifier locks.
|
void |
clear()
remove all tasks from storage and reset all counters.
|
void |
createTaskQueue(java.lang.String name) |
protected void |
deactivate(ComponentContext context) |
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.
|
protected java.util.Collection<ZkTaskQueue> |
getTaskQueues()
get task queues as unmodifyable collection.
|
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 |
setClusterConfigService(ClusterConfigService ccs)
set new ClusterConfigService.
|
void |
setMaxNoOfTasksPerHost(long maxTasks)
set the maximum number of tasks that should be delivered to a host.
|
void |
setZooKeeperService(ZooKeeperService zooKeeperService) |
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.
|
void |
unsetClusterConfigService(ClusterConfigService ccs)
remove an ClusterConfigService.
|
void |
unsetZooKeeperService(ZooKeeperService zooKeeperService) |
public static final java.lang.String HOST_COUNTER_MAP_ZK_PATH
public static final java.lang.String QUALIFIER_LOCKS_ZK_PATH
public static final long TASKSPERHOST_UNLIMITED
_maxNoOfTasksPerHost.protected void activate(ComponentContext context)
context - OSGi service component context.protected void deactivate(ComponentContext context)
context - OSGi service component context.public void createTaskQueue(java.lang.String name)
createTaskQueue in interface TaskStoragename - the name of the task queue to create.public boolean hasTaskQueue(java.lang.String name)
hasTaskQueue in interface TaskStoragename - the task queue name to checkprotected java.util.Collection<ZkTaskQueue> getTaskQueues()
public long getMaxNoOfTasksPerHost()
getMaxNoOfTasksPerHost in interface TaskStoragepublic void setMaxNoOfTasksPerHost(long maxTasks)
setMaxNoOfTasksPerHost in interface TaskStoragemaxTasks - maximum number of tasks that should be delivered to a host. (scale up control)public java.util.Map<java.lang.String,java.lang.Integer> getScaleUpCounters()
throws TaskmanagerException
getScaleUpCounters in interface TaskStorageTaskmanagerException - on error.public void storeInProgressTask(Task task) throws TaskmanagerException
storeInProgressTask in interface TaskStoragetask - the task to store, contains the worker nameTaskmanagerException - if send failspublic void storeTask(Task task) throws TaskmanagerException
storeTask in interface TaskStoragetask - the task to store, contains the worker nameTaskmanagerException - if send failspublic void storeTask(java.lang.String workerName,
Task task)
throws TaskmanagerException
storeTask in interface TaskStorageworkerName - the worker for which to store the task.task - the task to store.TaskmanagerException - if send failspublic Task getTask(java.lang.String workerName, java.lang.String workerHost, java.util.Collection<java.lang.String> qualifiers) throws TaskmanagerException
getTask in interface TaskStorageworkerName - the workerName where to get the task from.workerHost - the host name where the worker is running that requested the taskqualifiers - if not null, allowed qualifiers of returned task.null if there is none
available.TaskmanagerException - if receive failspublic Task getInProgressTask(java.lang.String workerName, java.lang.String taskId) throws TaskmanagerException
getInProgressTask in interface TaskStorageworkerName - name of workertaskId - task IdTaskmanagerException - if task is not in-progress or other errors.public void deleteTask(java.lang.String workerName,
java.lang.String taskId)
throws TaskmanagerException
deleteTask in interface TaskStorageworkerName - the workerName from where the task was originally get.taskId - the task identifier.TaskmanagerException - if taskId is invalid or not marked as finishingpublic void keepAlive(java.lang.String workerName,
java.lang.String taskId)
throws TaskmanagerException
keepAlive in interface TaskStorageworkerName - name/id as stringtaskId - task id that is currently processed as stringTaskmanagerException - if any error occurspublic void purge(java.lang.String workerName)
throws TaskmanagerException
purge in interface TaskStorageworkerName - name/id as stringTaskmanagerException - if any error occurspublic void lockQualifiers(java.lang.String workerName,
java.util.Collection<java.lang.String> qualifiers)
TaskStoragelockQualifiers in interface TaskStorageworkerName - a worker's namequalifiers - a list of qualifiers to lockpublic boolean isLockedQualifier(java.lang.String workerName,
java.lang.String qualifier)
throws TaskmanagerException
isLockedQualifier in interface TaskStorageTaskmanagerExceptionpublic void checkQualifierLockAge(long timeToLiveMs)
timeToLiveMs - public java.util.Map<java.lang.String,TaskCounter> getTaskCounters() throws TaskmanagerException
getTaskCounters in interface TaskStorageTaskmanagerException - counting failspublic TaskList getTaskList(java.lang.String workerName, java.lang.String section, int maxCount) throws TaskmanagerException
getTaskList in interface TaskStorageworkerName - 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 TaskStorageworkerName - pipe in which the task is storedsection - queue section ("todo" or "inprogress")taskName - task identifierTaskmanagerException - on errorpublic long getFailSafetyLevel()
getFailSafetyLevel in interface TaskStoragepublic void clear()
throws TaskmanagerException
clear in interface TaskStorageTaskmanagerException - errorpublic void setZooKeeperService(ZooKeeperService zooKeeperService)
zooKeeperService - referenced servicepublic void unsetZooKeeperService(ZooKeeperService zooKeeperService)
zooKeeperService - referenced servicepublic void setClusterConfigService(ClusterConfigService ccs)
ccs - new ClusterConfigServicepublic void unsetClusterConfigService(ClusterConfigService ccs)
ccs - new ClusterConfigServicepublic void removeTasks(AnyMap filterMap) throws TaskmanagerException
removeTasks in interface TaskStoragefilterMap - map to identify tasks to be removedTaskmanagerException - an exception if something went wrong