| 76 | |
| 77 | |
| 78 | comm::RetCode StoreConfig::Rebuild() { |
| 79 | bool need_check = NeedCheck(); |
| 80 | |
| 81 | QLVerb("start"); |
| 82 | |
| 83 | impl_->store_id2store.clear(); |
| 84 | impl_->addr2store_id.clear(); |
| 85 | |
| 86 | auto &&proto = GetProto(); |
| 87 | |
| 88 | for (int i{0}; i < proto.stores_size(); ++i) { |
| 89 | const auto &store(proto.stores(i)); |
| 90 | if (!store.store_id()) continue; |
| 91 | if (need_check) PHX_ASSERT(impl_->store_id2store.end() == impl_->store_id2store.find(store.store_id()), ==, true); |
| 92 | impl_->store_id2store.emplace(store.store_id(), make_shared<proto::Store>(store)); |
| 93 | |
| 94 | for (int j{0}; j < store.addrs_size(); ++j) { |
| 95 | auto &&addr = store.addrs(j); |
| 96 | if (need_check) PHX_ASSERT(impl_->addr2store_id.end() == impl_->addr2store_id.find(comm::utils::EncodeAddr(addr)), ==, true); |
| 97 | impl_->addr2store_id.emplace(comm::utils::EncodeAddr(addr), store.store_id()); |
| 98 | QLVerb("add addr(%s:%d:%d) store_id %d", addr.ip().c_str(), addr.port(), addr.paxos_port(), store.store_id()); |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | return comm::RetCode::RET_OK; |
| 103 | } |
| 104 | |
| 105 | |
| 106 | comm::RetCode StoreConfig::GetAllStore(std::vector<shared_ptr<const proto::Store>> &stores) const { |
nothing calls this directly
no test coverage detected