short_name = service->GetShortName();
}
+ if (!host)
+ return;
+
{
ObjectLock olock(host);
host_name = host->GetName();
boost::mutex Host::m_ServiceMutex;
map<String, map<String, weak_ptr<Service> > > Host::m_ServicesCache;
-bool Host::m_ServicesCacheValid = false;
+bool Host::m_ServicesCacheValid = true;
REGISTER_SCRIPTFUNCTION("ValidateServiceDictionary", &Host::ValidateServiceDictionary);
{
DynamicObject::OnRegistrationCompleted();
+ Host::InvalidateServicesCache();
Host::UpdateSlaveServices(GetSelf());
}
{
DynamicObject::Ptr configObject = DynamicObject::GetObject("Host", name);
- if (!configObject)
- BOOST_THROW_EXCEPTION(invalid_argument("Host '" + name + "' does not exist."));
-
return dynamic_pointer_cast<Host>(configObject);
}
{
{
boost::mutex::scoped_lock lock(m_ServiceMutex);
+
+ if (m_ServicesCacheValid)
+ Utility::QueueAsyncCallback(boost::bind(&Host::RefreshServicesCache));
+
m_ServicesCacheValid = false;
}
-
- Utility::QueueAsyncCallback(boost::bind(&Host::RefreshServicesCache));
}
void Host::RefreshServicesCache(void)
short_name = service->GetShortName();
}
+ if (!host)
+ continue;
+
String host_name;
{
{
{
boost::mutex::scoped_lock lock(m_Mutex);
+
+ if (m_MembersCacheValid)
+ Utility::QueueAsyncCallback(boost::bind(&HostGroup::RefreshMembersCache));
+
m_MembersCacheValid = false;
}
-
- Utility::QueueAsyncCallback(boost::bind(&HostGroup::RefreshMembersCache));
}
void HostGroup::RefreshMembersCache(void)
{
{
boost::mutex::scoped_lock lock(m_CommentMutex);
+
+ if (m_CommentsCacheValid)
+ Utility::QueueAsyncCallback(boost::bind(&Service::RefreshCommentsCache));
+
m_CommentsCacheValid = false;
}
-
- Utility::QueueAsyncCallback(boost::bind(&Service::RefreshCommentsCache));
}
void Service::RefreshCommentsCache(void)
{
{
boost::mutex::scoped_lock lock(m_DowntimeMutex);
+
+ if (m_DowntimesCacheValid)
+ Utility::QueueAsyncCallback(boost::bind(&Service::RefreshDowntimesCache));
+
m_DowntimesCacheValid = false;
}
-
- Utility::QueueAsyncCallback(boost::bind(&Service::RefreshDowntimesCache));
}
void Service::RefreshDowntimesCache(void)
{
{
boost::mutex::scoped_lock lock(m_NotificationMutex);
+
+ if (m_NotificationsCacheValid)
+ Utility::QueueAsyncCallback(boost::bind(&Service::RefreshNotificationsCache));
+
m_NotificationsCacheValid = false;
}
-
- Utility::QueueAsyncCallback(boost::bind(&Service::RefreshNotificationsCache));
}
void Service::RefreshNotificationsCache(void)
void Service::OnRegistrationCompleted(void)
{
DynamicObject::OnRegistrationCompleted();
-
- Host::InvalidateServicesCache();
}
String Service::GetDisplayName(void) const
{
{
boost::mutex::scoped_lock lock(m_Mutex);
+
+ if (m_MembersCacheValid)
+ Utility::QueueAsyncCallback(boost::bind(&ServiceGroup::RefreshMembersCache));
+
m_MembersCacheValid = false;
}
-
- Utility::QueueAsyncCallback(boost::bind(&ServiceGroup::RefreshMembersCache));
}
void ServiceGroup::RefreshMembersCache(void)
{
DynamicObject::Ptr configObject = DynamicObject::GetObject("User", name);
- if (!configObject)
- BOOST_THROW_EXCEPTION(invalid_argument("User '" + name + "' does not exist."));
-
return dynamic_pointer_cast<User>(configObject);
}