public RaftEngineOptions(NodeConnectionInfo connection, StorageEnvironmentOptions storageOptions, ITransport transport, IRaftStateMachine stateMachine) { if (connection == null) { throw new ArgumentNullException("connection"); } if (String.IsNullOrWhiteSpace(connection.Name)) { throw new ArgumentNullException("connection.Name"); } if (storageOptions == null) { throw new ArgumentNullException("storageOptions"); } if (transport == null) { throw new ArgumentNullException("transport"); } if (stateMachine == null) { throw new ArgumentNullException("stateMachine"); } SelfConnection = connection; StorageOptions = storageOptions; Transport = transport; StateMachine = stateMachine; ElectionTimeout = 1200; HeartbeatTimeout = 300; Stopwatch = new Stopwatch(); MaxLogLengthBeforeCompaction = 32 * 1024; MaxStepDownDrainTime = TimeSpan.FromSeconds(15); MaxEntriesPerRequest = 256; }
internal LeaderState(IRaftStateMachine stateMachine, bool allowPartitioning, long term) : base(stateMachine) { currentTerm = term; this.allowPartitioning = allowPartitioning; timerCancellation = new CancellationTokenSource(); forcedReplication = new AsyncManualResetEvent(false); }
internal LeaderState(IRaftStateMachine stateMachine, bool allowPartitioning, long term) : base(stateMachine) { currentTerm = term; this.allowPartitioning = allowPartitioning; timerCancellation = new CancellationTokenSource(); processingState = new AtomicBoolean(false); }
internal LeaderState(IRaftStateMachine stateMachine, bool allowPartitioning, long term) : base(stateMachine) { currentTerm = term; this.allowPartitioning = allowPartitioning; timerCancellation = new(); replicationEvent = new(); replicationQueue = new(); precedingTermCache = new TermCache(MaxTermCacheSize); }
/// <summary> /// Initializes a new instance of the <see cref="RaftNode"/> class. /// </summary> /// <param name="nodeId">The node's ID</param> /// <param name="stateMachine"><see cref="IRaftStateMachine"/> to replicate</param> public RaftNode(uint nodeId, IRaftStateMachine stateMachine) { this.NodeId = nodeId; this.StateMachine = stateMachine; this.Log = new List <LogEntry>(); electionTimer = new Timer(TriggerElection); heartbeatTimer = new Timer(SendHeartbeats); NextIndex = new Dictionary <uint, int>(); MatchIndex = new Dictionary <uint, int>(); }
public RaftEngineOptions(NodeConnectionInfo connection, StorageEnvironmentOptions storageOptions, ITransport transport, IRaftStateMachine stateMachine) { if (connection == null) throw new ArgumentNullException("connection"); if (String.IsNullOrWhiteSpace(connection.Name)) throw new ArgumentNullException("connection.Name"); if (storageOptions == null) throw new ArgumentNullException("storageOptions"); if (transport == null) throw new ArgumentNullException("transport"); if (stateMachine == null) throw new ArgumentNullException("stateMachine"); SelfConnection = connection; StorageOptions = storageOptions; Transport = transport; StateMachine = stateMachine; ElectionTimeout = 1200; HeartbeatTimeout = 300; Stopwatch = new Stopwatch(); MaxLogLengthBeforeCompaction = 32 * 1024; MaxStepDownDrainTime = TimeSpan.FromSeconds(15); MaxEntriesPerRequest = 256; }
internal CandidateState(IRaftStateMachine stateMachine, long term) : base(stateMachine) { votingCancellation = new CancellationTokenSource(); Term = term; }
internal FollowerState(IRaftStateMachine stateMachine) : base(stateMachine) { refreshEvent = new AsyncAutoResetEvent(false); trackerCancellation = new CancellationTokenSource(); }
private protected RaftState(IRaftStateMachine stateMachine) => this.stateMachine = stateMachine;
internal StandbyState(IRaftStateMachine stateMachine) : base(stateMachine) { }
internal FollowerState(IRaftStateMachine stateMachine) : base(stateMachine) { refreshEvent = new AutoResetEvent(false); }