MCPcopy Create free account
hub / github.com/Tencent/phxqueue / ProposeMaster

Method ProposeMaster

phxqueue/lock/keepmasterthread.cpp:404–433  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

402//}
403
404comm::RetCode KeepMasterThread::ProposeMaster(const int paxos_group_id,
405 const comm::proto::Addr addr) {
406 QLInfo("paxos_group_id %d try be master", paxos_group_id);
407
408 // 1. serialize paxos value
409 proto::LockPaxosArgs args;
410 args.mutable_master_addr()->CopyFrom(addr);
411
412 string buf;
413 args.SerializeToString(&buf);
414
415 // 2. send to paxos
416 LockContext lc;
417 phxpaxos::SMCtx sm_ctx(LockSM::ID, &lc);
418 uint64_t instance_id{0};
419 int paxos_ret{impl_->lock->GetNode()->Propose(paxos_group_id, buf, instance_id, &sm_ctx)};
420 const int topic_id{impl_->lock->GetTopicID()};
421 if (phxpaxos::PaxosTryCommitRet_OK != paxos_ret) {
422 QLErr("paxos_group_id %d Propose err %d buf.size %zu", paxos_group_id, paxos_ret, buf.size());
423 comm::LockKeepMasterThreadBP::GetThreadInstance()->
424 OnProposeMasterSucc(topic_id, paxos_group_id);
425 } else {
426 QLInfo("paxos_group_id %d Propose ok instance_id %" PRIu64 " buf.size %zu",
427 paxos_group_id, instance_id, buf.size());
428 comm::LockKeepMasterThreadBP::GetThreadInstance()->
429 OnProposeMasterErr(topic_id, paxos_group_id);
430 }
431
432 return comm::RetCode::RET_OK;
433}
434
435comm::RetCode KeepMasterThread::UpdatePaxosArgs() {
436 const int topic_id{impl_->lock->GetTopicID()};

Callers

nothing calls this directly

Calls 4

OnProposeMasterSuccMethod · 0.80
OnProposeMasterErrMethod · 0.80
GetNodeMethod · 0.45
GetTopicIDMethod · 0.45

Tested by

no test coverage detected