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
| Edit this page 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
| Edit this page View SourceAuditTrail
Defines persistent state for the Raft-based cluster.
Declaration
IPersistentState AuditTrail { get; set; }
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 |
Term
Gets term number used by Raft algorithm to check the consistency of the cluster.
Declaration
long Term { get; }
Property Value
Type | Description |
---|---|
long |
Methods
| Edit this page View SourceApplyReadBarrierAsync(CancellationToken)
Ensures linearizable read from underlying state machine.
Declaration
ValueTask ApplyReadBarrierAsync(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 result. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
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(TimeSpan, CancellationToken)
Waits until the local node is elected as the leader.
Declaration
ValueTask<CancellationToken> WaitForLeadershipAsync(TimeSpan timeout, CancellationToken token = default)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | timeout | The time to wait; or InfiniteTimeSpan. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask<CancellationToken> | The leadership token. |
Exceptions
Type | Condition |
---|---|
TimeoutException | The operation is timed out. |
OperationCanceledException | The operation has been canceled. |
ObjectDisposedException | The local node is disposed. |