Interface IRaftClusterMember
Represents cluster member accessible through Raft protocol.
Inherited Members
Namespace: DotNext.Net.Cluster.Consensus.Raft
Assembly: DotNext.Net.Cluster.dll
Syntax
public interface IRaftClusterMember : IClusterMember, IPeer
Fields
| Edit this page View SourceMessageTypeAttributeName
Represents metrics attribute containing Raft message type.
Declaration
protected const string MessageTypeAttributeName = "dotnext.raft.client.message"
Field Value
Type | Description |
---|---|
string |
RemoteAddressMeterAttributeName
Represents metrics attribute containing the address of the local node.
Declaration
protected const string RemoteAddressMeterAttributeName = "dotnext.raft.client.address"
Field Value
Type | Description |
---|---|
string |
Properties
| Edit this page View SourceState
Gets a reference to the replication state.
Declaration
ref IRaftClusterMember.ReplicationState State { get; }
Property Value
Type | Description |
---|---|
IRaftClusterMember.ReplicationState |
Remarks
Implementing class should provide memory storage for IRaftClusterMember.ReplicationState type without any special semantics.
Methods
| Edit this page View SourceAppendEntriesAsync<TEntry, TList>(long, TList, long, long, long, IClusterConfiguration, bool, CancellationToken)
Transfers log entries to the member.
Declaration
Task<Result<HeartbeatResult>> AppendEntriesAsync<TEntry, TList>(long term, TList entries, long prevLogIndex, long prevLogTerm, long commitIndex, IClusterConfiguration config, bool applyConfig, CancellationToken token) where TEntry : IRaftLogEntry where TList : IReadOnlyList<TEntry>
Parameters
Type | Name | Description |
---|---|---|
long | term | Term value maintained by local cluster member. |
TList | entries | A set of entries to be replicated with this node. |
long | prevLogIndex | Index of log entry immediately preceding new ones. |
long | prevLogTerm | Term of |
long | commitIndex | Last entry known to be committed by the local node. |
IClusterConfiguration | config | The list of cluster members. |
bool | applyConfig | true to inform that the receiver must apply previously proposed configuration; false to propose a new configuration. |
CancellationToken | token | The token that can be used to cancel asynchronous operation. |
Returns
Type | Description |
---|---|
Task<Result<HeartbeatResult>> | The processing result. |
Type Parameters
Name | Description |
---|---|
TEntry | The type of the log entry. |
TList | The type of the log entries list. |
Exceptions
Type | Condition |
---|---|
MemberUnavailableException | The member is unreachable through the network. |
CancelPendingRequestsAsync()
Aborts all active outbound requests asynchronously.
Declaration
ValueTask CancelPendingRequestsAsync()
Returns
Type | Description |
---|---|
ValueTask | The task representing shutdown operation. |
InstallSnapshotAsync(long, IRaftLogEntry, long, CancellationToken)
Installs the snapshot of the log to this cluster member.
Declaration
Task<Result<HeartbeatResult>> InstallSnapshotAsync(long term, IRaftLogEntry snapshot, long snapshotIndex, CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
long | term | Leader's term. |
IRaftLogEntry | snapshot | The log entry representing the snapshot. |
long | snapshotIndex | The index of the last included log entry in the snapshot. |
CancellationToken | token | The token that can be used to cancel asynchronous operation. |
Returns
Type | Description |
---|---|
Task<Result<HeartbeatResult>> | The processing result. |
Exceptions
Type | Condition |
---|---|
MemberUnavailableException | The member is unreachable through the network. |
PreVoteAsync(long, long, long, CancellationToken)
Checks whether the transition to Candidate state makes sense.
Declaration
Task<Result<PreVoteResult>> PreVoteAsync(long term, long lastLogIndex, long lastLogTerm, CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
long | term | Term value maintained by local cluster member. |
long | lastLogIndex | Index of candidate's last log entry. |
long | lastLogTerm | Term of candidate's last log entry. |
CancellationToken | token | The token that can be used to cancel asynchronous operation. |
Returns
Type | Description |
---|---|
Task<Result<PreVoteResult>> | Pre-vote result received from the member. |
Remarks
Called by a server before changing itself to Candidate status. If a majority of servers return true, proceed to Candidate. Otherwise, wait for another election timeout.
See Also
| Edit this page View SourceSynchronizeAsync(long, CancellationToken)
Starts a new round of heartbeats.
Declaration
Task<long?> SynchronizeAsync(long commitIndex, CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
long | commitIndex | The index of the last committed log entry. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
Task<long?> | The index of the last committed log entry; or null if the member is not a leader. |
Exceptions
Type | Condition |
---|---|
MemberUnavailableException | The member is unreachable through the network. |
VoteAsync(long, long, long, CancellationToken)
Requests vote from the member.
Declaration
Task<Result<bool>> VoteAsync(long term, long lastLogIndex, long lastLogTerm, CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
long | term | Term value maintained by local cluster member. |
long | lastLogIndex | Index of candidate's last log entry. |
long | lastLogTerm | Term of candidate's last log entry. |
CancellationToken | token | The token that can be used to cancel asynchronous operation. |
Returns
Type | Description |
---|---|
Task<Result<bool>> | Vote received from the member; true if node accepts new leader, false if node doesn't accept new leader. |