• 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。

  • 相关阅读:
    POJ 3624 Charm Bracelet 简单01背包
    POJ 1426 Find The Multiple BFS
    HDU 2612 Find a way BFS,防止超时是关键
    P3399 丝绸之路(线性二维dp)
    洛谷P1726 上白泽慧音(Tarjan强连通分量)
    codevs1557 热浪(堆优化dijkstra)
    P1462 通往奥格瑞玛的道路(二分答案+最短路)
    洛谷P1330 封锁阳光大学(二分图染色)
    洛谷P1341 无序字母对(欧拉回路)
    洛谷P1613 跑路(最短路+倍增)
  • 原文地址:https://www.cnblogs.com/zhangwanhua/p/10037401.html
Copyright © 2020-2023  润新知