2011-12-21 16:07:18 +04:00
|
|
|
package akka.remote
|
|
|
|
|
|
|
|
|
|
import com.typesafe.config.{Config, ConfigFactory}
|
|
|
|
|
|
|
|
|
|
trait AbstractRemoteActorMultiJvmSpec {
|
|
|
|
|
def NrOfNodes: Int
|
|
|
|
|
def commonConfig: Config
|
|
|
|
|
|
2011-12-22 12:36:52 +04:00
|
|
|
def remotes: Seq[String] = {
|
2011-12-21 19:06:51 +04:00
|
|
|
val arrayOpt = Option(System.getProperty("test.hosts")).map(_ split ",")
|
2011-12-22 12:36:52 +04:00
|
|
|
(arrayOpt getOrElse Array.fill(NrOfNodes)("localhost")).toSeq
|
2011-12-21 16:07:18 +04:00
|
|
|
}
|
|
|
|
|
|
2011-12-21 17:30:08 +04:00
|
|
|
def specString(count: Int): String = {
|
|
|
|
|
val specs = for ((host, idx) <- remotes.take(count).zipWithIndex) yield
|
|
|
|
|
"\"akka://AkkaRemoteSpec@%s:%d\"".format(host, 9991+idx)
|
|
|
|
|
specs.mkString(",")
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-21 16:07:18 +04:00
|
|
|
val nodeConfigs = ((1 to NrOfNodes).toList zip remotes) map {
|
|
|
|
|
case (idx, host) =>
|
|
|
|
|
ConfigFactory.parseString("""
|
|
|
|
|
akka {
|
|
|
|
|
remote.server.hostname="%s"
|
2011-12-22 12:36:52 +04:00
|
|
|
remote.server.port = "%d"
|
2011-12-21 16:07:18 +04:00
|
|
|
cluster.nodename = "node%d"
|
2011-12-22 12:36:52 +04:00
|
|
|
}""".format(host, 9990+idx, idx)) withFallback commonConfig
|
2011-12-21 16:07:18 +04:00
|
|
|
}
|
|
|
|
|
}
|