Class ClusteredTaskManager
- java.lang.Object
-
- org.wso2.carbon.ntask.core.impl.AbstractQuartzTaskManager
-
- org.wso2.carbon.ntask.core.impl.clustered.ClusteredTaskManager
-
- All Implemented Interfaces:
TaskManager
public class ClusteredTaskManager extends AbstractQuartzTaskManager
This class represents a clustered task manager, which is used when tasks are distributed across a cluster.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.wso2.carbon.ntask.core.impl.AbstractQuartzTaskManager
AbstractQuartzTaskManager.TaskTriggerListener
-
Nested classes/interfaces inherited from interface org.wso2.carbon.ntask.core.TaskManager
TaskManager.TaskState
-
-
Constructor Summary
Constructors Constructor Description ClusteredTaskManager(TaskRepository taskRepository)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
deleteLocalTasks()
boolean
deleteTask(String taskName)
Stops and deletes a task with the given name.boolean
deleteTask(String memberId, String taskName)
boolean
finalDeleteTask(String taskName)
void
finalPauseTask(String taskName)
void
finalRescheduleTask(String taskName)
void
finalResumeTask(String taskName)
void
finalScheduleTask(String taskName)
List<TaskInfo>
getAllRunningTasksInOtherMembers(String memberId)
Gets all the tasks running on the other task server members of the clusterList<List<TaskInfo>>
getAllRunningTasksInServers()
List<TaskInfo>
getAllTasks()
Get all task information.Map<String,TaskManager.TaskState>
getAllTaskStates()
ClusterGroupCommunicator
getClusterComm()
List<TaskInfo>
getFinalRunningTasksInServer()
TaskManager.TaskState
getFinalTaskState(String taskName)
String
getMemberId()
String
getMemberIdFromTaskName(String taskName, boolean createIfNotExists)
List<String>
getMemberIds()
List<TaskInfo>
getRunningTasksInServer(String memberId)
int
getServerCount()
TaskInfo
getTask(String taskName)
Get task information.TaskManager.TaskState
getTaskState(String taskName)
Gets tasks state informationTaskManager.TaskState
getTaskState(String memberId, String taskName)
String
getTaskType()
int
getTenantId()
void
initStartupTasks()
Initialize the startup tasks.boolean
isLeader()
boolean
isTaskScheduled(String taskName)
Checks if the given task is already scheduled.void
pauseTask(String taskName)
Pauses a task with the given name.void
pauseTask(String memberId, String taskName)
void
registerTask(TaskInfo taskInfo)
Registers a new task or updates if one already exists.void
rescheduleTask(String taskName)
Reschedules a task with the given name, only the trigger information will be updated in the reschedule.void
rescheduleTask(String memberId, String taskName)
void
resumeTask(String taskName)
Resumes a paused task with the given name.void
resumeTask(String memberId, String taskName)
void
scheduleMissingTasks()
void
scheduleMissingTasks(String memberId)
Schedules tasks for the given member idvoid
scheduleTask(String taskName)
Starts a task with the given name.void
scheduleTask(String memberId, String taskName)
<V> V
sendReceive(String memberId, TaskCall<V> taskCall)
-
Methods inherited from class org.wso2.carbon.ntask.core.impl.AbstractQuartzTaskManager
deleteLocalTask, getAllFinishedTasks, getAllLocalRunningTasks, getAllLocalTaskStates, getLocalTaskState, getScheduler, getTaskRepository, isLocalTaskScheduled, pauseLocalTask, registerLocalTask, registerLocalTaskActionListener, rescheduleLocalTask, resumeLocalTask, scheduleAllTasks, scheduleLocalTask, scheduleLocalTask
-
-
-
-
Constructor Detail
-
ClusteredTaskManager
public ClusteredTaskManager(TaskRepository taskRepository) throws org.wso2.carbon.ntask.common.TaskException
- Throws:
org.wso2.carbon.ntask.common.TaskException
-
-
Method Detail
-
getTenantId
public int getTenantId()
- Overrides:
getTenantId
in classAbstractQuartzTaskManager
-
getTaskType
public String getTaskType()
- Overrides:
getTaskType
in classAbstractQuartzTaskManager
-
getClusterComm
public ClusterGroupCommunicator getClusterComm() throws org.wso2.carbon.ntask.common.TaskException
- Throws:
org.wso2.carbon.ntask.common.TaskException
-
initStartupTasks
public void initStartupTasks() throws org.wso2.carbon.ntask.common.TaskException
Description copied from interface:TaskManager
Initialize the startup tasks.- Throws:
org.wso2.carbon.ntask.common.TaskException
-
scheduleMissingTasks
public void scheduleMissingTasks() throws org.wso2.carbon.ntask.common.TaskException
- Throws:
org.wso2.carbon.ntask.common.TaskException
-
scheduleMissingTasks
public void scheduleMissingTasks(String memberId) throws org.wso2.carbon.ntask.common.TaskException
Schedules tasks for the given member id- Parameters:
memberId
- cluster member identifier- Throws:
org.wso2.carbon.ntask.common.TaskException
-
scheduleTask
public void scheduleTask(String taskName) throws org.wso2.carbon.ntask.common.TaskException
Description copied from interface:TaskManager
Starts a task with the given name.- Parameters:
taskName
- The name of the task- Throws:
org.wso2.carbon.ntask.common.TaskException
-
rescheduleTask
public void rescheduleTask(String taskName) throws org.wso2.carbon.ntask.common.TaskException
Description copied from interface:TaskManager
Reschedules a task with the given name, only the trigger information will be updated in the reschedule.- Parameters:
taskName
- The task to be rescheduled- Throws:
org.wso2.carbon.ntask.common.TaskException
-
getAllTaskStates
public Map<String,TaskManager.TaskState> getAllTaskStates() throws org.wso2.carbon.ntask.common.TaskException
- Throws:
org.wso2.carbon.ntask.common.TaskException
-
getTaskState
public TaskManager.TaskState getTaskState(String taskName) throws org.wso2.carbon.ntask.common.TaskException
Description copied from interface:TaskManager
Gets tasks state information- Parameters:
taskName
- The name of the task- Returns:
- State of the task
- Throws:
org.wso2.carbon.ntask.common.TaskException
-
deleteTask
public boolean deleteTask(String taskName) throws org.wso2.carbon.ntask.common.TaskException
Description copied from interface:TaskManager
Stops and deletes a task with the given name.- Parameters:
taskName
- The name of the task- Returns:
- true if the task was found and deleted
- Throws:
org.wso2.carbon.ntask.common.TaskException
-
pauseTask
public void pauseTask(String taskName) throws org.wso2.carbon.ntask.common.TaskException
Description copied from interface:TaskManager
Pauses a task with the given name.- Parameters:
taskName
- The name of the task- Throws:
org.wso2.carbon.ntask.common.TaskException
-
resumeTask
public void resumeTask(String taskName) throws org.wso2.carbon.ntask.common.TaskException
Description copied from interface:TaskManager
Resumes a paused task with the given name.- Parameters:
taskName
- The name of the task- Throws:
org.wso2.carbon.ntask.common.TaskException
-
registerTask
public void registerTask(TaskInfo taskInfo) throws org.wso2.carbon.ntask.common.TaskException
Description copied from interface:TaskManager
Registers a new task or updates if one already exists.- Parameters:
taskInfo
- The task information- Throws:
org.wso2.carbon.ntask.common.TaskException
-
getTask
public TaskInfo getTask(String taskName) throws org.wso2.carbon.ntask.common.TaskException
Description copied from interface:TaskManager
Get task information.- Parameters:
taskName
- The name of the task- Returns:
- The task information
- Throws:
org.wso2.carbon.ntask.common.TaskException
- if the task cannot be found
-
getAllTasks
public List<TaskInfo> getAllTasks() throws org.wso2.carbon.ntask.common.TaskException
Description copied from interface:TaskManager
Get all task information.- Returns:
- Task information list
- Throws:
org.wso2.carbon.ntask.common.TaskException
-
getServerCount
public int getServerCount() throws org.wso2.carbon.ntask.common.TaskException
- Throws:
org.wso2.carbon.ntask.common.TaskException
-
getAllRunningTasksInOtherMembers
public List<TaskInfo> getAllRunningTasksInOtherMembers(String memberId) throws org.wso2.carbon.ntask.common.TaskException
Gets all the tasks running on the other task server members of the cluster- Parameters:
memberId
- cluster member identifier- Returns:
- task list of the running tasks
- Throws:
org.wso2.carbon.ntask.common.TaskException
-
getAllRunningTasksInServers
public List<List<TaskInfo>> getAllRunningTasksInServers() throws org.wso2.carbon.ntask.common.TaskException
- Throws:
org.wso2.carbon.ntask.common.TaskException
-
isTaskScheduled
public boolean isTaskScheduled(String taskName) throws org.wso2.carbon.ntask.common.TaskException
Description copied from interface:TaskManager
Checks if the given task is already scheduled.- Parameters:
taskName
- The task name- Returns:
- true if already scheduled
- Throws:
org.wso2.carbon.ntask.common.TaskException
-
sendReceive
public <V> V sendReceive(String memberId, TaskCall<V> taskCall) throws org.wso2.carbon.ntask.common.TaskException
- Throws:
org.wso2.carbon.ntask.common.TaskException
-
getMemberIds
public List<String> getMemberIds() throws org.wso2.carbon.ntask.common.TaskException
- Throws:
org.wso2.carbon.ntask.common.TaskException
-
getMemberId
public String getMemberId() throws org.wso2.carbon.ntask.common.TaskException
- Throws:
org.wso2.carbon.ntask.common.TaskException
-
isLeader
public boolean isLeader() throws org.wso2.carbon.ntask.common.TaskException
- Throws:
org.wso2.carbon.ntask.common.TaskException
-
getMemberIdFromTaskName
public String getMemberIdFromTaskName(String taskName, boolean createIfNotExists) throws org.wso2.carbon.ntask.common.TaskException
- Throws:
org.wso2.carbon.ntask.common.TaskException
-
getRunningTasksInServer
public List<TaskInfo> getRunningTasksInServer(String memberId) throws org.wso2.carbon.ntask.common.TaskException
- Throws:
org.wso2.carbon.ntask.common.TaskException
-
getFinalRunningTasksInServer
public List<TaskInfo> getFinalRunningTasksInServer() throws Exception
- Throws:
Exception
-
getTaskState
public TaskManager.TaskState getTaskState(String memberId, String taskName) throws Exception
- Throws:
Exception
-
getFinalTaskState
public TaskManager.TaskState getFinalTaskState(String taskName) throws Exception
- Throws:
Exception
-
scheduleTask
public void scheduleTask(String memberId, String taskName) throws org.wso2.carbon.ntask.common.TaskException
- Throws:
org.wso2.carbon.ntask.common.TaskException
-
finalScheduleTask
public void finalScheduleTask(String taskName) throws Exception
- Throws:
Exception
-
rescheduleTask
public void rescheduleTask(String memberId, String taskName) throws org.wso2.carbon.ntask.common.TaskException
- Throws:
org.wso2.carbon.ntask.common.TaskException
-
finalRescheduleTask
public void finalRescheduleTask(String taskName) throws Exception
- Throws:
Exception
-
deleteTask
public boolean deleteTask(String memberId, String taskName) throws Exception
- Throws:
Exception
-
pauseTask
public void pauseTask(String memberId, String taskName) throws org.wso2.carbon.ntask.common.TaskException
- Throws:
org.wso2.carbon.ntask.common.TaskException
-
resumeTask
public void resumeTask(String memberId, String taskName) throws org.wso2.carbon.ntask.common.TaskException
- Throws:
org.wso2.carbon.ntask.common.TaskException
-
deleteLocalTasks
public void deleteLocalTasks() throws org.wso2.carbon.ntask.common.TaskException
- Overrides:
deleteLocalTasks
in classAbstractQuartzTaskManager
- Throws:
org.wso2.carbon.ntask.common.TaskException
-
-