if (electing_me &&
acked_me.size() > (elector_paxos_size() / 2)) {
// i win
- elector->victory();
+ declare_victory();
} else {
// whoever i deferred to didn't declare victory quickly enough.
if (elector_ever_participated())
}
}
-void Elector::victory()
+
+void ElectionLogic::declare_victory()
+{
+ leader_acked = -1;
+ electing_me = false;
+
+ set<int> new_quorum;
+ new_quorum.swap(acked_me);
+
+ ceph_assert(epoch % 2 == 1); // election
+ bump_epoch(epoch+1); // is over!
+
+ elector->message_victory(new_quorum);
+}
+
+void Elector::message_victory(const set<int>& quorum)
{
- logic.leader_acked = -1;
- logic.electing_me = false;
uint64_t cluster_features = CEPH_FEATURES_ALL;
mon_feature_t mon_features = ceph::features::mon::get_supported();
- set<int> quorum;
map<int,Metadata> metadata;
ceph_release_t min_mon_release{ceph_release_t::unknown};
- for (auto id : logic.acked_me) {
- quorum.insert(id);
+ for (auto id : quorum) {
auto i = peer_info.find(id);
ceph_assert(i != peer_info.end());
auto& info = i->second;
cancel_timer();
- ceph_assert(logic.epoch % 2 == 1); // election
- logic.bump_epoch(logic.epoch+1); // is over!
// tell everyone!
for (set<int>::iterator p = quorum.begin();
// is that _everyone_?
if (logic.acked_me.size() == mon->monmap->size()) {
// if yes, shortcut to election finish
- victory();
+ logic.declare_victory();
}
} else {
// ignore, i'm deferring already.
void defer(int who);
void end_election_period();
void handle_propose_logic(epoch_t mepoch, int from);
+ void declare_victory();
private:
* @post We have a quorum, composed of the monitors that acked us
* @post We sent a message of type OP_VICTORY to each quorum member.
*/
- void victory();
-
+ void message_victory(const set<int>& quorum);
/**
* Handle a message from some other node proposing itself to become it
* the Leader.
}
}
-void Monitor::win_election(epoch_t epoch, set<int>& active, uint64_t features,
+void Monitor::win_election(epoch_t epoch, const set<int>& active, uint64_t features,
const mon_feature_t& mon_features,
ceph_release_t min_mon_release,
const map<int,Metadata>& metadata)
void start_election();
void win_standalone_election();
// end election (called by Elector)
- void win_election(epoch_t epoch, set<int>& q,
+ void win_election(epoch_t epoch, const set<int>& q,
uint64_t features,
const mon_feature_t& mon_features,
ceph_release_t min_mon_release,