| 114 | } |
| 115 | |
| 116 | bool StreamingSourceManager::stopDatasetAndWait(DatasetId dataset_id, const QString& reason) { |
| 117 | auto it = sessions_.find(dataset_id); |
| 118 | if (it == sessions_.end()) { |
| 119 | return false; |
| 120 | } |
| 121 | |
| 122 | StreamingSession* sess = it->second.get(); |
| 123 | if (sess->runtime_host != nullptr) { |
| 124 | sess->runtime_host->requestStop(reason.toStdString()); |
| 125 | } |
| 126 | if (sess->worker != nullptr) { |
| 127 | sess->worker->wait(); |
| 128 | } |
| 129 | |
| 130 | QString stopped_reason = reason; |
| 131 | if (sess->runtime_host != nullptr && !sess->runtime_host->lastError().empty()) { |
| 132 | stopped_reason = QString::fromStdString(sess->runtime_host->lastError()); |
| 133 | } |
| 134 | |
| 135 | sessions_.erase(it); |
| 136 | for (const ObjectTopicId topic_id : secondary_object_store_->listTopics(dataset_id)) { |
| 137 | secondary_object_store_->removeTopic(topic_id); |
| 138 | } |
| 139 | secondary_data_engine_->removeDataset(dataset_id); |
| 140 | emit streamStopped(dataset_id, stopped_reason); |
| 141 | return true; |
| 142 | } |
| 143 | |
| 144 | void StreamingSourceManager::stopAllAndWait(const QString& reason) { |
| 145 | std::vector<DatasetId> dataset_ids; |
no test coverage detected