Skip to content

Commit

Permalink
Properly handle default values for allowMaximumSizeToDivergeFromCoreS…
Browse files Browse the repository at this point in the history
…ize when

configuring properties using Archaius
  • Loading branch information
ptab committed Dec 6, 2016
1 parent 3f7ad96 commit b61919d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public HystrixThreadPoolDefault(HystrixThreadPoolKey threadPoolKey, HystrixThrea
this.queueSize = properties.maxQueueSize().get();
this.queue = concurrencyStrategy.getBlockingQueue(queueSize);

if (properties.getAllowMaximumSizeToDivergeFromCoreSize()) {
if (properties.getAllowMaximumSizeToDivergeFromCoreSize().get()) {
this.metrics = HystrixThreadPoolMetrics.getInstance(threadPoolKey,
concurrencyStrategy.getThreadPool(threadPoolKey, properties.coreSize(), properties.maximumSize(), properties.keepAliveTimeMinutes(), TimeUnit.MINUTES, queue),
properties);
Expand Down Expand Up @@ -218,7 +218,7 @@ private void touchConfig() {
final int dynamicCoreSize = properties.coreSize().get();
final int dynamicMaximumSize = properties.maximumSize().get();
int updatedMaximumSize = dynamicMaximumSize;
final boolean allowSizesToDiverge = properties.getAllowMaximumSizeToDivergeFromCoreSize();
final boolean allowSizesToDiverge = properties.getAllowMaximumSizeToDivergeFromCoreSize().get();
boolean maxTooLow = false;

if (allowSizesToDiverge && dynamicMaximumSize < dynamicCoreSize) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public abstract class HystrixThreadPoolProperties {
private final HystrixProperty<Integer> keepAliveTime;
private final HystrixProperty<Integer> maxQueueSize;
private final HystrixProperty<Integer> queueSizeRejectionThreshold;
private final boolean allowMaximumSizeToDivergeFromCoreSize;
private final HystrixProperty<Boolean> allowMaximumSizeToDivergeFromCoreSize;

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

protected HystrixThreadPoolProperties(HystrixThreadPoolKey key, Setter builder, String propertyPrefix) {
this.allowMaximumSizeToDivergeFromCoreSize = getValueOnce(propertyPrefix, key, "allowMaximumSizeToDivergeFromCoreSize",
this.allowMaximumSizeToDivergeFromCoreSize = getProperty(propertyPrefix, key, "allowMaximumSizeToDivergeFromCoreSize",
builder.getAllowMaximumSizeToDivergeFromCoreSize(), default_allow_maximum_size_to_diverge_from_core_size);

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

private static boolean getValueOnce(String propertyPrefix, HystrixThreadPoolKey key, String instanceProperty, boolean builderOverrideValue, boolean defaultValue) {
private static HystrixProperty<Boolean> getProperty(String propertyPrefix, HystrixThreadPoolKey key, String instanceProperty, Boolean builderOverrideValue, Boolean defaultValue) {
return forBoolean()
.add(propertyPrefix + ".threadpool." + key.name() + "." + instanceProperty, builderOverrideValue)
.add(propertyPrefix + ".threadpool.default." + instanceProperty, defaultValue)
.build()
.get();
.build();
}

/**
Expand Down Expand Up @@ -158,7 +157,7 @@ public HystrixProperty<Integer> queueSizeRejectionThreshold() {
return queueSizeRejectionThreshold;
}

public boolean getAllowMaximumSizeToDivergeFromCoreSize() {
public HystrixProperty<Boolean> getAllowMaximumSizeToDivergeFromCoreSize() {
return allowMaximumSizeToDivergeFromCoreSize;
}

Expand Down Expand Up @@ -218,7 +217,7 @@ public static class Setter {
private Integer keepAliveTimeMinutes = null;
private Integer maxQueueSize = null;
private Integer queueSizeRejectionThreshold = null;
private boolean allowMaximumSizeToDivergeFromCoreSize = false;
private Boolean allowMaximumSizeToDivergeFromCoreSize = null;
private Integer rollingStatisticalWindowInMilliseconds = null;
private Integer rollingStatisticalWindowBuckets = null;

Expand All @@ -245,7 +244,7 @@ public Integer getQueueSizeRejectionThreshold() {
return queueSizeRejectionThreshold;
}

public boolean getAllowMaximumSizeToDivergeFromCoreSize() {
public Boolean getAllowMaximumSizeToDivergeFromCoreSize() {
return allowMaximumSizeToDivergeFromCoreSize;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static HystrixThreadPoolConfiguration sample(HystrixThreadPoolKey threadP
threadPoolProperties.maxQueueSize().get(),
threadPoolProperties.queueSizeRejectionThreshold().get(),
threadPoolProperties.keepAliveTimeMinutes().get(),
threadPoolProperties.getAllowMaximumSizeToDivergeFromCoreSize(),
threadPoolProperties.getAllowMaximumSizeToDivergeFromCoreSize().get(),
threadPoolProperties.metricsRollingStatisticalWindowBuckets().get(),
threadPoolProperties.metricsRollingStatisticalWindowInMilliseconds().get());
}
Expand Down

0 comments on commit b61919d

Please sign in to comment.