Improvements and finalization of dynamically resizable routers, replaces ActorPool. See 1557

* resize on nth message instead of always each message
* improved pressure evaluation
* more tests
* documentation
* removed ActorPool
This commit is contained in:
Patrik Nordwall 2012-01-10 15:53:27 +01:00
parent 8b71bf5bea
commit 19845d93e8
21 changed files with 591 additions and 1226 deletions

View file

@ -4,6 +4,7 @@
package akka.docs.jrouting;
import akka.routing.RoundRobinRouter;
import akka.routing.DefaultResizer;
import akka.actor.ActorRef;
import akka.actor.Props;
import akka.actor.UntypedActor;
@ -56,5 +57,15 @@ public class RouterViaProgramExample {
for (int i = 1; i <= 6; i++) {
router2.tell(new ExampleActor.Message(i));
}
//#programmaticRoutingWithResizer
int lowerBound = 2;
int upperBound = 15;
DefaultResizer resizer = new DefaultResizer(lowerBound, upperBound);
ActorRef router3 = system.actorOf(new Props(ExampleActor.class).withRouter(new RoundRobinRouter(nrOfInstances)));
//#programmaticRoutingWithResizer
for (int i = 1; i <= 6; i++) {
router3.tell(new ExampleActor.Message(i));
}
}
}