/* package for testing */
        internal HystrixRollingNumber(ITime time, int timeInMilliseconds, int numberOfBuckets)
        {
            this.time = time;
            this.timeInMilliseconds = timeInMilliseconds;
            this.numberOfBuckets    = numberOfBuckets;

            if (timeInMilliseconds % numberOfBuckets != 0)
            {
                throw new ArgumentException("The timeInMilliseconds must divide equally into numberOfBuckets. For example 1000/10 is ok, 1000/11 is not.");
            }
            this.bucketSizeInMillseconds = timeInMilliseconds / numberOfBuckets;

            buckets = new BucketCircularArray(numberOfBuckets);
        }
 public ListState(BucketCircularArray cb, AtomicReferenceArray <Bucket> data, int head, int tail)
 {
     this.cb   = cb;
     this.head = head;
     this.tail = tail;
     if (head == 0 && tail == 0)
     {
         size = 0;
     }
     else
     {
         this.size = (tail + cb.dataLength - head) % cb.dataLength;
     }
     this.data = data;
 }
                public ListState(BucketCircularArray ca, AtomicReferenceArray <Bucket> data, int head, int tail)
                {
                    this._ca   = ca;
                    this._head = head;
                    this._tail = tail;
                    if (head == 0 && tail == 0)
                    {
                        _size = 0;
                    }
                    else
                    {
                        this._size = (tail + ca.dataLength - head) % ca.dataLength;
                    }

                    this._data = data;
                }
                public ListState(BucketCircularArray cb, AtomicReferenceArray <Bucket> data, int head, int tail)
                {
                    _cb         = cb;
                    _head       = head;
                    _buckettail = tail;
                    if (head == 0 && tail == 0)
                    {
                        _size = 0;
                    }
                    else
                    {
                        _size = (tail + cb._dataLength - head) % cb._dataLength;
                    }

                    _data = data;
                }
        /* package for testing */
        internal HystrixRollingPercentile(ITime time, int timeInMilliseconds, int numberOfBuckets, int bucketDataLength, bool enabled)
        {
            this.time = time;
            this.timeInMilliseconds = timeInMilliseconds;
            this.numberOfBuckets    = numberOfBuckets;
            this.bucketDataLength   = bucketDataLength;
            this.enabled            = enabled;

            if (this.timeInMilliseconds % this.numberOfBuckets != 0)
            {
                throw new ArgumentException("The timeInMilliseconds must divide equally into numberOfBuckets. For example 1000/10 is ok, 1000/11 is not.");
            }
            this.bucketSizeInMilliseconds = this.timeInMilliseconds / this.numberOfBuckets;

            buckets = new BucketCircularArray(this.numberOfBuckets);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="HystrixRollingPercentile"/> class.
        /// </summary>
        /// <param name="time">The <see cref="ITime"/> instance to measure time.</param>
        /// <param name="timeInMilliseconds">Number of milliseconds of data that should be tracked.</param>
        /// <param name="numberOfBuckets">Number of buckets that the time window should be divided into.</param>
        /// <param name="bucketDataLength">Number of values stored in each bucket.</param>
        /// <param name="enabled">Sets whether data should be tracked and percentiles be calculated.</param>
        internal HystrixRollingPercentile(ITime time, IHystrixProperty<int> timeInMilliseconds, IHystrixProperty<int> numberOfBuckets, IHystrixProperty<int> bucketDataLength, IHystrixProperty<bool> enabled)
        {
            if (timeInMilliseconds.Get() % numberOfBuckets.Get() != 0)
            {
                throw new ArgumentException("The timeInMilliseconds must divide equally into numberOfBuckets. For example 1000/10 is ok, 1000/11 is not.");
            }

            this.time = time;
            this.timeInMilliseconds = timeInMilliseconds;
            this.numberOfBuckets = numberOfBuckets;
            this.bucketDataLength = bucketDataLength;
            this.enabled = enabled;
            this.buckets = new BucketCircularArray<Bucket>(this.numberOfBuckets.Get());
        }
Beispiel #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RollingNumber"/> class.
        /// </summary>
        /// <param name="time">The <see cref="ITime"/> instance to measure time.</param>
        /// <param name="timeInMilliseconds">The total time window to track.</param>
        /// <param name="numberOfBuckets">The number of parts to break the time window.</param>
        private RollingNumber(ITime time, IProperty<int> timeInMilliseconds, IProperty<int> numberOfBuckets)
        {
            this.time = time;
            this.timeInMilliseconds = timeInMilliseconds;
            this.numberOfBuckets = numberOfBuckets;

            if (timeInMilliseconds.Get() % numberOfBuckets.Get() != 0)
            {
                throw new ArgumentException("The timeInMilliseconds must divide equally into numberOfBuckets. For example 1000/10 is ok, 1000/11 is not.");
            }

            this.buckets = new BucketCircularArray<Bucket>(numberOfBuckets.Get());
        }