Example #1
0
        public static void PingAllServers()
        {
            List <string> allServers = config.GetServers();
            Stopwatch     watch      = new Stopwatch();

            for (int pingCount = 0; pingCount < 5; pingCount++)
            {
                foreach (string server in allServers)
                {
                    CloudBlobClient blobClient = ClientRegistry.GetCloudBlobClient(server);
                    if (blobClient != null)
                    {
                        CloudBlobContainer blobContainer = blobClient.GetContainerReference(containerName);
                        //Log("Pinging " + SiteName(server) + " aka " + server + "...");
                        watch.Restart();
                        //we perform a dummy operation to get the rtt latency!
                        try
                        {
                            bool ok = blobContainer.Exists();
                        }
                        catch (StorageException se)
                        {
                            Log("Storage exception when pinging " + SiteName(server) + ": " + se.Message);
                        }
                        long        el = watch.ElapsedMilliseconds;
                        ServerState ss = container.Monitor.GetServerState(server);
                        ss.AddRtt(el);
                        //Log("Pinged " + SiteName(server) + " in " + el + " milliseconds");
                    }
                    else
                    {
                        Log("Failed to ping " + SiteName(server));
                    }
                }
            }
        }
Example #2
0
        private void buttonGetLatency_Click(object sender, EventArgs e)
        {
            ServerMonitor        monitor     = DemoLib.GetServerMonitor();
            ReplicaConfiguration config      = DemoLib.GetCurrentConfiguration();
            List <string>        allServers  = config.GetServers();
            List <string>        siteNames   = new List <string>();
            List <string>        siteLatency = new List <string>();

            foreach (string server in allServers)
            {
                ServerState ss = monitor.GetServerState(server);
                siteNames.Add(DemoLib.SiteName(server));
                siteLatency.Add(ss.RTTs.FindAverage().ToString("F0").PadLeft(5));
            }

            listBoxLatencySites.DataSource = null;
            listBoxLatencySites.DataSource = siteNames;
            listBoxLatencySites.ClearSelected();
            listBoxLatencyTimes.DataSource = null;
            listBoxLatencyTimes.DataSource = siteLatency;
            listBoxLatencyTimes.ClearSelected();
        }