| 6965 | } |
| 6966 | |
| 6967 | std::shared_ptr<Task> NameServerImpl::CreateLoadTableTask(const std::string& endpoint, uint64_t op_index, |
| 6968 | ::fedb::api::OPType op_type, const std::string& name, |
| 6969 | uint32_t tid, uint32_t pid, uint32_t seg_cnt, |
| 6970 | bool is_leader) { |
| 6971 | std::shared_ptr<Task> task = std::make_shared<Task>(endpoint, std::make_shared<::fedb::api::TaskInfo>()); |
| 6972 | auto it = tablets_.find(endpoint); |
| 6973 | if (it == tablets_.end() || it->second->state_ != ::fedb::api::TabletState::kTabletHealthy) { |
| 6974 | return std::shared_ptr<Task>(); |
| 6975 | } |
| 6976 | task->task_info_->set_op_id(op_index); |
| 6977 | task->task_info_->set_op_type(op_type); |
| 6978 | task->task_info_->set_task_type(::fedb::api::TaskType::kLoadTable); |
| 6979 | task->task_info_->set_status(::fedb::api::TaskStatus::kInited); |
| 6980 | task->task_info_->set_endpoint(endpoint); |
| 6981 | |
| 6982 | ::fedb::api::TableMeta table_meta; |
| 6983 | table_meta.set_name(name); |
| 6984 | table_meta.set_tid(tid); |
| 6985 | table_meta.set_pid(pid); |
| 6986 | table_meta.set_seg_cnt(seg_cnt); |
| 6987 | if (is_leader) { |
| 6988 | table_meta.set_mode(::fedb::api::TableMode::kTableLeader); |
| 6989 | } else { |
| 6990 | table_meta.set_mode(::fedb::api::TableMode::kTableFollower); |
| 6991 | } |
| 6992 | boost::function<bool()> fun = |
| 6993 | boost::bind(&TabletClient::LoadTable, it->second->client_, table_meta, task->task_info_); |
| 6994 | task->fun_ = boost::bind(&NameServerImpl::WrapTaskFun, this, fun, task->task_info_); |
| 6995 | return task; |
| 6996 | } |
| 6997 | |
| 6998 | std::shared_ptr<Task> NameServerImpl::CreateLoadTableRemoteTask(const std::string& alias, const std::string& name, |
| 6999 | const std::string& db, const std::string& endpoint, |
nothing calls this directly
no outgoing calls
no test coverage detected