Class RestoreRunner
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
ConstructorsConstructorDescriptionRestoreRunner(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 TypeMethodDescriptionvoidrun()Finds the latest backup under the key prefix, downloads it, and restores it.
-
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 stores3Client- the client the backup is listed and downloaded throughbucket- the bucket backups are read fromkeyPrefix- 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.gznames 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
-