Rename CommentCache/DowntimeCache to CommentsCache/DowntimesCache

Fixes #3677
This commit is contained in:
Gunnar Beutner 2013-02-13 22:36:24 +01:00
parent f4d8791424
commit 40202c455d
4 changed files with 73 additions and 73 deletions

View File

@ -22,10 +22,10 @@
using namespace icinga; using namespace icinga;
int Service::m_NextCommentID = 1; int Service::m_NextCommentID = 1;
map<int, String> Service::m_LegacyCommentCache; map<int, String> Service::m_LegacyCommentsCache;
map<String, Service::WeakPtr> Service::m_CommentCache; map<String, Service::WeakPtr> Service::m_CommentsCache;
bool Service::m_CommentCacheValid; bool Service::m_CommentsCacheValid;
Timer::Ptr Service::m_CommentExpireTimer; Timer::Ptr Service::m_CommentsExpireTimer;
int Service::GetNextCommentID(void) int Service::GetNextCommentID(void)
{ {
@ -34,7 +34,7 @@ int Service::GetNextCommentID(void)
Dictionary::Ptr Service::GetComments(void) const Dictionary::Ptr Service::GetComments(void) const
{ {
Service::ValidateCommentCache(); Service::ValidateCommentsCache();
return Get("comments"); return Get("comments");
} }
@ -84,9 +84,9 @@ void Service::RemoveComment(const String& id)
String Service::GetCommentIDFromLegacyID(int id) 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 Empty;
return it->second; return it->second;
@ -94,9 +94,9 @@ String Service::GetCommentIDFromLegacyID(int id)
Service::Ptr Service::GetOwnerByCommentID(const String& 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) 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()); return (expire_time != 0 && expire_time < Utility::GetTime());
} }
void Service::InvalidateCommentCache(void) void Service::InvalidateCommentsCache(void)
{ {
m_CommentCacheValid = false; m_CommentsCacheValid = false;
m_CommentCache.clear(); m_CommentsCache.clear();
m_LegacyCommentCache.clear(); m_LegacyCommentsCache.clear();
} }
void Service::AddCommentsToCache(void) void Service::AddCommentsToCache(void)
@ -145,7 +145,7 @@ void Service::AddCommentsToCache(void)
if (legacy_id >= m_NextCommentID) if (legacy_id >= m_NextCommentID)
m_NextCommentID = legacy_id + 1; 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; /* The legacy_id is already in use by another comment;
* this shouldn't usually happen - assign it a new ID */ * this shouldn't usually happen - assign it a new ID */
@ -154,18 +154,18 @@ void Service::AddCommentsToCache(void)
Touch("comments"); Touch("comments");
} }
m_LegacyCommentCache[legacy_id] = id; m_LegacyCommentsCache[legacy_id] = id;
m_CommentCache[id] = GetSelf(); m_CommentsCache[id] = GetSelf();
} }
} }
void Service::ValidateCommentCache(void) void Service::ValidateCommentsCache(void)
{ {
if (m_CommentCacheValid) if (m_CommentsCacheValid)
return; return;
m_CommentCache.clear(); m_CommentsCache.clear();
m_LegacyCommentCache.clear(); m_LegacyCommentsCache.clear();
DynamicObject::Ptr object; DynamicObject::Ptr object;
BOOST_FOREACH(tie(tuples::ignore, object), DynamicType::GetByName("Service")->GetObjects()) { BOOST_FOREACH(tie(tuples::ignore, object), DynamicType::GetByName("Service")->GetObjects()) {
@ -173,13 +173,13 @@ void Service::ValidateCommentCache(void)
service->AddCommentsToCache(); service->AddCommentsToCache();
} }
m_CommentCacheValid = true; m_CommentsCacheValid = true;
if (!m_CommentExpireTimer) { if (!m_CommentsExpireTimer) {
m_CommentExpireTimer = boost::make_shared<Timer>(); m_CommentsExpireTimer = boost::make_shared<Timer>();
m_CommentExpireTimer->SetInterval(300); m_CommentsExpireTimer->SetInterval(300);
m_CommentExpireTimer->OnTimerExpired.connect(boost::bind(&Service::CommentExpireTimerHandler)); m_CommentsExpireTimer->OnTimerExpired.connect(boost::bind(&Service::CommentsExpireTimerHandler));
m_CommentExpireTimer->Start(); m_CommentsExpireTimer->Start();
} }
} }
@ -208,7 +208,7 @@ void Service::RemoveExpiredComments(void)
} }
} }
void Service::CommentExpireTimerHandler(void) void Service::CommentsExpireTimerHandler(void)
{ {
DynamicObject::Ptr object; DynamicObject::Ptr object;
BOOST_FOREACH(tie(tuples::ignore, object), DynamicType::GetByName("Service")->GetObjects()) { BOOST_FOREACH(tie(tuples::ignore, object), DynamicType::GetByName("Service")->GetObjects()) {

View File

@ -22,10 +22,10 @@
using namespace icinga; using namespace icinga;
int Service::m_NextDowntimeID = 1; int Service::m_NextDowntimeID = 1;
map<int, String> Service::m_LegacyDowntimeCache; map<int, String> Service::m_LegacyDowntimesCache;
map<String, Service::WeakPtr> Service::m_DowntimeCache; map<String, Service::WeakPtr> Service::m_DowntimesCache;
bool Service::m_DowntimeCacheValid; bool Service::m_DowntimesCacheValid;
Timer::Ptr Service::m_DowntimeExpireTimer; Timer::Ptr Service::m_DowntimesExpireTimer;
int Service::GetNextDowntimeID(void) int Service::GetNextDowntimeID(void)
{ {
@ -34,7 +34,7 @@ int Service::GetNextDowntimeID(void)
Dictionary::Ptr Service::GetDowntimes(void) const Dictionary::Ptr Service::GetDowntimes(void) const
{ {
Service::ValidateDowntimeCache(); Service::ValidateDowntimesCache();
return Get("downtimes"); return Get("downtimes");
} }
@ -131,11 +131,11 @@ void Service::TriggerDowntime(const String& id)
String Service::GetDowntimeIDFromLegacyID(int id) 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 Empty;
return it->second; return it->second;
@ -143,9 +143,9 @@ String Service::GetDowntimeIDFromLegacyID(int id)
Service::Ptr Service::GetOwnerByDowntimeID(const String& 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) 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()); return (downtime->Get("end_time") < Utility::GetTime());
} }
void Service::InvalidateDowntimeCache(void) void Service::InvalidateDowntimesCache(void)
{ {
m_DowntimeCacheValid = false; m_DowntimesCacheValid = false;
m_DowntimeCache.clear(); m_DowntimesCache.clear();
m_LegacyDowntimeCache.clear(); m_LegacyDowntimesCache.clear();
} }
void Service::AddDowntimesToCache(void) void Service::AddDowntimesToCache(void)
@ -211,7 +211,7 @@ void Service::AddDowntimesToCache(void)
if (legacy_id >= m_NextDowntimeID) if (legacy_id >= m_NextDowntimeID)
m_NextDowntimeID = legacy_id + 1; 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; /* The legacy_id is already in use by another downtime;
* this shouldn't usually happen - assign it a new ID. */ * this shouldn't usually happen - assign it a new ID. */
legacy_id = m_NextDowntimeID++; legacy_id = m_NextDowntimeID++;
@ -219,18 +219,18 @@ void Service::AddDowntimesToCache(void)
Touch("downtimes"); Touch("downtimes");
} }
m_LegacyDowntimeCache[legacy_id] = id; m_LegacyDowntimesCache[legacy_id] = id;
m_DowntimeCache[id] = GetSelf(); m_DowntimesCache[id] = GetSelf();
} }
} }
void Service::ValidateDowntimeCache(void) void Service::ValidateDowntimesCache(void)
{ {
if (m_DowntimeCacheValid) if (m_DowntimesCacheValid)
return; return;
m_DowntimeCache.clear(); m_DowntimesCache.clear();
m_LegacyDowntimeCache.clear(); m_LegacyDowntimesCache.clear();
DynamicObject::Ptr object; DynamicObject::Ptr object;
BOOST_FOREACH(tie(tuples::ignore, object), DynamicType::GetByName("Service")->GetObjects()) { BOOST_FOREACH(tie(tuples::ignore, object), DynamicType::GetByName("Service")->GetObjects()) {
@ -238,13 +238,13 @@ void Service::ValidateDowntimeCache(void)
service->AddDowntimesToCache(); service->AddDowntimesToCache();
} }
m_DowntimeCacheValid = true; m_DowntimesCacheValid = true;
if (!m_DowntimeExpireTimer) { if (!m_DowntimesExpireTimer) {
m_DowntimeExpireTimer = boost::make_shared<Timer>(); m_DowntimesExpireTimer = boost::make_shared<Timer>();
m_DowntimeExpireTimer->SetInterval(300); m_DowntimesExpireTimer->SetInterval(300);
m_DowntimeExpireTimer->OnTimerExpired.connect(boost::bind(&Service::DowntimeExpireTimerHandler)); m_DowntimesExpireTimer->OnTimerExpired.connect(boost::bind(&Service::DowntimesExpireTimerHandler));
m_DowntimeExpireTimer->Start(); m_DowntimesExpireTimer->Start();
} }
} }
@ -273,7 +273,7 @@ void Service::RemoveExpiredDowntimes(void)
} }
} }
void Service::DowntimeExpireTimerHandler(void) void Service::DowntimesExpireTimerHandler(void)
{ {
DynamicObject::Ptr object; DynamicObject::Ptr object;
BOOST_FOREACH(tie(tuples::ignore, object), DynamicType::GetByName("Service")->GetObjects()) { BOOST_FOREACH(tie(tuples::ignore, object), DynamicType::GetByName("Service")->GetObjects()) {

View File

@ -53,8 +53,8 @@ Service::~Service(void)
{ {
ServiceGroup::InvalidateMembersCache(); ServiceGroup::InvalidateMembersCache();
Host::InvalidateServicesCache(); Host::InvalidateServicesCache();
Service::InvalidateDowntimeCache(); Service::InvalidateDowntimesCache();
Service::InvalidateCommentCache(); Service::InvalidateCommentsCache();
} }
String Service::GetDisplayName(void) const String Service::GetDisplayName(void) const
@ -222,9 +222,9 @@ void Service::OnAttributeChanged(const String& name, const Value& oldValue)
Host::InvalidateServicesCache(); Host::InvalidateServicesCache();
UpdateSlaveNotifications(); UpdateSlaveNotifications();
} else if (name == "downtimes") } else if (name == "downtimes")
Service::InvalidateDowntimeCache(); Service::InvalidateDowntimesCache();
else if (name == "comments") else if (name == "comments")
Service::InvalidateCommentCache(); Service::InvalidateCommentsCache();
else if (name == "notifications") else if (name == "notifications")
UpdateSlaveNotifications(); UpdateSlaveNotifications();
else if (name == "check_interval") { else if (name == "check_interval") {

View File

@ -204,8 +204,8 @@ public:
static bool IsDowntimeActive(const Dictionary::Ptr& downtime); static bool IsDowntimeActive(const Dictionary::Ptr& downtime);
static bool IsDowntimeExpired(const Dictionary::Ptr& downtime); static bool IsDowntimeExpired(const Dictionary::Ptr& downtime);
static void InvalidateDowntimeCache(void); static void InvalidateDowntimesCache(void);
static void ValidateDowntimeCache(void); static void ValidateDowntimesCache(void);
bool IsInDowntime(void) const; bool IsInDowntime(void) const;
bool IsAcknowledged(void); bool IsAcknowledged(void);
@ -227,8 +227,8 @@ public:
static bool IsCommentExpired(const Dictionary::Ptr& comment); static bool IsCommentExpired(const Dictionary::Ptr& comment);
static void InvalidateCommentCache(void); static void InvalidateCommentsCache(void);
static void ValidateCommentCache(void); static void ValidateCommentsCache(void);
/* Notifications */ /* Notifications */
void RequestNotifications(NotificationType type) const; void RequestNotifications(NotificationType type) const;
@ -257,12 +257,12 @@ private:
/* Downtimes */ /* Downtimes */
static int m_NextDowntimeID; static int m_NextDowntimeID;
static map<int, String> m_LegacyDowntimeCache; static map<int, String> m_LegacyDowntimesCache;
static map<String, Service::WeakPtr> m_DowntimeCache; static map<String, Service::WeakPtr> m_DowntimesCache;
static bool m_DowntimeCacheValid; static bool m_DowntimesCacheValid;
static Timer::Ptr m_DowntimeExpireTimer; static Timer::Ptr m_DowntimesExpireTimer;
static void DowntimeExpireTimerHandler(void); static void DowntimesExpireTimerHandler(void);
void AddDowntimesToCache(void); void AddDowntimesToCache(void);
void RemoveExpiredDowntimes(void); void RemoveExpiredDowntimes(void);
@ -270,12 +270,12 @@ private:
/* Comments */ /* Comments */
static int m_NextCommentID; static int m_NextCommentID;
static map<int, String> m_LegacyCommentCache; static map<int, String> m_LegacyCommentsCache;
static map<String, Service::WeakPtr> m_CommentCache; static map<String, Service::WeakPtr> m_CommentsCache;
static bool m_CommentCacheValid; static bool m_CommentsCacheValid;
static Timer::Ptr m_CommentExpireTimer; static Timer::Ptr m_CommentsExpireTimer;
static void CommentExpireTimerHandler(void); static void CommentsExpireTimerHandler(void);
void AddCommentsToCache(void); void AddCommentsToCache(void);
void RemoveExpiredComments(void); void RemoveExpiredComments(void);