]> granicus.if.org Git - icinga2/commitdiff
Remove Host::OnInitCompleted and clean up the classes' constructors.
authorGunnar Beutner <gunnar.beutner@netways.de>
Mon, 11 Feb 2013 13:01:52 +0000 (14:01 +0100)
committerGunnar Beutner <gunnar.beutner@netways.de>
Mon, 11 Feb 2013 13:01:52 +0000 (14:01 +0100)
Fixes #3678

12 files changed:
lib/base/dynamicobject.cpp
lib/base/dynamicobject.h
lib/base/dynamictype.cpp
lib/icinga/host.cpp
lib/icinga/host.h
lib/icinga/hostgroup.cpp
lib/icinga/hostgroup.h
lib/icinga/notification.cpp
lib/icinga/notification.h
lib/icinga/service.cpp
lib/icinga/servicegroup.cpp
lib/icinga/servicegroup.h

index 569ff9e70f5668fedc65fbc2da5c00d790f25938..b3ad74084591fad595737dbdc65a084fbe438135 100644 (file)
@@ -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);
index 21e00c1d13585b1a248dae958db05a9b2041b97a..7260efa6a9039435f298957e1956ec59d1b49a15 100644 (file)
@@ -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 */
 };
 
 }
index 8cb5edab004bfd1b6cb51d1b02274b9df42b7903..05efe7b5a6bdd0a389701329322909e27eb9cb24 100644 (file)
@@ -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;
 }
 
index 7420993486f4121d493999a213b3afb9affe7431..b0df21bbe4ce7720d3b3ac86b24546bdad6cc33e 100644 (file)
@@ -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;
index 472a1cdb56956f7d35fab4bc1193cabfcb9d8890..7b4d18139a490e5578c491dd549281b734da8796 100644 (file)
@@ -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);
index b09946d7c50cb8c74c1720ad87e7ea662efdc515..1e692e6dcbce47343e069b189ea7f5783d910761 100644 (file)
@@ -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;
 }
-
index a3c28760c53974a70e5603ac65590b451020a4bc..17854435699082342e6aedb8781709daaf452fe9 100644 (file)
@@ -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);
index 905e85723e49320363c76409b45f05e12457816d..046d8c06626feb43afc1b55cc276468cfc0330e6 100644 (file)
@@ -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();
+}
index f91ca946c819dbbfe77ecff906f246d64afb2d74..ae607183691d2b22396301c4a7af501c4ee0f3aa 100644 (file)
@@ -62,6 +62,9 @@ public:
 
        void SendNotification(NotificationType type);
 
+protected:
+       void OnAttributeChanged(const String& name, const Value& oldValue);
+
 private:
        set<ScriptTask::Ptr> m_Tasks;
 
index da7b1938449b85d16392d486406d91038475da24..78bbb60002fb008cfe0d69d41b73027db024ffbc 100644 (file)
@@ -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)
 {
index 3c4b091609ae2f7c513bcf9240b928557c17ff66..bba8789efd51139e724c31f66cc43eb49d9e3da7 100644 (file)
@@ -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;
 }
-
index b7ed563189223ae5f928541fe00fff4bbf0e53c2..631f943f905717e7a553c5842019b1cd18ce1b0e 100644 (file)
@@ -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);