如何检查Matrics属性是否适用于hystrix?

时间:2017-06-06 10:55:14

标签: hybris hystrix netflix

我的local.properties文件hystrix属性如下所示。

hystrix.command.FASTSearchPageCommand.execution.isolation.strategy=THREAD
hystrix.command.FASTSearchPageCommand.execution.isolation.semaphore.maxConcurrentRequests=10
hystrix.command.FASTSearchPageCommand.execution.isolation.thread.timeoutInMilliseconds=1000

hystrix.command.FASTSearchPageCommand.execution.timeout.disabled=true
hystrix.command.FASTSearchPageCommand.execution.timeout.enabled=false

hystrix.command.FASTSearchPageCommand.execution.isolation.thread.interruptOnTimeout=true
hystrix.command.FASTSearchPageCommand.fallback.isolation.semaphore.maxConcurrentRequests=10
hystrix.command.FASTSearchPageCommand.fallback.disabled=false
hystrix.command.FASTSearchPageCommand.fallback.enabled=true


hystrix.command.FASTSearchPageCommand.circuitBreaker.disabled=false
hystrix.command.FASTSearchPageCommand.circuitBreaker.enabled=true
hystrix.command.FASTSearchPageCommand.circuitBreaker.requestVolumeThreshold=10
hystrix.command.FASTSearchPageCommand.circuitBreaker.sleepWindowInMilliseconds=8000
hystrix.command.FASTSearchPageCommand.circuitBreaker.errorThresholdPercentage=10
hystrix.command.FASTSearchPageCommand.circuitBreaker.forceOpen=false
hystrix.command.FASTSearchPageCommand.circuitBreaker.forceClosed=false
hystrix.command.FASTSearchPageCommand.metrics.rollingStats.timeInMilliseconds=1000
hystrix.command.FASTSearchPageCommand.metrics.rollingStats.numBuckets=5
hystrix.command.FASTSearchPageCommand.metrics.rollingPercentile.enabled=true
hystrix.command.FASTSearchPageCommand.metrics.rollingPercentile.timeInMilliseconds=100
hystrix.command.FASTSearchPageCommand.metrics.rollingPercentile.bucketSize=10
hystrix.command.FASTSearchPageCommand.metrics.healthSnapshot.intervalInMilliseconds=100
fastSearch.executionTimeout=5000

那么如何检查所有工作正常。就像我怎么能注意到我的matrics属性正常工作。如果可以给我一些运行和回退方法的代码。

1 个答案:

答案 0 :(得分:0)

我认为您可以在此处找到所有文档:Hystrix docs

他们的文档中的示例如下:

public class CommandThatFailsSilently extends HystrixCommand<String> {

    private final boolean throwException;

    public CommandThatFailsSilently(boolean throwException) {
        super(HystrixCommandGroupKey.Factory.asKey("FASTSearchPageCommand"));
        this.throwException = throwException;
    }

    @Override
    protected String run() {
        if (throwException) {
            throw new RuntimeException("failure from CommandThatFailsFast");
        } else {
            return "success";
        }
    }

    @Override
    protected String getFallback() {
        return null;
    }
}