Show / Hide Table of Contents

Class ConsensusOnlyState

Represents lightweight Raft node state that is suitable for distributed consensus only.

Inheritance
object
Disposable
ConsensusOnlyState
Implements
IDisposable
IPersistentState
IAuditTrail<IRaftLogEntry>
IAuditTrail
Inherited Members
Disposable.Dispose()
Disposable.Dispose(IEnumerable<IDisposable>)
Disposable.DisposeAsync(IEnumerable<IAsyncDisposable>)
Disposable.Dispose<T>(ReadOnlySpan<T>)
Disposable.DisposeAsync(params IAsyncDisposable[])
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: DotNext.Net.Cluster.Consensus.Raft
Assembly: DotNext.Net.Cluster.dll
Syntax
public sealed class ConsensusOnlyState : Disposable, IDisposable, IPersistentState, IAuditTrail<IRaftLogEntry>, IAuditTrail
Remarks

The actual state doesn't persist on disk and exists only in memory. Moreover, this implementation cannot append non-empty log entries.

Properties

| Edit this page View Source

LastCommittedEntryIndex

Gets the index of the last committed log entry.

Declaration
public long LastCommittedEntryIndex { get; }
Property Value
Type Description
long
| Edit this page View Source

LastEntryIndex

Gets the index of the last uncommitted log entry.

Declaration
public long LastEntryIndex { get; }
Property Value
Type Description
long
| Edit this page View Source

Term

Reads Term value associated with the local member from the persistent storage.

Declaration
public long Term { get; }
Property Value
Type Description
long

The term restored from persistent storage.

Methods

| Edit this page View Source

CommitAsync(long, CancellationToken)

Commits log entries into the underlying storage and marks these entries as committed.

Declaration
public ValueTask<long> CommitAsync(long endIndex, CancellationToken token)
Parameters
Type Name Description
long endIndex

The index of the last entry to commit, inclusively.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask<long>

The actual number of committed entries.

Remarks

This method should update cached value provided by method LastCommittedEntryIndex called with argument of value true. Additionally, it may force log compaction and squash all committed entries into the single entry called snapshot.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

| Edit this page View Source

Dispose(bool)

Releases all resources associated with this audit trail.

Declaration
protected override void Dispose(bool disposing)
Parameters
Type Name Description
bool disposing

Indicates whether the Dispose(bool) has been called directly or from finalizer.

Overrides
Disposable.Dispose(bool)
| Edit this page View Source

ReadAsync<TResult>(ILogEntryConsumer<IRaftLogEntry, TResult>, long, long, CancellationToken)

Reads the range of the log entries from this storage.

Declaration
public ValueTask<TResult> ReadAsync<TResult>(ILogEntryConsumer<IRaftLogEntry, TResult> reader, long startIndex, long endIndex, CancellationToken token)
Parameters
Type Name Description
ILogEntryConsumer<IRaftLogEntry, TResult> reader

The reader over log entries.

long startIndex

The index of the first log entry to retrieve.

long endIndex

The index of the last log entry to retrieve, inclusive.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask<TResult>

The result of the transformation applied to the range of the log entries.

Type Parameters
Name Description
TResult

The type of the result.

| Edit this page View Source

ReadAsync<TResult>(ILogEntryConsumer<IRaftLogEntry, TResult>, long, CancellationToken)

Reads the log entries starting at the specified index to the end of the log.

Declaration
public ValueTask<TResult> ReadAsync<TResult>(ILogEntryConsumer<IRaftLogEntry, TResult> reader, long startIndex, CancellationToken token)
Parameters
Type Name Description
ILogEntryConsumer<IRaftLogEntry, TResult> reader

The reader over log entries.

long startIndex

The index of the first log entry to retrieve.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask<TResult>

The result of the transformation applied to the range of the log entries.

Type Parameters
Name Description
TResult

The type of the result.

Implements

IDisposable
IPersistentState
IAuditTrail<TEntry>
IAuditTrail

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)
Command.AppendAsync<TCommand>(IPersistentState, TCommand, object?, CancellationToken)
PersistentStateExtensions.AppendAsync(IPersistentState, ReadOnlyMemory<byte>, object?, CancellationToken)
PersistentStateExtensions.AppendAsync<T>(IPersistentState, T, object?, CancellationToken)
PersistentStateExtensions.AppendJsonAsync<T>(IPersistentState, T, object?, CancellationToken)
  • Edit this page
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾