[icinga-checkins] icinga.org: icinga2/master: Remove Host:: OnInitCompleted and clean up the classes' constructors.

git at icinga.org git at icinga.org
Mon Feb 11 14:02:07 CET 2013


Module: icinga2
Branch: master
Commit: 2501ff805ae305e571bec30d9639a05ddbddfd2c
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=2501ff805ae305e571bec30d9639a05ddbddfd2c

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Mon Feb 11 14:01:52 2013 +0100

Remove Host::OnInitCompleted and clean up the classes' constructors.

Fixes #3678

---

 lib/base/dynamicobject.cpp  |    3 ---
 lib/base/dynamicobject.h    |    3 ---
 lib/base/dynamictype.cpp    |    3 ---
 lib/icinga/host.cpp         |   11 ++---------
 lib/icinga/host.h           |    1 -
 lib/icinga/hostgroup.cpp    |    5 ++++-
 lib/icinga/hostgroup.h      |    4 +---
 lib/icinga/notification.cpp |    6 ++++++
 lib/icinga/notification.h   |    3 +++
 lib/icinga/service.cpp      |    7 +------
 lib/icinga/servicegroup.cpp |    5 ++++-
 lib/icinga/servicegroup.h   |    4 +---
 12 files changed, 22 insertions(+), 33 deletions(-)

diff --git a/lib/base/dynamicobject.cpp b/lib/base/dynamicobject.cpp
index 569ff9e..b3ad740 100644
--- a/lib/base/dynamicobject.cpp
+++ b/lib/base/dynamicobject.cpp
@@ -484,9 +484,6 @@ void DynamicObject::FlushTx(void)
 void DynamicObject::OnAttributeChanged(const String&, const Value&)
 { }
 
-void DynamicObject::OnInitCompleted(void)
-{ }
-
 DynamicObject::Ptr DynamicObject::GetObject(const String& type, const String& name)
 {
 	DynamicType::Ptr dtype = DynamicType::GetByName(type);
diff --git a/lib/base/dynamicobject.h b/lib/base/dynamicobject.h
index 21e00c1..7260efa 100644
--- a/lib/base/dynamicobject.h
+++ b/lib/base/dynamicobject.h
@@ -133,7 +133,6 @@ public:
 
 protected:
 	virtual void OnAttributeChanged(const String& name, const Value& oldValue);
-	virtual void OnInitCompleted(void);
 
 private:
 	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
 	 * constructor has to be able to insert objects into this list. */
 	static set<DynamicObject *> m_ModifiedObjects;
-
-	friend class DynamicType; /* for OnInitCompleted */
 };
 
 }
diff --git a/lib/base/dynamictype.cpp b/lib/base/dynamictype.cpp
index 8cb5eda..05efe7b 100644
--- a/lib/base/dynamictype.cpp
+++ b/lib/base/dynamictype.cpp
@@ -93,9 +93,6 @@ DynamicObject::Ptr DynamicType::CreateObject(const Dictionary::Ptr& serializedUp
 	/* apply the object's non-config attributes */
 	obj->ApplyUpdate(serializedUpdate, Attribute_All & ~Attribute_Config);
 
-	/* notify the object that it's "ready" */
-	obj->OnInitCompleted();
-
 	return obj;
 }
 
diff --git a/lib/icinga/host.cpp b/lib/icinga/host.cpp
index 7420993..b0df21b 100644
--- a/lib/icinga/host.cpp
+++ b/lib/icinga/host.cpp
@@ -27,7 +27,7 @@ bool Host::m_ServicesCacheValid = true;
 REGISTER_SCRIPTFUNCTION("native::ValidateServiceDictionary", &Host::ValidateServiceDictionary);
 
 static AttributeDescription hostAttributes[] = {
-	{ "convenience_services", Attribute_Transient }
+	{ "slave_services", Attribute_Transient }
 };
 
 REGISTER_TYPE(Host, hostAttributes);
@@ -36,18 +36,11 @@ Host::Host(const Dictionary::Ptr& properties)
 	: DynamicObject(properties)
 { }
 
-void Host::OnInitCompleted(void)
-{
-	HostGroup::InvalidateMembersCache();
-
-	UpdateSlaveServices();
-}
-
 Host::~Host(void)
 {
 	HostGroup::InvalidateMembersCache();
 
-	Dictionary::Ptr services = Get("convenience_services");
+	Dictionary::Ptr services = Get("slave_services");
 
 	if (services) {
 		ConfigItem::Ptr service;
diff --git a/lib/icinga/host.h b/lib/icinga/host.h
index 472a1cd..7b4d181 100644
--- a/lib/icinga/host.h
+++ b/lib/icinga/host.h
@@ -37,7 +37,6 @@ public:
 	typedef weak_ptr<Host> WeakPtr;
 
 	Host(const Dictionary::Ptr& properties);
-	void OnInitCompleted(void);
 	~Host(void);
 
 	static bool Exists(const String& name);
diff --git a/lib/icinga/hostgroup.cpp b/lib/icinga/hostgroup.cpp
index b09946d..1e692e6 100644
--- a/lib/icinga/hostgroup.cpp
+++ b/lib/icinga/hostgroup.cpp
@@ -26,6 +26,10 @@ bool HostGroup::m_MembersCacheValid = true;
 
 REGISTER_TYPE(HostGroup, NULL);
 
+HostGroup::HostGroup(const Dictionary::Ptr& properties)
+	: DynamicObject(properties)
+{ }
+
 String HostGroup::GetDisplayName(void) const
 {
 	String value = Get("alias");
@@ -112,4 +116,3 @@ void HostGroup::ValidateMembersCache(void)
 
 	m_MembersCacheValid = true;
 }
-
diff --git a/lib/icinga/hostgroup.h b/lib/icinga/hostgroup.h
index a3c2876..1785443 100644
--- a/lib/icinga/hostgroup.h
+++ b/lib/icinga/hostgroup.h
@@ -34,9 +34,7 @@ public:
 	typedef shared_ptr<HostGroup> Ptr;
 	typedef weak_ptr<HostGroup> WeakPtr;
 
-	HostGroup(const Dictionary::Ptr& properties)
-		: DynamicObject(properties)
-	{ }
+	HostGroup(const Dictionary::Ptr& properties);;
 
 	static bool Exists(const String& name);
 	static HostGroup::Ptr GetByName(const String& name);
diff --git a/lib/icinga/notification.cpp b/lib/icinga/notification.cpp
index 905e857..046d8c0 100644
--- a/lib/icinga/notification.cpp
+++ b/lib/icinga/notification.cpp
@@ -108,3 +108,9 @@ void Notification::NotificationCompletedHandler(const ScriptTask::Ptr& task)
 		Logger::Write(LogWarning, "icinga", message);
 	}
 }
+
+void Notification::OnAttributeChanged(const String& name, const Value& oldValue)
+{
+	if (name == "host_name" || name == "service")
+		Service::InvalidateNotificationsCache();
+}
diff --git a/lib/icinga/notification.h b/lib/icinga/notification.h
index f91ca94..ae60718 100644
--- a/lib/icinga/notification.h
+++ b/lib/icinga/notification.h
@@ -62,6 +62,9 @@ public:
 
 	void SendNotification(NotificationType type);
 
+protected:
+	void OnAttributeChanged(const String& name, const Value& oldValue);
+
 private:
 	set<ScriptTask::Ptr> m_Tasks;
 
diff --git a/lib/icinga/service.cpp b/lib/icinga/service.cpp
index da7b193..78bbb60 100644
--- a/lib/icinga/service.cpp
+++ b/lib/icinga/service.cpp
@@ -47,12 +47,7 @@ REGISTER_TYPE(Service, serviceAttributes);
 
 Service::Service(const Dictionary::Ptr& serializedObject)
 	: DynamicObject(serializedObject)
-{
-	ServiceGroup::InvalidateMembersCache();
-	Host::InvalidateServicesCache();
-	Service::InvalidateDowntimeCache();
-	Service::InvalidateCommentCache();
-}
+{ }
 
 Service::~Service(void)
 {
diff --git a/lib/icinga/servicegroup.cpp b/lib/icinga/servicegroup.cpp
index 3c4b091..bba8789 100644
--- a/lib/icinga/servicegroup.cpp
+++ b/lib/icinga/servicegroup.cpp
@@ -26,6 +26,10 @@ bool ServiceGroup::m_MembersCacheValid;
 
 REGISTER_TYPE(ServiceGroup, NULL);
 
+ServiceGroup::ServiceGroup(const Dictionary::Ptr& properties)
+	: DynamicObject(properties)
+{ }
+
 String ServiceGroup::GetDisplayName(void) const
 {
 	String value = Get("alias");
@@ -112,4 +116,3 @@ void ServiceGroup::ValidateMembersCache(void)
 
 	m_MembersCacheValid = true;
 }
-
diff --git a/lib/icinga/servicegroup.h b/lib/icinga/servicegroup.h
index b7ed563..631f943 100644
--- a/lib/icinga/servicegroup.h
+++ b/lib/icinga/servicegroup.h
@@ -34,9 +34,7 @@ public:
 	typedef shared_ptr<ServiceGroup> Ptr;
 	typedef weak_ptr<ServiceGroup> WeakPtr;
 
-	ServiceGroup(const Dictionary::Ptr& properties)
-		: DynamicObject(properties)
-	{ }
+	ServiceGroup(const Dictionary::Ptr& properties);
 
 	static bool Exists(const String& name);
 	static ServiceGroup::Ptr GetByName(const String& name);





More information about the icinga-checkins mailing list