]> granicus.if.org Git - icinga2/commitdiff
Fix: Endpoints were not properly marked as local.
authorGunnar Beutner <gunnar.beutner@netways.de>
Fri, 18 Jan 2013 08:36:28 +0000 (09:36 +0100)
committerGunnar Beutner <gunnar.beutner@netways.de>
Fri, 18 Jan 2013 08:37:27 +0000 (09:37 +0100)
components/checker/checkercomponent.cpp
components/demo/democomponent.cpp
components/replication/replicationcomponent.cpp
lib/remoting/endpoint.cpp
lib/remoting/endpoint.h
lib/remoting/endpointmanager.cpp

index 8e16d87ad2c0e76cdfccefb50392a53aa7fd094a..928289a47e05183c8f007edc97b0100e6d742187 100644 (file)
@@ -23,7 +23,7 @@ using namespace icinga;
 
 void CheckerComponent::Start(void)
 {
-       m_Endpoint = Endpoint::MakeEndpoint("checker", true);
+       m_Endpoint = Endpoint::MakeEndpoint("checker", false);
 
        /* dummy registration so the delegation module knows this is a checker
           TODO: figure out a better way for this */
index 17c3d4dbf88d0375c5345b192edf3b11031cf97a..b72b02f1ecb48316b0b2ae1350c9cfdece3d856c 100644 (file)
@@ -26,7 +26,7 @@ using namespace icinga;
  */
 void DemoComponent::Start(void)
 {
-       m_Endpoint = Endpoint::MakeEndpoint("demo", true);
+       m_Endpoint = Endpoint::MakeEndpoint("demo", false);
        m_Endpoint->RegisterTopicHandler("demo::HelloWorld",
            boost::bind(&DemoComponent::HelloWorldRequestHandler, this, _2,
            _3));
index f8ee5c68c7c589715e79790fa0d62009a1c80e40..ec717566a1e05a2a3e5e0f6abee2f102e2e875eb 100644 (file)
@@ -26,7 +26,7 @@ using namespace icinga;
  */
 void ReplicationComponent::Start(void)
 {
-       m_Endpoint = Endpoint::MakeEndpoint("replication", true);
+       m_Endpoint = Endpoint::MakeEndpoint("replication", false);
 
        DynamicObject::OnRegistered.connect(boost::bind(&ReplicationComponent::LocalObjectRegisteredHandler, this, _1));
        DynamicObject::OnUnregistered.connect(boost::bind(&ReplicationComponent::LocalObjectUnregisteredHandler, this, _1));
index 99d26848e0566fc31f22d2b09b88515c8d8400d9..b6e89f1f392fc5d2220216fa969af209f2e33d57 100644 (file)
@@ -76,15 +76,16 @@ Endpoint::Ptr Endpoint::GetByName(const String& name)
  * Helper function for creating new endpoint objects.
  *
  * @param name The name of the new endpoint.
+ * @param replicated Whether replication is enabled for the endpoint object.
  * @param local Whether the new endpoint should be local.
  * @returns The new endpoint.
  */
-Endpoint::Ptr Endpoint::MakeEndpoint(const String& name, bool local)
+Endpoint::Ptr Endpoint::MakeEndpoint(const String& name, bool replicated, bool local)
 {
        ConfigItemBuilder::Ptr endpointConfig = boost::make_shared<ConfigItemBuilder>();
        endpointConfig->SetType("Endpoint");
        endpointConfig->SetName(local ? "local:" + name : name);
-       endpointConfig->SetLocal(local ? 1 : 0);
+       endpointConfig->SetLocal(!replicated);
        endpointConfig->AddExpression("local", OperatorSet, local);
 
        DynamicObject::Ptr object = endpointConfig->Compile()->Commit();
index 744469723916a7e9a9110c4eefedfb652260f75f..9b8e22eb81fb92616f254030224d2b1e667b3b63 100644 (file)
@@ -69,7 +69,7 @@ public:
        String GetNode(void) const;
        String GetService(void) const;
 
-       static Endpoint::Ptr MakeEndpoint(const String& name, bool local);
+       static Endpoint::Ptr MakeEndpoint(const String& name, bool replicated, bool local = true);
 
        static boost::signal<void (const Endpoint::Ptr&)> OnConnected;
        static boost::signal<void (const Endpoint::Ptr&)> OnDisconnected;
index 299e24ab5400670e75ee139c3095a8b1f0985b13..799f3c2f8327240f22a7b21d10292201891caf51 100644 (file)
@@ -81,7 +81,7 @@ void EndpointManager::SetIdentity(const String& identity)
        if (object)
                m_Endpoint = dynamic_pointer_cast<Endpoint>(object);
        else
-               m_Endpoint = Endpoint::MakeEndpoint(identity, false);
+               m_Endpoint = Endpoint::MakeEndpoint(identity, true, true);
 }
 
 /**
@@ -173,7 +173,7 @@ void EndpointManager::ClientConnectedHandler(const Stream::Ptr& client, const St
        if (Endpoint::Exists(identity))
                endpoint = Endpoint::GetByName(identity);
        else
-               endpoint = Endpoint::MakeEndpoint(identity, false);
+               endpoint = Endpoint::MakeEndpoint(identity, true);
 
        endpoint->SetClient(jclient);
 }
@@ -310,9 +310,11 @@ void EndpointManager::SubscriptionTimerHandler(void)
                if (!endpoint->IsLocalEndpoint())
                        continue;
 
-               String topic;
-               BOOST_FOREACH(tie(tuples::ignore, topic), endpoint->GetSubscriptions()) {
-                       subscriptions->Set(topic, topic);
+               if (endpoint->GetSubscriptions()) {
+                       String topic;
+                       BOOST_FOREACH(tie(tuples::ignore, topic), endpoint->GetSubscriptions()) {
+                               subscriptions->Set(topic, topic);
+                       }
                }
        }