From 3dabc6ae1f8627e6790ccc672a0b20acab1bac54 Mon Sep 17 00:00:00 2001 From: "Rodrigo Q. Saramago" Date: Sat, 16 Apr 2016 17:33:36 -0300 Subject: [PATCH] Rerun leader election for every new member --- src/main/scala/cfabcast/MembershipManager.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/scala/cfabcast/MembershipManager.scala b/src/main/scala/cfabcast/MembershipManager.scala index d1570a0..73e1c2a 100644 --- a/src/main/scala/cfabcast/MembershipManager.scala +++ b/src/main/scala/cfabcast/MembershipManager.scala @@ -24,7 +24,7 @@ class MembershipManager extends Actor with ActorLogging { val cluster = Cluster(context.system) val settings = Settings(context.system) - val waitFor = settings.MinNrOfNodes + val minNrOfNodes = settings.MinNrOfNodes val quorumSize = settings.QuorumSize // A Set of nodes(members) in the cluster that this node knows about @@ -88,13 +88,13 @@ class MembershipManager extends Actor with ActorLogging { context watch ref context.become(registering(actualConfig)) val refs = members.keySet - if (refs.size == waitFor) { + if (refs.size >= minNrOfNodes) { //TODO: Remove this from here implicit val timeout = Timeout(3 seconds) val futOfDones = refs.map(r => r ? UpdateConfig(actualConfig)) val allDone = Future.sequence(futOfDones).onComplete { // TODO: explicitly send to leaders ref - case Success(s) => leaderOracle ! MemberChange(actualConfig, actualConfig.proposers.values.toSet, waitFor) + case Success(s) => leaderOracle ! MemberChange(actualConfig, actualConfig.proposers.values.toSet, minNrOfNodes) case Failure(f) => log.error("Something goes wrong: {} ", f) } }