Package com.tnsai.reliability
Class S3CheckpointStore
java.lang.Object
com.tnsai.reliability.S3CheckpointStore
- All Implemented Interfaces:
CheckpointStore
S3-backed
CheckpointStore (TNS-312). Use this when checkpoints
need to outlive a single host — agent fleet distributed across many
processes / containers / regions, where a run starting in one place
may be resumed in another.
Object layout
One JSON object per checkpoint ats3://<bucket>/<keyPrefix><runId>/<stepIndex>.json.
The shape matches FilesystemCheckpointStore's envelope:
runId, stepIndex, capturedAt, stateBase64,
metadata, previousCheckpointId.
Atomic writes
S3PutObject is atomic — readers either see the previous good
version or the new one, never a torn write. No tmp/rename dance like
the filesystem store needs.
Concurrency
TheS3Client is thread-safe; this store delegates directly so
concurrent save(com.tnsai.reliability.Checkpoint) / latest(java.lang.String) from many threads is fine.
Run id sanitisation
Run ids are S3 object-key components — must not contain/
(would change the directory layout) or be empty. The store rejects
those at the entry point.
Optional dependency
software.amazon.awssdk:s3 is declared
<optional>true</optional> on tnsai-core; consumers
that don't use this store don't pay for the SDK. Loading this class
without the SDK on the classpath is a hard NoClassDefFoundError,
by design.- Since:
- 0.10.0 (TNS-312)
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDefault key prefix; objects land under this folder in the bucket. -
Constructor Summary
ConstructorsConstructorDescriptionS3CheckpointStore(software.amazon.awssdk.services.s3.S3Client s3, String bucket) S3CheckpointStore(software.amazon.awssdk.services.s3.S3Client s3, String bucket, String keyPrefix) -
Method Summary
Modifier and TypeMethodDescriptionvoidsave(Checkpoint cp) Persist a checkpoint.voidDrop every checkpoint forrunIdcaptured strictly beforebefore.
-
Field Details
-
DEFAULT_KEY_PREFIX
Default key prefix; objects land under this folder in the bucket.- See Also:
-
-
Constructor Details
-
S3CheckpointStore
-
S3CheckpointStore
-
-
Method Details
-
save
Description copied from interface:CheckpointStorePersist a checkpoint. Returns when the entry is durable — see "Durability" in the type-level javadoc. Overwrites any prior checkpoint with the same(runId, stepIndex)pair so a step that retries can replace its earlier snapshot.- Specified by:
savein interfaceCheckpointStore
-
latest
- Specified by:
latestin interfaceCheckpointStore- Returns:
- the highest-
stepIndexcheckpoint known forrunId, or empty when the store has none.
-
history
- Specified by:
historyin interfaceCheckpointStore- Returns:
- all checkpoints for
runId, ordered by ascendingstepIndex. Empty list when no checkpoints exist. Implementations may impose a soft cap when histories grow unbounded; document the cap in their javadoc when they do.
-
truncate
Description copied from interface:CheckpointStoreDrop every checkpoint forrunIdcaptured strictly beforebefore. Leaves the latest entry if it falls on or after the cutoff so resume continues to work. Used by retention jobs; not on the run's hot path.- Specified by:
truncatein interfaceCheckpointStore
-