| 6660 | } |
| 6661 | |
| 6662 | int NameServerImpl::CreateReLoadTableTask(std::shared_ptr<OPData> op_data) { |
| 6663 | std::string name = op_data->op_info_.name(); |
| 6664 | std::string db = op_data->op_info_.db(); |
| 6665 | uint32_t pid = op_data->op_info_.pid(); |
| 6666 | std::string endpoint = op_data->op_info_.data(); |
| 6667 | auto it = tablets_.find(endpoint); |
| 6668 | if (it == tablets_.end() || it->second->state_ != ::fedb::api::TabletState::kTabletHealthy) { |
| 6669 | PDLOG(WARNING, "tablet[%s] is not online", endpoint.c_str()); |
| 6670 | return -1; |
| 6671 | } |
| 6672 | std::shared_ptr<TableInfo> table_info; |
| 6673 | if (!GetTableInfoUnlock(name, db, &table_info)) { |
| 6674 | PDLOG(WARNING, "table[%s] is not exist!", name.c_str()); |
| 6675 | return -1; |
| 6676 | } |
| 6677 | uint32_t tid = table_info->tid(); |
| 6678 | uint32_t seg_cnt = table_info->seg_cnt(); |
| 6679 | std::shared_ptr<Task> task = |
| 6680 | CreateLoadTableTask(endpoint, op_data->op_info_.op_id(), ::fedb::api::OPType::kReLoadTableOP, name, tid, pid, |
| 6681 | seg_cnt, true); |
| 6682 | if (!task) { |
| 6683 | PDLOG(WARNING, "create loadtable task failed. tid[%u] pid[%u]", tid, pid); |
| 6684 | return -1; |
| 6685 | } |
| 6686 | op_data->task_list_.push_back(task); |
| 6687 | task = CreateUpdatePartitionStatusTask(name, db, pid, endpoint, true, true, op_data->op_info_.op_id(), |
| 6688 | ::fedb::api::OPType::kReLoadTableOP); |
| 6689 | if (!task) { |
| 6690 | PDLOG(WARNING, |
| 6691 | "create update table alive status task failed. table[%s] pid[%u] " |
| 6692 | "endpoint[%s]", |
| 6693 | name.c_str(), pid, endpoint.c_str()); |
| 6694 | return -1; |
| 6695 | } |
| 6696 | op_data->task_list_.push_back(task); |
| 6697 | PDLOG(INFO, "create ReLoadTable task ok. name[%s] pid[%u] endpoint[%s]", name.c_str(), pid, endpoint.c_str()); |
| 6698 | return 0; |
| 6699 | } |
| 6700 | |
| 6701 | int NameServerImpl::CreateUpdatePartitionStatusOP(const std::string& name, const std::string& db, uint32_t pid, |
| 6702 | const std::string& endpoint, bool is_leader, bool is_alive, |