Show / Hide Table of Contents

Interface IRaftCluster

Represents cluster of nodes coordinated using Raft consensus protocol.

Inherited Members
IReplicationCluster<IRaftLogEntry>.ReplicateAsync<TEntryImpl>(TEntryImpl, CancellationToken)
IReplicationCluster.ForceReplicationAsync(CancellationToken)
IReplicationCluster.ReplicationCompleted
ICluster.WaitForLeaderAsync(TimeSpan, CancellationToken)
ICluster.ResignAsync(CancellationToken)
ICluster.Leader
ICluster.LeaderChanged
IPeerMesh<IClusterMember>.TryGetPeer(EndPoint)
IPeerMesh.Peers
IPeerMesh.PeerDiscovered
IPeerMesh.PeerGone
Namespace: DotNext.Net.Cluster.Consensus.Raft
Assembly: DotNext.Net.Cluster.dll
Syntax
public interface IRaftCluster : IReplicationCluster<IRaftLogEntry>, IReplicationCluster, ICluster, IPeerMesh<IClusterMember>, IPeerMesh<IRaftClusterMember>, IPeerMesh

Fields

View Source

LocalAddressMeterAttributeName

Represents metrics attribute containing the address of the local node.

Declaration
protected const string LocalAddressMeterAttributeName = "dotnext.raft.server.address"
Field Value
Type Description
string

Properties

View Source

AuditTrail

Defines persistent state for the Raft-based cluster.

Declaration
IPersistentState AuditTrail { get; }
Property Value
Type Description
IPersistentState
View Source

ConsensusToken

Gets a token that remains non-canceled while the local node is a part of the majority of the cluster and has communication with the leader.

Declaration
CancellationToken ConsensusToken { get; }
Property Value
Type Description
CancellationToken
Remarks

The token moves to canceled state if the current node upgrades to the candidate state or loses connection with the leader.

View Source

ElectionTimeout

Gets election timeout used by local cluster member.

Declaration
TimeSpan ElectionTimeout { get; }
Property Value
Type Description
TimeSpan
View Source

LeadershipToken

Gets the token that can be used to track leader state.

Declaration
CancellationToken LeadershipToken { get; }
Property Value
Type Description
CancellationToken
Remarks

The token moves to canceled state if the current node downgrades to the follower state.

View Source

Members

Gets a set of visible cluster members.

Declaration
IReadOnlyCollection<IRaftClusterMember> Members { get; }
Property Value
Type Description
IReadOnlyCollection<IRaftClusterMember>
View Source

Readiness

Represents a task indicating that the current node is ready to serve requests.

Declaration
Task Readiness { get; }
Property Value
Type Description
Task

Methods

View Source

ApplyReadBarrierAsync(ReadBarrierType, CancellationToken)

Ensures linearizable read from underlying state machine.

Declaration
ValueTask ApplyReadBarrierAsync(ReadBarrierType barrierType, CancellationToken token = default)
Parameters
Type Name Description
ReadBarrierType barrierType

Read barrier type. It has effect only when this instance is a leader.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The task representing asynchronous result.

Exceptions
Type Condition
ArgumentOutOfRangeException

barrierType is invalid.

OperationCanceledException

The operation has been canceled.

QuorumUnreachableException

The quorum is not visible to the local node.

View Source

SetConfigurationStorage(IPersistentState, IClusterConfigurationStorage)

Associates the configuration storage with the WAL.

Declaration
protected static void SetConfigurationStorage(IPersistentState auditTrail, IClusterConfigurationStorage configurationStorage)
Parameters
Type Name Description
IPersistentState auditTrail

The WAL implementation.

IClusterConfigurationStorage configurationStorage

The configuration storage.

View Source

TryGetLeaseToken(out CancellationToken)

Tries to get the lease that can be used to perform the read with linearizability guarantees.

Declaration
bool TryGetLeaseToken(out CancellationToken token)
Parameters
Type Name Description
CancellationToken token

The token representing lease.

Returns
Type Description
bool

true if the current node is leader; otherwise, false.

View Source

WaitForLeadershipAsync(CancellationToken)

Waits until the local node is elected as the leader.

Declaration
Task<CancellationToken> WaitForLeadershipAsync(CancellationToken token = default)
Parameters
Type Name Description
CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
Task<CancellationToken>

The leadership token.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

ObjectDisposedException

The local node is disposed.

See Also
LeadershipToken

Extension Methods

BasicExtensions.As<T>(T)
BasicExtensions.IsBetween<T, TLowerBound, TUpperBound>(T, TLowerBound, TUpperBound)
BasicExtensions.IsOneOf<T>(T, params ReadOnlySpan<T>)
RaftClusterExtensions.ApplyReadBarrierAsync(IRaftCluster, CancellationToken)
RaftClusterExtensions.ReplicateAsync(IRaftCluster, ReadOnlyMemory<byte>, object?, CancellationToken)
RaftClusterExtensions.ReplicateAsync<T>(IRaftCluster, T, object?, CancellationToken)
RaftClusterExtensions.ReplicateJsonAsync<T>(IRaftCluster, T, object?, CancellationToken)
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾