mirror of https://github.com/Icinga/icinga2.git
Fix: Endpoints were not properly marked as local.
This commit is contained in:
parent
70c66fa542
commit
5a7aeb1f19
|
@ -23,7 +23,7 @@ using namespace icinga;
|
||||||
|
|
||||||
void CheckerComponent::Start(void)
|
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
|
/* dummy registration so the delegation module knows this is a checker
|
||||||
TODO: figure out a better way for this */
|
TODO: figure out a better way for this */
|
||||||
|
|
|
@ -26,7 +26,7 @@ using namespace icinga;
|
||||||
*/
|
*/
|
||||||
void DemoComponent::Start(void)
|
void DemoComponent::Start(void)
|
||||||
{
|
{
|
||||||
m_Endpoint = Endpoint::MakeEndpoint("demo", true);
|
m_Endpoint = Endpoint::MakeEndpoint("demo", false);
|
||||||
m_Endpoint->RegisterTopicHandler("demo::HelloWorld",
|
m_Endpoint->RegisterTopicHandler("demo::HelloWorld",
|
||||||
boost::bind(&DemoComponent::HelloWorldRequestHandler, this, _2,
|
boost::bind(&DemoComponent::HelloWorldRequestHandler, this, _2,
|
||||||
_3));
|
_3));
|
||||||
|
|
|
@ -26,7 +26,7 @@ using namespace icinga;
|
||||||
*/
|
*/
|
||||||
void ReplicationComponent::Start(void)
|
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::OnRegistered.connect(boost::bind(&ReplicationComponent::LocalObjectRegisteredHandler, this, _1));
|
||||||
DynamicObject::OnUnregistered.connect(boost::bind(&ReplicationComponent::LocalObjectUnregisteredHandler, this, _1));
|
DynamicObject::OnUnregistered.connect(boost::bind(&ReplicationComponent::LocalObjectUnregisteredHandler, this, _1));
|
||||||
|
|
|
@ -76,15 +76,16 @@ Endpoint::Ptr Endpoint::GetByName(const String& name)
|
||||||
* Helper function for creating new endpoint objects.
|
* Helper function for creating new endpoint objects.
|
||||||
*
|
*
|
||||||
* @param name The name of the new endpoint.
|
* @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.
|
* @param local Whether the new endpoint should be local.
|
||||||
* @returns The new endpoint.
|
* @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>();
|
ConfigItemBuilder::Ptr endpointConfig = boost::make_shared<ConfigItemBuilder>();
|
||||||
endpointConfig->SetType("Endpoint");
|
endpointConfig->SetType("Endpoint");
|
||||||
endpointConfig->SetName(local ? "local:" + name : name);
|
endpointConfig->SetName(local ? "local:" + name : name);
|
||||||
endpointConfig->SetLocal(local ? 1 : 0);
|
endpointConfig->SetLocal(!replicated);
|
||||||
endpointConfig->AddExpression("local", OperatorSet, local);
|
endpointConfig->AddExpression("local", OperatorSet, local);
|
||||||
|
|
||||||
DynamicObject::Ptr object = endpointConfig->Compile()->Commit();
|
DynamicObject::Ptr object = endpointConfig->Compile()->Commit();
|
||||||
|
|
|
@ -69,7 +69,7 @@ public:
|
||||||
String GetNode(void) const;
|
String GetNode(void) const;
|
||||||
String GetService(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&)> OnConnected;
|
||||||
static boost::signal<void (const Endpoint::Ptr&)> OnDisconnected;
|
static boost::signal<void (const Endpoint::Ptr&)> OnDisconnected;
|
||||||
|
|
|
@ -81,7 +81,7 @@ void EndpointManager::SetIdentity(const String& identity)
|
||||||
if (object)
|
if (object)
|
||||||
m_Endpoint = dynamic_pointer_cast<Endpoint>(object);
|
m_Endpoint = dynamic_pointer_cast<Endpoint>(object);
|
||||||
else
|
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))
|
if (Endpoint::Exists(identity))
|
||||||
endpoint = Endpoint::GetByName(identity);
|
endpoint = Endpoint::GetByName(identity);
|
||||||
else
|
else
|
||||||
endpoint = Endpoint::MakeEndpoint(identity, false);
|
endpoint = Endpoint::MakeEndpoint(identity, true);
|
||||||
|
|
||||||
endpoint->SetClient(jclient);
|
endpoint->SetClient(jclient);
|
||||||
}
|
}
|
||||||
|
@ -310,9 +310,11 @@ void EndpointManager::SubscriptionTimerHandler(void)
|
||||||
if (!endpoint->IsLocalEndpoint())
|
if (!endpoint->IsLocalEndpoint())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
String topic;
|
if (endpoint->GetSubscriptions()) {
|
||||||
BOOST_FOREACH(tie(tuples::ignore, topic), endpoint->GetSubscriptions()) {
|
String topic;
|
||||||
subscriptions->Set(topic, topic);
|
BOOST_FOREACH(tie(tuples::ignore, topic), endpoint->GetSubscriptions()) {
|
||||||
|
subscriptions->Set(topic, topic);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue