2011-12-05 11:16:29 +01:00
|
|
|
package akka.remote
|
|
|
|
|
|
2011-12-15 11:43:26 +01:00
|
|
|
import akka.actor.{ Actor, Props }
|
2011-12-05 11:16:29 +01:00
|
|
|
import akka.remote._
|
2011-12-15 11:43:26 +01:00
|
|
|
import akka.routing._
|
|
|
|
|
import akka.testkit._
|
|
|
|
|
import akka.util.duration._
|
|
|
|
|
import akka.dispatch.Await
|
2011-12-05 11:16:29 +01:00
|
|
|
|
2011-12-21 16:07:18 +04:00
|
|
|
object NewRemoteActorMultiJvmSpec extends AbstractRemoteActorMultiJvmSpec {
|
|
|
|
|
override def NrOfNodes = 2
|
2011-12-05 11:16:29 +01:00
|
|
|
|
|
|
|
|
class SomeActor extends Actor with Serializable {
|
|
|
|
|
def receive = {
|
2011-12-15 11:43:26 +01:00
|
|
|
case "identify" ⇒ sender ! context.system.nodename
|
2011-12-05 11:16:29 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
import com.typesafe.config.ConfigFactory
|
2011-12-21 16:07:18 +04:00
|
|
|
override def commonConfig = ConfigFactory.parseString("""
|
2011-12-05 11:16:29 +01:00
|
|
|
akka {
|
|
|
|
|
loglevel = "WARNING"
|
|
|
|
|
actor {
|
|
|
|
|
provider = "akka.remote.RemoteActorRefProvider"
|
|
|
|
|
deployment {
|
2011-12-15 11:43:26 +01:00
|
|
|
/service-hello.remote = "akka://AkkaRemoteSpec@localhost:9991"
|
2011-12-05 11:16:29 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}""")
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-21 16:07:18 +04:00
|
|
|
class NewRemoteActorMultiJvmNode1 extends AkkaRemoteSpec(NewRemoteActorMultiJvmSpec.nodeConfigs(0)) {
|
2011-12-05 11:16:29 +01:00
|
|
|
|
|
|
|
|
import NewRemoteActorMultiJvmSpec._
|
|
|
|
|
|
|
|
|
|
val nodes = NrOfNodes
|
|
|
|
|
|
|
|
|
|
"___" must {
|
|
|
|
|
"___" in {
|
|
|
|
|
barrier("start")
|
|
|
|
|
|
|
|
|
|
barrier("done")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-21 16:07:18 +04:00
|
|
|
class NewRemoteActorMultiJvmNode2 extends AkkaRemoteSpec(NewRemoteActorMultiJvmSpec.nodeConfigs(1)) with DefaultTimeout {
|
2011-12-05 11:16:29 +01:00
|
|
|
|
|
|
|
|
import NewRemoteActorMultiJvmSpec._
|
|
|
|
|
|
|
|
|
|
val nodes = NrOfNodes
|
|
|
|
|
|
|
|
|
|
"A new remote actor" must {
|
|
|
|
|
"be locally instantiated on a remote node and be able to communicate through its RemoteActorRef" in {
|
|
|
|
|
barrier("start")
|
|
|
|
|
|
2011-12-15 11:43:26 +01:00
|
|
|
val actor = system.actorOf(Props[SomeActor], "service-hello")
|
|
|
|
|
Await.result(actor ? "identify", timeout.duration) must equal("node1")
|
2011-12-05 11:16:29 +01:00
|
|
|
|
|
|
|
|
barrier("done")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|