##// END OF EJS Templates
Correction for MR
perrinel -
r703:ba0e6f7d7791
parent child
Show More
@@ -50,17 +50,19 void NetworkController::onProcessRequested(std::shared_ptr<QNetworkRequest> requ
50 << QThread::currentThread() << request.get() << reply;
50 << QThread::currentThread() << request.get() << reply;
51 impl->lockRead();
51 impl->lockRead();
52 auto it = impl->m_NetworkReplyToId.find(reply);
52 auto it = impl->m_NetworkReplyToId.find(reply);
53 impl->unlock();
54 if (it != impl->m_NetworkReplyToId.cend()) {
53 if (it != impl->m_NetworkReplyToId.cend()) {
54 qCDebug(LOG_NetworkController()) << tr("Remove for reply: ") << it->second;
55 impl->unlock();
55 impl->lockWrite();
56 impl->lockWrite();
56 qCDebug(LOG_NetworkController()) << tr("Remove for reply: ")
57 << impl->m_NetworkReplyToId[reply];
58 impl->m_NetworkReplyToId.erase(reply);
57 impl->m_NetworkReplyToId.erase(reply);
59 impl->unlock();
58 impl->unlock();
60 // Deletes reply
59 // Deletes reply
61 callback(reply, identifier);
60 callback(reply, identifier);
62 reply->deleteLater();
61 reply->deleteLater();
63 }
62 }
63 else {
64 impl->unlock();
65 }
64
66
65 qCDebug(LOG_NetworkController()) << tr("NetworkController onReplyFinished END")
67 qCDebug(LOG_NetworkController()) << tr("NetworkController onReplyFinished END")
66 << QThread::currentThread() << reply;
68 << QThread::currentThread() << reply;
@@ -76,10 +78,15 void NetworkController::onProcessRequested(std::shared_ptr<QNetworkRequest> requ
76 << bytesRead << totalBytes;
78 << bytesRead << totalBytes;
77 impl->lockRead();
79 impl->lockRead();
78 auto it = impl->m_NetworkReplyToId.find(reply);
80 auto it = impl->m_NetworkReplyToId.find(reply);
79 impl->unlock();
80 if (it != impl->m_NetworkReplyToId.cend()) {
81 if (it != impl->m_NetworkReplyToId.cend()) {
81 emit this->replyDownloadProgress(it->second, request, progress);
82 auto id = it->second;
83 impl->unlock();
84 emit this->replyDownloadProgress(id, request, progress);
85 }
86 else {
87 impl->unlock();
82 }
88 }
89
83 qCDebug(LOG_NetworkController()) << tr("NetworkController onReplyProgress END")
90 qCDebug(LOG_NetworkController()) << tr("NetworkController onReplyProgress END")
84 << QThread::currentThread() << reply;
91 << QThread::currentThread() << reply;
85 }
92 }
@@ -82,6 +82,8 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
86 << dateTime;
85 this->retrieveData(acqIdentifier, dateTime, data);
87 this->retrieveData(acqIdentifier, dateTime, data);
86
88
87
89
@@ -102,11 +104,12 void AmdaProvider::onReplyDownloadProgress(QUuid acqIdentifier,
102 std::shared_ptr<QNetworkRequest> networkRequest,
104 std::shared_ptr<QNetworkRequest> networkRequest,
103 double progress)
105 double progress)
104 {
106 {
105 qCInfo(LOG_AmdaProvider()) << tr("onReplyDownloadProgress") << acqIdentifier
107 qCDebug(LOG_AmdaProvider()) << tr("onReplyDownloadProgress") << acqIdentifier
106 << networkRequest.get() << progress;
108 << networkRequest.get() << progress;
107 auto acqIdToRequestProgressMapIt = m_AcqIdToRequestProgressMap.find(acqIdentifier);
109 auto acqIdToRequestProgressMapIt = m_AcqIdToRequestProgressMap.find(acqIdentifier);
108 if (acqIdToRequestProgressMapIt != m_AcqIdToRequestProgressMap.end()) {
110 if (acqIdToRequestProgressMapIt != m_AcqIdToRequestProgressMap.end()) {
109
111
112 // Update the progression for the current request
110 auto requestPtr = networkRequest;
113 auto requestPtr = networkRequest;
111 auto findRequest = [requestPtr](const auto &entry) { return requestPtr == entry.first; };
114 auto findRequest = [requestPtr](const auto &entry) { return requestPtr == entry.first; };
112
115
@@ -125,18 +128,15 void AmdaProvider::onReplyDownloadProgress(QUuid acqIdentifier,
125 qCWarning(LOG_AmdaProvider()) << tr("Can't retrieve Request in progress")
128 qCWarning(LOG_AmdaProvider()) << tr("Can't retrieve Request in progress")
126 << acqIdentifier << networkRequest.get() << progress;
129 << acqIdentifier << networkRequest.get() << progress;
127 }
130 }
128 }
129
131
130 acqIdToRequestProgressMapIt = m_AcqIdToRequestProgressMap.find(acqIdentifier);
132 // Compute the current final progress and notify it
131 if (acqIdToRequestProgressMapIt != m_AcqIdToRequestProgressMap.end()) {
132 double finalProgress = 0.0;
133 double finalProgress = 0.0;
133
134
134 auto &requestProgressMap = acqIdToRequestProgressMapIt->second;
135 auto fraq = requestProgressMap.size();
135 auto fraq = requestProgressMap.size();
136
136
137 for (auto requestProgress : requestProgressMap) {
137 for (auto requestProgress : requestProgressMap) {
138 finalProgress += requestProgress.second;
138 finalProgress += requestProgress.second;
139 qCDebug(LOG_AmdaProvider()) << tr("current final progress without freq:")
139 qCDebug(LOG_AmdaProvider()) << tr("Current final progress without fraq:")
140 << finalProgress << requestProgress.second;
140 << finalProgress << requestProgress.second;
141 }
141 }
142
142
@@ -144,8 +144,7 void AmdaProvider::onReplyDownloadProgress(QUuid acqIdentifier,
144 finalProgress = finalProgress / fraq;
144 finalProgress = finalProgress / fraq;
145 }
145 }
146
146
147 qCDebug(LOG_AmdaProvider()) << tr("2 onReplyDownloadProgress final progress") << fraq
147 qCDebug(LOG_AmdaProvider()) << tr("Current final progress: ") << fraq << finalProgress;
148 << finalProgress;
149 emit dataProvidedProgress(acqIdentifier, finalProgress);
148 emit dataProvidedProgress(acqIdentifier, finalProgress);
150 }
149 }
151 else {
150 else {
@@ -176,7 +175,7 void AmdaProvider::retrieveData(QUuid token, const SqpRange &dateTime, const QVa
176 auto endDate = dateFormat(dateTime.m_TEnd);
175 auto endDate = dateFormat(dateTime.m_TEnd);
177
176
178 auto url = QUrl{QString{AMDA_URL_FORMAT}.arg(startDate, endDate, productId)};
177 auto url = QUrl{QString{AMDA_URL_FORMAT}.arg(startDate, endDate, productId)};
179 qCDebug(LOG_AmdaProvider()) << tr("TORM AmdaProvider::retrieveData url:") << url;
178 qCInfo(LOG_AmdaProvider()) << tr("TORM AmdaProvider::retrieveData url:") << url;
180 auto tempFile = std::make_shared<QTemporaryFile>();
179 auto tempFile = std::make_shared<QTemporaryFile>();
181
180
182 // LAMBDA
181 // LAMBDA
@@ -184,7 +183,7 void AmdaProvider::retrieveData(QUuid token, const SqpRange &dateTime, const QVa
184 productValueType](QNetworkReply *reply, QUuid dataId) noexcept {
183 productValueType](QNetworkReply *reply, QUuid dataId) noexcept {
185
184
186 // Don't do anything if the reply was abort
185 // Don't do anything if the reply was abort
187 if (reply->error() != QNetworkReply::OperationCanceledError) {
186 if (reply->error() == QNetworkReply::NoError) {
188
187
189 if (tempFile) {
188 if (tempFile) {
190 auto replyReadAll = reply->readAll();
189 auto replyReadAll = reply->readAll();
@@ -206,16 +205,19 void AmdaProvider::retrieveData(QUuid token, const SqpRange &dateTime, const QVa
206 << dataId;
205 << dataId;
207 m_AcqIdToRequestProgressMap.erase(dataId);
206 m_AcqIdToRequestProgressMap.erase(dataId);
208 }
207 }
208 else {
209 qCCritical(LOG_AmdaProvider()) << tr("httpDownloadFinished ERROR");
210 }
209
211
210 };
212 };
211 auto httpFinishedLambda
213 auto httpFinishedLambda
212 = [this, httpDownloadFinished, tempFile](QNetworkReply *reply, QUuid dataId) noexcept {
214 = [this, httpDownloadFinished, tempFile](QNetworkReply *reply, QUuid dataId) noexcept {
213
215
214 // Don't do anything if the reply was abort
216 // Don't do anything if the reply was abort
215 if (reply->error() != QNetworkReply::OperationCanceledError) {
217 if (reply->error() == QNetworkReply::NoError) {
216 auto downloadFileUrl = QUrl{QString{reply->readAll()}};
218 auto downloadFileUrl = QUrl{QString{reply->readAll()}};
217
219
218 qCDebug(LOG_AmdaProvider())
220 qCInfo(LOG_AmdaProvider())
219 << tr("TORM AmdaProvider::retrieveData downloadFileUrl:") << downloadFileUrl;
221 << tr("TORM AmdaProvider::retrieveData downloadFileUrl:") << downloadFileUrl;
220 // Executes request for downloading file //
222 // Executes request for downloading file //
221
223
@@ -230,6 +232,7 void AmdaProvider::retrieveData(QUuid token, const SqpRange &dateTime, const QVa
230 else {
232 else {
231 qCDebug(LOG_AmdaProvider())
233 qCDebug(LOG_AmdaProvider())
232 << tr("acquisition requests erase because of aborting") << dataId;
234 << tr("acquisition requests erase because of aborting") << dataId;
235 qCCritical(LOG_AmdaProvider()) << tr("httpFinishedLambda ERROR");
233 m_AcqIdToRequestProgressMap.erase(dataId);
236 m_AcqIdToRequestProgressMap.erase(dataId);
234 }
237 }
235 };
238 };
General Comments 2
You need to be logged in to leave comments. Login now