2012-01-20 14:29:50 +01:00
|
|
|
/**
|
|
|
|
|
* Copyright (C) 2009-2011 Typesafe Inc. <http://www.typesafe.com>
|
|
|
|
|
*/
|
|
|
|
|
package akka.remote.netty
|
|
|
|
|
|
|
|
|
|
import com.typesafe.config.Config
|
|
|
|
|
import akka.util.Duration
|
|
|
|
|
import java.util.concurrent.TimeUnit._
|
|
|
|
|
import java.net.InetAddress
|
|
|
|
|
import akka.config.ConfigurationException
|
|
|
|
|
|
|
|
|
|
class NettySettings(config: Config, val systemName: String) {
|
|
|
|
|
|
|
|
|
|
import config._
|
|
|
|
|
|
|
|
|
|
val BackoffTimeout = Duration(getMilliseconds("backoff-timeout"), MILLISECONDS)
|
|
|
|
|
|
|
|
|
|
val SecureCookie: Option[String] = getString("secure-cookie") match {
|
|
|
|
|
case "" ⇒ None
|
|
|
|
|
case cookie ⇒ Some(cookie)
|
|
|
|
|
}
|
|
|
|
|
val RequireCookie = {
|
|
|
|
|
val requireCookie = getBoolean("require-cookie")
|
|
|
|
|
if (requireCookie && SecureCookie.isEmpty) throw new ConfigurationException(
|
|
|
|
|
"Configuration option 'akka.remote.netty.require-cookie' is turned on but no secure cookie is defined in 'akka.remote.netty.secure-cookie'.")
|
|
|
|
|
requireCookie
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
val UsePassiveConnections = getBoolean("use-passive-connections")
|
2012-04-27 01:10:20 +02:00
|
|
|
val UseDispatcherForIO = getString("use-dispatcher-for-io") match {
|
|
|
|
|
case "" | null ⇒ None
|
|
|
|
|
case dispatcher ⇒ Some(dispatcher)
|
|
|
|
|
}
|
2012-01-20 14:29:50 +01:00
|
|
|
|
|
|
|
|
val ReconnectionTimeWindow = Duration(getMilliseconds("reconnection-time-window"), MILLISECONDS)
|
|
|
|
|
val ReadTimeout = Duration(getMilliseconds("read-timeout"), MILLISECONDS)
|
2012-02-01 16:06:30 +01:00
|
|
|
val WriteTimeout = Duration(getMilliseconds("write-timeout"), MILLISECONDS)
|
|
|
|
|
val AllTimeout = Duration(getMilliseconds("all-timeout"), MILLISECONDS)
|
2012-01-20 14:29:50 +01:00
|
|
|
val ReconnectDelay = Duration(getMilliseconds("reconnect-delay"), MILLISECONDS)
|
|
|
|
|
val MessageFrameSize = getBytes("message-frame-size").toInt
|
|
|
|
|
|
|
|
|
|
val Hostname = getString("hostname") match {
|
|
|
|
|
case "" ⇒ InetAddress.getLocalHost.getHostAddress
|
|
|
|
|
case value ⇒ value
|
|
|
|
|
}
|
2012-02-01 16:06:30 +01:00
|
|
|
|
2012-02-18 17:39:20 +01:00
|
|
|
val OutboundLocalAddress: Option[String] = getString("outbound-local-address") match {
|
|
|
|
|
case "auto" | "" | null ⇒ None
|
|
|
|
|
case some ⇒ Some(some)
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-10 08:20:36 +01:00
|
|
|
@deprecated("WARNING: This should only be used by professionals.", "2.0")
|
2012-02-01 16:06:30 +01:00
|
|
|
val PortSelector = getInt("port")
|
2012-01-27 12:14:28 +01:00
|
|
|
|
2012-01-20 14:29:50 +01:00
|
|
|
val ConnectionTimeout = Duration(getMilliseconds("connection-timeout"), MILLISECONDS)
|
|
|
|
|
|
|
|
|
|
val Backlog = getInt("backlog")
|
|
|
|
|
|
2012-01-30 11:48:02 +01:00
|
|
|
val ExecutionPoolKeepalive = Duration(getMilliseconds("execution-pool-keepalive"), MILLISECONDS)
|
2012-01-20 14:29:50 +01:00
|
|
|
|
|
|
|
|
val ExecutionPoolSize = getInt("execution-pool-size") match {
|
|
|
|
|
case sz if sz < 1 ⇒ throw new IllegalArgumentException("akka.remote.netty.execution-pool-size is less than 1")
|
|
|
|
|
case sz ⇒ sz
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
val MaxChannelMemorySize = getBytes("max-channel-memory-size") match {
|
|
|
|
|
case sz if sz < 0 ⇒ throw new IllegalArgumentException("akka.remote.netty.max-channel-memory-size is less than 0 bytes")
|
|
|
|
|
case sz ⇒ sz
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
val MaxTotalMemorySize = getBytes("max-total-memory-size") match {
|
|
|
|
|
case sz if sz < 0 ⇒ throw new IllegalArgumentException("akka.remote.netty.max-total-memory-size is less than 0 bytes")
|
|
|
|
|
case sz ⇒ sz
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|