Interface BatchJob

All Superinterfaces:
KeyValuePair<String,String>, Persistent, Serializable

public interface BatchJob extends Persistent
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 Details

    • CREATED

      static final int CREATED
      Initial 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 STARTED
      State 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 call BatchAdapter.doPoll(BatchJob).
      See Also:
    • FINISHED

      static final int FINISHED
      State 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 COMPLETED
      State 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 ABORTED
      State for aborted instances. The cancellation was issued manually. The workflow engine does nothing with jobs in this state.
      See Also:
    • STARTERROR

      static final int STARTERROR
      State 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 FINISHERROR
      State 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 STARTERRORHANDLING
      error handling for batchjobs which couln't be started is currently active
      See Also:
    • FINISHERRORHANDLING

      static final int FINISHERRORHANDLING
      error handling for batchjobs which couln't be finished is currently active
      See Also:
    • COMPLETEDERRORHANDLING

      static final int COMPLETEDERRORHANDLING
      error handling has been completed
      See Also:
    • STARTERRORHANDLINGPENDING

      static final int STARTERRORHANDLINGPENDING
      error handling for batchjobs which couldn't be started will be started soon
      See Also:
    • FINISHERRORHANDLINGPENDING

      static final int FINISHERRORHANDLINGPENDING
      error handling for batchjobs which couldn't be finished will be started soon
      See Also:
    • STARTERRORHANDLINGFAILED

      static final int STARTERRORHANDLINGFAILED
      error handling is defined for this batchjob, but it did fail to start
      See Also:
    • FINISHERRORHANDLINGFAILED

      static final int FINISHERRORHANDLINGFAILED
      error 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.
      See Also:
    • 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

      void setExecutor(String executor)
      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

      void setParams(String params)
      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

      void setResultvalues(String resultvalues)
      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

      void setStarttime(Date starttime)
      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

      void setFinishtime(Date finishtime)
    • 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

      default String getStateName()
    • getStateName

      static String getStateName(int state)