| 6741 | } |
| 6742 | |
| 6743 | int NameServerImpl::CreateUpdatePartitionStatusOPTask(std::shared_ptr<OPData> op_data) { |
| 6744 | EndpointStatusData endpoint_status_data; |
| 6745 | if (!endpoint_status_data.ParseFromString(op_data->op_info_.data())) { |
| 6746 | PDLOG(WARNING, "parse endpont_status_data failed. data[%s]", op_data->op_info_.data().c_str()); |
| 6747 | return -1; |
| 6748 | } |
| 6749 | std::string name = op_data->op_info_.name(); |
| 6750 | std::string db = op_data->op_info_.db(); |
| 6751 | uint32_t pid = op_data->op_info_.pid(); |
| 6752 | std::string endpoint = endpoint_status_data.endpoint(); |
| 6753 | bool is_leader = endpoint_status_data.is_leader(); |
| 6754 | bool is_alive = endpoint_status_data.is_alive(); |
| 6755 | std::shared_ptr<::fedb::nameserver::TableInfo> table_info; |
| 6756 | if (!GetTableInfoUnlock(name, db, &table_info)) { |
| 6757 | PDLOG(WARNING, "table[%s] is not exist!", name.c_str()); |
| 6758 | return -1; |
| 6759 | } |
| 6760 | std::shared_ptr<Task> task = |
| 6761 | CreateUpdatePartitionStatusTask(name, db, pid, endpoint, is_leader, is_alive, op_data->op_info_.op_id(), |
| 6762 | ::fedb::api::OPType::kUpdatePartitionStatusOP); |
| 6763 | if (!task) { |
| 6764 | PDLOG(WARNING, |
| 6765 | "create update table alive status task failed. table[%s] pid[%u] " |
| 6766 | "endpoint[%s]", |
| 6767 | name.c_str(), pid, endpoint.c_str()); |
| 6768 | return -1; |
| 6769 | } |
| 6770 | op_data->task_list_.push_back(task); |
| 6771 | PDLOG(INFO, |
| 6772 | "create UpdatePartitionStatusOP task ok." |
| 6773 | "name[%s] pid[%u] endpoint[%s] is_leader[%d] is_alive[%d]", |
| 6774 | name.c_str(), pid, endpoint.c_str(), is_leader, is_alive); |
| 6775 | return 0; |
| 6776 | } |
| 6777 | |
| 6778 | int NameServerImpl::MatchTermOffset(const std::string& name, const std::string& db, uint32_t pid, bool has_table, |
| 6779 | uint64_t term, uint64_t offset) { |