这一节咱们来说hystrix的properties配置体系,properties配置也是各个功能模块的基础功能。hystrix将配置分红三个部分:ide
1.HystrixCommandProperties用于HystrixCommand配置,一个HystrixCommandKey对应一个HystrixCommandProperties实例。ui
2.HystrixThreadPoolProperties用于HystrixThreadPool配置,一个HystrixThreadPoolKey对应一个HystrixThreadPoolProperties实例。spa
3.HystrixCollapserProperties用于HystrixCollapserCommand配置,一个HystrixCollapserKey对应一个HystrixCollapserProperties实例。插件
类别 | 配置项 | 默认值 | 说明 |
HystrixCommandProperties | hystrix.threadpool.[commandkey].circuitBreaker.enabled对象 |
true | |
hystrix.threadpool.[commandkey].circuitBreaker.requestVolumeThreshold | 20 | ||
hystrix.threadpool.[commandkey].circuitBreaker.sleepWindowInMilliseconds | 5000 | ||
hystrix.threadpool.[commandkey].circuitBreaker.errorThresholdPercentage | 50 | ||
hystrix.threadpool.[commandkey].circuitBreaker.forceOpen | false | ||
hystrix.threadpool.[commandkey].circuitBreaker.forceClosed | false | ||
hystrix.threadpool.[commandkey].execution.isolation.strategy | Thread | ||
hystrix.threadpool.[commandkey].execution.isolation.thread.timeoutInMilliseconds | 1000 | ||
hystrix.threadpool.[commandkey].execution.timeout.enabled | true | ||
hystrix.threadpool.[commandkey].execution.isolation.thread.interruptOnTimeout | true | ||
hystrix.threadpool.[commandkey].execution.isolation.thread.interruptOnFutureCancel | false | ||
hystrix.threadpool.[commandkey].execution.isolation.semaphore.maxConcurrentRequests | 10 | ||
hystrix.threadpool.[commandkey].fallback.isolation.semaphore.maxConcurrentRequests | 10 | ||
hystrix.threadpool.[commandkey].fallback.enabled | true | ||
hystrix.threadpool.[commandkey].metrics.rollingStats.timeInMilliseconds | 10000 | ||
hystrix.threadpool.[commandkey].metrics.rollingStats.numBuckets | 10 | ||
hystrix.threadpool.[commandkey].metrics.rollingPercentile.enabled | true | ||
hystrix.threadpool.[commandkey].metrics.rollingPercentile.timeInMilliseconds | 60000 | ||
hystrix.threadpool.[commandkey].metrics.rollingPercentile.numBuckets | 6 | ||
hystrix.threadpool.[commandkey].metrics.rollingPercentile.bucketSize | 100 | ||
hystrix.threadpool.[commandkey].metrics.healthSnapshot.intervalInMilliseconds | 500 | ||
hystrix.threadpool.[commandkey].requestCache.enabled | true | ||
hystrix.threadpool.[commandkey].requestLog.enabled | true | ||
hystrix.threadpool.[commandkey].threadPoolKeyOverride | |||
HystrixThreadPoolProperties | hystrix.threadpool.[threadPoolkey].coreSize | 10 | |
hystrix.threadpool.[threadPoolkey].allowMaximumSizeToDivergeFromCoreSize | false | ||
hystrix.threadpool.[threadPoolkey].maximumSize | 10 | ||
hystrix.threadpool.[threadPoolkey].keepAliveTimeMinutes | 1 | ||
hystrix.threadpool.[threadPoolkey].maxQueueSize | -1 | ||
hystrix.threadpool.[threadPoolkey].queueSizeRejectionThreshold | 5 | ||
hystrix.threadpool.[threadPoolkey].metrics.rollingStats.timeInMilliseconds | 10000 | ||
hystrix.threadpool.[threadPoolkey].metrics.rollingStats.numBuckets | 10 | ||
HystrixCollapserProperties | hystrix.collapser.[collapserCommandkey].maxRequestsInBatch | Integer.MAX_VALUE | |
hystrix.collapser.[collapserCommandkey].timerDelayInMilliseconds | 10 | ||
hystrix.collapser.[collapserCommandkey].requestCache.enabled | true | ||
hystrix.collapser.[collapserCommandkey].metrics.rollingStats.timeInMilliseconds | 10000 | ||
hystrix.collapser.[collapserCommandkey].metrics.rollingStats.numBuckets | 10 | ||
hystrix.collapser.[collapserCommandkey].metrics.rollingPercentile.enabled | true | ||
hystrix.collapser.[collapserCommandkey].metrics.rollingPercentile.timeInMilliseconds | 60000 | ||
hystrix.collapser.[collapserCommandkey].metrics.rollingPercentile.numBuckets | 6 | ||
hystrix.collapser.[collapserCommandkey].metrics.rollingPercentile.bucketSize | 100 |
内部每一个属性由一个ChainHystrixProperty表示,ChainHystrixProperty是一个串联的HystrixDynamicProperty,持续获取串中的属性值,直到得到不为null值为止。ChainHystrixProperty串联的HystrixDynamicProperty默认经过插件获取的HystrixDynamicProperties获取(最后咱们会讲到插件)。ci
HystrixDynamicProperty表示动态配置数据,若是配置源发送变化,经过该对象获取配置也会相应变化。hystrix中有种实现类:it
1.经过archaius实现获取配置项,经过HystrixDynamicPropertiesArchaius建立该类HystrixDynamicProperty。io
2.经过system实现获取配置项,经过HystrixDynamicPropertiesSystemProperties建立该类HystrixDynamicProperty。table