Class RestoreRunner

java.lang.Object
ai.chatur.cortex.spring.backup.RestoreRunner

public class RestoreRunner extends Object
Downloads the most recent backup under a key prefix and loads it into the assertions store.

The download counterpart to BackupRunner: that snapshots the store and uploads it, this finds the latest upload and restores it. Like BackupRunner it is a plain object with no Spring or scheduler dependency, so all of its behaviour can be exercised directly; RestoreExecutionConfiguration's bootstrap is the thin lifecycle adapter that runs it once, at startup.

The store is treated as replaceable and S3 as the source of truth, so a restore is a wipe-and-load (see RestoreService), and it runs on every boot. The one case it does not touch the store is when the bucket holds no backup yet: a genuine first-ever deployment has nothing to restore, so it logs and leaves the (empty) store alone rather than failing. Every other failure — a missing bucket, bad credentials, a corrupt backup — propagates, so an instance that was meant to come up seeded fails loudly instead of serving an empty graph.

  • Constructor Summary

    Constructors
    Constructor
    Description
    RestoreRunner(ai.chatur.cortex.core.store.RestoreService restoreService, software.amazon.awssdk.services.s3.S3Client s3Client, String bucket, String keyPrefix)
    Creates the runner.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    run()
    Finds the latest backup under the key prefix, downloads it, and restores it.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RestoreRunner

      public RestoreRunner(ai.chatur.cortex.core.store.RestoreService restoreService, software.amazon.awssdk.services.s3.S3Client s3Client, String bucket, String keyPrefix)
      Creates the runner.
      Parameters:
      restoreService - loads the downloaded backup into the store
      s3Client - the client the backup is listed and downloaded through
      bucket - the bucket backups are read from
      keyPrefix - the prefix backups were uploaded under; only objects beneath it are considered
  • Method Details

    • run

      public void run()
      Finds the latest backup under the key prefix, downloads it, and restores it.

      "Latest" is by last-modified time, breaking ties on the key — which for the backup_<yyyy-MM-dd_HHmmss>.nq.gz names a backup carries is itself chronological. When the prefix holds no objects the method returns without touching the store.

      Throws:
      RuntimeException - if listing, downloading, or loading the backup fails