Class RaftCluster
Represents default implementation of Raft-based cluster.
Implements
Inherited Members
Namespace: DotNext.Net.Cluster.Consensus.Raft
Assembly: DotNext.Net.Cluster.dll
Syntax
public class RaftCluster : RaftCluster<RaftClusterMember>, IDisposable, IUnresponsiveClusterMemberRemovalSupport, IStandbyModeSupport, IRaftCluster, IReplicationCluster<IRaftLogEntry>, IReplicationCluster, ICluster, IPeerMesh<IClusterMember>, IPeerMesh<IRaftClusterMember>, IPeerMesh, IAsyncDisposable
Constructors
| Edit this page View SourceRaftCluster(NodeConfiguration)
Initializes a new default implementation of Raft-based cluster.
Declaration
public RaftCluster(RaftCluster.NodeConfiguration configuration)
Parameters
Type | Name | Description |
---|---|---|
RaftCluster.NodeConfiguration | configuration | The configuration of the cluster. |
Properties
| Edit this page View SourceConfigurationStorage
Gets configuration storage.
Declaration
protected override sealed IClusterConfigurationStorage<EndPoint> ConfigurationStorage { get; }
Property Value
Type | Description |
---|---|
IClusterConfigurationStorage<EndPoint> |
Overrides
| Edit this page View SourceLocalMemberAddress
Gets the address of the local member.
Declaration
public EndPoint LocalMemberAddress { get; }
Property Value
Type | Description |
---|---|
EndPoint |
Logger
Gets logger used by this object.
Declaration
protected override ILogger Logger { get; }
Property Value
Type | Description |
---|---|
ILogger |
Overrides
Methods
| Edit this page View SourceAddMemberAsync(EndPoint, CancellationToken)
Announces a new member in the cluster.
Declaration
public Task<bool> AddMemberAsync(EndPoint address, CancellationToken token = default)
Parameters
Type | Name | Description |
---|---|---|
EndPoint | address | The addres of the cluster member. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
Task<bool> | true if the node has been added to the cluster successfully; false if the node rejects the replication or the address of the node cannot be committed. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled or the cluster elects a new leader. |
DetectLocalMemberAsync(RaftClusterMember, CancellationToken)
Determines whether the specified candidate represents a local node.
Declaration
protected override ValueTask<bool> DetectLocalMemberAsync(RaftClusterMember candidate, CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
RaftClusterMember | candidate | The candidate to check. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask<bool> | true if |
Overrides
| Edit this page View SourceDispose(bool)
Releases managed and unmanaged resources associated with this object.
Declaration
protected override void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
bool | disposing | true if called from Dispose(); false if called from finalizer ~Disposable(). |
Overrides
| Edit this page View SourceRemoveMemberAsync(EndPoint, CancellationToken)
Removes the member from the cluster.
Declaration
public Task<bool> RemoveMemberAsync(EndPoint address, CancellationToken token = default)
Parameters
Type | Name | Description |
---|---|---|
EndPoint | address | The cluster member to remove. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
Task<bool> | true if the node has been removed from the cluster successfully; false if the node rejects the replication or the address of the node cannot be committed. |
StartAsync(CancellationToken)
Starts serving local member.
Declaration
public override Task StartAsync(CancellationToken token = default)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | token | The token that can be used to cancel initialization process. |
Returns
Type | Description |
---|---|
Task | The task representing asynchronous execution of the method. |
Overrides
| Edit this page View SourceStopAsync(CancellationToken)
Stops serving local member.
Declaration
public override Task StopAsync(CancellationToken token = default)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | token | The token that can be used to cancel shutdown process. |
Returns
Type | Description |
---|---|
Task | The task representing asynchronous execution of the method. |
Overrides
| Edit this page View SourceUnavailableMemberDetected(RaftClusterMember, CancellationToken)
Notifies that the member is unavailable.
Declaration
protected override sealed ValueTask UnavailableMemberDetected(RaftClusterMember member, CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
RaftClusterMember | member | The member that is considered as unavailable. |
CancellationToken | token | The token associated with LeadershipToken that identifies the leader state at the time of detection. |
Returns
Type | Description |
---|---|
ValueTask | The task representing asynchronous result. |
Overrides
Remarks
It's an infrastructure method that can be used to remove unavailable member from the cluster configuration at the leader side.