| 395 | |
| 396 | |
| 397 | comm::RetCode BaseMgr::GetItemsByCursorID(const int queue_id, const uint64_t cursor_id, |
| 398 | vector<comm::proto::QItem> &items) { |
| 399 | items.clear(); |
| 400 | |
| 401 | const int paxos_group_id(queue_id % impl_->store->GetStoreOption()->ngroup); |
| 402 | |
| 403 | |
| 404 | std::vector<std::pair<std::string, int>> values; |
| 405 | int paxos_ret = impl_->store->GetNode()->GetInstanceValue(paxos_group_id, cursor_id, values); |
| 406 | if (phxpaxos::Paxos_GetInstanceValue_Value_Not_Chosen_Yet == paxos_ret) { |
| 407 | return comm::RetCode::RET_ERR_PAXOS_NOT_CHOSEN; |
| 408 | } else if (phxpaxos::Paxos_GetInstanceValue_Value_NotExist == paxos_ret) { |
| 409 | QLWarn("GetInstanceValue not exist paxos_group_id %d cursor_id %" PRIu64, |
| 410 | paxos_group_id, cursor_id); |
| 411 | return comm::RetCode::RET_OK; |
| 412 | } else if (0 != paxos_ret) { |
| 413 | QLErr("GetInstanceValue paxos_ret %d paxos_group_id %d cursor_id %" PRIu64, |
| 414 | paxos_ret, paxos_group_id, cursor_id); |
| 415 | return comm::RetCode::RET_ERR_PAXOS_GET_INSTANCE_VALUE; |
| 416 | } |
| 417 | |
| 418 | for (auto &&value : values) { |
| 419 | QLVerb("value.length() %zu", value.first.length()); |
| 420 | if (value.second != StoreSM::ID) continue; |
| 421 | |
| 422 | proto::StorePaxosArgs args; |
| 423 | if (!args.ParseFromString(value.first)) { |
| 424 | QLErr("ParseFromString fail"); |
| 425 | return comm::RetCode::RET_ERR_PAXOS_VALUE_PARSE; |
| 426 | } |
| 427 | |
| 428 | if (!args.add_req().items_size()) continue; |
| 429 | if (queue_id != args.add_req().queue_id()) continue; |
| 430 | |
| 431 | for (size_t i{0}; i < args.add_req().items_size(); ++i) { |
| 432 | items.push_back(args.add_req().items(i)); |
| 433 | items.back().set_cursor_id(cursor_id); |
| 434 | QLVerb("add item. topic_id %d uin %" PRIu64, |
| 435 | args.add_req().items(i).meta().topic_id(), |
| 436 | args.add_req().items(i).meta().uin()); |
| 437 | QLVerb("back item. topic_id %d uin %" PRIu64, |
| 438 | items.back().meta().topic_id(), items.back().meta().uin()); |
| 439 | } |
| 440 | } |
| 441 | |
| 442 | return comm::RetCode::RET_OK; |
| 443 | } |
| 444 | |
| 445 | StoreMetaQueue *BaseMgr::GetMetaQueue(const int queue_id) { |
| 446 | if (queue_id >= impl_->store->GetStoreOption()->nqueue) { |
nothing calls this directly
no test coverage detected