public static IHystrixThreadPoolProperties GetThreadPoolProperties(HystrixThreadPoolKey threadPoolKey, HystrixThreadPoolPropertiesSetter setter)
        {
            if (threadPoolKey == null)
            {
                throw new ArgumentNullException("threadPoolKey");
            }

            IHystrixPropertiesStrategy strategy = HystrixPlugins.Instance.PropertiesStrategy;
            string cacheKey = strategy.GetThreadPoolPropertiesCacheKey(threadPoolKey, setter);

            if (String.IsNullOrEmpty(cacheKey))
            {
                return(strategy.GetThreadPoolProperties(threadPoolKey, setter));
            }
            else
            {
                return(threadPoolProperties.GetOrAdd(cacheKey, w =>
                {
                    if (setter == null)
                    {
                        setter = new HystrixThreadPoolPropertiesSetter();
                    }

                    return strategy.GetThreadPoolProperties(threadPoolKey, setter);
                }));
            }
        }
 public IHystrixThreadPoolProperties GetThreadPoolProperties(HystrixThreadPoolKey threadPoolKey, HystrixThreadPoolPropertiesSetter setter)
 {
     if (setter == null)
     {
         setter = UnitTestSetterFactory.GetThreadPoolPropertiesSetter();
     }
     return(new MockingHystrixThreadPoolProperties(setter));
 }
 public string GetThreadPoolPropertiesCacheKey(HystrixThreadPoolKey threadPoolKey, HystrixThreadPoolPropertiesSetter setter)
 {
     return(null);
 }
Beispiel #4
0
 public HystrixCommandSetter AndThreadPoolKey(HystrixThreadPoolKey threadPoolKey)
 {
     ThreadPoolKey = threadPoolKey;
     return(this);
 }
 public virtual IHystrixMetricsPublisherThreadPool GetMetricsPublisherForThreadPool(HystrixThreadPoolKey threadPoolKey, HystrixThreadPoolMetrics metrics, IHystrixThreadPoolProperties properties)
 {
     return(new HystrixMetricsPublisherThreadPoolDefault(threadPoolKey, metrics, properties));
 }
 public DefaultThreadFactory(HystrixThreadPoolKey key)
 {
     this.key = key;
 }
 public virtual ThreadPoolExecutor GetThreadPool(HystrixThreadPoolKey threadPoolKey, IHystrixProperty <int> corePoolSize, IHystrixProperty <int> maximumPoolSize, IHystrixProperty <TimeSpan> keepAliveTime, IBlockingQueue <IRunnable> workQueue)
 {
     return(new ThreadPoolExecutor(corePoolSize.Get(), maximumPoolSize.Get(), keepAliveTime.Get(), workQueue, new DefaultThreadFactory(threadPoolKey)));
 }
 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()));
 }
 public IHystrixMetricsPublisherThreadPool GetMetricsPublisherForThreadPool(HystrixThreadPoolKey threadPoolKey, HystrixThreadPoolMetrics metrics, IHystrixThreadPoolProperties properties)
 {
     return(new Dummy1());
 }
 public static IHystrixMetricsPublisherThreadPool CreateOrRetrievePublisherForThreadPool(HystrixThreadPoolKey threadPoolKey, HystrixThreadPoolMetrics metrics, IHystrixThreadPoolProperties properties)
 {
     return(instance.GetPublisherForThreadPool(threadPoolKey, metrics, properties));
 }
 public IHystrixMetricsPublisherThreadPool GetMetricsPublisherForThreadPool(HystrixThreadPoolKey threadPoolKey, HystrixThreadPoolMetrics metrics, IHystrixThreadPoolProperties properties)
 {
     return(new HystrixDelegateMetricsPublisherThreadPool(() => this.threadCounter.IncrementAndGet()));
 }
Beispiel #12
0
 public virtual string GetThreadPoolPropertiesCacheKey(HystrixThreadPoolKey threadPoolKey, HystrixThreadPoolPropertiesSetter setter)
 {
     return(threadPoolKey.Name);
 }
Beispiel #13
0
 public virtual IHystrixThreadPoolProperties GetThreadPoolProperties(HystrixThreadPoolKey threadPoolKey, HystrixThreadPoolPropertiesSetter setter)
 {
     return(new HystrixThreadPoolPropertiesDefault(setter));
 }
 public HystrixMetricsPublisherThreadPoolDefault(HystrixThreadPoolKey threadPoolKey, HystrixThreadPoolMetrics metrics, IHystrixThreadPoolProperties properties)
 {
     // do nothing by default
 }