Skip to content

Commit

Permalink
Changing so that you can specify any dispatcher id to be used for rem…
Browse files Browse the repository at this point in the history
…oting
  • Loading branch information
viktorklang committed Apr 26, 2012
1 parent 45694c6 commit a99d980
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
6 changes: 3 additions & 3 deletions akka-remote/src/main/resources/reference.conf
Expand Up @@ -92,9 +92,9 @@ akka {
# (I) Reuse inbound connections for outbound messages
use-passive-connections = on

# (I) If "on" then the default dispatcher will be used to accept inbound connections,
# and IO. If "off" then dedicated threads will be used.
use-default-dispatcher-for-io = off
# (I) EXPERIMENTAL If "<id.of.dispatcher>" then the specified dispatcher will be used to accept inbound connections,
# and perform IO. If "" then dedicated threads will be used.
use-dispatcher-for-io = ""

# (I) The hostname or ip to bind the remoting to,
# InetAddress.getLocalHost.getHostAddress is used if empty
Expand Down
12 changes: 8 additions & 4 deletions akka-remote/src/main/scala/akka/remote/netty/Server.scala
Expand Up @@ -26,10 +26,14 @@ class NettyRemoteServer(val netty: NettyRemoteTransport) {

val ip = InetAddress.getByName(settings.Hostname)

private val factory = {
val boss, worker = if (settings.UseDefaultDispatcherForIO) netty.system.dispatcher else Executors.newCachedThreadPool()
new NioServerSocketChannelFactory(boss, worker)
}
private val factory =
settings.UseDispatcherForIO match {
case Some(id)
val d = netty.system.dispatchers.lookup(id)
new NioServerSocketChannelFactory(d, d)
case None
new NioServerSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedThreadPool())
}

private val executionHandler = new ExecutionHandler(netty.executor)

Expand Down
5 changes: 4 additions & 1 deletion akka-remote/src/main/scala/akka/remote/netty/Settings.scala
Expand Up @@ -27,7 +27,10 @@ class NettySettings(config: Config, val systemName: String) {
}

val UsePassiveConnections = getBoolean("use-passive-connections")
val UseDefaultDispatcherForIO = getBoolean("use-default-dispatcher-for-io")
val UseDispatcherForIO = getString("use-dispatcher-for-io") match {
case "" | null None
case dispatcher Some(dispatcher)
}

val ReconnectionTimeWindow = Duration(getMilliseconds("reconnection-time-window"), MILLISECONDS)
val ReadTimeout = Duration(getMilliseconds("read-timeout"), MILLISECONDS)
Expand Down

0 comments on commit a99d980

Please sign in to comment.