Commit 7ce2ee9d authored by Dominik Charousset's avatar Dominik Charousset

Merge branch 'unstable' of github.com:Neverlord/libcppa into unstable

parents 55802684 0d225bcd
...@@ -313,10 +313,7 @@ class AkkaClientActor(system: ActorSystem) extends AkkaActor { ...@@ -313,10 +313,7 @@ class AkkaClientActor(system: ActorSystem) extends AkkaActor {
} }
} }
object DistributedClientApp { object Distributed {
val NumPings = "num_pings=([0-9]+)".r
val SimpleUri = "([0-9a-zA-Z\\.]+):([0-9]+)".r
@tailrec def run(args: List[String], paths: List[String], numPings: Option[Int], finalizer: (List[String], Int) => Unit): Unit = args match { @tailrec def run(args: List[String], paths: List[String], numPings: Option[Int], finalizer: (List[String], Int) => Unit): Unit = args match {
case NumPings(num) :: tail => numPings match { case NumPings(num) :: tail => numPings match {
...@@ -333,13 +330,26 @@ object DistributedClientApp { ...@@ -333,13 +330,26 @@ object DistributedClientApp {
} }
} }
def main(args: Array[String]): Unit = { val IntStr = "([0-9]+)".r
try { val NumPings = "num_pings=([0-9]+)".r
args(0) match { val SimpleUri = "([0-9a-zA-Z\\.]+):([0-9]+)".r
case "remote_actors" => run(args.toList.drop(1), Nil, None, ((paths, x) => {
def main(args: Array[String]): Unit = args match {
// server mode
case Array("mode=server", "remote_actors", IntStr(istr)) => (new ServerActor(istr.toInt)).start
case Array("mode=server", "akka") => {
val system = ActorSystem("pongServer", ConfigFactory.load.getConfig("pongServer"))
val pong = system.actorOf(Props(new AkkaServerActor(system)), "pong")
Unit
}
// client mode
case Array("mode=benchmark", "remote_actors", _*) => {
run(args.toList.drop(2), Nil, None, ((paths, x) => {
(new ClientActor(paths map (path => path match { case SimpleUri(host, port) => RemoteActorPath(path, host, port.toInt) }), x)).start (new ClientActor(paths map (path => path match { case SimpleUri(host, port) => RemoteActorPath(path, host, port.toInt) }), x)).start
})) }))
case "akka" => run(args.toList.drop(1), Nil, None, ((paths, x) => { }
case Array("mode=benchmark", "akka", _*) => {
run(args.toList.drop(2), Nil, None, ((paths, x) => {
val system = ActorSystem("benchmark", ConfigFactory.load.getConfig("benchmark")) val system = ActorSystem("benchmark", ConfigFactory.load.getConfig("benchmark"))
system.actorOf(Props(new AkkaClientActor(system))) ! RunAkkaClient(paths, x) system.actorOf(Props(new AkkaClientActor(system))) ! RunAkkaClient(paths, x)
global.latch.await global.latch.await
...@@ -347,28 +357,16 @@ object DistributedClientApp { ...@@ -347,28 +357,16 @@ object DistributedClientApp {
System.exit(0) System.exit(0)
})) }))
} }
} // error
catch { case _ => {
case e => { println("Running in server mode:\n" +
println("usage: DistributedClientApp (remote_actors|akka) {nodes...} num_pings={num}\nexample: DistributedClientApp remote_actors localhost:1234 localhost:2468 num_pings=1000\n") " mode=server\n" +
throw e " remote_actors PORT *or* akka\n" +
} "\n" +
"Running the benchmark:\n" +
" mode=benchmark\n" +
" remote_actors ... *or* akka\n" );
} }
} }
}
object DistributedServerApp {
val IntStr = "([0-9]+)".r
def main(args: Array[String]): Unit = args match {
case Array("remote_actors", IntStr(istr)) => (new ServerActor(istr.toInt)).start
case Array("akka") => {
val system = ActorSystem("pongServer", ConfigFactory.load.getConfig("pongServer"))
val pong = system.actorOf(Props(new AkkaServerActor(system)), "pong")
Unit
}
case _ => println("usage: DistributedServerApp remote_actors PORT\n" +
" or: DistributedServerApp akka")
}
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment