Adds immediate migration results in progress
This commit is contained in:
2102 files changed
+17482
-15071
No files matched your search
+20
-21
@@ -9,12 +9,11 @@
|
||||
|
||||
namespace BuildingControlUnit
|
||||
{
|
||||
HandleHttpRequest::HandleHttpRequest(bool useQueue, QObject *parent)
|
||||
: QObject(parent)
|
||||
HandleHttpRequest::HandleHttpRequest(bool useQueue, QObject *parent) : QObject(parent)
|
||||
, m_nam(new QNetworkAccessManager(this))
|
||||
, m_bUseQueue(useQueue)
|
||||
{
|
||||
INFO_LOG() << "Using Queue: " << m_bUseQueue;
|
||||
, m_bUseQueue(useQueue),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
|
||||
INFO_LOG(m_logger) << "Using Queue: " << m_bUseQueue;
|
||||
connect(m_nam, &QNetworkAccessManager::finished,
|
||||
this, &HandleHttpRequest::onReplyFinished);
|
||||
connect(m_nam, &QNetworkAccessManager::authenticationRequired,
|
||||
@@ -41,7 +40,7 @@ void HandleHttpRequest::enqueue(const QUrl &url, HandleHttpQueueMessageStatus st
|
||||
if ((HandleHttpQueueMessageStatus::MS_Cyclic == status) &&
|
||||
m_queueMap[host].uniquenessChecker.contains(url.toString()))
|
||||
{
|
||||
WARNING_LOG() << "Discarding duplicate url \"" << url.toString() << "\" due to slow message handling.";
|
||||
WARNING_LOG(m_logger) << "Discarding duplicate url \"" << url.toString() << "\" due to slow message handling.";
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -49,7 +48,7 @@ void HandleHttpRequest::enqueue(const QUrl &url, HandleHttpQueueMessageStatus st
|
||||
networkRequest.request = QNetworkRequest(url);
|
||||
m_queueMap[host].uniquenessChecker.insert(url.toString());
|
||||
m_queueMap[host].requests.enqueue(networkRequest);
|
||||
DEBUG_LOG() << "Added '" << url.toString() << " to queue for host: " << host
|
||||
DEBUG_LOG(m_logger) << "Added '" << url.toString() << " to queue for host: " << host
|
||||
<< " Queue has " << m_queueMap[host].requests.count() << " elements";
|
||||
trySendNextRequest();
|
||||
}
|
||||
@@ -59,21 +58,21 @@ void HandleHttpRequest::onAuthenticationRequired(QNetworkReply *reply, QAuthenti
|
||||
{
|
||||
if (!reply || !authenticator)
|
||||
{
|
||||
ERROR_LOG() << "Internal error - Nullptr exception!";
|
||||
ERROR_LOG(m_logger) << "Internal error - Nullptr exception!";
|
||||
}
|
||||
else if (!m_queueMap.contains(reply->url().host()))
|
||||
{
|
||||
WARNING_LOG() << "Internal error - got auth reply from unknown host!";
|
||||
WARNING_LOG(m_logger) << "Internal error - got auth reply from unknown host!";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_bUseQueue && reply != m_queueMap[reply->url().host()].activeReply)
|
||||
WARNING_LOG() << "Internal error - got auth reply from unknown request!";
|
||||
WARNING_LOG(m_logger) << "Internal error - got auth reply from unknown request!";
|
||||
|
||||
|
||||
if (m_queueMap[reply->url().host()].bAuthAlreadyRequested)
|
||||
return;
|
||||
DEBUG_LOG() << "Authentication request";
|
||||
DEBUG_LOG(m_logger) << "Authentication request";
|
||||
authenticator->setUser(m_username);
|
||||
authenticator->setPassword(m_passwd);
|
||||
m_queueMap[reply->url().host()].bAuthAlreadyRequested = true;
|
||||
@@ -89,17 +88,17 @@ void HandleHttpRequest::onReplyFinished(QNetworkReply *reply)
|
||||
}
|
||||
if (!reply)
|
||||
{
|
||||
ERROR_LOG() << "Internal error - Nullptr exception!";
|
||||
ERROR_LOG(m_logger) << "Internal error - Nullptr exception!";
|
||||
}
|
||||
else if (!m_queueMap.contains(reply->url().host()))
|
||||
{
|
||||
reply->deleteLater();
|
||||
WARNING_LOG() << "Internal error - got reply from unknown host!";
|
||||
WARNING_LOG(m_logger) << "Internal error - got reply from unknown host!";
|
||||
}
|
||||
else if (m_bUseQueue && reply != m_queueMap[reply->url().host()].activeReply)
|
||||
{
|
||||
reply->deleteLater();
|
||||
WARNING_LOG() << "Internal error - got reply from unknown request!";
|
||||
WARNING_LOG(m_logger) << "Internal error - got reply from unknown request!";
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -109,16 +108,16 @@ void HandleHttpRequest::onReplyFinished(QNetworkReply *reply)
|
||||
if ( m_newConnection)
|
||||
{
|
||||
m_newConnection = false;
|
||||
DEBUG_LOG() << "emit newEgcuConnection host=" << reply->url().host();
|
||||
DEBUG_LOG(m_logger) << "emit newEgcuConnection host=" << reply->url().host();
|
||||
emit newEgcuConnection(reply->url().host());
|
||||
}
|
||||
DEBUG_LOG() << "Request successfull";
|
||||
DEBUG_LOG(m_logger) << "Request successfull";
|
||||
}
|
||||
else
|
||||
WARNING_LOG() << "Invalid request for host " << reply->url().host() << ", response code: " << responseCode << ", query: " << reply->url().toString();
|
||||
WARNING_LOG(m_logger) << "Invalid request for host " << reply->url().host() << ", response code: " << responseCode << ", query: " << reply->url().toString();
|
||||
|
||||
QByteArray replyData = reply->readAll();
|
||||
DEBUG_LOG() << "Got reply (" << reply->url().toString() << "): " << replyData
|
||||
DEBUG_LOG(m_logger) << "Got reply (" << reply->url().toString() << "): " << replyData
|
||||
<< " host=" << reply->url().host();
|
||||
emit egcuReply(reply->url().host(), replyData);
|
||||
|
||||
@@ -133,7 +132,7 @@ void HandleHttpRequest::sendNextRequest(HandleHttpQueue& queue)
|
||||
{
|
||||
if (m_bUseQueue && queue.activeReply != nullptr)
|
||||
{
|
||||
WARNING_LOG() << "Internal error - active reply not yet finished!";
|
||||
WARNING_LOG(m_logger) << "Internal error - active reply not yet finished!";
|
||||
}
|
||||
else if (!queue.requests.isEmpty())
|
||||
{
|
||||
@@ -144,11 +143,11 @@ void HandleHttpRequest::sendNextRequest(HandleHttpQueue& queue)
|
||||
if ( networkRequest.time.secsTo(QTime::currentTime()) < 5)
|
||||
{
|
||||
queue.activeReply = m_nam->get(request);
|
||||
DEBUG_LOG() << "Send request " << request.url().toString() << " and waiting for reply (" << queue.activeReply << ")";
|
||||
DEBUG_LOG(m_logger) << "Send request " << request.url().toString() << " and waiting for reply (" << queue.activeReply << ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_LOG() << "remove request " << request.url().toString()
|
||||
DEBUG_LOG(m_logger) << "remove request " << request.url().toString()
|
||||
<< " because it's too old" << networkRequest.time.secsTo(QTime::currentTime());
|
||||
sendNextRequest(queue);
|
||||
m_newConnection = true;
|
||||
|
||||
Reference in new issue
Block a user