From ca51fe8c56f2f2d68f5a0fa694e93fe99d992935 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Mon, 26 May 2014 13:48:42 +0200 Subject: [PATCH] Remove the keep_alive attribute. Fixes #6304 --- doc/6-configuring-icinga-2.md | 1 - lib/remote/apiclient.cpp | 50 ----------------------------------- lib/remote/apiclient.hpp | 5 ---- lib/remote/endpoint.ti | 3 --- lib/remote/remote-type.conf | 1 - 5 files changed, 60 deletions(-) diff --git a/doc/6-configuring-icinga-2.md b/doc/6-configuring-icinga-2.md index 3c20fb8c1..0680dc46c 100644 --- a/doc/6-configuring-icinga-2.md +++ b/doc/6-configuring-icinga-2.md @@ -1602,7 +1602,6 @@ Attributes: ----------------|---------------- host |**Required.** The hostname/IP address of the remote Icinga 2 instance. port |**Optional.** The service name/port of the remote Icinga 2 instance. Defaults to `5665`. - keep_alive |**Optional.** Keep-alive duration for connections. Defaults to `5m`. log_duration |**Optional.** Duration for keeping replay logs on connection loss. Defaults to `1d`. diff --git a/lib/remote/apiclient.cpp b/lib/remote/apiclient.cpp index a3b518b1c..67a95623c 100644 --- a/lib/remote/apiclient.cpp +++ b/lib/remote/apiclient.cpp @@ -26,14 +26,9 @@ #include "base/utility.hpp" #include "base/logger_fwd.hpp" #include "base/exception.hpp" -#include "base/initialize.hpp" using namespace icinga; -Timer::Ptr ApiClient::m_KeepAliveTimer; - -INITIALIZE_ONCE(&ApiClient::StaticInitialize); - static Value SetLogPositionHandler(const MessageOrigin& origin, const Dictionary::Ptr& params); REGISTER_APIFUNCTION(SetLogPosition, log, &SetLogPositionHandler); @@ -43,14 +38,6 @@ ApiClient::ApiClient(const String& identity, const Stream::Ptr& stream, Connecti m_Endpoint = Endpoint::GetByName(identity); } -void ApiClient::StaticInitialize(void) -{ - m_KeepAliveTimer = make_shared(); - m_KeepAliveTimer->OnTimerExpired.connect(boost::bind(&ApiClient::KeepAliveTimerHandler)); - m_KeepAliveTimer->SetInterval(5); - m_KeepAliveTimer->Start(); -} - void ApiClient::Start(void) { boost::thread thread(boost::bind(&ApiClient::MessageThreadProc, static_cast(GetSelf()))); @@ -178,43 +165,6 @@ void ApiClient::MessageThreadProc(void) } } -void ApiClient::KeepAliveTimerHandler(void) -{ - double now = Utility::GetTime(); - - BOOST_FOREACH(const Endpoint::Ptr& endpoint, DynamicType::GetObjects()) { - if (endpoint->GetZone() == Zone::GetLocalZone()) - continue; - - if (endpoint->GetSyncing() || endpoint->GetKeepAlive() <= 0) - continue; - - double timeout = now - endpoint->GetKeepAlive(); - - BOOST_FOREACH(const ApiClient::Ptr& client, endpoint->GetClients()) { - if (client->m_Seen < timeout) { - Log(LogNotice, "remote", "Closing connection with inactive endpoint '" + endpoint->GetName() + "'"); - client->Disconnect(); - } - } - } - - - ApiListener::Ptr listener = ApiListener::GetInstance(); - - if (listener) { - double timeout = now - 60; - - BOOST_FOREACH(const ApiClient::Ptr& client, listener->GetAnonymousClients()) { - if (client->m_Seen < timeout) { - Log(LogNotice, "remote", "Closing connection with inactive anonymous endpoint '" + client->GetIdentity() + "'"); - client->Disconnect(); - } - } - } - -} - Value SetLogPositionHandler(const MessageOrigin& origin, const Dictionary::Ptr& params) { if (!params) diff --git a/lib/remote/apiclient.hpp b/lib/remote/apiclient.hpp index 3809f85ca..b491708c0 100644 --- a/lib/remote/apiclient.hpp +++ b/lib/remote/apiclient.hpp @@ -46,8 +46,6 @@ public: ApiClient(const String& identity, const Stream::Ptr& stream, ConnectionRole role); - static void StaticInitialize(void); - void Start(void); String GetIdentity(void) const; @@ -68,9 +66,6 @@ private: bool ProcessMessage(void); void MessageThreadProc(void); - - static Timer::Ptr m_KeepAliveTimer; - static void KeepAliveTimerHandler(void); }; } diff --git a/lib/remote/endpoint.ti b/lib/remote/endpoint.ti index dc0a9029e..cc06414db 100644 --- a/lib/remote/endpoint.ti +++ b/lib/remote/endpoint.ti @@ -9,9 +9,6 @@ class Endpoint : DynamicObject [config] String port { default {{{ return "5665"; }}} }; - [config] double keep_alive { - default {{{ return 300; }}} - }; [config] double log_duration { default {{{ return 86400; }}} }; diff --git a/lib/remote/remote-type.conf b/lib/remote/remote-type.conf index b458ccd5e..a4abff727 100644 --- a/lib/remote/remote-type.conf +++ b/lib/remote/remote-type.conf @@ -39,7 +39,6 @@ %attribute %string "host", %attribute %string "port", - %attribute %number "keep_alive", %attribute %number "log_duration" }