2012-08-30 13:41:01 +02:00
|
|
|
/**
|
2013-01-09 01:47:48 +01:00
|
|
|
* Copyright (C) 2009-2013 Typesafe Inc. <http://www.typesafe.com>
|
2012-08-30 13:41:01 +02:00
|
|
|
*/
|
|
|
|
|
package akka.cluster
|
|
|
|
|
|
|
|
|
|
import akka.testkit._
|
|
|
|
|
import akka.actor._
|
|
|
|
|
import akka.routing._
|
|
|
|
|
import com.typesafe.config._
|
|
|
|
|
import akka.cluster.routing.ClusterRouterConfig
|
2012-09-07 12:07:41 +02:00
|
|
|
import akka.cluster.routing.ClusterRouterSettings
|
2012-08-30 13:41:01 +02:00
|
|
|
|
|
|
|
|
object ClusterDeployerSpec {
|
|
|
|
|
val deployerConf = ConfigFactory.parseString("""
|
|
|
|
|
akka.actor.provider = "akka.cluster.ClusterActorRefProvider"
|
|
|
|
|
akka.actor.deployment {
|
2012-09-08 17:30:42 +02:00
|
|
|
/user/service1 {
|
2012-08-30 13:41:01 +02:00
|
|
|
router = round-robin
|
|
|
|
|
nr-of-instances = 20
|
|
|
|
|
cluster.enabled = on
|
|
|
|
|
cluster.max-nr-of-instances-per-node = 3
|
2012-09-11 19:11:20 +02:00
|
|
|
cluster.allow-local-routees = off
|
2012-09-08 17:30:42 +02:00
|
|
|
}
|
|
|
|
|
/user/service2 {
|
|
|
|
|
router = round-robin
|
|
|
|
|
nr-of-instances = 20
|
|
|
|
|
cluster.enabled = on
|
2012-09-11 19:11:20 +02:00
|
|
|
cluster.allow-local-routees = off
|
2012-09-07 14:54:53 +02:00
|
|
|
cluster.routees-path = "/user/myservice"
|
2012-08-30 13:41:01 +02:00
|
|
|
}
|
|
|
|
|
}
|
2013-01-17 16:19:31 +01:00
|
|
|
akka.remote.netty.tcp.port = 0
|
2012-08-30 13:41:01 +02:00
|
|
|
""", ConfigParseOptions.defaults)
|
|
|
|
|
|
|
|
|
|
class RecipeActor extends Actor {
|
|
|
|
|
def receive = { case _ ⇒ }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@org.junit.runner.RunWith(classOf[org.scalatest.junit.JUnitRunner])
|
|
|
|
|
class ClusterDeployerSpec extends AkkaSpec(ClusterDeployerSpec.deployerConf) {
|
|
|
|
|
|
|
|
|
|
"A RemoteDeployer" must {
|
|
|
|
|
|
2012-09-08 17:30:42 +02:00
|
|
|
"be able to parse 'akka.actor.deployment._' with specified cluster lookup routee settings" in {
|
|
|
|
|
val service = "/user/service1"
|
|
|
|
|
val deployment = system.asInstanceOf[ActorSystemImpl].provider.deployer.lookup(service.split("/").drop(1))
|
|
|
|
|
deployment must not be (None)
|
|
|
|
|
|
|
|
|
|
deployment must be(Some(
|
|
|
|
|
Deploy(
|
|
|
|
|
service,
|
|
|
|
|
deployment.get.config,
|
2012-09-10 14:11:03 +02:00
|
|
|
ClusterRouterConfig(RoundRobinRouter(20), ClusterRouterSettings(
|
2012-09-11 20:49:08 +02:00
|
|
|
totalInstances = 20, maxInstancesPerNode = 3, allowLocalRoutees = false)),
|
2012-09-08 17:30:42 +02:00
|
|
|
ClusterScope)))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"be able to parse 'akka.actor.deployment._' with specified cluster deploy routee settings" in {
|
2012-08-30 13:41:01 +02:00
|
|
|
val service = "/user/service2"
|
|
|
|
|
val deployment = system.asInstanceOf[ActorSystemImpl].provider.deployer.lookup(service.split("/").drop(1))
|
|
|
|
|
deployment must not be (None)
|
|
|
|
|
|
|
|
|
|
deployment must be(Some(
|
|
|
|
|
Deploy(
|
|
|
|
|
service,
|
|
|
|
|
deployment.get.config,
|
2012-09-10 14:11:03 +02:00
|
|
|
ClusterRouterConfig(RoundRobinRouter(20), ClusterRouterSettings(
|
2012-09-11 20:49:08 +02:00
|
|
|
totalInstances = 20, routeesPath = "/user/myservice", allowLocalRoutees = false)),
|
2012-08-30 13:41:01 +02:00
|
|
|
ClusterScope)))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-09 01:47:48 +01:00
|
|
|
}
|