From 8540c70f18fb1d995313c6477937abd4744535d6 Mon Sep 17 00:00:00 2001 From: Roland Date: Fri, 9 Dec 2011 18:15:14 +0100 Subject: [PATCH] require deployment actor paths to be relative to /user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - they still must start with “/” in the configuration file - they will be looked up while deploying under /user and /remote, the latter being necessary to support fully transparent deployment (i.e. the path under /remote is shortened from the left to arrive at the logical ancestor which is just a child of /user on some node) --- .../akka/remote/RemoteActorRefProvider.scala | 16 ++++++++++++---- .../akka/remote/RemoteCommunicationSpec.scala | 6 +++--- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/akka-remote/src/main/scala/akka/remote/RemoteActorRefProvider.scala b/akka-remote/src/main/scala/akka/remote/RemoteActorRefProvider.scala index df7fcf8544..2a39a44c12 100644 --- a/akka-remote/src/main/scala/akka/remote/RemoteActorRefProvider.scala +++ b/akka-remote/src/main/scala/akka/remote/RemoteActorRefProvider.scala @@ -75,18 +75,26 @@ class RemoteActorRefProvider( else { val path = supervisor.path / name - val deployment = deployer.lookupDeploymentFor(path.elements.mkString("/", "/", "")) - @scala.annotation.tailrec def lookupRemotes(p: Iterable[String]): Option[DeploymentConfig.Deploy] = { p.headOption match { case None ⇒ None case Some("remote") ⇒ lookupRemotes(p.drop(2)) - case Some(_) ⇒ deployer.lookupDeploymentFor(p.mkString("/", "/", "")) + case Some("user") ⇒ deployer.lookupDeploymentFor(p.drop(1).mkString("/", "/", "")) + case Some(_) ⇒ None } } - deployment orElse (if (path.elements.head == "remote") lookupRemotes(path.elements) else None) match { + val elems = path.elements + val deployment = (elems.head match { + case "user" ⇒ deployer.lookupDeploymentFor(elems.drop(1).mkString("/", "/", "")) + case _ ⇒ None + }) orElse (elems.head match { + case "remote" ⇒ lookupRemotes(elems) + case _ ⇒ None + }) + + deployment match { case Some(DeploymentConfig.Deploy(_, _, routerType, nrOfInstances, RemoteDeploymentConfig.RemoteScope(remoteAddresses))) ⇒ // FIXME RK deployer shall only concern itself with placement of actors on remote nodes diff --git a/akka-remote/src/test/scala/akka/remote/RemoteCommunicationSpec.scala b/akka-remote/src/test/scala/akka/remote/RemoteCommunicationSpec.scala index 7d0676464f..80e7c122da 100644 --- a/akka-remote/src/test/scala/akka/remote/RemoteCommunicationSpec.scala +++ b/akka-remote/src/test/scala/akka/remote/RemoteCommunicationSpec.scala @@ -38,9 +38,9 @@ akka { port = 12345 } actor.deployment { - /user/blub.remote.nodes = ["remote_sys@localhost:12346"] - /user/looker/child.remote.nodes = ["remote_sys@localhost:12346"] - /user/looker/child/grandchild.remote.nodes = ["RemoteCommunicationSpec@localhost:12345"] + /blub.remote.nodes = ["remote_sys@localhost:12346"] + /looker/child.remote.nodes = ["remote_sys@localhost:12346"] + /looker/child/grandchild.remote.nodes = ["RemoteCommunicationSpec@localhost:12345"] } } """) with ImplicitSender {