Exemplo n.º 1
0
        private void ApplyToStateMachine(int commitIndex, int lastApplied)
        {
            while (commitIndex > lastApplied)
            {
                lastApplied++;
                var log = _log.Get(lastApplied);
                _fsm.Handle(log);
            }

            CurrentState = new CurrentState(CurrentState.Id, CurrentState.CurrentTerm,
                                            CurrentState.VotedFor, commitIndex, lastApplied, CurrentState.LeaderId);
        }
Exemplo n.º 2
0
        private async Task ApplyToStateMachine(int commitIndex, int lastApplied, AppendEntries appendEntries)
        {
            while (commitIndex > lastApplied)
            {
                lastApplied++;
                var log = await _log.Get(lastApplied);

                await _fsm.Handle(log);
            }

            CurrentState = new CurrentState(CurrentState.Id, appendEntries.Term,
                                            CurrentState.VotedFor, commitIndex, lastApplied, CurrentState.LeaderId);
        }
Exemplo n.º 3
0
        private async Task ApplyToStateMachine(int commitIndex, int lastApplied, AppendEntries appendEntries)
        {
            while (commitIndex > lastApplied)
            {
                _logger.LogInformation($"id: {CurrentState.Id} handling log in fsm in loop, commitIndex: {commitIndex}, lastApplied: {lastApplied}, ae.Count: {appendEntries.Entries.Count}");

                lastApplied++;

                var log = await _log.Get(lastApplied);

                await _fsm.Handle(log);
            }

            CurrentState = new CurrentState(CurrentState.Id, appendEntries.Term,
                                            CurrentState.VotedFor, commitIndex, lastApplied, CurrentState.LeaderId);

            _logger.LogInformation($"id: {CurrentState.Id} handling log in fsm out of loop now, commitIndex: {commitIndex}, lastApplied: {lastApplied}, ae.Count: {appendEntries.Entries.Count}");

            _logger.LogInformation($"id: {CurrentState.Id} CurrentState.CommitIndex: {CurrentState.CommitIndex}, CurrentState.LastApplied: {CurrentState.LastApplied}");
        }