Show / Hide Table of Contents

Class SimpleStateMachine

Represents a state machine that keeps the entire state in the memory but periodically creates a persistent snapshot for recovery.

Inheritance
object
SimpleStateMachine
Implements
IAsyncDisposable
IStateMachine
ISnapshotManager
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: DotNext.Net.Cluster.Consensus.Raft.StateMachine
Assembly: DotNext.Net.Cluster.dll
Syntax
public abstract class SimpleStateMachine : IAsyncDisposable, IStateMachine, ISnapshotManager

Constructors

| Edit this page View Source

SimpleStateMachine(DirectoryInfo)

Initializes a new simple state machine.

Declaration
protected SimpleStateMachine(DirectoryInfo location)
Parameters
Type Name Description
DirectoryInfo location

Methods

| Edit this page View Source

ApplyAsync(LogEntry, CancellationToken)

Applies the log entry to this state machine.

Declaration
protected abstract ValueTask<bool> ApplyAsync(LogEntry entry, CancellationToken token)
Parameters
Type Name Description
LogEntry entry

The log entry to apply to the current state machine.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask<bool>

true if the current state must be persisted; otherwise, false.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

| Edit this page View Source

DisposeAsync()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.

Declaration
public virtual ValueTask DisposeAsync()
Returns
Type Description
ValueTask

A task that represents the asynchronous dispose operation.

| Edit this page View Source

PersistAsync(IAsyncBinaryWriter, CancellationToken)

Persists the current state.

Declaration
protected abstract ValueTask PersistAsync(IAsyncBinaryWriter writer, CancellationToken token)
Parameters
Type Name Description
IAsyncBinaryWriter writer

The writer that can be used to write the state.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The task representing asynchronous execution of the method.

| Edit this page View Source

RestoreAsync(CommandInterpreter, FileInfo, CancellationToken)

Restores the in-memory state from the snapshot.

Declaration
protected static ValueTask RestoreAsync(CommandInterpreter interpreter, FileInfo snapshotFile, CancellationToken token)
Parameters
Type Name Description
CommandInterpreter interpreter

The command interpreter.

FileInfo snapshotFile

The snapshot file.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The task representing asynchronous execution of the method.

Remarks

This method is intended to be called from RestoreAsync(FileInfo, CancellationToken) when the compatibility with CommandInterpreter is required.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

| Edit this page View Source

RestoreAsync(FileInfo, CancellationToken)

Restores the in-memory state from the snapshot.

Declaration
protected abstract ValueTask RestoreAsync(FileInfo snapshotFile, CancellationToken token)
Parameters
Type Name Description
FileInfo snapshotFile

The snapshot file.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The task representing asynchronous execution of the method.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

| Edit this page View Source

RestoreAsync(CancellationToken)

Restores the in-memory state from the most recent snapshot stored on the disk.

Declaration
public ValueTask RestoreAsync(CancellationToken token = default)
Parameters
Type Name Description
CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The task representing asynchronous execution of the method.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

Implements

IAsyncDisposable
IStateMachine
ISnapshotManager

Extension Methods

BasicExtensions.As<T>(T)
BasicExtensions.GetUserData<T>(T)
BasicExtensions.IsBetween<T, TLowerBound, TUpperBound>(T, TLowerBound, TUpperBound)
BasicExtensions.IsOneOf<T>(T, ReadOnlySpan<T>)
ExpressionBuilder.Const<T>(T)
AsyncLockAcquisition.AcquireLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireLockAsync<T>(T, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, bool, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, bool, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, TimeSpan, CancellationToken)
LockAcquisition.AcquireReadLock<T>(T)
LockAcquisition.AcquireReadLock<T>(T, TimeSpan)
LockAcquisition.AcquireUpgradeableReadLock<T>(T)
LockAcquisition.AcquireUpgradeableReadLock<T>(T, TimeSpan)
LockAcquisition.AcquireWriteLock<T>(T)
LockAcquisition.AcquireWriteLock<T>(T, TimeSpan)
  • Edit this page
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾