Hystrix支持的动态配置

Hystrix支持的动态配置列表如下:

 

  1. Command Properties
    1. Execution
      1. execution.isolation.strategy
      2. execution.isolation.thread.timeoutInMilliseconds
      3. execution.timeout.enabled
      4. execution.isolation.thread.interruptOnTimeout
      5. execution.isolation.thread.interruptOnCancel
      6. execution.isolation.semaphore.maxConcurrentRequests
    2. Fallback
      1. fallback.isolation.semaphore.maxConcurrentRequests
      2. fallback.enabled
    3. Circuit Breaker
      1. circuitBreaker.enabled
      2. circuitBreaker.requestVolumeThreshold
      3. circuitBreaker.sleepWindowInMilliseconds
      4. circuitBreaker.errorThresholdPercentage
      5. circuitBreaker.forceOpen
      6. circuitBreaker.forceClosed
    4. Metrics
      1. metrics.rollingStats.timeInMilliseconds
      2. metrics.rollingStats.numBuckets
      3. metrics.rollingPercentile.enabled
      4. metrics.rollingPercentile.timeInMilliseconds
      5. metrics.rollingPercentile.numBuckets
      6. metrics.rollingPercentile.bucketSize
      7. metrics.healthSnapshot.intervalInMilliseconds
    5. Request Context
      1. requestCache.enabled
      2. requestLog.enabled
  2. Collapser Properties
    1. maxRequestsInBatch
    2. timerDelayInMilliseconds
    3. requestCache.enabled
  3. Thread Pool Properties
    1. coreSize
    2. maximumSize
    3. maxQueueSize
    4. queueSizeRejectionThreshold
    5. keepAliveTimeMinutes
    6. allowMaximumSizeToDivergeFromCoreSize
    7. metrics.rollingStats.timeInMilliseconds
    8. metrics.rollingStats.numBuckets

 


    /**
     * Semaphore that only supports tryAcquire and never blocks and that supports a dynamic permit count.
     * <p>
     * Using AtomicInteger increment/decrement instead of java.util.concurrent.Semaphore since we don't need blocking and need a custom implementation to get the dynamic permit count and since
     * AtomicInteger achieves the same behavior and performance without the more complex implementation of the actual Semaphore class using AbstractQueueSynchronizer.
     */
    /* package */static class TryableSemaphoreActual implements TryableSemaphore {
        protected final HystrixProperty<Integer> numberOfPermits;
        private final AtomicInteger count = new AtomicInteger(0);

        public TryableSemaphoreActual(HystrixProperty<Integer> numberOfPermits) {
            this.numberOfPermits = numberOfPermits;
        }

        @Override
        public boolean tryAcquire() {
            int currentCount = count.incrementAndGet();
            if (currentCount > numberOfPermits.get()) {
                count.decrementAndGet();
                return false;
            } else {
                return true;
            }
        }

        @Override
        public void release() {
            count.decrementAndGet();
        }

        @Override
        public int getNumberOfPermitsUsed() {
            return count.get();
        }

    }

com.netflix.hystrix.HystrixThreadPool.HystrixThreadPoolDefault

   // allow us to change things via fast-properties by setting it each time
        private void touchConfig() {
            final int dynamicCoreSize = properties.coreSize().get();
            threadPool.setCorePoolSize(dynamicCoreSize);
            threadPool.setMaximumPoolSize(dynamicCoreSize); // we always want maxSize the same as coreSize, we are not using a dynamically resizing pool
            threadPool.setKeepAliveTime(properties.keepAliveTimeMinutes().get(), TimeUnit.MINUTES); // this doesn't really matter since we're not resizing
        }

 

相关源码类:

com.netflix.hystrix.HystrixThreadPoolProperties

com.netflix.hystrix.HystrixThreadPool

 

com.netflix.hystrix.HystrixThreadPool.HystrixThreadPoolDefault

com.netflix.hystrix.HystrixThreadPool.HystrixThreadPoolDefault.touchConfig()

 

com.netflix.hystrix.config.HystrixCommandConfiguration.sample(HystrixCommandKey, HystrixThreadPoolKey, HystrixCommandGroupKey, HystrixCommandProperties)

 

com.netflix.hystrix.AbstractCommand.getExecutionSemaphore()

com.netflix.hystrix.strategy.properties.HystrixPropertiesFactory.getCommandProperties(HystrixCommandKey, Setter)

 

com.netflix.hystrix.AbstractCommand.TryableSemaphoreActual<R>

 

 

 

com.netflix.hystrix.HystrixCommandProperties

com.netflix.hystrix.AbstractCommand<R>

com.netflix.hystrix.HystrixCollapserProperties

https://github.com/Netflix/Hystrix/wiki/Configuration#CommandProperties

 

http://www.iocoder.cn/Hystrix/command-execute-first-run/

转载于:https://my.oschina.net/xiaominmin/blog/1590790

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值