| 154 | } |
| 155 | |
| 156 | comm::RetCode BaseMgr::Get(const comm::proto::GetRequest &req, comm::proto::GetResponse &resp) { |
| 157 | comm::RetCode ret; |
| 158 | |
| 159 | const int topic_id = impl_->store->GetTopicID(); |
| 160 | |
| 161 | shared_ptr<const config::TopicConfig> topic_config; |
| 162 | if (comm::RetCode::RET_OK != (ret = config::GlobalConfig::GetThreadInstance()->GetTopicConfigByTopicID(topic_id, topic_config))) { |
| 163 | QLErr("GetTopicConfigByTopicID ret %d topic_id %d", as_integer(ret), topic_id); |
| 164 | return ret; |
| 165 | } |
| 166 | |
| 167 | shared_ptr<const config::proto::QueueInfo> queue_info; |
| 168 | if (comm::RetCode::RET_OK != (ret = topic_config->GetQueueInfoByQueue(req.queue_id(), queue_info))) { |
| 169 | QLErr("GetQueueInfoByQueue ret %d", as_integer(ret)); |
| 170 | return ret; |
| 171 | } |
| 172 | |
| 173 | comm::StoreBaseMgrBP::GetThreadInstance()->OnGet(req); |
| 174 | |
| 175 | if (req.queue_id() >= impl_->store->GetStoreOption()->nqueue) { |
| 176 | QLErr("queue_id %d invalid. nqueue %d", req.queue_id(), impl_->store->GetStoreOption()->nqueue); |
| 177 | return comm::RetCode::RET_ERR_RANGE_QUEUE; |
| 178 | } |
| 179 | |
| 180 | QLVerb("begin. req.prev_cursor_id %llu req.next_cursor_id %llu", req.prev_cursor_id(), req.next_cursor_id()); |
| 181 | |
| 182 | uint64_t cli_prev_cursor_id{req.prev_cursor_id()}; |
| 183 | uint64_t cli_next_cursor_id{req.next_cursor_id()}; |
| 184 | |
| 185 | StoreMetaQueue &meta_queue = impl_->meta_queues[req.queue_id()]; |
| 186 | |
| 187 | SyncCtrl *sync = impl_->store->GetSyncCtrl(); |
| 188 | |
| 189 | if (as_integer(ret = sync->AdjustNextCursorID(req.sub_id(), req.queue_id(), cli_prev_cursor_id, cli_next_cursor_id)) < 0) { |
| 190 | comm::StoreBaseMgrBP::GetThreadInstance()->OnAdjustNextCursorIDFail(req); |
| 191 | QLErr("AdjustCur failed sub_id %d queue_id %d", req.sub_id(), req.queue_id()); |
| 192 | return comm::RetCode::RET_ERR_GET_ADJUST_CURSOR_ID_FAIL; |
| 193 | } else if (as_integer(ret)) { |
| 194 | comm::StoreBaseMgrBP::GetThreadInstance()->OnCursorIDNotFound(req); |
| 195 | QLInfo("cursorid not found. ret %d sub_id %d queue_id %d", as_integer(ret), req.sub_id(), req.queue_id()); |
| 196 | cli_prev_cursor_id = cli_next_cursor_id = -1; |
| 197 | } |
| 198 | |
| 199 | if (cli_prev_cursor_id != req.prev_cursor_id() || cli_next_cursor_id != req.next_cursor_id()) { |
| 200 | comm::StoreBaseMgrBP::GetThreadInstance()->OnCursorIDChange(req); |
| 201 | QLInfo("AdjustCur sub_id %d queue_id %d prev_cursor_id %" PRIu64 |
| 202 | " -> %" PRIu64 " next_cursor_id %" PRIu64 " -> %" PRIu64, |
| 203 | req.sub_id(), req.queue_id(), |
| 204 | static_cast<uint64_t>(req.prev_cursor_id()), cli_prev_cursor_id, |
| 205 | static_cast<uint64_t>(req.next_cursor_id()), cli_next_cursor_id); |
| 206 | } |
| 207 | |
| 208 | // get cp |
| 209 | uint64_t cp = -1, min_instance_id = -1; |
| 210 | do { |
| 211 | const int paxos_group_id(req.queue_id() % impl_->store->GetStoreOption()->ngroup); |
| 212 | auto stat = impl_->store->GetCheckPointStatMgr()->GetCheckPointStat(paxos_group_id); |
| 213 | if (!stat) { |
nothing calls this directly
no test coverage detected