Skip to end of metadata
Go to start of metadata

Starting Point

  • Users would like to check in individual job scripts or monitor scripts
    • if a job chain has been executed in the current period, e.g. for the current day,
    • what is the last job chain order state of the job chain,
    • if an order previously completed successfully or with an error.
  • The intention for checking the job chain execution history is to automate decision making based on the point in time or execution result of a previous job chain run.

Feature

  • FEATURE AVAILABILITY STARTING FROM RELEASE 1.10.2
  • This feature 
    • is available with
      JITL-228 - Provide a function for checking the job chain and order history in job monitors by use of the XML interface Released
    • is a subset of
      JITL-212 - Provide a function for checking the job history in job monitors by use of web services Released
  • A JobChainHistory object is provided for job chain history checks that can be used
    • in individual jobs that are implemented with Java or JavaScript.
    • in individual job monitors that are implemented with Java or JavaScript.
  • The JobChainHistory object returns a JobChainHistoryInformation object for a given job chain that contains the history of the job chain runs.
  • The JobChainHistoryInformation object provides a set of JobChainHistoryInformationEntry objects that expose the history information for the respective job chain runs.

JobChainHistory Object

This object is instantiated by a job or job monitor and provides the method to retrieve a JobCHainHistoryInformation object for a given job chain.

ObjectDescription
jobChainHistory = new Packages.com.sos.jitl.checkrunhistory.JobChainHistory( spooler.delegate )
object for use with jobs and job monitors that are implemented with Java or JavaScript
Methods 
JobSchedulerHistoryInfoEntry = jobChainHistory.getJobChainInfo( jobchain, limit, timelimit )

retrieves the JobHistoryInformation object within the specified limits:

  • jobchain: for a specific job chain (the path of the job chain)
    • an order id can be specified with the syntax: jobchain(order_id)
  • limit: for the specified number of entries from the job chain history
  • timelimit: for a specific time range for which the job chain history is considered
    • the range is an interval for from and to
    • the default for from is 00:00:00
    • the default for to is the current time
    • the interval is specified with from..to
    • if only one time is specified, it is the from time.
jobChainHistory.getNumberOfCompleted()The number of completed entries
jobChainHistory.getNumberOfStarts()The number of starts
jobChainHistory.getNumberOfCompletedSuccessful()The number of completed runs with a state that is not an error state
jobChainHistory.getNumberOfCompletedWithError()The number of completed runs with a state that is an error state
jobChainHistory.getCount()The number of entries

JobChainHistoryInformation Object

This object is returned by the JobChainHistory object for a given job chain and provides a set of JobChainHistoryInformationEntry objects for the respective job chain runs.

  • Completed translates to: "has an end date"
  • With error translates to: "has a state that is an error state in the job chain"
ObjectDescription
jobChainHistoryInfo = jobChainHistory.getChainJobInfo( jobchain, limit, timelimit )
The JobChainHistoryInformation object is retrieved from the JobChainHistory object for a given job chain Please note that an order can be specified with the jobchain: jobchain(order_id).
Methods Description
Retrieve JobChainHistoryInformationEntry objects
JobSchedulerHistoryInfoEntry jobChainHistoryInfo.getRunning()Get the JobSchedulerHistoryInfoEntry object for the current job chain run. 
JobSchedulerHistoryInfoEntry jobChainHistoryInfo.getLastExecution()Get the JobSchedulerHistoryInfoEntry object for the most recently started job chain run including running order and orders that completed successfully or failed with error.
JobSchedulerHistoryInfoEntry jobChainHistoryInfo.getLastCompleted()Get the JobSchedulerHistoryInfoEntry object for the most recently completed job chain run including orders that completed successfully or failed with error.
JobSchedulerHistoryInfoEntry jobChainHistoryInfo.getLastCompletedSuccessful()Get the JobSchedulerHistoryInfoEntry object for the most recently successfully completed job chain run.
JobSchedulerHistoryInfoEntry jobChainHistoryInfo.getLastCompletedWithError()Get the JobSchedulerHistoryInfoEntry object for the most recently completed job chain run that failed with error.
Checks for any job chain runs in the period of the current day
boolean jobChainHistoryInfo.isStartedToday()Indicates that a job chain run started within the current period and applies to running job chains and completed job chain runs.
boolean jobChainHistoryInfo.isStartedTodayCompleted()Indicates that a job chain run started and completed within the current period and applies to job chain runs that completed successfully or failed with error.
boolean jobChainHistoryInfo.isStartedTodayCompletedSuccessful()Indicates that a job chain run started and completed successfully within the current period.
boolean jobChainHistoryInfo.isStartedTodayCompletedWithError()Indicates that a job chain run started and completed with error within the current period.
Checks for any job chain runs that completed today 
boolean jobChainHistoryInfo.isCompletedToday()Indicates that a job chain run completed in the current period and applies to job runs that completed successfully or failed with error.
boolean jobChainHistoryInfo.isCompletedTodaySuccessful()

Indicates that a job chain run completed successfully within the current period.

boolean jobChainHistoryInfo.isCompletedTodayWithError()Indicates that a job chain run completed with error within the current period.
Checks for any job chain runs that ended after a specific point in time
boolean jobChainHistoryInfo.isCompleteddAfter( "03:00:00" )indicates that a job chain run completed after the given date
boolean jobChainHistoryInfo.isCompletedWithSuccessfulAfter( "03:00:00" )indicates that a job chain run completed successfully after the given date
boolean jobChainHistoryInfo.isCompletedWithErrorAfter( "03:00:00" )indicates that a job chain run completed with error after the given date
Checks for any job chain runs that started after a specific point in time
boolean jobChainHistoryInfo.startedAfter( "03:00:00" )

indicates that a job chain run started after the given date, the job chain might be completed or running

boolean jobChainHistoryInfo.startedSuccessfulAfter( "03:00:00" )indictes that a job chain run started after the given date and does not report any errors, the job chain might be completed or running
boolean jobChainHistoryInfo.startedWithErrorAfter( "03:00:00" )indicates that a job chain run started after the given date and does report errors, the job chain might be completed or running

JobSchedulerHistoryInfoEntry Object

The object represents the history for a specific job chain run and is provided by the JobChainHistoryInformation object.

ObjectDescription
JobSchedulerHistoryInfoEntry jobChainHistoryInfo.getRunning()Get the JobSchedulerHistoryInfoEntry object for the current job chain run.
JobSchedulerHistoryInfoEntry jobChainHistoryInfo.getLastExecution()Get the JobSchedulerHistoryInfoEntry object for the most recently started job chain run including running job chains and job chains that completed successfully or failed with error.
... 
PropertyDescription
nameContains the job chain name.
foundIndicates if the associated object is not null.
idExposes the unique order history identification as provided by JobScheduler.
order_idThe order id of the current order
positionReturns the position of the object in the job chain execution history: a value 0 signals the most recent entry, larger values suggest older entries.
startReturns the start date of the job chain run.
endReturns the end date of the job chain run.
durationReturns the duration in the format hh:mm:ss. If longer than one day the format provided is d:hh:mm:ss.
stateThe current state of the order.
errorIndicates an error status, 1=error, 0=no error. An order execution will be assumed as an error if the state is an error state in the job chain.

Usage

Use with a Job Script

A complete example file demonstrates the use of 


 Expand source

Use with a Monitor Script

To identify if a running job chain is a rerun of a previously failed job chain execution you can use the following script for a pre-processing monitor. The script will expose the information if a rerun has been identified with the environment variable SCHEDULER_PARAM_JOB_CHAIN_IS_RERUN


 Expand source

Explanations

  • The script retrieves the last job chain execution that completed with error and checks if the position of the object provided is the first in the recent history list. The first position of a job chain that recently completed with error is
    • 0 if the script is executed as a pre-processing monitor script before a task start.
    • 1 if the script is executed as a job script for a running task. That task would be added to the begin of the recent history list.
  • In order to check if a job chain did run before a given point in time you can query a job chain history object that takes a time limit into consideration as from the following samples:

Implementation

  • The implementation makes use of API methods, i.e. XML commands, to retrieve the job history instead of a database connection.
  • The solution can be used with Agents.
  • No separate HTTP connection is created, the solution makes use of the HTTP(S) connection that is established between Master and Agent.

References

Change Management References

Loading
T Key Linked Issues Fix Version/s Status P Summary Updated
Feature JITL-228 JITL-217 , JITL-290 1.9.8, 1.10.2 Released Minor Provide a function for checking the job chain and order history in job monitors by use of the XML interface Mar 23, 2016

Documentation