Merge pull request #1070 from drewhk/wip-2906-udpate-remote-samples-drewhk

Updated samples to run with the new remoting #2906
This commit is contained in:
drewhk 2013-01-28 02:13:33 -08:00
commit d486721563
16 changed files with 49 additions and 45 deletions

View file

@ -10,7 +10,7 @@ public class FactorialBackendMain {
// Override the configuration of the port
// when specified as program argument
if (args.length > 0)
System.setProperty("akka.remoting.transports.tcp.port", args[0]);
System.setProperty("akka.remote.netty.tcp.port", args[0]);
ActorSystem system = ActorSystem.create("ClusterSystem", ConfigFactory.load("factorial"));

View file

@ -12,7 +12,7 @@ public class SimpleClusterApp {
// Override the configuration of the port
// when specified as program argument
if (args.length > 0)
System.setProperty("akka.remoting.transports.tcp.port", args[0]);
System.setProperty("akka.remote.netty.tcp.port", args[0]);
// Create an Akka system
ActorSystem system = ActorSystem.create("ClusterSystem");

View file

@ -11,7 +11,7 @@ public class StatsSampleMain {
// Override the configuration of the port
// when specified as program argument
if (args.length > 0)
System.setProperty("akka.remoting.transports.tcp.port", args[0]);
System.setProperty("akka.remote.netty.tcp.port", args[0]);
//#start-router-lookup
ActorSystem system = ActorSystem.create("ClusterSystem",

View file

@ -15,7 +15,7 @@ public class StatsSampleOneMasterMain {
// Override the configuration of the port
// when specified as program argument
if (args.length > 0)
System.setProperty("akka.remoting.transports.tcp.port", args[0]);
System.setProperty("akka.remote.netty.tcp.port", args[0]);
//#start-router-deploy
ActorSystem system = ActorSystem.create("ClusterSystem",

View file

@ -9,7 +9,7 @@ public class TransformationBackendMain {
// Override the configuration of the port
// when specified as program argument
if (args.length > 0)
System.setProperty("akka.remoting.transports.tcp.port", args[0]);
System.setProperty("akka.remote.netty.tcp.port", args[0]);
ActorSystem system = ActorSystem.create("ClusterSystem");

View file

@ -18,7 +18,7 @@ public class TransformationFrontendMain {
// Override the configuration of the port
// when specified as program argument
if (args.length > 0)
System.setProperty("akka.remoting.transports.tcp.port", args[0]);
System.setProperty("akka.remote.netty.tcp.port", args[0]);
ActorSystem system = ActorSystem.create("ClusterSystem");

View file

@ -3,9 +3,9 @@ akka {
actor {
provider = "akka.cluster.ClusterActorRefProvider"
}
remoting {
remote {
log-remote-lifecycle-events = off
transports.tcp {
netty.tcp {
hostname = "127.0.0.1"
port = 0
}
@ -13,8 +13,8 @@ akka {
cluster {
seed-nodes = [
"tcp.akka://ClusterSystem@127.0.0.1:2551",
"tcp.akka://ClusterSystem@127.0.0.1:2552"]
"akka.tcp://ClusterSystem@127.0.0.1:2551",
"akka.tcp://ClusterSystem@127.0.0.1:2552"]
auto-down = on
}

View file

@ -60,7 +60,7 @@ object FactorialBackend {
def main(args: Array[String]): Unit = {
// Override the configuration of the port
// when specified as program argument
if (args.nonEmpty) System.setProperty("akka.remoting.transports.tcp.port", args(0))
if (args.nonEmpty) System.setProperty("akka.remote.netty.tcp.port", args(0))
val system = ActorSystem("ClusterSystem", ConfigFactory.load("factorial"))
system.actorOf(Props[FactorialBackend], name = "factorialBackend")

View file

@ -10,7 +10,7 @@ object SimpleClusterApp {
// Override the configuration of the port
// when specified as program argument
if (args.nonEmpty) System.setProperty("akka.remoting.transports.tcp.port", args(0))
if (args.nonEmpty) System.setProperty("akka.remote.netty.tcp.port", args(0))
// Create an Akka system
val system = ActorSystem("ClusterSystem")

View file

@ -123,7 +123,7 @@ object StatsSample {
def main(args: Array[String]): Unit = {
// Override the configuration of the port
// when specified as program argument
if (args.nonEmpty) System.setProperty("akka.remoting.transports.tcp.port", args(0))
if (args.nonEmpty) System.setProperty("akka.remote.netty.tcp.port", args(0))
//#start-router-lookup
val system = ActorSystem("ClusterSystem", ConfigFactory.parseString("""
@ -151,7 +151,7 @@ object StatsSampleOneMaster {
def main(args: Array[String]): Unit = {
// Override the configuration of the port
// when specified as program argument
if (args.nonEmpty) System.setProperty("akka.remoting.transports.tcp.port", args(0))
if (args.nonEmpty) System.setProperty("akka.remote.netty.tcp.port", args(0))
//#start-router-deploy
val system = ActorSystem("ClusterSystem", ConfigFactory.parseString("""

View file

@ -30,7 +30,7 @@ object TransformationFrontend {
def main(args: Array[String]): Unit = {
// Override the configuration of the port
// when specified as program argument
if (args.nonEmpty) System.setProperty("akka.remoting.transports.tcp.port", args(0))
if (args.nonEmpty) System.setProperty("akka.remote.netty.tcp.port", args(0))
val system = ActorSystem("ClusterSystem")
val frontend = system.actorOf(Props[TransformationFrontend], name = "frontend")
@ -77,7 +77,7 @@ object TransformationBackend {
def main(args: Array[String]): Unit = {
// Override the configuration of the port
// when specified as program argument
if (args.nonEmpty) System.setProperty("akka.remoting.transports.tcp.port", args(0))
if (args.nonEmpty) System.setProperty("akka.remote.netty.tcp.port", args(0))
val system = ActorSystem("ClusterSystem")
system.actorOf(Props[TransformationBackend], name = "backend")

View file

@ -55,17 +55,19 @@ Select to run "sample.remote.calculator.CalcApp" which in the case below is numb
[1] sample.remote.calculator.LookupApp
[2] sample.remote.calculator.CreationApp
[3] sample.remote.calculator.CalcApp
[3] sample.remote.calculator.java.JCreationApp
[4] sample.remote.calculator.CalcApp
[5] sample.remote.calculator.java.JCalcApp
[6] sample.remote.calculator.java.JLookupApp
Enter number: 3
Enter number: 4
You should see something similar to this::
[info] Running sample.remote.calculator.CalcApp
[INFO] [12/22/2011 14:21:51.631] [run-main] [ActorSystem] REMOTE: RemoteServerStarted@akka://CalculatorApplication@127.0.0.1:2552
[INFO] [12/22/2011 14:21:51.632] [run-main] [Remote] Starting remote server on [akka://CalculatorApplication@127.0.0.1:2552]
[INFO] [01/25/2013 15:02:51.355] [run-main] [Remoting] Starting remoting
[INFO] [01/25/2013 15:02:52.121] [run-main] [Remoting] Remoting started; listening on addresses :[akka.tcp://CalculatorApplication@127.0.0.1:2552]
Started Calculator Application - waiting for messages
[INFO] [12/22/2011 14:22:39.894] [New I/O server worker #1-1] [ActorSystem] REMOTE: RemoteClientStarted@akka://127.0.0.1:2553
Open up a new terminal window and run SBT once more:
@ -81,21 +83,23 @@ Select to run "sample.remote.calculator.LookupApp" which in the case below is nu
[1] sample.remote.calculator.LookupApp
[2] sample.remote.calculator.CreationApp
[3] sample.remote.calculator.CalcApp
[3] sample.remote.calculator.java.JCreationApp
[4] sample.remote.calculator.CalcApp
[5] sample.remote.calculator.java.JCalcApp
[6] sample.remote.calculator.java.JLookupApp
Enter number: 1
Now you should see something like this::
[info] Running sample.remote.calculator.LookupApp
[INFO] [12/22/2011 14:54:38.630] [run-main] [ActorSystem] REMOTE: RemoteServerStarted@akka://LookupApplication@127.0.0.1:2553
[INFO] [12/22/2011 14:54:38.632] [run-main] [Remote] Starting remote server on [akka://LookupApplication@127.0.0.1:2553]
[INFO] [01/25/2013 15:05:53.954] [run-main] [Remoting] Starting remoting
[INFO] [01/25/2013 15:05:54.769] [run-main] [Remoting] Remoting started; listening on addresses :[akka.tcp://LookupApplication@127.0.0.1:2553]
Started Lookup Application
[INFO] [12/22/2011 14:54:38.801] [default-dispatcher-21] [ActorSystem] REMOTE: RemoteClientStarted@akka://127.0.0.1:2552
Sub result: 4 - 30 = -26
Add result: 17 + 1 = 18
Add result: 37 + 43 = 80
Add result: 68 + 66 = 134
Add result: 0 + 22 = 22
Add result: 41 + 71 = 112
Add result: 61 + 14 = 75
Add result: 77 + 82 = 159
Congrats! You have now successfully looked up a remote actor and communicated with it.
The next step is to have an actor deployed on a remote note.
@ -113,22 +117,22 @@ Select to run "sample.remote.calculator.CreationApp" which in the case below is
[1] sample.remote.calculator.LookupApp
[2] sample.remote.calculator.CreationApp
[3] sample.remote.calculator.CalcApp
[3] sample.remote.calculator.java.JCreationApp
[4] sample.remote.calculator.CalcApp
[5] sample.remote.calculator.java.JCalcApp
[6] sample.remote.calculator.java.JLookupApp
Enter number: 2
Now you should see something like this::
[info] Running sample.remote.calculator.CreationApp
[INFO] [12/22/2011 14:57:02.150] [run-main] [ActorSystem] REMOTE: RemoteServerStarted@akka://RemoteCreation@127.0.0.1:2554
[INFO] [12/22/2011 14:57:02.151] [run-main] [Remote] Starting remote server on [akka://RemoteCreation@127.0.0.1:2554]
[INFO] [12/22/2011 14:57:02.267] [default-dispatcher-21] [ActorSystem] REMOTE: RemoteClientStarted@akka://127.0.0.1:2552
[INFO] [01/14/2013 15:08:08.890] [run-main] [Remoting] Starting remoting
Started Creation Application
Mul result: 14 * 17 = 238
Div result: 3764 / 80 = 47.00
Mul result: 16 * 5 = 80
Mul result: 1 * 18 = 18
Mul result: 8 * 13 = 104
Mul result: 15 * 12 = 180
Div result: 3840 / 10 = 384,00
Mul result: 1 * 5 = 5
Div result: 3240 / 45 = 72,00
That's it!

View file

@ -22,7 +22,7 @@ public class JLookupApplication implements Bootable {
.getConfig("remotelookup"));
actor = system.actorOf(new Props(JLookupActor.class));
remoteActor = system.actorFor(
"akka://CalculatorApplication@127.0.0.1:2552/user/simpleCalculator");
"akka.tcp://CalculatorApplication@127.0.0.1:2552/user/simpleCalculator");
}
public void doSomething(Op.MathOp mathOp) {

View file

@ -3,7 +3,7 @@ calculator {
include "common"
akka {
remote.netty.port = 2552
remote.netty.tcp.port = 2552
}
}
//#calculator
@ -13,7 +13,7 @@ remotelookup {
include "common"
akka {
remote.netty.port = 2553
remote.netty.tcp.port = 2553
}
}
//#remotelookup
@ -26,12 +26,12 @@ remotecreation {
actor {
deployment {
/advancedCalculator {
remote = "akka://CalculatorApplication@127.0.0.1:2552"
remote = "akka.tcp://CalculatorApplication@127.0.0.1:2552"
}
}
}
remote.netty.port = 2554
remote.netty.tcp.port = 2554
}
}
//#remotecreation

View file

@ -5,7 +5,7 @@ akka {
}
remote {
netty {
netty.tcp {
hostname = "127.0.0.1"
}
}

View file

@ -20,7 +20,7 @@ class LookupApplication extends Bootable {
ActorSystem("LookupApplication", ConfigFactory.load.getConfig("remotelookup"))
val actor = system.actorOf(Props[LookupActor], "lookupActor")
val remoteActor = system.actorFor(
"akka://CalculatorApplication@127.0.0.1:2552/user/simpleCalculator")
"akka.tcp://CalculatorApplication@127.0.0.1:2552/user/simpleCalculator")
def doSomething(op: MathOp) = {
actor ! (remoteActor, op)