diff --git a/hystrix-core/src/jmh/java/com/netflix/hystrix/perf/CommandExecutionPerfTest.java b/hystrix-core/src/jmh/java/com/netflix/hystrix/perf/CommandExecutionPerfTest.java index dffe99176..cc40587a7 100644 --- a/hystrix-core/src/jmh/java/com/netflix/hystrix/perf/CommandExecutionPerfTest.java +++ b/hystrix-core/src/jmh/java/com/netflix/hystrix/perf/CommandExecutionPerfTest.java @@ -51,29 +51,53 @@ */ public class CommandExecutionPerfTest { - static HystrixCommandProperties.Setter threadIsolatedCommandDefaults = HystrixCommandProperties.Setter() + private static HystrixCommandProperties.Setter threadIsolatedCommandDefaults = HystrixCommandProperties.Setter() .withExecutionIsolationStrategy(HystrixCommandProperties.ExecutionIsolationStrategy.THREAD) .withRequestCacheEnabled(true) .withRequestLogEnabled(true) .withCircuitBreakerEnabled(true) .withCircuitBreakerForceOpen(false); - static HystrixCommandProperties.Setter semaphoreIsolatedCommandDefaults = HystrixCommandProperties.Setter() + private static HystrixCommandProperties.Setter threadIsolatedFailFastCommandDefaults = HystrixCommandProperties.Setter() + .withExecutionIsolationStrategy(HystrixCommandProperties.ExecutionIsolationStrategy.THREAD) + .withRequestCacheEnabled(true) + .withRequestLogEnabled(true) + .withCircuitBreakerEnabled(true) + .withCircuitBreakerForceOpen(true); + + private static HystrixCommandProperties.Setter semaphoreIsolatedCommandDefaults = HystrixCommandProperties.Setter() .withExecutionIsolationStrategy(HystrixCommandProperties.ExecutionIsolationStrategy.SEMAPHORE) .withRequestCacheEnabled(true) .withRequestLogEnabled(true) .withCircuitBreakerEnabled(true) .withCircuitBreakerForceOpen(false); - static HystrixThreadPoolProperties.Setter threadPoolDefaults = HystrixThreadPoolProperties.Setter() + private static HystrixCommandProperties.Setter semaphoreIsolatedFailFastCommandDefaults = HystrixCommandProperties.Setter() + .withExecutionIsolationStrategy(HystrixCommandProperties.ExecutionIsolationStrategy.SEMAPHORE) + .withRequestCacheEnabled(true) + .withRequestLogEnabled(true) + .withCircuitBreakerEnabled(true) + .withCircuitBreakerForceOpen(true); + + private static HystrixThreadPoolProperties.Setter threadPoolDefaults = HystrixThreadPoolProperties.Setter() .withCoreSize(100); - static HystrixCommandGroupKey groupKey = HystrixCommandGroupKey.Factory.asKey("PERF"); + private static HystrixCommandGroupKey groupKey = HystrixCommandGroupKey.Factory.asKey("PERF"); - private static HystrixCommandProperties.Setter getCommandSetter(HystrixCommandProperties.ExecutionIsolationStrategy isolationStrategy) { + private static HystrixCommandProperties.Setter getCommandSetter(HystrixCommandProperties.ExecutionIsolationStrategy isolationStrategy, boolean forceOpen) { switch (isolationStrategy) { - case THREAD: return threadIsolatedCommandDefaults; - default: return semaphoreIsolatedCommandDefaults; + case THREAD: + if (forceOpen) { + return threadIsolatedFailFastCommandDefaults; + } else { + return threadIsolatedCommandDefaults; + } + default: + if (forceOpen) { + return semaphoreIsolatedFailFastCommandDefaults; + } else { + return semaphoreIsolatedCommandDefaults; + } } } @@ -89,6 +113,9 @@ public static class CommandState { HystrixCommand command; HystrixRequestContext requestContext; + @Param({"true", "false"}) + public boolean forceOpen; + @Param({"true", "false"}) public boolean setUpRequestContext; @@ -107,7 +134,7 @@ public void setUp() { command = new HystrixCommand( HystrixCommand.Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("PERF")) - .andCommandPropertiesDefaults(getCommandSetter(isolationStrategy)) + .andCommandPropertiesDefaults(getCommandSetter(isolationStrategy, forceOpen)) .andThreadPoolPropertiesDefaults(threadPoolDefaults) ) { @Override @@ -136,6 +163,9 @@ public static class ObservableCommandState { HystrixObservableCommand command; HystrixRequestContext requestContext; + @Param({"true", "false"}) + public boolean forceOpen; + @Param({"true", "false"}) public boolean setUpRequestContext; @@ -151,7 +181,7 @@ public void setUp() { command = new HystrixObservableCommand( HystrixObservableCommand.Setter.withGroupKey(groupKey) - .andCommandPropertiesDefaults(getCommandSetter(HystrixCommandProperties.ExecutionIsolationStrategy.SEMAPHORE)) + .andCommandPropertiesDefaults(getCommandSetter(HystrixCommandProperties.ExecutionIsolationStrategy.SEMAPHORE, forceOpen)) ) { @Override protected Observable construct() {