Ejemplo n.º 1
0
        /// <summary>
        /// Get an array of values for all buckets in the rolling counter for the given <see cref="HystrixRollingNumberEvent"/> type.
        /// Index 0 is the oldest bucket.
        /// The <see cref="HystrixRollingNumberEvent"/> must be a "Counter" type (HystrixRollingNumberEvent.IsCounter() == true).
        /// </summary>
        /// <param name="type">HystrixRollingNumberEvent defining which counter to retrieve values from</param>
        /// <returns>Array of values from each of the rolling buckets for given <see cref="HystrixRollingNumberEvent"/> counter type</returns>
        public long[] GetValues(HystrixRollingNumberEvent type)
        {
            if (this.GetCurrentBucket() == null)
            {
                return(new long[0]);
            }

            // get buckets as an array (which is a copy of the current state at this point in time)
            Bucket[] bucketArray = this.buckets.GetArray();

            // we have bucket data so we'll return an array of values for all buckets
            long[] values = new long[bucketArray.Length];
            int    i      = 0;

            foreach (Bucket bucket in bucketArray)
            {
                if (type.IsCounter())
                {
                    values[i++] = bucket.GetAdder(type).Sum();
                }
                else if (type.IsMaxUpdater())
                {
                    values[i++] = bucket.GetMaxUpdater(type).Max();
                }
            }

            return(values);
        }
Ejemplo n.º 2
0
            /// <summary>
            /// Gets the <see cref="LongAdder"/> instance for the specified event.
            /// </summary>
            /// <param name="type">The specified event.</param>
            /// <returns>The <see cref="LongAdder"/> instance for the specified event.</returns>
            public LongAdder GetAdder(HystrixRollingNumberEvent type)
            {
                if (!type.IsCounter())
                {
                    throw new ArgumentException(string.Format("Type is not a Counter: {0}", type), "type");
                }

                return(this.adderForCounterType[(int)type]);
            }
Ejemplo n.º 3
0
        public StripedLongAdder GetAdder(HystrixRollingNumberEvent type)
        {
            if (!type.IsCounter())
            {
                throw new InvalidOperationException("Type is not a Counter: " + type);
            }

            return(adderForCounterType[(int)type]);
        }
Ejemplo n.º 4
0
        public long Get(HystrixRollingNumberEvent type)
        {
            if (type.IsCounter())
            {
                return(adderForCounterType[(int)type].GetValue());
            }
            if (type.IsMaxUpdater())
            {
                return(updaterForCounterType[(int)type].Max());
            }

            throw new InvalidOperationException("Unknown type of event: " + type);
        }
Ejemplo n.º 5
0
            /// <summary>
            /// Gets the value for the specified <see cref="HystrixRollingNumberEvent"/> in this bucket.
            /// (Returns <see cref="LongAdder.Sum()"/> for Counter types and <see cref="LongMaxUpdater.Max()"/> for MaxUpdater types.)
            /// </summary>
            /// <param name="type">The specified event.</param>
            /// <returns>The value for the specified event in this bucket.</returns>
            public long Get(HystrixRollingNumberEvent type)
            {
                if (type.IsCounter())
                {
                    return(this.adderForCounterType[(int)type].Sum());
                }

                if (type.IsMaxUpdater())
                {
                    return(this.updaterForCounterType[(int)type].Max());
                }

                throw new ArgumentException(string.Format("Unknown type of event: {0}", type), "type");
            }
Ejemplo n.º 6
0
            /// <summary>
            /// Gets the <see cref="LongAdder"/> instance for the specified event.
            /// </summary>
            /// <param name="type">The specified event.</param>
            /// <returns>The <see cref="LongAdder"/> instance for the specified event.</returns>
            public LongAdder GetAdder(HystrixRollingNumberEvent type)
            {
                if (!type.IsCounter())
                {
                    throw new ArgumentException(string.Format("Type is not a Counter: {0}", type), "type");
                }

                return this.adderForCounterType[(int)type];
            }
Ejemplo n.º 7
0
 /// <summary>
 /// Gets the cumulative value for the specified <see cref="HystrixRollingNumberEvent"/>.
 /// (Returns <see cref="LongAdder.Sum()"/> for Counter types and <see cref="LongMaxUpdater.Max()"/> for MaxUpdater types.)
 /// </summary>
 /// <param name="type">The specified event.</param>
 /// <returns>The cumulative value for the specified event.</returns>
 public long Get(HystrixRollingNumberEvent type)
 {
     if (type.IsCounter())
     {
         return this.adderForCounterType[(int)type].Sum();
     }
     else if (type.IsMaxUpdater())
     {
         return this.updaterForCounterType[(int)type].Max();
     }
     else
     {
         throw new ArgumentException(string.Format("Unknown type of event: {0}", type), "type");
     }
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Get an array of values for all buckets in the rolling counter for the given <see cref="HystrixRollingNumberEvent"/> type.
        /// Index 0 is the oldest bucket.
        /// The <see cref="HystrixRollingNumberEvent"/> must be a "Counter" type (HystrixRollingNumberEvent.IsCounter() == true).
        /// </summary>
        /// <param name="type">HystrixRollingNumberEvent defining which counter to retrieve values from</param>
        /// <returns>Array of values from each of the rolling buckets for given <see cref="HystrixRollingNumberEvent"/> counter type</returns>
        public long[] GetValues(HystrixRollingNumberEvent type)
        {
            if (this.GetCurrentBucket() == null)
            {
                return new long[0];
            }

            // get buckets as an array (which is a copy of the current state at this point in time)
            Bucket[] bucketArray = this.buckets.GetArray();

            // we have bucket data so we'll return an array of values for all buckets
            long[] values = new long[bucketArray.Length];
            int i = 0;
            foreach (Bucket bucket in bucketArray)
            {
                if (type.IsCounter())
                {
                    values[i++] = bucket.GetAdder(type).Sum();
                }
                else if (type.IsMaxUpdater())
                {
                    values[i++] = bucket.GetMaxUpdater(type).Max();
                }
            }

            return values;
        }