Пример #1
0
        public CrashedReplicaPMACK RemoveCrashedReplica_aux(CrashedReplicaPM request)
        {
            //propagate to each server
            foreach (Server s in servList)
            {
                CrashedReplicaServer crashed_replica = new CrashedReplicaServer();
                crashed_replica.Partitionid = request.Partitionid;
                foreach (String serv_id in request.Serverid)
                {
                    crashed_replica.Serverid.Add(serv_id);
                }
                AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
                GrpcChannel channel = GrpcChannel.ForAddress(s.getURL());
                var         serv    = new GStoreServices.GStoreServicesClient(channel);
                serv.RemoveCrashedReplica(crashed_replica);
            }

            //propagate to each client
            foreach (Client c in cliList)
            {
                CrashedReplicaClient crashed_replica = new CrashedReplicaClient();
                crashed_replica.Partitionid = request.Partitionid;
                foreach (String serv_id in request.Serverid)
                {
                    crashed_replica.Serverid.Add(serv_id);
                }
                AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
                GrpcChannel channel = GrpcChannel.ForAddress(c.getURL());
                var         client  = new ClientServices.ClientServicesClient(channel);
                client.RemoveCrashedReplicaClient(crashed_replica);
            }
            return(new CrashedReplicaPMACK {
            });
        }
Пример #2
0
        private void sendPartitionToServer(string server_id)
        {
            Console.WriteLine("Sending the partition to the server...");
#pragma warning disable CS0436 // Type conflicts with imported type
            CompletePartition complete_partition = new CompletePartition();
#pragma warning restore CS0436 // Type conflicts with imported type
            foreach (Partition p in this.partList)
            {
                Console.WriteLine($"Found partition: {p.getName()}");
#pragma warning disable CS0436 // Type conflicts with imported type
                PartitionInfo part = new PartitionInfo();
#pragma warning restore CS0436 // Type conflicts with imported type
                part.Partitionid = p.getName();
                foreach ((string s, bool b) in p.getServIDs())
                {
                    foreach (Server serv in this.servList)
                    {
                        if (serv.getID() == s)
                        {
                            Console.WriteLine($"Valur of server id: {serv.getID()}");
                            //add server info to message
#pragma warning disable CS0436 // Type conflicts with imported type
                            part.Servers.Add(new ServerInfo
#pragma warning restore CS0436 // Type conflicts with imported type
                            {
                                Serverid = s,
                                Url      = serv.getURL(),
                                Mindelay = serv.getMin(),
                                Maxdelay = serv.getMax(),
                                Ismaster = b
                            });
                        }
                    }
                }
                complete_partition.Partitions.Add(part);
            }

            //send partition to every server
            foreach (Server serv in this.servList)
            {
                if (serv.getID() == server_id)
                {
                    AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
                    GrpcChannel channel = GrpcChannel.ForAddress(serv.getURL());
                    GStoreServices.GStoreServicesClient client = new GStoreServices.GStoreServicesClient(channel);
                    client.ReceivePartitionInfo(complete_partition);
                }
            }
        }
Пример #3
0
        public void propagateCrash(string server_id)
        {
            Console.WriteLine("*****************************************************");
            Console.WriteLine("Puppet Master is propagating crash...");
            Console.WriteLine("*****************************************************");
            //propagate to the servers
            foreach (Server s in this.servList)
            {
                Console.WriteLine($"Server {s.getID()}....");
                if (s.getID() != server_id)
                {
                    //do client to server and propagate
                    AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
                    GrpcChannel channel = GrpcChannel.ForAddress(s.getURL());
                    var         client  = new GStoreServices.GStoreServicesClient(channel);
                    client.ServerCrasedServer(new ServerCrashedID
                    {
                        Serverid = server_id
                    });
                }
            }
            Console.WriteLine("Propagating to clients....");
            //propagate to the clients

            foreach (Client c in this.cliList)
            {
                //do client to server and propagate
                AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
                GrpcChannel channel = GrpcChannel.ForAddress(c.getURL());
                var         client  = new ClientServices.ClientServicesClient(channel);
                client.ServerCrasedClient(new ServerCrashedClientID
                {
                    Serverclientid = server_id
                });
            }
        }