Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Favor timeout property that is not thread-specific. (execution.timeoutInMilliseconds) #664

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,17 @@ public Boolean getValue() {
return properties.circuitBreakerForceClosed().get();
}
});
//this naming convention is deprecated as of 1.4.0-RC7, remove in 1.5.x
metricRegistry.register(createMetricName("propertyValue_executionIsolationThreadTimeoutInMilliseconds"), new Gauge<Number>() {
@Override
public Number getValue() {
return properties.executionIsolationThreadTimeoutInMilliseconds().get();
return properties.executionTimeoutInMilliseconds().get();
}
});
metricRegistry.register(createMetricName("propertyValue_executionTimeoutInMilliseconds"), new Gauge<Number>() {
@Override
public Number getValue() {
return properties.executionTimeoutInMilliseconds().get();
}
});
metricRegistry.register(createMetricName("propertyValue_executionIsolationStrategy"), new Gauge<String>() {
Expand Down
6 changes: 3 additions & 3 deletions hystrix-contrib/hystrix-javanica/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ Command properties can be set using @HystrixCommand's 'commandProperties' like b

```java
@HystrixCommand(commandProperties = {
@HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "500")
@HystrixProperty(name = "execution.timeoutInMilliseconds", value = "500")
})
public User getUserById(String id) {
return userResource.getUserById(id);
Expand All @@ -353,15 +353,15 @@ Command properties can be set using @HystrixCommand's 'commandProperties' like b
Javanica dynamically sets properties using Hystrix ConfigurationManager.
For the example above Javanica behind the scenes performs next action:
```java
ConfigurationManager.getConfigInstance().setProperty("hystrix.command.getUserById.execution.isolation.thread.timeoutInMilliseconds", "500");
ConfigurationManager.getConfigInstance().setProperty("hystrix.command.getUserById.execution.timeoutInMilliseconds", "500");
```
More about Hystrix command properties [command](https://github.com/Netflix/Hystrix/wiki/Configuration#wiki-CommandExecution) and [fallback](https://github.com/Netflix/Hystrix/wiki/Configuration#wiki-CommandFallback)

ThreadPoolProperties can be set using @HystrixCommand's 'threadPoolProperties' like below:

```java
@HystrixCommand(commandProperties = {
@HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "500")
@HystrixProperty(name = "execution.timeoutInMilliseconds", value = "500")
},
threadPoolProperties = {
@HystrixProperty(name = "coreSize", value = "30"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void testGetUser() throws NoSuchFieldException, IllegalAccessException {
assertEquals("Test", command.getThreadPoolKey().name());
assertTrue(command.getExecutionEvents().contains(HystrixEventType.SUCCESS));
// assert properties
assertEquals(110, command.getProperties().executionIsolationThreadTimeoutInMilliseconds().get().intValue());
assertEquals(110, command.getProperties().executionTimeoutInMilliseconds().get().intValue());
assertEquals(false, command.getProperties().executionIsolationThreadInterruptOnTimeout().get());

Field field = command.getClass().getSuperclass().getSuperclass().getSuperclass().getDeclaredField("threadPool");
Expand Down Expand Up @@ -90,7 +90,7 @@ public static class UserService {

@HystrixCommand(commandKey = "GetUserCommand", groupKey = "UserGroupKey", threadPoolKey = "Test",
commandProperties = {
@HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "110"),
@HystrixProperty(name = "execution.timeoutInMilliseconds", value = "110"),
@HystrixProperty(name = "execution.isolation.thread.interruptOnTimeout", value = "false")
},
threadPoolProperties = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,9 @@ private String getCommandJson(HystrixCommandMetrics commandMetrics) throws IOExc
json.writeBooleanField("propertyValue_circuitBreakerEnabled", commandProperties.circuitBreakerEnabled().get());

json.writeStringField("propertyValue_executionIsolationStrategy", commandProperties.executionIsolationStrategy().get().name());
json.writeNumberField("propertyValue_executionIsolationThreadTimeoutInMilliseconds", commandProperties.executionIsolationThreadTimeoutInMilliseconds().get());
//this naming convention is deprecated as of 1.4.0-RC7, remove in 1.5.x
json.writeNumberField("propertyValue_executionIsolationThreadTimeoutInMilliseconds", commandProperties.executionTimeoutInMilliseconds().get());
json.writeNumberField("propertyValue_executionTimeoutInMilliseconds", commandProperties.executionTimeoutInMilliseconds().get());
json.writeBooleanField("propertyValue_executionIsolationThreadInterruptOnTimeout", commandProperties.executionIsolationThreadInterruptOnTimeout().get());
json.writeStringField("propertyValue_executionIsolationThreadPoolKeyOverride", commandProperties.executionIsolationThreadPoolKeyOverride().get());
json.writeNumberField("propertyValue_executionIsolationSemaphoreMaxConcurrentRequests", commandProperties.executionIsolationSemaphoreMaxConcurrentRequests().get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ static String toJson(HystrixCommandMetrics commandMetrics) throws IOException {
json.writeBooleanField("propertyValue_circuitBreakerEnabled", commandProperties.circuitBreakerEnabled().get());

json.writeStringField("propertyValue_executionIsolationStrategy", commandProperties.executionIsolationStrategy().get().name());
json.writeNumberField("propertyValue_executionIsolationThreadTimeoutInMilliseconds", commandProperties.executionIsolationThreadTimeoutInMilliseconds().get());
//this naming convention is deprecated as of 1.4.0-RC7, remove in 1.5.x
json.writeNumberField("propertyValue_executionIsolationThreadTimeoutInMilliseconds", commandProperties.executionTimeoutInMilliseconds().get());
json.writeNumberField("propertyValue_executionTimeoutInMilliseconds", commandProperties.executionTimeoutInMilliseconds().get());
json.writeBooleanField("propertyValue_executionIsolationThreadInterruptOnTimeout", commandProperties.executionIsolationThreadInterruptOnTimeout().get());
json.writeStringField("propertyValue_executionIsolationThreadPoolKeyOverride", commandProperties.executionIsolationThreadPoolKeyOverride().get());
json.writeNumberField("propertyValue_executionIsolationSemaphoreMaxConcurrentRequests", commandProperties.executionIsolationSemaphoreMaxConcurrentRequests().get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,17 @@ public Boolean getValue() {
return properties.circuitBreakerForceClosed().get();
}
});
//this naming convention is deprecated as of 1.4.0-RC7, remove in 1.5.x
monitors.add(new InformationalMetric<Number>(MonitorConfig.builder("propertyValue_executionIsolationThreadTimeoutInMilliseconds").build()) {
@Override
public Number getValue() {
return properties.executionIsolationThreadTimeoutInMilliseconds().get();
return properties.executionTimeoutInMilliseconds().get();
}
});
monitors.add(new InformationalMetric<Number>(MonitorConfig.builder("propertyValue_executionTimeoutInMilliseconds").build()) {
@Override
public Number getValue() {
return properties.executionTimeoutInMilliseconds().get();
}
});
monitors.add(new InformationalMetric<String>(MonitorConfig.builder("propertyValue_executionIsolationStrategy").build()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,17 @@ public Boolean value() {
return properties.circuitBreakerForceClosed().get();
}
});
//this naming convention is deprecated as of 1.4.0-RC7, remove in 1.5.x
metricsRegistry.newGauge(createMetricName("propertyValue_executionIsolationThreadTimeoutInMilliseconds"), new Gauge<Number>() {
@Override
public Number value() {
return properties.executionIsolationThreadTimeoutInMilliseconds().get();
return properties.executionTimeoutInMilliseconds().get();
}
});
metricsRegistry.newGauge(createMetricName("propertyValue_executionTimeoutInMilliseconds"), new Gauge<Number>() {
@Override
public Number value() {
return properties.executionTimeoutInMilliseconds().get();
}
});
metricsRegistry.newGauge(createMetricName("propertyValue_executionIsolationStrategy"), new Gauge<String>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,7 @@ public void tick() {

@Override
public int getIntervalTimeInMilliseconds() {
return originalCommand.properties.executionIsolationThreadTimeoutInMilliseconds().get();
return originalCommand.properties.executionTimeoutInMilliseconds().get();
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ protected HystrixCommand(HystrixCommandGroupKey group, HystrixThreadPoolKey thre
* <p>
* 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.
* @param executionTimeoutInMilliseconds
* Time in milliseconds at which point the calling thread will timeout and unsubscribe from the command
*/
protected HystrixCommand(HystrixCommandGroupKey group, int executionIsolationThreadTimeoutInMilliseconds) {
this(new Setter(group).andCommandPropertiesDefaults(HystrixCommandProperties.Setter().withExecutionIsolationThreadTimeoutInMilliseconds(executionIsolationThreadTimeoutInMilliseconds)));
protected HystrixCommand(HystrixCommandGroupKey group, int executionTimeoutInMilliseconds) {
this(new Setter(group).andCommandPropertiesDefaults(HystrixCommandProperties.Setter().withExecutionTimeoutInMilliseconds(executionTimeoutInMilliseconds)));
}

/**
Expand All @@ -103,11 +103,11 @@ protected HystrixCommand(HystrixCommandGroupKey group, int executionIsolationThr
* 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.
* @param executionTimeoutInMilliseconds
* Time in milliseconds at which point the calling thread will timeout and unsubscribe from the command
*/
protected HystrixCommand(HystrixCommandGroupKey group, HystrixThreadPoolKey threadPool, int executionIsolationThreadTimeoutInMilliseconds) {
this(new Setter(group).andThreadPoolKey(threadPool).andCommandPropertiesDefaults(HystrixCommandProperties.Setter().withExecutionIsolationThreadTimeoutInMilliseconds(executionIsolationThreadTimeoutInMilliseconds)));
protected HystrixCommand(HystrixCommandGroupKey group, HystrixThreadPoolKey threadPool, int executionTimeoutInMilliseconds) {
this(new Setter(group).andThreadPoolKey(threadPool).andCommandPropertiesDefaults(HystrixCommandProperties.Setter().withExecutionTimeoutInMilliseconds(executionTimeoutInMilliseconds)));
}

/**
Expand Down
Loading