Skip to content

Commit 0c8f733

Browse files
authored
Merge pull request #1435 from ptab/fix-reading-allowMaximumSizeToDivergeFromCoreSize-from-archaius
Properly handle default values for allowMaximumSizeToDivergeFromCoreSize
2 parents 148e8f1 + b61919d commit 0c8f733

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ public HystrixThreadPoolDefault(HystrixThreadPoolKey threadPoolKey, HystrixThrea
174174
this.queueSize = properties.maxQueueSize().get();
175175
this.queue = concurrencyStrategy.getBlockingQueue(queueSize);
176176

177-
if (properties.getAllowMaximumSizeToDivergeFromCoreSize()) {
177+
if (properties.getAllowMaximumSizeToDivergeFromCoreSize().get()) {
178178
this.metrics = HystrixThreadPoolMetrics.getInstance(threadPoolKey,
179179
concurrencyStrategy.getThreadPool(threadPoolKey, properties.coreSize(), properties.maximumSize(), properties.keepAliveTimeMinutes(), TimeUnit.MINUTES, queue),
180180
properties);
@@ -218,7 +218,7 @@ private void touchConfig() {
218218
final int dynamicCoreSize = properties.coreSize().get();
219219
final int dynamicMaximumSize = properties.maximumSize().get();
220220
int updatedMaximumSize = dynamicMaximumSize;
221-
final boolean allowSizesToDiverge = properties.getAllowMaximumSizeToDivergeFromCoreSize();
221+
final boolean allowSizesToDiverge = properties.getAllowMaximumSizeToDivergeFromCoreSize().get();
222222
boolean maxTooLow = false;
223223

224224
if (allowSizesToDiverge && dynamicMaximumSize < dynamicCoreSize) {

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public abstract class HystrixThreadPoolProperties {
6363
private final HystrixProperty<Integer> keepAliveTime;
6464
private final HystrixProperty<Integer> maxQueueSize;
6565
private final HystrixProperty<Integer> queueSizeRejectionThreshold;
66-
private final boolean allowMaximumSizeToDivergeFromCoreSize;
66+
private final HystrixProperty<Boolean> allowMaximumSizeToDivergeFromCoreSize;
6767

6868
private final HystrixProperty<Integer> threadPoolRollingNumberStatisticalWindowInMilliseconds;
6969
private final HystrixProperty<Integer> threadPoolRollingNumberStatisticalWindowBuckets;
@@ -77,7 +77,7 @@ protected HystrixThreadPoolProperties(HystrixThreadPoolKey key, Setter builder)
7777
}
7878

7979
protected HystrixThreadPoolProperties(HystrixThreadPoolKey key, Setter builder, String propertyPrefix) {
80-
this.allowMaximumSizeToDivergeFromCoreSize = getValueOnce(propertyPrefix, key, "allowMaximumSizeToDivergeFromCoreSize",
80+
this.allowMaximumSizeToDivergeFromCoreSize = getProperty(propertyPrefix, key, "allowMaximumSizeToDivergeFromCoreSize",
8181
builder.getAllowMaximumSizeToDivergeFromCoreSize(), default_allow_maximum_size_to_diverge_from_core_size);
8282

8383
this.corePoolSize = getProperty(propertyPrefix, key, "coreSize", builder.getCoreSize(), default_coreSize);
@@ -99,12 +99,11 @@ private static HystrixProperty<Integer> getProperty(String propertyPrefix, Hystr
9999
.build();
100100
}
101101

102-
private static boolean getValueOnce(String propertyPrefix, HystrixThreadPoolKey key, String instanceProperty, boolean builderOverrideValue, boolean defaultValue) {
102+
private static HystrixProperty<Boolean> getProperty(String propertyPrefix, HystrixThreadPoolKey key, String instanceProperty, Boolean builderOverrideValue, Boolean defaultValue) {
103103
return forBoolean()
104104
.add(propertyPrefix + ".threadpool." + key.name() + "." + instanceProperty, builderOverrideValue)
105105
.add(propertyPrefix + ".threadpool.default." + instanceProperty, defaultValue)
106-
.build()
107-
.get();
106+
.build();
108107
}
109108

110109
/**
@@ -158,7 +157,7 @@ public HystrixProperty<Integer> queueSizeRejectionThreshold() {
158157
return queueSizeRejectionThreshold;
159158
}
160159

161-
public boolean getAllowMaximumSizeToDivergeFromCoreSize() {
160+
public HystrixProperty<Boolean> getAllowMaximumSizeToDivergeFromCoreSize() {
162161
return allowMaximumSizeToDivergeFromCoreSize;
163162
}
164163

@@ -218,7 +217,7 @@ public static class Setter {
218217
private Integer keepAliveTimeMinutes = null;
219218
private Integer maxQueueSize = null;
220219
private Integer queueSizeRejectionThreshold = null;
221-
private boolean allowMaximumSizeToDivergeFromCoreSize = false;
220+
private Boolean allowMaximumSizeToDivergeFromCoreSize = null;
222221
private Integer rollingStatisticalWindowInMilliseconds = null;
223222
private Integer rollingStatisticalWindowBuckets = null;
224223

@@ -245,7 +244,7 @@ public Integer getQueueSizeRejectionThreshold() {
245244
return queueSizeRejectionThreshold;
246245
}
247246

248-
public boolean getAllowMaximumSizeToDivergeFromCoreSize() {
247+
public Boolean getAllowMaximumSizeToDivergeFromCoreSize() {
249248
return allowMaximumSizeToDivergeFromCoreSize;
250249
}
251250

hystrix-core/src/main/java/com/netflix/hystrix/config/HystrixThreadPoolConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public static HystrixThreadPoolConfiguration sample(HystrixThreadPoolKey threadP
5353
threadPoolProperties.maxQueueSize().get(),
5454
threadPoolProperties.queueSizeRejectionThreshold().get(),
5555
threadPoolProperties.keepAliveTimeMinutes().get(),
56-
threadPoolProperties.getAllowMaximumSizeToDivergeFromCoreSize(),
56+
threadPoolProperties.getAllowMaximumSizeToDivergeFromCoreSize().get(),
5757
threadPoolProperties.metricsRollingStatisticalWindowBuckets().get(),
5858
threadPoolProperties.metricsRollingStatisticalWindowInMilliseconds().get());
5959
}

0 commit comments

Comments
 (0)