mirror of
https://github.com/Icinga/icinga2.git
synced 2025-04-08 17:05:25 +02:00
Renamed ConfigObject to DynamicObject.
This commit is contained in:
parent
24a5a10e00
commit
8c185a38b0
base
Makefile.ambase.vcxprojbase.vcxproj.filterscomponent.cppcomponent.hdynamicobject.cppdynamicobject.hi2-base.hlogger.cpplogger.h
cib
host.cpphost.hhostgroup.cpphostgroup.hnagioschecktask.cppservice.cppservice.hservicegroup.cppservicegroup.h
components
checker
cibsync
compat
convenience
delegation
discovery
dyn
icinga
@ -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 \
|
||||
|
@ -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" />
|
||||
|
@ -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>
|
||||
@ -177,6 +174,9 @@
|
||||
<ClInclude Include="netstring.h">
|
||||
<Filter>Headerdateien</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="dynamicobject.h">
|
||||
<Filter>Headerdateien</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="Quelldateien">
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -21,11 +21,11 @@
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -17,30 +17,30 @@
|
||||
* 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 */
|
@ -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"
|
||||
|
@ -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())
|
||||
|
@ -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;
|
||||
|
@ -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."));
|
||||
|
@ -23,14 +23,14 @@
|
||||
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);
|
||||
|
@ -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."));
|
||||
|
@ -23,14 +23,14 @@
|
||||
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);
|
||||
|
@ -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);
|
||||
|
@ -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."));
|
||||
|
@ -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);
|
||||
|
@ -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."));
|
||||
|
@ -23,14 +23,14 @@
|
||||
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);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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) {
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user