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

Method InitTopicID

phxqueue/lock/lock.cpp:513–560  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

511}
512
513comm::RetCode Lock::InitTopicID() {
514
515 if (!impl_->opt.topic.empty()) {
516 comm::RetCode ret{config::GlobalConfig::GetThreadInstance()->
517 GetTopicIDByTopicName(impl_->opt.topic, impl_->topic_id)};
518 if (comm::RetCode::RET_OK != ret) {
519 QLErr("GetTopicIDByTopicName ret %d topic %s",
520 as_integer(ret), impl_->opt.topic.c_str());
521 }
522
523 return ret;
524 }
525
526 QLInfo("find topic by addr %s:%d:%d", impl_->addr.ip().c_str(), impl_->addr.port(), impl_->addr.paxos_port());
527
528 set<int> topic_ids;
529 comm::RetCode ret{config::GlobalConfig::GetThreadInstance()->GetAllTopicID(topic_ids)};
530 if (comm::RetCode::RET_OK != ret) {
531 QLErr("GetAllTopicID ret %d", comm::as_integer(ret));
532
533 return ret;
534 }
535
536 QLInfo("topic_ids size %zu", topic_ids.size());
537
538 for (auto &&topic_id : topic_ids) {
539 QLInfo("check topic %d", topic_id);
540
541 shared_ptr<const config::LockConfig> lock_config;
542 comm::RetCode topic_ret{config::GlobalConfig::GetThreadInstance()->GetLockConfig(topic_id, lock_config)};
543 if (comm::RetCode::RET_OK != topic_ret) {
544 QLErr("GetLockConfig ret %d", comm::as_integer(topic_ret));
545
546 continue;
547 }
548
549 int lock_id{-1};
550 topic_ret = lock_config->GetLockIDByAddr(impl_->addr, lock_id);
551 if (comm::RetCode::RET_OK == topic_ret) {
552 QLInfo("found toipc %d addr %s:%d", topic_id, impl_->addr.ip().c_str(), impl_->addr.port());
553 impl_->topic_id = topic_id;
554
555 return comm::RetCode::RET_OK;
556 }
557 }
558
559 return comm::RetCode::RET_ERR_RANGE_ADDR;
560}
561
562
563} // namespace lock

Callers

nothing calls this directly

Calls 5

as_integerFunction · 0.85
GetTopicIDByTopicNameMethod · 0.80
GetAllTopicIDMethod · 0.80
GetLockConfigMethod · 0.80
GetLockIDByAddrMethod · 0.80

Tested by

no test coverage detected