using namespace icinga;
int Service::m_NextCommentID = 1;
-map<int, String> Service::m_LegacyCommentCache;
-map<String, Service::WeakPtr> Service::m_CommentCache;
-bool Service::m_CommentCacheValid;
-Timer::Ptr Service::m_CommentExpireTimer;
+map<int, String> Service::m_LegacyCommentsCache;
+map<String, Service::WeakPtr> Service::m_CommentsCache;
+bool Service::m_CommentsCacheValid;
+Timer::Ptr Service::m_CommentsExpireTimer;
int Service::GetNextCommentID(void)
{
Dictionary::Ptr Service::GetComments(void) const
{
- Service::ValidateCommentCache();
+ Service::ValidateCommentsCache();
return Get("comments");
}
String Service::GetCommentIDFromLegacyID(int id)
{
- map<int, String>::iterator it = m_LegacyCommentCache.find(id);
+ map<int, String>::iterator it = m_LegacyCommentsCache.find(id);
- if (it == m_LegacyCommentCache.end())
+ if (it == m_LegacyCommentsCache.end())
return Empty;
return it->second;
Service::Ptr Service::GetOwnerByCommentID(const String& id)
{
- ValidateCommentCache();
+ ValidateCommentsCache();
- return m_CommentCache[id].lock();
+ return m_CommentsCache[id].lock();
}
Dictionary::Ptr Service::GetCommentByID(const String& id)
return (expire_time != 0 && expire_time < Utility::GetTime());
}
-void Service::InvalidateCommentCache(void)
+void Service::InvalidateCommentsCache(void)
{
- m_CommentCacheValid = false;
- m_CommentCache.clear();
- m_LegacyCommentCache.clear();
+ m_CommentsCacheValid = false;
+ m_CommentsCache.clear();
+ m_LegacyCommentsCache.clear();
}
void Service::AddCommentsToCache(void)
if (legacy_id >= m_NextCommentID)
m_NextCommentID = legacy_id + 1;
- if (m_LegacyCommentCache.find(legacy_id) != m_LegacyCommentCache.end()) {
+ if (m_LegacyCommentsCache.find(legacy_id) != m_LegacyCommentsCache.end()) {
/* The legacy_id is already in use by another comment;
* this shouldn't usually happen - assign it a new ID */
Touch("comments");
}
- m_LegacyCommentCache[legacy_id] = id;
- m_CommentCache[id] = GetSelf();
+ m_LegacyCommentsCache[legacy_id] = id;
+ m_CommentsCache[id] = GetSelf();
}
}
-void Service::ValidateCommentCache(void)
+void Service::ValidateCommentsCache(void)
{
- if (m_CommentCacheValid)
+ if (m_CommentsCacheValid)
return;
- m_CommentCache.clear();
- m_LegacyCommentCache.clear();
+ m_CommentsCache.clear();
+ m_LegacyCommentsCache.clear();
DynamicObject::Ptr object;
BOOST_FOREACH(tie(tuples::ignore, object), DynamicType::GetByName("Service")->GetObjects()) {
service->AddCommentsToCache();
}
- m_CommentCacheValid = true;
+ m_CommentsCacheValid = true;
- if (!m_CommentExpireTimer) {
- m_CommentExpireTimer = boost::make_shared<Timer>();
- m_CommentExpireTimer->SetInterval(300);
- m_CommentExpireTimer->OnTimerExpired.connect(boost::bind(&Service::CommentExpireTimerHandler));
- m_CommentExpireTimer->Start();
+ if (!m_CommentsExpireTimer) {
+ m_CommentsExpireTimer = boost::make_shared<Timer>();
+ m_CommentsExpireTimer->SetInterval(300);
+ m_CommentsExpireTimer->OnTimerExpired.connect(boost::bind(&Service::CommentsExpireTimerHandler));
+ m_CommentsExpireTimer->Start();
}
}
}
}
-void Service::CommentExpireTimerHandler(void)
+void Service::CommentsExpireTimerHandler(void)
{
DynamicObject::Ptr object;
BOOST_FOREACH(tie(tuples::ignore, object), DynamicType::GetByName("Service")->GetObjects()) {
using namespace icinga;
int Service::m_NextDowntimeID = 1;
-map<int, String> Service::m_LegacyDowntimeCache;
-map<String, Service::WeakPtr> Service::m_DowntimeCache;
-bool Service::m_DowntimeCacheValid;
-Timer::Ptr Service::m_DowntimeExpireTimer;
+map<int, String> Service::m_LegacyDowntimesCache;
+map<String, Service::WeakPtr> Service::m_DowntimesCache;
+bool Service::m_DowntimesCacheValid;
+Timer::Ptr Service::m_DowntimesExpireTimer;
int Service::GetNextDowntimeID(void)
{
Dictionary::Ptr Service::GetDowntimes(void) const
{
- Service::ValidateDowntimeCache();
+ Service::ValidateDowntimesCache();
return Get("downtimes");
}
String Service::GetDowntimeIDFromLegacyID(int id)
{
- ValidateDowntimeCache();
+ ValidateDowntimesCache();
- map<int, String>::iterator it = m_LegacyDowntimeCache.find(id);
+ map<int, String>::iterator it = m_LegacyDowntimesCache.find(id);
- if (it == m_LegacyDowntimeCache.end())
+ if (it == m_LegacyDowntimesCache.end())
return Empty;
return it->second;
Service::Ptr Service::GetOwnerByDowntimeID(const String& id)
{
- ValidateDowntimeCache();
+ ValidateDowntimesCache();
- return m_DowntimeCache[id].lock();
+ return m_DowntimesCache[id].lock();
}
Dictionary::Ptr Service::GetDowntimeByID(const String& id)
return (downtime->Get("end_time") < Utility::GetTime());
}
-void Service::InvalidateDowntimeCache(void)
+void Service::InvalidateDowntimesCache(void)
{
- m_DowntimeCacheValid = false;
- m_DowntimeCache.clear();
- m_LegacyDowntimeCache.clear();
+ m_DowntimesCacheValid = false;
+ m_DowntimesCache.clear();
+ m_LegacyDowntimesCache.clear();
}
void Service::AddDowntimesToCache(void)
if (legacy_id >= m_NextDowntimeID)
m_NextDowntimeID = legacy_id + 1;
- if (m_LegacyDowntimeCache.find(legacy_id) != m_LegacyDowntimeCache.end()) {
+ if (m_LegacyDowntimesCache.find(legacy_id) != m_LegacyDowntimesCache.end()) {
/* The legacy_id is already in use by another downtime;
* this shouldn't usually happen - assign it a new ID. */
legacy_id = m_NextDowntimeID++;
Touch("downtimes");
}
- m_LegacyDowntimeCache[legacy_id] = id;
- m_DowntimeCache[id] = GetSelf();
+ m_LegacyDowntimesCache[legacy_id] = id;
+ m_DowntimesCache[id] = GetSelf();
}
}
-void Service::ValidateDowntimeCache(void)
+void Service::ValidateDowntimesCache(void)
{
- if (m_DowntimeCacheValid)
+ if (m_DowntimesCacheValid)
return;
- m_DowntimeCache.clear();
- m_LegacyDowntimeCache.clear();
+ m_DowntimesCache.clear();
+ m_LegacyDowntimesCache.clear();
DynamicObject::Ptr object;
BOOST_FOREACH(tie(tuples::ignore, object), DynamicType::GetByName("Service")->GetObjects()) {
service->AddDowntimesToCache();
}
- m_DowntimeCacheValid = true;
+ m_DowntimesCacheValid = true;
- if (!m_DowntimeExpireTimer) {
- m_DowntimeExpireTimer = boost::make_shared<Timer>();
- m_DowntimeExpireTimer->SetInterval(300);
- m_DowntimeExpireTimer->OnTimerExpired.connect(boost::bind(&Service::DowntimeExpireTimerHandler));
- m_DowntimeExpireTimer->Start();
+ if (!m_DowntimesExpireTimer) {
+ m_DowntimesExpireTimer = boost::make_shared<Timer>();
+ m_DowntimesExpireTimer->SetInterval(300);
+ m_DowntimesExpireTimer->OnTimerExpired.connect(boost::bind(&Service::DowntimesExpireTimerHandler));
+ m_DowntimesExpireTimer->Start();
}
}
}
}
-void Service::DowntimeExpireTimerHandler(void)
+void Service::DowntimesExpireTimerHandler(void)
{
DynamicObject::Ptr object;
BOOST_FOREACH(tie(tuples::ignore, object), DynamicType::GetByName("Service")->GetObjects()) {
{
ServiceGroup::InvalidateMembersCache();
Host::InvalidateServicesCache();
- Service::InvalidateDowntimeCache();
- Service::InvalidateCommentCache();
+ Service::InvalidateDowntimesCache();
+ Service::InvalidateCommentsCache();
}
String Service::GetDisplayName(void) const
Host::InvalidateServicesCache();
UpdateSlaveNotifications();
} else if (name == "downtimes")
- Service::InvalidateDowntimeCache();
+ Service::InvalidateDowntimesCache();
else if (name == "comments")
- Service::InvalidateCommentCache();
+ Service::InvalidateCommentsCache();
else if (name == "notifications")
UpdateSlaveNotifications();
else if (name == "check_interval") {
static bool IsDowntimeActive(const Dictionary::Ptr& downtime);
static bool IsDowntimeExpired(const Dictionary::Ptr& downtime);
- static void InvalidateDowntimeCache(void);
- static void ValidateDowntimeCache(void);
+ static void InvalidateDowntimesCache(void);
+ static void ValidateDowntimesCache(void);
bool IsInDowntime(void) const;
bool IsAcknowledged(void);
static bool IsCommentExpired(const Dictionary::Ptr& comment);
- static void InvalidateCommentCache(void);
- static void ValidateCommentCache(void);
+ static void InvalidateCommentsCache(void);
+ static void ValidateCommentsCache(void);
/* Notifications */
void RequestNotifications(NotificationType type) const;
/* Downtimes */
static int m_NextDowntimeID;
- static map<int, String> m_LegacyDowntimeCache;
- static map<String, Service::WeakPtr> m_DowntimeCache;
- static bool m_DowntimeCacheValid;
- static Timer::Ptr m_DowntimeExpireTimer;
+ static map<int, String> m_LegacyDowntimesCache;
+ static map<String, Service::WeakPtr> m_DowntimesCache;
+ static bool m_DowntimesCacheValid;
+ static Timer::Ptr m_DowntimesExpireTimer;
- static void DowntimeExpireTimerHandler(void);
+ static void DowntimesExpireTimerHandler(void);
void AddDowntimesToCache(void);
void RemoveExpiredDowntimes(void);
/* Comments */
static int m_NextCommentID;
- static map<int, String> m_LegacyCommentCache;
- static map<String, Service::WeakPtr> m_CommentCache;
- static bool m_CommentCacheValid;
- static Timer::Ptr m_CommentExpireTimer;
+ static map<int, String> m_LegacyCommentsCache;
+ static map<String, Service::WeakPtr> m_CommentsCache;
+ static bool m_CommentsCacheValid;
+ static Timer::Ptr m_CommentsExpireTimer;
- static void CommentExpireTimerHandler(void);
+ static void CommentsExpireTimerHandler(void);
void AddCommentsToCache(void);
void RemoveExpiredComments(void);