這一節咱們來說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