# IJournaledState

Package: [Microsoft.Orleans.Journaling](/orleans/docs/api/csharp/microsoft.orleans.journaling/) 10.0.0-alpha.1

[NuGet package](https://www.nuget.org/packages/Microsoft.Orleans.Journaling) | [Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Journaling/IJournaledState.cs#L40)

```csharp
public interface IJournaledState
```

Interface for a state which can be persisted to durable storage.

## Remarks

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](/orleans/docs/api/csharp/microsoft.orleans.journaling/orleans.journaling.ijournaledstate/) (and occasionally [IJournaledState](/orleans/docs/api/csharp/microsoft.orleans.journaling/orleans.journaling.ijournaledstate/)) to materialize the pending changes, then flushes the journal to durable storage.
- [IJournaledState](/orleans/docs/api/csharp/microsoft.orleans.journaling/orleans.journaling.ijournaledstate/) is 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 [IJournaledState](/orleans/docs/api/csharp/microsoft.orleans.journaling/orleans.journaling.ijournaledstate/) followed 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)](/orleans/docs/api/csharp/microsoft.orleans.journaling/orleans.journaling.ijournaledstate/methods/appendentries-orleans-journaling-journalstreamwriter-e6d2bb88/)
- [AppendSnapshot(JournalStreamWriter)](/orleans/docs/api/csharp/microsoft.orleans.journaling/orleans.journaling.ijournaledstate/methods/appendsnapshot-orleans-journaling-journalstreamwriter-ba85e074/)
- [DeepCopy](/orleans/docs/api/csharp/microsoft.orleans.journaling/orleans.journaling.ijournaledstate/methods/deepcopy-30f7c750/)
- [OnRecoveryCompleted](/orleans/docs/api/csharp/microsoft.orleans.journaling/orleans.journaling.ijournaledstate/methods/onrecoverycompleted-92384f85/)
- [OnWriteCompleted](/orleans/docs/api/csharp/microsoft.orleans.journaling/orleans.journaling.ijournaledstate/methods/onwritecompleted-729ccb55/)
- [ReplayEntry(JournalEntry, JournalReplayContext)](/orleans/docs/api/csharp/microsoft.orleans.journaling/orleans.journaling.ijournaledstate/methods/replayentry-orleans-journaling-journalentry-orleans-journaling-journalreplaycont-c3f71293/)
- [Reset(JournalStreamWriter)](/orleans/docs/api/csharp/microsoft.orleans.journaling/orleans.journaling.ijournaledstate/methods/reset-orleans-journaling-journalstreamwriter-e79b1867/)
