Show / Hide Table of Contents

Class RaftCluster

Represents default implementation of Raft-based cluster.

Inheritance
object
Disposable
RaftCluster<RaftClusterMember>
RaftCluster
Implements
IDisposable
IUnresponsiveClusterMemberRemovalSupport
IStandbyModeSupport
IRaftCluster
IReplicationCluster<IRaftLogEntry>
IReplicationCluster
ICluster
IPeerMesh<IClusterMember>
IPeerMesh<IRaftClusterMember>
IPeerMesh
IAsyncDisposable
Inherited Members
RaftCluster<RaftClusterMember>.FailureDetectorFactory
RaftCluster<RaftClusterMember>.EndPointComparer
RaftCluster<RaftClusterMember>.ElectionTimeout
RaftCluster<RaftClusterMember>.Readiness
RaftCluster<RaftClusterMember>.TryGetLeaseToken(out CancellationToken)
RaftCluster<RaftClusterMember>.LeadershipToken
RaftCluster<RaftClusterMember>.ConsensusToken
RaftCluster<RaftClusterMember>.AuditTrail
RaftCluster<RaftClusterMember>.LifecycleToken
RaftCluster<RaftClusterMember>.Members
RaftCluster<RaftClusterMember>.Term
RaftCluster<RaftClusterMember>.LeaderChanged
RaftCluster<RaftClusterMember>.ReplicationCompleted
RaftCluster<RaftClusterMember>.Leader
RaftCluster<RaftClusterMember>.WaitForLeaderAsync(TimeSpan, CancellationToken)
RaftCluster<RaftClusterMember>.WaitForLeadershipAsync(TimeSpan, CancellationToken)
RaftCluster<RaftClusterMember>.StartFollowing()
RaftCluster<RaftClusterMember>.RevertToNormalModeAsync(CancellationToken)
RaftCluster<RaftClusterMember>.EnableStandbyModeAsync(CancellationToken)
RaftCluster<RaftClusterMember>.Standby
RaftCluster<RaftClusterMember>.InstallSnapshotAsync<TSnapshot>(ClusterMemberId, long, TSnapshot, long, CancellationToken)
RaftCluster<RaftClusterMember>.AppendEntriesAsync<TEntry>(ClusterMemberId, long, ILogEntryProducer<TEntry>, long, long, long, IClusterConfiguration, bool, CancellationToken)
RaftCluster<RaftClusterMember>.PreVoteAsync(ClusterMemberId, long, long, long, CancellationToken)
RaftCluster<RaftClusterMember>.VoteAsync(ClusterMemberId, long, long, long, CancellationToken)
RaftCluster<RaftClusterMember>.ResignAsync(CancellationToken)
RaftCluster<RaftClusterMember>.SynchronizeAsync(long, CancellationToken)
RaftCluster<RaftClusterMember>.ApplyReadBarrierAsync(CancellationToken)
RaftCluster<RaftClusterMember>.ForceReplicationAsync(CancellationToken)
RaftCluster<RaftClusterMember>.ReplicateAsync<TEntry>(TEntry, CancellationToken)
RaftCluster<RaftClusterMember>.DisposeAsyncCore()
RaftCluster<RaftClusterMember>.DisposeAsync()
RaftCluster<RaftClusterMember>.TryGetMember(ClusterMemberId)
RaftCluster<RaftClusterMember>.MemberAdded
RaftCluster<RaftClusterMember>.MemberRemoved
RaftCluster<RaftClusterMember>.AddMemberAsync(RaftClusterMember, CancellationToken)
RaftCluster<RaftClusterMember>.RemoveMemberAsync(ClusterMemberId, CancellationToken)
RaftCluster<RaftClusterMember>.AddMemberAsync<TAddress>(RaftClusterMember, int, IClusterConfigurationStorage<TAddress>, Func<RaftClusterMember, TAddress>, CancellationToken)
RaftCluster<RaftClusterMember>.RemoveMemberAsync<TAddress>(ClusterMemberId, IClusterConfigurationStorage<TAddress>, Func<RaftClusterMember, TAddress>, CancellationToken)
Disposable.IsDisposed
Disposable.IsDisposing
Disposable.IsDisposingOrDisposed
Disposable.CreateException()
Disposable.DisposedTask
Disposable.GetDisposedTask<T>()
Disposable.TrySetDisposedException<T>(TaskCompletionSource<T>)
Disposable.TrySetDisposedException(TaskCompletionSource)
Disposable.TryBeginDispose()
Disposable.Dispose()
Disposable.Dispose(IEnumerable<IDisposable>)
Disposable.DisposeAsync(IEnumerable<IAsyncDisposable>)
Disposable.Dispose<T>(ReadOnlySpan<T>)
Disposable.DisposeAsync(params IAsyncDisposable[])
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
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 Source

RaftCluster(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 Source

ConfigurationStorage

Gets configuration storage.

Declaration
protected override sealed IClusterConfigurationStorage<EndPoint> ConfigurationStorage { get; }
Property Value
Type Description
IClusterConfigurationStorage<EndPoint>
Overrides
RaftCluster<RaftClusterMember>.ConfigurationStorage
| Edit this page View Source

LocalMemberAddress

Gets the address of the local member.

Declaration
public EndPoint LocalMemberAddress { get; }
Property Value
Type Description
EndPoint
| Edit this page View Source

Logger

Gets logger used by this object.

Declaration
protected override ILogger Logger { get; }
Property Value
Type Description
ILogger
Overrides
RaftCluster<RaftClusterMember>.Logger

Methods

| Edit this page View Source

AddMemberAsync(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.

| Edit this page View Source

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 candidate represents a local node; otherwise, false.

Overrides
RaftCluster<RaftClusterMember>.DetectLocalMemberAsync(RaftClusterMember, CancellationToken)
| Edit this page View Source

Dispose(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
RaftCluster<RaftClusterMember>.Dispose(bool)
| Edit this page View Source

RemoveMemberAsync(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.

| Edit this page View Source

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
RaftCluster<RaftClusterMember>.StartAsync(CancellationToken)
| Edit this page View Source

StopAsync(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
RaftCluster<RaftClusterMember>.StopAsync(CancellationToken)
| Edit this page View Source

UnavailableMemberDetected(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
RaftCluster<RaftClusterMember>.UnavailableMemberDetected(RaftClusterMember, CancellationToken)
Remarks

It's an infrastructure method that can be used to remove unavailable member from the cluster configuration at the leader side.

Implements

IDisposable
IUnresponsiveClusterMemberRemovalSupport
IStandbyModeSupport
IRaftCluster
IReplicationCluster<TEntry>
IReplicationCluster
ICluster
IPeerMesh<TPeer>
IPeerMesh<TPeer>
IPeerMesh
IAsyncDisposable

Extension Methods

RaftClusterExtensions.ReplicateAsync(IRaftCluster, ReadOnlyMemory<byte>, object?, CancellationToken)
RaftClusterExtensions.ReplicateAsync<T>(IRaftCluster, T, object?, CancellationToken)
RaftClusterExtensions.ReplicateJsonAsync<T>(IRaftCluster, T, object?, CancellationToken)
BasicExtensions.As<T>(T)
BasicExtensions.GetUserData<T>(T)
BasicExtensions.IsBetween<T, TLowerBound, TUpperBound>(T, TLowerBound, TUpperBound)
BasicExtensions.IsOneOf<T>(T, ReadOnlySpan<T>)
ExpressionBuilder.Const<T>(T)
AsyncLockAcquisition.AcquireLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireLockAsync<T>(T, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, bool, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, bool, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, TimeSpan, CancellationToken)
LockAcquisition.AcquireReadLock<T>(T)
LockAcquisition.AcquireReadLock<T>(T, TimeSpan)
LockAcquisition.AcquireUpgradeableReadLock<T>(T)
LockAcquisition.AcquireUpgradeableReadLock<T>(T, TimeSpan)
LockAcquisition.AcquireWriteLock<T>(T)
LockAcquisition.AcquireWriteLock<T>(T, TimeSpan)
  • Edit this page
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾