コード例 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HystrixThreadPoolMetrics"/> class.
 /// </summary>
 /// <param name="threadPoolKey">The key of the parent thread pool.</param>
 /// <param name="threadPool">The <see cref="ThreadPoolExecutor"/> of the parent thread pool.</param>
 /// <param name="properties">The properties of the parent thread pool.</param>
 private HystrixThreadPoolMetrics(HystrixThreadPoolKey threadPoolKey, ThreadPoolExecutor threadPool, IHystrixThreadPoolProperties properties)
 {
     this.threadPoolKey = threadPoolKey;
     this.threadPool    = threadPool;
     this.properties    = properties;
     this.counter       = new HystrixRollingNumber(properties.MetricsRollingStatisticalWindowInMilliseconds, properties.MetricsRollingStatisticalWindowBuckets);
 }
コード例 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HystrixThreadPoolMetrics"/> class.
 /// </summary>
 /// <param name="threadPoolKey">The key of the parent thread pool.</param>
 /// <param name="threadPool">The <see cref="ThreadPoolExecutor"/> of the parent thread pool.</param>
 /// <param name="properties">The properties of the parent thread pool.</param>
 private HystrixThreadPoolMetrics(HystrixThreadPoolKey threadPoolKey, ThreadPoolExecutor threadPool, IHystrixThreadPoolProperties properties)
 {
     this.threadPoolKey = threadPoolKey;
     this.threadPool = threadPool;
     this.properties = properties;
     this.counter = new HystrixRollingNumber(properties.MetricsRollingStatisticalWindowInMilliseconds, properties.MetricsRollingStatisticalWindowBuckets);
 }
コード例 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HystrixThreadPoolDefault"/> class.
        /// </summary>
        /// <param name="threadPoolKey">The key of this thread pool.</param>
        /// <param name="setter">The default properties of this thread pool.</param>
        public HystrixThreadPoolDefault(HystrixThreadPoolKey threadPoolKey, HystrixThreadPoolPropertiesSetter setter)
        {
            this.properties = HystrixPropertiesFactory.GetThreadPoolProperties(threadPoolKey, setter);
            this.queue      = HystrixPlugins.Instance.ConcurrencyStrategy.GetBlockingQueue(this.properties.MaxQueueSize.Get());
            this.threadPool = HystrixPlugins.Instance.ConcurrencyStrategy.GetThreadPool(threadPoolKey, this.properties.CoreSize, this.properties.CoreSize, this.properties.KeepAliveTime, this.queue);
            this.metrics    = HystrixThreadPoolMetrics.GetInstance(threadPoolKey, this.threadPool, this.properties);

            HystrixMetricsPublisherFactory.CreateOrRetrievePublisherForThreadPool(threadPoolKey, this.metrics, this.properties);
        }
コード例 #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HystrixThreadPoolDefault"/> class.
        /// </summary>
        /// <param name="threadPoolKey">The key of this thread pool.</param>
        /// <param name="setter">The default properties of this thread pool.</param>
        public HystrixThreadPoolDefault(HystrixThreadPoolKey threadPoolKey, HystrixThreadPoolPropertiesSetter setter)
        {
            this.properties = HystrixPropertiesFactory.GetThreadPoolProperties(threadPoolKey, setter);
            this.queue = HystrixPlugins.Instance.ConcurrencyStrategy.GetBlockingQueue(this.properties.MaxQueueSize.Get());
            this.threadPool = HystrixPlugins.Instance.ConcurrencyStrategy.GetThreadPool(threadPoolKey, this.properties.CoreSize, this.properties.CoreSize, this.properties.KeepAliveTime, this.queue);
            this.metrics = HystrixThreadPoolMetrics.GetInstance(threadPoolKey, this.threadPool, this.properties);

            HystrixMetricsPublisherFactory.CreateOrRetrievePublisherForThreadPool(threadPoolKey, this.metrics, this.properties);
        }
コード例 #5
0
        /// <summary>
        /// Produces JSON formatted metrics data from an instance of <see cref="HystrixThreadPoolMetrics"/>.
        /// </summary>
        /// <param name="threadPoolMetrics">The metrics of a thread pool.</param>
        /// <returns>JSON formatted metrics data.</returns>
        private static string CreateThreadPoolSampleData(HystrixThreadPoolMetrics threadPoolMetrics)
        {
            IHystrixThreadPoolProperties properties = threadPoolMetrics.Properties;

            JObject data = new JObject(
                new JProperty("type", "HystrixThreadPool"),
                new JProperty("name", threadPoolMetrics.ThreadPoolKey.Name),
                new JProperty("currentTime", GetCurrentTimeForJavascript()),
                new JProperty("currentActiveCount", threadPoolMetrics.CurrentActiveCount),
                new JProperty("currentCompletedTaskCount", threadPoolMetrics.CurrentCompletedTaskCount),
                new JProperty("currentCorePoolSize", threadPoolMetrics.CurrentCorePoolSize),
                new JProperty("currentLargestPoolSize", threadPoolMetrics.CurrentLargestPoolSize),
                new JProperty("currentMaximumPoolSize", threadPoolMetrics.CurrentMaximumPoolSize),
                new JProperty("currentPoolSize", threadPoolMetrics.CurrentPoolSize),
                new JProperty("currentQueueSize", threadPoolMetrics.CurrentQueueSize),
                new JProperty("currentTaskCount", threadPoolMetrics.CurrentTaskCount),
                new JProperty("rollingCountThreadsExecuted", threadPoolMetrics.RollingCountThreadsExecuted),
                new JProperty("rollingMaxActiveThreads", threadPoolMetrics.RollingMaxActiveThreads),
                new JProperty("propertyValue_queueSizeRejectionThreshold", properties.QueueSizeRejectionThreshold.Get()),
                new JProperty("propertyValue_metricsRollingStatisticalWindowInMilliseconds", properties.MetricsRollingStatisticalWindowInMilliseconds.Get()),
                new JProperty("reportingHosts", 1));

            return(data.ToString(Formatting.None));
        }
コード例 #6
0
 public virtual IHystrixMetricsPublisherThreadPool GetMetricsPublisherForThreadPool(HystrixThreadPoolKey threadPoolKey, HystrixThreadPoolMetrics metrics, IHystrixThreadPoolProperties properties)
 {
     return(new HystrixMetricsPublisherThreadPoolDefault(threadPoolKey, metrics, properties));
 }
コード例 #7
0
 public IHystrixMetricsPublisherThreadPool GetMetricsPublisherForThreadPool(HystrixThreadPoolKey threadPoolKey, HystrixThreadPoolMetrics metrics, IHystrixThreadPoolProperties properties)
 {
     return new HystrixDelegateMetricsPublisherThreadPool(() => this.threadCounter.IncrementAndGet());
 }
コード例 #8
0
 /// <summary>
 /// Gets the <see cref="HystrixThreadPoolMetrics"/> instance for a given <see cref="HystrixThreadPoolKey"/>.
 /// If no metrics exists for the specified key, a new one will be created from the specified threadPool and setter.
 /// </summary>
 /// <param name="key">Key of the tracked thread pool.</param>
 /// <param name="threadPool">The thread pool executor of the tracked pool.</param>
 /// <param name="properties">The properties of the tracked pool.</param>
 /// <returns>A new or an existing thread pool metrics instance of the specified key.</returns>
 public static HystrixThreadPoolMetrics GetInstance(HystrixThreadPoolKey key, ThreadPoolExecutor threadPool, IHystrixThreadPoolProperties properties)
 {
     return Metrics.GetOrAdd(key, w => new HystrixThreadPoolMetrics(key, threadPool, properties));
 }
コード例 #9
0
 public IHystrixMetricsPublisherThreadPool GetMetricsPublisherForThreadPool(HystrixThreadPoolKey threadPoolKey, HystrixThreadPoolMetrics metrics, IHystrixThreadPoolProperties properties)
 {
     return(new Dummy1());
 }
 public HystrixMetricsPublisherThreadPoolDefault(HystrixThreadPoolKey threadPoolKey, HystrixThreadPoolMetrics metrics, IHystrixThreadPoolProperties properties)
 {
     // do nothing by default
 }
コード例 #11
0
 public static IHystrixMetricsPublisherThreadPool CreateOrRetrievePublisherForThreadPool(HystrixThreadPoolKey threadPoolKey, HystrixThreadPoolMetrics metrics, IHystrixThreadPoolProperties properties)
 {
     return(instance.GetPublisherForThreadPool(threadPoolKey, metrics, properties));
 }
コード例 #12
0
 public IHystrixMetricsPublisherThreadPool GetMetricsPublisherForThreadPool(HystrixThreadPoolKey threadPoolKey, HystrixThreadPoolMetrics metrics, IHystrixThreadPoolProperties properties)
 {
     return(new HystrixDelegateMetricsPublisherThreadPool(() => this.threadCounter.IncrementAndGet()));
 }
コード例 #13
0
 public IHystrixMetricsPublisherThreadPool GetPublisherForThreadPool(HystrixThreadPoolKey threadPoolKey, HystrixThreadPoolMetrics metrics, IHystrixThreadPoolProperties properties)
 {
     return this.threadPoolPublishers.GetOrAdd(threadPoolKey.Name,
         w => this.strategy.GetMetricsPublisherForThreadPool(threadPoolKey, metrics, properties),
         w => w.Initialize());
 }
コード例 #14
0
 public static IHystrixMetricsPublisherThreadPool CreateOrRetrievePublisherForThreadPool(HystrixThreadPoolKey threadPoolKey, HystrixThreadPoolMetrics metrics, IHystrixThreadPoolProperties properties)
 {
     return instance.GetPublisherForThreadPool(threadPoolKey, metrics, properties);
 }
コード例 #15
0
 /// <summary>
 /// Gets the <see cref="HystrixThreadPoolMetrics"/> instance for a given <see cref="HystrixThreadPoolKey"/>.
 /// If no metrics exists for the specified key, a new one will be created from the specified threadPool and setter.
 /// </summary>
 /// <param name="key">Key of the tracked thread pool.</param>
 /// <param name="threadPool">The thread pool executor of the tracked pool.</param>
 /// <param name="properties">The properties of the tracked pool.</param>
 /// <returns>A new or an existing thread pool metrics instance of the specified key.</returns>
 public static HystrixThreadPoolMetrics GetInstance(HystrixThreadPoolKey key, ThreadPoolExecutor threadPool, IHystrixThreadPoolProperties properties)
 {
     return(Metrics.GetOrAdd(key, w => new HystrixThreadPoolMetrics(key, threadPool, properties)));
 }
コード例 #16
0
ファイル: AtlasPublisher.cs プロジェクト: Elders/Hystrix.NET
 public IHystrixMetricsPublisherThreadPool GetMetricsPublisherForThreadPool(HystrixThreadPoolKey threadPoolKey, HystrixThreadPoolMetrics metrics, IHystrixThreadPoolProperties properties)
 {
     return new Dummy1();
 }
コード例 #17
0
 public virtual IHystrixMetricsPublisherThreadPool GetMetricsPublisherForThreadPool(HystrixThreadPoolKey threadPoolKey, HystrixThreadPoolMetrics metrics, IHystrixThreadPoolProperties properties)
 {
     return new HystrixMetricsPublisherThreadPoolDefault(threadPoolKey, metrics, properties);
 }
コード例 #18
0
 public IHystrixMetricsPublisherThreadPool GetPublisherForThreadPool(HystrixThreadPoolKey threadPoolKey, HystrixThreadPoolMetrics metrics, IHystrixThreadPoolProperties properties)
 {
     return(this.threadPoolPublishers.GetOrAdd(threadPoolKey.Name,
                                               w => this.strategy.GetMetricsPublisherForThreadPool(threadPoolKey, metrics, properties),
                                               w => w.Initialize()));
 }