Package ca.uhn.fhir.batch2.maintenance
Class JobMaintenanceServiceImpl
java.lang.Object
ca.uhn.fhir.batch2.maintenance.JobMaintenanceServiceImpl
- All Implemented Interfaces:
IJobMaintenanceService,IHasScheduledJobs
public class JobMaintenanceServiceImpl
extends Object
implements 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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionJobMaintenanceServiceImpl(ISchedulerService theSchedulerService, IJobPersistence theJobPersistence, JpaStorageSettings theStorageSettings, JobDefinitionRegistry theJobDefinitionRegistry, BatchJobSender theBatchJobSender, WorkChunkProcessor theExecutor, IReductionStepExecutorService theReductionStepExecutorService) Constructor -
Method Summary
Modifier and TypeMethodDescriptionvoidenableMaintenancePass(boolean theToEnable) This is only to be called in a testing environment to ensure state changes are controlled.voidForces a second maintenance run.voidvoidscheduleJobs(ISchedulerService theSchedulerService) voidsetMaintenanceJobFinishedCallback(Runnable theMaintenanceJobFinishedCallback) voidsetMaintenanceJobStartedCallback(Runnable theMaintenanceJobStartedCallback) voidsetScheduledJobFrequencyMillis(long theScheduledJobFrequencyMillis) booleanDo not wait for the next scheduled time for maintenance.
-
Field Details
-
INSTANCES_PER_PASS
- See Also:
-
SCHEDULED_JOB_ID
-
MAINTENANCE_TRIGGER_RUN_WITHOUT_SCHEDULER_TIMEOUT
- See Also:
-
-
Constructor Details
-
JobMaintenanceServiceImpl
public JobMaintenanceServiceImpl(@Nonnull ISchedulerService theSchedulerService, @Nonnull IJobPersistence theJobPersistence, JpaStorageSettings theStorageSettings, @Nonnull JobDefinitionRegistry theJobDefinitionRegistry, @Nonnull BatchJobSender theBatchJobSender, @Nonnull WorkChunkProcessor theExecutor, @Nonnull IReductionStepExecutorService theReductionStepExecutorService) Constructor
-
-
Method Details
-
scheduleJobs
- Specified by:
scheduleJobsin interfaceIHasScheduledJobs
-
setScheduledJobFrequencyMillis
-
triggerMaintenancePass
Description copied from interface:IJobMaintenanceServiceDo not wait for the next scheduled time for maintenance. Trigger it immediately.- Specified by:
triggerMaintenancePassin interfaceIJobMaintenanceService- Returns:
- true if a request to run a maintance pass was submitted
-
forceMaintenancePass
Description copied from interface:IJobMaintenanceServiceForces a second maintenance run. Only to be used in tests to simulate a long running maintenance step- Specified by:
forceMaintenancePassin interfaceIJobMaintenanceService
-
enableMaintenancePass
Description copied from interface:IJobMaintenanceServiceThis is only to be called in a testing environment to ensure state changes are controlled.- Specified by:
enableMaintenancePassin interfaceIJobMaintenanceService
-
runMaintenancePass
- Specified by:
runMaintenancePassin interfaceIJobMaintenanceService
-
setMaintenanceJobStartedCallback
-
setMaintenanceJobFinishedCallback
-