GetRollingMaxValue() public method

public GetRollingMaxValue ( RollingNumberEvent ev, long startWindowTime = 0L ) : long
ev RollingNumberEvent
startWindowTime long
return long
 public void testEmptyMax()
 {
     MockedClock time = new MockedClock();
     RollingNumberEvent type = RollingNumberEvent.THREAD_MAX_ACTIVE;
     RollingNumber counter = new RollingNumber(time, 200, 10);
     Assert.Equal(0, counter.GetRollingMaxValue(type));
 }
        public void testUpdateMax2()
        {
            MockedClock time = new MockedClock();

            RollingNumber counter = new RollingNumber(time, 200, 10);

            // increment
            counter.UpdateRollingMax(RollingNumberEvent.THREAD_MAX_ACTIVE, 10);
            counter.UpdateRollingMax(RollingNumberEvent.THREAD_MAX_ACTIVE, 30);
            counter.UpdateRollingMax(RollingNumberEvent.THREAD_MAX_ACTIVE, 20);

            // we should have 1 bucket
            var buckets = counter.GetBuckets().ToArray();
            Assert.Equal(1, buckets.Length);

            // the count should be 30
            Assert.Equal(30, counter.buckets.First().GetMaxUpdater(RollingNumberEvent.THREAD_MAX_ACTIVE));
            Assert.Equal(30, counter.GetRollingMaxValue(RollingNumberEvent.THREAD_MAX_ACTIVE));

            // sleep to get to a new bucket
            time.Increment(counter.BucketSizeInMs * 3);

            counter.UpdateRollingMax(RollingNumberEvent.THREAD_MAX_ACTIVE, 30);
            counter.UpdateRollingMax(RollingNumberEvent.THREAD_MAX_ACTIVE, 30);
            counter.UpdateRollingMax(RollingNumberEvent.THREAD_MAX_ACTIVE, 50);

            // we should have 2 buckets
            buckets = counter.GetBuckets().ToArray();
            Assert.Equal(2, buckets.Length);
        
            // the count
            Assert.Equal(50, buckets.First().GetMaxUpdater(RollingNumberEvent.THREAD_MAX_ACTIVE));
            Assert.Equal(50, counter.GetValueOfLatestBucket(RollingNumberEvent.THREAD_MAX_ACTIVE));

            // values per bucket
            var values = counter.GetValues(RollingNumberEvent.THREAD_MAX_ACTIVE).ToArray();
            Assert.Equal(30, values[1]); // oldest bucket
            Assert.Equal(50, values[0]); // latest bucket
        }
        public void testMaxValue()
        {
            MockedClock time = new MockedClock();

            RollingNumberEvent type = RollingNumberEvent.THREAD_MAX_ACTIVE;

            RollingNumber counter = new RollingNumber(time, 200, 10);

            counter.UpdateRollingMax(type, 10);

            // sleep to get to a new bucket
            time.Increment(counter.BucketSizeInMs);

            counter.UpdateRollingMax(type, 30);

            // sleep to get to a new bucket
            time.Increment(counter.BucketSizeInMs);

            counter.UpdateRollingMax(type, 40);

            // sleep to get to a new bucket
            time.Increment(counter.BucketSizeInMs);

            counter.UpdateRollingMax(type, 15);

            Assert.Equal(40, counter.GetRollingMaxValue(type));

        }
Ejemplo n.º 4
0
 public long GetRollingMaxConcurrentExecutions()
 {
     return(_counter.GetRollingMaxValue(RollingNumberEvent.COMMAND_MAX_ACTIVE));
 }