public void UpdateServers(string serverId, string serverUrl)
        {
            ServerUrlMapping.AddServerToServerUrlMapping(serverId, serverUrl);

            if (pcsRole == "server")
            {
                server.UpdateServersContext(ServerUrlMapping.serverUrlMapping);
            }
            else if (pcsRole == "client")
            {
                client.UpdateServersContext(ServerUrlMapping.serverUrlMapping);
            }
        }
Exemple #2
0
        private void attachServer(string server_id)
        {
            if (debug_console)
            {
                Console.WriteLine("Attaching to server with id: " + server_id);
            }
            string url = ServerUrlMapping.GetServerUrl(server_id);

            if (debug_console)
            {
                Console.WriteLine("Server URL is: " + url);
            }
            channel            = GrpcChannel.ForAddress(url);
            client             = new DataStoreService.DataStoreServiceClient(channel);
            attached_server_id = server_id;
        }
Exemple #3
0
        private bool HandleCrashedServer(string crashed_server_id)
        {
            Console.WriteLine("--------------------");
            Console.WriteLine(">>> CLIENT: Notify Crash... " + crashed_server_id);
            Console.WriteLine(">>> The server is not responding. It seems to have crashed. ServerID: " + crashed_server_id);
            Console.WriteLine("--------------------");

            if (NotifyPartitionsAboutCrashedServerAndReattachNewMaster(crashed_server_id))
            {
                PartitionMapping.RemoveCrashedServerFromAllPartitions(crashed_server_id);
                ServerUrlMapping.RemoveCrashedServer(crashed_server_id);
                Console.WriteLine("--------------------");
                return(true);
            }

            return(false);
        }
Exemple #4
0
        private void updateConnectionToReplicas(string partition_id)
        {
            string[] replicas = PartitionMapping.GetPartitionReplicas(partition_id);

            foreach (string replica in replicas)
            {
                GrpcChannel channel;

                if (replica_channels.TryGetValue(replica, out channel))
                {
                    channel.ShutdownAsync();
                }

                string url = ServerUrlMapping.GetServerUrl(replica);
                channel = GrpcChannel.ForAddress(url);
                replica_channels[replica] = channel;
                replica_clients[replica]  = new ServerCommunicationService.ServerCommunicationServiceClient(channel);
            }
        }
Exemple #5
0
 public void UpdateServersContext(Dictionary <string, string> serverUrlMapping)
 {
     ServerUrlMapping.CreateServerUrlMapping(serverUrlMapping);
 }