Maintaining Schedules and Batch Job Executions
Overview
A system schedule is a task that is scheduled for execution by the system batch queue at a specific time, for a given frequency of re-occurrence. The task scheduler is used to schedule tasks that trigger the corresponding system batch job when the scheduled time is reached.
Users require the functionality to perform the processing of tasks, such as the generation of reports or invoices, or the deletion of redundant records, in the background so that their interactive session is not held up waiting for the task to complete, allowing them to continue working.
System Batch Jobs
The system batch processor is provided through a reusable Java-based batch processing architecture framework that is developed around Spring Batch and Quartz Scheduler.
Quartz Scheduler and CRON/Schedule
Example Batch Definition File created by the system
For any type of job that can be scheduled or directly run on the system batch queue, the Quartz Scheduler works on the:
- Schedule Name—The schedule name can reflect the Job Name destined for the system batch queue, or the schedule expression.
- Schedule Group—A schedule group provides a categorisation for the schedule, for example, there may be a schedule group for finance reporting.
Together the Schedule Group and Schedule Name uniquely reference the schedule from an application point of view.
Each job schedule has associated parameters known as a schedule expression.
Spring Batch works on the Job Name.
Process
The MSESCH—Schedule application is used to establish schedules in the system scheduler which, when executed at the appointed time, places a job on the system batch queue, to be executed on the system batch processor, in order of priority and when the job entered the queue. Other CCLAS 6 applications also have the ability to send jobs to the system batch processor.
A batch job execution is the process of running a job on the system batch processor. The system scheduler is used to schedule jobs on the system batch processor. The MSEJEX—Job Executions is used to view the status of jobs sent to the system batch processor.
Effect on the system batch queue when DNS Batch Servers are started or stopped
Entry of jobs on the system batch queue
Since a system batch job's Queued Time + Priority is used to determine the next task to process from the queue, when a system batch job is created, the Queued Time is set to the application server's time. However, when a batch queue task has its Created, Started and Ending times recorded in the MSEJEX—Job Executions application, the times are recorded relative to the Time Zone of the laboratory associated with the task.
Refer to Configuring the System Batch Queue for prioritising system batch queue jobs by type, placing queue limits by report request code on CCBPGEN and CCBRGEN system batch jobs, and placing timeouts on processing system batch queue jobs.
Reviewing Batch Job Details
The MSEJEX—Search Job Executions screen allows users to search for jobs that are executed. Only jobs that have run and are not deleted by housekeeping are displayed.
The job execution refers to what happened during the run of the job and hence refers to that run and only that run. If the batch job was run more than once, it would then display across a number of rows with the same Instance Id and different Execution Ids.
The job instance refers to the logical job run, for example, the November 15th Run, or the batch job 'Update Stock Codes' runs every night and the Instance Id is 20131114 (yyyymmdd). If this fails and needs to be rerun, it is still the same Instance Id that is run or restarted, so it is not a different value.
The details of the batch job run for the job instance is found in the log.
Each job execution shows as a separate entry. There may be multiple job executions for a job instance. Opening a job instance launches the MSEJEX—Job Executions Details screen for the batch job.
Actions that can be taken on batch jobs
| Status | Available action |
|---|---|
|
Started |
When the job is running it can be stopped (Stop) or abandoned (Abandon). |
|
Failed |
A failed job can only be restarted (Restart) or rerun if allowed by the functionality of the application. |
|
Completed |
The log can be reviewed and the output files can be viewed. |
|
Starting |
When the job is starting it can be stopped (Stop) or abandoned (Abandon). |
|
Stopping |
When a job is stopping no action can be taken. |
|
Stopped |
A stopped job can only be restarted or rerun if allowed by the functionality of the application. |
|
Unknown/ Abandoned |
A job with an unknown or abandoned state is assumed to be not continuable, i.e. no action can be taken. |
|
Queued |
When the job is queued it can be stopped (Stop) or abandoned (Abandon). |
Note: Jobs that are stopped may need to be rerun from the start rather than restarted from a point of failure or abandonment. Ideally, all jobs should be able to start up where they left off, but there are scenarios where this is not possible. Those jobs that cannot be restarted and must be rerun is flagged.
Those jobs that are restarted show in the log with the same Execution Id, whereas those that are restarted have a different Execution Id.
A job can be stopped or abandoned when it is queued, starting or started. A stopped or failed job can be restarted if allowed by the functionality of the application.
Stop/Restart/Abandon multiple batch job executions
Abandon/Restart/Stop a batch job execution
Handy Scripts for the Batch Job Queue and Execution Tables
The following SQL script can be used to clear records in Batch Job Queue and Batch Job Execution tables for a batch jobs that were starting or started on a batch queue server that no longer exists. To have this script operate on your CCLAS 6 environment, replace CCDOCO with the name of your Oracle connection.
DeleteStartedButDeadBatchJobs.sql
--BATCH_JOB_QUEUE.JOB_KEY --> BATCH_JOB_QUEUE_PARAMS.JOB_KEY
-- --> BATCH_JOB_INSTANCE.JOB_KEY; BATCH_JOB_INSTANCE.JOB_INSTANCE_ID --> BATCH_JOB_EXECUTION.JOB_INSTANCE_ID; BATCH_JOB_EXECUTION.JOB_EXECUTION_ID --> BATCH_JOB_EXECUTION_CONTEXT.JOB_EXECUTION_ID
-- BATCH_JOB_EXECUTION_PARAMS.JOB_EXECUTION_ID --> BATCH_STEP_EXECUTION.JOB_EXECUTION_ID; BATCH_STEP_EXECUTION.STEP_EXECUTION_ID --> BATCH_STEP_EXECUTION_CONTEXT.STEP_EXECUTION_ID
create table temp (batchServer varchar2(255), jobKey varchar2(32), jobInstanceId number(20,0), jobExecutionId number(20,0), stepExecutionId number(20,0));
insert into temp (batchServer, jobKey, jobInstanceId, jobExecutionId, stepExecutionId)
select distinct BJQ.BATCH_SERVER, BJQ.JOB_KEY, BJI.JOB_INSTANCE_ID, BJE.JOB_EXECUTION_ID, BSE.STEP_EXECUTION_ID
from BATCH_JOB_QUEUE BJQ
join BATCH_JOB_QUEUE_PARAMS BJQP on BJQP.JOB_KEY = BJQ.JOB_KEY
join BATCH_JOB_INSTANCE BJI on BJI.JOB_KEY = BJQ.JOB_KEY
join BATCH_JOB_EXECUTION BJE on BJE.JOB_INSTANCE_ID = BJI.JOB_INSTANCE_ID
join BATCH_JOB_EXECUTION_CONTEXT BJEC on BJEC.JOB_EXECUTION_ID = BJE.JOB_EXECUTION_ID
join BATCH_JOB_EXECUTION_PARAMS BJEP on BJEP.JOB_EXECUTION_ID = BJE.JOB_EXECUTION_ID
join BATCH_STEP_EXECUTION BSE on BSE.JOB_EXECUTION_ID = BJE.JOB_EXECUTION_ID
join BATCH_STEP_EXECUTION_CONTEXT BSEC on BSEC.STEP_EXECUTION_ID = BSE.STEP_EXECUTION_ID
where BJE.STATUS in ('STARTED','STARTING')
and BJQ.BATCH_SERVER not in (select distinct MACHINE from V$SESSION where USERNAME='CCDOCO');
--select * from temp;
delete from BATCH_STEP_EXECUTION_CONTEXT BSEC where BSEC.STEP_EXECUTION_ID in (select stepExecutionId from temp);
delete from BATCH_STEP_EXECUTION BSE where BSE.JOB_EXECUTION_ID in (select jobExecutionId from temp);
delete from BATCH_JOB_EXECUTION_PARAMS BJEP where BJEP.JOB_EXECUTION_ID in (select jobExecutionId from temp);
delete from BATCH_JOB_EXECUTION_CONTEXT BJEC where BJEC.JOB_EXECUTION_ID in (select jobExecutionId from temp);
delete from BATCH_JOB_EXECUTION BJE where BJE.JOB_EXECUTION_ID in (select jobExecutionId from temp);
delete from BATCH_JOB_INSTANCE BJI where BJI.JOB_KEY in (select jobKey from temp);
delete from BATCH_JOB_QUEUE_PARAMS BJQP where BJQP.JOB_KEY in (select jobKey from temp);
delete from BATCH_JOB_QUEUE BJQ where BJQ.JOB_KEY in (select jobKey from temp);
drop table temp;
- Maintaining Schedule Jobs and Samples
- Registering Jobs from Schedule Jobs
- Maintaining Job Paperwork and Labels
- Maintaining Instrument and Task Schedules
- Maintaining Instrument File Uploads
- Generating Reports from Report Requests
- Distributing Certificate Reports
- Generating WIP and Estimate Job Costs
- Generating WIP and Estimate Job Invoices
- Maintaining Invoice Documents for an Invoice
- Scheduling Grid Reports for Job Status, Financial and QC History Grid Reports
- Configuring the System Batch Queue
