diff --git a/hystrix-core/src/main/java/com/netflix/hystrix/HystrixCommand.java b/hystrix-core/src/main/java/com/netflix/hystrix/HystrixCommand.java index 4e7c8c787..9a4aad92f 100755 --- a/hystrix-core/src/main/java/com/netflix/hystrix/HystrixCommand.java +++ b/hystrix-core/src/main/java/com/netflix/hystrix/HystrixCommand.java @@ -54,7 +54,7 @@ public abstract class HystrixCommand extends AbstractCommand implements Hy * @param group * {@link HystrixCommandGroupKey} used to group together multiple {@link HystrixCommand} objects. *

- * The {@link HystrixCommandGroupKey} is used to represent a common relationship between commands. For example, a library or team name, the system all related commands interace with, + * The {@link HystrixCommandGroupKey} is used to represent a common relationship between commands. For example, a library or team name, the system all related commands interact with, * common business purpose etc. */ protected HystrixCommand(HystrixCommandGroupKey group) { @@ -62,6 +62,60 @@ protected HystrixCommand(HystrixCommandGroupKey group) { this(new Setter(group)); } + + /** + * Construct a {@link HystrixCommand} with defined {@link HystrixCommandGroupKey} and {@link HystrixThreadPoolKey}. + *

+ * The {@link HystrixCommandKey} will be derived from the implementing class name. + * + * @param group + * {@link HystrixCommandGroupKey} used to group together multiple {@link HystrixCommand} objects. + *

+ * The {@link HystrixCommandGroupKey} is used to represent a common relationship between commands. For example, a library or team name, the system all related commands interact with, + * common business purpose etc. + * @param threadPool + * {@link HystrixThreadPoolKey} used to identify the thread pool in which a {@link HystrixCommand} executes. + */ + protected HystrixCommand(HystrixCommandGroupKey group, HystrixThreadPoolKey threadPool) { + this(new Setter(group).andThreadPoolKey(threadPool)); + } + + /** + * Construct a {@link HystrixCommand} with defined {@link HystrixCommandGroupKey} and thread timeout + *

+ * The {@link HystrixCommandKey} will be derived from the implementing class name. + * + * @param group + * {@link HystrixCommandGroupKey} used to group together multiple {@link HystrixCommand} objects. + *

+ * The {@link HystrixCommandGroupKey} is used to represent a common relationship between commands. For example, a library or team name, the system all related commands interact with, + * common business purpose etc. + * @param executionIsolationThreadTimeoutInMilliseconds + * Time in milliseconds at which point the calling thread will timeout (using {@link Future#get}) and walk away from the executing thread. + */ + protected HystrixCommand(HystrixCommandGroupKey group, int executionIsolationThreadTimeoutInMilliseconds) { + this(new Setter(group).andCommandPropertiesDefaults(HystrixCommandProperties.Setter().withExecutionIsolationThreadTimeoutInMilliseconds(executionIsolationThreadTimeoutInMilliseconds))); + } + + /** + * Construct a {@link HystrixCommand} with defined {@link HystrixCommandGroupKey}, {@link HystrixThreadPoolKey}, and thread timeout. + *

+ * The {@link HystrixCommandKey} will be derived from the implementing class name. + * + * @param group + * {@link HystrixCommandGroupKey} used to group together multiple {@link HystrixCommand} objects. + *

+ * The {@link HystrixCommandGroupKey} is used to represent a common relationship between commands. For example, a library or team name, the system all related commands interact with, + * common business purpose etc. + * @param threadPool + * {@link HystrixThreadPoolKey} used to identify the thread pool in which a {@link HystrixCommand} executes. + * @param executionIsolationThreadTimeoutInMilliseconds + * Time in milliseconds at which point the calling thread will timeout (using {@link Future#get}) and walk away from the executing thread. + */ + protected HystrixCommand(HystrixCommandGroupKey group, HystrixThreadPoolKey threadPool, int executionIsolationThreadTimeoutInMilliseconds) { + this(new Setter(group).andThreadPoolKey(threadPool).andCommandPropertiesDefaults(HystrixCommandProperties.Setter().withExecutionIsolationThreadTimeoutInMilliseconds(executionIsolationThreadTimeoutInMilliseconds))); + } + /** * Construct a {@link HystrixCommand} with defined {@link Setter} that allows injecting property and strategy overrides and other optional arguments. *