예제 #1
0
 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
 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
 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
 protected virtual bool AddServerReply(Client client, AddServerReply reply)
 {
     return true;
 }
예제 #5
0
 protected override bool AddServerReply(Client client, AddServerReply reply)
 {
     LastMessage = reply;
     LastClient = client;
     return true;
 }