Class DefaultJobManager
- java.lang.Object
-
- org.activiti.engine.impl.asyncexecutor.DefaultJobManager
-
- All Implemented Interfaces:
JobManager
public class DefaultJobManager extends java.lang.Object implements JobManager
-
-
Field Summary
Fields Modifier and Type Field Description protected ProcessEngineConfigurationImplprocessEngineConfiguration
-
Constructor Summary
Constructors Constructor Description DefaultJobManager()DefaultJobManager(ProcessEngineConfigurationImpl processEngineConfiguration)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AbstractJobEntityactivateSuspendedJob(SuspendedJobEntity job)Transforms aSuspendedJobEntityback to anAbstractJobEntity(i.e.protected intcalculateMaxIterationsValue(java.lang.String originalExpression)protected AbstractJobEntitycopyJobInfo(AbstractJobEntity copyToJob, AbstractJobEntity copyFromJob)JobEntitycreateAsyncJob(ExecutionEntity execution, boolean exclusive)Creates an async job for the providedExecutionEntity, so that it can be continued later in a background thread.protected DeadLetterJobEntitycreateDeadLetterJobFromOtherJob(AbstractJobEntity otherJob)protected JobEntitycreateExecutableJobFromOtherJob(AbstractJobEntity job)protected SuspendedJobEntitycreateSuspendedJobFromOtherJob(AbstractJobEntity otherJob)TimerJobEntitycreateTimerJob(org.activiti.bpmn.model.TimerEventDefinition timerEventDefinition, boolean interrupting, ExecutionEntity execution, java.lang.String timerEventType, java.lang.String jobHandlerConfiguration)Creates aTimerJobEntitybased on the currentExecutionEntityand the configuration in theTimerEventDefinition.protected TimerJobEntitycreateTimerJobFromOtherJob(AbstractJobEntity otherJob)voidexecute(Job job)Execute a job, which means that the logic (async logic, timer that fires, etc) is executed, typically by a background thread of an executor.protected voidexecuteJobHandler(JobEntity jobEntity)protected voidexecuteMessageJob(JobEntity jobEntity)protected voidexecuteTimerJob(JobEntity timerEntity)protected voidfillDefaultAsyncJobInfo(JobEntity jobEntity, ExecutionEntity execution, boolean exclusive)protected AsyncExecutorgetAsyncExecutor()protected java.lang.StringgetBusinessCalendarName(java.lang.String calendarName, VariableScope variableScope)protected CommandContextgetCommandContext()protected ExecutionEntityManagergetExecutionEntityManager()protected intgetMaxIterations(org.activiti.bpmn.model.Process process, java.lang.String activityId)ProcessEngineConfigurationImplgetProcessEngineConfiguration()protected voidhintAsyncExecutor(JobEntity job)protected JobEntityinternalCreateAsyncJob(ExecutionEntity execution, boolean exclusive)protected JobEntityinternalCreateLockedAsyncJob(ExecutionEntity execution, boolean exclusive)protected booleanisAsyncExecutorActive()protected booleanisValidTime(JobEntity timerEntity, java.util.Date newTimerDate, VariableScope variableScope)JobEntitymoveDeadLetterJobToExecutableJob(DeadLetterJobEntity deadLetterJobEntity, int retries)Transforms aDeadLetterJobEntityto aJobEntity, thus making it executable again.DeadLetterJobEntitymoveJobToDeadLetterJob(AbstractJobEntity job)Transforms anAbstractJobEntityto aDeadLetterJobEntity.SuspendedJobEntitymoveJobToSuspendedJob(AbstractJobEntity job)Moves anAbstractJobEntityto become aSuspendedJobEntity, such that theAsyncExecutorwon't pick it up anymore for execution.TimerJobEntitymoveJobToTimerJob(AbstractJobEntity job)Moves anAbstractJobEntityto become aTimerJobEntity.JobEntitymoveTimerJobToExecutableJob(TimerJobEntity timerJob)Moves aTimerJobEntityto become an asyncJobEntity.protected voidrestoreExtraData(JobEntity timerEntity, VariableScope variableScope)voidscheduleAsyncJob(JobEntity jobEntity)Schedules and async job.voidscheduleTimerJob(TimerJobEntity timerJob)Schedules a timer, meaning it will be inserted in the datastore.voidsetProcessEngineConfiguration(ProcessEngineConfigurationImpl processEngineConfiguration)The ProcessEngineCongiguration instance will be passed when theProcessEngineis built.protected voidtriggerExecutorIfNeeded(JobEntity jobEntity)voidunacquire(Job job)Unacquires a job, meaning that this job was previously locked, and it is now freed to be acquired by other executor nodes.
-
-
-
Field Detail
-
processEngineConfiguration
protected ProcessEngineConfigurationImpl processEngineConfiguration
-
-
Constructor Detail
-
DefaultJobManager
public DefaultJobManager()
-
DefaultJobManager
public DefaultJobManager(ProcessEngineConfigurationImpl processEngineConfiguration)
-
-
Method Detail
-
createAsyncJob
public JobEntity createAsyncJob(ExecutionEntity execution, boolean exclusive)
Description copied from interface:JobManagerCreates an async job for the providedExecutionEntity, so that it can be continued later in a background thread.- Specified by:
createAsyncJobin interfaceJobManager
-
scheduleAsyncJob
public void scheduleAsyncJob(JobEntity jobEntity)
Description copied from interface:JobManagerSchedules and async job. If theAsyncExecutoris running, it can be executed immediately after the transaction. Otherwise it can be picked up by other executors.- Specified by:
scheduleAsyncJobin interfaceJobManager
-
triggerExecutorIfNeeded
protected void triggerExecutorIfNeeded(JobEntity jobEntity)
-
createTimerJob
public TimerJobEntity createTimerJob(org.activiti.bpmn.model.TimerEventDefinition timerEventDefinition, boolean interrupting, ExecutionEntity execution, java.lang.String timerEventType, java.lang.String jobHandlerConfiguration)
Description copied from interface:JobManagerCreates aTimerJobEntitybased on the currentExecutionEntityand the configuration in theTimerEventDefinition.- Specified by:
createTimerJobin interfaceJobManager
-
scheduleTimerJob
public void scheduleTimerJob(TimerJobEntity timerJob)
Description copied from interface:JobManagerSchedules a timer, meaning it will be inserted in the datastore.- Specified by:
scheduleTimerJobin interfaceJobManager
-
moveTimerJobToExecutableJob
public JobEntity moveTimerJobToExecutableJob(TimerJobEntity timerJob)
Description copied from interface:JobManagerMoves aTimerJobEntityto become an asyncJobEntity. This happens for example when the due date of a timer is reached, the timer entity then becomes a 'regular' async job that can be picked up by theAsyncExecutor.- Specified by:
moveTimerJobToExecutableJobin interfaceJobManager
-
moveJobToTimerJob
public TimerJobEntity moveJobToTimerJob(AbstractJobEntity job)
Description copied from interface:JobManagerMoves anAbstractJobEntityto become aTimerJobEntity. This happens for example when an async job is executed and fails. It then becomes a timer, as it needs to be retried later.- Specified by:
moveJobToTimerJobin interfaceJobManager
-
moveJobToSuspendedJob
public SuspendedJobEntity moveJobToSuspendedJob(AbstractJobEntity job)
Description copied from interface:JobManagerMoves anAbstractJobEntityto become aSuspendedJobEntity, such that theAsyncExecutorwon't pick it up anymore for execution.- Specified by:
moveJobToSuspendedJobin interfaceJobManager
-
activateSuspendedJob
public AbstractJobEntity activateSuspendedJob(SuspendedJobEntity job)
Description copied from interface:JobManagerTransforms aSuspendedJobEntityback to anAbstractJobEntity(i.e. to what it was originally). The job will now again be able to picked up by theAsyncExecutor.- Specified by:
activateSuspendedJobin interfaceJobManager
-
moveJobToDeadLetterJob
public DeadLetterJobEntity moveJobToDeadLetterJob(AbstractJobEntity job)
Description copied from interface:JobManagerTransforms anAbstractJobEntityto aDeadLetterJobEntity. This means that the job has been tried a configurable amount of times, but kept failing.- Specified by:
moveJobToDeadLetterJobin interfaceJobManager
-
moveDeadLetterJobToExecutableJob
public JobEntity moveDeadLetterJobToExecutableJob(DeadLetterJobEntity deadLetterJobEntity, int retries)
Description copied from interface:JobManagerTransforms aDeadLetterJobEntityto aJobEntity, thus making it executable again. Note that a 'retries' parameter needs to be passed, as the job got into the deadletter table because of it failed and retries became 0.- Specified by:
moveDeadLetterJobToExecutableJobin interfaceJobManager
-
execute
public void execute(Job job)
Description copied from interface:JobManagerExecute a job, which means that the logic (async logic, timer that fires, etc) is executed, typically by a background thread of an executor.- Specified by:
executein interfaceJobManager
-
unacquire
public void unacquire(Job job)
Description copied from interface:JobManagerUnacquires a job, meaning that this job was previously locked, and it is now freed to be acquired by other executor nodes.- Specified by:
unacquirein interfaceJobManager
-
executeMessageJob
protected void executeMessageJob(JobEntity jobEntity)
-
executeTimerJob
protected void executeTimerJob(JobEntity timerEntity)
-
executeJobHandler
protected void executeJobHandler(JobEntity jobEntity)
-
restoreExtraData
protected void restoreExtraData(JobEntity timerEntity, VariableScope variableScope)
-
getMaxIterations
protected int getMaxIterations(org.activiti.bpmn.model.Process process, java.lang.String activityId)
-
calculateMaxIterationsValue
protected int calculateMaxIterationsValue(java.lang.String originalExpression)
-
isValidTime
protected boolean isValidTime(JobEntity timerEntity, java.util.Date newTimerDate, VariableScope variableScope)
-
getBusinessCalendarName
protected java.lang.String getBusinessCalendarName(java.lang.String calendarName, VariableScope variableScope)
-
hintAsyncExecutor
protected void hintAsyncExecutor(JobEntity job)
-
internalCreateAsyncJob
protected JobEntity internalCreateAsyncJob(ExecutionEntity execution, boolean exclusive)
-
internalCreateLockedAsyncJob
protected JobEntity internalCreateLockedAsyncJob(ExecutionEntity execution, boolean exclusive)
-
fillDefaultAsyncJobInfo
protected void fillDefaultAsyncJobInfo(JobEntity jobEntity, ExecutionEntity execution, boolean exclusive)
-
createExecutableJobFromOtherJob
protected JobEntity createExecutableJobFromOtherJob(AbstractJobEntity job)
-
createTimerJobFromOtherJob
protected TimerJobEntity createTimerJobFromOtherJob(AbstractJobEntity otherJob)
-
createSuspendedJobFromOtherJob
protected SuspendedJobEntity createSuspendedJobFromOtherJob(AbstractJobEntity otherJob)
-
createDeadLetterJobFromOtherJob
protected DeadLetterJobEntity createDeadLetterJobFromOtherJob(AbstractJobEntity otherJob)
-
copyJobInfo
protected AbstractJobEntity copyJobInfo(AbstractJobEntity copyToJob, AbstractJobEntity copyFromJob)
-
getProcessEngineConfiguration
public ProcessEngineConfigurationImpl getProcessEngineConfiguration()
-
setProcessEngineConfiguration
public void setProcessEngineConfiguration(ProcessEngineConfigurationImpl processEngineConfiguration)
Description copied from interface:JobManagerThe ProcessEngineCongiguration instance will be passed when theProcessEngineis built.- Specified by:
setProcessEngineConfigurationin interfaceJobManager
-
isAsyncExecutorActive
protected boolean isAsyncExecutorActive()
-
getCommandContext
protected CommandContext getCommandContext()
-
getAsyncExecutor
protected AsyncExecutor getAsyncExecutor()
-
getExecutionEntityManager
protected ExecutionEntityManager getExecutionEntityManager()
-
-