| 9563 | } |
| 9564 | |
| 9565 | std::shared_ptr<Task> NameServerImpl::CreateAddIndexToTabletTask(uint64_t op_index, ::fedb::api::OPType op_type, |
| 9566 | uint32_t tid, uint32_t pid, |
| 9567 | const std::vector<std::string>& endpoints, |
| 9568 | const ::fedb::common::ColumnKey& column_key) { |
| 9569 | std::shared_ptr<Task> task = std::make_shared<Task>("", std::make_shared<::fedb::api::TaskInfo>()); |
| 9570 | for (const auto& endpoint : endpoints) { |
| 9571 | std::shared_ptr<TabletInfo> tablet = GetHealthTabletInfoNoLock(endpoint); |
| 9572 | if (!tablet) { |
| 9573 | return std::shared_ptr<Task>(); |
| 9574 | } |
| 9575 | std::shared_ptr<Task> sub_task = std::make_shared<Task>(endpoint, std::make_shared<::fedb::api::TaskInfo>()); |
| 9576 | sub_task->task_info_->set_op_id(op_index); |
| 9577 | sub_task->task_info_->set_op_type(op_type); |
| 9578 | sub_task->task_info_->set_task_type(::fedb::api::TaskType::kAddIndexToTablet); |
| 9579 | sub_task->task_info_->set_status(::fedb::api::TaskStatus::kInited); |
| 9580 | boost::function<bool()> fun = |
| 9581 | boost::bind(&TabletClient::AddIndex, tablet->client_, tid, pid, column_key, sub_task->task_info_); |
| 9582 | sub_task->fun_ = boost::bind(&NameServerImpl::WrapTaskFun, this, fun, sub_task->task_info_); |
| 9583 | task->sub_task_.push_back(sub_task); |
| 9584 | PDLOG(INFO, |
| 9585 | "add subtask AddIndexToTablet. op_id[%lu] tid[%u] pid[%u] " |
| 9586 | "endpoint[%s]", |
| 9587 | op_index, tid, pid, endpoint.c_str()); |
| 9588 | } |
| 9589 | task->task_info_->set_op_id(op_index); |
| 9590 | task->task_info_->set_op_type(op_type); |
| 9591 | task->task_info_->set_task_type(::fedb::api::TaskType::kAddIndexToTablet); |
| 9592 | task->task_info_->set_status(::fedb::api::TaskStatus::kInited); |
| 9593 | task->fun_ = boost::bind(&NameServerImpl::RunSubTask, this, task); |
| 9594 | return task; |
| 9595 | } |
| 9596 | |
| 9597 | void NameServerImpl::CreateDatabase(RpcController* controller, const CreateDatabaseRequest* request, |
| 9598 | GeneralResponse* response, Closure* done) { |
nothing calls this directly
no outgoing calls
no test coverage detected