]> granicus.if.org Git - icinga2/commitdiff
Remove selective reconnecting behavior
authorMarkus Frosch <markus@lazyfrosch.de>
Thu, 11 Jun 2015 21:02:13 +0000 (23:02 +0200)
committerMichael Friedrich <michael.friedrich@netways.de>
Mon, 15 Jun 2015 12:47:04 +0000 (14:47 +0200)
We want to remove the partial reconnecting behavior, so that all endpoints of
a zone try to connect to a lower or higher zone in hierarchy.

fixes #9406

Signed-off-by: Michael Friedrich <michael.friedrich@netways.de>
lib/remote/apilistener.cpp

index de96f97bf885069fd018fae234330fd7d2a2b130..7d218fe34a2bd5772e212cb8dd0a635c5c5a5477 100644 (file)
@@ -368,58 +368,47 @@ void ApiListener::ApiTimerHandler(void)
                }
        }
 
-       if (IsMaster()) {
-               Zone::Ptr my_zone = Zone::GetLocalZone();
+       Zone::Ptr my_zone = Zone::GetLocalZone();
+
+       BOOST_FOREACH(const Zone::Ptr& zone, DynamicType::GetObjectsByType<Zone>()) {
+               /* only connect to endpoints in a) the same zone b) our parent zone c) immediate child zones */
+               if (my_zone != zone && my_zone != zone->GetParent() && zone != my_zone->GetParent()) {
+                       Log(LogDebug, "ApiListener")
+                           << "Not connecting to Zone '" << zone->GetName() << "' because it's not in the same zone, a parent or a child zone.";
+                       continue;
+               }
 
-               BOOST_FOREACH(const Zone::Ptr& zone, DynamicType::GetObjectsByType<Zone>()) {
-                       /* only connect to endpoints in a) the same zone b) our parent zone c) immediate child zones */
-                       if (my_zone != zone && my_zone != zone->GetParent() && zone != my_zone->GetParent()) {
+               BOOST_FOREACH(const Endpoint::Ptr& endpoint, zone->GetEndpoints()) {
+                       /* don't connect to ourselves */
+                       if (endpoint->GetName() == GetIdentity()) {
                                Log(LogDebug, "ApiListener")
-                                   << "Not connecting to Zone '" << zone->GetName() << "' because it's not in the same zone, a parent or a child zone.";
+                                   << "Not connecting to Endpoint '" << endpoint->GetName() << "' because that's us.";
                                continue;
                        }
 
-                       bool connected = false;
-
-                       BOOST_FOREACH(const Endpoint::Ptr& endpoint, zone->GetEndpoints()) {
-                               if (endpoint->IsConnected()) {
-                                       connected = true;
-                                       break;
-                               }
+                       /* don't try to connect to endpoints which don't have a host and port */
+                       if (endpoint->GetHost().IsEmpty() || endpoint->GetPort().IsEmpty()) {
+                               Log(LogDebug, "ApiListener")
+                                   << "Not connecting to Endpoint '" << endpoint->GetName() << "' because the host/port attributes are missing.";
+                               continue;
                        }
 
-                       /* don't connect to an endpoint if we already have a connection to the zone */
-                       if (connected) {
+                       /* don't try to connect if there's already a connection attempt */
+                       if (endpoint->GetConnecting()) {
                                Log(LogDebug, "ApiListener")
-                                   << "Not connecting to Zone '" << zone->GetName() << "' because we're already connected to it.";
+                                   << "Not connecting to Endpoint '" << endpoint->GetName() << "' because we're already trying to connect to it.";
                                continue;
                        }
 
-                       BOOST_FOREACH(const Endpoint::Ptr& endpoint, zone->GetEndpoints()) {
-                               /* don't connect to ourselves */
-                               if (endpoint->GetName() == GetIdentity()) {
-                                       Log(LogDebug, "ApiListener")
-                                           << "Not connecting to Endpoint '" << endpoint->GetName() << "' because that's us.";
-                                       continue;
-                               }
-
-                               /* don't try to connect to endpoints which don't have a host and port */
-                               if (endpoint->GetHost().IsEmpty() || endpoint->GetPort().IsEmpty()) {
-                                       Log(LogDebug, "ApiListener")
-                                           << "Not connecting to Endpoint '" << endpoint->GetName() << "' because the host/port attributes are missing.";
-                                       continue;
-                               }
-
-                               /* don't try to connect if there's already a connection attempt */
-                               if (endpoint->GetConnecting()) {
-                                       Log(LogDebug, "ApiListener")
-                                           << "Not connecting to Endpoint '" << endpoint->GetName() << "' because we're already trying to connect to it.";
-                                       continue;
-                               }
-
-                               boost::thread thread(boost::bind(&ApiListener::AddConnection, this, endpoint));
-                               thread.detach();
+                       /* don't try to connect if we're already connected */
+                       if (endpoint->IsConnected()) {
+                               Log(LogDebug, "ApiListener")
+                                   << "Not connecting to Endpoint '" << endpoint->GetName() << "' because we're already connected to it.";
+                               continue;
                        }
+
+                       boost::thread thread(boost::bind(&ApiListener::AddConnection, this, endpoint));
+                       thread.detach();
                }
        }