rename AkkaConfig values to CamelCase
This commit is contained in:
parent
42e1bba164
commit
36ec202d94
30 changed files with 146 additions and 139 deletions
|
|
@ -4,11 +4,11 @@
|
|||
|
||||
package akka.tutorial.java.second;
|
||||
|
||||
import static akka.actor.Actors.actorOf;
|
||||
import static akka.actor.Actors.poisonPill;
|
||||
import static java.lang.System.currentTimeMillis;
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
import akka.AkkaApplication;
|
||||
import akka.routing.RoutedProps;
|
||||
import akka.routing.Routing;
|
||||
import scala.Option;
|
||||
|
|
@ -24,6 +24,8 @@ import scala.collection.JavaConversions;
|
|||
import java.util.LinkedList;
|
||||
|
||||
public class Pi {
|
||||
|
||||
private static final AkkaApplication app = new AkkaApplication();
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Pi pi = new Pi();
|
||||
|
|
@ -99,11 +101,11 @@ public class Pi {
|
|||
|
||||
LinkedList<ActorRef> workers = new LinkedList<ActorRef>();
|
||||
for (int i = 0; i < nrOfWorkers; i++) {
|
||||
ActorRef worker = actorOf(Worker.class, "worker");
|
||||
ActorRef worker = app.createActor(Worker.class);
|
||||
workers.add(worker);
|
||||
}
|
||||
|
||||
router = Routing.actorOf(RoutedProps.apply().withConnections(workers).withRoundRobinRouter(), "pi");
|
||||
router = app.routing().actorOf(RoutedProps.apply().withConnections(workers).withRoundRobinRouter(), "pi");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -159,11 +161,11 @@ public class Pi {
|
|||
public void calculate(final int nrOfWorkers, final int nrOfElements, final int nrOfMessages) throws Exception {
|
||||
|
||||
// create the master
|
||||
ActorRef master = actorOf(new UntypedActorFactory() {
|
||||
ActorRef master = app.createActor(new UntypedActorFactory() {
|
||||
public UntypedActor create() {
|
||||
return new Master(nrOfWorkers, nrOfMessages, nrOfElements);
|
||||
}
|
||||
}, "worker");
|
||||
});
|
||||
|
||||
// start the calculation
|
||||
long start = currentTimeMillis();
|
||||
|
|
|
|||
|
|
@ -10,9 +10,12 @@ import System.{ currentTimeMillis ⇒ now }
|
|||
import akka.routing.Routing.Broadcast
|
||||
import akka.actor.{ Timeout, Channel, Actor, PoisonPill }
|
||||
import akka.routing.{ RoutedProps, Routing }
|
||||
import akka.AkkaApplication
|
||||
|
||||
object Pi extends App {
|
||||
|
||||
val app = AkkaApplication()
|
||||
|
||||
calculate(nrOfWorkers = 4, nrOfElements = 10000, nrOfMessages = 10000)
|
||||
|
||||
// ====================
|
||||
|
|
@ -50,10 +53,10 @@ object Pi extends App {
|
|||
var nrOfResults: Int = _
|
||||
|
||||
// create the workers
|
||||
val workers = Vector.fill(nrOfWorkers)(actorOf[Worker])
|
||||
val workers = Vector.fill(nrOfWorkers)(app.createActor[Worker])
|
||||
|
||||
// wrap them with a load-balancing router
|
||||
val router = Routing.actorOf(RoutedProps().withConnections(workers).withRoundRobinRouter, "pi")
|
||||
val router = app.routing.actorOf(RoutedProps().withConnections(workers).withRoundRobinRouter, "pi")
|
||||
|
||||
// phase 1, can accept a Calculate message
|
||||
def scatter: Receive = {
|
||||
|
|
@ -96,7 +99,7 @@ object Pi extends App {
|
|||
// ==================
|
||||
def calculate(nrOfWorkers: Int, nrOfElements: Int, nrOfMessages: Int) {
|
||||
// create the master
|
||||
val master = actorOf(new Master(nrOfWorkers, nrOfElements, nrOfMessages))
|
||||
val master = app.createActor(new Master(nrOfWorkers, nrOfElements, nrOfMessages))
|
||||
|
||||
//start the calculation
|
||||
val start = now
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue