Package com.groiss.wf.batch
Class BatchManager
java.lang.Object
com.groiss.wf.batch.BatchManager
- All Implemented Interfaces:
TimerTask
Starts and Completes BatchJobs. Provides methods for changing batch jobs.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic BatchJob
completeJob
(BatchJob bj) Complete a started BatchJob.static BatchJob
completeJob
(BatchJob bj, int resultCode) Complete a started BatchJob.static BatchJob
completeJob
(BatchJob bj, int resultCode, String resultvalues) Complete a started BatchJob.static void
Deprecated, for removal: This API element is subject to removal in a future version.static BatchJob
Gets a current copy (a fresh incarnation) of the batch job from the database.static BatchJob
static BatchJob
markJobError
(BatchJob bj, int resultCode, String resultValue, Exception ex) Mark a BatchJob as erroneous.static BatchJob
markJobError
(BatchJob bj, Exception ex) Mark a BatchJob as erroneous.static BatchJob
Mark a a started BatchJob as finished.static BatchJob
markJobFinished
(BatchJob bj, int resultCode) Mark a started BatchJob as finished.static BatchJob
markJobFinished
(BatchJob bj, int resultCode, String resultvalues) Mark a started BatchJob as finished.static BatchJob
markJobPoll
(BatchJob bj, int resultCode, String resultValue, Throwable ex) Mark a started BatchJob as pollable.static BatchJob
markJobPoll
(BatchJob bj, Throwable ex) Mark a started BatchJob as pollable.static BatchJob
markJobRetry
(BatchJob bj, int resultCode, String resultValue, Throwable ex) Mark a created BatchJob as 'startretry'.static BatchJob
markJobRetry
(BatchJob bj, Throwable ex) Mark a created BatchJob as 'startretry'.static BatchJob
markJobSuspendPoll
(BatchJob bj, int resultCode, String resultValue, Throwable ex) Mark a created BatchJob as suspended from further poll attempts.static BatchJob
markJobSuspendPoll
(BatchJob bj, Throwable ex) Mark a created BatchJob as suspended from further poll attempts.static BatchJob
markJobSuspendRetry
(BatchJob bj, int resultCode, String resultValue, Exception ex) Mark a created BatchJob as suspended from further start attempts.static BatchJob
markJobSuspendRetry
(BatchJob bj, Exception ex) Mark a created BatchJob as suspended from further start attempts.void
run
(TimerEntry te, String args) the TimerTask interface
-
Field Details
-
ERROR_ON_COMPLETE
- See Also:
-
-
Constructor Details
-
BatchManager
public BatchManager()
-
-
Method Details
-
run
the TimerTask interface -
markJobRetry
Mark a created BatchJob as 'startretry'. Typically used in doStart() of the BatchAdapter, if the batch job has not (yet) been marked as 'startretry' and such a retry is desired.
Runs in the same transaction as the caller. The exception does not have any special semantics for the system, it will be used to get a resultCode and a resultValue, if the BatchAdapter overridesBatchAdapter.getErrorCode(BatchJob, Throwable)
.
The BatchManager (or the assigned executor) will try to start the job on its next run.- Parameters:
bj
- the BatchJob to mark- Returns:
- the changed BatchJob
-
markJobRetry
Mark a created BatchJob as 'startretry'. Typically used in doStart() of the BatchAdapter, if the batch job has not (yet) been marked as 'startretry' and such a retry is desired.
Runs in the same transaction as the caller. The exception does not have any special semantics. Resultcode and resultvalue do not have any special semantics for the system.
The BatchManager (or the assigned executor) will try to start the job on its next run.- Parameters:
bj
- the BatchJob to markresultCode
- the result code to set on the batchjobresultValue
- the result value to set on the batchJob- Returns:
- the changed BatchJob
-
markJobError
Mark a BatchJob as erroneous. Typically used in doStart() or doPoll(), to avoid further start attempts or polling attempts. The batch job will be placed in stateBatchJob.STARTERROR
orBatchJob.FINISHERROR
.
Runs in the same transaction as the caller. The exception does not have any special semantics, it will be used to get a resultCode and a resultValue, if the BatchAdapter overridesBatchAdapter.getErrorCode(BatchJob, Throwable)
.- Parameters:
bj
- the BatchJob to mark- Returns:
- the changed BatchJob
-
markJobError
Mark a BatchJob as erroneous. Typically used in doStart() or doPoll(), to avoid further start attempts or polling attempts. The batch job will be placed in stateBatchJob.STARTERROR
orBatchJob.FINISHERROR
.
Runs in the same transaction as the caller. The exception does not have any special semantics, it will be used to get a resultCode and a resultValue, if the BatchAdapter overridesBatchAdapter.getErrorCode(BatchJob, Throwable)
.- Parameters:
bj
- the BatchJob to markresultCode
- the result code to set on the batchjobresultValue
- the result value to set on the batchJob- Returns:
- the changed BatchJob
-
markJobSuspendRetry
Mark a created BatchJob as suspended from further start attempts. Typically used in doStart() of the BatchAdapter, if the batch job has been marked as 'startretry' and such a retry is not desired anymore.
Runs in the same transaction as the caller. The exception does not have any special semantics, it will be used to get a resultCode and a resultValue, if the BatchAdapter overridesBatchAdapter.getErrorCode(BatchJob, Throwable)
.
The batch job will be in stateBatchJob.CREATED
afterwards. The BatchManager (or the assigned executor) will not try to start the job in subsequent runs.
The start attempts can be resumed again by marking the batch job viamarkJobRetry(BatchJob, Throwable)
.- Parameters:
bj
- the BatchJob to mark- Returns:
- the changed BatchJob
-
markJobSuspendRetry
public static BatchJob markJobSuspendRetry(BatchJob bj, int resultCode, String resultValue, Exception ex) Mark a created BatchJob as suspended from further start attempts. Typically used in doStart() of the BatchAdapter, if the batch job has been marked as 'startretry' and such a retry is not desired anymore.
Runs in the same transaction as the caller. The exception does not have any special semantics. Resultcode and resultvalue do not have any special semantics for the system.
The batch job will be in stateBatchJob.CREATED
afterwards. The BatchManager (or the assigned executor) will not try to start the job in subsequent runs.
The start attempts can be resumed again by marking the batch job viamarkJobRetry(BatchJob, Throwable)
.- Parameters:
bj
- the BatchJob to markresultCode
- the result code to set on the batchjobresultValue
- the result value to set on the batchJob- Returns:
- the changed BatchJob
-
markJobSuspendPoll
Mark a created BatchJob as suspended from further poll attempts. Typically used in doPoll() of the BatchAdapter, if the batch job has been marked as 'pollfinish' and such a polling is not desired anymore.
Runs in the same transaction as the caller. The exception does not have any special semantics, it will be used to get a resultCode and a resultValue, if the BatchAdapter overridesBatchAdapter.getErrorCode(BatchJob, Throwable)
.
The batch job will be in stateBatchJob.STARTED
afterwards. The BatchManager (or the assigned executor) will not try to poll for job completion in subsequent runs.
The poll attempts can be resumed again by marking the batch job viamarkJobPoll(BatchJob, Throwable)
.- Parameters:
bj
- the BatchJob to mark- Returns:
- the changed BatchJob
-
markJobSuspendPoll
public static BatchJob markJobSuspendPoll(BatchJob bj, int resultCode, String resultValue, Throwable ex) Mark a created BatchJob as suspended from further poll attempts. Typically used in doPoll() of the BatchAdapter, if the batch job has been marked as 'pollfinish' and such a polling is not desired anymore.
Runs in the same transaction as the caller. The exception does not have any special semantics. Resultcode and resultvalue do not have any special semantics for the system.
The batch job will be in stateBatchJob.STARTED
afterwards. The BatchManager (or the assigned executor) will not try to poll for job completion in subsequent runs.
The poll attempts can be resumed again by marking the batch job viamarkJobPoll(BatchJob, Throwable)
.- Parameters:
bj
- the BatchJob to markresultCode
- the result code to set on the batchjobresultValue
- the result value to set on the batchJob- Returns:
- the changed BatchJob
-
markJobPoll
Mark a started BatchJob as pollable. Typically used in doStart() of the BatchAdapter, if the batch job has been not been marked as 'pollfinish' and such a polling is desired.
Runs in the same transaction as the caller. The exception does not have any special semantics, it will be used to get a resultCode and a resultValue, if the BatchAdapter overridesBatchAdapter.getErrorCode(BatchJob, Throwable)
.
The BatchManager (or the assigned executor) will try to poll for job completion in subsequent runs.
The poll attempts can be suspended again by marking the batch job viamarkJobSuspendPoll(BatchJob, Throwable)
.- Parameters:
bj
- the BatchJob to mark- Returns:
- the changed BatchJob
-
markJobPoll
Mark a started BatchJob as pollable. Typically used in doStart() of the BatchAdapter, if the batch job has been not been marked as 'pollfinish' and such a polling is desired.
Runs in the same transaction as the caller. The exception does not have any special semantics. Resultcode and resultvalue do not have any special semantics for the system.
The BatchManager (or the assigned executor) will try to poll for job completion in subsequent runs.
The poll attempts can be suspended again by marking the batch job viamarkJobSuspendPoll(BatchJob, Throwable)
.- Parameters:
bj
- the BatchJob to markresultCode
- the result code to set on the batchjobresultValue
- the result value to set on the batchJob- Returns:
- the changed BatchJob
-
markJobFinished
Mark a a started BatchJob as finished. Typically used from an external execution context or from doPoll() in the BatchAdapter. Runs in the same transaction as the caller. Neither resultcode nor result have any special semantics for the BatchManager. Their meaning must be interpreted properly by the corresponding BatchAdapter.
The BatchManager will complete the job on its next run.- Parameters:
bj
- the BatchJob to mark- Returns:
- the changed BatchJob
- Throws:
Exception
- when the BatchJob is not in stateBatchJob.STARTED
.
-
markJobFinished
Mark a started BatchJob as finished. Typically used from an external execution context or from doPoll() in the BatchAdapter. Runs in the same transaction as the caller. Neither resultcode nor result have any special semantics for the BatchManager. Their meaning must be interpreted properly by the corresponding BatchAdapter.
The BatchManager will complete the job on its next run.- Parameters:
bj
- the BatchJob to markresultCode
- an int to indicate a result condition- Returns:
- the changed BatchJob
throws Exception when the BatchJob is not in state
BatchJob.STARTED
. - Throws:
Exception
-
markJobFinished
public static BatchJob markJobFinished(BatchJob bj, int resultCode, String resultvalues) throws Exception Mark a started BatchJob as finished. Typically used from an external execution context or from doPoll() in the BatchAdapter. Runs in the same transaction as the caller. Neither resultcode nor result have any special semantics for the BatchManager. Their meaning must be interpreted properly by the corresponding BatchAdapter.
The BatchManager will complete the job on its next run.- Parameters:
bj
- the BatchJob to markresultCode
- an int to indicate a result conditionresultvalues
- a String to transport some results- Returns:
- the changed BatchJob
- Throws:
Exception
- when the BatchJob is not in stateBatchJob.STARTED
.
-
markJobAborted
-
exceptionHandlingFinished
Deprecated, for removal: This API element is subject to removal in a future version.Called when a process exception path is finished. For internal use only. Needed for compatibility reasons. -
completeJob
Complete a started BatchJob. Marks the Job as finished and then completes the Job. Also finishes the originating StepInstance.
Can be used to avoid the delay between marking a job as finished and the next run of the BatchManager. IssuesBeanManager.commit()
orBeanManager.rollback()
.
During completion,BatchAdapter.beforeCompletion(BatchJob)
andBatchAdapter.afterCompletion(BatchJob, boolean)
will be called. After completeJob,BatchJob.getJobstate()
can be used to inquire about the outcome of the operation.- Parameters:
bj
- the BatchJob to complete.- Returns:
- the changed BatchJob
- Throws:
Exception
- when the BatchJob is not in stateBatchJob.STARTED
.
-
completeJob
Complete a started BatchJob. Marks the Job as finished and then completes the Job. Also finishes the originating StepInstance.
Can be used to avoid the delay between marking a job as finished and the next run of the BatchManager. IssuesBeanManager.commit()
orBeanManager.rollback()
.
During completion,BatchAdapter.beforeCompletion(BatchJob)
andBatchAdapter.afterCompletion(BatchJob, boolean)
will be called. After completeJob,BatchJob.getJobstate()
can be used to inquire about the outcome of the operation.- Parameters:
bj
- the BatchJob to complete.resultCode
- an int to indicate a result condition- Returns:
- the changed BatchJob
- Throws:
Exception
- when the BatchJob is not in stateBatchJob.STARTED
.
-
completeJob
public static BatchJob completeJob(BatchJob bj, int resultCode, String resultvalues) throws Exception Complete a started BatchJob. Marks the Job as finished and then completes the Job. Also finishes the originating StepInstance.
Can be used to avoid the delay between marking a job as finished and the next run of the BatchManager. IssuesBeanManager.commit()
orBeanManager.rollback()
.
During completion,BatchAdapter.beforeCompletion(BatchJob)
andBatchAdapter.afterCompletion(BatchJob, boolean)
will be called. After completeJob,BatchJob.getJobstate()
can be used to inquire about the outcome of the operation.- Parameters:
bj
- the BatchJob to complete.resultCode
- an int to indicate a result conditionresultvalues
- a String to transport some results- Returns:
- the changed BatchJob
- Throws:
Exception
- when the BatchJob is not in stateBatchJob.STARTED
.
-
getFreshBatchJob
Gets a current copy (a fresh incarnation) of the batch job from the database.Can be used to get the (possibly concurrently modified) current instance of the batch job.
- Parameters:
bj
- the batch job to get a fresh copy of- Returns:
- the current copy of the batch job
-