Skip to content

Commit

Permalink
Output setting around maximum thread pool size and whether this confi…
Browse files Browse the repository at this point in the history
…g is enabled
  • Loading branch information
Matt Jacobs committed Oct 20, 2016
1 parent 643d680 commit f68bd2f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ private static void writeThreadPoolConfigJson(JsonGenerator json, HystrixThreadP
json.writeNumberField("maxQueueSize", threadPoolConfig.getMaxQueueSize());
json.writeNumberField("queueRejectionThreshold", threadPoolConfig.getQueueRejectionThreshold());
json.writeNumberField("keepAliveTimeInMinutes", threadPoolConfig.getKeepAliveTimeInMinutes());
json.writeBooleanField("allowMaximumSizeToDivergeFromCoreSize", threadPoolConfig.getAllowMaximumSizeToDivergeFromCoreSize());
json.writeNumberField("counterBucketSizeInMilliseconds", threadPoolConfig.getRollingCounterBucketSizeInMilliseconds());
json.writeNumberField("counterBucketCount", threadPoolConfig.getRollingCounterNumberOfBuckets());
json.writeEndObject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,20 @@ public class HystrixThreadPoolConfiguration {
private final int maxQueueSize;
private final int queueRejectionThreshold;
private final int keepAliveTimeInMinutes;
private final boolean allowMaximumSizeToDivergeFromCoreSize;
private final int rollingCounterNumberOfBuckets;
private final int rollingCounterBucketSizeInMilliseconds;

public HystrixThreadPoolConfiguration(HystrixThreadPoolKey threadPoolKey, int coreSize, int maximumSize, int maxQueueSize, int queueRejectionThreshold,
int keepAliveTimeInMinutes, int rollingCounterNumberOfBuckets,
int keepAliveTimeInMinutes, boolean allowMaximumSizeToDivergeFromCoreSize, int rollingCounterNumberOfBuckets,
int rollingCounterBucketSizeInMilliseconds) {
this.threadPoolKey = threadPoolKey;
this.coreSize = coreSize;
this.maximumSize = maximumSize;
this.maxQueueSize = maxQueueSize;
this.queueRejectionThreshold = queueRejectionThreshold;
this.keepAliveTimeInMinutes = keepAliveTimeInMinutes;
this.allowMaximumSizeToDivergeFromCoreSize = allowMaximumSizeToDivergeFromCoreSize;
this.rollingCounterNumberOfBuckets = rollingCounterNumberOfBuckets;
this.rollingCounterBucketSizeInMilliseconds = rollingCounterBucketSizeInMilliseconds;
}
Expand All @@ -51,6 +53,7 @@ public static HystrixThreadPoolConfiguration sample(HystrixThreadPoolKey threadP
threadPoolProperties.maxQueueSize().get(),
threadPoolProperties.queueSizeRejectionThreshold().get(),
threadPoolProperties.keepAliveTimeMinutes().get(),
threadPoolProperties.getAllowMaximumSizeToDivergeFromCoreSize(),
threadPoolProperties.metricsRollingStatisticalWindowBuckets().get(),
threadPoolProperties.metricsRollingStatisticalWindowInMilliseconds().get());
}
Expand All @@ -64,7 +67,11 @@ public int getCoreSize() {
}

public int getMaximumSize() {
return maximumSize;
if (allowMaximumSizeToDivergeFromCoreSize) {
return maximumSize;
} else {
return coreSize;
}
}

public int getMaxQueueSize() {
Expand All @@ -79,6 +86,10 @@ public int getKeepAliveTimeInMinutes() {
return keepAliveTimeInMinutes;
}

public boolean getAllowMaximumSizeToDivergeFromCoreSize() {
return allowMaximumSizeToDivergeFromCoreSize;
}

public int getRollingCounterNumberOfBuckets() {
return rollingCounterNumberOfBuckets;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ public static HystrixConfiguration fromByteBuffer(ByteBuffer bb) {
threadPool.getValue().path("maxQueueSize").asInt(),
threadPool.getValue().path("queueRejectionThreshold").asInt(),
threadPool.getValue().path("keepAliveTimeInMinutes").asInt(),
threadPool.getValue().path("allowMaximumSizeToDivergeFromCoreSize").asBoolean(),
threadPool.getValue().path("counterBucketCount").asInt(),
threadPool.getValue().path("counterBucketSizeInMilliseconds").asInt()
);
Expand Down Expand Up @@ -257,6 +258,7 @@ private static void writeThreadPoolConfigJson(JsonGenerator json, HystrixThreadP
json.writeNumberField("maxQueueSize", threadPoolConfig.getMaxQueueSize());
json.writeNumberField("queueRejectionThreshold", threadPoolConfig.getQueueRejectionThreshold());
json.writeNumberField("keepAliveTimeInMinutes", threadPoolConfig.getKeepAliveTimeInMinutes());
json.writeBooleanField("allowMaximumSizeToDivergeFromCoreSize", threadPoolConfig.getAllowMaximumSizeToDivergeFromCoreSize());
json.writeNumberField("counterBucketSizeInMilliseconds", threadPoolConfig.getRollingCounterBucketSizeInMilliseconds());
json.writeNumberField("counterBucketCount", threadPoolConfig.getRollingCounterNumberOfBuckets());
json.writeEndObject();
Expand Down

0 comments on commit f68bd2f

Please sign in to comment.