@Component public class JobManager extends Object
| 构造器和说明 |
|---|
JobManager(SupervisorProperties conf,
cn.ponfee.disjob.common.base.IdGenerator idGenerator,
SchedJobMapper jobMapper,
SchedDependMapper dependMapper,
SchedInstanceMapper instanceMapper,
SchedWorkflowMapper workflowMapper,
SchedTaskMapper taskMapper,
WorkerClient workerClient,
org.springframework.transaction.support.TransactionTemplate txTemplate) |
| 限定符和类型 | 方法和说明 |
|---|---|
Long |
addJob(SchedJob job) |
boolean |
cancelInstance(long instanceId,
cn.ponfee.disjob.core.enums.Operation ops)
Cancel instance
|
void |
changeInstanceState(long instanceId,
cn.ponfee.disjob.core.enums.ExecuteState toExecuteState)
Force change instance state, for example: CANCELED -> WAITING
|
void |
changeJobState(String user,
long jobId,
cn.ponfee.disjob.core.enums.JobState toState) |
void |
deleteInstance(long instanceId) |
void |
deleteJob(String user,
long jobId) |
void |
disableJob(SchedJob job) |
boolean |
dispatch(SchedJob job,
SchedInstance instance,
List<SchedTask> tasks) |
long |
generateId() |
void |
manualTriggerJob(long jobId) |
boolean |
pauseInstance(long instanceId)
Pause instance
|
void |
processTaskDispatchFailedEvent(TaskDispatchFailedEvent event)
Listen task dispatch failed event
`@Async`需要标注`@EnableAsync`来启用,默认使用的是`SimpleAsyncTaskExecutor`线程池,会为每个任务创建一个新线程(慎用默认的线程池) |
boolean |
purgeInstance(SchedInstance inst)
Purge the zombie instance which maybe dead
|
boolean |
redispatch(SchedJob job,
SchedInstance instance,
List<SchedTask> tasks) |
boolean |
resumeInstance(long instanceId)
Resume the instance from paused to waiting state
|
void |
saveInstanceAndTasks(SchedInstance instance,
List<SchedTask> tasks) |
void |
saveLeadInstanceAndWorkflows(SchedInstance instance,
List<SchedWorkflow> workflows) |
boolean |
savepoint(long taskId,
String worker,
String executeSnapshot) |
void |
scheduleTriggerJob(SchedJob job,
long triggerTime) |
List<SchedTask> |
splitJob(String group,
long instanceId,
cn.ponfee.disjob.core.dto.worker.SplitJobParam param) |
cn.ponfee.disjob.core.dto.supervisor.StartTaskResult |
startTask(cn.ponfee.disjob.core.dto.supervisor.StartTaskParam param)
Starts the task
|
boolean |
stopTask(cn.ponfee.disjob.core.dto.supervisor.StopTaskParam param)
Stops the task
|
boolean |
updateInstanceNextScanTime(SchedInstance inst,
Date nextScanTime) |
void |
updateJob(SchedJob job) |
void |
updateJobNextScanTime(SchedJob job) |
boolean |
updateJobNextTriggerTime(SchedJob job) |
void |
updateTaskWorker(String worker,
List<Long> taskIds)
Set or clear task worker
|
public JobManager(SupervisorProperties conf, cn.ponfee.disjob.common.base.IdGenerator idGenerator, SchedJobMapper jobMapper, SchedDependMapper dependMapper, SchedInstanceMapper instanceMapper, SchedWorkflowMapper workflowMapper, SchedTaskMapper taskMapper, WorkerClient workerClient, @Qualifier(value="disjobTransactionTemplate") org.springframework.transaction.support.TransactionTemplate txTemplate)
public long generateId()
public List<SchedTask> splitJob(String group, long instanceId, cn.ponfee.disjob.core.dto.worker.SplitJobParam param) throws cn.ponfee.disjob.core.exception.JobException
cn.ponfee.disjob.core.exception.JobExceptionpublic boolean dispatch(SchedJob job, SchedInstance instance, List<SchedTask> tasks)
public boolean redispatch(SchedJob job, SchedInstance instance, List<SchedTask> tasks)
public void disableJob(SchedJob job)
public boolean updateJobNextTriggerTime(SchedJob job)
public void updateJobNextScanTime(SchedJob job)
public boolean updateInstanceNextScanTime(SchedInstance inst, Date nextScanTime)
public void saveLeadInstanceAndWorkflows(SchedInstance instance, List<SchedWorkflow> workflows)
public void saveInstanceAndTasks(SchedInstance instance, List<SchedTask> tasks)
@Transactional(transactionManager="disjobTransactionManager",
rollbackFor=java.lang.Exception.class)
public Long addJob(SchedJob job)
throws cn.ponfee.disjob.core.exception.JobException
cn.ponfee.disjob.core.exception.JobException@Transactional(transactionManager="disjobTransactionManager",
rollbackFor=java.lang.Exception.class)
public void updateJob(SchedJob job)
throws cn.ponfee.disjob.core.exception.JobException
cn.ponfee.disjob.core.exception.JobException@Transactional(transactionManager="disjobTransactionManager",
rollbackFor=java.lang.Exception.class)
public void deleteJob(String user,
long jobId)
@Transactional(transactionManager="disjobTransactionManager",
rollbackFor=java.lang.Exception.class)
public void changeJobState(String user,
long jobId,
cn.ponfee.disjob.core.enums.JobState toState)
@Transactional(transactionManager="disjobTransactionManager",
rollbackFor=java.lang.Exception.class)
public void manualTriggerJob(long jobId)
throws cn.ponfee.disjob.core.exception.JobException
cn.ponfee.disjob.core.exception.JobException@Transactional(transactionManager="disjobTransactionManager",
rollbackFor=java.lang.Exception.class)
public void scheduleTriggerJob(SchedJob job,
long triggerTime)
throws cn.ponfee.disjob.core.exception.JobException
cn.ponfee.disjob.core.exception.JobException@Transactional(transactionManager="disjobTransactionManager",
rollbackFor=java.lang.Exception.class)
public void updateTaskWorker(String worker,
List<Long> taskIds)
worker - the workertaskIds - the task id list@EventListener public void processTaskDispatchFailedEvent(TaskDispatchFailedEvent event)
`@Async`需要标注`@EnableAsync`来启用,默认使用的是`SimpleAsyncTaskExecutor`线程池,会为每个任务创建一个新线程(慎用默认的线程池)
event - the TaskDispatchFailedEventpublic cn.ponfee.disjob.core.dto.supervisor.StartTaskResult startTask(cn.ponfee.disjob.core.dto.supervisor.StartTaskParam param)
param - the start task parampublic boolean stopTask(cn.ponfee.disjob.core.dto.supervisor.StopTaskParam param)
param - the stop task paramtrue if stopped task successfulpublic void changeInstanceState(long instanceId,
cn.ponfee.disjob.core.enums.ExecuteState toExecuteState)
instanceId - the instance id, unsupported workflowtoExecuteState - the target execute statepublic void deleteInstance(long instanceId)
public boolean purgeInstance(SchedInstance inst)
inst - the sched instancetrue if purged successfullypublic boolean pauseInstance(long instanceId)
instanceId - the instance id, if workflow must be lead instance idtrue if paused successfullypublic boolean cancelInstance(long instanceId,
cn.ponfee.disjob.core.enums.Operation ops)
instanceId - the instance id, if workflow must be lead instance idops - the operationtrue if canceled successfullypublic boolean resumeInstance(long instanceId)
instanceId - the instance id, if workflow must be lead instance idtrue if resumed successfullyCopyright © 2025. All rights reserved.