mirror of https://github.com/Icinga/icinga2.git
parent
9f8cb8dd36
commit
ed53366490
|
@ -138,7 +138,7 @@ static Object::Ptr DeserializeObject(const Object::Ptr& object, const Dictionary
|
|||
continue;
|
||||
|
||||
try {
|
||||
instance->SetField(fid, Deserialize(kv.second, safe_mode, attributeTypes));
|
||||
instance->SetField(fid, Deserialize(kv.second, safe_mode, attributeTypes), true);
|
||||
} catch (const std::exception&) {
|
||||
instance->SetField(fid, Empty);
|
||||
}
|
||||
|
|
|
@ -39,7 +39,8 @@ Timer::Ptr DbConnection::m_ProgramStatusTimer;
|
|||
boost::once_flag DbConnection::m_OnceFlag = BOOST_ONCE_INIT;
|
||||
|
||||
DbConnection::DbConnection(void)
|
||||
: m_QueryStats(15 * 60), m_PendingQueries(0), m_PendingQueriesTimestamp(0), m_IDCacheValid(false)
|
||||
: m_QueryStats(15 * 60), m_PendingQueries(0), m_PendingQueriesTimestamp(0),
|
||||
m_IDCacheValid(false), m_ActiveChangedHandler(false)
|
||||
{ }
|
||||
|
||||
void DbConnection::OnConfigLoaded(void)
|
||||
|
@ -74,7 +75,14 @@ void DbConnection::Start(bool runtimeCreated)
|
|||
|
||||
DbObject::OnQuery.connect(boost::bind(&DbConnection::ExecuteQuery, this, _1));
|
||||
DbObject::OnMultipleQueries.connect(boost::bind(&DbConnection::ExecuteMultipleQueries, this, _1));
|
||||
ConfigObject::OnActiveChanged.connect(boost::bind(&DbConnection::UpdateObject, this, _1));
|
||||
}
|
||||
|
||||
void DbConnection::EnableActiveChangedHandler(void)
|
||||
{
|
||||
if (!m_ActiveChangedHandler) {
|
||||
ConfigObject::OnActiveChanged.connect(boost::bind(&DbConnection::UpdateObject, this, _1));
|
||||
m_ActiveChangedHandler = true;
|
||||
}
|
||||
}
|
||||
|
||||
void DbConnection::StatsLoggerTimerHandler(void)
|
||||
|
@ -394,8 +402,10 @@ void DbConnection::UpdateObject(const ConfigObject::Ptr& object)
|
|||
bool dbActive = GetObjectActive(dbobj);
|
||||
bool active = object->IsActive();
|
||||
|
||||
if (active && !dbActive) {
|
||||
ActivateObject(dbobj);
|
||||
if (active) {
|
||||
if (!dbActive)
|
||||
ActivateObject(dbobj);
|
||||
|
||||
dbobj->SendConfigUpdate();
|
||||
dbobj->SendStatusUpdate();
|
||||
} else if (!active) {
|
||||
|
|
|
@ -98,6 +98,8 @@ protected:
|
|||
bool IsIDCacheValid(void) const;
|
||||
void SetIDCacheValid(bool valid);
|
||||
|
||||
void EnableActiveChangedHandler(void);
|
||||
|
||||
static void UpdateProgramStatus(void);
|
||||
|
||||
static int GetSessionToken(void);
|
||||
|
@ -127,6 +129,7 @@ private:
|
|||
RingBuffer m_QueryStats;
|
||||
int m_PendingQueries;
|
||||
double m_PendingQueriesTimestamp;
|
||||
bool m_ActiveChangedHandler;
|
||||
};
|
||||
|
||||
struct database_error : virtual std::exception, virtual boost::exception { };
|
||||
|
|
|
@ -399,16 +399,16 @@ void IdoMysqlConnection::Reconnect(void)
|
|||
|
||||
SetIDCacheValid(true);
|
||||
|
||||
EnableActiveChangedHandler();
|
||||
|
||||
BOOST_FOREACH(const DbObject::Ptr& dbobj, activeDbObjs) {
|
||||
if (dbobj->GetObject() == NULL) {
|
||||
Log(LogNotice, "IdoMysqlConnection")
|
||||
<< "Deactivate deleted object name1: '" << dbobj->GetName1()
|
||||
<< "' name2: '" << dbobj->GetName2() + "'.";
|
||||
DeactivateObject(dbobj);
|
||||
} else {
|
||||
dbobj->SendConfigUpdate();
|
||||
dbobj->SendStatusUpdate();
|
||||
}
|
||||
if (dbobj->GetObject())
|
||||
continue;
|
||||
|
||||
Log(LogNotice, "IdoMysqlConnection")
|
||||
<< "Deactivate deleted object name1: '" << dbobj->GetName1()
|
||||
<< "' name2: '" << dbobj->GetName2() + "'.";
|
||||
DeactivateObject(dbobj);
|
||||
}
|
||||
|
||||
UpdateAllObjects();
|
||||
|
|
|
@ -372,16 +372,16 @@ void IdoPgsqlConnection::Reconnect(void)
|
|||
|
||||
SetIDCacheValid(true);
|
||||
|
||||
EnableActiveChangedHandler();
|
||||
|
||||
BOOST_FOREACH(const DbObject::Ptr& dbobj, activeDbObjs) {
|
||||
if (dbobj->GetObject() == NULL) {
|
||||
Log(LogNotice, "IdoPgsqlConnection")
|
||||
<< "Deactivate deleted object name1: '" << dbobj->GetName1()
|
||||
<< "' name2: '" << dbobj->GetName2() + "'.";
|
||||
DeactivateObject(dbobj);
|
||||
} else {
|
||||
dbobj->SendConfigUpdate();
|
||||
dbobj->SendStatusUpdate();
|
||||
}
|
||||
if (dbobj->GetObject())
|
||||
continue;
|
||||
|
||||
Log(LogNotice, "IdoPgsqlConnection")
|
||||
<< "Deactivate deleted object name1: '" << dbobj->GetName1()
|
||||
<< "' name2: '" << dbobj->GetName2() + "'.";
|
||||
DeactivateObject(dbobj);
|
||||
}
|
||||
|
||||
UpdateAllObjects();
|
||||
|
|
Loading…
Reference in New Issue