mirror of https://github.com/Icinga/icinga2.git
Performance improvements for *Group::GetMembers().
This commit is contained in:
parent
9413466cef
commit
b79f966b53
|
@ -21,7 +21,7 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
map<String, vector<String> > Host::m_ServicesCache;
|
||||
map<String, vector<Service::WeakPtr> > Host::m_ServicesCache;
|
||||
bool Host::m_ServicesCacheValid = true;
|
||||
|
||||
static AttributeDescription hostAttributes[] = {
|
||||
|
@ -295,11 +295,12 @@ set<Service::Ptr> Host::GetServices(void) const
|
|||
|
||||
ValidateServicesCache();
|
||||
|
||||
BOOST_FOREACH(const String& svc, m_ServicesCache[GetName()]) {
|
||||
if (!Service::Exists(svc))
|
||||
BOOST_FOREACH(const Service::WeakPtr& svc, m_ServicesCache[GetName()]) {
|
||||
Service::Ptr service = svc.lock();
|
||||
|
||||
if (!service)
|
||||
continue;
|
||||
|
||||
Service::Ptr service = Service::GetByName(svc);
|
||||
services.insert(service);
|
||||
}
|
||||
|
||||
|
@ -323,7 +324,7 @@ void Host::ValidateServicesCache(void)
|
|||
BOOST_FOREACH(tie(tuples::ignore, object), DynamicType::GetByName("Service")->GetObjects()) {
|
||||
const Service::Ptr& service = static_pointer_cast<Service>(object);
|
||||
|
||||
m_ServicesCache[service->GetHost()->GetName()].push_back(service->GetName());
|
||||
m_ServicesCache[service->GetHost()->GetName()].push_back(service);
|
||||
}
|
||||
|
||||
m_ServicesCacheValid = true;
|
||||
|
|
|
@ -59,7 +59,7 @@ protected:
|
|||
private:
|
||||
static bool m_InitializerDone;
|
||||
|
||||
static map<String, vector<String> > m_ServicesCache;
|
||||
static map<String, vector<weak_ptr<Service> > > m_ServicesCache;
|
||||
static bool m_ServicesCacheValid;
|
||||
|
||||
static void ObjectCommittedHandler(const ConfigItem::Ptr& item);
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
map<String, vector<String> > HostGroup::m_MembersCache;
|
||||
map<String, vector<Host::WeakPtr> > HostGroup::m_MembersCache;
|
||||
bool HostGroup::m_MembersCacheValid = true;
|
||||
|
||||
static AttributeDescription hostGroupAttributes[] = {
|
||||
|
@ -73,11 +73,12 @@ set<Host::Ptr> HostGroup::GetMembers(void) const
|
|||
|
||||
ValidateMembersCache();
|
||||
|
||||
BOOST_FOREACH(const String& hst, m_MembersCache[GetName()]) {
|
||||
if (!Host::Exists(hst))
|
||||
BOOST_FOREACH(const Host::WeakPtr& hst, m_MembersCache[GetName()]) {
|
||||
Host::Ptr host = hst.lock();
|
||||
|
||||
if (!host)
|
||||
continue;
|
||||
|
||||
Host::Ptr host = Host::GetByName(hst);
|
||||
hosts.insert(host);
|
||||
}
|
||||
|
||||
|
@ -110,7 +111,7 @@ void HostGroup::ValidateMembersCache(void)
|
|||
if (!HostGroup::Exists(hostgroup))
|
||||
Logger::Write(LogWarning, "icinga", "Host group '" + static_cast<String>(hostgroup) + "' used but not defined.");
|
||||
|
||||
m_MembersCache[hostgroup].push_back(host->GetName());
|
||||
m_MembersCache[hostgroup].push_back(host);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ public:
|
|||
static void InvalidateMembersCache(void);
|
||||
|
||||
private:
|
||||
static map<String, vector<String> > m_MembersCache;
|
||||
static map<String, vector<weak_ptr<Host> > > m_MembersCache;
|
||||
static bool m_MembersCacheValid;
|
||||
|
||||
static void ValidateMembersCache(void);
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
map<String, vector<String> > ServiceGroup::m_MembersCache;
|
||||
map<String, vector<Service::WeakPtr> > ServiceGroup::m_MembersCache;
|
||||
bool ServiceGroup::m_MembersCacheValid;
|
||||
|
||||
static AttributeDescription serviceGroupAttributes[] = {
|
||||
|
@ -73,11 +73,12 @@ set<Service::Ptr> ServiceGroup::GetMembers(void) const
|
|||
|
||||
ValidateMembersCache();
|
||||
|
||||
BOOST_FOREACH(const String& svc, m_MembersCache[GetName()]) {
|
||||
if (!Service::Exists(svc))
|
||||
BOOST_FOREACH(const Service::WeakPtr& svc, m_MembersCache[GetName()]) {
|
||||
Service::Ptr service = svc.lock();
|
||||
|
||||
if (!service)
|
||||
continue;
|
||||
|
||||
Service::Ptr service = Service::GetByName(svc);
|
||||
services.insert(service);
|
||||
}
|
||||
|
||||
|
@ -110,7 +111,7 @@ void ServiceGroup::ValidateMembersCache(void)
|
|||
if (!ServiceGroup::Exists(servicegroup))
|
||||
Logger::Write(LogWarning, "icinga", "Service group '" + static_cast<String>(servicegroup) + "' used but not defined.");
|
||||
|
||||
m_MembersCache[servicegroup].push_back(service->GetName());
|
||||
m_MembersCache[servicegroup].push_back(service);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ public:
|
|||
static void InvalidateMembersCache(void);
|
||||
|
||||
private:
|
||||
static map<String, vector<String> > m_MembersCache;
|
||||
static map<String, vector<weak_ptr<Service> > > m_MembersCache;
|
||||
static bool m_MembersCacheValid;
|
||||
|
||||
static void ValidateMembersCache(void);
|
||||
|
|
Loading…
Reference in New Issue