hystrix(4) properties配置


這一節我們來講hystrix的properties配置體系,properties配置也是各個功能模塊的基礎功能。hystrix將配置分成三個部分:

  1.HystrixCommandProperties用於HystrixCommand配置,一個HystrixCommandKey對應一個HystrixCommandProperties實例。

  2.HystrixThreadPoolProperties用於HystrixThreadPool配置,一個HystrixThreadPoolKey對應一個HystrixThreadPoolProperties實例。

  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獲取(最后我們會講到插件)

  HystrixDynamicProperty表示動態配置數據,如果配置源發送變化,通過該對象獲取配置也會相應變化。hystrix中有種實現類:

    1.通過archaius實現獲取配置項,通過HystrixDynamicPropertiesArchaius創建該類HystrixDynamicProperty。

    2.通過system實現獲取配置項,通過HystrixDynamicPropertiesSystemProperties創建該類HystrixDynamicProperty。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM