Beispiel #1
0
 public CircuitBreaker(ICommandConfigSet configSet, ICommandMetrics metrics)
 {
     this.ConfigSet = configSet;
     this.Metrics   = metrics;
     this.OpenFlag  = new AtomicBoolean();
     this.CircuitOpenedOrLastTestedTime = new AtomicLong();
 }
 protected virtual void Config(ICommandConfigSet configSet)
 {
     if (this._config != null)
     {
         this._config(configSet);
     }
 }
Beispiel #3
0
        public static bool AreEqual(ICommandConfigSet configSet1, ICommandConfigSet configSet2)
        {
            if (configSet1 == configSet2)
            {
                return(true);
            }

            if (configSet1 == null || configSet2 == null)
            {
                return(false);
            }

            return(configSet1.CircuitBreakerEnabled == configSet2.CircuitBreakerEnabled &&
                   configSet1.CircuitBreakerErrorThresholdPercentage == configSet2.CircuitBreakerErrorThresholdPercentage &&
                   configSet1.CircuitBreakerForceClosed == configSet2.CircuitBreakerForceClosed &&
                   configSet1.CircuitBreakerForceOpen == configSet2.CircuitBreakerForceOpen &&
                   configSet1.CircuitBreakerRequestCountThreshold == configSet2.CircuitBreakerRequestCountThreshold &&
                   configSet1.CircuitBreakerSleepWindowInMilliseconds == configSet2.CircuitBreakerSleepWindowInMilliseconds &&
                   configSet1.CommandMaxConcurrentCount == configSet2.CommandMaxConcurrentCount &&
                   configSet1.CommandTimeoutInMilliseconds == configSet2.CommandTimeoutInMilliseconds &&
                   configSet1.DegradeLogLevel == configSet2.DegradeLogLevel &&
                   configSet1.FallbackMaxConcurrentCount == configSet2.FallbackMaxConcurrentCount &&
                   configSet1.LogExecutionError == configSet2.LogExecutionError &&
                   configSet1.MaxAsyncCommandExceedPercentage == configSet2.MaxAsyncCommandExceedPercentage &&
                   configSet1.MetricsHealthSnapshotIntervalInMilliseconds == configSet2.MetricsHealthSnapshotIntervalInMilliseconds &&
                   configSet1.MetricsRollingPercentileBucketSize == configSet2.MetricsRollingPercentileBucketSize &&
                   configSet1.MetricsRollingPercentileEnabled == configSet2.MetricsRollingPercentileEnabled &&
                   configSet1.MetricsRollingPercentileWindowBuckets == configSet2.MetricsRollingPercentileWindowBuckets &&
                   configSet1.MetricsRollingPercentileWindowInMilliseconds == configSet2.MetricsRollingPercentileWindowInMilliseconds &&
                   configSet1.MetricsRollingStatisticalWindowBuckets == configSet2.MetricsRollingStatisticalWindowBuckets &&
                   configSet1.MetricsRollingStatisticalWindowInMilliseconds == configSet2.MetricsRollingStatisticalWindowInMilliseconds);
        }
Beispiel #4
0
        public static List <HystrixThreadPoolInfo> GetHystrixThreadPoolList()
        {
            List <HystrixThreadPoolInfo> list = new List <HystrixThreadPoolInfo>();

            foreach (string str in CThreadPoolFactory.AllPools.Keys.ToArray <string>())
            {
                CThreadPool       pool;
                CommandComponents components;
                if (CThreadPoolFactory.AllPools.TryGetValue(str, out pool) && HystrixCommandBase.CommandComponentsCollection.TryGetValue(str, out components))
                {
                    ICommandConfigSet     configSet = components.ConfigSet;
                    HystrixThreadPoolInfo item      = new HystrixThreadPoolInfo {
                        type = "HystrixThreadPool",
                        name = str,
                        currentActiveCount        = pool.NowRunningWorkCount,
                        currentCorePoolSize       = pool.PoolThreadCount,
                        currentQueueSize          = pool.NowWaitingWorkCount,
                        currentLargestPoolSize    = pool.LargestPoolSize,
                        currentMaximumPoolSize    = pool.MaxConcurrentCount,
                        currentCompletedTaskCount = pool.FinishedWorkCount,
                        currentPoolSize           = pool.CurrentPoolSize,
                        currentTaskCount          = pool.CurrentTaskCount,
                        currentTime = CommonUtils.CurrentUnixTimeInMilliseconds,
                        propertyValue_metricsRollingStatisticalWindowInMilliseconds = configSet.MetricsRollingStatisticalWindowInMilliseconds,
                        propertyValue_queueSizeRejectionThreshold = (configSet.CommandMaxConcurrentCount * configSet.MaxAsyncCommandExceedPercentage) / 100,
                        reportingHosts = 1,
                        rollingCountThreadsExecuted = 0,
                        rollingMaxActiveThreads     = 0
                    };
                    list.Add(item);
                }
            }
            return(list);
        }
        public TestCircuitBreaker()
        {
            ConfigSet = new CommandConfigSet()
            {
                CircuitBreakerEnabled = true,
                CircuitBreakerRequestCountThreshold    = 2,
                CircuitBreakerErrorThresholdPercentage = 50,
                CircuitBreakerForceClosed = false,
                CircuitBreakerForceOpen   = false,
                CircuitBreakerSleepWindowInMilliseconds = 5000,

                MetricsRollingStatisticalWindowBuckets        = 10,
                MetricsRollingStatisticalWindowInMilliseconds = 10000,
                MetricsRollingPercentileEnabled = true,
                MetricsRollingPercentileWindowInMilliseconds = 60000,
                MetricsRollingPercentileWindowBuckets        = 6,
                MetricsRollingPercentileBucketSize           = 100,
                MetricsHealthSnapshotIntervalInMilliseconds  = 1,

                CommandMaxConcurrentCount    = 10,
                CommandTimeoutInMilliseconds = 5000,

                FallbackMaxConcurrentCount = 10
            };

            _Metrics = ComponentFactory.CreateCommandMetrics(ConfigSet, "BreakerTest", IsolationModeEnum.SemaphoreIsolation);

            OpenFlag = new AtomicBoolean();
            CircuitOpenedOrLastTestedTime = new AtomicLong();
        }
Beispiel #6
0
        public static ICommandConfigSet CreateCustomConfigSet(IsolationModeEnum isolationMode = IsolationModeEnum.SemaphoreIsolation)
        {
            ICommandConfigSet configSet = ComponentFactory.CreateCommandConfigSet(isolationMode);

            configSet.ToConcrete().CircuitBreakerEnabled = false;
            configSet.CircuitBreakerErrorThresholdPercentage = 99;
            configSet.CircuitBreakerForceClosed           = true;
            configSet.CircuitBreakerForceOpen             = true;
            configSet.CircuitBreakerRequestCountThreshold = 99;
            configSet.ToConcrete().CircuitBreakerSleepWindowInMilliseconds = 4999;
            configSet.CommandMaxConcurrentCount    = 99;
            configSet.CommandTimeoutInMilliseconds = 4999;
            configSet.DegradeLogLevel                 = true;
            configSet.FallbackMaxConcurrentCount      = 4999;
            configSet.LogExecutionError               = true;
            configSet.MaxAsyncCommandExceedPercentage = 99;
            configSet.ToConcrete().MetricsHealthSnapshotIntervalInMilliseconds   = 10;
            configSet.ToConcrete().MetricsRollingPercentileBucketSize            = 50;
            configSet.ToConcrete().MetricsRollingPercentileEnabled               = false;
            configSet.ToConcrete().MetricsRollingPercentileWindowBuckets         = 20;
            configSet.ToConcrete().MetricsRollingPercentileWindowInMilliseconds  = 80 * 1000;
            configSet.ToConcrete().MetricsRollingStatisticalWindowBuckets        = 20;
            configSet.ToConcrete().MetricsRollingStatisticalWindowInMilliseconds = 200 * 1000;

            return(configSet);
        }
        public TestCircuitBreaker(ICommandConfigSet configSet, ICommandMetrics metrics)
        {
            ConfigSet = configSet;
            _Metrics  = metrics;

            OpenFlag = new AtomicBoolean();
            CircuitOpenedOrLastTestedTime = new AtomicLong();
        }
 public static ICommandMetrics CreateCommandMetrics(ICommandConfigSet configSet, string key, IsolationModeEnum isolationMode)
 {
     if (isolationMode == IsolationModeEnum.SemaphoreIsolation)
     {
         return(new SemaphoreIsolationCommandMetrics(configSet, key));
     }
     return(new ThreadIsolationCommandMetrics(configSet, key));
 }
Beispiel #9
0
        public static void RaiseConfigChangeEvent(this ICommandConfigSet configSet)
        {
            IConfigChangeEvent event2 = configSet as IConfigChangeEvent;

            if (event2 != null)
            {
                event2.RaiseConfigChangeEvent();
            }
        }
Beispiel #10
0
        public static void SubcribeConfigChangeEvent(this ICommandConfigSet configSet, HandleConfigChangeDelegate handleConfigChange)
        {
            IConfigChangeEvent event2 = configSet as IConfigChangeEvent;

            if (event2 != null)
            {
                event2.OnConfigChanged += handleConfigChange;
            }
        }
        protected override void Config(ICommandConfigSet configSet)
        {
            if (InitConfigSet == null)
            {
                base.Config(configSet);
                return;
            }

            ScenarioTestHelper.SetCommandConfigFrom(configSet, InitConfigSet);
        }
Beispiel #12
0
 public NullLog(ICommandConfigSet configSet, Type type)
 {
     try
     {
         ConfigSet = configSet;
     }
     catch
     {
     }
 }
Beispiel #13
0
        public static void SubcribeConfigChangeEvent(this ICommandConfigSet configSet, HandleConfigChangeDelegate handleConfigChange)
        {
            IConfigChangeEvent hasConfigChangeEvent = configSet as IConfigChangeEvent;

            if (hasConfigChangeEvent == null)
            {
                return;
            }

            hasConfigChangeEvent.OnConfigChanged += handleConfigChange;
        }
Beispiel #14
0
 public CLog(ICommandConfigSet configSet, Type type)
 {
     try
     {
         this.ConfigSet = configSet;
         this.Logger    = LogManager.GetLogger(type);
     }
     catch
     {
     }
 }
Beispiel #15
0
        public static void RaiseConfigChangeEvent(this ICommandConfigSet configSet)
        {
            IConfigChangeEvent hasConfigChangeEvent = configSet as IConfigChangeEvent;

            if (hasConfigChangeEvent == null)
            {
                return;
            }

            hasConfigChangeEvent.RaiseConfigChangeEvent();
        }
 private static void OnConfigChanged(string key, ICommandConfigSet configSet)
 {
     if (!string.IsNullOrWhiteSpace(key) && (configSet != null))
     {
         IsolationSemaphore semaphore;
         IsolationSemaphore semaphore2;
         if (((configSet.CommandMaxConcurrentCount > 0) && ExecutionSemaphores.TryGetValue(key, out semaphore)) && ((semaphore != null) && (semaphore.Count != configSet.CommandMaxConcurrentCount)))
         {
             semaphore.Count = configSet.CommandMaxConcurrentCount;
         }
         if (((configSet.FallbackMaxConcurrentCount > 0) && FallbackExecutionSemaphores.TryGetValue(key, out semaphore2)) && ((semaphore2 != null) && (semaphore2.Count != configSet.FallbackMaxConcurrentCount)))
         {
             semaphore2.Count = configSet.FallbackMaxConcurrentCount;
         }
     }
 }
Beispiel #17
0
 public static void SetCommandConfigFrom(ICommandConfigSet configSet1, ICommandConfigSet configSet2)
 {
     configSet1.ToConcrete().CircuitBreakerEnabled = configSet2.ToConcrete().CircuitBreakerEnabled;
     configSet1.CircuitBreakerErrorThresholdPercentage = configSet2.CircuitBreakerErrorThresholdPercentage;
     configSet1.CircuitBreakerForceClosed           = configSet2.CircuitBreakerForceClosed;
     configSet1.CircuitBreakerForceOpen             = configSet2.CircuitBreakerForceOpen;
     configSet1.CircuitBreakerRequestCountThreshold = configSet2.CircuitBreakerRequestCountThreshold;
     configSet1.ToConcrete().CircuitBreakerSleepWindowInMilliseconds = configSet2.CircuitBreakerSleepWindowInMilliseconds;
     configSet1.CommandMaxConcurrentCount    = configSet2.CommandMaxConcurrentCount;
     configSet1.CommandTimeoutInMilliseconds = configSet2.CommandTimeoutInMilliseconds;
     configSet1.DegradeLogLevel                 = configSet2.DegradeLogLevel;
     configSet1.FallbackMaxConcurrentCount      = configSet2.FallbackMaxConcurrentCount;
     configSet1.LogExecutionError               = configSet2.LogExecutionError;
     configSet1.MaxAsyncCommandExceedPercentage = configSet2.MaxAsyncCommandExceedPercentage;
     configSet1.ToConcrete().MetricsHealthSnapshotIntervalInMilliseconds   = configSet2.MetricsHealthSnapshotIntervalInMilliseconds;
     configSet1.ToConcrete().MetricsRollingPercentileBucketSize            = configSet2.MetricsRollingPercentileBucketSize;
     configSet1.ToConcrete().MetricsRollingPercentileEnabled               = configSet2.MetricsRollingPercentileEnabled;
     configSet1.ToConcrete().MetricsRollingPercentileWindowBuckets         = configSet2.MetricsRollingPercentileWindowBuckets;
     configSet1.ToConcrete().MetricsRollingPercentileWindowInMilliseconds  = configSet2.MetricsRollingPercentileWindowInMilliseconds;
     configSet1.ToConcrete().MetricsRollingStatisticalWindowBuckets        = configSet2.MetricsRollingStatisticalWindowBuckets;
     configSet1.ToConcrete().MetricsRollingStatisticalWindowInMilliseconds = configSet2.MetricsRollingStatisticalWindowInMilliseconds;
 }
        private static void OnConfigChanged(string key, ICommandConfigSet configSet)
        {
            if (string.IsNullOrWhiteSpace(key) || configSet == null)
            {
                return;
            }

            IsolationSemaphore executionSemaphore;

            if (configSet.CommandMaxConcurrentCount > 0 && ExecutionSemaphores.TryGetValue(key, out executionSemaphore) &&
                executionSemaphore != null && executionSemaphore.Count != configSet.CommandMaxConcurrentCount)
            {
                executionSemaphore.Count = configSet.CommandMaxConcurrentCount;
            }

            IsolationSemaphore fallbackExecutionSemaphore;

            if (configSet.FallbackMaxConcurrentCount > 0 && FallbackExecutionSemaphores.TryGetValue(key, out fallbackExecutionSemaphore) &&
                fallbackExecutionSemaphore != null && fallbackExecutionSemaphore.Count != configSet.FallbackMaxConcurrentCount)
            {
                fallbackExecutionSemaphore.Count = configSet.FallbackMaxConcurrentCount;
            }
        }
 public static ICircuitBreaker CreateCircuitBreaker(ICommandConfigSet configSet, ICommandMetrics metrics)
 {
     return(new CHystrix.CircuitBreaker.CircuitBreaker(configSet, metrics));
 }
 public static ILog CreateLog(ICommandConfigSet configSet, Type type)
 {
     return(new CLog(configSet, type));
 }
Beispiel #21
0
 public static void InitTestHealthSnapshotInterval(this ICommandConfigSet configSet)
 {
     configSet.ToConcrete().MetricsHealthSnapshotIntervalInMilliseconds = HealthSnapshotIntervalInMilliseconds;
 }
 public CommandMetrics(ICommandConfigSet configSet)
 {
     ConfigSet = configSet;
     Reset();
 }
Beispiel #23
0
 public CommandMetrics(ICommandConfigSet configSet)
 {
     this.ConfigSet = configSet;
     this.Reset();
 }
Beispiel #24
0
 public static CommandConfigSet ToConcrete(this ICommandConfigSet configSet)
 {
     return((CommandConfigSet)configSet);
 }
Beispiel #25
0
 public SemaphoreIsolationCommandMetrics(ICommandConfigSet configSet, string key) : base(configSet)
 {
     this.Key = key;
 }
 private ICommandMetrics GetMetrics(ICommandConfigSet configset)
 {
     return(ComponentFactory.CreateCommandMetrics(configset, "BreakerTest", IsolationModeEnum.SemaphoreIsolation));
 }
 public static void Reset()
 {
     InitConfigSet = null;
 }
 public ThreadIsolationCommandMetrics(ICommandConfigSet configSet, string key)
     : base(configSet)
 {
     Key = key;
 }
        internal static CommandComponents CreateCommandComponents(string key, string instanceKey, string commandKey, string groupKey, string domain, IsolationModeEnum isolationMode, Action <ICommandConfigSet> config, Type type)
        {
            if (!key.IsValidHystrixName())
            {
                string message = "Hystrix command key has invalid char: " + key + @". Name pattern is: ^[a-zA-Z0-9][a-zA-Z0-9\-_.]*[a-zA-Z0-9]$";
                CommonUtils.Log.Log(LogLevelEnum.Fatal, message, new Dictionary <string, string>().AddLogTagData("FXD303004"));
                throw new ArgumentException(message);
            }
            if (!string.IsNullOrWhiteSpace(instanceKey) && !instanceKey.IsValidHystrixName())
            {
                string str2 = "Hystrix command instanceKey has invalid char: " + instanceKey + @". Name pattern is: ^[a-zA-Z0-9][a-zA-Z0-9\-_.]*[a-zA-Z0-9]$";
                CommonUtils.Log.Log(LogLevelEnum.Fatal, str2, new Dictionary <string, string>().AddLogTagData("FXD303004"));
                throw new ArgumentException(str2);
            }
            if (!commandKey.IsValidHystrixName())
            {
                string str3 = "Hystrix command commandKey has invalid char: " + commandKey + @". Name pattern is: ^[a-zA-Z0-9][a-zA-Z0-9\-_.]*[a-zA-Z0-9]$";
                CommonUtils.Log.Log(LogLevelEnum.Fatal, str3, new Dictionary <string, string>().AddLogTagData("FXD303004"));
                throw new ArgumentException(str3);
            }
            if (!groupKey.IsValidHystrixName())
            {
                string str4 = "Hystrix command group commandKey has invalid char: " + groupKey + @". Name pattern is: ^[a-zA-Z0-9][a-zA-Z0-9\-_.]*[a-zA-Z0-9]$";
                CommonUtils.Log.Log(LogLevelEnum.Fatal, str4, new Dictionary <string, string>().AddLogTagData("FXD303005"));
                throw new ArgumentException(str4);
            }
            if (!domain.IsValidHystrixName())
            {
                string str5 = "Hystrix domain has invalid char: " + domain + @". Name pattern is: ^[a-zA-Z0-9][a-zA-Z0-9\-_.]*[a-zA-Z0-9]$";
                CommonUtils.Log.Log(LogLevelEnum.Fatal, str5, new Dictionary <string, string>().AddLogTagData("FXD303006"));
                throw new ArgumentException(str5);
            }
            if (CommandCount >= MaxCommandCount)
            {
                string str6 = "Hystrix command count has reached the limit: " + MaxCommandCount;
                CommonUtils.Log.Log(LogLevelEnum.Fatal, str6, new Dictionary <string, string>().AddLogTagData("FXD303007"));
                throw new ArgumentException(str6);
            }
            CommandCount.IncrementAndGet();
            ICommandConfigSet configSet = ComponentFactory.CreateCommandConfigSet(isolationMode);

            configSet.SubcribeConfigChangeEvent(delegate(ICommandConfigSet c) {
                OnConfigChanged(key, c);
            });
            try
            {
                if (config != null)
                {
                    config(configSet);
                }
            }
            catch (Exception exception)
            {
                CommonUtils.Log.Log(LogLevelEnum.Fatal, "Failed to config command: " + key, exception, new Dictionary <string, string>().AddLogTagData("FXD303008"));
            }
            ICommandMetrics   metrics    = ComponentFactory.CreateCommandMetrics(configSet, key, isolationMode);
            CommandComponents components = new CommandComponents {
                ConfigSet      = configSet,
                Metrics        = metrics,
                CircuitBreaker = ComponentFactory.CreateCircuitBreaker(configSet, metrics)
            };
            CommandInfo info = new CommandInfo {
                Domain      = domain.ToLower(),
                GroupKey    = groupKey.ToLower(),
                CommandKey  = commandKey.ToLower(),
                InstanceKey = (instanceKey == null) ? null : instanceKey.ToLower(),
                Key         = key.ToLower(),
                Type        = isolationMode.ToString()
            };

            components.CommandInfo   = info;
            components.Log           = ComponentFactory.CreateLog(configSet, type);
            components.IsolationMode = isolationMode;
            return(components);
        }
Beispiel #30
0
        private static void SyncConfig(object sender, ElapsedEventArgs arg)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(HystrixCommandBase.ConfigServiceUrl))
                {
                    CommonUtils.Log.Log(LogLevelEnum.Warning, "Config Service Url is empty.",
                                        new Dictionary <string, string>().AddLogTagData("FXD303011"));
                    return;
                }

                string configServiceOperationUrl        = HystrixCommandBase.ConfigServiceUrl.WithTrailingSlash() + ConfigServiceOperationName + ".json";
                GetApplicationConfigRequestType request = new GetApplicationConfigRequestType()
                {
                    AppName = HystrixCommandBase.HystrixAppName.ToLower()
                };
                string responseJson = configServiceOperationUrl.PostJsonToUrl(request.ToJson());
                if (string.IsNullOrWhiteSpace(responseJson))
                {
                    CommonUtils.Log.Log(LogLevelEnum.Warning, "Got null response from config service: " + HystrixCommandBase.ConfigServiceUrl,
                                        new Dictionary <string, string>().AddLogTagData("FXD303012"));
                    return;
                }

                GetApplicationConfigResponseType response = responseJson.FromJson <GetApplicationConfigResponseType>();
                if (response == null)
                {
                    return;
                }

                if (response.DefaultConfig != null)
                {
                    if (response.DefaultConfig.CircuitBreakerErrorThresholdPercentage.HasValue &&
                        response.DefaultConfig.CircuitBreakerErrorThresholdPercentage.Value >= ComponentFactory.MinGlobalDefaultCircuitBreakerErrorThresholdPercentage &&
                        response.DefaultConfig.CircuitBreakerErrorThresholdPercentage.Value <= 100)
                    {
                        ComponentFactory.GlobalDefaultCircuitBreakerErrorThresholdPercentage = response.DefaultConfig.CircuitBreakerErrorThresholdPercentage;
                    }

                    if (response.DefaultConfig.CircuitBreakerForceClosed.HasValue)
                    {
                        ComponentFactory.GlobalDefaultCircuitBreakerForceClosed = response.DefaultConfig.CircuitBreakerForceClosed;
                    }

                    if (response.DefaultConfig.CircuitBreakerRequestCountThreshold.HasValue &&
                        response.DefaultConfig.CircuitBreakerRequestCountThreshold.Value >= ComponentFactory.MinGlobalDefaultCircuitBreakerRequestCountThreshold)
                    {
                        ComponentFactory.GlobalDefaultCircuitBreakerRequestCountThreshold = response.DefaultConfig.CircuitBreakerRequestCountThreshold;
                    }

                    if (response.DefaultConfig.CommandMaxConcurrentCount.HasValue &&
                        response.DefaultConfig.CommandMaxConcurrentCount.Value >= ComponentFactory.MinGlobalDefaultCommandMaxConcurrentCount)
                    {
                        ComponentFactory.GlobalDefaultCommandMaxConcurrentCount = response.DefaultConfig.CommandMaxConcurrentCount;
                    }

                    if (response.DefaultConfig.CommandTimeoutInMilliseconds.HasValue &&
                        response.DefaultConfig.CommandTimeoutInMilliseconds.Value >= ComponentFactory.MinGlobalDefaultCommandTimeoutInMilliseconds)
                    {
                        ComponentFactory.GlobalDefaultCommandTimeoutInMilliseconds = response.DefaultConfig.CommandTimeoutInMilliseconds;
                    }

                    if (response.DefaultConfig.FallbackMaxConcurrentCount.HasValue &&
                        response.DefaultConfig.FallbackMaxConcurrentCount.Value >= ComponentFactory.MinGlobalDefaultFallbackMaxConcurrentCount)
                    {
                        ComponentFactory.GlobalDefaultFallbackMaxConcurrentCount = response.DefaultConfig.FallbackMaxConcurrentCount;
                    }
                }

                bool noValuableConfig = response.Application == null || response.Application.Commands == null || response.Application.Commands.Count == 0;
                Dictionary <string, CommandComponents> commandComponentsCollection = HystrixCommandBase.CommandComponentsCollection.ToDictionary(p => p.Key, p => p.Value);
                foreach (KeyValuePair <string, CommandComponents> pair in commandComponentsCollection)
                {
                    ICommandConfigSet configSet = pair.Value.ConfigSet;

                    if (noValuableConfig)
                    {
                        configSet.RaiseConfigChangeEvent();
                        continue;
                    }

                    CHystrixCommand command = response.Application.Commands.Where(c => string.Compare(c.Key, pair.Value.CommandInfo.CommandKey, true) == 0).FirstOrDefault();
                    if (command == null || command.Config == null)
                    {
                        configSet.RaiseConfigChangeEvent();
                        continue;
                    }

                    if (command.Config.CircuitBreakerErrorThresholdPercentage.HasValue &&
                        command.Config.CircuitBreakerErrorThresholdPercentage.Value > 0 && command.Config.CircuitBreakerErrorThresholdPercentage.Value <= 100)
                    {
                        configSet.CircuitBreakerErrorThresholdPercentage = command.Config.CircuitBreakerErrorThresholdPercentage.Value;
                    }
                    if (command.Config.CircuitBreakerForceClosed.HasValue)
                    {
                        configSet.CircuitBreakerForceClosed = command.Config.CircuitBreakerForceClosed.Value;
                    }
                    if (command.Config.CircuitBreakerForceOpen.HasValue)
                    {
                        configSet.CircuitBreakerForceOpen = command.Config.CircuitBreakerForceOpen.Value;
                    }
                    if (command.Config.CircuitBreakerRequestCountThreshold.HasValue && command.Config.CircuitBreakerRequestCountThreshold.Value > 0)
                    {
                        configSet.CircuitBreakerRequestCountThreshold = command.Config.CircuitBreakerRequestCountThreshold.Value;
                    }
                    if (command.Config.CommandMaxConcurrentCount.HasValue && command.Config.CommandMaxConcurrentCount.Value > 0)
                    {
                        configSet.CommandMaxConcurrentCount = command.Config.CommandMaxConcurrentCount.Value;
                    }
                    if (command.Config.CommandTimeoutInMilliseconds.HasValue && command.Config.CommandTimeoutInMilliseconds.Value > 0)
                    {
                        configSet.CommandTimeoutInMilliseconds = command.Config.CommandTimeoutInMilliseconds.Value;
                    }
                    if (command.Config.DegradeLogLevel.HasValue)
                    {
                        configSet.DegradeLogLevel = command.Config.DegradeLogLevel.Value;
                    }
                    if (command.Config.LogExecutionError.HasValue)
                    {
                        configSet.LogExecutionError = command.Config.LogExecutionError.Value;
                    }
                    if (command.Config.FallbackMaxConcurrentCount.HasValue && command.Config.FallbackMaxConcurrentCount.Value > 0)
                    {
                        configSet.FallbackMaxConcurrentCount = command.Config.FallbackMaxConcurrentCount.Value;
                    }
                    if (command.Config.MaxAsyncCommandExceedPercentage.HasValue && command.Config.MaxAsyncCommandExceedPercentage.Value >= 0 &&
                        command.Config.MaxAsyncCommandExceedPercentage.Value <= 100)
                    {
                        configSet.MaxAsyncCommandExceedPercentage = command.Config.MaxAsyncCommandExceedPercentage.Value;
                    }

                    configSet.RaiseConfigChangeEvent();
                }
            }
            catch (Exception ex)
            {
                CommonUtils.Log.Log(LogLevelEnum.Warning, "Failed to sync config from config service: " + HystrixCommandBase.ConfigServiceUrl, ex,
                                    new Dictionary <string, string>().AddLogTagData("FXD303014"));
            }
        }