2012-05-14 14:26:32 +02:00
|
|
|
/**
|
2012-05-23 09:26:20 +02:00
|
|
|
* Copyright (C) 2009-2012 Typesafe Inc. <http://www.typesafe.com>
|
2012-05-14 14:26:32 +02:00
|
|
|
*/
|
|
|
|
|
package akka.remote
|
|
|
|
|
|
2012-05-23 09:26:20 +02:00
|
|
|
import com.typesafe.config.ConfigFactory
|
|
|
|
|
|
2012-05-14 14:26:32 +02:00
|
|
|
import akka.actor.Actor
|
|
|
|
|
import akka.actor.ActorRef
|
|
|
|
|
import akka.actor.Props
|
|
|
|
|
import akka.pattern.ask
|
2012-05-23 09:26:20 +02:00
|
|
|
import akka.remote.testkit.MultiNodeConfig
|
|
|
|
|
import akka.remote.testkit.MultiNodeSpec
|
|
|
|
|
import akka.testkit._
|
2012-05-14 14:26:32 +02:00
|
|
|
|
2012-05-23 09:26:20 +02:00
|
|
|
object SimpleRemoteMultiJvmSpec extends MultiNodeConfig {
|
2012-05-14 14:26:32 +02:00
|
|
|
|
|
|
|
|
class SomeActor extends Actor with Serializable {
|
|
|
|
|
def receive = {
|
|
|
|
|
case "identify" ⇒ sender ! self
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-23 09:26:20 +02:00
|
|
|
commonConfig(ConfigFactory.parseString("""
|
2012-05-24 10:56:32 +02:00
|
|
|
# akka.loglevel = DEBUG
|
2012-05-23 09:26:20 +02:00
|
|
|
akka.remote {
|
|
|
|
|
log-received-messages = on
|
|
|
|
|
log-sent-messages = on
|
|
|
|
|
}
|
|
|
|
|
akka.actor.debug {
|
|
|
|
|
receive = on
|
|
|
|
|
fsm = on
|
|
|
|
|
}
|
|
|
|
|
"""))
|
|
|
|
|
|
|
|
|
|
val master = role("master")
|
|
|
|
|
val slave = role("slave")
|
2012-05-14 14:26:32 +02:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-23 09:26:20 +02:00
|
|
|
class SimpleRemoteMultiJvmNode1 extends SimpleRemoteSpec
|
|
|
|
|
class SimpleRemoteMultiJvmNode2 extends SimpleRemoteSpec
|
|
|
|
|
|
|
|
|
|
class SimpleRemoteSpec extends MultiNodeSpec(SimpleRemoteMultiJvmSpec)
|
|
|
|
|
with ImplicitSender with DefaultTimeout {
|
2012-05-14 14:26:32 +02:00
|
|
|
import SimpleRemoteMultiJvmSpec._
|
|
|
|
|
|
2012-05-23 09:26:20 +02:00
|
|
|
def initialParticipants = 2
|
|
|
|
|
|
|
|
|
|
runOn(master) {
|
2012-05-14 14:26:32 +02:00
|
|
|
system.actorOf(Props[SomeActor], "service-hello")
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-23 09:26:20 +02:00
|
|
|
"Remoting" must {
|
|
|
|
|
"lookup remote actor" in {
|
|
|
|
|
runOn(slave) {
|
|
|
|
|
val hello = system.actorFor(node(master) / "user" / "service-hello")
|
|
|
|
|
hello.isInstanceOf[RemoteActorRef] must be(true)
|
|
|
|
|
val masterAddress = testConductor.getAddressFor(master).await
|
|
|
|
|
(hello ? "identify").await.asInstanceOf[ActorRef].path.address must equal(masterAddress)
|
|
|
|
|
}
|
|
|
|
|
testConductor.enter("done")
|
|
|
|
|
}
|
2012-05-14 14:26:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2012-05-23 09:26:20 +02:00
|
|
|
|