From b17cafd0cf378cbe0dc305ad5648332c5344d0a7 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Wed, 13 Feb 2013 09:55:39 +0100 Subject: [PATCH] Make the delegation interval configurable. --- components/delegation/delegationcomponent.cpp | 13 ++++++++++++- components/delegation/delegationcomponent.h | 2 ++ itl/standalone.conf | 6 +++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/components/delegation/delegationcomponent.cpp b/components/delegation/delegationcomponent.cpp index 5744b2dc7..0ec753ed7 100644 --- a/components/delegation/delegationcomponent.cpp +++ b/components/delegation/delegationcomponent.cpp @@ -27,11 +27,22 @@ EXPORT_COMPONENT(delegation, DelegationComponent); void DelegationComponent::Start(void) { m_DelegationTimer = boost::make_shared(); - 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")); diff --git a/components/delegation/delegationcomponent.h b/components/delegation/delegationcomponent.h index 4241a7d26..b47751b2f 100644 --- a/components/delegation/delegationcomponent.h +++ b/components/delegation/delegationcomponent.h @@ -39,6 +39,8 @@ private: vector GetCheckerCandidates(const Service::Ptr& service) const; static bool IsEndpointChecker(const Endpoint::Ptr& endpoint); + + double GetDelegationInterval(void) const; }; } diff --git a/itl/standalone.conf b/itl/standalone.conf index 53f88f1eb..023c7b10f 100644 --- a/itl/standalone.conf +++ b/itl/standalone.conf @@ -18,5 +18,9 @@ ******************************************************************************/ local object Component "checker" {} -local object Component "delegation" {} + +local object Component "delegation" { + delegation_interval = 120 +} + local object Component "notification" {}