private async Task <ClusterInfo> SendGossipAsync(ClusterInfo clusterInfo, EndPoint server, DateTime deadline) { var request = new GossipRequest { Info = ClusterInfo.ToGrpcClusterInfo(clusterInfo), Server = new GossipEndPoint(server.GetHost(), (uint)server.GetPort()) }; var clusterInfoDto = await _gossipClient.UpdateAsync(request, deadline : deadline.ToUniversalTime()); return(ClusterInfo.FromGrpcClusterInfo(clusterInfoDto)); }
public bool HasChangedSince(ClusterInfo other) { if (ReferenceEquals(null, other)) return true; if (ReferenceEquals(this, other)) return false; if (other.Members.Length != Members.Length) return true; for (int i = 0; i < Members.Length; i++) { if (!Members[i].Equals(other.Members[i])) return true; } return false; }
public static EventStore.Cluster.ClusterInfo ToGrpcClusterInfo(ClusterInfo cluster) { var members = Array.ConvertAll(cluster.Members, x => new EventStore.Cluster.MemberInfo { InstanceId = Uuid.FromGuid(x.InstanceId).ToDto(), TimeStamp = x.TimeStamp.ToTicksSinceEpoch(), State = (EventStore.Cluster.MemberInfo.Types.VNodeState)x.State, IsAlive = x.IsAlive, HttpEndPoint = new EventStore.Cluster.EndPoint( x.HttpEndPoint.GetHost(), (uint)x.HttpEndPoint.GetPort()), InternalTcp = x.InternalSecureTcpEndPoint != null ? new EventStore.Cluster.EndPoint( x.InternalSecureTcpEndPoint.GetHost(), (uint)x.InternalSecureTcpEndPoint.GetPort()) : new EventStore.Cluster.EndPoint( x.InternalTcpEndPoint.GetHost(), (uint)x.InternalTcpEndPoint.GetPort()), InternalTcpUsesTls = x.InternalSecureTcpEndPoint != null, ExternalTcp = x.ExternalSecureTcpEndPoint != null ? new EventStore.Cluster.EndPoint( x.ExternalSecureTcpEndPoint.GetHost(), (uint)x.ExternalSecureTcpEndPoint.GetPort()) : x.ExternalTcpEndPoint != null ? new EventStore.Cluster.EndPoint( x.ExternalTcpEndPoint.GetHost(), (uint)x.ExternalTcpEndPoint.GetPort()) : null, ExternalTcpUsesTls = x.ExternalSecureTcpEndPoint != null, LastCommitPosition = x.LastCommitPosition, WriterCheckpoint = x.WriterCheckpoint, ChaserCheckpoint = x.ChaserCheckpoint, EpochPosition = x.EpochPosition, EpochNumber = x.EpochNumber, EpochId = Uuid.FromGuid(x.EpochId).ToDto(), NodePriority = x.NodePriority, IsReadOnlyReplica = x.IsReadOnlyReplica, AdvertiseHostToClientAs = x.AdvertiseHostToClientAs ?? "", AdvertiseHttpPortToClientAs = (uint)x.AdvertiseHttpPortToClientAs, AdvertiseTcpPortToClientAs = (uint)x.AdvertiseTcpPortToClientAs }).ToArray(); var info = new EventStore.Cluster.ClusterInfo(); info.Members.AddRange(members); return(info); }
private async Task SendPrepareOkAsync(int view, Guid serverId, EndPoint serverHttpEndPoint, int epochNumber, long epochPosition, Guid epochId, Guid epochLeaderInstanceId, long lastCommitPosition, long writerCheckpoint, long chaserCheckpoint, int nodePriority, ClusterInfo clusterInfo, DateTime deadline) { var request = new PrepareOkRequest { View = view, ServerId = Uuid.FromGuid(serverId).ToDto(), ServerHttp = new GossipEndPoint(serverHttpEndPoint.GetHost(), (uint)serverHttpEndPoint.GetPort()), EpochNumber = epochNumber, EpochPosition = epochPosition, EpochId = Uuid.FromGuid(epochId).ToDto(), EpochLeaderInstanceId = Uuid.FromGuid(epochLeaderInstanceId).ToDto(), LastCommitPosition = lastCommitPosition, WriterCheckpoint = writerCheckpoint, ChaserCheckpoint = chaserCheckpoint, NodePriority = nodePriority, ClusterInfo = ClusterInfo.ToGrpcClusterInfo(clusterInfo) }; await _electionsClient.PrepareOkAsync(request, deadline : deadline.ToUniversalTime()); }
public ClusterInfoDto(ClusterInfo clusterInfo, IPEndPoint serverEndPoint) { Members = clusterInfo.Members.Select(x => new MemberInfoDto(x)).ToArray(); ServerIp = serverEndPoint.Address.ToString(); ServerPort = serverEndPoint.Port; }
private async Task <ClusterInfo> GetGossipAsync(DateTime deadline) { var clusterInfoDto = await _gossipClient.ReadAsync(new Empty(), deadline : deadline.ToUniversalTime()); return(ClusterInfo.FromGrpcClusterInfo(clusterInfoDto)); }
public ClientClusterInfo(ClusterInfo clusterInfo, string serverIp, int serverPort) { Members = clusterInfo.Members.Select(x => new ClientMemberInfo(x)).ToArray(); ServerIp = serverIp; ServerPort = serverPort; }
public GossipUpdated(ClusterInfo clusterInfo) { ClusterInfo = clusterInfo; }
public SendGossip(ClusterInfo clusterInfo, IPEndPoint serverEndPoint) { ClusterInfo = clusterInfo; ServerEndPoint = serverEndPoint; }
public GossipReceived(IEnvelope envelope, ClusterInfo clusterInfo, IPEndPoint server) { Envelope = envelope; ClusterInfo = clusterInfo; Server = server; }