コード例 #1
0
ファイル: JoinState.cs プロジェクト: cphillips83/Raft.NET
 protected override bool AddServerReply(Client client, AddServerReply reply)
 {
     if (client == null)
         Console.WriteLine("{0}: Server {1} replied with not leader and doesn't know who is the leader", _server.Name, reply.From);
     else
     {
         //try again, playing catch up or not leader
         //client should be derived from leader hint
         if (reply.Status == AddServerStatus.TimedOut || reply.Status == AddServerStatus.NotLeader)
         {
             _bootstrap = client;
             resetHeartbeat();
             Console.WriteLine("{0}: Server {1} replied with not leader or timedout and suggest {2}", _server.Name, reply.From, reply.From);
         }
         else
         {
             //ok, we were added! switch to follower
             //client list should be up to date via the log entries
             Console.WriteLine("{0}: Server {1} replied with OK", _server.Name, reply.From);
             _server.ChangeState(new FollowerState(_server));
         }
     }
     return true;
 }
コード例 #2
0
ファイル: AbstractState.cs プロジェクト: cphillips83/Raft.NET
 public bool AddServerReply(AddServerReply reply)
 {
     if (reply.Status == AddServerStatus.NotLeader && reply.LeaderHint == null)
     {
         return AddServerReply(null, reply);
     }
     else
     {
         var client = new Client(_server, reply.LeaderHint);
         return AddServerReply(client, reply);
     }
 }
コード例 #3
0
ファイル: Client.cs プロジェクト: cphillips83/Raft.NET
 public void SendAddServerReply(AddServerStatus status, IPEndPoint leaderHint)
 {
     Console.WriteLine("{0}: Sending add server reply to {1} with status {2}", _server.Name, ID, status);
     var message = new AddServerReply()
     {
         From = _server.ID,
         Status = status,
         LeaderHint = leaderHint,
     };
     _lastMessage = message;
     _server.Transport.SendMessage(this, message);
 }
コード例 #4
0
ファイル: AbstractState.cs プロジェクト: cphillips83/Raft.NET
 protected virtual bool AddServerReply(Client client, AddServerReply reply)
 {
     return true;
 }
コード例 #5
0
ファイル: TestState.cs プロジェクト: cphillips83/Raft.NET
 protected override bool AddServerReply(Client client, AddServerReply reply)
 {
     LastMessage = reply;
     LastClient = client;
     return true;
 }