Class JobMaintenanceServiceImpl

java.lang.Object
ca.uhn.fhir.batch2.maintenance.JobMaintenanceServiceImpl
All Implemented Interfaces:
IJobMaintenanceService, IHasScheduledJobs

This class performs regular polls of the stored jobs in order to perform maintenance. This includes two major functions.

First, we calculate statistics and delete expired tasks. This class does the following things:

  • For instances that are IN_PROGRESS, calculates throughput and percent complete
  • For instances that are IN_PROGRESS where all chunks are COMPLETE, marks instance as COMPLETE
  • For instances that are COMPLETE, purges chunk data
  • For instances that are IN_PROGRESS where at least one chunk is FAILED, marks instance as FAILED and propagates the error message to the instance, and purges chunk data
  • For instances that are IN_PROGRESS with an error message set where no chunks are ERRORED or FAILED, clears the error message in the instance (meaning presumably there was an error but it cleared)
  • For instances that are IN_PROGRESS and isCancelled flag is set marks them as ERRORED and indicating the current running step if any
  • For instances that are COMPLETE or FAILED and are old, delete them entirely

Second, we check for any job instances where the job is configured to have gated execution. For these instances, we check if the current step is complete (all chunks are in COMPLETE status) and trigger the next step.

The maintenance pass is run once per minute. However if a gated job is fast-tracking (i.e. every step produced exactly one chunk, then the maintenance task will be triggered earlier than scheduled by the step executor.