mirror of https://github.com/Icinga/icinga2.git
Remove Host::OnInitCompleted and clean up the classes' constructors.
Fixes #3678
This commit is contained in:
parent
f6f771a3f6
commit
2501ff805a
|
@ -484,9 +484,6 @@ void DynamicObject::FlushTx(void)
|
||||||
void DynamicObject::OnAttributeChanged(const String&, const Value&)
|
void DynamicObject::OnAttributeChanged(const String&, const Value&)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
void DynamicObject::OnInitCompleted(void)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
DynamicObject::Ptr DynamicObject::GetObject(const String& type, const String& name)
|
DynamicObject::Ptr DynamicObject::GetObject(const String& type, const String& name)
|
||||||
{
|
{
|
||||||
DynamicType::Ptr dtype = DynamicType::GetByName(type);
|
DynamicType::Ptr dtype = DynamicType::GetByName(type);
|
||||||
|
|
|
@ -133,7 +133,6 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void OnAttributeChanged(const String& name, const Value& oldValue);
|
virtual void OnAttributeChanged(const String& name, const Value& oldValue);
|
||||||
virtual void OnInitCompleted(void);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void InternalSetAttribute(const String& name, const Value& data, double tx, bool allowEditConfig = false);
|
void InternalSetAttribute(const String& name, const Value& data, double tx, bool allowEditConfig = false);
|
||||||
|
@ -149,8 +148,6 @@ private:
|
||||||
/* This has to be a set of raw pointers because the DynamicObject
|
/* This has to be a set of raw pointers because the DynamicObject
|
||||||
* constructor has to be able to insert objects into this list. */
|
* constructor has to be able to insert objects into this list. */
|
||||||
static set<DynamicObject *> m_ModifiedObjects;
|
static set<DynamicObject *> m_ModifiedObjects;
|
||||||
|
|
||||||
friend class DynamicType; /* for OnInitCompleted */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,9 +93,6 @@ DynamicObject::Ptr DynamicType::CreateObject(const Dictionary::Ptr& serializedUp
|
||||||
/* apply the object's non-config attributes */
|
/* apply the object's non-config attributes */
|
||||||
obj->ApplyUpdate(serializedUpdate, Attribute_All & ~Attribute_Config);
|
obj->ApplyUpdate(serializedUpdate, Attribute_All & ~Attribute_Config);
|
||||||
|
|
||||||
/* notify the object that it's "ready" */
|
|
||||||
obj->OnInitCompleted();
|
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ bool Host::m_ServicesCacheValid = true;
|
||||||
REGISTER_SCRIPTFUNCTION("native::ValidateServiceDictionary", &Host::ValidateServiceDictionary);
|
REGISTER_SCRIPTFUNCTION("native::ValidateServiceDictionary", &Host::ValidateServiceDictionary);
|
||||||
|
|
||||||
static AttributeDescription hostAttributes[] = {
|
static AttributeDescription hostAttributes[] = {
|
||||||
{ "convenience_services", Attribute_Transient }
|
{ "slave_services", Attribute_Transient }
|
||||||
};
|
};
|
||||||
|
|
||||||
REGISTER_TYPE(Host, hostAttributes);
|
REGISTER_TYPE(Host, hostAttributes);
|
||||||
|
@ -36,18 +36,11 @@ Host::Host(const Dictionary::Ptr& properties)
|
||||||
: DynamicObject(properties)
|
: DynamicObject(properties)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
void Host::OnInitCompleted(void)
|
|
||||||
{
|
|
||||||
HostGroup::InvalidateMembersCache();
|
|
||||||
|
|
||||||
UpdateSlaveServices();
|
|
||||||
}
|
|
||||||
|
|
||||||
Host::~Host(void)
|
Host::~Host(void)
|
||||||
{
|
{
|
||||||
HostGroup::InvalidateMembersCache();
|
HostGroup::InvalidateMembersCache();
|
||||||
|
|
||||||
Dictionary::Ptr services = Get("convenience_services");
|
Dictionary::Ptr services = Get("slave_services");
|
||||||
|
|
||||||
if (services) {
|
if (services) {
|
||||||
ConfigItem::Ptr service;
|
ConfigItem::Ptr service;
|
||||||
|
|
|
@ -37,7 +37,6 @@ public:
|
||||||
typedef weak_ptr<Host> WeakPtr;
|
typedef weak_ptr<Host> WeakPtr;
|
||||||
|
|
||||||
Host(const Dictionary::Ptr& properties);
|
Host(const Dictionary::Ptr& properties);
|
||||||
void OnInitCompleted(void);
|
|
||||||
~Host(void);
|
~Host(void);
|
||||||
|
|
||||||
static bool Exists(const String& name);
|
static bool Exists(const String& name);
|
||||||
|
|
|
@ -26,6 +26,10 @@ bool HostGroup::m_MembersCacheValid = true;
|
||||||
|
|
||||||
REGISTER_TYPE(HostGroup, NULL);
|
REGISTER_TYPE(HostGroup, NULL);
|
||||||
|
|
||||||
|
HostGroup::HostGroup(const Dictionary::Ptr& properties)
|
||||||
|
: DynamicObject(properties)
|
||||||
|
{ }
|
||||||
|
|
||||||
String HostGroup::GetDisplayName(void) const
|
String HostGroup::GetDisplayName(void) const
|
||||||
{
|
{
|
||||||
String value = Get("alias");
|
String value = Get("alias");
|
||||||
|
@ -112,4 +116,3 @@ void HostGroup::ValidateMembersCache(void)
|
||||||
|
|
||||||
m_MembersCacheValid = true;
|
m_MembersCacheValid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,9 +34,7 @@ public:
|
||||||
typedef shared_ptr<HostGroup> Ptr;
|
typedef shared_ptr<HostGroup> Ptr;
|
||||||
typedef weak_ptr<HostGroup> WeakPtr;
|
typedef weak_ptr<HostGroup> WeakPtr;
|
||||||
|
|
||||||
HostGroup(const Dictionary::Ptr& properties)
|
HostGroup(const Dictionary::Ptr& properties);;
|
||||||
: DynamicObject(properties)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
static bool Exists(const String& name);
|
static bool Exists(const String& name);
|
||||||
static HostGroup::Ptr GetByName(const String& name);
|
static HostGroup::Ptr GetByName(const String& name);
|
||||||
|
|
|
@ -108,3 +108,9 @@ void Notification::NotificationCompletedHandler(const ScriptTask::Ptr& task)
|
||||||
Logger::Write(LogWarning, "icinga", message);
|
Logger::Write(LogWarning, "icinga", message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Notification::OnAttributeChanged(const String& name, const Value& oldValue)
|
||||||
|
{
|
||||||
|
if (name == "host_name" || name == "service")
|
||||||
|
Service::InvalidateNotificationsCache();
|
||||||
|
}
|
||||||
|
|
|
@ -62,6 +62,9 @@ public:
|
||||||
|
|
||||||
void SendNotification(NotificationType type);
|
void SendNotification(NotificationType type);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void OnAttributeChanged(const String& name, const Value& oldValue);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
set<ScriptTask::Ptr> m_Tasks;
|
set<ScriptTask::Ptr> m_Tasks;
|
||||||
|
|
||||||
|
|
|
@ -47,12 +47,7 @@ REGISTER_TYPE(Service, serviceAttributes);
|
||||||
|
|
||||||
Service::Service(const Dictionary::Ptr& serializedObject)
|
Service::Service(const Dictionary::Ptr& serializedObject)
|
||||||
: DynamicObject(serializedObject)
|
: DynamicObject(serializedObject)
|
||||||
{
|
{ }
|
||||||
ServiceGroup::InvalidateMembersCache();
|
|
||||||
Host::InvalidateServicesCache();
|
|
||||||
Service::InvalidateDowntimeCache();
|
|
||||||
Service::InvalidateCommentCache();
|
|
||||||
}
|
|
||||||
|
|
||||||
Service::~Service(void)
|
Service::~Service(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -26,6 +26,10 @@ bool ServiceGroup::m_MembersCacheValid;
|
||||||
|
|
||||||
REGISTER_TYPE(ServiceGroup, NULL);
|
REGISTER_TYPE(ServiceGroup, NULL);
|
||||||
|
|
||||||
|
ServiceGroup::ServiceGroup(const Dictionary::Ptr& properties)
|
||||||
|
: DynamicObject(properties)
|
||||||
|
{ }
|
||||||
|
|
||||||
String ServiceGroup::GetDisplayName(void) const
|
String ServiceGroup::GetDisplayName(void) const
|
||||||
{
|
{
|
||||||
String value = Get("alias");
|
String value = Get("alias");
|
||||||
|
@ -112,4 +116,3 @@ void ServiceGroup::ValidateMembersCache(void)
|
||||||
|
|
||||||
m_MembersCacheValid = true;
|
m_MembersCacheValid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,9 +34,7 @@ public:
|
||||||
typedef shared_ptr<ServiceGroup> Ptr;
|
typedef shared_ptr<ServiceGroup> Ptr;
|
||||||
typedef weak_ptr<ServiceGroup> WeakPtr;
|
typedef weak_ptr<ServiceGroup> WeakPtr;
|
||||||
|
|
||||||
ServiceGroup(const Dictionary::Ptr& properties)
|
ServiceGroup(const Dictionary::Ptr& properties);
|
||||||
: DynamicObject(properties)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
static bool Exists(const String& name);
|
static bool Exists(const String& name);
|
||||||
static ServiceGroup::Ptr GetByName(const String& name);
|
static ServiceGroup::Ptr GetByName(const String& name);
|
||||||
|
|
Loading…
Reference in New Issue