From 40202c455d2478c5845c14d9a5b1126747a7cd30 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Wed, 13 Feb 2013 22:36:24 +0100 Subject: [PATCH] Rename CommentCache/DowntimeCache to CommentsCache/DowntimesCache Fixes #3677 --- lib/icinga/service-comment.cpp | 54 +++++++++++++++---------------- lib/icinga/service-downtime.cpp | 56 ++++++++++++++++----------------- lib/icinga/service.cpp | 8 ++--- lib/icinga/service.h | 28 ++++++++--------- 4 files changed, 73 insertions(+), 73 deletions(-) diff --git a/lib/icinga/service-comment.cpp b/lib/icinga/service-comment.cpp index 1b1619fb0..dfeed2388 100644 --- a/lib/icinga/service-comment.cpp +++ b/lib/icinga/service-comment.cpp @@ -22,10 +22,10 @@ using namespace icinga; int Service::m_NextCommentID = 1; -map Service::m_LegacyCommentCache; -map Service::m_CommentCache; -bool Service::m_CommentCacheValid; -Timer::Ptr Service::m_CommentExpireTimer; +map Service::m_LegacyCommentsCache; +map Service::m_CommentsCache; +bool Service::m_CommentsCacheValid; +Timer::Ptr Service::m_CommentsExpireTimer; int Service::GetNextCommentID(void) { @@ -34,7 +34,7 @@ int Service::GetNextCommentID(void) Dictionary::Ptr Service::GetComments(void) const { - Service::ValidateCommentCache(); + Service::ValidateCommentsCache(); return Get("comments"); } @@ -84,9 +84,9 @@ void Service::RemoveComment(const String& id) String Service::GetCommentIDFromLegacyID(int id) { - map::iterator it = m_LegacyCommentCache.find(id); + map::iterator it = m_LegacyCommentsCache.find(id); - if (it == m_LegacyCommentCache.end()) + if (it == m_LegacyCommentsCache.end()) return Empty; return it->second; @@ -94,9 +94,9 @@ String Service::GetCommentIDFromLegacyID(int id) 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) @@ -123,11 +123,11 @@ bool Service::IsCommentExpired(const Dictionary::Ptr& comment) 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) @@ -145,7 +145,7 @@ 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 */ @@ -154,18 +154,18 @@ void Service::AddCommentsToCache(void) 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()) { @@ -173,13 +173,13 @@ void Service::ValidateCommentCache(void) service->AddCommentsToCache(); } - m_CommentCacheValid = true; + m_CommentsCacheValid = true; - if (!m_CommentExpireTimer) { - m_CommentExpireTimer = boost::make_shared(); - m_CommentExpireTimer->SetInterval(300); - m_CommentExpireTimer->OnTimerExpired.connect(boost::bind(&Service::CommentExpireTimerHandler)); - m_CommentExpireTimer->Start(); + if (!m_CommentsExpireTimer) { + m_CommentsExpireTimer = boost::make_shared(); + m_CommentsExpireTimer->SetInterval(300); + m_CommentsExpireTimer->OnTimerExpired.connect(boost::bind(&Service::CommentsExpireTimerHandler)); + m_CommentsExpireTimer->Start(); } } @@ -208,7 +208,7 @@ void Service::RemoveExpiredComments(void) } } -void Service::CommentExpireTimerHandler(void) +void Service::CommentsExpireTimerHandler(void) { DynamicObject::Ptr object; BOOST_FOREACH(tie(tuples::ignore, object), DynamicType::GetByName("Service")->GetObjects()) { diff --git a/lib/icinga/service-downtime.cpp b/lib/icinga/service-downtime.cpp index c9a18c9a7..2c7df0cfe 100644 --- a/lib/icinga/service-downtime.cpp +++ b/lib/icinga/service-downtime.cpp @@ -22,10 +22,10 @@ using namespace icinga; int Service::m_NextDowntimeID = 1; -map Service::m_LegacyDowntimeCache; -map Service::m_DowntimeCache; -bool Service::m_DowntimeCacheValid; -Timer::Ptr Service::m_DowntimeExpireTimer; +map Service::m_LegacyDowntimesCache; +map Service::m_DowntimesCache; +bool Service::m_DowntimesCacheValid; +Timer::Ptr Service::m_DowntimesExpireTimer; int Service::GetNextDowntimeID(void) { @@ -34,7 +34,7 @@ int Service::GetNextDowntimeID(void) Dictionary::Ptr Service::GetDowntimes(void) const { - Service::ValidateDowntimeCache(); + Service::ValidateDowntimesCache(); return Get("downtimes"); } @@ -131,11 +131,11 @@ void Service::TriggerDowntime(const String& id) String Service::GetDowntimeIDFromLegacyID(int id) { - ValidateDowntimeCache(); + ValidateDowntimesCache(); - map::iterator it = m_LegacyDowntimeCache.find(id); + map::iterator it = m_LegacyDowntimesCache.find(id); - if (it == m_LegacyDowntimeCache.end()) + if (it == m_LegacyDowntimesCache.end()) return Empty; return it->second; @@ -143,9 +143,9 @@ String Service::GetDowntimeIDFromLegacyID(int id) 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) @@ -189,11 +189,11 @@ bool Service::IsDowntimeExpired(const Dictionary::Ptr& downtime) 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) @@ -211,7 +211,7 @@ 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++; @@ -219,18 +219,18 @@ void Service::AddDowntimesToCache(void) 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()) { @@ -238,13 +238,13 @@ void Service::ValidateDowntimeCache(void) service->AddDowntimesToCache(); } - m_DowntimeCacheValid = true; + m_DowntimesCacheValid = true; - if (!m_DowntimeExpireTimer) { - m_DowntimeExpireTimer = boost::make_shared(); - m_DowntimeExpireTimer->SetInterval(300); - m_DowntimeExpireTimer->OnTimerExpired.connect(boost::bind(&Service::DowntimeExpireTimerHandler)); - m_DowntimeExpireTimer->Start(); + if (!m_DowntimesExpireTimer) { + m_DowntimesExpireTimer = boost::make_shared(); + m_DowntimesExpireTimer->SetInterval(300); + m_DowntimesExpireTimer->OnTimerExpired.connect(boost::bind(&Service::DowntimesExpireTimerHandler)); + m_DowntimesExpireTimer->Start(); } } @@ -273,7 +273,7 @@ void Service::RemoveExpiredDowntimes(void) } } -void Service::DowntimeExpireTimerHandler(void) +void Service::DowntimesExpireTimerHandler(void) { DynamicObject::Ptr object; BOOST_FOREACH(tie(tuples::ignore, object), DynamicType::GetByName("Service")->GetObjects()) { diff --git a/lib/icinga/service.cpp b/lib/icinga/service.cpp index 3a88eb9b8..72a09e8c9 100644 --- a/lib/icinga/service.cpp +++ b/lib/icinga/service.cpp @@ -53,8 +53,8 @@ Service::~Service(void) { ServiceGroup::InvalidateMembersCache(); Host::InvalidateServicesCache(); - Service::InvalidateDowntimeCache(); - Service::InvalidateCommentCache(); + Service::InvalidateDowntimesCache(); + Service::InvalidateCommentsCache(); } String Service::GetDisplayName(void) const @@ -222,9 +222,9 @@ void Service::OnAttributeChanged(const String& name, const Value& oldValue) 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") { diff --git a/lib/icinga/service.h b/lib/icinga/service.h index 9d1c18f91..ba76f6cc5 100644 --- a/lib/icinga/service.h +++ b/lib/icinga/service.h @@ -204,8 +204,8 @@ public: 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); @@ -227,8 +227,8 @@ public: 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; @@ -257,12 +257,12 @@ private: /* Downtimes */ static int m_NextDowntimeID; - static map m_LegacyDowntimeCache; - static map m_DowntimeCache; - static bool m_DowntimeCacheValid; - static Timer::Ptr m_DowntimeExpireTimer; + static map m_LegacyDowntimesCache; + static map 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); @@ -270,12 +270,12 @@ private: /* Comments */ static int m_NextCommentID; - static map m_LegacyCommentCache; - static map m_CommentCache; - static bool m_CommentCacheValid; - static Timer::Ptr m_CommentExpireTimer; + static map m_LegacyCommentsCache; + static map 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); -- 2.40.0