MCPcopy Create free account
hub / github.com/ceph/ceph / dispatch

Method dispatch

src/mon/Elector.cc:676–779  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

674}
675
676void Elector::dispatch(MonOpRequestRef op)
677{
678 op->mark_event("elector:dispatch");
679 ceph_assert(op->is_type_election_or_ping());
680
681 switch (op->get_req()->get_type()) {
682
683 case MSG_MON_ELECTION:
684 {
685 if (!logic.participating) {
686 return;
687 }
688 if (op->get_req()->get_source().num() >= mon->monmap->size()) {
689 dout(5) << " ignoring bogus election message with bad mon rank "
690 << op->get_req()->get_source() << dendl;
691 return;
692 }
693
694 auto em = op->get_req<MMonElection>();
695 dout(20) << __func__ << " from: " << mon->monmap->get_rank(em->get_source_addr()) << dendl;
696 // assume an old message encoding would have matched
697 if (em->fsid != mon->monmap->fsid) {
698 dout(0) << " ignoring election msg fsid "
699 << em->fsid << " != " << mon->monmap->fsid << dendl;
700 return;
701 }
702
703 if (!mon->monmap->contains(em->get_source_addr())) {
704 dout(1) << "discarding election message: " << em->get_source_addr()
705 << " not in my monmap " << *mon->monmap << dendl;
706 return;
707 }
708
709 MonMap peermap;
710 peermap.decode(em->monmap_bl);
711 if (peermap.epoch > mon->monmap->epoch) {
712 dout(0) << em->get_source_inst() << " has newer monmap epoch " << peermap.epoch
713 << " > my epoch " << mon->monmap->epoch
714 << ", taking it"
715 << dendl;
716 mon->monmap->decode(em->monmap_bl);
717 auto t(std::make_shared<MonitorDBStore::Transaction>());
718 t->put("monmap", mon->monmap->epoch, em->monmap_bl);
719 t->put("monmap", "last_committed", mon->monmap->epoch);
720 mon->store->apply_transaction(t);
721 //mon->monmon()->paxos->stash_latest(mon->monmap->epoch, em->monmap_bl);
722 cancel_timer();
723 mon->notify_new_monmap(false);
724 mon->bootstrap();
725 return;
726 }
727 if (peermap.epoch < mon->monmap->epoch) {
728 dout(0) << em->get_source_inst() << " has older monmap epoch " << peermap.epoch
729 << " < my epoch " << mon->monmap->epoch
730 << dendl;
731 }
732
733 if (em->strategy != logic.strategy) {

Callers

nothing calls this directly

Calls 15

get_epochFunction · 0.85
mark_eventMethod · 0.80
get_source_addrMethod · 0.80
get_source_instMethod · 0.80
apply_transactionMethod · 0.80
notify_new_monmapMethod · 0.80
get_typeMethod · 0.45
get_reqMethod · 0.45
numMethod · 0.45
get_sourceMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected