+act #3663 Package BalancingDispatcher for usage in router pool

* In fact, make it easy to define any dedicated dispatcher for a pool
This commit is contained in:
Patrik Nordwall 2013-10-16 13:02:35 +02:00
parent f6179da523
commit 80892762ad
22 changed files with 140 additions and 47 deletions

View file

@ -4,22 +4,27 @@
package docs.jrouting;
import akka.testkit.AkkaJUnitActorSystemResource;
import org.junit.ClassRule;
import org.junit.Test;
import akka.testkit.JavaTestKit;
import akka.actor.ActorSystem;
//#imports1
import akka.actor.UntypedActor;
import akka.routing.ConsistentHashingRouter.ConsistentHashable;
import java.util.Map;
import java.util.HashMap;
import java.io.Serializable;
//#imports1
//#imports2
import akka.actor.Props;
import akka.actor.ActorRef;
import akka.routing.ConsistentHashingPool;
import akka.routing.ConsistentHashingRouter;
import akka.routing.ConsistentHashingRouter.ConsistentHashMapper;
import akka.routing.ConsistentHashingRouter.ConsistentHashableEnvelope;
@ -120,7 +125,7 @@ public class ConsistentHashingRouterDocTest {
};
ActorRef cache = system.actorOf(
new ConsistentHashingRouter(10).withHashMapper(hashMapper).props(
new ConsistentHashingPool(10).withHashMapper(hashMapper).props(
Props.create(Cache.class)),
"cache");

View file

@ -317,12 +317,11 @@ public class RouterDocTest {
public void demonstrateDispatcher() {
//#dispatchers
Props props =
// head will run on "router-dispatcher" dispatcher
new RoundRobinPool(5).withDispatcher("router-dispatcher").props(
Props.create(Worker.class))
// Worker routees will run on "workers-dispatcher" dispatcher
.withDispatcher("workers-dispatcher");
ActorRef router = system.actorOf(props);
// head router actor will run on "router-dispatcher" dispatcher
// Worker routees will run on "pool-dispatcher" dispatcher
new RandomPool(5).withDispatcher("router-dispatcher").props(
Props.create(Worker.class));
ActorRef router = system.actorOf(props, "poolWithDispatcher");
//#dispatchers
}
@ -390,8 +389,8 @@ public class RouterDocTest {
public void demonstrateRemoteDeploy() {
//#remoteRoutees
Address[] addresses = {
new Address("akka", "remotesys", "otherhost", 1234),
AddressFromURIString.parse("akka://othersys@anotherhost:1234")};
new Address("akka.tcp", "remotesys", "otherhost", 1234),
AddressFromURIString.parse("akka.tcp://othersys@anotherhost:1234")};
ActorRef routerRemote = system.actorOf(
new RemoteRouterConfig(new RoundRobinPool(5), addresses).props(
Props.create(Echo.class)));