Package com.groiss.wf.batch
Interface BatchJob
- All Superinterfaces:
KeyValuePair<String,
,String> Persistent
,Serializable
Captures state information about batch jobs.
Basically, each batch job is in one of four normal life cycle states or one of two error states.
First it is CREATED, then it is STARTED, then it is FINISHED and afterwards it is COMPLETED.
It may also be manually ABORTED.
The specific life cycle may be much more complex, according to behavioral modification flags and timer interaction.
Please note that setting properties of the BatchJob should be achieved via the mark* methods of BatchManager
.
When updates on a BatchJob instance via its setters need to be made, the following pattern is recommended in order to account for concurrent modifications by other threads:
doStart(BatchJob job) {
...
job = BatchManager.getFreshBatchJob(job);
job.setResultValues("my results");
store.update(job);
}
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
State for aborted instances.static final int
State for completed instances.static final int
error handling has been completedstatic final int
Initial state for the instance.static final int
State for finished instances.static final int
State for instances which could not be finished by the BatchManager or the corresponding executor.static final int
error handling for batchjobs which couln't be finished is currently activestatic final int
error handling is defined for this batchjob, but it did fail to startstatic final int
error handling for batchjobs which couldn't be finished will be started soonstatic final int
State for started instances.static final int
State for instances which could not be started.static final int
error handling for batchjobs which couln't be started is currently activestatic final int
error handling is defined for this batchjob, but it did fail to startstatic final int
error handling for batchjobs which couldn't be started will be started soonFields inherited from interface com.groiss.store.Persistent
emptyKeys
-
Method Summary
Modifier and TypeMethodDescriptionGet the time the instance was aborted.Get the time the instance was completed.The process context in which the instance was submitted.Get the time the instance was created.Get the executor of the instance.Get the time the instance was finished.int
The state of the instance.The jobtype of the instance.Get the time of the last start attempt.Get the parameters for the job execution.int
Gets the number of poll attempts to far.long
Gets the poll interval.int
Get the resultcode of the instance.Get the resultvalues of the instance.int
Gets the number of start attempts to far.long
Gets the start interval.Get the time the instance was started or is about to be started.default String
static String
getStateName
(int state) boolean
Determine whether the instance is to be finished automatically ('autofinish' in WDL).boolean
Determine whether an error during start or poll of the instance will force the engine to go back to the latest interactive step ('gobackonerror' in WDL).boolean
Determine whether the instance start and poll attempts are to be made in a new thread ('newthread' in WDL).boolean
Determine whether a job should be polled for being finished ('pollfinish' in WDL) by the BatchManager or a corresponding executor.boolean
Determines if the batch job is resumable.boolean
Determine whether erroneous starts will be retried later on ('retrystart' in WDL) by the BatchManager or a corresponding executor.boolean
Determine whether the instance is to be started immediately ('startnow' in WDL).boolean
Determine if the batch job is suspendable.void
setAutofinish
(boolean autofinish) Set the autofinish property of the instance.void
setExecutor
(String executor) Set the executor of the instance.void
setFinishtime
(Date finishtime) void
setGoBackOnError
(boolean gobackonerror) Set the gobackonerror property of the instance.void
setJobstate
(int state) Set the state of the job.void
setNewthread
(boolean newthread) Set the newthread property of the instance.void
Set the params field of the instance.void
setPollFinish
(boolean pollfinish) Set the pollfinish property of the instance.void
setPollInterval
(long pollinterval) Set the poll interval of an instance.void
setResultcode
(int resultcode) Set the resultcode of the instance.void
setResultvalues
(String resultvalues) Set the resultvalues.void
setRetryStart
(boolean retrystart) Set the retrystart property of the instance.void
setStartInterval
(long startinterval) Set the start interval of an instance.void
setStartnow
(boolean startnow) Set the startnow property of the instance.void
setStarttime
(Date starttime) Set the time the instance should be started.Methods inherited from interface com.groiss.store.Persistent
afterDelete, afterInsert, afterRead, afterUpdate, beforeDelete, beforeInsert, beforeUpdate, dbFields, getKey, getKeys, getLocalClassName, getLocalObjectName, getOid, getStore, getTableName, getValue, isFilled, isValid, setFilled, setOid, setOid, toListString
-
Field Details
-
CREATED
static final int CREATEDInitial state for the instance. Immediately after it is created. External execution context do not yet know about batchjobs in this state. The BatchManager (or corresponding executor) periodically looks for jobs in this state and starts them.- See Also:
-
STARTED
static final int STARTEDState for started instances. The batchJob is in the external execution context. The workflow engine does nothing with jobs in this state. If the batchjob has been set to be a polling one, the BatchManager (or assigned executor) will periodically callBatchAdapter.doPoll(BatchJob)
.- See Also:
-
FINISHED
static final int FINISHEDState for finished instances. The batchJob was finished in the external execution context. The BatchManager (or corresponding executor) periodically checks for jobs in this state and completes them. Especially, the originating task of the BatchJob is finished.- See Also:
-
COMPLETED
static final int COMPLETEDState for completed instances. The batchJob was completed by the BatchManager or corresponding executor. The workflow engine does nothing with jobs in this state.- See Also:
-
ABORTED
static final int ABORTEDState for aborted instances. The cancellation was issued manually. The workflow engine does nothing with jobs in this state.- See Also:
-
STARTERROR
static final int STARTERRORState for instances which could not be started. E.g. where doStart of the BatchAdapter threw an Exception. The workflow engine does nothing with jobs in this state.- See Also:
-
FINISHERROR
static final int FINISHERRORState for instances which could not be finished by the BatchManager or the corresponding executor. E.g. where beforeCompletion of the BatchAdapter threw an Exception. The workflow engine does nothing with jobs in this state.- See Also:
-
STARTERRORHANDLING
static final int STARTERRORHANDLINGerror handling for batchjobs which couln't be started is currently active- See Also:
-
FINISHERRORHANDLING
static final int FINISHERRORHANDLINGerror handling for batchjobs which couln't be finished is currently active- See Also:
-
COMPLETEDERRORHANDLING
static final int COMPLETEDERRORHANDLINGerror handling has been completed- See Also:
-
STARTERRORHANDLINGPENDING
static final int STARTERRORHANDLINGPENDINGerror handling for batchjobs which couldn't be started will be started soon- See Also:
-
FINISHERRORHANDLINGPENDING
static final int FINISHERRORHANDLINGPENDINGerror handling for batchjobs which couldn't be finished will be started soon- See Also:
-
STARTERRORHANDLINGFAILED
static final int STARTERRORHANDLINGFAILEDerror handling is defined for this batchjob, but it did fail to start- See Also:
-
FINISHERRORHANDLINGFAILED
static final int FINISHERRORHANDLINGFAILEDerror handling is defined for this batchjob, but it did fail to start- See Also:
-
-
Method Details
-
setStartnow
void setStartnow(boolean startnow) Set the startnow property of the instance. -
isStartnow
boolean isStartnow()Determine whether the instance is to be started immediately ('startnow' in WDL). If true, the BatchManager is not involved with the start of the job, it is started immediately after creation. -
setAutofinish
void setAutofinish(boolean autofinish) Set the autofinish property of the instance. -
isAutofinish
boolean isAutofinish()Determine whether the instance is to be finished automatically ('autofinish' in WDL). If true, the job is marked as finished as soon as the doStart method of the specified BatchAdapter terminates. -
setNewthread
void setNewthread(boolean newthread) Set the newthread property of the instance. -
isNewthread
boolean isNewthread()Determine whether the instance start and poll attempts are to be made in a new thread ('newthread' in WDL).
At job creation, a new thread is started immediately after job creation ant this threas executes the start and possibly (if autofinishe is set) the finishing of the batch job.
If the job is being polled for finish, this wioll also take place in a new thread. -
setGoBackOnError
void setGoBackOnError(boolean gobackonerror) Set the gobackonerror property of the instance. -
isGoBackOnError
boolean isGoBackOnError()Determine whether an error during start or poll of the instance will force the engine to go back to the latest interactive step ('gobackonerror' in WDL). If false, the process will remain at this step. -
setRetryStart
void setRetryStart(boolean retrystart) Set the retrystart property of the instance. -
isRetryStart
boolean isRetryStart()Determine whether erroneous starts will be retried later on ('retrystart' in WDL) by the BatchManager or a corresponding executor. -
setPollFinish
void setPollFinish(boolean pollfinish) Set the pollfinish property of the instance. -
isPollFinish
boolean isPollFinish()Determine whether a job should be polled for being finished ('pollfinish' in WDL) by the BatchManager or a corresponding executor. -
getJobtype
String getJobtype()The jobtype of the instance.- Returns:
- a Classname of a BatchAdapter which is responsible for event handling for this instance.
-
getExecutor
String getExecutor()Get the executor of the instance.- Returns:
- the executor
-
setExecutor
Set the executor of the instance. Typically used in afterCreate() of the BatchAdapter. Must be the id of an existing @enterprise timer with class BatchManager. This timer will be used for the instances start and poll attempts. If not set, the BatchManager will be used as the instances executor.
The calling thread must update the batchjob afterwards.- Parameters:
executor
- the id of the timer to use as the executor of this instance.
-
getJobstate
int getJobstate()The state of the instance.- Returns:
- an int representing the execution state of the instance.
-
setJobstate
void setJobstate(int state) Set the state of the job.- Parameters:
state
- the state to set
-
getContext
ActivityInstance getContext()The process context in which the instance was submitted.- Returns:
- a ActivityInstance which represents the TASK where the instance was submitted.
-
setParams
Set the params field of the instance. -
getParams
String getParams()Get the parameters for the job execution. Must be interpreted by the BatchAdapter.- Returns:
- a String containing parameters for execution.
-
setResultvalues
Set the resultvalues. Not interpreted by the BatchManager.- Parameters:
resultvalues
- a String
-
getResultvalues
String getResultvalues()Get the resultvalues of the instance.- Returns:
- a String representing some result of the instances execution.
-
setResultcode
void setResultcode(int resultcode) Set the resultcode of the instance. Not interpreted by the BatchManager.- Parameters:
resultcode
- an int representing a coded result of the instances execution
-
getResultcode
int getResultcode()Get the resultcode of the instance.- Returns:
- an int with the coded result of the execution of the instance.
-
getCreationtime
Date getCreationtime()Get the time the instance was created.- Returns:
- a Date
-
setStarttime
Set the time the instance should be started. If null, then it is started at the next run of the BatchManager. Otherwise it is started in the first run of the BatchManager which takes place after the starttime. -
getStarttime
Date getStarttime()Get the time the instance was started or is about to be started. If null- Returns:
- a Date
-
setFinishtime
-
getFinishtime
Date getFinishtime()Get the time the instance was finished.- Returns:
- a Date
-
getCompletiontime
Date getCompletiontime()Get the time the instance was completed.- Returns:
- a Date
-
getLastStartTryTime
Date getLastStartTryTime()Get the time of the last start attempt.- Returns:
- time of the last start attempt
-
getAborttime
Date getAborttime()Get the time the instance was aborted.- Returns:
- a Date
-
getStartAttemptCount
int getStartAttemptCount()Gets the number of start attempts to far.- Returns:
- the number of start attempts
-
getStartInterval
long getStartInterval()Gets the start interval.- Returns:
- the start interval (seconds)
-
setStartInterval
void setStartInterval(long startinterval) Set the start interval of an instance. Calls to the Adapters doStart() method will not be made more often than this interval.- Parameters:
startinterval
- the interval to use (seconds)
-
getLastpolltime
Date getLastpolltime()- Returns:
-
getPollAttemptCount
int getPollAttemptCount()Gets the number of poll attempts to far.- Returns:
- the number of poll attempts
-
getPollInterval
long getPollInterval()Gets the poll interval.- Returns:
- the poll interval (seconds)
-
setPollInterval
void setPollInterval(long pollinterval) Set the poll interval of an instance. Calls to the Adapters doPoll() method will not be made more often than this interval.- Parameters:
pollinterval
- the interval to use (seconds)
-
isSuspendable
boolean isSuspendable()Determine if the batch job is suspendable.- Returns:
- true, if the batch job is suspendable
-
isResumable
boolean isResumable()Determines if the batch job is resumable.- Returns:
- true,if the batch job is resumable
-
getStateName
-
getStateName
-