MonitorDBStore::Transaction t;
t.put(Monitor::MONITOR_NAME, "election_epoch", epoch);
mon->store->apply_transaction(t);
- mon->reset();
+
+ mon->join_election();
// clear up some state
electing_me = false;
dout(5) << " got propose from old epoch, quorum is " << mon->quorum
<< ", " << m->get_source() << " must have just started" << dendl;
// we may be active; make sure we reset things in the monitor appropriately.
- mon->reset();
mon->start_election();
} else {
dout(5) << " ignoring old propose" << dendl;
} else {
// wait, i should win!
if (!electing_me) {
- mon->reset();
mon->start_election();
}
}
// reset
state = STATE_PROBING;
- reset();
+ _reset();
// sync store
if (g_conf->mon_compact_on_bootstrap) {
}
// called by bootstrap(), or on leader|peon -> electing
-void Monitor::reset()
+void Monitor::_reset()
{
- dout(10) << "reset" << dendl;
+ dout(10) << __func__ << dendl;
+
+ assert(state == STATE_ELECTING ||
+ state == STATE_PROBING);
cancel_probe_timeout();
timecheck_finish();
m->put();
}
+void Monitor::join_election()
+{
+ dout(10) << __func__ << dendl;
+ state = STATE_ELECTING;
+ _reset();
+}
+
void Monitor::start_election()
{
dout(10) << "start_election" << dendl;
+ state = STATE_ELECTING;
+ _reset();
cancel_probe_timeout();
- // call a new election
- state = STATE_ELECTING;
clog.info() << "mon." << name << " calling new monitor election\n";
elector.call_election();
}
void Monitor::win_election(epoch_t epoch, set<int>& active, uint64_t features)
{
- if (!is_electing())
- reset();
+ if (!is_electing()) {
+ state = STATE_ELECTING;
+ _reset();
+ }
state = STATE_LEADER;
leader_since = ceph_clock_now(g_ceph_context);
string quorumcmd;
cmd_getval(g_ceph_context, cmdmap, "quorumcmd", quorumcmd);
if (quorumcmd == "exit") {
- reset();
start_election();
elector.stop_participating();
rs = "stopped responding to quorum, initiated new election";
r = 0;
} else if (quorumcmd == "enter") {
elector.start_participating();
- reset();
start_election();
rs = "started responding to quorum, initiated new election";
r = 0;
return quorum_features;
}
+private:
+ void _reset(); ///< called from bootstrap, start_, or join_election
+public:
void bootstrap();
- void reset();
+ void join_election();
void start_election();
void win_standalone_election();
void win_election(epoch_t epoch, set<int>& q,