| 626 | } |
| 627 | |
| 628 | comm::RetCode HeartBeatLock::DoLock(const int vpid, Queue_t *const queue) { |
| 629 | |
| 630 | comm::RetCode ret; |
| 631 | |
| 632 | auto &&opt = impl_->consumer->GetConsumerOption(); |
| 633 | |
| 634 | auto topic_id = impl_->consumer->GetTopicID(); |
| 635 | |
| 636 | if (LOCK_ITEM_MAGIC != queue->magic) { |
| 637 | comm::ConsumerHeartBeatLockBP::GetThreadInstance()->OnNoLockTarget(topic_id); |
| 638 | return comm::RetCode::RET_NO_LOCK_TARGET; |
| 639 | } |
| 640 | |
| 641 | shared_ptr<const config::TopicConfig> topic_config; |
| 642 | if (comm::RetCode::RET_OK != (ret = config::GlobalConfig::GetThreadInstance()->GetTopicConfigByTopicID(topic_id, topic_config))) { |
| 643 | QLErr("ERR: GetTopicConfigByTopicID ret %d topic_id %u", comm::as_integer(ret), topic_id); |
| 644 | return ret; |
| 645 | } |
| 646 | |
| 647 | shared_ptr<const config::proto::Sub> sub; |
| 648 | if (comm::RetCode::RET_OK != (ret = topic_config->GetSubBySubID(queue->sub_id, sub))) { |
| 649 | QLErr("ERR: GetSubBySubID ret %d sub_id %u", comm::as_integer(ret), queue->sub_id); |
| 650 | return ret; |
| 651 | } |
| 652 | |
| 653 | if (sub->skip_lock()) { |
| 654 | comm::ConsumerHeartBeatLockBP::GetThreadInstance()->OnSkipLock(topic_id, sub->sub_id()); |
| 655 | return comm::RetCode::RET_OK; |
| 656 | } |
| 657 | |
| 658 | shared_ptr<const config::LockConfig> lock_config; |
| 659 | if (comm::RetCode::RET_OK != (ret = config::GlobalConfig::GetThreadInstance()->GetLockConfig(topic_id, lock_config))) { |
| 660 | QLErr("ERR: GetLockConfig ret %d topic_id %u", comm::as_integer(ret), topic_id); |
| 661 | return ret; |
| 662 | } |
| 663 | |
| 664 | set<int> lock_ids; |
| 665 | if (comm::RetCode::RET_OK != (ret = lock_config->GetAllLockID(lock_ids))) { |
| 666 | QLErr("ERR: GetAllLockID ret %d", comm::as_integer(ret)); |
| 667 | return ret; |
| 668 | } |
| 669 | |
| 670 | if (lock_ids.empty()) { |
| 671 | QLErr("ERR: lock_ids empty"); |
| 672 | return comm::RetCode::RET_ERR_RANGE_LOCK; |
| 673 | } |
| 674 | |
| 675 | const int lock_id = *lock_ids.begin(); |
| 676 | |
| 677 | string lock_key; |
| 678 | { |
| 679 | ostringstream oss; |
| 680 | oss << topic_id << "-" << queue->sub_id << "-" << queue->store_id << "-" << queue->queue_id; |
| 681 | lock_key = oss.str(); |
| 682 | } |
| 683 | |
| 684 | string client_id; |
| 685 | { |
nothing calls this directly
no test coverage detected