virtual void _start() = 0;
virtual void _defer_to(int who) = 0;
virtual void message_victory(const set<int>& quorum) = 0;
- virtual bool is_current_member(int rank) = 0;
+ virtual bool is_current_member(int ) = 0;
virtual ~ElectionOwner() {}
};
class ElectionLogic {
-public:
ElectionOwner *elector;
CephContext *cct;
epoch_t epoch = 0;
+ int leader_acked;
+public:
bool participating;
bool electing_me;
set<int> acked_me;
- int leader_acked;
ElectionLogic(ElectionOwner *e, CephContext *c) : elector(e), cct(c),
+ leader_acked(-1),
participating(true),
- electing_me(false), leader_acked(-1) {}
+ electing_me(false) {}
void declare_standalone_victory();
void start();
- void defer(int who);
void end_election_period();
void receive_propose(epoch_t mepoch, int from);
void receive_ack(int from, epoch_t from_epoch);
bool receive_victory_claim(int from, epoch_t from_epoch);
+ epoch_t get_epoch() { return epoch; }
private:
void init();
void bump_epoch(epoch_t e);
+ void defer(int who);
void declare_victory();
};
void Elector::_defer_to(int who)
{
- MMonElection *m = new MMonElection(MMonElection::OP_ACK, logic.epoch, mon->monmap);
+ MMonElection *m = new MMonElection(MMonElection::OP_ACK, get_epoch(), mon->monmap);
m->mon_features = ceph::features::mon::get_supported();
m->mon_release = ceph_release();
mon->collect_metadata(&m->metadata);
p != quorum.end();
++p) {
if (*p == mon->rank) continue;
- MMonElection *m = new MMonElection(MMonElection::OP_VICTORY, logic.epoch,
+ MMonElection *m = new MMonElection(MMonElection::OP_VICTORY, get_epoch(),
mon->monmap);
m->quorum = quorum;
m->quorum_features = cluster_features;
}
// tell monitor
- mon->win_election(logic.epoch, quorum,
+ mon->win_election(get_epoch(), quorum,
cluster_features, mon_features, min_mon_release,
metadata);
}
dout(5) << "handle_ack from " << m->get_source() << dendl;
int from = m->get_source().num();
- ceph_assert(m->epoch == logic.epoch);
+ ceph_assert(m->epoch == get_epoch());
uint64_t required_features = mon->get_required_features();
if ((required_features ^ m->get_connection()->get_features()) &
required_features) {
return;
}
- mon->lose_election(logic.epoch, m->quorum, from,
+ mon->lose_election(get_epoch(), m->quorum, from,
m->quorum_features, m->mon_features, m->mon_release);
// cancel my timer
return;
}
- if (em->epoch < logic.epoch) {
+ if (em->epoch < get_epoch()) {
dout(5) << "old epoch, dropping" << dendl;
break;
}