public HystrixRollingPercentile(IDateTimeProvider dateTimeProvider, int timeInMilliseconds, int numberOfBuckets, int bucketDataLength, IHystrixConfigurationService configurationService)
        {
            if (timeInMilliseconds <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(timeInMilliseconds), "Parameter timeInMilliseconds needs to be greater than 0");
            }
            if (numberOfBuckets <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(numberOfBuckets), "Parameter numberOfBuckets needs to be greater than 0");
            }
            if (timeInMilliseconds % numberOfBuckets != 0)
            {
                throw new ArgumentOutOfRangeException(nameof(timeInMilliseconds), "Parameter timeInMilliseconds needs to be an exact multiple of numberOfBuckets");
            }
            if (bucketDataLength < 100)
            {
                throw new ArgumentOutOfRangeException(nameof(bucketDataLength), "Parameter bucketDataLength needs to be greater than or equal to 100");
            }

            this.timeInMilliseconds   = timeInMilliseconds;
            this.numberOfBuckets      = numberOfBuckets;
            this.bucketDataLength     = bucketDataLength;
            this.dateTimeProvider     = dateTimeProvider ?? throw new ArgumentNullException(nameof(dateTimeProvider));
            this.configurationService = configurationService ?? throw new ArgumentNullException(nameof(configurationService));

            bucketSizeInMilliseconds = this.timeInMilliseconds / this.numberOfBuckets;

            buckets = new CircularArray <RollingPercentileBucket>(this.numberOfBuckets);
        }
Example #2
0
        public HystrixRollingNumber(IDateTimeProvider dateTimeProvider, int timeInMilliseconds, int numberOfBuckets)
        {
            if (timeInMilliseconds <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(timeInMilliseconds), "Parameter timeInMilliseconds needs to be greater than 0");
            }
            if (numberOfBuckets <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(numberOfBuckets), "Parameter numberOfBuckets needs to be greater than 0");
            }
            if (timeInMilliseconds % numberOfBuckets != 0)
            {
                throw new ArgumentOutOfRangeException(nameof(timeInMilliseconds), "Parameter timeInMilliseconds needs to be an exact multiple of numberOfBuckets");
            }

            this.dateTimeProvider = dateTimeProvider ?? throw new ArgumentNullException(nameof(dateTimeProvider));

            TimeInMilliseconds      = timeInMilliseconds;
            NumberOfBuckets         = numberOfBuckets;
            BucketSizeInMillseconds = timeInMilliseconds / numberOfBuckets;

            buckets = new CircularArray <RollingNumberBucket>(numberOfBuckets);
        }