2011-12-07 16:29:12 +01:00
|
|
|
/**
|
|
|
|
|
* Copyright (C) 2009-2011 Typesafe Inc. <http://www.typesafe.com>
|
|
|
|
|
*/
|
|
|
|
|
package akka.remote
|
|
|
|
|
|
|
|
|
|
import akka.actor._
|
2011-12-13 01:09:05 +01:00
|
|
|
import akka.routing._
|
2011-12-07 16:29:12 +01:00
|
|
|
import com.typesafe.config._
|
|
|
|
|
import akka.config.ConfigurationException
|
|
|
|
|
|
2011-12-12 23:31:15 +01:00
|
|
|
case class RemoteScope(node: UnparsedSystemAddress[UnparsedTransportAddress]) extends Scope
|
2011-12-07 16:29:12 +01:00
|
|
|
|
2011-12-09 20:19:59 +01:00
|
|
|
class RemoteDeployer(_settings: ActorSystem.Settings) extends Deployer(_settings) {
|
2011-12-07 16:29:12 +01:00
|
|
|
|
2011-12-09 20:19:59 +01:00
|
|
|
override protected def parseConfig(path: String, config: Config): Option[Deploy] = {
|
2011-12-07 16:29:12 +01:00
|
|
|
import scala.collection.JavaConverters._
|
|
|
|
|
import akka.util.ReflectiveAccess._
|
|
|
|
|
|
2011-12-13 01:09:05 +01:00
|
|
|
super.parseConfig(path, config) match {
|
|
|
|
|
case d @ Some(deploy) ⇒
|
|
|
|
|
deploy.config.getString("remote") match {
|
|
|
|
|
case RemoteAddressExtractor(r) ⇒ Some(deploy.copy(scope = RemoteScope(r)))
|
|
|
|
|
case str ⇒
|
|
|
|
|
if (!str.isEmpty) throw new ConfigurationException("unparseable remote node name " + str)
|
|
|
|
|
val nodes = deploy.config.getStringList("target.nodes").asScala
|
|
|
|
|
if (nodes.isEmpty || deploy.routing == NoRouter) d
|
|
|
|
|
else {
|
|
|
|
|
val r = deploy.routing match {
|
2011-12-21 10:03:26 +01:00
|
|
|
case RoundRobinRouter(x, _) ⇒ RemoteRoundRobinRouter(x, nodes)
|
|
|
|
|
case RandomRouter(x, _) ⇒ RemoteRandomRouter(x, nodes)
|
|
|
|
|
case BroadcastRouter(x, _) ⇒ RemoteBroadcastRouter(x, nodes)
|
2011-12-20 19:57:42 +01:00
|
|
|
case ScatterGatherFirstCompletedRouter(x, _, w) ⇒ RemoteScatterGatherFirstCompletedRouter(x, nodes, w)
|
2011-12-13 01:09:05 +01:00
|
|
|
}
|
|
|
|
|
Some(deploy.copy(routing = r))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
case None ⇒ None
|
|
|
|
|
}
|
2011-12-07 16:29:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|