| 3997 | } |
| 3998 | |
| 3999 | int TabletImpl::AddOPMultiTask( |
| 4000 | const ::fedb::api::TaskInfo& task_info, ::fedb::api::TaskType task_type, |
| 4001 | std::shared_ptr<::fedb::api::TaskInfo>& task_ptr) { |
| 4002 | std::lock_guard<std::mutex> lock(mu_); |
| 4003 | if (FindMultiTask(task_info)) { |
| 4004 | PDLOG(WARNING, "task is running. op_id[%lu] op_type[%s] task_type[%s]", |
| 4005 | task_info.op_id(), |
| 4006 | ::fedb::api::OPType_Name(task_info.op_type()).c_str(), |
| 4007 | ::fedb::api::TaskType_Name(task_info.task_type()).c_str()); |
| 4008 | return -1; |
| 4009 | } |
| 4010 | task_ptr.reset(task_info.New()); |
| 4011 | task_ptr->CopyFrom(task_info); |
| 4012 | task_ptr->set_status(::fedb::api::TaskStatus::kDoing); |
| 4013 | auto iter = task_map_.find(task_info.op_id()); |
| 4014 | if (iter == task_map_.end()) { |
| 4015 | task_map_.insert(std::make_pair( |
| 4016 | task_info.op_id(), |
| 4017 | std::list<std::shared_ptr<::fedb::api::TaskInfo>>())); |
| 4018 | } |
| 4019 | task_map_[task_info.op_id()].push_back(task_ptr); |
| 4020 | if (task_info.task_type() != task_type) { |
| 4021 | PDLOG(WARNING, "task type is not match. type is[%s]", |
| 4022 | ::fedb::api::TaskType_Name(task_info.task_type()).c_str()); |
| 4023 | task_ptr->set_status(::fedb::api::TaskStatus::kFailed); |
| 4024 | return -1; |
| 4025 | } |
| 4026 | return 0; |
| 4027 | } |
| 4028 | |
| 4029 | std::shared_ptr<::fedb::api::TaskInfo> TabletImpl::FindMultiTask( |
| 4030 | const ::fedb::api::TaskInfo& task_info) { |