Fix bugs, see #2311

This commit is contained in:
Patrik Nordwall 2012-07-04 16:09:01 +02:00
parent 9368475512
commit c1d12550a4
2 changed files with 8 additions and 5 deletions

View file

@ -795,7 +795,6 @@ private[cluster] final class ClusterCore(cluster: Cluster) extends Actor with Ac
latestGossip = seenVersionedGossip
log.info("Cluster Node [{}] - Marked address [{}] as LEAVING", selfAddress, address)
publishState()
notifyListeners(localGossip)
}
}
@ -819,7 +818,11 @@ private[cluster] final class ClusterCore(cluster: Cluster) extends Actor with Ac
*/
def removing(address: Address): Unit = {
log.info("Cluster Node [{}] - Node has been REMOVED by the leader - shutting down...", selfAddress)
publishState()
val localGossip = latestGossip
// just cleaning up the gossip state
latestGossip = Gossip()
// make sure the final (removed) state is always published
notifyListeners(localGossip)
cluster.shutdown()
}
@ -1309,7 +1312,7 @@ private[cluster] final class ClusterCore(cluster: Cluster) extends Actor with Ac
}
def notifyListeners(oldGossip: Gossip): Unit = {
if (PublishStateInterval == Duration.Zero) publishState
if (PublishStateInterval == Duration.Zero) publishState()
val oldMembersStatus = oldGossip.members.map(m (m.address, m.status))
val newMembersStatus = latestGossip.members.map(m (m.address, m.status))

View file

@ -38,7 +38,7 @@ abstract class NodeUpSpec
"be unaffected when joining again" taggedAs LongRunningTest in {
val unexpected = new AtomicReference[SortedSet[Member]]
val unexpected = new AtomicReference[SortedSet[Member]](SortedSet.empty)
cluster.registerListener(new MembershipChangeListener {
def notify(members: SortedSet[Member]) {
if (members.size != 2 || members.exists(_.status != MemberStatus.Up))
@ -55,7 +55,7 @@ abstract class NodeUpSpec
// let it run for a while to make sure that nothing bad happens
for (n 1 to 20) {
100.millis.dilated.sleep()
unexpected.get must be(null)
unexpected.get must be(SortedSet.empty)
cluster.latestGossip.members.forall(_.status == MemberStatus.Up) must be(true)
}