Пример #1
0
        public virtual void TestAccumulate()
        {
            Configuration conf = new Configuration();

            conf.Set("ns." + DecayRpcScheduler.IpcCallqueueDecayschedulerPeriodKey, "99999999"
                     );
            // Never flush
            scheduler = new DecayRpcScheduler(1, "ns", conf);
            Assert.Equal(0, scheduler.GetCallCountSnapshot().Count);
            // empty first
            scheduler.GetPriorityLevel(MockCall("A"));
            Assert.Equal(1, scheduler.GetCallCountSnapshot()["A"]);
            Assert.Equal(1, scheduler.GetCallCountSnapshot()["A"]);
            scheduler.GetPriorityLevel(MockCall("A"));
            scheduler.GetPriorityLevel(MockCall("B"));
            scheduler.GetPriorityLevel(MockCall("A"));
            Assert.Equal(3, scheduler.GetCallCountSnapshot()["A"]);
            Assert.Equal(1, scheduler.GetCallCountSnapshot()["B"]);
        }
Пример #2
0
        public virtual void TestDecay()
        {
            Configuration conf = new Configuration();

            conf.Set("ns." + DecayRpcScheduler.IpcCallqueueDecayschedulerPeriodKey, "999999999"
                     );
            // Never
            conf.Set("ns." + DecayRpcScheduler.IpcCallqueueDecayschedulerFactorKey, "0.5");
            scheduler = new DecayRpcScheduler(1, "ns", conf);
            Assert.Equal(0, scheduler.GetTotalCallSnapshot());
            for (int i = 0; i < 4; i++)
            {
                scheduler.GetPriorityLevel(MockCall("A"));
            }
            for (int i_1 = 0; i_1 < 8; i_1++)
            {
                scheduler.GetPriorityLevel(MockCall("B"));
            }
            Assert.Equal(12, scheduler.GetTotalCallSnapshot());
            Assert.Equal(4, scheduler.GetCallCountSnapshot()["A"]);
            Assert.Equal(8, scheduler.GetCallCountSnapshot()["B"]);
            scheduler.ForceDecay();
            Assert.Equal(6, scheduler.GetTotalCallSnapshot());
            Assert.Equal(2, scheduler.GetCallCountSnapshot()["A"]);
            Assert.Equal(4, scheduler.GetCallCountSnapshot()["B"]);
            scheduler.ForceDecay();
            Assert.Equal(3, scheduler.GetTotalCallSnapshot());
            Assert.Equal(1, scheduler.GetCallCountSnapshot()["A"]);
            Assert.Equal(2, scheduler.GetCallCountSnapshot()["B"]);
            scheduler.ForceDecay();
            Assert.Equal(1, scheduler.GetTotalCallSnapshot());
            Assert.Equal(null, scheduler.GetCallCountSnapshot()["A"]);
            Assert.Equal(1, scheduler.GetCallCountSnapshot()["B"]);
            scheduler.ForceDecay();
            Assert.Equal(0, scheduler.GetTotalCallSnapshot());
            Assert.Equal(null, scheduler.GetCallCountSnapshot()["A"]);
            Assert.Equal(null, scheduler.GetCallCountSnapshot()["B"]);
        }