p != quorum.end();
++p) {
if (*p == whoami) continue;
- mon->messenger->send_message(new MMonElection(MMonElection::OP_VICTORY, epoch, mon->monmap),
- mon->monmap->get_inst(*p));
+ MMonElection *m = new MMonElection(MMonElection::OP_VICTORY, epoch, mon->monmap);
+ m->quorum = quorum;
+ mon->messenger->send_message(m, mon->monmap->get_inst(*p));
}
// tell monitor
if (m->epoch > epoch) {
bump_epoch(m->epoch);
}
- else if (m->epoch < epoch && // got an "old" propose,
- epoch % 2 == 0 && // in a non-election cycle
- mon->quorum.count(from) == 0) { // from someone outside the quorum
- // a mon just started up, call a new election so they can rejoin!
- dout(5) << " got propose from old epoch, " << m->get_source() << " must have just started" << dendl;
- start();
+ else if (m->epoch < epoch) {
+ // got an "old" propose,
+ if (epoch % 2 == 0 && // in a non-election cycle
+ mon->quorum.count(from) == 0) { // from someone outside the quorum
+ // a mon just started up, call a new election so they can rejoin!
+ dout(5) << " got propose from old epoch, quorum is " << mon->quorum
+ << ", " << m->get_source() << " must have just started" << dendl;
+ start();
+ } else {
+ dout(5) << " ignoring old propose" << dendl;
+ delete m;
+ return;
+ }
}
if (whoami < from) {
bump_epoch(m->epoch);
// they win
- mon->lose_election(epoch, from);
+ mon->lose_election(epoch, m->quorum, from);
// cancel my timer
cancel_timer();
clientmon->election_finished();
}
-void Monitor::lose_election(epoch_t epoch, int l)
+void Monitor::lose_election(epoch_t epoch, set<int> &q, int l)
{
state = STATE_PEON;
mon_epoch = epoch;
leader = l;
- dout(10) << "lose_election, epoch " << mon_epoch << " leader is mon" << leader << dendl;
+ quorum = q;
+ dout(10) << "lose_election, epoch " << mon_epoch << " leader is mon" << leader
+ << " quorum is " << quorum << dendl;
// init paxos
paxos_mdsmap.peon_init();
case PAXOS_CLIENTMAP:
paxos_clientmap.dispatch(m);
break;
+ case PAXOS_PGMAP:
+ paxos_pgmap.dispatch(m);
+ break;
default:
assert(0);
}
}
void call_election(); // initiate election
- void win_election(epoch_t epoch, set<int>& q); // end election (called by Elector)
- void lose_election(epoch_t epoch, int l); // end election (called by Elector)
+ void win_election(epoch_t epoch, set<int>& q); // end election (called by Elector)
+ void lose_election(epoch_t epoch, set<int>& q, int l); // end election (called by Elector)
// -- paxos --