=clu #17362 Make cluster.joinSeedNodes equivalent to conf seed-nodes

* the difference was in the retry of failed join attempt
* also clarify the documentation
This commit is contained in:
Patrik Nordwall 2015-05-04 08:35:46 +02:00
parent c68ebc6d5a
commit aaa620c35e
3 changed files with 33 additions and 24 deletions

View file

@ -239,6 +239,7 @@ private[cluster] class ClusterCoreDaemon(publisher: ActorRef) extends Actor with
val statsEnabled = PublishStatsInterval.isFinite val statsEnabled = PublishStatsInterval.isFinite
var gossipStats = GossipStats() var gossipStats = GossipStats()
var seedNodes = SeedNodes
var seedNodeProcess: Option[ActorRef] = None var seedNodeProcess: Option[ActorRef] = None
var seedNodeProcessCounter = 0 // for unique names var seedNodeProcessCounter = 0 // for unique names
var leaderActionCounter = 0 var leaderActionCounter = 0
@ -279,10 +280,10 @@ private[cluster] class ClusterCoreDaemon(publisher: ActorRef) extends Actor with
case _ // auto-down is disabled case _ // auto-down is disabled
} }
if (SeedNodes.isEmpty) if (seedNodes.isEmpty)
logInfo("No seed-nodes configured, manual cluster join required") logInfo("No seed-nodes configured, manual cluster join required")
else else
self ! JoinSeedNodes(SeedNodes) self ! JoinSeedNodes(seedNodes)
} }
override def postStop(): Unit = { override def postStop(): Unit = {
@ -296,7 +297,7 @@ private[cluster] class ClusterCoreDaemon(publisher: ActorRef) extends Actor with
def uninitialized: Actor.Receive = { def uninitialized: Actor.Receive = {
case InitJoin sender() ! InitJoinNack(selfAddress) case InitJoin sender() ! InitJoinNack(selfAddress)
case ClusterUserAction.JoinTo(address) join(address) case ClusterUserAction.JoinTo(address) join(address)
case JoinSeedNodes(seedNodes) joinSeedNodes(seedNodes) case JoinSeedNodes(newSeedNodes) joinSeedNodes(newSeedNodes)
case msg: SubscriptionMessage publisher forward msg case msg: SubscriptionMessage publisher forward msg
} }
@ -306,14 +307,15 @@ private[cluster] class ClusterCoreDaemon(publisher: ActorRef) extends Actor with
case ClusterUserAction.JoinTo(address) case ClusterUserAction.JoinTo(address)
becomeUninitialized() becomeUninitialized()
join(address) join(address)
case JoinSeedNodes(seedNodes) case JoinSeedNodes(newSeedNodes)
becomeUninitialized() becomeUninitialized()
joinSeedNodes(seedNodes) joinSeedNodes(newSeedNodes)
case msg: SubscriptionMessage publisher forward msg case msg: SubscriptionMessage publisher forward msg
case _: Tick case _: Tick
if (deadline.exists(_.isOverdue)) { if (deadline.exists(_.isOverdue)) {
// join attempt failed, retry
becomeUninitialized() becomeUninitialized()
if (SeedNodes.nonEmpty) joinSeedNodes(SeedNodes) if (seedNodes.nonEmpty) joinSeedNodes(seedNodes)
else join(joinWith) else join(joinWith)
} }
} }
@ -371,21 +373,22 @@ private[cluster] class ClusterCoreDaemon(publisher: ActorRef) extends Actor with
def initJoin(): Unit = sender() ! InitJoinAck(selfAddress) def initJoin(): Unit = sender() ! InitJoinAck(selfAddress)
def joinSeedNodes(seedNodes: immutable.IndexedSeq[Address]): Unit = { def joinSeedNodes(newSeedNodes: immutable.IndexedSeq[Address]): Unit = {
if (seedNodes.nonEmpty) { if (newSeedNodes.nonEmpty) {
stopSeedNodeProcess() stopSeedNodeProcess()
seedNodes = newSeedNodes // keep them for retry
seedNodeProcess = seedNodeProcess =
if (seedNodes == immutable.IndexedSeq(selfAddress)) { if (newSeedNodes == immutable.IndexedSeq(selfAddress)) {
self ! ClusterUserAction.JoinTo(selfAddress) self ! ClusterUserAction.JoinTo(selfAddress)
None None
} else { } else {
// use unique name of this actor, stopSeedNodeProcess doesn't wait for termination // use unique name of this actor, stopSeedNodeProcess doesn't wait for termination
seedNodeProcessCounter += 1 seedNodeProcessCounter += 1
if (seedNodes.head == selfAddress) { if (newSeedNodes.head == selfAddress) {
Some(context.actorOf(Props(classOf[FirstSeedNodeProcess], seedNodes). Some(context.actorOf(Props(classOf[FirstSeedNodeProcess], newSeedNodes).
withDispatcher(UseDispatcher), name = "firstSeedNodeProcess-" + seedNodeProcessCounter)) withDispatcher(UseDispatcher), name = "firstSeedNodeProcess-" + seedNodeProcessCounter))
} else { } else {
Some(context.actorOf(Props(classOf[JoinSeedNodeProcess], seedNodes). Some(context.actorOf(Props(classOf[JoinSeedNodeProcess], newSeedNodes).
withDispatcher(UseDispatcher), name = "joinSeedNodeProcess-" + seedNodeProcessCounter)) withDispatcher(UseDispatcher), name = "joinSeedNodeProcess-" + seedNodeProcessCounter))
} }
} }

View file

@ -88,7 +88,9 @@ seed nodes in the existing cluster.
If you don't configure seed nodes you need to join the cluster programmatically or manually. If you don't configure seed nodes you need to join the cluster programmatically or manually.
Manual joining can be performed by using ref:`cluster_jmx_java` or :ref:`cluster_command_line_java`. Manual joining can be performed by using ref:`cluster_jmx_java` or :ref:`cluster_command_line_java`.
Joining programatically can be performed with ``Cluster.get(system).join``. Joining programatically can be performed with ``Cluster.get(system).join``. Unsuccessful join attempts are
automatically retried after the time period defined in configuration property ``retry-unsuccessful-join-after``.
Retries can be disabled by setting the property to ``off``.
You can join to any node in the cluster. It does not have to be configured as a seed node. You can join to any node in the cluster. It does not have to be configured as a seed node.
Note that you can only join to an existing cluster member, which means that for bootstrapping some Note that you can only join to an existing cluster member, which means that for bootstrapping some
@ -99,11 +101,12 @@ which is attractive when dynamically discovering other nodes at startup by using
When using ``joinSeedNodes`` you should not include the node itself except for the node that is When using ``joinSeedNodes`` you should not include the node itself except for the node that is
supposed to be the first seed node, and that should be placed first in parameter to ``joinSeedNodes``. supposed to be the first seed node, and that should be placed first in parameter to ``joinSeedNodes``.
Unsuccessful join attempts are automatically retried after the time period defined in Unsuccessful attempts to contact seed nodes are automatically retried after the time period defined in
configuration property ``retry-unsuccessful-join-after``. When using ``seed-nodes`` this configuration property ``seed-node-timeout``. Unsuccessful attempt to join a specific seed node is
means that a new seed node is picked. When joining manually or programatically this means automatically retried after the configured ``retry-unsuccessful-join-after`. Retrying means that it
that the last join request is retried. Retries can be disabled by setting the property to tries to contact all seed nodes and then joins the node that answers first. The first node in the list
``off``. of seed nodes will join itself if it cannot contact any of the other seed nodes within the
configured ``seed-node-timeout``.
An actor system can only join a cluster once. Additional attempts will be ignored. An actor system can only join a cluster once. Additional attempts will be ignored.
When it has successfully joined it must be restarted to be able to join another When it has successfully joined it must be restarted to be able to join another

View file

@ -82,7 +82,9 @@ seed nodes in the existing cluster.
If you don't configure seed nodes you need to join the cluster programmatically or manually. If you don't configure seed nodes you need to join the cluster programmatically or manually.
Manual joining can be performed by using ref:`cluster_jmx_scala` or :ref:`cluster_command_line_scala`. Manual joining can be performed by using ref:`cluster_jmx_scala` or :ref:`cluster_command_line_scala`.
Joining programatically can be performed with ``Cluster(system).join``. Joining programatically can be performed with ``Cluster(system).join``. Unsuccessful join attempts are
automatically retried after the time period defined in configuration property ``retry-unsuccessful-join-after``.
Retries can be disabled by setting the property to ``off``.
You can join to any node in the cluster. It does not have to be configured as a seed node. You can join to any node in the cluster. It does not have to be configured as a seed node.
Note that you can only join to an existing cluster member, which means that for bootstrapping some Note that you can only join to an existing cluster member, which means that for bootstrapping some
@ -94,11 +96,12 @@ When using ``joinSeedNodes`` you should not include the node itself except for t
supposed to be the first seed node, and that should be placed first in parameter to supposed to be the first seed node, and that should be placed first in parameter to
``joinSeedNodes``. ``joinSeedNodes``.
Unsuccessful join attempts are automatically retried after the time period defined in Unsuccessful attempts to contact seed nodes are automatically retried after the time period defined in
configuration property ``retry-unsuccessful-join-after``. When using ``seed-nodes`` this configuration property ``seed-node-timeout``. Unsuccessful attempt to join a specific seed node is
means that a new seed node is picked. When joining manually or programatically this means automatically retried after the configured ``retry-unsuccessful-join-after`. Retrying means that it
that the last join request is retried. Retries can be disabled by setting the property to tries to contact all seed nodes and then joins the node that answers first. The first node in the list
``off``. of seed nodes will join itself if it cannot contact any of the other seed nodes within the
configured ``seed-node-timeout``.
An actor system can only join a cluster once. Additional attempts will be ignored. An actor system can only join a cluster once. Additional attempts will be ignored.
When it has successfully joined it must be restarted to be able to join another When it has successfully joined it must be restarted to be able to join another