Skip to content

Commit

Permalink
Write to error log actual dynamicMaxPoolSize from properties if maxPo…
Browse files Browse the repository at this point in the history
…olSize < corePoolSize
  • Loading branch information
Andrey Tereskin committed Nov 16, 2016
1 parent 442966e commit f6baba0
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,30 +216,31 @@ public Scheduler getScheduler(Func0<Boolean> shouldInterruptThread) {
// allow us to change things via fast-properties by setting it each time
private void touchConfig() {
final int dynamicCoreSize = properties.coreSize().get();
int dynamicMaximumSize = properties.maximumSize().get();
final int dynamicMaximumSize = properties.maximumSize().get();
int updatedMaximumSize = dynamicMaximumSize;
final boolean allowSizesToDiverge = properties.getAllowMaximumSizeToDivergeFromCoreSize();
boolean maxTooLow = false;

if (allowSizesToDiverge && dynamicMaximumSize < dynamicCoreSize) {
//if user sets maximum < core (or defaults get us there), we need to maintain invariant of core <= maximum
dynamicMaximumSize = dynamicCoreSize;
updatedMaximumSize = dynamicCoreSize;
maxTooLow = true;
}

if (!allowSizesToDiverge) {
//if user has not opted in to allowing sizes to diverge, ensure maximum == core
dynamicMaximumSize = dynamicCoreSize;
updatedMaximumSize = dynamicCoreSize;
}

// In JDK 6, setCorePoolSize and setMaximumPoolSize will execute a lock operation. Avoid them if the pool size is not changed.
if (threadPool.getCorePoolSize() != dynamicCoreSize || (allowSizesToDiverge && threadPool.getMaximumPoolSize() != dynamicMaximumSize)) {
if (threadPool.getCorePoolSize() != dynamicCoreSize || (allowSizesToDiverge && threadPool.getMaximumPoolSize() != updatedMaximumSize)) {
if (maxTooLow) {
logger.error("Hystrix ThreadPool configuration for : " + metrics.getThreadPoolKey().name() + " is trying to set coreSize = " +
dynamicCoreSize + " and maximumSize = " + dynamicMaximumSize + ". Maximum size will be set to " +
dynamicCoreSize + ", the coreSize value, since it must be equal to or greater than the coreSize value");
}
threadPool.setCorePoolSize(dynamicCoreSize);
threadPool.setMaximumPoolSize(dynamicMaximumSize);
threadPool.setMaximumPoolSize(updatedMaximumSize);
}

threadPool.setKeepAliveTime(properties.keepAliveTimeMinutes().get(), TimeUnit.MINUTES);
Expand Down

0 comments on commit f6baba0

Please sign in to comment.