IJournaledState
interface
Namespace: Orleans.Journaling
Interface for a state which can be persisted to durable storage.
public interface IJournaledStateRemarks
Implementations are owned by a single Orleans.Journaling.JournaledStateManager and are accessed from one logical thread at a time. They participate in the journaling lifecycle as follows:
- User code mutates in-memory state synchronously (typically by invoking codec helpers that both apply the mutation locally and emit the corresponding command to the journal).
- At the end of the grain turn, the journaled state manager calls
IJournaledState(and occasionallyIJournaledState) to materialize the pending changes, then flushes the journal to durable storage. IJournaledStateis invoked when the durable write has been acknowledged. Implementations that need to know when state has actually been persisted (for example, to release waiters or trigger downstream notifications) should hook into this callback rather than treating in-memory mutations as durable.- On failure, the journaled state manager triggers recovery by calling
IJournaledStatefollowed by replaying snapshots and entries from durable storage. Implementations must therefore make any volatile in-memory bookkeeping fully recoverable from the journal.
In other words, in-memory mutations are journaled within the same grain turn and become durable when the journal flushes. Implementations are free to apply mutations eagerly (before the durable write completes); recovery rebuilds in-memory state from the journal, so a turn-failure-and-recovery cycle observably rewinds any unflushed changes.
Methods
AppendEntries(JournalStreamWriter)Writes pending state changes to the journal.AppendSnapshot(JournalStreamWriter)Writes a snapshot of the state to the provided writer.DeepCopyCreates and returns a deep copy of this instance. All replicas must be independent such that changes to one do not affect any other.OnRecoveryCompletedNotifies the state that all prior journal entries and snapshots have been applied.OnWriteCompletedNotifies the state that all prior journal entries and snapshots which it has written have been written to stable storage.ReplayEntry(JournalEntry, JournalReplayContext)Replays one entry during journal recovery.Reset(JournalStreamWriter)Resets the state.
