]> granicus.if.org Git - icinga2/commitdiff
Renamed ConfigObject to DynamicObject.
authorGunnar Beutner <gunnar.beutner@netways.de>
Mon, 30 Jul 2012 08:17:29 +0000 (10:17 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Mon, 30 Jul 2012 08:17:29 +0000 (10:17 +0200)
30 files changed:
base/Makefile.am
base/base.vcxproj
base/base.vcxproj.filters
base/component.cpp
base/component.h
base/dynamicobject.cpp [moved from base/configobject.cpp with 69% similarity]
base/dynamicobject.h [moved from base/configobject.h with 77% similarity]
base/i2-base.h
base/logger.cpp
base/logger.h
cib/host.cpp
cib/host.h
cib/hostgroup.cpp
cib/hostgroup.h
cib/nagioschecktask.cpp
cib/service.cpp
cib/service.h
cib/servicegroup.cpp
cib/servicegroup.h
components/checker/checkercomponent.cpp
components/cibsync/cibsynccomponent.cpp
components/cibsync/cibsynccomponent.h
components/compat/compatcomponent.cpp
components/convenience/conveniencecomponent.cpp
components/delegation/delegationcomponent.cpp
components/delegation/delegationcomponent.h
components/discovery/discoverycomponent.cpp
dyn/configitem.cpp
dyn/configitem.h
icinga/icingaapplication.cpp

index 2b64ffcfdadab39555e7c7a19ae88bf70be63fb5..9b5d72b5760fd8d65068f0aa25592ca482528d04 100644 (file)
@@ -10,10 +10,10 @@ libbase_la_SOURCES =  \
        asynctask.h \
        component.cpp \
        component.h \
-       configobject.cpp \
-       configobject.h \
        dictionary.cpp \
        dictionary.h \
+       dynamicobject.cpp \
+       dynamicobject.h \
        event.cpp \
        event.h \
        exception.cpp \
index ed034480a6d5fb81b48914c29b567797bc02556f..8545cbd00d1692a23b63a60a7044260a0c808fbb 100644 (file)
@@ -13,7 +13,7 @@
   <ItemGroup>
     <ClCompile Include="application.cpp" />
     <ClCompile Include="component.cpp" />
-    <ClCompile Include="configobject.cpp" />
+    <ClCompile Include="dynamicobject.cpp" />
     <ClCompile Include="dictionary.cpp" />
     <ClCompile Include="event.cpp" />
     <ClCompile Include="exception.cpp" />
@@ -47,7 +47,7 @@
     <ClInclude Include="application.h" />
     <ClInclude Include="asynctask.h" />
     <ClInclude Include="component.h" />
-    <ClInclude Include="configobject.h" />
+    <ClInclude Include="dynamicobject.h" />
     <ClInclude Include="dictionary.h" />
     <ClInclude Include="event.h" />
     <ClInclude Include="fifo.h" />
index 0a152dbdf30924f584341cdc636d7b72bbf642d9..2fd084fd517df39efe6d8ac8e20239093477345e 100644 (file)
@@ -7,9 +7,6 @@
     <ClCompile Include="component.cpp">
       <Filter>Quelldateien</Filter>
     </ClCompile>
-    <ClCompile Include="configobject.cpp">
-      <Filter>Quelldateien</Filter>
-    </ClCompile>
     <ClCompile Include="dictionary.cpp">
       <Filter>Quelldateien</Filter>
     </ClCompile>
@@ -85,6 +82,9 @@
     <ClCompile Include="netstring.cpp">
       <Filter>Quelldateien</Filter>
     </ClCompile>
+    <ClCompile Include="dynamicobject.cpp">
+      <Filter>Quelldateien</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="application.h">
@@ -96,9 +96,6 @@
     <ClInclude Include="component.h">
       <Filter>Headerdateien</Filter>
     </ClInclude>
-    <ClInclude Include="configobject.h">
-      <Filter>Headerdateien</Filter>
-    </ClInclude>
     <ClInclude Include="dictionary.h">
       <Filter>Headerdateien</Filter>
     </ClInclude>
     <ClInclude Include="netstring.h">
       <Filter>Headerdateien</Filter>
     </ClInclude>
+    <ClInclude Include="dynamicobject.h">
+      <Filter>Headerdateien</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <Filter Include="Quelldateien">
index 304ea20842e43fb0f79d16490eb610a0f5b99b26..55c1c26f47f831b429be8c20d6913564a956992c 100644 (file)
@@ -27,7 +27,7 @@ REGISTER_CLASS(Component);
  * Constructor for the component class.
  */
 Component::Component(const Dictionary::Ptr& properties)
-       : ConfigObject(properties)
+       : DynamicObject(properties)
 {
        assert(Application::IsMainThread());
 
@@ -136,7 +136,7 @@ void Component::AddSearchDir(const string& componentDirectory)
  *
  * @returns The configuration.
  */
-ConfigObject::Ptr IComponent::GetConfig(void) const
+DynamicObject::Ptr IComponent::GetConfig(void) const
 {
        return m_Config->GetSelf();
 }
index 9f106a6cad2661f1e8de32e6a26eadd0b876cd88..2f7f9c25f05c10a065f84fca61aabc14884ff50c 100644 (file)
@@ -33,10 +33,10 @@ public:
        virtual void Stop(void);
 
 protected:
-       ConfigObject::Ptr GetConfig(void) const;
+       DynamicObject::Ptr GetConfig(void) const;
 
 private:
-       ConfigObject *m_Config;
+       DynamicObject *m_Config;
 
        friend class Component;
 };
@@ -47,7 +47,7 @@ private:
  *
  * @ingroup base
  */
-class I2_BASE_API Component : public ConfigObject
+class I2_BASE_API Component : public DynamicObject
 {
 public:
        typedef shared_ptr<Component> Ptr;
similarity index 69%
rename from base/configobject.cpp
rename to base/dynamicobject.cpp
index 5303b7a3edd2c82223c9961b7d061683c3b7a978..44adff2e6604c606669214399bd0b6b63b9d0cab 100644 (file)
 
 using namespace icinga;
 
-map<pair<string, string>, Dictionary::Ptr> ConfigObject::m_PersistentTags;
-boost::signal<void (const ConfigObject::Ptr&)> ConfigObject::OnCommitted;
-boost::signal<void (const ConfigObject::Ptr&)> ConfigObject::OnRemoved;
+map<pair<string, string>, Dictionary::Ptr> DynamicObject::m_PersistentTags;
+boost::signal<void (const DynamicObject::Ptr&)> DynamicObject::OnCommitted;
+boost::signal<void (const DynamicObject::Ptr&)> DynamicObject::OnRemoved;
 
-ConfigObject::ConfigObject(const Dictionary::Ptr& properties)
+DynamicObject::DynamicObject(const Dictionary::Ptr& properties)
        : m_Properties(properties), m_Tags(boost::make_shared<Dictionary>())
 {
        /* restore the object's tags */
@@ -37,88 +37,88 @@ ConfigObject::ConfigObject(const Dictionary::Ptr& properties)
        }
 }
 
-void ConfigObject::SetProperties(const Dictionary::Ptr& properties)
+void DynamicObject::SetProperties(const Dictionary::Ptr& properties)
 {
        m_Properties = properties;
 }
 
-Dictionary::Ptr ConfigObject::GetProperties(void) const
+Dictionary::Ptr DynamicObject::GetProperties(void) const
 {
        return m_Properties;
 }
 
-void ConfigObject::SetTags(const Dictionary::Ptr& tags)
+void DynamicObject::SetTags(const Dictionary::Ptr& tags)
 {
        m_Tags = tags;
 }
 
-Dictionary::Ptr ConfigObject::GetTags(void) const
+Dictionary::Ptr DynamicObject::GetTags(void) const
 {
        return m_Tags;
 }
 
-string ConfigObject::GetType(void) const
+string DynamicObject::GetType(void) const
 {
        string type;
        GetProperties()->Get("__type", &type);
        return type;
 }
 
-string ConfigObject::GetName(void) const
+string DynamicObject::GetName(void) const
 {
        string name;
        GetProperties()->Get("__name", &name);
        return name;
 }
 
-bool ConfigObject::IsLocal(void) const
+bool DynamicObject::IsLocal(void) const
 {
        bool value = false;
        GetProperties()->Get("__local", &value);
        return value;
 }
 
-bool ConfigObject::IsAbstract(void) const
+bool DynamicObject::IsAbstract(void) const
 {
        bool value = false;
        GetProperties()->Get("__abstract", &value);
        return value;
 }
 
-void ConfigObject::SetSource(const string& value)
+void DynamicObject::SetSource(const string& value)
 {
        GetProperties()->Set("__source", value);
 }
 
-string ConfigObject::GetSource(void) const
+string DynamicObject::GetSource(void) const
 {
        string value;
        GetProperties()->Get("__source", &value);
        return value;
 }
 
-void ConfigObject::SetCommitTimestamp(double ts)
+void DynamicObject::SetCommitTimestamp(double ts)
 {
        GetProperties()->Set("__tx", ts);
 }
 
-double ConfigObject::GetCommitTimestamp(void) const
+double DynamicObject::GetCommitTimestamp(void) const
 {
        double value = 0;
        GetProperties()->Get("__tx", &value);
        return value;
 }
 
-void ConfigObject::Commit(void)
+void DynamicObject::Commit(void)
 {
        assert(Application::IsMainThread());
 
-       ConfigObject::Ptr dobj = GetObject(GetType(), GetName());
-       ConfigObject::Ptr self = GetSelf();
+       DynamicObject::Ptr dobj = GetObject(GetType(), GetName());
+       DynamicObject::Ptr self = GetSelf();
        assert(!dobj || dobj == self);
 
-       pair<ConfigObject::TypeMap::iterator, bool> ti;
-       ti = GetAllObjects().insert(make_pair(GetType(), ConfigObject::NameMap()));
+       pair<DynamicObject::TypeMap::iterator, bool> ti;
+       ti = GetAllObjects().insert(make_pair(GetType(), DynamicObject::NameMap()));
        ti.first->second.insert(make_pair(GetName(), GetSelf()));
 
        SetCommitTimestamp(Utility::GetTime());
@@ -126,17 +126,17 @@ void ConfigObject::Commit(void)
        OnCommitted(GetSelf());
 }
 
-void ConfigObject::Unregister(void)
+void DynamicObject::Unregister(void)
 {
        assert(Application::IsMainThread());
 
-       ConfigObject::TypeMap::iterator tt;
+       DynamicObject::TypeMap::iterator tt;
        tt = GetAllObjects().find(GetType());
 
        if (tt == GetAllObjects().end())
                return;
 
-       ConfigObject::NameMap::iterator nt = tt->second.find(GetName());
+       DynamicObject::NameMap::iterator nt = tt->second.find(GetName());
 
        if (nt == tt->second.end())
                return;
@@ -146,41 +146,41 @@ void ConfigObject::Unregister(void)
        OnRemoved(GetSelf());
 }
 
-ConfigObject::Ptr ConfigObject::GetObject(const string& type, const string& name)
+DynamicObject::Ptr DynamicObject::GetObject(const string& type, const string& name)
 {
-       ConfigObject::TypeMap::iterator tt;
+       DynamicObject::TypeMap::iterator tt;
        tt = GetAllObjects().find(type);
 
        if (tt == GetAllObjects().end())
-               return ConfigObject::Ptr();
+               return DynamicObject::Ptr();
 
-       ConfigObject::NameMap::iterator nt = tt->second.find(name);              
+       DynamicObject::NameMap::iterator nt = tt->second.find(name);              
 
        if (nt == tt->second.end())
-               return ConfigObject::Ptr();
+               return DynamicObject::Ptr();
 
        return nt->second;
 }
 
-pair<ConfigObject::TypeMap::iterator, ConfigObject::TypeMap::iterator> ConfigObject::GetTypes(void)
+pair<DynamicObject::TypeMap::iterator, DynamicObject::TypeMap::iterator> DynamicObject::GetTypes(void)
 {
        return make_pair(GetAllObjects().begin(), GetAllObjects().end());
 }
 
-pair<ConfigObject::NameMap::iterator, ConfigObject::NameMap::iterator> ConfigObject::GetObjects(const string& type)
+pair<DynamicObject::NameMap::iterator, DynamicObject::NameMap::iterator> DynamicObject::GetObjects(const string& type)
 {
-       pair<ConfigObject::TypeMap::iterator, bool> ti;
-       ti = GetAllObjects().insert(make_pair(type, ConfigObject::NameMap()));
+       pair<DynamicObject::TypeMap::iterator, bool> ti;
+       ti = GetAllObjects().insert(make_pair(type, DynamicObject::NameMap()));
 
        return make_pair(ti.first->second.begin(), ti.first->second.end());
 }
 
-void ConfigObject::RemoveTag(const string& key)
+void DynamicObject::RemoveTag(const string& key)
 {
        GetTags()->Remove(key);
 }
 
-ScriptTask::Ptr ConfigObject::InvokeMethod(const string& method,
+ScriptTask::Ptr DynamicObject::InvokeMethod(const string& method,
     const vector<Variant>& arguments, ScriptTask::CompletionCallback callback)
 {
        Dictionary::Ptr methods;
@@ -199,7 +199,7 @@ ScriptTask::Ptr ConfigObject::InvokeMethod(const string& method,
        return task;
 }
 
-void ConfigObject::DumpObjects(const string& filename)
+void DynamicObject::DumpObjects(const string& filename)
 {
        Logger::Write(LogInformation, "base", "Dumping program state to file '" + filename + "'");
 
@@ -211,11 +211,11 @@ void ConfigObject::DumpObjects(const string& filename)
 
        FIFO::Ptr fifo = boost::make_shared<FIFO>();
 
-       ConfigObject::TypeMap::iterator tt;
+       DynamicObject::TypeMap::iterator tt;
        for (tt = GetAllObjects().begin(); tt != GetAllObjects().end(); tt++) {
-               ConfigObject::NameMap::iterator nt;
+               DynamicObject::NameMap::iterator nt;
                for (nt = tt->second.begin(); nt != tt->second.end(); nt++) {
-                       ConfigObject::Ptr object = nt->second;
+                       DynamicObject::Ptr object = nt->second;
 
                        Dictionary::Ptr persistentObject = boost::make_shared<Dictionary>();
 
@@ -249,10 +249,8 @@ void ConfigObject::DumpObjects(const string& filename)
        }
 }
 
-void ConfigObject::RestoreObjects(const string& filename)
+void DynamicObject::RestoreObjects(const string& filename)
 {
-       assert(GetAllObjects().empty());
-
        Logger::Write(LogInformation, "base", "Restoring program state from file '" + filename + "'");
 
        std::ifstream fp;
@@ -290,7 +288,7 @@ void ConfigObject::RestoreObjects(const string& filename)
 
                Dictionary::Ptr properties;
                if (persistentObject->Get("properties", &properties)) {
-                       ConfigObject::Ptr object = Create(type, properties);
+                       DynamicObject::Ptr object = Create(type, properties);
                        object->SetTags(tags);
                        object->Commit();
                } else {
@@ -301,33 +299,34 @@ void ConfigObject::RestoreObjects(const string& filename)
        }
 }
 
-ConfigObject::TypeMap& ConfigObject::GetAllObjects(void)
+DynamicObject::TypeMap& DynamicObject::GetAllObjects(void)
 {
        static TypeMap objects;
        return objects;
 }
 
-ConfigObject::ClassMap& ConfigObject::GetClasses(void)
+DynamicObject::ClassMap& DynamicObject::GetClasses(void)
 {
        static ClassMap classes;
        return classes;
 }
 
-void ConfigObject::RegisterClass(const string& type, ConfigObject::Factory factory)
+void DynamicObject::RegisterClass(const string& type, DynamicObject::Factory factory)
 {
-       GetClasses()[type] = factory;
+       if (GetObjects(type).first != GetObjects(type).second)
+               throw_exception(runtime_error("Cannot register class for type '" +
+                   type + "': Objects of this type already exist."));
 
-       /* TODO: upgrade existing objects */
+       GetClasses()[type] = factory;
 }
 
-ConfigObject::Ptr ConfigObject::Create(const string& type, const Dictionary::Ptr& properties)
+DynamicObject::Ptr DynamicObject::Create(const string& type, const Dictionary::Ptr& properties)
 {
-       ConfigObject::ClassMap::iterator it;
+       DynamicObject::ClassMap::iterator it;
        it = GetClasses().find(type);
 
        if (it != GetClasses().end())
                return it->second(properties);
        else
-               return boost::make_shared<ConfigObject>(properties);
+               return boost::make_shared<DynamicObject>(properties);
 }
-
similarity index 77%
rename from base/configobject.h
rename to base/dynamicobject.h
index 16b4be97f1262b69a41b0909cb584e4ec1169ee0..f61f08f08096930e12ba3ffa8692fab99a2d720b 100644 (file)
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
  ******************************************************************************/
 
-#ifndef CONFIGOBJECT_H
-#define CONFIGOBJECT_H
+#ifndef DYNAMICOBJECT_H
+#define DYNAMICOBJECT_H
 
 namespace icinga
 {
 
 /**
- * A configuration object.
+ * A dynamic object that can be instantiated from the configuration file.
  *
  * @ingroup base
  */
-class I2_BASE_API ConfigObject : public Object
+class I2_BASE_API DynamicObject : public Object
 {
 public:
-       typedef shared_ptr<ConfigObject> Ptr;
-       typedef weak_ptr<ConfigObject> WeakPtr;
+       typedef shared_ptr<DynamicObject> Ptr;
+       typedef weak_ptr<DynamicObject> WeakPtr;
 
-       typedef function<ConfigObject::Ptr (const Dictionary::Ptr&)> Factory;
+       typedef function<DynamicObject::Ptr (const Dictionary::Ptr&)> Factory;
 
        typedef map<string, Factory> ClassMap;
-       typedef map<string, ConfigObject::Ptr> NameMap;
+       typedef map<string, DynamicObject::Ptr> NameMap;
        typedef map<string, NameMap> TypeMap;
 
-       ConfigObject(const Dictionary::Ptr& properties);
+       DynamicObject(const Dictionary::Ptr& properties);
 
        void SetProperties(const Dictionary::Ptr& config);
        Dictionary::Ptr GetProperties(void) const;
@@ -68,7 +68,7 @@ public:
 
        void RemoveTag(const string& key);
 
-       ScriptTask::Ptr InvokeMethod(const string& hook,
+       ScriptTask::Ptr InvokeMethod(const string& method,
            const vector<Variant>& arguments, ScriptTask::CompletionCallback callback);
 
        string GetType(void) const;
@@ -85,7 +85,7 @@ public:
        void Commit(void);
        void Unregister(void);
 
-       static ConfigObject::Ptr GetObject(const string& type, const string& name);
+       static DynamicObject::Ptr GetObject(const string& type, const string& name);
        static pair<TypeMap::iterator, TypeMap::iterator> GetTypes(void);
        static pair<NameMap::iterator, NameMap::iterator> GetObjects(const string& type);
 
@@ -93,10 +93,10 @@ public:
        static void RestoreObjects(const string& filename);
 
        static void RegisterClass(const string& type, Factory factory);
-       static ConfigObject::Ptr Create(const string& type, const Dictionary::Ptr& properties);
+       static DynamicObject::Ptr Create(const string& type, const Dictionary::Ptr& properties);
 
-       static boost::signal<void (const ConfigObject::Ptr&)> OnCommitted;
-       static boost::signal<void (const ConfigObject::Ptr&)> OnRemoved;
+       static boost::signal<void (const DynamicObject::Ptr&)> OnCommitted;
+       static boost::signal<void (const DynamicObject::Ptr&)> OnRemoved;
 
 private:
        static ClassMap& GetClasses(void);
@@ -113,9 +113,9 @@ private:
 class RegisterClassHelper
 {
 public:
-       RegisterClassHelper(const string& name, ConfigObject::Factory factory)
+       RegisterClassHelper(const string& name, DynamicObject::Factory factory)
        {
-               ConfigObject::RegisterClass(name, factory);
+               DynamicObject::RegisterClass(name, factory);
        }
 };
 
@@ -124,4 +124,4 @@ public:
 
 }
 
-#endif /* CONFIGOBJECT_H */
+#endif /* DYNAMICOBJECT_H */
index fb236bd60cf85e1e04d5a407e3a89ca9b74fe16f..62b96d9353f916025c077ebdb9a98a4dad14cb85 100644 (file)
@@ -184,7 +184,7 @@ namespace tuples = boost::tuples;
 #include "process.h"
 #include "scriptfunction.h"
 #include "scripttask.h"
-#include "configobject.h"
+#include "dynamicobject.h"
 #include "logger.h"
 #include "application.h"
 #include "component.h"
index 28bc0d8a2e7961a91c0d590196d5edd793e83b86..56718b9f6a2708b81fb7e21232e0d0cedaeca602 100644 (file)
@@ -30,7 +30,7 @@ REGISTER_CLASS(Logger);
  *                    to this logger.
  */
 Logger::Logger(const Dictionary::Ptr& properties)
-       : ConfigObject(properties)
+       : DynamicObject(properties)
 {
        if (!IsLocal())
                throw_exception(runtime_error("Logger objects must be local."));
@@ -107,8 +107,8 @@ LogSeverity Logger::GetMinSeverity(void) const
  */
 void Logger::ForwardLogEntry(const LogEntry& entry)
 {
-       ConfigObject::Ptr object;
-       BOOST_FOREACH(tie(tuples::ignore, object), ConfigObject::GetObjects("Logger")) {
+       DynamicObject::Ptr object;
+       BOOST_FOREACH(tie(tuples::ignore, object), DynamicObject::GetObjects("Logger")) {
                Logger::Ptr logger = dynamic_pointer_cast<Logger>(object);
 
                if (entry.Severity >= logger->GetMinSeverity())
index 7b3f3d49627bbcbb229c879627d02beac60ba737..524bc8d21823a9ac632c335bae6632c852b458d8 100644 (file)
@@ -60,15 +60,15 @@ public:
        virtual void ProcessLogEntry(const LogEntry& entry) = 0;
 
 protected:
-       ConfigObject::Ptr GetConfig(void) const;
+       DynamicObject::Ptr GetConfig(void) const;
 
 private:
-       ConfigObject *m_Config;
+       DynamicObject *m_Config;
 
        friend class Logger;
 };
 
-class I2_BASE_API Logger : public ConfigObject
+class I2_BASE_API Logger : public DynamicObject
 {
 public:
        typedef shared_ptr<Logger> Ptr;
index 2d69f36f43eddcca468e9472210135b2150bb037..c2b4c592d3ccf38c149013ecb5631684bdd64ef3 100644 (file)
@@ -35,12 +35,12 @@ string Host::GetAlias(void) const
 
 bool Host::Exists(const string& name)
 {
-       return (ConfigObject::GetObject("Host", name));
+       return (DynamicObject::GetObject("Host", name));
 }
 
 Host::Ptr Host::GetByName(const string& name)
 {
-       ConfigObject::Ptr configObject = ConfigObject::GetObject("Host", name);
+       DynamicObject::Ptr configObject = DynamicObject::GetObject("Host", name);
 
        if (!configObject)
                throw_exception(invalid_argument("Host '" + name + "' does not exist."));
index 95101a0967584cb4a209dfa37174ee6975472722..ae327fbdc7de80ebef2f817ac39906c1221c620f 100644 (file)
 namespace icinga
 {
 
-class I2_CIB_API Host : public ConfigObject
+class I2_CIB_API Host : public DynamicObject
 {
 public:
        typedef shared_ptr<Host> Ptr;
        typedef weak_ptr<Host> WeakPtr;
 
        Host(const Dictionary::Ptr& properties)
-               : ConfigObject(properties)
+               : DynamicObject(properties)
        { }
 
        static bool Exists(const string& name);
index bbae75254d3a2942024ca51114fc4c3d73b887fe..58ddaf3d240a4574d04762e033aacb2c7dfaf9c3 100644 (file)
@@ -49,12 +49,12 @@ string HostGroup::GetActionUrl(void) const
 
 bool HostGroup::Exists(const string& name)
 {
-       return (ConfigObject::GetObject("HostGroup", name));
+       return (DynamicObject::GetObject("HostGroup", name));
 }
 
 HostGroup::Ptr HostGroup::GetByName(const string& name)
 {
-       ConfigObject::Ptr configObject = ConfigObject::GetObject("HostGroup", name);
+       DynamicObject::Ptr configObject = DynamicObject::GetObject("HostGroup", name);
 
        if (!configObject)
                throw_exception(invalid_argument("HostGroup '" + name + "' does not exist."));
index 820bdbb0f4a5c4c5a6d291369420401c90925af3..f283e0da947cb02230e29ce506ec9b4738640dc4 100644 (file)
 namespace icinga
 {
 
-class I2_CIB_API HostGroup : public ConfigObject
+class I2_CIB_API HostGroup : public DynamicObject
 {
 public:
        typedef shared_ptr<HostGroup> Ptr;
        typedef weak_ptr<HostGroup> WeakPtr;
 
        HostGroup(const Dictionary::Ptr& properties)
-               : ConfigObject(properties)
+               : DynamicObject(properties)
        { }
 
        static bool Exists(const string& name);
index 9209c0e30a766b5c2cce6348714a56b68474df41..e7568ac186cb5f8f4bf37ef18bb9fc63d6bb2a9f 100644 (file)
@@ -31,7 +31,7 @@ void NagiosCheckTask::ScriptFunc(const ScriptTask::Ptr& task, const vector<Varia
                throw_exception(invalid_argument("Missing argument: Service must be specified."));
 
        Variant vservice = arguments[0];
-       if (!vservice.IsObjectType<ConfigObject>())
+       if (!vservice.IsObjectType<DynamicObject>())
                throw_exception(invalid_argument("Argument must be a config object."));
 
        Service::Ptr service = static_cast<Service::Ptr>(vservice);
index 5e8d959103adc6fca0c4cb97a8dbd66cf97203e4..6d410aeb91e3e19433f36534808f9a1a2a40dce9 100644 (file)
@@ -37,12 +37,12 @@ string Service::GetAlias(void) const
 
 bool Service::Exists(const string& name)
 {
-       return (ConfigObject::GetObject("Service", name));
+       return (DynamicObject::GetObject("Service", name));
 }
 
 Service::Ptr Service::GetByName(const string& name)
 {
-       ConfigObject::Ptr configObject = ConfigObject::GetObject("Service", name);
+       DynamicObject::Ptr configObject = DynamicObject::GetObject("Service", name);
 
        if (!configObject)
                throw_exception(invalid_argument("Service '" + name + "' does not exist."));
index fa9fda51d1ced0bc178c421f00d30f708541588c..dcfa7fae2a87ab399e8e0ee9f70eb2e6f99d6216 100644 (file)
@@ -42,14 +42,14 @@ class CheckResult;
 class CheckResultMessage;
 class ServiceStatusMessage;
 
-class I2_CIB_API Service : public ConfigObject
+class I2_CIB_API Service : public DynamicObject
 {
 public:
        typedef shared_ptr<Service> Ptr;
        typedef weak_ptr<Service> WeakPtr;
 
        Service(const Dictionary::Ptr& properties)
-               : ConfigObject(properties)
+               : DynamicObject(properties)
        { }
 
        static bool Exists(const string& name);
index e19b08bda71d77c16c1aec53fbae03cb60be1d2f..daca48aab4ce59d39c35373c593d00fc04064ac3 100644 (file)
@@ -49,12 +49,12 @@ string ServiceGroup::GetActionUrl(void) const
 
 bool ServiceGroup::Exists(const string& name)
 {
-       return (ConfigObject::GetObject("ServiceGroup", name));
+       return (DynamicObject::GetObject("ServiceGroup", name));
 }
 
 ServiceGroup::Ptr ServiceGroup::GetByName(const string& name)
 {
-       ConfigObject::Ptr configObject = ConfigObject::GetObject("ServiceGroup", name);
+       DynamicObject::Ptr configObject = DynamicObject::GetObject("ServiceGroup", name);
 
        if (!configObject)
                throw_exception(invalid_argument("ServiceGroup '" + name + "' does not exist."));
index 9666f15da97af3a061d7724f507ceb0ec38b920f..d43b5a671419852f7accf63cb955b4dd4f09e50b 100644 (file)
 namespace icinga
 {
 
-class I2_CIB_API ServiceGroup : public ConfigObject
+class I2_CIB_API ServiceGroup : public DynamicObject
 {
 public:
        typedef shared_ptr<ServiceGroup> Ptr;
        typedef weak_ptr<ServiceGroup> WeakPtr;
 
        ServiceGroup(const Dictionary::Ptr& properties)
-               : ConfigObject(properties)
+               : DynamicObject(properties)
        { }
 
        static bool Exists(const string& name);
index e05549fb855a0a0aed06d1a3ae097cf084d47e7d..bf0944bbc411dfd34bc12874d992026e2aed9dc1 100644 (file)
@@ -76,7 +76,7 @@ void CheckerComponent::CheckTimerHandler(void)
                arguments.push_back(service);
                ScriptTask::Ptr task;
                task = service->InvokeMethod("check", arguments, boost::bind(&CheckerComponent::CheckCompletedHandler, this, service, _1));
-               assert(task); /* TODO: gracefully handle missing hooks */
+               assert(task); /* TODO: gracefully handle missing methods */
 
                service->SetTag("current_task", task);
 
index 376090c0baf78afe0ad5f5794e05094515a60672..7516e1879745abd7e9486e15c280467bd3a5fd39 100644 (file)
@@ -34,8 +34,8 @@ void CIBSyncComponent::Start(void)
        m_Endpoint->RegisterTopicHandler("config::FetchObjects",
            boost::bind(&CIBSyncComponent::FetchObjectsHandler, this, _2));
 
-       ConfigObject::OnCommitted.connect(boost::bind(&CIBSyncComponent::LocalObjectCommittedHandler, this, _1));
-       ConfigObject::OnRemoved.connect(boost::bind(&CIBSyncComponent::LocalObjectRemovedHandler, this, _1));
+       DynamicObject::OnCommitted.connect(boost::bind(&CIBSyncComponent::LocalObjectCommittedHandler, this, _1));
+       DynamicObject::OnRemoved.connect(boost::bind(&CIBSyncComponent::LocalObjectRemovedHandler, this, _1));
 
        m_Endpoint->RegisterPublication("config::ObjectCommitted");
        m_Endpoint->RegisterPublication("config::ObjectRemoved");
@@ -106,7 +106,7 @@ void CIBSyncComponent::SessionEstablishedHandler(const Endpoint::Ptr& endpoint)
        EndpointManager::GetInstance()->SendUnicastMessage(m_Endpoint, endpoint, request);
 }
 
-RequestMessage CIBSyncComponent::MakeObjectMessage(const ConfigObject::Ptr& object, string method, bool includeProperties)
+RequestMessage CIBSyncComponent::MakeObjectMessage(const DynamicObject::Ptr& object, string method, bool includeProperties)
 {
        RequestMessage msg;
        msg.SetMethod(method);
@@ -123,17 +123,17 @@ RequestMessage CIBSyncComponent::MakeObjectMessage(const ConfigObject::Ptr& obje
        return msg;
 }
 
-bool CIBSyncComponent::ShouldReplicateObject(const ConfigObject::Ptr& object)
+bool CIBSyncComponent::ShouldReplicateObject(const DynamicObject::Ptr& object)
 {
        return (!object->IsLocal());
 }
 
 void CIBSyncComponent::FetchObjectsHandler(const Endpoint::Ptr& sender)
 {
-       pair<ConfigObject::TypeMap::iterator, ConfigObject::TypeMap::iterator> trange;
-       ConfigObject::TypeMap::iterator tt;
+       pair<DynamicObject::TypeMap::iterator, DynamicObject::TypeMap::iterator> trange;
+       DynamicObject::TypeMap::iterator tt;
        for (tt = trange.first; tt != trange.second; tt++) {
-               ConfigObject::Ptr object;
+               DynamicObject::Ptr object;
                BOOST_FOREACH(tie(tuples::ignore, object), tt->second) {
                        if (!ShouldReplicateObject(object))
                                continue;
@@ -145,7 +145,7 @@ void CIBSyncComponent::FetchObjectsHandler(const Endpoint::Ptr& sender)
        }
 }
 
-void CIBSyncComponent::LocalObjectCommittedHandler(const ConfigObject::Ptr& object)
+void CIBSyncComponent::LocalObjectCommittedHandler(const DynamicObject::Ptr& object)
 {
        /* don't send messages when we're currently processing a remote update */
        if (m_SyncingConfig)
@@ -158,7 +158,7 @@ void CIBSyncComponent::LocalObjectCommittedHandler(const ConfigObject::Ptr& obje
            MakeObjectMessage(object, "config::ObjectCommitted", true));
 }
 
-void CIBSyncComponent::LocalObjectRemovedHandler(const ConfigObject::Ptr& object)
+void CIBSyncComponent::LocalObjectRemovedHandler(const DynamicObject::Ptr& object)
 {
        /* don't send messages when we're currently processing a remote update */
        if (m_SyncingConfig)
@@ -189,10 +189,10 @@ void CIBSyncComponent::RemoteObjectCommittedHandler(const Endpoint::Ptr& sender,
        if (!params.Get("properties", &properties))
                return;
 
-       ConfigObject::Ptr object = ConfigObject::GetObject(type, name);
+       DynamicObject::Ptr object = DynamicObject::GetObject(type, name);
 
        if (!object) {
-               object = boost::make_shared<ConfigObject>(properties.GetDictionary());
+               object = boost::make_shared<DynamicObject>(properties.GetDictionary());
 
                if (object->GetSource() == EndpointManager::GetInstance()->GetIdentity()) {
                        /* the peer sent us an object that was originally created by us - 
@@ -204,7 +204,7 @@ void CIBSyncComponent::RemoteObjectCommittedHandler(const Endpoint::Ptr& sender,
                        return;
                }
        } else {
-               ConfigObject::Ptr remoteObject = boost::make_shared<ConfigObject>(properties.GetDictionary());
+               DynamicObject::Ptr remoteObject = boost::make_shared<DynamicObject>(properties.GetDictionary());
 
                if (object->GetCommitTimestamp() >= remoteObject->GetCommitTimestamp())
                        return;
@@ -245,7 +245,7 @@ void CIBSyncComponent::RemoteObjectRemovedHandler(const RequestMessage& request)
        if (!params.Get("type", &type))
                return;
 
-       ConfigObject::Ptr object = ConfigObject::GetObject(type, name);
+       DynamicObject::Ptr object = DynamicObject::GetObject(type, name);
 
        if (!object)
                return;
index 8a5cbfd174490320256f94f1c75c51819962155b..3bc46945b1dd7c64891ad22c9c185026d6e4dbee 100644 (file)
@@ -41,17 +41,17 @@ private:
        void NewEndpointHandler(const Endpoint::Ptr& endpoint);
        void SessionEstablishedHandler(const Endpoint::Ptr& endpoint);
 
-       void LocalObjectCommittedHandler(const ConfigObject::Ptr& object);
-       void LocalObjectRemovedHandler(const ConfigObject::Ptr& object);
+       void LocalObjectCommittedHandler(const DynamicObject::Ptr& object);
+       void LocalObjectRemovedHandler(const DynamicObject::Ptr& object);
 
        void FetchObjectsHandler(const Endpoint::Ptr& sender);
        void RemoteObjectCommittedHandler(const Endpoint::Ptr& sender, const RequestMessage& request);
        void RemoteObjectRemovedHandler(const RequestMessage& request);
 
-       static RequestMessage MakeObjectMessage(const ConfigObject::Ptr& object,
+       static RequestMessage MakeObjectMessage(const DynamicObject::Ptr& object,
            string method, bool includeProperties);
 
-       static bool ShouldReplicateObject(const ConfigObject::Ptr& object);
+       static bool ShouldReplicateObject(const DynamicObject::Ptr& object);
 };
 
 }
index 2deb7e3a6f25883f402609b0d24367539054f377..ae288f53520611d6242169f7602f9d8d9249d434 100644 (file)
@@ -222,8 +222,8 @@ void CompatComponent::StatusTimerHandler(void)
 
        map<string, vector<string> > hostgroups;
 
-       ConfigObject::Ptr object;
-       BOOST_FOREACH(tie(tuples::ignore, object), ConfigObject::GetObjects("Host")) {
+       DynamicObject::Ptr object;
+       BOOST_FOREACH(tie(tuples::ignore, object), DynamicObject::GetObjects("Host")) {
                const Host::Ptr& host = static_pointer_cast<Host>(object);
 
                Dictionary::Ptr dict;
@@ -265,7 +265,7 @@ void CompatComponent::StatusTimerHandler(void)
 
        map<string, vector<Service::Ptr> > servicegroups;
 
-       BOOST_FOREACH(tie(tuples::ignore, object), ConfigObject::GetObjects("Service")) {
+       BOOST_FOREACH(tie(tuples::ignore, object), DynamicObject::GetObjects("Service")) {
                Service::Ptr service = static_pointer_cast<Service>(object);
 
                Dictionary::Ptr dict;
index 9bf399d45c96865805acd999680dda027898a81d..7d700fafb96503f2146180a3cee71aa37955be10 100644 (file)
@@ -144,7 +144,7 @@ void ConvenienceComponent::HostRemovedHandler(const ConfigItem::Ptr& item)
        if (item->GetType() != "host")
                return;
 
-       ConfigObject::Ptr host = item->GetConfigObject();
+       DynamicObject::Ptr host = item->GetDynamicObject();
 
        if (!host)
                return;
index c1dda1310026be1338114e23c91d3939c849f19a..161412bab81811b205aa43ddc000a5228170fa7a 100644 (file)
@@ -24,8 +24,8 @@ using namespace icinga;
 
 void DelegationComponent::Start(void)
 {
-       ConfigObject::OnCommitted.connect(boost::bind(&DelegationComponent::ServiceCommittedHandler, this, _1));
-       ConfigObject::OnRemoved.connect(boost::bind(&DelegationComponent::ServiceRemovedHandler, this, _1));
+       DynamicObject::OnCommitted.connect(boost::bind(&DelegationComponent::ServiceCommittedHandler, this, _1));
+       DynamicObject::OnRemoved.connect(boost::bind(&DelegationComponent::ServiceRemovedHandler, this, _1));
 
        m_DelegationTimer = boost::make_shared<Timer>();
        m_DelegationTimer->SetInterval(30);
@@ -50,7 +50,7 @@ void DelegationComponent::Stop(void)
                mgr->UnregisterEndpoint(m_Endpoint);
 }
 
-void DelegationComponent::ServiceCommittedHandler(const ConfigObject::Ptr& object)
+void DelegationComponent::ServiceCommittedHandler(const DynamicObject::Ptr& object)
 {
        Service::Ptr service = dynamic_pointer_cast<Service>(object);
 
@@ -71,7 +71,7 @@ void DelegationComponent::ServiceCommittedHandler(const ConfigObject::Ptr& objec
        }
 }
 
-void DelegationComponent::ServiceRemovedHandler(const ConfigObject::Ptr& object)
+void DelegationComponent::ServiceRemovedHandler(const DynamicObject::Ptr& object)
 {
        Service::Ptr service = dynamic_pointer_cast<Service>(object);
 
@@ -160,8 +160,8 @@ void DelegationComponent::SessionEstablishedHandler(const Endpoint::Ptr& endpoin
                return;
 
        /* locally clear checker for all services that previously belonged to this endpoint */
-       ConfigObject::Ptr object;
-       BOOST_FOREACH(tie(tuples::ignore, object), ConfigObject::GetObjects("Service")) {
+       DynamicObject::Ptr object;
+       BOOST_FOREACH(tie(tuples::ignore, object), DynamicObject::GetObjects("Service")) {
                Service::Ptr service = dynamic_pointer_cast<Service>(object);
 
                if (!service)
@@ -186,8 +186,8 @@ void DelegationComponent::DelegationTimerHandler(void)
        vector<Service::Ptr> services;
 
        /* build "checker -> service count" histogram */
-       ConfigObject::Ptr object;
-       BOOST_FOREACH(tie(tuples::ignore, object), ConfigObject::GetObjects("Service")) {
+       DynamicObject::Ptr object;
+       BOOST_FOREACH(tie(tuples::ignore, object), DynamicObject::GetObjects("Service")) {
                Service::Ptr service = dynamic_pointer_cast<Service>(object);
 
                if (!service)
index 6a067f01c34ce245e6c486e7af7369f8c0101c14..4ace3fe35e3d5e6af028350ad52e489c717ef05a 100644 (file)
@@ -39,8 +39,8 @@ private:
        void NewEndpointHandler(const Endpoint::Ptr& endpoint);
        void SessionEstablishedHandler(const Endpoint::Ptr& endpoint);
 
-       void ServiceCommittedHandler(const ConfigObject::Ptr& object);
-       void ServiceRemovedHandler(const ConfigObject::Ptr& object);
+       void ServiceCommittedHandler(const DynamicObject::Ptr& object);
+       void ServiceRemovedHandler(const DynamicObject::Ptr& object);
        void DelegationTimerHandler(void);
 
        vector<Endpoint::Ptr> GetCheckerCandidates(const Service::Ptr& service) const;
index fe1f50d84009095408e136c3f4a6a9387b2b81de..44326fdd29833d98d42ac9a0350233f217756d88 100644 (file)
@@ -313,8 +313,8 @@ bool DiscoveryComponent::HasMessagePermission(const Dictionary::Ptr& roles, cons
        if (!roles)
                return false;
 
-       ConfigObject::Ptr role;
-       BOOST_FOREACH(tie(tuples::ignore, role), ConfigObject::GetObjects("Role")) {
+       DynamicObject::Ptr role;
+       BOOST_FOREACH(tie(tuples::ignore, role), DynamicObject::GetObjects("Role")) {
                Dictionary::Ptr permissions;
                if (!role->GetProperty(messageType, &permissions))
                        continue;
@@ -355,7 +355,7 @@ void DiscoveryComponent::ProcessDiscoveryMessage(const string& identity, const D
        if (message.GetService(&service) && !service.empty())
                info->Service = service;
 
-       ConfigObject::Ptr endpointConfig = ConfigObject::GetObject("endpoint", identity);
+       DynamicObject::Ptr endpointConfig = DynamicObject::GetObject("endpoint", identity);
        Dictionary::Ptr roles;
        if (endpointConfig)
                endpointConfig->GetProperty("roles", &roles);
@@ -442,8 +442,8 @@ void DiscoveryComponent::DiscoveryTimerHandler(void)
        double now = Utility::GetTime();
 
        /* check whether we have to reconnect to one of our upstream endpoints */
-       ConfigObject::Ptr object;
-       BOOST_FOREACH(tie(tuples::ignore, object), ConfigObject::GetObjects("Endpoint")) {
+       DynamicObject::Ptr object;
+       BOOST_FOREACH(tie(tuples::ignore, object), DynamicObject::GetObjects("Endpoint")) {
                /* Check if we're already connected to this endpoint. */
                if (endpointManager->GetEndpointByIdentity(object->GetName()))
                        continue;
@@ -470,7 +470,7 @@ void DiscoveryComponent::DiscoveryTimerHandler(void)
                /* for explicitly-configured upstream endpoints
                 * we prefer to use the node/service from the
                 * config object - which is what the for loop above does */
-               if (ConfigObject::GetObject("endpoint", identity))
+               if (DynamicObject::GetObject("endpoint", identity))
                        continue;
 
                if (info->LastSeen < now - DiscoveryComponent::RegistrationTTL) {
index 1a46d9a239449a51df07487660505a6cddb5e5c9..f445eefa545fcb1319f47f813f8323eaab27befc 100644 (file)
@@ -75,22 +75,22 @@ void ConfigItem::CalculateProperties(Dictionary::Ptr dictionary) const
        m_ExpressionList->Execute(dictionary);
 }
 
-ConfigObject::Ptr ConfigItem::Commit(void)
+DynamicObject::Ptr ConfigItem::Commit(void)
 {
-       ConfigObject::Ptr dobj = m_ConfigObject.lock();
+       DynamicObject::Ptr dobj = m_DynamicObject.lock();
 
        Dictionary::Ptr properties = boost::make_shared<Dictionary>();
        CalculateProperties(properties);
 
        if (!dobj)
-               dobj = ConfigObject::GetObject(GetType(), GetName());
+               dobj = DynamicObject::GetObject(GetType(), GetName());
 
        if (!dobj)
-               dobj = ConfigObject::Create(GetType(), properties);
+               dobj = DynamicObject::Create(GetType(), properties);
        else
                dobj->SetProperties(properties);
 
-       m_ConfigObject = dobj;
+       m_DynamicObject = dobj;
 
        if (dobj->IsAbstract())
                dobj->Unregister();
@@ -109,7 +109,7 @@ ConfigObject::Ptr ConfigItem::Commit(void)
 
 void ConfigItem::Unregister(void)
 {
-       ConfigObject::Ptr dobj = m_ConfigObject.lock();
+       DynamicObject::Ptr dobj = m_DynamicObject.lock();
 
        if (dobj)
                dobj->Unregister();
@@ -123,9 +123,9 @@ void ConfigItem::Unregister(void)
        OnRemoved(GetSelf());
 }
 
-ConfigObject::Ptr ConfigItem::GetConfigObject(void) const
+DynamicObject::Ptr ConfigItem::GetDynamicObject(void) const
 {
-       return m_ConfigObject.lock();
+       return m_DynamicObject.lock();
 }
 
 ConfigItem::Ptr ConfigItem::GetObject(const string& type, const string& name)
index ddc479082c43981d9a5b2bf6cd09df36b14bdcae..8df8edb7785ec26b3c94ebd3a720ac5c3f285dac 100644 (file)
@@ -41,10 +41,10 @@ public:
 
        void CalculateProperties(Dictionary::Ptr dictionary) const;
 
-       ConfigObject::Ptr Commit(void);
+       DynamicObject::Ptr Commit(void);
        void Unregister(void);
 
-       ConfigObject::Ptr GetConfigObject(void) const;
+       DynamicObject::Ptr GetDynamicObject(void) const;
 
        DebugInfo GetDebugInfo(void) const;
 
@@ -61,7 +61,7 @@ private:
        vector<string> m_Parents;
        DebugInfo m_DebugInfo;
 
-       ConfigObject::WeakPtr m_ConfigObject;
+       DynamicObject::WeakPtr m_DynamicObject;
 
        typedef map<pair<string, string>, ConfigItem::Ptr> ItemMap;
        static ItemMap m_Items;
index e5388207a2ee4fd534d9be45fdef2405820e71c4..cfd8cd9b69dbed4ddc1cbd81401b651dccc2e58d 100644 (file)
@@ -42,14 +42,6 @@ IcingaApplication::IcingaApplication(void)
  */
 int IcingaApplication::Main(const vector<string>& args)
 {
-       /* restore the previous program state */
-       ConfigObject::RestoreObjects("retention.dat");
-
-       m_RetentionTimer = boost::make_shared<Timer>();
-       m_RetentionTimer->SetInterval(60);
-       m_RetentionTimer->OnTimerExpired.connect(boost::bind(&IcingaApplication::DumpProgramState, this));
-       m_RetentionTimer->Start();
-
        /* create console logger */
        ConfigItemBuilder::Ptr consoleLogConfig = boost::make_shared<ConfigItemBuilder>();
        consoleLogConfig->SetType("Logger");
@@ -58,6 +50,15 @@ int IcingaApplication::Main(const vector<string>& args)
        consoleLogConfig->AddExpression("type", OperatorSet, "console");
        consoleLogConfig->Compile()->Commit();
 
+       /* restore the previous program state */
+       DynamicObject::RestoreObjects("retention.dat");
+
+       /* periodically dump the program state */
+       m_RetentionTimer = boost::make_shared<Timer>();
+       m_RetentionTimer->SetInterval(60);
+       m_RetentionTimer->OnTimerExpired.connect(boost::bind(&IcingaApplication::DumpProgramState, this));
+       m_RetentionTimer->Start();
+
 #ifdef _WIN32
        Logger::Write(LogInformation, "icinga", "Icinga component loader");
 #else /* _WIN32 */
@@ -135,7 +136,7 @@ int IcingaApplication::Main(const vector<string>& args)
                item->Commit();
        }
 
-       ConfigObject::Ptr icingaConfig = ConfigObject::GetObject("Application", "icinga");
+       DynamicObject::Ptr icingaConfig = DynamicObject::GetObject("Application", "icinga");
 
        if (!icingaConfig)
                throw_exception(runtime_error("Configuration must contain an 'Application' object named 'icinga'."));
@@ -196,7 +197,7 @@ int IcingaApplication::Main(const vector<string>& args)
 }
 
 void IcingaApplication::DumpProgramState(void) {
-       ConfigObject::DumpObjects("retention.dat.tmp");
+       DynamicObject::DumpObjects("retention.dat.tmp");
        rename("retention.dat.tmp", "retention.dat");
 }