2011-12-07 16:29:12 +01:00
|
|
|
/**
|
2014-02-02 19:05:45 -06:00
|
|
|
* Copyright (C) 2009-2014 Typesafe Inc. <http://www.typesafe.com>
|
2011-12-07 16:29:12 +01:00
|
|
|
*/
|
|
|
|
|
package akka.remote
|
|
|
|
|
|
|
|
|
|
import akka.actor._
|
2011-12-13 01:09:05 +01:00
|
|
|
import akka.routing._
|
2012-09-17 12:54:08 +02:00
|
|
|
import akka.remote.routing._
|
2012-05-16 17:04:13 +02:00
|
|
|
import akka.ConfigurationException
|
2012-11-07 16:35:14 +01:00
|
|
|
import akka.japi.Util.immutableSeq
|
|
|
|
|
import com.typesafe.config._
|
2013-09-19 08:00:05 +02:00
|
|
|
import akka.routing.Pool
|
|
|
|
|
import akka.remote.routing.RemoteRouterConfig
|
2011-12-07 16:29:12 +01:00
|
|
|
|
2012-08-29 19:33:19 +02:00
|
|
|
@SerialVersionUID(1L)
|
2012-01-31 21:19:28 +01:00
|
|
|
case class RemoteScope(node: Address) extends Scope {
|
|
|
|
|
def withFallback(other: Scope): Scope = this
|
|
|
|
|
}
|
2011-12-07 16:29:12 +01:00
|
|
|
|
2013-02-08 13:13:52 +01:00
|
|
|
/**
|
|
|
|
|
* INTERNAL API
|
|
|
|
|
*/
|
2012-05-24 11:44:39 +02:00
|
|
|
private[akka] class RemoteDeployer(_settings: ActorSystem.Settings, _pm: DynamicAccess) extends Deployer(_settings, _pm) {
|
2012-05-24 12:40:52 +02:00
|
|
|
override def parseConfig(path: String, config: Config): Option[Deploy] = {
|
2011-12-07 16:29:12 +01:00
|
|
|
import scala.collection.JavaConverters._
|
|
|
|
|
|
2011-12-13 01:09:05 +01:00
|
|
|
super.parseConfig(path, config) match {
|
|
|
|
|
case d @ Some(deploy) ⇒
|
|
|
|
|
deploy.config.getString("remote") match {
|
2012-02-27 10:28:20 +01:00
|
|
|
case AddressFromURIString(r) ⇒ Some(deploy.copy(scope = RemoteScope(r)))
|
2013-05-30 21:37:57 +02:00
|
|
|
case str if !str.isEmpty ⇒ throw new ConfigurationException(s"unparseable remote node name [${str}]")
|
2012-11-07 16:35:14 +01:00
|
|
|
case _ ⇒
|
|
|
|
|
val nodes = immutableSeq(deploy.config.getStringList("target.nodes")).map(AddressFromURIString(_))
|
2012-01-31 21:19:28 +01:00
|
|
|
if (nodes.isEmpty || deploy.routerConfig == NoRouter) d
|
2013-09-19 08:00:05 +02:00
|
|
|
else deploy.routerConfig match {
|
|
|
|
|
case r: Pool ⇒ Some(deploy.copy(routerConfig = RemoteRouterConfig(r, nodes)))
|
|
|
|
|
case _ ⇒ d
|
|
|
|
|
}
|
2011-12-13 01:09:05 +01:00
|
|
|
}
|
|
|
|
|
case None ⇒ None
|
|
|
|
|
}
|
2011-12-07 16:29:12 +01:00
|
|
|
}
|
2013-01-09 01:47:48 +01:00
|
|
|
}
|