protected override bool AppendEntriesReply(Client client, AppendEntriesReply reply) { return true; }
public bool AppendEntriesReply(AppendEntriesReply reply) { var client = _server.GetClient(reply.From); return AppendEntriesReply(client, reply); }
//protected override AppendEntriesReply? AppendEntriesRequest2(Client client, AppendEntriesRequest request) //{ // var _persistedState = _server.PersistedStore; // if (_persistedState.Term < request.Term) // _persistedState.Term = request.Term; // _server.ChangeState(new FollowerState(_server)); // //TODO: push back in to sequencer // return null; //} protected override bool AppendEntriesReply(Client client, AppendEntriesReply reply) { if (StepDown(reply.Term)) return true; return true; }
protected override bool AppendEntriesReply(Client client, AppendEntriesReply reply) { if (StepDown(reply.Term)) return true; var joiningServer = _serversToAdd.FirstOrDefault(x => x.Client.ID.Equals(client.ID)); if (joiningServer != null) client = joiningServer.Client; if (reply.Success) { client.MatchIndex = Math.Max(client.MatchIndex, reply.MatchIndex); client.NextIndex = reply.MatchIndex + 1; if (client.MatchIndex != _server.CommitIndex) client.NextHeartBeat = 0; //keep streaming until caught up } else { //client.MatchIndex = Math.Max(client.MatchIndex, reply.MatchIndex); client.NextIndex = Math.Max(1, reply.MatchIndex + 1); //client.NextIndex = Math.Max(1, client.NextIndex - 1); client.NextHeartBeat = 0; } //Console.WriteLine("{0}: AppendReply from {1}, took {2}", _server.ID, client.ID, _server.PersistedStore.RPC_TIMEOUT - (client.RpcDue - _server.Tick)); client.RpcDue = 0; if (joiningServer != null && joiningServer.Client.MatchIndex == _server.CommitIndex) { // we are ready, but another change is in progress if (_server.PersistedStore.ConfigLocked) { // reset the rounds because we are waiting for the config file to be free // this should keep the server getting heart beats joiningServer.Round = 10; } else { //_server.AddClientFromLog(client.ID); _server.PersistedStore.AddServer(_server, client.ID); RemoveServerJoin(client); } } return true; }
//protected abstract AppendEntriesReply? AppendEntriesRequest2(Client client, AppendEntriesRequest request) //; ////{ //// return null; ////} protected abstract bool AppendEntriesReply(Client client, AppendEntriesReply reply);
public void SendAppendEntriesReply(uint matchIndex, bool success) { var _persistedState = _server.PersistedStore; var message = new AppendEntriesReply() { From = _server.ID, Term = _persistedState.Term, MatchIndex = matchIndex, Success = success }; _lastMessage = message; _server.Transport.SendMessage(this, message); }
public void SendReply(Peer peer, AppendEntriesReply reply) { SendMessage(peer, reply); }
protected override bool AppendEntriesReply(Client client, AppendEntriesReply reply) { LastMessage = reply; LastClient = client; return true; }
protected override bool AppendEntriesReply(Client client, AppendEntriesReply reply) { var _persistedState = _server.PersistedStore; if (_persistedState.Term < reply.Term) _persistedState.Term = reply.Term; return true; }
protected void handleAppendEntriesReply(IConsensus model, AppendEntriesReply reply) { if (_persistedState.Term < reply.Term) stepDown(model, reply.Term); if (_state == ServerState.Leader && _persistedState.Term == reply.Term) { var peer = _peers.First(x => x.ID == reply.From); if (reply.Success) { peer.MatchIndex = Math.Max(peer.MatchIndex, reply.MatchIndex); peer.NextIndex = reply.MatchIndex + 1; } else { peer.NextIndex = Math.Max(1, peer.NextIndex - 1); } peer.RpcDue = 0; } }