public override async Task <Empty> Prepare(PrepareRequest request, ServerCallContext context) { var user = context.GetHttpContext().User; if (!await _authorizationProvider.CheckAccessAsync(user, PrepareOperation, context.CancellationToken).ConfigureAwait(false)) { throw AccessDenied(); } _bus.Publish(new ElectionMessage.Prepare( Uuid.FromDto(request.ServerId).ToGuid(), new DnsEndPoint(request.ServerHttp.Address, (int)request.ServerHttp.Port), request.View)); return(EmptyResult); }
public override async Task <Empty> LeaderIsResigning(LeaderIsResigningRequest request, ServerCallContext context) { var user = context.GetHttpContext().User; if (!await _authorizationProvider.CheckAccessAsync(user, MasterIsResigningOperation, context.CancellationToken).ConfigureAwait(false)) { throw RpcExceptions.AccessDenied(); } _bus.Publish(new ElectionMessage.LeaderIsResigning( Uuid.FromDto(request.LeaderId).ToGuid(), new DnsEndPoint(request.LeaderHttp.Address, (int)request.LeaderHttp.Port))); return(EmptyResult); }
public static ClusterInfo FromGrpcClusterInfo(EventStore.Cluster.ClusterInfo grpcCluster) { var receivedMembers = Array.ConvertAll(grpcCluster.Members.ToArray(), x => new MemberInfo( Uuid.FromDto(x.InstanceId).ToGuid(), x.TimeStamp.FromTicksSinceEpoch(), (VNodeState)x.State, x.IsAlive, new IPEndPoint(IPAddress.Parse(x.InternalTcp.Address), (int)x.InternalTcp.Port), new IPEndPoint(IPAddress.Parse(x.ExternalTcp.Address), (int)x.ExternalTcp.Port), new IPEndPoint(IPAddress.Parse(x.InternalHttp.Address), (int)x.InternalHttp.Port), new IPEndPoint(IPAddress.Parse(x.ExternalHttp.Address), (int)x.ExternalHttp.Port), x.LastCommitPosition, x.WriterCheckpoint, x.ChaserCheckpoint, x.EpochPosition, x.EpochNumber, Uuid.FromDto(x.EpochId).ToGuid(), x.NodePriority, x.IsReadOnlyReplica )).ToArray(); return(new ClusterInfo(receivedMembers)); }
private async Task Subscribe() { try { while (await _call.ResponseStream.MoveNext().ConfigureAwait(false) && !_disposed.IsCancellationRequested) { var current = _call.ResponseStream.Current; switch (current.ContentCase) { case ReadResp.ContentOneofCase.Event: try { await _eventAppeared(this, ConvertToResolvedEvent(current), current.Event.CountCase switch { ReadResp.Types.ReadEvent.CountOneofCase.RetryCount => current.Event.RetryCount, _ => default }, _disposed.Token).ConfigureAwait(false); if (_autoAck) { await AckInternal(Uuid.FromDto(current.Event.Link?.Id ?? current.Event.Event.Id)).ConfigureAwait(false); } } catch (Exception ex) when(ex is ObjectDisposedException || ex is OperationCanceledException) { SubscriptionDropped(SubscriptionDroppedReason.Disposed); return; } catch (Exception ex) { try { SubscriptionDropped(SubscriptionDroppedReason.SubscriberError, ex); } finally { _disposed.Cancel(); } return; } break; }
public static ClusterInfo FromGrpcClusterInfo(EventStore.Cluster.ClusterInfo grpcCluster) { var receivedMembers = Array.ConvertAll(grpcCluster.Members.ToArray(), x => new MemberInfo( Uuid.FromDto(x.InstanceId).ToGuid(), x.TimeStamp.FromTicksSinceEpoch(), (VNodeState)x.State, x.IsAlive, !x.InternalTcpUsesTls ? new DnsEndPoint(x.InternalTcp.Address, (int)x.InternalTcp.Port) : null, x.InternalTcpUsesTls ? new DnsEndPoint(x.InternalTcp.Address, (int)x.InternalTcp.Port) : null, !x.ExternalTcpUsesTls && x.ExternalTcp != null ? new DnsEndPoint(x.ExternalTcp.Address, (int)x.ExternalTcp.Port) : null, x.ExternalTcpUsesTls && x.ExternalTcp != null ? new DnsEndPoint(x.ExternalTcp.Address, (int)x.ExternalTcp.Port) : null, new DnsEndPoint(x.HttpEndPoint.Address, (int)x.HttpEndPoint.Port), x.AdvertiseHostToClientAs, (int)x.AdvertiseHttpPortToClientAs, (int)x.AdvertiseTcpPortToClientAs, x.LastCommitPosition, x.WriterCheckpoint, x.ChaserCheckpoint, x.EpochPosition, x.EpochNumber, Uuid.FromDto(x.EpochId).ToGuid(), x.NodePriority, x.IsReadOnlyReplica )).ToArray(); return(new ClusterInfo(receivedMembers)); }
public override async Task <Empty> PrepareOk(PrepareOkRequest request, ServerCallContext context) { var user = context.GetHttpContext().User; if (!await _authorizationProvider.CheckAccessAsync(user, PrepareOkOperation, context.CancellationToken).ConfigureAwait(false)) { throw AccessDenied(); } _bus.Publish(new ElectionMessage.PrepareOk( request.View, Uuid.FromDto(request.ServerId).ToGuid(), new DnsEndPoint(request.ServerHttp.Address, (int)request.ServerHttp.Port), request.EpochNumber, request.EpochPosition, Uuid.FromDto(request.EpochId).ToGuid(), Uuid.FromDto(request.EpochLeaderInstanceId).ToGuid(), request.LastCommitPosition, request.WriterCheckpoint, request.ChaserCheckpoint, request.NodePriority, ClusterInfo.FromGrpcClusterInfo(request.ClusterInfo))); return(EmptyResult); }