]> granicus.if.org Git - icinga2/commitdiff
Increase reconnection timer interval for cluster connections
authorGunnar Beutner <gunnar.beutner@netways.de>
Thu, 21 Jul 2016 10:27:18 +0000 (12:27 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Thu, 21 Jul 2016 10:27:18 +0000 (12:27 +0200)
fixes #12193

lib/remote/apilistener.cpp
lib/remote/apilistener.hpp

index 4a31eb8e908fc6660f5d9b5d70c8314524ccbd62..01c7d6db3560451620cd644638c17a64181d0093 100644 (file)
@@ -142,6 +142,12 @@ void ApiListener::Start(bool runtimeCreated)
        m_Timer->Start();
        m_Timer->Reschedule(0);
 
+       m_ReconnectTimer = new Timer();
+       m_ReconnectTimer->OnTimerExpired.connect(boost::bind(&ApiListener::ApiReconnectTimerHandler, this));
+       m_ReconnectTimer->SetInterval(60);
+       m_ReconnectTimer->Start();
+       m_ReconnectTimer->Reschedule(0);
+
        OnMasterChanged(true);
 }
 
@@ -489,6 +495,46 @@ void ApiListener::ApiTimerHandler(void)
                }
        }
 
+       BOOST_FOREACH(const Endpoint::Ptr& endpoint, ConfigType::GetObjectsByType<Endpoint>()) {
+               if (!endpoint->GetConnected())
+                       continue;
+
+               double ts = endpoint->GetRemoteLogPosition();
+
+               if (ts == 0)
+                       continue;
+
+               Dictionary::Ptr lparams = new Dictionary();
+               lparams->Set("log_position", ts);
+
+               Dictionary::Ptr lmessage = new Dictionary();
+               lmessage->Set("jsonrpc", "2.0");
+               lmessage->Set("method", "log::SetLogPosition");
+               lmessage->Set("params", lparams);
+
+               double maxTs = 0;
+
+               BOOST_FOREACH(const JsonRpcConnection::Ptr& client, endpoint->GetClients()) {
+                       if (client->GetTimestamp() > maxTs)
+                               maxTs = client->GetTimestamp();
+               }
+
+               BOOST_FOREACH(const JsonRpcConnection::Ptr& client, endpoint->GetClients()) {
+                       if (client->GetTimestamp() != maxTs)
+                               client->Disconnect();
+                       else
+                               client->SendMessage(lmessage);
+               }
+
+               Log(LogNotice, "ApiListener")
+                   << "Setting log position for identity '" << endpoint->GetName() << "': "
+                   << Utility::FormatDateTime("%Y/%m/%d %H:%M:%S", ts);
+       }
+
+}
+
+void ApiListener::ApiReconnectTimerHandler(void)
+{
        Zone::Ptr my_zone = Zone::GetLocalZone();
 
        BOOST_FOREACH(const Zone::Ptr& zone, ConfigType::GetObjectsByType<Zone>()) {
@@ -541,42 +587,6 @@ void ApiListener::ApiTimerHandler(void)
                }
        }
 
-       BOOST_FOREACH(const Endpoint::Ptr& endpoint, ConfigType::GetObjectsByType<Endpoint>()) {
-               if (!endpoint->GetConnected())
-                       continue;
-
-               double ts = endpoint->GetRemoteLogPosition();
-
-               if (ts == 0)
-                       continue;
-
-               Dictionary::Ptr lparams = new Dictionary();
-               lparams->Set("log_position", ts);
-
-               Dictionary::Ptr lmessage = new Dictionary();
-               lmessage->Set("jsonrpc", "2.0");
-               lmessage->Set("method", "log::SetLogPosition");
-               lmessage->Set("params", lparams);
-
-               double maxTs = 0;
-
-               BOOST_FOREACH(const JsonRpcConnection::Ptr& client, endpoint->GetClients()) {
-                       if (client->GetTimestamp() > maxTs)
-                               maxTs = client->GetTimestamp();
-               }
-
-               BOOST_FOREACH(const JsonRpcConnection::Ptr& client, endpoint->GetClients()) {
-                       if (client->GetTimestamp() != maxTs)
-                               client->Disconnect();
-                       else
-                               client->SendMessage(lmessage);
-               }
-
-               Log(LogNotice, "ApiListener")
-                   << "Setting log position for identity '" << endpoint->GetName() << "': "
-                   << Utility::FormatDateTime("%Y/%m/%d %H:%M:%S", ts);
-       }
-
        Endpoint::Ptr master = GetMaster();
 
        if (master)
index 895524f6980ba1ba727189926ec3d12165ae630e..3f9a325a85febea9f5affc98076077d4b2e7b00e 100644 (file)
@@ -111,11 +111,13 @@ private:
        std::set<JsonRpcConnection::Ptr> m_AnonymousClients;
        std::set<HttpServerConnection::Ptr> m_HttpClients;
        Timer::Ptr m_Timer;
+       Timer::Ptr m_ReconnectTimer;
        Endpoint::Ptr m_LocalEndpoint;
 
        static ApiListener::Ptr m_Instance;
 
        void ApiTimerHandler(void);
+       void ApiReconnectTimerHandler(void);
 
        bool AddListener(const String& node, const String& service);
        void AddConnection(const Endpoint::Ptr& endpoint);