assert(epoch % 2 == 1); // election
bump_epoch(epoch+1); // is over!
+
+ // calculate my supported commands for peons to advertise
+ if (!my_supported_commands.length()) {
+ const MonCommand *cmds;
+ int cmdsize;
+ get_locally_supported_monitor_commands(&cmds, &cmdsize);
+ MonCommand::encode_array(cmds, cmdsize, my_supported_commands);
+ }
- // tell everyone
+ // tell everyone!
for (set<int>::iterator p = quorum.begin();
p != quorum.end();
++p) {
MMonElection *m = new MMonElection(MMonElection::OP_VICTORY, epoch, mon->monmap);
m->quorum = quorum;
m->quorum_features = features;
+ m->commands = my_supported_commands;
mon->messenger->send_message(m, mon->monmap->get_inst(*p));
}
mon->lose_election(epoch, m->quorum, from, m->quorum_features);
// cancel my timer
- cancel_timer();
+ cancel_timer();
+
+ // stash leader's commands
+ if (m->commands.length()) {
+ MonCommand *new_cmds;
+ int cmdsize;
+ bufferlist::iterator bi = m->commands.begin();
+ MonCommand::decode_array(&new_cmds, &cmdsize, bi);
+ set_leader_supported_commands(new_cmds, cmdsize);
+ } else { // they are a legacy monitor; use known legacy command set
+ // TODO: actually store legacy command set, and use here!
+ }
+
m->put();
}
clog.info() << "mon." << name << "@" << rank
<< " won leader election with quorum " << quorum << "\n";
+ const MonCommand *new_cmds;
+ int cmdsize;
+ get_locally_supported_monitor_commands(&new_cmds, &cmdsize);
+ set_leader_supported_commands(new_cmds, cmdsize);
+
paxos->leader_init();
for (vector<PaxosService*>::iterator p = paxos_service.begin(); p != paxos_service.end(); ++p)
(*p)->election_finished();