| 69 | } |
| 70 | |
| 71 | comm::RetCode Store::InitTopicID() { |
| 72 | comm::RetCode ret; |
| 73 | |
| 74 | if (!impl_->opt.topic.empty()) { |
| 75 | if (comm::RetCode::RET_OK != |
| 76 | (ret = config::GlobalConfig::GetThreadInstance()-> |
| 77 | GetTopicIDByTopicName(impl_->opt.topic, impl_->topic_id))) { |
| 78 | QLErr("GetTopicIDByTopicName ret %d topic %s", |
| 79 | as_integer(ret), impl_->opt.topic.c_str()); |
| 80 | } |
| 81 | return ret; |
| 82 | } |
| 83 | |
| 84 | QLInfo("no topic name. find toipc_id by addr(%s:%d)", |
| 85 | impl_->addr.ip().c_str(), impl_->addr.port()); |
| 86 | |
| 87 | set<int> topic_ids; |
| 88 | if (comm::RetCode::RET_OK != |
| 89 | (ret = config::GlobalConfig::GetThreadInstance()->GetAllTopicID(topic_ids))) { |
| 90 | QLErr("GetAllTopicID ret %d", as_integer(ret)); |
| 91 | return ret; |
| 92 | } |
| 93 | |
| 94 | for (auto &&topic_id : topic_ids) { |
| 95 | |
| 96 | QLVerb("check topic_id %d", topic_id); |
| 97 | |
| 98 | shared_ptr<const config::StoreConfig> store_config; |
| 99 | if (comm::RetCode::RET_OK != |
| 100 | (ret = config::GlobalConfig::GetThreadInstance()-> |
| 101 | GetStoreConfig(topic_id, store_config))) { |
| 102 | QLErr("GetStoreConfig ret %d", as_integer(ret)); |
| 103 | continue; |
| 104 | } |
| 105 | |
| 106 | int store_id; |
| 107 | if (comm::RetCode::RET_OK == |
| 108 | (ret = store_config->GetStoreIDByAddr(impl_->addr, store_id))) { |
| 109 | QLInfo("found toipc_id %d addr (%s:%d)", |
| 110 | topic_id, impl_->addr.ip().c_str(), impl_->addr.port()); |
| 111 | impl_->topic_id = topic_id; |
| 112 | return comm::RetCode::RET_OK; |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | return comm::RetCode::RET_ERR_RANGE_ADDR; |
| 117 | } |
| 118 | |
| 119 | comm::RetCode Store::Init() { |
| 120 | comm::RetCode ret; |
nothing calls this directly
no test coverage detected