mirror of https://github.com/Icinga/icinga2.git
Bugfix for restoring objects from the retention.dat file.
This commit is contained in:
parent
1de42d08f2
commit
d8be3f088f
|
@ -436,7 +436,7 @@ void DynamicObject::RestoreObjects(const String& filename)
|
||||||
bool hasConfig = persistentObject->Contains("configTx");
|
bool hasConfig = persistentObject->Contains("configTx");
|
||||||
Dictionary::Ptr update = persistentObject->Get("update");
|
Dictionary::Ptr update = persistentObject->Get("update");
|
||||||
|
|
||||||
if (hasConfig) {
|
if (hasConfig && ClassExists(type)) {
|
||||||
DynamicObject::Ptr object = Create(type, update);
|
DynamicObject::Ptr object = Create(type, update);
|
||||||
object->Register();
|
object->Register();
|
||||||
} else {
|
} else {
|
||||||
|
@ -466,6 +466,37 @@ void DynamicObject::RegisterClass(const String& type, DynamicObject::Factory fac
|
||||||
type + "': Objects of this type already exist."));
|
type + "': Objects of this type already exist."));
|
||||||
|
|
||||||
GetClasses()[type] = factory;
|
GetClasses()[type] = factory;
|
||||||
|
|
||||||
|
/* restore persistent objects that match the newly-registered class */
|
||||||
|
map<pair<String, String>, Dictionary::Ptr>::iterator prev, st;
|
||||||
|
for (st = m_PersistentUpdates.begin(); st != m_PersistentUpdates.end(); st++)
|
||||||
|
{
|
||||||
|
/* check type of the update */
|
||||||
|
if (st->first.first != type) {
|
||||||
|
st++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Dictionary::Ptr update = st->second;
|
||||||
|
bool hasConfig = update->Contains("configTx");
|
||||||
|
if (!hasConfig) {
|
||||||
|
st++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
DynamicObject::Ptr object = Create(type, update);
|
||||||
|
object->Register();
|
||||||
|
|
||||||
|
prev = st;
|
||||||
|
st++;
|
||||||
|
m_PersistentUpdates.erase(prev);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DynamicObject::ClassExists(const String& type)
|
||||||
|
{
|
||||||
|
return (GetClasses().find(type) != GetClasses().end());
|
||||||
}
|
}
|
||||||
|
|
||||||
DynamicObject::Ptr DynamicObject::Create(const String& type, const Dictionary::Ptr& serializedUpdate)
|
DynamicObject::Ptr DynamicObject::Create(const String& type, const Dictionary::Ptr& serializedUpdate)
|
||||||
|
|
|
@ -118,6 +118,7 @@ public:
|
||||||
static void RestoreObjects(const String& filename);
|
static void RestoreObjects(const String& filename);
|
||||||
|
|
||||||
static void RegisterClass(const String& type, Factory factory);
|
static void RegisterClass(const String& type, Factory factory);
|
||||||
|
static bool ClassExists(const String& type);
|
||||||
static DynamicObject::Ptr Create(const String& type, const Dictionary::Ptr& serializedUpdate);
|
static DynamicObject::Ptr Create(const String& type, const Dictionary::Ptr& serializedUpdate);
|
||||||
|
|
||||||
static double GetCurrentTx(void);
|
static double GetCurrentTx(void);
|
||||||
|
|
|
@ -160,8 +160,6 @@ void CheckerComponent::CheckerChangedHandler(const Service::Ptr& service)
|
||||||
if (m_PendingServices.find(service) != m_PendingServices.end())
|
if (m_PendingServices.find(service) != m_PendingServices.end())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
service->UpdateNextCheck();
|
|
||||||
|
|
||||||
m_IdleServices.insert(service);
|
m_IdleServices.insert(service);
|
||||||
} else {
|
} else {
|
||||||
m_IdleServices.erase(service);
|
m_IdleServices.erase(service);
|
||||||
|
|
Loading…
Reference in New Issue