void notify_rank_removed(int rank_removed);
void notify_strategy_maybe_changed(int strategy);
/**
- * Set the disallowed leaders. This has no effect
- * if the disallowed set is identical; if it differs
- * we call an election.
+ * Set the disallowed leaders.
+ *
+ * If you call this and the new disallowed set
+ * contains your current leader, you are
+ * responsible for calling an election!
+ *
+ * @returns false if the set is unchanged,
+ * true if the set changed
*/
- void set_disallowed_leaders(const set<int>& dl) {
- if (dl == disallowed_leaders) return;
+ bool set_disallowed_leaders(const set<int>& dl) {
+ if (dl == disallowed_leaders) return false;
disallowed_leaders = dl;
- call_election();
+ return true;
}
void dump_connection_scores(Formatter *f) {
f->open_object_section("connection scores");
dout(10) << "bootstrap -- finished compaction" << dendl;
}
+ // stretch mode bits
+ set_elector_disallowed_leaders(false);
+
// singleton monitor?
if (monmap->size() == 1 && rank == 0) {
win_standalone_election();
f->close_section();
f->dump_object("feature_map", session_map.feature_map);
+ f->dump_bool("stretch_mode", stretch_mode_engaged);
f->close_section(); // mon_status
}
maybe_engage_stretch_mode();
}
+ if (is_stretch_mode()) {
+ if (!monmap->stretch_marked_down_mons.empty()) {
+ set_degraded_stretch_mode();
+ }
+ }
+ set_elector_disallowed_leaders(true);
+}
+
+void Monitor::set_elector_disallowed_leaders(bool allow_election)
+{
set<int> dl;
for (auto name : monmap->disallowed_leaders) {
dl.insert(monmap->get_rank(name));
for (auto name : monmap->stretch_marked_down_mons) {
dl.insert(monmap->get_rank(name));
}
- if (!monmap->stretch_marked_down_mons.empty()) {
- set_degraded_stretch_mode();
- }
dl.insert(monmap->get_rank(monmap->tiebreaker_mon));
}
- elector.set_disallowed_leaders(dl);
+
+ bool disallowed_changed = elector.set_disallowed_leaders(dl);
+ if (disallowed_changed && allow_election) {
+ elector.call_election();
+ }
}
struct CMonEnableStretchMode : public Context {
bool session_stretch_allowed(MonSession *s, MonOpRequestRef& op);
void disconnect_disallowed_stretch_sessions();
+ void set_elector_disallowed_leaders(bool allow_election);
public:
bool is_stretch_mode() { return stretch_mode_engaged; }
bool is_degraded_stretch_mode() { return degraded_stretch_mode; }