pekko/akka-remote/src/multi-jvm/scala/akka/remote/AbstractRemoteActorMultiJvmSpec.scala

30 lines
904 B
Scala
Raw Normal View History

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] = {
val arrayOpt = Option(System.getProperty("test.hosts")).map(_ split ",")
2011-12-22 12:36:52 +04:00
(arrayOpt getOrElse Array.fill(NrOfNodes)("localhost")).toSeq
}
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(",")
}
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"
cluster.nodename = "node%d"
2011-12-22 12:36:52 +04:00
}""".format(host, 9990+idx, idx)) withFallback commonConfig
}
}