示例#1
0
        private void updateMeetingLocationsOnAllServers()
        {
            String con = "";

            foreach (MeetingLocation mloc in meetingLocations)
            {
                con += mloc.encodeSOAP() + "#";
            }

            foreach (String url in urlServers.Values)
            {
                Uri          myUri = new Uri(url);
                Task         task;
                String       psURLHost = myUri.Host;
                int          psURLPort = myUri.Port + 200;
                PuppetServer ps        = (PuppetServer)Activator.GetObject(typeof(PuppetServer), "http://" + psURLHost + ":" + psURLPort + "/ps");
                if (con.Length > 1)
                {
                    String conCorrected = con.Remove(con.Length - 1);


                    task = Task.Factory.StartNew(() => ps.updateLocations(conCorrected));
                    task.Wait();
                }
            }
        }
示例#2
0
        private void getStat()
        {
            foreach (String url in urlServers.Values)
            {
                Uri myUri = new Uri(url);

                String       psURLHost = myUri.Host;
                int          psURLPort = myUri.Port + 200;
                PuppetServer ps        = (PuppetServer)Activator.GetObject(typeof(PuppetServer), "http://" + psURLHost + ":" + psURLPort + "/ps");
                Task         task      = Task.Factory.StartNew(() => ps.status());
                task.Wait();
            }
        }
示例#3
0
        private void Unfreez(string servID)
        {
            urlServers.TryGetValue(servID, out String url);

            Uri myUri = new Uri(url);

            String psURLHost = myUri.Host;
            int    psURLPort = myUri.Port + 200;

            PuppetServer ps   = (PuppetServer)Activator.GetObject(typeof(PuppetServer), "http://" + psURLHost + ":" + psURLPort + "/ps");
            Task         task = Task.Factory.StartNew(() => ps.unfreeze());

            task.Wait();
        }
示例#4
0
        private void addServer(string serverID, string URL, int maxFaults, int minDelay, int maxDelay)
        {
            PCSService pCs;
            Uri        myUri = new Uri(URL);

            IPAddress[] hostIPs = Dns.GetHostAddresses(myUri.Host);
            Task        task;



            // get local IP addresses
            IPAddress[] localIPs = Dns.GetHostAddresses(Dns.GetHostName());
            // test if any host IP is a loopback IP or is equal to any local IP


            if (hostIPs.Any(hostIP => IPAddress.IsLoopback(hostIP) || localIPs.Contains(hostIP))) // we can directly create the server because is
            {
                var process = new Process
                {
                    StartInfo = new ProcessStartInfo
                    {
                        FileName  = Directory.GetCurrentDirectory() + @"..\..\..\..\Server\bin\Debug\Server",
                        Arguments = serverID + "'" + URL + "'" + maxFaults + "'" + minDelay + "'" + maxDelay,
                    }
                };

                process.Start();
                sProcesses.Add(serverID, process);
            }
            else
            {
                pCs  = (PCSService)Activator.GetObject(typeof(PCSService), myUri.Scheme + Uri.SchemeDelimiter + myUri.Host + ":10000");
                task = Task.Factory.StartNew(() => pCs.createServerProcess(serverID, URL, maxFaults, minDelay, maxDelay));
                task.Wait();
            }
            String psURLHost = myUri.Host;
            int    psURLPort = myUri.Port + 200;

            Console.WriteLine("serverID: " + serverID + " URL: " + URL);
            PuppetServer ps = (PuppetServer)Activator.GetObject(typeof(PuppetServer), "http://" + psURLHost + ":" + psURLPort + "/ps");

            foreach (KeyValuePair <String, String> server in urlServers)
            {
                task = Task.Factory.StartNew(() => ps.initializeView(server.Key, server.Value));
                task.Wait();
            }
            urlServers.Add(serverID, URL);

            String con = "";

            foreach (MeetingLocation mloc in meetingLocations)
            {
                con += mloc.encodeSOAP() + "#";
            }
            if (con.Length > 1)
            {
                con = con.Remove(con.Length - 1);
                ps.updateLocations(con);
            }
            task = Task.Factory.StartNew(() => ps.addServerToView(serverID, URL));
            task.Wait();

            serverNo++;
            addServerId.Text = "server" + serverNo.ToString().PadLeft(2, '0');
            addURL.Text      = "tcp://localhost:80" + serverNo.ToString().PadLeft(2, '0') + "/mcm";
        }