class MMonElection : public Message {
- static const int HEAD_VERSION = 2;
+ static const int HEAD_VERSION = 3;
+ static const int COMPAT_VERSION = 2;
public:
static const int OP_PROPOSE = 1;
epoch_t epoch;
bufferlist monmap_bl;
set<int> quorum;
+ uint64_t quorum_features;
- MMonElection() : Message(MSG_MON_ELECTION, HEAD_VERSION) { }
- MMonElection(int o, epoch_t e, MonMap *m) :
- Message(MSG_MON_ELECTION, HEAD_VERSION),
- fsid(m->fsid), op(o), epoch(e) {
-
+ MMonElection() : Message(MSG_MON_ELECTION, HEAD_VERSION, COMPAT_VERSION) { }
+ MMonElection(int o, epoch_t e, MonMap *m)
+ : Message(MSG_MON_ELECTION, HEAD_VERSION, COMPAT_VERSION),
+ fsid(m->fsid), op(o), epoch(e), quorum_features(0) {
// encode using full feature set; we will reencode for dest later,
// if necessary
m->encode(monmap_bl, CEPH_FEATURES_ALL);
::encode(epoch, payload);
::encode(monmap_bl, payload);
::encode(quorum, payload);
+ ::encode(quorum_features, payload);
}
void decode_payload() {
bufferlist::iterator p = payload.begin();
::decode(epoch, p);
::decode(monmap_bl, p);
::decode(quorum, p);
+ if (header.version >= 3)
+ ::decode(quorum_features, p);
+ else
+ quorum_features = 0;
}
};
void Elector::handle_victory(MMonElection *m)
{
- dout(5) << "handle_victory from " << m->get_source() << dendl;
+ dout(5) << "handle_victory from " << m->get_source() << " quorum_features " << m->quorum_features << dendl;
int from = m->get_source().num();
assert(from < mon->rank);
bump_epoch(m->epoch);
// they win
- mon->lose_election(epoch, m->quorum, from);
+ mon->lose_election(epoch, m->quorum, from, m->quorum_features);
// cancel my timer
cancel_timer();
return elector.get_epoch();
}
-void Monitor::win_election(epoch_t epoch, set<int>& active, unsigned features)
+void Monitor::win_election(epoch_t epoch, set<int>& active, uint64_t features)
{
if (!is_electing())
reset();
finish_election();
}
-void Monitor::lose_election(epoch_t epoch, set<int> &q, int l)
+void Monitor::lose_election(epoch_t epoch, set<int> &q, int l, uint64_t features)
{
state = STATE_PEON;
leader_since = utime_t();
leader = l;
quorum = q;
outside_quorum.clear();
- quorum_features = 0;
+ quorum_features = features;
dout(10) << "lose_election, epoch " << epoch << " leader is mon" << leader
- << " quorum is " << quorum << dendl;
+ << " quorum is " << quorum << " features are " << quorum_features << dendl;
for (vector<Paxos*>::iterator p = paxos.begin(); p != paxos.end(); p++)
(*p)->peon_init();
void start_election();
void win_standalone_election();
void win_election(epoch_t epoch, set<int>& q,
- unsigned features); // end election (called by Elector)
- void lose_election(epoch_t epoch, set<int>& q, int l); // end election (called by Elector)
+ uint64_t features); // end election (called by Elector)
+ void lose_election(epoch_t epoch, set<int>& q, int l,
+ uint64_t features); // end election (called by Elector)
void finish_election();
void update_logger();