From bfd11ad8c5deab4bc3dc5a84c090d9c28251afa6 Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Tue, 17 Jan 2012 15:25:26 +0100 Subject: [PATCH] Removing nodename --- .../src/main/scala/akka/actor/ActorCell.scala | 4 ++-- .../scala/akka/actor/ActorRefProvider.scala | 5 ----- .../main/scala/akka/actor/ActorSystem.scala | 6 ------ .../RoundRobin1ReplicaMultiJvmSpec.scala | 3 +-- akka-docs/dev/multi-jvm-testing.rst | 19 ++++++++----------- akka-remote/src/main/resources/reference.conf | 1 - .../src/main/scala/akka/remote/Remote.scala | 4 ++-- .../akka/remote/RemoteActorRefProvider.scala | 1 - .../scala/akka/remote/RemoteSettings.scala | 5 ----- .../AbstractRemoteActorMultiJvmSpec.scala | 1 - .../DirectRoutedRemoteActorMultiJvmSpec.scala | 4 ++-- .../remote/NewRemoteActorMultiJvmSpec.scala | 4 ++-- .../RandomRoutedRemoteActorMultiJvmSpec.scala | 8 ++++---- ...ndRobinRoutedRemoteActorMultiJvmSpec.scala | 9 +++++---- ...rGatherRoutedRemoteActorMultiJvmSpec.scala | 4 ++-- .../akka/remote/RemoteCommunicationSpec.scala | 1 - .../scala/akka/remote/RemoteConfigSpec.scala | 3 +-- .../akka/remote/RemoteDeathWatchSpec.scala | 1 - .../akka/remote/RemoteDeployerSpec.scala | 1 - .../scala/akka/remote/RemoteRouterSpec.scala | 1 - .../src/main/resources/application.conf | 3 --- 21 files changed, 29 insertions(+), 59 deletions(-) diff --git a/akka-actor/src/main/scala/akka/actor/ActorCell.scala b/akka-actor/src/main/scala/akka/actor/ActorCell.scala index c804f5b56f..40f94b4210 100644 --- a/akka-actor/src/main/scala/akka/actor/ActorCell.scala +++ b/akka-actor/src/main/scala/akka/actor/ActorCell.scala @@ -287,10 +287,10 @@ private[akka] class ActorCell( mailbox = dispatcher.createMailbox(this) // ➡➡➡ NEVER SEND THE SAME SYSTEM MESSAGE OBJECT TO TWO ACTORS ⬅⬅⬅ - dispatcher.systemDispatch(this, Create()) + parent.sendSystemMessage(akka.dispatch.Supervise(self)) // ➡➡➡ NEVER SEND THE SAME SYSTEM MESSAGE OBJECT TO TWO ACTORS ⬅⬅⬅ - parent.sendSystemMessage(akka.dispatch.Supervise(self)) + dispatcher.systemDispatch(this, Create()) dispatcher.attach(this) } diff --git a/akka-actor/src/main/scala/akka/actor/ActorRefProvider.scala b/akka-actor/src/main/scala/akka/actor/ActorRefProvider.scala index de907827a5..7bc9f502d1 100644 --- a/akka-actor/src/main/scala/akka/actor/ActorRefProvider.scala +++ b/akka-actor/src/main/scala/akka/actor/ActorRefProvider.scala @@ -39,8 +39,6 @@ trait ActorRefProvider { */ def deathWatch: DeathWatch - def nodename: String - /** * The root path for all actors within this actor system, including remote * address if enabled. @@ -285,9 +283,6 @@ class LocalActorRefProvider( new RootActorPath(LocalAddress(_systemName)), new Deployer(settings)) - val nodename: String = "local" - val clustername: String = "local" - val log = Logging(eventStream, "LocalActorRefProvider(" + rootPath.address + ")") /* diff --git a/akka-actor/src/main/scala/akka/actor/ActorSystem.scala b/akka-actor/src/main/scala/akka/actor/ActorSystem.scala index 00df791166..174d13b9d2 100644 --- a/akka-actor/src/main/scala/akka/actor/ActorSystem.scala +++ b/akka-actor/src/main/scala/akka/actor/ActorSystem.scala @@ -153,11 +153,6 @@ abstract class ActorSystem extends ActorRefFactory { */ def logConfiguration(): Unit - /** - * The logical node name where this actor system resides. - */ - def nodename: String - /** * Construct a path below the application guardian to be used with [[ActorSystem.actorFor]]. */ @@ -373,7 +368,6 @@ class ActorSystemImpl(val name: String, applicationConfig: Config) extends Actor def guardian: InternalActorRef = provider.guardian def systemGuardian: InternalActorRef = provider.systemGuardian def deathWatch: DeathWatch = provider.deathWatch - def nodename: String = provider.nodename def /(actorName: String): ActorPath = guardian.path / actorName def /(path: Iterable[String]): ActorPath = guardian.path / path diff --git a/akka-cluster/src/multi-jvm/scala/akka/cluster/routing/roundrobin/replicationfactor_1/RoundRobin1ReplicaMultiJvmSpec.scala b/akka-cluster/src/multi-jvm/scala/akka/cluster/routing/roundrobin/replicationfactor_1/RoundRobin1ReplicaMultiJvmSpec.scala index 35938749ba..3605ba9d34 100644 --- a/akka-cluster/src/multi-jvm/scala/akka/cluster/routing/roundrobin/replicationfactor_1/RoundRobin1ReplicaMultiJvmSpec.scala +++ b/akka-cluster/src/multi-jvm/scala/akka/cluster/routing/roundrobin/replicationfactor_1/RoundRobin1ReplicaMultiJvmSpec.scala @@ -17,8 +17,7 @@ object RoundRobin1ReplicaMultiJvmSpec { class HelloWorld extends Actor with Serializable { def receive = { - case "Hello" ⇒ - reply("World from node [" + Config.nodename + "]") + case "Hello" ⇒ reply("World from node [" + Config.nodename + "]") } } diff --git a/akka-docs/dev/multi-jvm-testing.rst b/akka-docs/dev/multi-jvm-testing.rst index dfad74f84e..9fc42349f2 100644 --- a/akka-docs/dev/multi-jvm-testing.rst +++ b/akka-docs/dev/multi-jvm-testing.rst @@ -159,21 +159,20 @@ You can define specific JVM options for each of the spawned JVMs. You do that by a file named after the node in the test with suffix ``.opts`` and put them in the same directory as the test. -For example, to feed the JVM options ``-Dakka.cluster.nodename=node1`` and -``-Dakka.remote.port=9991`` to the ``SampleMultiJvmNode1`` let's create three ``*.opts`` files -and add the options to them. +For example, to feed the JVM options ``-Dakka.remote.port=9991`` to the ``SampleMultiJvmNode1`` +let's create three ``*.opts`` files and add the options to them. ``SampleMultiJvmNode1.opts``:: - -Dakka.cluster.nodename=node1 -Dakka.remote.port=9991 + -Dakka.remote.port=9991 ``SampleMultiJvmNode2.opts``:: - -Dakka.cluster.nodename=node2 -Dakka.remote.port=9992 + -Dakka.remote.port=9992 ``SampleMultiJvmNode3.opts``:: - -Dakka.cluster.nodename=node3 -Dakka.remote.port=9993 + -Dakka.remote.port=9993 Overriding configuration options @@ -188,15 +187,15 @@ For example, to override the configuration option ``akka.cluster.name`` let's cr ``SampleMultiJvmNode1.conf``:: - akka.cluster.name = "test-cluster" + akka.remote.port = 9991 ``SampleMultiJvmNode2.conf``:: - akka.cluster.name = "test-cluster" + akka.remote.port = 9992 ``SampleMultiJvmNode3.conf``:: - akka.cluster.name = "test-cluster" + akka.remote.port = 9993 ScalaTest @@ -277,7 +276,6 @@ something in coordination:: "A cluster" must { "have jvm options" in { - System.getProperty("akka.cluster.nodename", "") must be("node1") System.getProperty("akka.remote.port", "") must be("9991") akka.config.Config.config.getString("test.name", "") must be("node1") } @@ -298,7 +296,6 @@ something in coordination:: "A cluster" must { "have jvm options" in { - System.getProperty("akka.cluster.nodename", "") must be("node2") System.getProperty("akka.remote.port", "") must be("9992") akka.config.Config.config.getString("test.name", "") must be("node2") } diff --git a/akka-remote/src/main/resources/reference.conf b/akka-remote/src/main/resources/reference.conf index 960d663636..814a85f591 100644 --- a/akka-remote/src/main/resources/reference.conf +++ b/akka-remote/src/main/resources/reference.conf @@ -137,7 +137,6 @@ akka { } cluster { - nodename = "default" seed-nodes = [] } } diff --git a/akka-remote/src/main/scala/akka/remote/Remote.scala b/akka-remote/src/main/scala/akka/remote/Remote.scala index 6efa542e0e..f76aa8e908 100644 --- a/akka-remote/src/main/scala/akka/remote/Remote.scala +++ b/akka-remote/src/main/scala/akka/remote/Remote.scala @@ -110,7 +110,7 @@ class Remote(val settings: ActorSystem.Settings, val remoteSettings: RemoteSetti } } - log.info("Starting remote server on [{}] with node name [{}]", remoteAddress, provider.nodename) + log.info("Starting remote server on [{}@{}]", system.name, remoteAddress) } } @@ -153,7 +153,7 @@ class RemoteSystemDaemon(system: ActorSystemImpl, remote: Remote, _path: ActorPa override def !(msg: Any)(implicit sender: ActorRef = null): Unit = msg match { case message: DaemonMsg ⇒ - log.debug("Received command [{}] to RemoteSystemDaemon on [{}]", message, remote.remoteSettings.NodeName) + log.debug("Received command [{}] to RemoteSystemDaemon on [{}]", message, path.address.hostPort) message match { case DaemonMsgCreate(factory, path, supervisor) ⇒ import remote.remoteAddress diff --git a/akka-remote/src/main/scala/akka/remote/RemoteActorRefProvider.scala b/akka-remote/src/main/scala/akka/remote/RemoteActorRefProvider.scala index bcfb98e76d..397f110783 100644 --- a/akka-remote/src/main/scala/akka/remote/RemoteActorRefProvider.scala +++ b/akka-remote/src/main/scala/akka/remote/RemoteActorRefProvider.scala @@ -32,7 +32,6 @@ class RemoteActorRefProvider( def rootGuardian = local.rootGuardian def guardian = local.guardian def systemGuardian = local.systemGuardian - def nodename = remoteSettings.NodeName def terminationFuture = local.terminationFuture def dispatcher = local.dispatcher diff --git a/akka-remote/src/main/scala/akka/remote/RemoteSettings.scala b/akka-remote/src/main/scala/akka/remote/RemoteSettings.scala index bc765bae26..ad0356c009 100644 --- a/akka-remote/src/main/scala/akka/remote/RemoteSettings.scala +++ b/akka-remote/src/main/scala/akka/remote/RemoteSettings.scala @@ -29,11 +29,6 @@ class RemoteSettings(val config: Config, val systemName: String) { case RemoteAddressExtractor(addr) ⇒ addr.transport } - val NodeName: String = config.getString("akka.cluster.nodename") match { - case "" ⇒ throw new ConfigurationException("Configuration option 'akka.cluster.nodename' must be non-empty.") - case value ⇒ value - } - val serverSettings = new RemoteServerSettings val clientSettings = new RemoteClientSettings diff --git a/akka-remote/src/multi-jvm/scala/akka/remote/AbstractRemoteActorMultiJvmSpec.scala b/akka-remote/src/multi-jvm/scala/akka/remote/AbstractRemoteActorMultiJvmSpec.scala index 0bc6d33f68..597b552fe9 100755 --- a/akka-remote/src/multi-jvm/scala/akka/remote/AbstractRemoteActorMultiJvmSpec.scala +++ b/akka-remote/src/multi-jvm/scala/akka/remote/AbstractRemoteActorMultiJvmSpec.scala @@ -23,7 +23,6 @@ trait AbstractRemoteActorMultiJvmSpec { akka { remote.server.hostname="%s" remote.server.port = "%d" - cluster.nodename = "node%d" }""".format(host, 9990+idx, idx)) withFallback commonConfig } } diff --git a/akka-remote/src/multi-jvm/scala/akka/remote/DirectRoutedRemoteActorMultiJvmSpec.scala b/akka-remote/src/multi-jvm/scala/akka/remote/DirectRoutedRemoteActorMultiJvmSpec.scala index 1b7a561cda..97b0e9c7e0 100644 --- a/akka-remote/src/multi-jvm/scala/akka/remote/DirectRoutedRemoteActorMultiJvmSpec.scala +++ b/akka-remote/src/multi-jvm/scala/akka/remote/DirectRoutedRemoteActorMultiJvmSpec.scala @@ -11,7 +11,7 @@ object DirectRoutedRemoteActorMultiJvmSpec extends AbstractRemoteActorMultiJvmSp class SomeActor extends Actor with Serializable { def receive = { - case "identify" ⇒ sender ! context.system.nodename + case "identify" ⇒ sender ! self.path.address.hostPort } } @@ -52,7 +52,7 @@ class DirectRoutedRemoteActorMultiJvmNode2 extends AkkaRemoteSpec(DirectRoutedRe val actor = system.actorOf(Props[SomeActor], "service-hello") actor.isInstanceOf[RemoteActorRef] must be(true) - Await.result(actor ? "identify", timeout.duration) must equal("node1") + Await.result(actor ? "identify", timeout.duration) must equal("AkkaRemoteSpec@localhost:9991") barrier("done") } diff --git a/akka-remote/src/multi-jvm/scala/akka/remote/NewRemoteActorMultiJvmSpec.scala b/akka-remote/src/multi-jvm/scala/akka/remote/NewRemoteActorMultiJvmSpec.scala index f7a02c3988..e6ed14419f 100644 --- a/akka-remote/src/multi-jvm/scala/akka/remote/NewRemoteActorMultiJvmSpec.scala +++ b/akka-remote/src/multi-jvm/scala/akka/remote/NewRemoteActorMultiJvmSpec.scala @@ -12,7 +12,7 @@ object NewRemoteActorMultiJvmSpec extends AbstractRemoteActorMultiJvmSpec { class SomeActor extends Actor with Serializable { def receive = { - case "identify" ⇒ sender ! context.system.nodename + case "identify" ⇒ sender ! self.path.address.hostPort } } @@ -55,7 +55,7 @@ class NewRemoteActorMultiJvmNode2 extends AkkaRemoteSpec(NewRemoteActorMultiJvmS barrier("start") val actor = system.actorOf(Props[SomeActor], "service-hello") - Await.result(actor ? "identify", timeout.duration) must equal("node1") + Await.result(actor ? "identify", timeout.duration) must equal("AkkaRemoteSpec@localhost:9991") barrier("done") } diff --git a/akka-remote/src/multi-jvm/scala/akka/remote/RandomRoutedRemoteActorMultiJvmSpec.scala b/akka-remote/src/multi-jvm/scala/akka/remote/RandomRoutedRemoteActorMultiJvmSpec.scala index b9440d28b3..c2cc058f8d 100644 --- a/akka-remote/src/multi-jvm/scala/akka/remote/RandomRoutedRemoteActorMultiJvmSpec.scala +++ b/akka-remote/src/multi-jvm/scala/akka/remote/RandomRoutedRemoteActorMultiJvmSpec.scala @@ -10,7 +10,7 @@ object RandomRoutedRemoteActorMultiJvmSpec extends AbstractRemoteActorMultiJvmSp override def NrOfNodes = 4 class SomeActor extends Actor with Serializable { def receive = { - case "hit" ⇒ sender ! context.system.nodename + case "hit" ⇒ sender ! self.path.address.hostPort case "end" ⇒ context.stop(self) } } @@ -83,9 +83,9 @@ class RandomRoutedRemoteActorMultiJvmNode4 extends AkkaRemoteSpec(RandomRoutedRe val iterationCount = 10 var replies = Map( - "node1" -> 0, - "node2" -> 0, - "node3" -> 0) + "AkkaRemoteSpec@localhost:9991" -> 0, + "AkkaRemoteSpec@localhost:9992" -> 0, + "AkkaRemoteSpec@localhost:9993" -> 0) for (i ← 0 until iterationCount) { for (k ← 0 until connectionCount) { diff --git a/akka-remote/src/multi-jvm/scala/akka/remote/RoundRobinRoutedRemoteActorMultiJvmSpec.scala b/akka-remote/src/multi-jvm/scala/akka/remote/RoundRobinRoutedRemoteActorMultiJvmSpec.scala index 5b5c6cbf6d..38e3182957 100644 --- a/akka-remote/src/multi-jvm/scala/akka/remote/RoundRobinRoutedRemoteActorMultiJvmSpec.scala +++ b/akka-remote/src/multi-jvm/scala/akka/remote/RoundRobinRoutedRemoteActorMultiJvmSpec.scala @@ -11,7 +11,7 @@ object RoundRobinRoutedRemoteActorMultiJvmSpec extends AbstractRemoteActorMultiJ class SomeActor extends Actor with Serializable { def receive = { - case "hit" ⇒ sender ! context.system.nodename + case "hit" ⇒ sender ! self.path.address.hostPort case "end" ⇒ context.stop(self) } } @@ -84,13 +84,14 @@ class RoundRobinRoutedRemoteActorMultiJvmNode4 extends AkkaRemoteSpec(RoundRobin val iterationCount = 10 var replies = Map( - "node1" -> 0, - "node2" -> 0, - "node3" -> 0) + "AkkaRemoteSpec@localhost:9991" -> 0, + "AkkaRemoteSpec@localhost:9992" -> 0, + "AkkaRemoteSpec@localhost:9993" -> 0) for (i ← 0 until iterationCount) { for (k ← 0 until connectionCount) { val nodeName = Await.result(actor ? "hit", timeout.duration).toString + replies = replies + (nodeName -> (replies(nodeName) + 1)) } } diff --git a/akka-remote/src/multi-jvm/scala/akka/remote/ScatterGatherRoutedRemoteActorMultiJvmSpec.scala b/akka-remote/src/multi-jvm/scala/akka/remote/ScatterGatherRoutedRemoteActorMultiJvmSpec.scala index c34de28882..48ef5adcc9 100644 --- a/akka-remote/src/multi-jvm/scala/akka/remote/ScatterGatherRoutedRemoteActorMultiJvmSpec.scala +++ b/akka-remote/src/multi-jvm/scala/akka/remote/ScatterGatherRoutedRemoteActorMultiJvmSpec.scala @@ -10,7 +10,7 @@ object ScatterGatherRoutedRemoteActorMultiJvmSpec extends AbstractRemoteActorMul override def NrOfNodes = 4 class SomeActor extends Actor with Serializable { def receive = { - case "hit" ⇒ sender ! context.system.nodename + case "hit" ⇒ sender ! self.path.address.hostPort case "end" ⇒ context.stop(self) } } @@ -91,7 +91,7 @@ class ScatterGatherRoutedRemoteActorMultiJvmNode4 extends AkkaRemoteSpec(Scatter val replies = (receiveWhile(5 seconds, messages = connectionCount * iterationCount) { case name: String ⇒ (name, 1) - }).foldLeft(Map("node1" -> 0, "node2" -> 0, "node3" -> 0)) { + }).foldLeft(Map("AkkaRemoteSpec@localhost:9991" -> 0, "AkkaRemoteSpec@localhost:9992" -> 0, "AkkaRemoteSpec@localhost:9993" -> 0)) { case (m, (n, c)) ⇒ m + (n -> (m(n) + c)) } diff --git a/akka-remote/src/test/scala/akka/remote/RemoteCommunicationSpec.scala b/akka-remote/src/test/scala/akka/remote/RemoteCommunicationSpec.scala index dd62ae48e2..58199b4683 100644 --- a/akka-remote/src/test/scala/akka/remote/RemoteCommunicationSpec.scala +++ b/akka-remote/src/test/scala/akka/remote/RemoteCommunicationSpec.scala @@ -33,7 +33,6 @@ object RemoteCommunicationSpec { class RemoteCommunicationSpec extends AkkaSpec(""" akka { actor.provider = "akka.remote.RemoteActorRefProvider" - cluster.nodename = Nonsense remote.server { hostname = localhost port = 12345 diff --git a/akka-remote/src/test/scala/akka/remote/RemoteConfigSpec.scala b/akka-remote/src/test/scala/akka/remote/RemoteConfigSpec.scala index 5d053f377b..03a343f3b1 100644 --- a/akka-remote/src/test/scala/akka/remote/RemoteConfigSpec.scala +++ b/akka-remote/src/test/scala/akka/remote/RemoteConfigSpec.scala @@ -3,7 +3,7 @@ package akka.remote import akka.testkit.AkkaSpec @org.junit.runner.RunWith(classOf[org.scalatest.junit.JUnitRunner]) -class RemoteConfigSpec extends AkkaSpec("akka.cluster.nodename = node1") { +class RemoteConfigSpec extends AkkaSpec("") { "RemoteExtension" must { "be able to parse remote and cluster config elements" in { @@ -40,7 +40,6 @@ class RemoteConfigSpec extends AkkaSpec("akka.cluster.nodename = node1") { // TODO cluster config will go into akka-cluster/reference.conf when we enable that module //akka.cluster - getString("akka.cluster.nodename") must equal("node1") getStringList("akka.cluster.seed-nodes") must equal(new java.util.ArrayList[String]) // getMilliseconds("akka.cluster.max-time-to-wait-until-connected") must equal(30 * 1000) diff --git a/akka-remote/src/test/scala/akka/remote/RemoteDeathWatchSpec.scala b/akka-remote/src/test/scala/akka/remote/RemoteDeathWatchSpec.scala index b51720aa01..80a4f3cffe 100644 --- a/akka-remote/src/test/scala/akka/remote/RemoteDeathWatchSpec.scala +++ b/akka-remote/src/test/scala/akka/remote/RemoteDeathWatchSpec.scala @@ -16,7 +16,6 @@ akka { /watchers.remote = "akka://other@127.0.0.1:2666" } } - cluster.nodename = buh remote.server { hostname = "127.0.0.1" port = 2665 diff --git a/akka-remote/src/test/scala/akka/remote/RemoteDeployerSpec.scala b/akka-remote/src/test/scala/akka/remote/RemoteDeployerSpec.scala index 1e78b3ebe3..15016748d0 100644 --- a/akka-remote/src/test/scala/akka/remote/RemoteDeployerSpec.scala +++ b/akka-remote/src/test/scala/akka/remote/RemoteDeployerSpec.scala @@ -11,7 +11,6 @@ import com.typesafe.config._ object RemoteDeployerSpec { val deployerConf = ConfigFactory.parseString(""" akka.actor.provider = "akka.remote.RemoteActorRefProvider" - akka.cluster.nodename = Whatever akka.actor.deployment { /user/service2 { router = round-robin diff --git a/akka-remote/src/test/scala/akka/remote/RemoteRouterSpec.scala b/akka-remote/src/test/scala/akka/remote/RemoteRouterSpec.scala index f183a940a7..5c06f36804 100644 --- a/akka-remote/src/test/scala/akka/remote/RemoteRouterSpec.scala +++ b/akka-remote/src/test/scala/akka/remote/RemoteRouterSpec.scala @@ -19,7 +19,6 @@ object RemoteRouterSpec { class RemoteRouterSpec extends AkkaSpec(""" akka { actor.provider = "akka.remote.RemoteActorRefProvider" - cluster.nodename = Nonsense remote.server { hostname = localhost port = 12345 diff --git a/akka-samples/akka-sample-remote/src/main/resources/application.conf b/akka-samples/akka-sample-remote/src/main/resources/application.conf index 6f50121cf4..ce550b33eb 100644 --- a/akka-samples/akka-sample-remote/src/main/resources/application.conf +++ b/akka-samples/akka-sample-remote/src/main/resources/application.conf @@ -4,7 +4,6 @@ calculator { akka { remote.server.port = 2552 - cluster.nodename = "n1" } } //#calculator @@ -15,7 +14,6 @@ remotelookup { akka { remote.server.port = 2553 - cluster.nodename = "n2" } } //#remotelookup @@ -34,7 +32,6 @@ remotecreation { } remote.server.port = 2554 - cluster.nodename = "n3" } } //#remotecreation