double now = Utility::GetTime();
long tasks = 0;
- while (!m_Services.empty()) {
- CheckerComponent::ServiceMultiSet::iterator it = m_Services.begin();
+ while (!m_IdleServices.empty()) {
+ typedef nth_index<ServiceSet, 1>::type CheckTimeView;
+ CheckTimeView& idx = boost::get<1>(m_IdleServices);
+
+ CheckTimeView::iterator it = idx.begin();
Service::Ptr service = *it;
if (service->GetNextCheck() > now)
break;
- m_Services.erase(it);
+ idx.erase(it);
Logger::Write(LogDebug, "checker", "Executing service check for '" + service->GetName() + "'");
/* remove the service from the list of pending services; if it's not in the
* list this was a manual (i.e. forced) check and we must not re-add the
* service to the services list because it's already there. */
- CheckerComponent::ServiceMultiSet::iterator it;
+ CheckerComponent::ServiceSet::iterator it;
it = m_PendingServices.find(service);
if (it != m_PendingServices.end()) {
m_PendingServices.erase(it);
- m_Services.insert(service);
+ m_IdleServices.insert(service);
}
Logger::Write(LogDebug, "checker", "Check finished for service '" + service->GetName() + "'");
Logger::Write(LogDebug, "checker", "ResultTimerHandler entered.");
stringstream msgbuf;
- msgbuf << "Pending services: " << m_PendingServices.size() << "; Idle services: " << m_Services.size();
+ msgbuf << "Pending services: " << m_PendingServices.size() << "; Idle services: " << m_IdleServices.size();
Logger::Write(LogInformation, "checker", msgbuf.str());
}
service->UpdateNextCheck();
- m_Services.insert(service);
+ m_IdleServices.insert(service);
} else {
- m_Services.erase(service);
+ m_IdleServices.erase(service);
m_PendingServices.erase(service);
}
}
if (!service)
return;
- m_Services.erase(service);
+ m_IdleServices.erase(service);
m_PendingServices.erase(service);
}
namespace icinga
{
-struct ServiceNextCheckLessComparer
+struct ServiceNextCheckExtractor
{
-public:
- bool operator()(const Service::Ptr& a, const Service::Ptr& b)
+ typedef double result_type;
+
+ double operator()(const Service::Ptr& service)
{
- return a->GetNextCheck() > b->GetNextCheck();
+ return service->GetNextCheck();
}
};
typedef shared_ptr<CheckerComponent> Ptr;
typedef weak_ptr<CheckerComponent> WeakPtr;
- typedef multiset<Service::Ptr, ServiceNextCheckLessComparer> ServiceMultiSet;
+ typedef multi_index_container<
+ Service::Ptr,
+ indexed_by<
+ ordered_unique<identity<Service::Ptr> >,
+ ordered_non_unique<ServiceNextCheckExtractor>
+ >
+ > ServiceSet;
virtual void Start(void);
virtual void Stop(void);
private:
VirtualEndpoint::Ptr m_Endpoint;
- ServiceMultiSet m_Services;
- ServiceMultiSet m_PendingServices;
+ ServiceSet m_IdleServices;
+ ServiceSet m_PendingServices;
Timer::Ptr m_CheckTimer;
#include <i2-icinga.h>
#include <i2-cib.h>
-#include <queue>
+#include <boost/multi_index_container.hpp>
+#include <boost/multi_index/ordered_index.hpp>
+#include <boost/multi_index/key_extractors.hpp>
-using std::priority_queue;
+using boost::multi_index_container;
+using boost::multi_index::indexed_by;
+using boost::multi_index::identity;
+using boost::multi_index::ordered_unique;
+using boost::multi_index::ordered_non_unique;
+using boost::multi_index::nth_index;
#include "checkercomponent.h"