2011-11-22 13:04:10 +01:00
|
|
|
/**
|
2012-01-19 18:21:06 +01:00
|
|
|
* Copyright (C) 2009-2012 Typesafe Inc. <http://www.typesafe.com>
|
2011-11-22 13:04:10 +01:00
|
|
|
*/
|
|
|
|
|
package akka.remote
|
|
|
|
|
|
|
|
|
|
import com.typesafe.config.Config
|
|
|
|
|
import akka.util.Duration
|
|
|
|
|
import java.util.concurrent.TimeUnit.MILLISECONDS
|
|
|
|
|
import java.net.InetAddress
|
|
|
|
|
import akka.config.ConfigurationException
|
2011-11-25 12:02:25 +01:00
|
|
|
import scala.collection.JavaConverters._
|
2011-11-22 13:04:10 +01:00
|
|
|
|
2012-01-05 09:23:02 +01:00
|
|
|
class RemoteSettings(val config: Config, val systemName: String) {
|
2011-11-22 13:04:10 +01:00
|
|
|
|
2011-11-24 18:53:18 +01:00
|
|
|
import config._
|
2011-11-22 13:04:10 +01:00
|
|
|
|
2012-01-21 00:32:37 +01:00
|
|
|
final val RemoteTransport = getString("akka.remote.transport")
|
|
|
|
|
final val FailureDetectorThreshold = getInt("akka.remote.failure-detector.threshold")
|
|
|
|
|
final val FailureDetectorMaxSampleSize = getInt("akka.remote.failure-detector.max-sample-size")
|
|
|
|
|
final val ShouldCompressData = getBoolean("akka.remote.use-compression")
|
|
|
|
|
final val RemoteSystemDaemonAckTimeout = Duration(getMilliseconds("akka.remote.remote-daemon-ack-timeout"), MILLISECONDS)
|
|
|
|
|
final val InitalDelayForGossip = Duration(getMilliseconds("akka.remote.gossip.initialDelay"), MILLISECONDS)
|
|
|
|
|
final val GossipFrequency = Duration(getMilliseconds("akka.remote.gossip.frequency"), MILLISECONDS)
|
|
|
|
|
final val BackoffTimeout = Duration(getMilliseconds("akka.remote.backoff-timeout"), MILLISECONDS)
|
|
|
|
|
final val LogReceivedMessages = getBoolean("akka.remote.log-received-messages")
|
|
|
|
|
final val LogSentMessages = getBoolean("akka.remote.log-sent-messages")
|
2011-11-22 13:04:10 +01:00
|
|
|
|
2011-12-06 16:49:39 +01:00
|
|
|
// TODO cluster config will go into akka-cluster/reference.conf when we enable that module
|
2012-01-21 00:32:37 +01:00
|
|
|
final val SeedNodes = Set.empty[RemoteNettyAddress] ++ getStringList("akka.cluster.seed-nodes").asScala.collect {
|
2011-12-11 20:00:26 +01:00
|
|
|
case RemoteAddressExtractor(addr) ⇒ addr.transport
|
|
|
|
|
}
|
2011-11-22 13:04:10 +01:00
|
|
|
|
2012-01-21 00:32:37 +01:00
|
|
|
final val serverSettings = new RemoteServerSettings
|
|
|
|
|
final val clientSettings = new RemoteClientSettings
|
2011-11-22 13:04:10 +01:00
|
|
|
|
2011-11-24 18:53:18 +01:00
|
|
|
class RemoteClientSettings {
|
2012-01-18 18:10:56 +01:00
|
|
|
val SecureCookie: Option[String] = getString("akka.remote.secure-cookie") match {
|
2011-11-24 18:53:18 +01:00
|
|
|
case "" ⇒ None
|
|
|
|
|
case cookie ⇒ Some(cookie)
|
2011-11-22 13:04:10 +01:00
|
|
|
}
|
|
|
|
|
|
2012-01-21 00:32:37 +01:00
|
|
|
final val ConnectionTimeout = Duration(getMilliseconds("akka.remote.client.connection-timeout"), MILLISECONDS)
|
|
|
|
|
final val ReconnectionTimeWindow = Duration(getMilliseconds("akka.remote.client.reconnection-time-window"), MILLISECONDS)
|
|
|
|
|
final val ReadTimeout = Duration(getMilliseconds("akka.remote.client.read-timeout"), MILLISECONDS)
|
|
|
|
|
final val ReconnectDelay = Duration(getMilliseconds("akka.remote.client.reconnect-delay"), MILLISECONDS)
|
|
|
|
|
final val MessageFrameSize = getBytes("akka.remote.client.message-frame-size").toInt
|
2011-11-24 18:53:18 +01:00
|
|
|
}
|
2011-11-22 13:04:10 +01:00
|
|
|
|
2011-11-24 18:53:18 +01:00
|
|
|
class RemoteServerSettings {
|
|
|
|
|
import scala.collection.JavaConverters._
|
2012-01-21 00:32:37 +01:00
|
|
|
final val MessageFrameSize = getBytes("akka.remote.server.message-frame-size").toInt
|
|
|
|
|
final val SecureCookie: Option[String] = getString("akka.remote.secure-cookie") match {
|
2011-11-24 18:53:18 +01:00
|
|
|
case "" ⇒ None
|
|
|
|
|
case cookie ⇒ Some(cookie)
|
|
|
|
|
}
|
2012-01-21 00:32:37 +01:00
|
|
|
final val RequireCookie = {
|
2012-01-18 18:10:56 +01:00
|
|
|
val requireCookie = getBoolean("akka.remote.server.require-cookie")
|
2011-11-24 18:53:18 +01:00
|
|
|
if (requireCookie && SecureCookie.isEmpty) throw new ConfigurationException(
|
|
|
|
|
"Configuration option 'akka.remote.server.require-cookie' is turned on but no secure cookie is defined in 'akka.remote.secure-cookie'.")
|
|
|
|
|
requireCookie
|
2011-11-22 13:04:10 +01:00
|
|
|
}
|
|
|
|
|
|
2012-01-21 00:32:37 +01:00
|
|
|
final val UsePassiveConnections = getBoolean("akka.remote.use-passive-connections")
|
2011-11-22 13:04:10 +01:00
|
|
|
|
2012-01-21 00:32:37 +01:00
|
|
|
final val UntrustedMode = getBoolean("akka.remote.server.untrusted-mode")
|
|
|
|
|
final val Hostname = getString("akka.remote.server.hostname") match {
|
2011-11-24 18:53:18 +01:00
|
|
|
case "" ⇒ InetAddress.getLocalHost.getHostAddress
|
|
|
|
|
case value ⇒ value
|
|
|
|
|
}
|
2012-01-21 00:32:37 +01:00
|
|
|
final val Port = getInt("akka.remote.server.port") match {
|
2012-01-20 15:36:56 +01:00
|
|
|
case 0 ⇒ try {
|
2012-01-20 14:27:00 +01:00
|
|
|
val s = new java.net.ServerSocket(0)
|
|
|
|
|
try s.getLocalPort finally s.close()
|
2012-01-20 15:36:56 +01:00
|
|
|
} catch { case e ⇒ throw new ConfigurationException("Unable to obtain random port", e) }
|
|
|
|
|
case other ⇒ other
|
2012-01-20 14:27:00 +01:00
|
|
|
}
|
2011-11-22 13:04:10 +01:00
|
|
|
|
2012-01-21 00:32:37 +01:00
|
|
|
final val Backlog = getInt("akka.remote.server.backlog")
|
2011-12-11 20:00:26 +01:00
|
|
|
|
2012-01-21 00:32:37 +01:00
|
|
|
final val ExecutionPoolKeepAlive = Duration(getMilliseconds("akka.remote.server.execution-pool-keepalive"), MILLISECONDS)
|
2011-12-29 18:00:44 +01:00
|
|
|
|
2012-01-21 00:32:37 +01:00
|
|
|
final val ExecutionPoolSize = getInt("akka.remote.server.execution-pool-size") match {
|
2011-12-29 18:00:44 +01:00
|
|
|
case sz if sz < 1 ⇒ throw new IllegalArgumentException("akka.remote.server.execution-pool-size is less than 1")
|
|
|
|
|
case sz ⇒ sz
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-21 00:32:37 +01:00
|
|
|
final val MaxChannelMemorySize = getBytes("akka.remote.server.max-channel-memory-size") match {
|
2011-12-30 12:04:20 +01:00
|
|
|
case sz if sz < 0 ⇒ throw new IllegalArgumentException("akka.remote.server.max-channel-memory-size is less than 0 bytes")
|
2011-12-29 18:00:44 +01:00
|
|
|
case sz ⇒ sz
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-21 00:32:37 +01:00
|
|
|
final val MaxTotalMemorySize = getBytes("akka.remote.server.max-total-memory-size") match {
|
2011-12-30 12:04:20 +01:00
|
|
|
case sz if sz < 0 ⇒ throw new IllegalArgumentException("akka.remote.server.max-total-memory-size is less than 0 bytes")
|
2011-12-29 18:00:44 +01:00
|
|
|
case sz ⇒ sz
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-11 20:00:26 +01:00
|
|
|
// TODO handle the system name right and move this to config file syntax
|
2012-01-21 00:32:37 +01:00
|
|
|
final val URI = "akka://sys@" + Hostname + ":" + Port
|
2011-11-22 13:04:10 +01:00
|
|
|
}
|
|
|
|
|
}
|