From 755408a52800e7fc8cd72b3e36179e5bfafd8554 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Bone=CC=81r?= Date: Tue, 7 Feb 2012 16:53:49 +0100 Subject: [PATCH] Removed cluster seed nodes, added 'join.contact-point', changed joining phase, added singleton cluster mode plus misc other changes. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jonas Bonér --- akka-cluster/src/main/resources/reference.conf | 10 ++++++++++ .../src/main/scala/akka/cluster/Gossiper.scala | 10 ++++++++++ .../test/scala/akka/cluster/ClusterConfigSpec.scala | 6 +++++- akka-docs/cluster/cluster.rst | 9 +++++---- 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/akka-cluster/src/main/resources/reference.conf b/akka-cluster/src/main/resources/reference.conf index 4d8c4a5e32..41a53ce52f 100644 --- a/akka-cluster/src/main/resources/reference.conf +++ b/akka-cluster/src/main/resources/reference.conf @@ -8,9 +8,19 @@ akka { cluster { +<<<<<<< HEAD # node to join - the full URI defined by a string on the form of "akka://system@hostname:port" # leave as empty string if the node should be a singleton cluster node-to-join = "" +======= + join { + # contact point on the form of "hostname:port" of a node to try to join + # leave as empty string if the node should be a singleton cluster + contact-point = "" + timeout = 30s + max-time-to-retry = 30s + } +>>>>>>> Removed cluster seed nodes, added 'join.contact-point', changed joining phase, added singleton cluster mode plus misc other changes. gossip { initialDelay = 5s diff --git a/akka-cluster/src/main/scala/akka/cluster/Gossiper.scala b/akka-cluster/src/main/scala/akka/cluster/Gossiper.scala index b134a9c54c..a082f29d7c 100644 --- a/akka-cluster/src/main/scala/akka/cluster/Gossiper.scala +++ b/akka-cluster/src/main/scala/akka/cluster/Gossiper.scala @@ -314,6 +314,16 @@ case class Gossiper(system: ActorSystemImpl, remote: RemoteActorRefProvider) { log.info("Node [{}] - Sending [{}] to [{}] through connection [{}]", remoteAddress, command, member.address, connection) connection ! command } + + contactPoint match { + case None ⇒ log.info("Booting up in singleton cluster mode") + case Some(member) ⇒ + log.info("Trying to join contact point node defined in the configuration [{}]", member) + setUpConnectionTo(member) match { + case None ⇒ log.error("Could not set up connection to join contact point node defined in the configuration [{}]", member) + case Some(connection) ⇒ tryJoinContactPoint(connection, deadline) + } + } } /** diff --git a/akka-cluster/src/test/scala/akka/cluster/ClusterConfigSpec.scala b/akka-cluster/src/test/scala/akka/cluster/ClusterConfigSpec.scala index 78c836f0b5..7f1b26e553 100644 --- a/akka-cluster/src/test/scala/akka/cluster/ClusterConfigSpec.scala +++ b/akka-cluster/src/test/scala/akka/cluster/ClusterConfigSpec.scala @@ -25,7 +25,11 @@ class ClusterConfigSpec extends AkkaSpec( import settings._ FailureDetectorThreshold must be(8) FailureDetectorMaxSampleSize must be(1000) - NodeToJoin must be(None) + + JoinContactPoint must be(None) + JoinTimeout must be(30 seconds) + JoinMaxTimeToRetry must be(30 seconds) + GossipInitialDelay must be(5 seconds) GossipFrequency must be(1 second) } diff --git a/akka-docs/cluster/cluster.rst b/akka-docs/cluster/cluster.rst index 40c84f3737..64e49b898e 100644 --- a/akka-docs/cluster/cluster.rst +++ b/akka-docs/cluster/cluster.rst @@ -74,12 +74,13 @@ each node hosting some part of the application. Cluster membership and partitioning of the application are decoupled. A node could be a member of a cluster without hosting any actors. -Single-node Cluster -------------------- + +Singleton Cluster +----------------- If a node does not have a preconfigured contact point to join in the Akka -configuration, then it is considered a single-node cluster and will -automatically transition from ``joining`` to ``up``. Single-node clusters +configuration, then it is considered a singleton cluster (single node cluster) +and will automatically transition from ``joining`` to ``up``. Singleton clusters can later explicitly send a ``Join`` message to another node to form a N-node cluster. It is also possible to link multiple N-node clusters by ``joining`` them.