Skip to main content

CheckpointCoordinator

Struct CheckpointCoordinator 

Source
pub struct CheckpointCoordinator { /* private fields */ }
Expand description

Checkpoint coordinator.

Implementations§

Source§

impl CheckpointCoordinator

Source

pub fn new(config: CheckpointConfig) -> Self

Create a new checkpoint coordinator without durable storage.

Checkpoints still capture registered operator state into their metadata but are not persisted to disk. Use CheckpointCoordinator::with_storage (or a storage_path in the config) for durable, recoverable checkpoints.

Source

pub fn with_storage( config: CheckpointConfig, storage: Arc<dyn CheckpointStorage>, ) -> Self

Create a coordinator backed by a durable CheckpointStorage.

Source

pub fn from_config(config: CheckpointConfig) -> Result<Self>

Create a coordinator whose storage is derived from config.storage_path.

When config.storage_path is set, a FileCheckpointStorage rooted at that path is created (the directory is created if missing). When it is None, this is equivalent to CheckpointCoordinator::new.

Source

pub async fn register_operator( &self, name: impl Into<String>, state: Arc<dyn DynOperatorState>, )

Register an operator state to be captured on every checkpoint.

The name uniquely identifies the operator across snapshot/restore; the same name must be used when restoring so the correct bytes are routed back to the operator. Registering an existing name replaces it.

Source

pub async fn operator_count(&self) -> usize

Number of registered operators.

Source

pub async fn trigger_checkpoint(&self) -> Result<u64>

Trigger a new checkpoint, capturing the state of all registered operators.

This snapshots every registered DynOperatorState, aggregating the captured bytes into the checkpoint metadata (operator_states) and recording the real total size_bytes. The checkpoint is left active (not yet completed/persisted); call CheckpointCoordinator::complete_checkpoint to finalize it, or use the combined CheckpointCoordinator::checkpoint which triggers, persists, and completes in one step.

If any operator snapshot fails, no active checkpoint is registered and the error is propagated — a failed capture never masquerades as success.

Source

pub async fn checkpoint(&self) -> Result<u64>

Trigger, persist, and complete a checkpoint in one durable step.

Captures registered operator state, persists it through the configured storage, and only marks the checkpoint successful once the state has been durably written. If capture or persistence fails, the checkpoint is completed as a failure (removed from the active set, not added to the completed set) and the error is returned — there is no silent success.

Source

pub async fn restore_checkpoint(&self, checkpoint_id: u64) -> Result<()>

Restore registered operators from a persisted checkpoint.

Loads the checkpoint through the configured storage and routes each stored operator-state blob back to the operator registered under the same name. Operators without a stored blob are left untouched.

Source

pub async fn complete_checkpoint( &self, checkpoint_id: u64, success: bool, ) -> Result<()>

Complete a checkpoint.

Source

pub async fn active_count(&self) -> usize

Get active checkpoint count.

Source

pub async fn active_metadata( &self, checkpoint_id: u64, ) -> Option<CheckpointMetadata>

Get a copy of an active (triggered-but-not-completed) checkpoint’s metadata, if present.

Source

pub async fn completed_count(&self) -> usize

Get completed checkpoint count.

Source

pub async fn latest_checkpoint(&self) -> Option<u64>

Get the latest completed checkpoint ID.

Source

pub async fn clear_old_checkpoints(&self, keep_count: usize)

Clear old checkpoints.

Source

pub async fn start_periodic_checkpointing(self: Arc<Self>)

Start periodic checkpointing.

On every config.interval, this runs the full capture → persist → complete pipeline via CheckpointCoordinator::checkpoint, bounded by config.timeout. A checkpoint is only reported as successful once the registered operator state has actually been captured (and, when storage is configured, durably written). Failures and timeouts are logged and the loop continues; a checkpoint is never marked successful without real state having been captured.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more