private void InitProtocol() { Uri[] servers = System.IO.File.ReadAllLines(SERVERS_LIST).ToList() .ConvertAll <Uri>(server => new Uri(server)) .Where(server => !server.Equals(this.replicaState.MyUrl)) .ToArray(); IMessage message = new ServerHandShakeRequest(this.replicaState.ServerId, Protocol.StateMachineReplication); IResponses responses = this.messageServiceClient.RequestMulticast(message, servers, 1, Timeout.TIMEOUT_SERVER_HANDSHAKE, true); IResponse[] filteredResponses = responses.ToArray(); // I'm the first server if (filteredResponses.Length == 0) { Log.Info("No servers found for handshake."); this.replicaState.SetNewConfiguration( new SortedDictionary <string, Uri> { { this.replicaState.ServerId, this.replicaState.MyUrl } }, new Uri[] { }, this.replicaState.ViewNumber + 1); this.replicaState.ChangeToNormalState(); return; } // Else multicast joinView to everyone Uri[] configuration = ((ServerHandShakeResponse)filteredResponses[0]).ViewConfiguration; IMessage joinViewMessage = new JoinView(this.replicaState.ServerId, this.replicaState.MyUrl); this.messageServiceClient.RequestMulticast( joinViewMessage, configuration, configuration.Length, Timeout.TIMEOUT_INIT, false); }
public IResponse VisitServerHandShakeRequest(ServerHandShakeRequest serverHandShakeRequest) { return(this.WaitNormalState(serverHandShakeRequest)); }
public IResponse VisitServerHandShakeRequest(ServerHandShakeRequest serverHandShakeRequest) { return(new ServerHandShakeResponse(this.replicaState.Configuration.Values.ToArray())); }