Пример #1
0
        public override async Task <ChangeReply> ChangeMasterNotification(ChangeNotificationRequest request, ServerCallContext context)
        {
            WaitUnfreeze();
            await _gigaStorage.ChangeMasterNotificationAsync(request.ServerId, request.NewServerId, request.PartitionId);

            return(await Task.FromResult(new ChangeReply
            {
                // Empty message as ack
            }));
        }
Пример #2
0
        // Notifies server_id that down_server_id is down and that the new master of the partions of down_server_id is new_server
        public void ChangeMasterNotificationRequest(string server, string down_server, string new_server, string partition)
        {
            Console.WriteLine("Notifying server: " + server + " about down server " + down_server + " with new " + new_server + " for partition " + partition);
            ChangeNotificationRequest changeNotificationRequest = new ChangeNotificationRequest {
                ServerId = down_server, NewServerId = new_server, PartitionId = partition
            };
            string s = server;

            new Thread(() => ThreadNotification(s, changeNotificationRequest)).Start();
        }
Пример #3
0
 public override Task <ChangeNotificationResponse> Notify(ChangeNotificationRequest request,
                                                          ServerCallContext context)
 {
     _logger.LogInformation(request.Value);
     _timestamps.Add(request.Value);
     _hub.Clients.All.SendAsync("onChanged", new Notification {
         Body = request.Value
     });
     _logger.LogInformation($"Pushed onChanged ({request.Value}) via SignalR");
     return(Task.FromResult(new ChangeNotificationResponse()));
 }
Пример #4
0
 public void ThreadNotification(string server, ChangeNotificationRequest request)
 {
     try
     {
         _clients[server].ChangeMasterNotificationAsync(request);
     }
     catch
     {
         // If fails then the server is down
         DeadServerReport(ServerId);
     }
 }