Merge branch 'master' into wip-1377-context-patriknw
This commit is contained in:
commit
1a93ddb7c0
10 changed files with 161 additions and 49 deletions
|
|
@ -310,22 +310,26 @@ abstract class MessageDispatcherConfigurator() {
|
|||
settings: Settings,
|
||||
createDispatcher: ⇒ (ThreadPoolConfig) ⇒ MessageDispatcher): ThreadPoolConfigDispatcherBuilder = {
|
||||
import ThreadPoolConfigDispatcherBuilder.conf_?
|
||||
import scala.math.{ min, max }
|
||||
|
||||
//Apply the following options to the config if they are present in the config
|
||||
|
||||
ThreadPoolConfigDispatcherBuilder(createDispatcher, ThreadPoolConfig()).configure(
|
||||
conf_?(Some(config getMilliseconds "keep-alive-time"))(time ⇒ _.setKeepAliveTime(Duration(time, TimeUnit.MILLISECONDS))),
|
||||
conf_?(Some(config getDouble "core-pool-size-factor"))(factor ⇒ _.setCorePoolSizeFromFactor(factor)),
|
||||
conf_?(Some(config getDouble "max-pool-size-factor"))(factor ⇒ _.setMaxPoolSizeFromFactor(factor)),
|
||||
conf_?(Some(config getBoolean "allow-core-timeout"))(allow ⇒ _.setAllowCoreThreadTimeout(allow)),
|
||||
conf_?(Some(config getInt "task-queue-size") flatMap {
|
||||
case size if size > 0 ⇒
|
||||
Some(config getString "task-queue-type") map {
|
||||
case "array" ⇒ ThreadPoolConfig.arrayBlockingQueue(size, false) //TODO config fairness?
|
||||
case "" | "linked" ⇒ ThreadPoolConfig.linkedBlockingQueue(size)
|
||||
case x ⇒ throw new IllegalArgumentException("[%s] is not a valid task-queue-type [array|linked]!" format x)
|
||||
}
|
||||
case _ ⇒ None
|
||||
})(queueFactory ⇒ _.setQueueFactory(queueFactory)))
|
||||
ThreadPoolConfigDispatcherBuilder(createDispatcher, ThreadPoolConfig())
|
||||
.setKeepAliveTime(Duration(config getMilliseconds "keep-alive-time", TimeUnit.MILLISECONDS))
|
||||
.setAllowCoreThreadTimeout(config getBoolean "allow-core-timeout")
|
||||
.setCorePoolSize(min(max(ThreadPoolConfig.scaledPoolSize(config getDouble "core-pool-size-factor"),
|
||||
config getInt "core-pool-size-min"), config getInt "core-pool-size-max"))
|
||||
.setMaxPoolSize(min(max(ThreadPoolConfig.scaledPoolSize(config getDouble "max-pool-size-factor"),
|
||||
config getInt "max-pool-size-min"), config getInt "max-pool-size-max"))
|
||||
.configure(
|
||||
conf_?(Some(config getInt "task-queue-size") flatMap {
|
||||
case size if size > 0 ⇒
|
||||
Some(config getString "task-queue-type") map {
|
||||
case "array" ⇒ ThreadPoolConfig.arrayBlockingQueue(size, false) //TODO config fairness?
|
||||
case "" | "linked" ⇒ ThreadPoolConfig.linkedBlockingQueue(size)
|
||||
case x ⇒ throw new IllegalArgumentException("[%s] is not a valid task-queue-type [array|linked]!" format x)
|
||||
}
|
||||
case _ ⇒ None
|
||||
})(queueFactory ⇒ _.setQueueFactory(queueFactory)))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue