Class BackupJob

java.lang.Object
ai.chatur.cortex.spring.backup.BackupJob
All Implemented Interfaces:
org.quartz.Job

@DisallowConcurrentExecution public class BackupJob extends Object implements org.quartz.Job
Quartz adapter around BackupRunner.

Deliberately holds no behavior of its own: everything worth testing lives in BackupRunner, which needs neither a scheduler nor a Quartz context to exercise.

Instantiated by Quartz, not by Spring: Boot's QuartzAutoConfiguration installs a SpringBeanJobFactory with the application context set, which creates each job through getAutowireCapableBeanFactory().createBean(jobClass). This class therefore has exactly one constructor, which is what makes that constructor injection unambiguous — adding a second would break the wiring at runtime rather than at compile time.

DisallowConcurrentExecution matters at short intervals: a backup of a large store can outlast its own interval. Overlapping runs would not corrupt anything — TDB2 serializes them inside read transactions — but they would thrash disk and upload bandwidth to no benefit.

  • Constructor Details

    • BackupJob

      public BackupJob(BackupRunner runner)
      Creates the job.
      Parameters:
      runner - the runner that takes and uploads the backup
  • Method Details

    • execute

      public void execute(org.quartz.JobExecutionContext context) throws org.quartz.JobExecutionException
      Runs one backup.

      Failures are wrapped rather than swallowed, so Quartz reports them. The wrap passes refireImmediately = false deliberately: a durable failure — bad credentials, a full disk, a missing bucket — would otherwise hot-loop. The next scheduled fire still happens, so a transient failure recovers on its own.

      Specified by:
      execute in interface org.quartz.Job
      Parameters:
      context - the Quartz execution context, unused
      Throws:
      org.quartz.JobExecutionException - if the backup or its upload fails