Make the delegation interval configurable.

This commit is contained in:
Gunnar Beutner 2013-02-13 09:55:39 +01:00
parent 800750c415
commit b17cafd0cf
3 changed files with 19 additions and 2 deletions

View File

@ -27,11 +27,22 @@ EXPORT_COMPONENT(delegation, DelegationComponent);
void DelegationComponent::Start(void)
{
m_DelegationTimer = boost::make_shared<Timer>();
m_DelegationTimer->SetInterval(30);
// TODO: implement a handler for config changes for the delegation_interval variable
m_DelegationTimer->SetInterval(GetDelegationInterval());
m_DelegationTimer->Reschedule(Utility::GetTime() + 10);
m_DelegationTimer->OnTimerExpired.connect(boost::bind(&DelegationComponent::DelegationTimerHandler, this));
m_DelegationTimer->Start();
}
double DelegationComponent::GetDelegationInterval(void) const
{
Value interval = GetConfig()->Get("delegation_interval");
if (interval.IsEmpty())
return 30;
else
return interval;
}
bool DelegationComponent::IsEndpointChecker(const Endpoint::Ptr& endpoint)
{
return (endpoint->HasSubscription("checker"));

View File

@ -39,6 +39,8 @@ private:
vector<Endpoint::Ptr> GetCheckerCandidates(const Service::Ptr& service) const;
static bool IsEndpointChecker(const Endpoint::Ptr& endpoint);
double GetDelegationInterval(void) const;
};
}

View File

@ -18,5 +18,9 @@
******************************************************************************/
local object Component "checker" {}
local object Component "delegation" {}
local object Component "delegation" {
delegation_interval = 120
}
local object Component "notification" {}