##// END OF EJS Templates
Implementation of automatic cancel for request that failed
perrinel -
r704:ff170594501a
parent child
Show More
@@ -55,11 +55,15 signals:
55 const SqpRange &dataRangeAcquired);
55 const SqpRange &dataRangeAcquired);
56
56
57 /**
57 /**
58 * @brief dataProvided send dataSeries under dateTime and that corresponds of the data
58 * @brief dataProvidedProgress notify the progression of the data identifier by acqIdentifier
59 * identified by identifier
60 */
59 */
61 void dataProvidedProgress(QUuid acqIdentifier, double progress);
60 void dataProvidedProgress(QUuid acqIdentifier, double progress);
62
61
62 /**
63 * @brief dataProvidedFailed notify that data acquisition has failed
64 */
65 void dataProvidedFailed(QUuid acqIdentifier);
66
63
67
64 /**
68 /**
65 * @brief requestConstructed send a request for the data identified by acqIdentifier
69 * @brief requestConstructed send a request for the data identified by acqIdentifier
@@ -43,10 +43,15 signals:
43
43
44 void variableRequestInProgress(QUuid vIdentifier, double progress);
44 void variableRequestInProgress(QUuid vIdentifier, double progress);
45
45
46
47 void variableCanceledRequested(QUuid vIdentifier);
48
49
46 public slots:
50 public slots:
47 void onVariableDataAcquired(QUuid acqIdentifier, std::shared_ptr<IDataSeries> dataSeries,
51 void onVariableDataAcquired(QUuid acqIdentifier, std::shared_ptr<IDataSeries> dataSeries,
48 SqpRange dataRangeAcquired);
52 SqpRange dataRangeAcquired);
49 void onVariableRetrieveDataInProgress(QUuid acqIdentifier, double progress);
53 void onVariableRetrieveDataInProgress(QUuid acqIdentifier, double progress);
54 void onVariableAcquisitionFailed(QUuid acqIdentifier);
50
55
51 private:
56 private:
52 void waitForFinish();
57 void waitForFinish();
@@ -106,6 +106,7 public slots:
106
106
107 /// Cancel the current request for the variable
107 /// Cancel the current request for the variable
108 void onAbortProgressRequested(std::shared_ptr<Variable> variable);
108 void onAbortProgressRequested(std::shared_ptr<Variable> variable);
109 void onAbortAcquisitionRequested(QUuid vIdentifier);
109
110
110 // synchronization group methods
111 // synchronization group methods
111 void onAddSynchronizationGroupId(QUuid synchronizationGroupId);
112 void onAddSynchronizationGroupId(QUuid synchronizationGroupId);
@@ -67,6 +67,7 QUuid VariableAcquisitionWorker::pushVariableRequest(QUuid varRequestId, QUuid v
67
67
68 // Request creation
68 // Request creation
69 auto acqRequest = AcquisitionRequest{};
69 auto acqRequest = AcquisitionRequest{};
70 qCInfo(LOG_VariableAcquisitionWorker()) << tr("TpushVariableRequest ") << vIdentifier;
70 acqRequest.m_VarRequestId = varRequestId;
71 acqRequest.m_VarRequestId = varRequestId;
71 acqRequest.m_vIdentifier = vIdentifier;
72 acqRequest.m_vIdentifier = vIdentifier;
72 acqRequest.m_DataProviderParameters = parameters;
73 acqRequest.m_DataProviderParameters = parameters;
@@ -157,7 +158,8 void VariableAcquisitionWorker::onVariableRetrieveDataInProgress(QUuid acqIdenti
157 auto finalProgression = currentAlreadyProgress + currentPartProgress;
158 auto finalProgression = currentAlreadyProgress + currentPartProgress;
158 emit variableRequestInProgress(aIdToARit->second.m_vIdentifier, finalProgression);
159 emit variableRequestInProgress(aIdToARit->second.m_vIdentifier, finalProgression);
159 qCDebug(LOG_VariableAcquisitionWorker())
160 qCDebug(LOG_VariableAcquisitionWorker())
160 << tr("TORM: onVariableRetrieveDataInProgress ") << aIdToARit->second.m_vIdentifier
161 << tr("TORM: onVariableRetrieveDataInProgress ")
162 << QThread::currentThread()->objectName() << aIdToARit->second.m_vIdentifier
161 << currentPartSize << currentAlreadyProgress << currentPartProgress << finalProgression;
163 << currentPartSize << currentAlreadyProgress << currentPartProgress << finalProgression;
162 if (finalProgression == 100.0) {
164 if (finalProgression == 100.0) {
163 emit variableRequestInProgress(aIdToARit->second.m_vIdentifier, 0.0);
165 emit variableRequestInProgress(aIdToARit->second.m_vIdentifier, 0.0);
@@ -166,6 +168,26 void VariableAcquisitionWorker::onVariableRetrieveDataInProgress(QUuid acqIdenti
166 impl->unlock();
168 impl->unlock();
167 }
169 }
168
170
171 void VariableAcquisitionWorker::onVariableAcquisitionFailed(QUuid acqIdentifier)
172 {
173 qCDebug(LOG_VariableAcquisitionWorker()) << tr("onVariableAcquisitionFailed")
174 << QThread::currentThread();
175 impl->lockRead();
176 auto it = impl->m_AcqIdentifierToAcqRequestMap.find(acqIdentifier);
177 if (it != impl->m_AcqIdentifierToAcqRequestMap.cend()) {
178 auto request = it->second;
179 impl->unlock();
180 qCInfo(LOG_VariableAcquisitionWorker()) << tr("onVariableAcquisitionFailed")
181 << acqIdentifier << request.m_vIdentifier
182 << QThread::currentThread();
183 emit variableCanceledRequested(request.m_vIdentifier);
184 }
185 else {
186 impl->unlock();
187 // TODO log no acqIdentifier recognized
188 }
189 }
190
169 void VariableAcquisitionWorker::onVariableDataAcquired(QUuid acqIdentifier,
191 void VariableAcquisitionWorker::onVariableDataAcquired(QUuid acqIdentifier,
170 std::shared_ptr<IDataSeries> dataSeries,
192 std::shared_ptr<IDataSeries> dataSeries,
171 SqpRange dataRangeAcquired)
193 SqpRange dataRangeAcquired)
@@ -151,12 +151,17 VariableController::VariableController(QObject *parent)
151 connect(impl->m_VariableModel, &VariableModel::abortProgessRequested, this,
151 connect(impl->m_VariableModel, &VariableModel::abortProgessRequested, this,
152 &VariableController::onAbortProgressRequested);
152 &VariableController::onAbortProgressRequested);
153
153
154 connect(impl->m_VariableAcquisitionWorker.get(),
155 &VariableAcquisitionWorker::variableCanceledRequested, this,
156 &VariableController::onAbortAcquisitionRequested);
157
154 connect(impl->m_VariableAcquisitionWorker.get(), &VariableAcquisitionWorker::dataProvided, this,
158 connect(impl->m_VariableAcquisitionWorker.get(), &VariableAcquisitionWorker::dataProvided, this,
155 &VariableController::onDataProvided);
159 &VariableController::onDataProvided);
156 connect(impl->m_VariableAcquisitionWorker.get(),
160 connect(impl->m_VariableAcquisitionWorker.get(),
157 &VariableAcquisitionWorker::variableRequestInProgress, this,
161 &VariableAcquisitionWorker::variableRequestInProgress, this,
158 &VariableController::onVariableRetrieveDataInProgress);
162 &VariableController::onVariableRetrieveDataInProgress);
159
163
164
160 connect(&impl->m_VariableAcquisitionWorkerThread, &QThread::started,
165 connect(&impl->m_VariableAcquisitionWorkerThread, &QThread::started,
161 impl->m_VariableAcquisitionWorker.get(), &VariableAcquisitionWorker::initialize);
166 impl->m_VariableAcquisitionWorker.get(), &VariableAcquisitionWorker::initialize);
162 connect(&impl->m_VariableAcquisitionWorkerThread, &QThread::finished,
167 connect(&impl->m_VariableAcquisitionWorkerThread, &QThread::finished,
@@ -273,6 +278,7 VariableController::createVariable(const QString &name, const QVariantHash &meta
273
278
274 // Associate the provider
279 // Associate the provider
275 impl->m_VariableToProviderMap[newVariable] = provider;
280 impl->m_VariableToProviderMap[newVariable] = provider;
281 qCInfo(LOG_VariableController()) << "createVariable: " << identifier;
276 impl->m_VariableToIdentifierMap[newVariable] = identifier;
282 impl->m_VariableToIdentifierMap[newVariable] = identifier;
277
283
278
284
@@ -358,6 +364,20 void VariableController::onAbortProgressRequested(std::shared_ptr<Variable> vari
358 }
364 }
359 }
365 }
360
366
367 void VariableController::onAbortAcquisitionRequested(QUuid vIdentifier)
368 {
369 qCDebug(LOG_VariableController()) << "TORM: variableController::onAbortAcquisitionRequested"
370 << QThread::currentThread()->objectName() << vIdentifier;
371
372 if (auto var = impl->findVariable(vIdentifier)) {
373 this->onAbortProgressRequested(var);
374 }
375 else {
376 qCCritical(LOG_VariableController())
377 << tr("Impossible to abort Acquisition Requestof a null variable");
378 }
379 }
380
361 void VariableController::onAddSynchronizationGroupId(QUuid synchronizationGroupId)
381 void VariableController::onAddSynchronizationGroupId(QUuid synchronizationGroupId)
362 {
382 {
363 qCDebug(LOG_VariableController()) << "TORM: VariableController::onAddSynchronizationGroupId"
383 qCDebug(LOG_VariableController()) << "TORM: VariableController::onAddSynchronizationGroupId"
@@ -645,6 +665,9 void VariableController::VariableControllerPrivate::registerProvider(
645 connect(provider.get(), &IDataProvider::dataProvidedProgress,
665 connect(provider.get(), &IDataProvider::dataProvidedProgress,
646 m_VariableAcquisitionWorker.get(),
666 m_VariableAcquisitionWorker.get(),
647 &VariableAcquisitionWorker::onVariableRetrieveDataInProgress);
667 &VariableAcquisitionWorker::onVariableRetrieveDataInProgress);
668 connect(provider.get(), &IDataProvider::dataProvidedFailed,
669 m_VariableAcquisitionWorker.get(),
670 &VariableAcquisitionWorker::onVariableAcquisitionFailed);
648 }
671 }
649 else {
672 else {
650 qCDebug(LOG_VariableController()) << tr("Cannot register provider, it already exists ");
673 qCDebug(LOG_VariableController()) << tr("Cannot register provider, it already exists ");
@@ -715,12 +738,10 QUuid VariableController::VariableControllerPrivate::acceptVariableRequest(
715 << varRequestId;
738 << varRequestId;
716 }
739 }
717
740
718 qCDebug(LOG_VariableController()) << tr("1: erase REQUEST in QUEUE ?")
719 << varRequestIdQueue.size();
720 varRequestIdQueue.pop_front();
741 varRequestIdQueue.pop_front();
721 qCDebug(LOG_VariableController()) << tr("2: erase REQUEST in QUEUE ?")
722 << varRequestIdQueue.size();
723 if (varRequestIdQueue.empty()) {
742 if (varRequestIdQueue.empty()) {
743 qCDebug(LOG_VariableController())
744 << tr("TORM Erase REQUEST because it has been accepted") << varId;
724 m_VarIdToVarRequestIdQueueMap.erase(varId);
745 m_VarIdToVarRequestIdQueueMap.erase(varId);
725 }
746 }
726 }
747 }
@@ -82,7 +82,7 void AmdaProvider::requestDataLoading(QUuid acqIdentifier, const DataProviderPar
82 const auto times = parameters.m_Times;
82 const auto times = parameters.m_Times;
83 const auto data = parameters.m_Data;
83 const auto data = parameters.m_Data;
84 for (const auto &dateTime : qAsConst(times)) {
84 for (const auto &dateTime : qAsConst(times)) {
85 qCInfo(LOG_AmdaProvider()) << tr("TORM AmdaProvider::requestDataLoading ") << acqIdentifier
85 qCDebug(LOG_AmdaProvider()) << tr("TORM AmdaProvider::requestDataLoading ") << acqIdentifier
86 << dateTime;
86 << dateTime;
87 this->retrieveData(acqIdentifier, dateTime, data);
87 this->retrieveData(acqIdentifier, dateTime, data);
88
88
@@ -125,8 +125,8 void AmdaProvider::onReplyDownloadProgress(QUuid acqIdentifier,
125 // This case can happened when a progression is send after the request has been
125 // This case can happened when a progression is send after the request has been
126 // finished.
126 // finished.
127 // Generaly the case when aborting a request
127 // Generaly the case when aborting a request
128 qCWarning(LOG_AmdaProvider()) << tr("Can't retrieve Request in progress")
128 qCDebug(LOG_AmdaProvider()) << tr("Can't retrieve Request in progress") << acqIdentifier
129 << acqIdentifier << networkRequest.get() << progress;
129 << networkRequest.get() << progress;
130 }
130 }
131
131
132 // Compute the current final progress and notify it
132 // Compute the current final progress and notify it
@@ -199,6 +199,7 void AmdaProvider::retrieveData(QUuid token, const SqpRange &dateTime, const QVa
199 }
199 }
200 else {
200 else {
201 /// @todo ALX : debug
201 /// @todo ALX : debug
202 emit dataProvidedFailed(dataId);
202 }
203 }
203 }
204 }
204 qCDebug(LOG_AmdaProvider()) << tr("acquisition requests erase because of finishing")
205 qCDebug(LOG_AmdaProvider()) << tr("acquisition requests erase because of finishing")
@@ -207,6 +208,7 void AmdaProvider::retrieveData(QUuid token, const SqpRange &dateTime, const QVa
207 }
208 }
208 else {
209 else {
209 qCCritical(LOG_AmdaProvider()) << tr("httpDownloadFinished ERROR");
210 qCCritical(LOG_AmdaProvider()) << tr("httpDownloadFinished ERROR");
211 emit dataProvidedFailed(dataId);
210 }
212 }
211
213
212 };
214 };
@@ -228,12 +230,16 void AmdaProvider::retrieveData(QUuid token, const SqpRange &dateTime, const QVa
228 updateRequestProgress(dataId, request, 0.0);
230 updateRequestProgress(dataId, request, 0.0);
229 emit requestConstructed(request, dataId, httpDownloadFinished);
231 emit requestConstructed(request, dataId, httpDownloadFinished);
230 }
232 }
233 else {
234 emit dataProvidedFailed(dataId);
235 }
231 }
236 }
232 else {
237 else {
233 qCDebug(LOG_AmdaProvider())
238 qCDebug(LOG_AmdaProvider())
234 << tr("acquisition requests erase because of aborting") << dataId;
239 << tr("acquisition requests erase because of aborting") << dataId;
235 qCCritical(LOG_AmdaProvider()) << tr("httpFinishedLambda ERROR");
240 qCCritical(LOG_AmdaProvider()) << tr("httpFinishedLambda ERROR");
236 m_AcqIdToRequestProgressMap.erase(dataId);
241 m_AcqIdToRequestProgressMap.erase(dataId);
242 emit dataProvidedFailed(dataId);
237 }
243 }
238 };
244 };
239
245
General Comments 2
You need to be logged in to leave comments. Login now