Start heartbeatSender after Welcome, see #3388

* Otherwise, if the Welcome message is lost, other nodes
  in the cluster will send HeartbeatRequest and it will start
  sending heartbeats without being a real member and the lost Welcome
  is not detected by the other members in the cluster
This commit is contained in:
Patrik Nordwall 2013-05-24 15:38:24 +02:00
parent beed693c1b
commit ec1626b746

View file

@ -241,9 +241,6 @@ private[cluster] final class ClusterCoreDaemon(publisher: ActorRef) extends Acto
private def clusterCore(address: Address): ActorSelection =
context.actorSelection(RootActorPath(address) / "system" / "cluster" / "core" / "daemon")
context.actorOf(Props[ClusterHeartbeatSender].
withDispatcher(UseDispatcher), name = "heartbeatSender")
import context.dispatcher
// start periodic gossip to random nodes in cluster
@ -304,6 +301,14 @@ private[cluster] final class ClusterCoreDaemon(publisher: ActorRef) extends Acto
}
}
def becomeInitialized(): Unit = {
// start heartbeatSender here, and not in constructor to make sure that
// heartbeating doesn't start before Welcome is received
context.actorOf(Props[ClusterHeartbeatSender].
withDispatcher(UseDispatcher), name = "heartbeatSender")
context.become(initialized)
}
def initialized: Actor.Receive = {
case msg: GossipEnvelope receiveGossip(msg)
case msg: GossipStatus receiveGossipStatus(msg)
@ -384,7 +389,7 @@ private[cluster] final class ClusterCoreDaemon(publisher: ActorRef) extends Acto
}
if (address == selfAddress) {
context.become(initialized)
becomeInitialized()
joining(selfUniqueAddress, cluster.selfRoles)
} else {
val joinDeadline = RetryUnsuccessfulJoinAfter match {
@ -457,7 +462,7 @@ private[cluster] final class ClusterCoreDaemon(publisher: ActorRef) extends Acto
publish(latestGossip)
if (from != selfUniqueAddress)
gossipTo(from, sender)
context.become(initialized)
becomeInitialized()
}
}