mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 17:35:34 +08:00
Some Web readers adjustemnts
* do not init shared URLs before needed * do not load info objects when DB is unavailable * adjust reader flags when DB is down * airport URL available in setup
This commit is contained in:
@@ -39,7 +39,7 @@ namespace BlackCore
|
||||
CDatabaseReader::CDatabaseReader(QObject *owner, const CDatabaseReaderConfigList &config, const QString &name) :
|
||||
BlackCore::CThreadedReader(owner, name), m_config(config)
|
||||
{
|
||||
this->m_sharedUrl = sApp->getGlobalSetup().getSwiftSharedUrls().getRandomWorkingUrl();
|
||||
getDbUrl(); // init
|
||||
}
|
||||
|
||||
void CDatabaseReader::readInBackgroundThread(CEntityFlags::Entity entities, const QDateTime &newerThan)
|
||||
@@ -230,11 +230,6 @@ namespace BlackCore
|
||||
return m_canConnect;
|
||||
}
|
||||
|
||||
CUrl CDatabaseReader::getWorkingSharedUrl() const
|
||||
{
|
||||
return this->m_sharedUrl;
|
||||
}
|
||||
|
||||
const QString &CDatabaseReader::getStatusMessage() const
|
||||
{
|
||||
return this->m_statusMessage;
|
||||
@@ -285,5 +280,21 @@ namespace BlackCore
|
||||
static const QString p("latestId");
|
||||
return p;
|
||||
}
|
||||
|
||||
const CUrl &CDatabaseReader::getDbUrl()
|
||||
{
|
||||
static const CUrl dbUrl(sApp->getGlobalSetup().getDbRootDirectoryUrl());
|
||||
return dbUrl;
|
||||
}
|
||||
|
||||
CUrl CDatabaseReader::getWorkingSharedUrl()
|
||||
{
|
||||
return sApp->getGlobalSetup().getSwiftSharedUrls().getRandomWorkingUrl();
|
||||
}
|
||||
|
||||
bool CDatabaseReader::canPingSwiftServer()
|
||||
{
|
||||
return CNetworkUtils::canConnect(getDbUrl());
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -103,9 +103,6 @@ namespace BlackCore
|
||||
//! \threadsafe
|
||||
bool canConnect(QString &message) const;
|
||||
|
||||
//! Obtain a working shared URL
|
||||
BlackMisc::Network::CUrl getWorkingSharedUrl() const;
|
||||
|
||||
//! Status message (error message)
|
||||
const QString &getStatusMessage() const;
|
||||
|
||||
@@ -118,13 +115,15 @@ namespace BlackCore
|
||||
//! Name of parameter for latest id
|
||||
static const QString ¶meterLatestId();
|
||||
|
||||
//! sift DB server reachable?
|
||||
static bool canPingSwiftServer();
|
||||
|
||||
signals:
|
||||
//! Combined read signal
|
||||
void dataRead(BlackMisc::Network::CEntityFlags::Entity entity, BlackMisc::Network::CEntityFlags::ReadState state, int number);
|
||||
|
||||
protected:
|
||||
CDatabaseReaderConfigList m_config; //!< DB reder configuration
|
||||
BlackMisc::Network::CUrl m_sharedUrl; //!< URL for shared files
|
||||
QString m_statusMessage; //!< Returned status message from watchdog
|
||||
bool m_canConnect = false; //!< Successful connection?
|
||||
mutable QReadWriteLock m_statusLock; //!< Lock
|
||||
@@ -152,7 +151,14 @@ namespace BlackCore
|
||||
//! Split into single entity and send dataRead signal
|
||||
void emitReadSignalPerSingleCachedEntity(BlackMisc::Network::CEntityFlags::Entity cachedEntities);
|
||||
|
||||
// ---------------- cache access ------------------
|
||||
//! DB base URL
|
||||
static const BlackMisc::Network::CUrl &getDbUrl();
|
||||
|
||||
//! Obtain a working shared URL
|
||||
static BlackMisc::Network::CUrl getWorkingSharedUrl();
|
||||
|
||||
//! \name Cache access
|
||||
//! @{
|
||||
|
||||
//! Syncronize caches for given entities
|
||||
virtual void syncronizeCaches(BlackMisc::Network::CEntityFlags::Entity entities) = 0;
|
||||
@@ -171,6 +177,7 @@ namespace BlackCore
|
||||
|
||||
//! Has URL been changed? Means we load from a differrent server
|
||||
static bool isChangedUrl(const BlackMisc::Network::CUrl &oldUrl, const BlackMisc::Network::CUrl ¤tUrl);
|
||||
//! @}
|
||||
|
||||
private:
|
||||
//! Check if terminated or error, otherwise split into array of objects
|
||||
|
||||
@@ -47,6 +47,13 @@ namespace BlackCore
|
||||
return static_cast<CDbFlags::DataRetrievalMode>(this->m_retrievalFlags);
|
||||
}
|
||||
|
||||
void CDatabaseReaderConfig::markAsDbDown()
|
||||
{
|
||||
CDbFlags::DataRetrievalMode m = this->getRetrievalMode();
|
||||
m = CDbFlags::adjustWhenDbIsDown(m);
|
||||
this->m_retrievalFlags = static_cast<int>(m);
|
||||
}
|
||||
|
||||
void CDatabaseReaderConfig::setCacheLifetime(const CTime &time)
|
||||
{
|
||||
this->m_cacheLifetime = time;
|
||||
@@ -86,6 +93,14 @@ namespace BlackCore
|
||||
return CDatabaseReaderConfig(); // not found
|
||||
}
|
||||
|
||||
void CDatabaseReaderConfigList::markAsDbDown()
|
||||
{
|
||||
for (CDatabaseReaderConfig &config : *this)
|
||||
{
|
||||
config.markAsDbDown();
|
||||
}
|
||||
}
|
||||
|
||||
void CDatabaseReaderConfigList::setCacheLifetimes(const CTime &time)
|
||||
{
|
||||
for (CDatabaseReaderConfig &config : *this)
|
||||
|
||||
@@ -53,6 +53,9 @@ namespace BlackCore
|
||||
//! Supported modes
|
||||
BlackMisc::Db::CDbFlags::DataRetrievalMode getRetrievalMode() const;
|
||||
|
||||
//! DB is down
|
||||
void markAsDbDown();
|
||||
|
||||
//! Timeout
|
||||
void setCacheLifetime(const BlackMisc::PhysicalQuantities::CTime &time);
|
||||
|
||||
@@ -91,6 +94,9 @@ namespace BlackCore
|
||||
//! FInd first one matching given
|
||||
CDatabaseReaderConfig findFirstOrDefaultForEntity(const BlackMisc::Network::CEntityFlags::Entity entities) const;
|
||||
|
||||
//! DB is down
|
||||
void markAsDbDown();
|
||||
|
||||
//! Update lifetimes
|
||||
void setCacheLifetimes(const BlackMisc::PhysicalQuantities::CTime &time);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user