コード例 #1
0
        void ReadWriteWorker_Completed(object sender, RunWorkerCompletedEventArgs e)
        {
            Print("Read and write average latencies:");
            Sampler sampler = initialConfig ? initialSampler : reconfigSampler;

            Print(DemoLib.PrintReadWriteTimes(sampler));

            readLatency = new List <string>();
            readLatency.Add(sampler.GetSampleValue("strongLatency").ToString("F2").PadLeft(8));
            readLatency.Add(sampler.GetSampleValue("causalLatency").ToString("F2").PadLeft(8));
            readLatency.Add(sampler.GetSampleValue("boundedLatency").ToString("F2").PadLeft(8));
            readLatency.Add(sampler.GetSampleValue("readmywritesLatency").ToString("F2").PadLeft(8));
            readLatency.Add(sampler.GetSampleValue("monotonicLatency").ToString("F2").PadLeft(8));
            readLatency.Add(sampler.GetSampleValue("eventualLatency").ToString("F2").PadLeft(8));

            if (!readAgain)
            {
                readLatencyListBox.DataSource = null;
                readLatencyListBox.DataSource = readLatency;
                readLatencyListBox.ClearSelected();
            }
            else
            {
                readAgainLatencyListBox.DataSource = null;
                readAgainLatencyListBox.DataSource = readLatency;
                readAgainLatencyListBox.ClearSelected();
            }

            if (initialConfig)
            {
                DemoLib.WriteDataFile(sampler);
            }
        }
コード例 #2
0
        public Form1()
        {
            InitializeComponent();

            consistencyChoices = new List <string> {
                "strong consistency",
                "causal consistency",
                "bounded staleness",
                "read my writes",
                "monotonic freshness",
                "eventual consistency"
            };
            consistencyListBox.DataSource = consistencyChoices;
            consistencyListBox.ClearSelected();

            readWriteWorker                     = new BackgroundWorker();
            readWriteWorker.DoWork             += new DoWorkEventHandler(ReadWriteWorker_DoWork);
            readWriteWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(ReadWriteWorker_Completed);

            Print("Running demo program...");
            DemoLib.RegisterLogger(Print);

            //
            // Create initial configuration
            //
            Print("Reading configuration...");
            DemoLib.Initialize();
            Print(DemoLib.PrintCurrentConfiguration());

            // Read sample data from file
            Print("Reading file data...");
            initialSampler  = DemoLib.NewSampler();
            reconfigSampler = DemoLib.NewSampler();
            DemoLib.ReadDataFile(initialSampler);
            Print(DemoLib.PrintReadWriteTimes(initialSampler));

            // Ping servers to measure and record round-trip times in the server state
            Print("Pinging servers...");
            DemoLib.PingAllServers();
            Print("Round-trip latencies to sites:");
            Print(DemoLib.PrintServerRTTs());
        }