Interface IRaftCluster
Represents cluster of nodes coordinated using Raft consensus protocol.
Inherited Members
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 SourceLocalAddressMeterAttributeName
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 SourceAuditTrail
Defines persistent state for the Raft-based cluster.
Declaration
IPersistentState AuditTrail { get; }
Property Value
| Type | Description |
|---|---|
| IPersistentState |
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.
ElectionTimeout
Gets election timeout used by local cluster member.
Declaration
TimeSpan ElectionTimeout { get; }
Property Value
| Type | Description |
|---|---|
| TimeSpan |
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.
Members
Gets a set of visible cluster members.
Declaration
IReadOnlyCollection<IRaftClusterMember> Members { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyCollection<IRaftClusterMember> |
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 SourceApplyReadBarrierAsync(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 |
|
| OperationCanceledException | The operation has been canceled. |
| QuorumUnreachableException | The quorum is not visible to the local node. |
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. |
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 |
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. |