Merge ClusterActoRef & RoutedActorRef: After merge with master

This commit is contained in:
Peter Veentjer 2011-08-29 09:22:14 +03:00
commit 56d4fc7d7c
14 changed files with 398 additions and 163 deletions

View file

@ -11,6 +11,7 @@ import static java.util.Arrays.asList;
import akka.actor.ActorRef;
import akka.actor.UntypedActor;
import akka.actor.UntypedActorFactory;
import akka.routing.RoutedProps;
import akka.routing.RouterType;
import akka.routing.Routing;
import akka.routing.Routing.Broadcast;
@ -108,7 +109,12 @@ public class Pi {
workers.add(worker);
}
router = Routing.actorOfWithRoundRobin("pi", JavaConversions.collectionAsScalaIterable(workers));
router = Routing.actorOf(
RoutedProps.apply()
.withRoundRobinRouter()
.withConnections(workers)
.withDeployId("pi")
);
}
// message handler

View file

@ -8,7 +8,7 @@ import akka.actor.{ Actor, PoisonPill }
import Actor._
import java.util.concurrent.CountDownLatch
import akka.routing.Routing.Broadcast
import akka.routing.Routing
import akka.routing.{ RoutedProps, Routing }
object Pi extends App {
@ -18,8 +18,11 @@ object Pi extends App {
// ===== Messages =====
// ====================
sealed trait PiMessage
case object Calculate extends PiMessage
case class Work(start: Int, nrOfElements: Int) extends PiMessage
case class Result(value: Double) extends PiMessage
// ==================
@ -55,7 +58,11 @@ object Pi extends App {
val workers = Vector.fill(nrOfWorkers)(actorOf[Worker].start())
// wrap them with a load-balancing router
val router = Routing.actorOfWithRoundRobin("pi", workers)
val router = Routing.actorOf(
RoutedProps.default
.withRoundRobinRouter()
.withConnections(workers)
.withDeployId("pi"))
// message handler
def receive = {