2011-11-22 13:04:10 +01:00
|
|
|
/**
|
|
|
|
|
* Copyright (C) 2009-2011 Typesafe Inc. <http://www.typesafe.com>
|
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
|
|
import com.eaio.uuid.UUID
|
2011-11-24 18:53:18 +01:00
|
|
|
import akka.actor._
|
2011-11-25 12:02:25 +01:00
|
|
|
import scala.collection.JavaConverters._
|
|
|
|
|
|
2011-11-25 10:45:22 +01:00
|
|
|
object RemoteExtension extends ExtensionId[RemoteExtensionSettings] with ExtensionIdProvider {
|
2011-11-24 18:53:18 +01:00
|
|
|
def lookup() = this
|
2011-11-29 11:50:22 +01:00
|
|
|
def createExtension(system: ActorSystemImpl) = new RemoteExtensionSettings(system.settings.config)
|
2011-11-24 18:53:18 +01:00
|
|
|
}
|
2011-11-22 13:04:10 +01:00
|
|
|
|
2011-11-29 11:50:22 +01:00
|
|
|
class RemoteExtensionSettings(val config: Config) extends Extension {
|
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
|
|
|
|
2011-11-24 18:53:18 +01:00
|
|
|
val FailureDetectorThreshold = getInt("akka.remote.failure-detector.threshold")
|
|
|
|
|
val FailureDetectorMaxSampleSize = getInt("akka.remote.failure-detector.max-sample-size")
|
|
|
|
|
val ShouldCompressData = config.getBoolean("akka.remote.use-compression")
|
|
|
|
|
val RemoteSystemDaemonAckTimeout = Duration(config.getMilliseconds("akka.remote.remote-daemon-ack-timeout"), MILLISECONDS)
|
2011-11-30 10:20:57 +01:00
|
|
|
val InitalDelayForGossip = Duration(config.getMilliseconds("akka.remote.gossip.initialDelay"), MILLISECONDS)
|
|
|
|
|
val GossipFrequency = Duration(config.getMilliseconds("akka.remote.gossip.frequency"), MILLISECONDS)
|
2011-11-22 13:04:10 +01:00
|
|
|
|
2011-11-24 18:53:18 +01:00
|
|
|
// TODO cluster config will go into akka-cluster-reference.conf when we enable that module
|
|
|
|
|
val ClusterName = getString("akka.cluster.name")
|
2011-11-25 12:10:23 +01:00
|
|
|
val SeedNodes = Set.empty[RemoteAddress] ++ getStringList("akka.cluster.seed-nodes").asScala.toSeq.map(RemoteAddress(_))
|
2011-11-22 13:04:10 +01:00
|
|
|
|
2011-11-24 18:53:18 +01:00
|
|
|
val NodeName: String = config.getString("akka.cluster.nodename") match {
|
2011-11-30 10:20:57 +01:00
|
|
|
case "" ⇒ throw new ConfigurationException("akka.cluster.nodename configuration property must be defined")
|
2011-11-24 18:53:18 +01:00
|
|
|
case value ⇒ value
|
|
|
|
|
}
|
2011-11-22 13:04:10 +01:00
|
|
|
|
2011-11-24 18:53:18 +01:00
|
|
|
val serverSettings = new RemoteServerSettings
|
|
|
|
|
val clientSettings = new RemoteClientSettings
|
2011-11-22 13:04:10 +01:00
|
|
|
|
2011-11-24 18:53:18 +01:00
|
|
|
class RemoteClientSettings {
|
|
|
|
|
val SecureCookie: Option[String] = config.getString("akka.remote.secure-cookie") match {
|
|
|
|
|
case "" ⇒ None
|
|
|
|
|
case cookie ⇒ Some(cookie)
|
2011-11-22 13:04:10 +01:00
|
|
|
}
|
|
|
|
|
|
2011-11-24 18:53:18 +01:00
|
|
|
val ReconnectionTimeWindow = Duration(config.getMilliseconds("akka.remote.client.reconnection-time-window"), MILLISECONDS)
|
|
|
|
|
val ReadTimeout = Duration(config.getMilliseconds("akka.remote.client.read-timeout"), MILLISECONDS)
|
|
|
|
|
val ReconnectDelay = Duration(config.getMilliseconds("akka.remote.client.reconnect-delay"), MILLISECONDS)
|
2011-11-29 11:50:22 +01:00
|
|
|
val MessageFrameSize = config.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._
|
2011-11-29 11:50:22 +01:00
|
|
|
val MessageFrameSize = config.getBytes("akka.remote.server.message-frame-size").toInt
|
2011-11-24 18:53:18 +01:00
|
|
|
val SecureCookie: Option[String] = config.getString("akka.remote.secure-cookie") match {
|
|
|
|
|
case "" ⇒ None
|
|
|
|
|
case cookie ⇒ Some(cookie)
|
|
|
|
|
}
|
|
|
|
|
val RequireCookie = {
|
|
|
|
|
val requireCookie = config.getBoolean("akka.remote.server.require-cookie")
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2011-11-24 18:53:18 +01:00
|
|
|
val UsePassiveConnections = config.getBoolean("akka.remote.use-passive-connections")
|
2011-11-22 13:04:10 +01:00
|
|
|
|
2011-11-24 18:53:18 +01:00
|
|
|
val UntrustedMode = config.getBoolean("akka.remote.server.untrusted-mode")
|
|
|
|
|
val Hostname = config.getString("akka.remote.server.hostname") match {
|
|
|
|
|
case "" ⇒ InetAddress.getLocalHost.getHostAddress
|
|
|
|
|
case value ⇒ value
|
|
|
|
|
}
|
|
|
|
|
val Port = config.getInt("akka.remote.server.port")
|
|
|
|
|
val ConnectionTimeout = Duration(config.getMilliseconds("akka.remote.server.connection-timeout"), MILLISECONDS)
|
2011-11-22 13:04:10 +01:00
|
|
|
|
2011-11-24 18:53:18 +01:00
|
|
|
val Backlog = config.getInt("akka.remote.server.backlog")
|
2011-11-22 13:04:10 +01:00
|
|
|
}
|
|
|
|
|
}
|