From efff45cf0bff7ec0ed1af49e61a43f70a08850ef Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Tue, 3 Jul 2012 15:26:58 +0200 Subject: [PATCH] Removed obsolete code. --- cib/service.cpp | 101 +++++++----------------------------------------- cib/service.h | 5 --- 2 files changed, 13 insertions(+), 93 deletions(-) diff --git a/cib/service.cpp b/cib/service.cpp index 13e3fc002..0f56d0fd5 100644 --- a/cib/service.cpp +++ b/cib/service.cpp @@ -107,101 +107,26 @@ Dictionary::Ptr Service::GetCheckers(void) const return value; } -vector Service::GetParents(void) const +bool Service::IsReachable(void) const { - vector parents; - Dictionary::Ptr dependencies = GetDependencies(); - if (dependencies) { - Dictionary::Iterator it; - for (it = dependencies->Begin(); it != dependencies->End(); it++) - parents.push_back(Service::GetByName(it->second)); - } - return parents; -} - -vector Service::GetChildren(void) const -{ - vector children; - - UpdateDependencyCache(); - Dictionary::Ptr childrenCache; - GetConfigObject()->GetTag("dependency_children", &childrenCache); - - if (childrenCache) { + if (dependencies) { Dictionary::Iterator it; - for (it = childrenCache->Begin(); it != childrenCache->End(); it++) - children.push_back(Service::GetByName(it->second)); - } - - return children; -} - -void Service::UpdateDependencyCache(void) -{ - static long cacheTx = 0; - - if (m_DependencyCacheValid) - return; - - cacheTx++; + for (it = dependencies->Begin(); it != dependencies->End(); it++) { + Service service = Service::GetByName(it->second); - ConfigObject::TMap::Range range = ConfigObject::GetObjects("service"); - ConfigObject::TMap::Iterator it; - for (it = range.first; it != range.second; it++) { - Service child = it->second; + /* ignore ourselves */ + if (service.GetName() == GetName()) + continue; - vector parents = child.GetParents(); - - vector::iterator st; - for (st = parents.begin(); st != parents.end(); st++) { - Service parent = *st; - - long tx = 0; - parent.GetConfigObject()->GetTag("dependency_cache_tx", &tx); - - Dictionary::Ptr children; - - /* rather than resetting the dependency dictionary in a separate loop we use the cache_tx - * tag to check if the dictionary is from this cache update run. */ - if (tx != cacheTx) { - children = boost::make_shared(); - parent.GetConfigObject()->SetTag("dependency_children", children); - parent.GetConfigObject()->SetTag("dependency_cache_tx", cacheTx); - } else { - parent.GetConfigObject()->GetTag("dependency_children", &children); - assert(children); - } - - children->AddUnnamedProperty(child.GetName()); - } - } - - m_DependencyCacheValid = true; -} - -void Service::InvalidateDependencyCache(void) -{ - m_DependencyCacheValid = false; -} - -bool Service::IsReachable(void) const -{ - vector parents = GetParents(); - - vector::iterator it; - for (it = parents.begin(); it != parents.end(); it++) { - /* ignore ourselves */ - if (it->GetName() == GetName()) - continue; - - if (!it->IsReachable()) - return false; + if (!service.IsReachable()) + return false; - if (it->GetStateType() == StateTypeHard && it->GetState() != StateOK && - it->GetState() != StateWarning) - return false; + if (service.GetStateType() == StateTypeHard && service.GetState() != StateOK && + service.GetState() != StateWarning) + return false; + } } return true; diff --git a/cib/service.h b/cib/service.h index 67eddb9ff..a10a58440 100644 --- a/cib/service.h +++ b/cib/service.h @@ -44,11 +44,6 @@ public: Dictionary::Ptr GetGroups(void) const; Dictionary::Ptr GetCheckers(void) const; - vector GetParents(void) const; - vector GetChildren(void) const; - static void UpdateDependencyCache(void); - static void InvalidateDependencyCache(void); - bool IsReachable(void) const; void SetNextCheck(time_t nextCheck); -- 2.40.0