pekko/akka-remote/src/multi-jvm/scala/akka/remote/AbstractRemoteActorMultiJvmSpec.scala
2011-12-21 19:06:51 +04:00

29 lines
896 B
Scala
Executable file

package akka.remote
import com.typesafe.config.{Config, ConfigFactory}
trait AbstractRemoteActorMultiJvmSpec {
def NrOfNodes: Int
def commonConfig: Config
def remotes: Array[String] = {
val arrayOpt = Option(System.getProperty("test.hosts")).map(_ split ",")
arrayOpt getOrElse Array.fill(NrOfNodes)("localhost")
}
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"
remote.server.port = "999%d"
cluster.nodename = "node%d"
}""".format(host, idx, idx)) withFallback commonConfig
}
}