!act,rem,clu #3549 Simplify and enhance routers
* Separate routing logic, to be usable stand alone, e.g. in actors * Simplify RouterConfig, only a factory * Move reading of config from Deployer to the RouterConfig * Distiction between Pool and Group router types * Remove usage of actorFor, use ActorSelection * Management messages to add and remove routees * Simplify the internals of RoutedActorCell & co * Move resize specific code to separate RoutedActorCell subclass * Change resizer api to only return capacity change * Resizer only allowed together with Pool * Re-implement all routers, and keep old api during deprecation phase * Replace ClusterRouterConfig, deprecation * Rewrite documentation * Migration guide * Also includes related ticket: +act #3087 Create nicer Props factories for RouterConfig
This commit is contained in:
parent
81ca6fe8c8
commit
ebadd567b2
104 changed files with 9671 additions and 5006 deletions
|
|
@ -10,39 +10,42 @@ import akka.actor.Actor
|
|||
import akka.actor.ActorRef
|
||||
import akka.actor.LocalActorRef
|
||||
import scala.concurrent.duration._
|
||||
import akka.actor.Identify
|
||||
import akka.actor.ActorIdentity
|
||||
|
||||
@org.junit.runner.RunWith(classOf[org.scalatest.junit.JUnitRunner])
|
||||
class RouteeCreationSpec extends AkkaSpec {
|
||||
|
||||
"Creating Routees" must {
|
||||
|
||||
"result in visible routees" in {
|
||||
val N = 100
|
||||
system.actorOf(Props(new Actor {
|
||||
testActor ! system.actorFor(self.path)
|
||||
system.actorOf(RoundRobinPool(N).props(Props(new Actor {
|
||||
system.actorSelection(self.path).tell(Identify(self.path), testActor)
|
||||
def receive = Actor.emptyBehavior
|
||||
}).withRouter(RoundRobinRouter(N)))
|
||||
})))
|
||||
for (i ← 1 to N) {
|
||||
expectMsgType[ActorRef] match {
|
||||
case _: LocalActorRef ⇒ // fine
|
||||
case x ⇒ fail(s"routee $i was a ${x.getClass}")
|
||||
expectMsgType[ActorIdentity] match {
|
||||
case ActorIdentity(_, Some(_)) ⇒ // fine
|
||||
case x ⇒ fail(s"routee $i was not found $x")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
"allow sending to context.parent" in {
|
||||
val N = 100
|
||||
system.actorOf(Props(new Actor {
|
||||
system.actorOf(RoundRobinPool(N).props(Props(new Actor {
|
||||
context.parent ! "one"
|
||||
def receive = {
|
||||
case "one" ⇒ testActor forward "two"
|
||||
}
|
||||
}).withRouter(RoundRobinRouter(N)))
|
||||
})))
|
||||
val gotit = receiveWhile(messages = N) {
|
||||
case "two" ⇒ lastSender.toString
|
||||
}
|
||||
expectNoMsg(100.millis)
|
||||
if (gotit.size != N) {
|
||||
fail(s"got only ${gotit.size} from \n${gotit mkString "\n"}")
|
||||
fail(s"got only ${gotit.size} from [${gotit mkString ", "}]")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue