Skip to content

Commit 60e47c1

Browse files
author
Matt Jacobs
committed
Favor timeout property that is not thread-specific. (execution.timeoutInMilliseconds)
* Deprecate usages of thread-specific setting (like execution.thread.isolation.timeoutInMilliseconds)
1 parent 66b5323 commit 60e47c1

File tree

13 files changed

+81
-63
lines changed

13 files changed

+81
-63
lines changed

hystrix-contrib/hystrix-codahale-metrics-publisher/src/main/java/com/netflix/hystrix/contrib/codahalemetricspublisher/HystrixCodaHaleMetricsPublisherCommand.java

+8-1
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,17 @@ public Boolean getValue() {
254254
return properties.circuitBreakerForceClosed().get();
255255
}
256256
});
257+
//this naming convention is deprecated as of 1.4.0-RC7, remove in 1.5.x
257258
metricRegistry.register(createMetricName("propertyValue_executionIsolationThreadTimeoutInMilliseconds"), new Gauge<Number>() {
258259
@Override
259260
public Number getValue() {
260-
return properties.executionIsolationThreadTimeoutInMilliseconds().get();
261+
return properties.executionTimeoutInMilliseconds().get();
262+
}
263+
});
264+
metricRegistry.register(createMetricName("propertyValue_executionTimeoutInMilliseconds"), new Gauge<Number>() {
265+
@Override
266+
public Number getValue() {
267+
return properties.executionTimeoutInMilliseconds().get();
261268
}
262269
});
263270
metricRegistry.register(createMetricName("propertyValue_executionIsolationStrategy"), new Gauge<String>() {

hystrix-contrib/hystrix-javanica/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ Command properties can be set using @HystrixCommand's 'commandProperties' like b
343343

344344
```java
345345
@HystrixCommand(commandProperties = {
346-
@HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "500")
346+
@HystrixProperty(name = "execution.timeoutInMilliseconds", value = "500")
347347
})
348348
public User getUserById(String id) {
349349
return userResource.getUserById(id);
@@ -353,15 +353,15 @@ Command properties can be set using @HystrixCommand's 'commandProperties' like b
353353
Javanica dynamically sets properties using Hystrix ConfigurationManager.
354354
For the example above Javanica behind the scenes performs next action:
355355
```java
356-
ConfigurationManager.getConfigInstance().setProperty("hystrix.command.getUserById.execution.isolation.thread.timeoutInMilliseconds", "500");
356+
ConfigurationManager.getConfigInstance().setProperty("hystrix.command.getUserById.execution.timeoutInMilliseconds", "500");
357357
```
358358
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)
359359

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

362362
```java
363363
@HystrixCommand(commandProperties = {
364-
@HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "500")
364+
@HystrixProperty(name = "execution.timeoutInMilliseconds", value = "500")
365365
},
366366
threadPoolProperties = {
367367
@HystrixProperty(name = "coreSize", value = "30"),

hystrix-contrib/hystrix-javanica/src/test/java/com/netflix/hystrix/contrib/javanica/test/spring/configuration/command/CommandPropertiesTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public void testGetUser() throws NoSuchFieldException, IllegalAccessException {
4646
assertEquals("Test", command.getThreadPoolKey().name());
4747
assertTrue(command.getExecutionEvents().contains(HystrixEventType.SUCCESS));
4848
// assert properties
49-
assertEquals(110, command.getProperties().executionIsolationThreadTimeoutInMilliseconds().get().intValue());
49+
assertEquals(110, command.getProperties().executionTimeoutInMilliseconds().get().intValue());
5050
assertEquals(false, command.getProperties().executionIsolationThreadInterruptOnTimeout().get());
5151

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

9191
@HystrixCommand(commandKey = "GetUserCommand", groupKey = "UserGroupKey", threadPoolKey = "Test",
9292
commandProperties = {
93-
@HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "110"),
93+
@HystrixProperty(name = "execution.timeoutInMilliseconds", value = "110"),
9494
@HystrixProperty(name = "execution.isolation.thread.interruptOnTimeout", value = "false")
9595
},
9696
threadPoolProperties = {

hystrix-contrib/hystrix-metrics-event-stream/src/main/java/com/netflix/hystrix/contrib/metrics/eventstream/HystrixMetricsPoller.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,9 @@ private String getCommandJson(HystrixCommandMetrics commandMetrics) throws IOExc
260260
json.writeBooleanField("propertyValue_circuitBreakerEnabled", commandProperties.circuitBreakerEnabled().get());
261261

262262
json.writeStringField("propertyValue_executionIsolationStrategy", commandProperties.executionIsolationStrategy().get().name());
263-
json.writeNumberField("propertyValue_executionIsolationThreadTimeoutInMilliseconds", commandProperties.executionIsolationThreadTimeoutInMilliseconds().get());
263+
//this naming convention is deprecated as of 1.4.0-RC7, remove in 1.5.x
264+
json.writeNumberField("propertyValue_executionIsolationThreadTimeoutInMilliseconds", commandProperties.executionTimeoutInMilliseconds().get());
265+
json.writeNumberField("propertyValue_executionTimeoutInMilliseconds", commandProperties.executionTimeoutInMilliseconds().get());
264266
json.writeBooleanField("propertyValue_executionIsolationThreadInterruptOnTimeout", commandProperties.executionIsolationThreadInterruptOnTimeout().get());
265267
json.writeStringField("propertyValue_executionIsolationThreadPoolKeyOverride", commandProperties.executionIsolationThreadPoolKeyOverride().get());
266268
json.writeNumberField("propertyValue_executionIsolationSemaphoreMaxConcurrentRequests", commandProperties.executionIsolationSemaphoreMaxConcurrentRequests().get());

hystrix-contrib/hystrix-rx-netty-metrics-stream/src/main/java/com/netflix/hystrix/contrib/rxnetty/metricsstream/JsonMappers.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ static String toJson(HystrixCommandMetrics commandMetrics) throws IOException {
108108
json.writeBooleanField("propertyValue_circuitBreakerEnabled", commandProperties.circuitBreakerEnabled().get());
109109

110110
json.writeStringField("propertyValue_executionIsolationStrategy", commandProperties.executionIsolationStrategy().get().name());
111-
json.writeNumberField("propertyValue_executionIsolationThreadTimeoutInMilliseconds", commandProperties.executionIsolationThreadTimeoutInMilliseconds().get());
111+
//this naming convention is deprecated as of 1.4.0-RC7, remove in 1.5.x
112+
json.writeNumberField("propertyValue_executionIsolationThreadTimeoutInMilliseconds", commandProperties.executionTimeoutInMilliseconds().get());
113+
json.writeNumberField("propertyValue_executionTimeoutInMilliseconds", commandProperties.executionTimeoutInMilliseconds().get());
112114
json.writeBooleanField("propertyValue_executionIsolationThreadInterruptOnTimeout", commandProperties.executionIsolationThreadInterruptOnTimeout().get());
113115
json.writeStringField("propertyValue_executionIsolationThreadPoolKeyOverride", commandProperties.executionIsolationThreadPoolKeyOverride().get());
114116
json.writeNumberField("propertyValue_executionIsolationSemaphoreMaxConcurrentRequests", commandProperties.executionIsolationSemaphoreMaxConcurrentRequests().get());

hystrix-contrib/hystrix-servo-metrics-publisher/src/main/java/com/netflix/hystrix/contrib/servopublisher/HystrixServoMetricsPublisherCommand.java

+8-1
Original file line numberDiff line numberDiff line change
@@ -323,10 +323,17 @@ public Boolean getValue() {
323323
return properties.circuitBreakerForceClosed().get();
324324
}
325325
});
326+
//this naming convention is deprecated as of 1.4.0-RC7, remove in 1.5.x
326327
monitors.add(new InformationalMetric<Number>(MonitorConfig.builder("propertyValue_executionIsolationThreadTimeoutInMilliseconds").build()) {
327328
@Override
328329
public Number getValue() {
329-
return properties.executionIsolationThreadTimeoutInMilliseconds().get();
330+
return properties.executionTimeoutInMilliseconds().get();
331+
}
332+
});
333+
monitors.add(new InformationalMetric<Number>(MonitorConfig.builder("propertyValue_executionTimeoutInMilliseconds").build()) {
334+
@Override
335+
public Number getValue() {
336+
return properties.executionTimeoutInMilliseconds().get();
330337
}
331338
});
332339
monitors.add(new InformationalMetric<String>(MonitorConfig.builder("propertyValue_executionIsolationStrategy").build()) {

hystrix-contrib/hystrix-yammer-metrics-publisher/src/main/java/com/netflix/hystrix/contrib/yammermetricspublisher/HystrixYammerMetricsPublisherCommand.java

+8-1
Original file line numberDiff line numberDiff line change
@@ -255,10 +255,17 @@ public Boolean value() {
255255
return properties.circuitBreakerForceClosed().get();
256256
}
257257
});
258+
//this naming convention is deprecated as of 1.4.0-RC7, remove in 1.5.x
258259
metricsRegistry.newGauge(createMetricName("propertyValue_executionIsolationThreadTimeoutInMilliseconds"), new Gauge<Number>() {
259260
@Override
260261
public Number value() {
261-
return properties.executionIsolationThreadTimeoutInMilliseconds().get();
262+
return properties.executionTimeoutInMilliseconds().get();
263+
}
264+
});
265+
metricsRegistry.newGauge(createMetricName("propertyValue_executionTimeoutInMilliseconds"), new Gauge<Number>() {
266+
@Override
267+
public Number value() {
268+
return properties.executionTimeoutInMilliseconds().get();
262269
}
263270
});
264271
metricsRegistry.newGauge(createMetricName("propertyValue_executionIsolationStrategy"), new Gauge<String>() {

hystrix-core/src/main/java/com/netflix/hystrix/AbstractCommand.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,7 @@ public void tick() {
954954

955955
@Override
956956
public int getIntervalTimeInMilliseconds() {
957-
return originalCommand.properties.executionIsolationThreadTimeoutInMilliseconds().get();
957+
return originalCommand.properties.executionTimeoutInMilliseconds().get();
958958
}
959959
};
960960

hystrix-core/src/main/java/com/netflix/hystrix/HystrixCommand.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ protected HystrixCommand(HystrixCommandGroupKey group, HystrixThreadPoolKey thre
8484
* <p>
8585
* 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,
8686
* common business purpose etc.
87-
* @param executionIsolationThreadTimeoutInMilliseconds
88-
* Time in milliseconds at which point the calling thread will timeout (using {@link Future#get}) and walk away from the executing thread.
87+
* @param executionTimeoutInMilliseconds
88+
* Time in milliseconds at which point the calling thread will timeout and unsubscribe from the command
8989
*/
90-
protected HystrixCommand(HystrixCommandGroupKey group, int executionIsolationThreadTimeoutInMilliseconds) {
91-
this(new Setter(group).andCommandPropertiesDefaults(HystrixCommandProperties.Setter().withExecutionIsolationThreadTimeoutInMilliseconds(executionIsolationThreadTimeoutInMilliseconds)));
90+
protected HystrixCommand(HystrixCommandGroupKey group, int executionTimeoutInMilliseconds) {
91+
this(new Setter(group).andCommandPropertiesDefaults(HystrixCommandProperties.Setter().withExecutionTimeoutInMilliseconds(executionTimeoutInMilliseconds)));
9292
}
9393

9494
/**
@@ -103,11 +103,11 @@ protected HystrixCommand(HystrixCommandGroupKey group, int executionIsolationThr
103103
* common business purpose etc.
104104
* @param threadPool
105105
* {@link HystrixThreadPoolKey} used to identify the thread pool in which a {@link HystrixCommand} executes.
106-
* @param executionIsolationThreadTimeoutInMilliseconds
107-
* Time in milliseconds at which point the calling thread will timeout (using {@link Future#get}) and walk away from the executing thread.
106+
* @param executionTimeoutInMilliseconds
107+
* Time in milliseconds at which point the calling thread will timeout and unsubscribe from the command
108108
*/
109-
protected HystrixCommand(HystrixCommandGroupKey group, HystrixThreadPoolKey threadPool, int executionIsolationThreadTimeoutInMilliseconds) {
110-
this(new Setter(group).andThreadPoolKey(threadPool).andCommandPropertiesDefaults(HystrixCommandProperties.Setter().withExecutionIsolationThreadTimeoutInMilliseconds(executionIsolationThreadTimeoutInMilliseconds)));
109+
protected HystrixCommand(HystrixCommandGroupKey group, HystrixThreadPoolKey threadPool, int executionTimeoutInMilliseconds) {
110+
this(new Setter(group).andThreadPoolKey(threadPool).andCommandPropertiesDefaults(HystrixCommandProperties.Setter().withExecutionTimeoutInMilliseconds(executionTimeoutInMilliseconds)));
111111
}
112112

113113
/**

0 commit comments

Comments
 (0)