mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-26 23:24:09 +02:00
Removed the broker setting.
This commit is contained in:
parent
3214c29363
commit
208e055651
@ -42,17 +42,11 @@ void DiscoveryComponent::Start(void)
|
|||||||
{
|
{
|
||||||
m_DiscoveryEndpoint = make_shared<VirtualEndpoint>();
|
m_DiscoveryEndpoint = make_shared<VirtualEndpoint>();
|
||||||
|
|
||||||
long isBroker = 0;
|
|
||||||
GetConfig()->GetPropertyInteger("broker", &isBroker);
|
|
||||||
m_Broker = (isBroker != 0);
|
|
||||||
|
|
||||||
m_DiscoveryEndpoint->RegisterMethodSource("discovery::RegisterComponent");
|
m_DiscoveryEndpoint->RegisterMethodSource("discovery::RegisterComponent");
|
||||||
m_DiscoveryEndpoint->RegisterMethodHandler("discovery::RegisterComponent",
|
m_DiscoveryEndpoint->RegisterMethodHandler("discovery::RegisterComponent",
|
||||||
bind_weak(&DiscoveryComponent::RegisterComponentMessageHandler, shared_from_this()));
|
bind_weak(&DiscoveryComponent::RegisterComponentMessageHandler, shared_from_this()));
|
||||||
|
|
||||||
if (IsBroker())
|
m_DiscoveryEndpoint->RegisterMethodSource("discovery::NewComponent");
|
||||||
m_DiscoveryEndpoint->RegisterMethodSource("discovery::NewComponent");
|
|
||||||
|
|
||||||
m_DiscoveryEndpoint->RegisterMethodHandler("discovery::NewComponent",
|
m_DiscoveryEndpoint->RegisterMethodHandler("discovery::NewComponent",
|
||||||
bind_weak(&DiscoveryComponent::NewComponentMessageHandler, shared_from_this()));
|
bind_weak(&DiscoveryComponent::NewComponentMessageHandler, shared_from_this()));
|
||||||
|
|
||||||
@ -216,18 +210,6 @@ bool DiscoveryComponent::GetComponentDiscoveryInfo(string component, ComponentDi
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* IsBroker
|
|
||||||
*
|
|
||||||
* Returns whether this component is a broker.
|
|
||||||
*
|
|
||||||
* @returns true if the component is a broker, false otherwise.
|
|
||||||
*/
|
|
||||||
bool DiscoveryComponent::IsBroker(void) const
|
|
||||||
{
|
|
||||||
return m_Broker;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NewIdentityHandler
|
* NewIdentityHandler
|
||||||
*
|
*
|
||||||
@ -263,19 +245,17 @@ int DiscoveryComponent::NewIdentityHandler(const EventArgs& ea)
|
|||||||
|
|
||||||
map<string, ComponentDiscoveryInfo::Ptr>::iterator ic;
|
map<string, ComponentDiscoveryInfo::Ptr>::iterator ic;
|
||||||
|
|
||||||
if (IsBroker()) {
|
// we assume the other component _always_ wants
|
||||||
// we assume the other component _always_ wants
|
// discovery::NewComponent messages from us
|
||||||
// discovery::NewComponent messages from us
|
endpoint->RegisterMethodSink("discovery::NewComponent");
|
||||||
endpoint->RegisterMethodSink("discovery::NewComponent");
|
|
||||||
|
|
||||||
// send discovery::NewComponent message for ourselves
|
// send discovery::NewComponent message for ourselves
|
||||||
SendDiscoveryMessage("discovery::NewComponent", GetEndpointManager()->GetIdentity(), endpoint);
|
SendDiscoveryMessage("discovery::NewComponent", GetEndpointManager()->GetIdentity(), endpoint);
|
||||||
|
|
||||||
// send discovery::NewComponent messages for all components
|
// send discovery::NewComponent messages for all components
|
||||||
// we know about
|
// we know about
|
||||||
for (ic = m_Components.begin(); ic != m_Components.end(); ic++) {
|
for (ic = m_Components.begin(); ic != m_Components.end(); ic++) {
|
||||||
SendDiscoveryMessage("discovery::NewComponent", ic->first, endpoint);
|
SendDiscoveryMessage("discovery::NewComponent", ic->first, endpoint);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if we already know the other component
|
// check if we already know the other component
|
||||||
@ -500,12 +480,10 @@ void DiscoveryComponent::ProcessDiscoveryMessage(string identity, DiscoveryMessa
|
|||||||
|
|
||||||
m_Components[identity] = info;
|
m_Components[identity] = info;
|
||||||
|
|
||||||
if (IsBroker())
|
SendDiscoveryMessage("discovery::NewComponent", identity, Endpoint::Ptr());
|
||||||
SendDiscoveryMessage("discovery::NewComponent", identity, Endpoint::Ptr());
|
|
||||||
|
|
||||||
/* don't send a welcome message for discovery::RegisterComponent
|
/* don't send a welcome message for discovery::RegisterComponent messages */
|
||||||
messages unless we're a broker */
|
if (endpoint && trusted)
|
||||||
if (endpoint && (trusted || IsBroker()))
|
|
||||||
FinishDiscoverySetup(endpoint);
|
FinishDiscoverySetup(endpoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -608,18 +586,16 @@ int DiscoveryComponent::DiscoveryTimerHandler(const TimerEventArgs& tea)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsBroker()) {
|
/* send discovery message to all connected components to
|
||||||
/* send discovery message to all connected components to
|
refresh their TTL for this component */
|
||||||
refresh their TTL for this component */
|
SendDiscoveryMessage("discovery::NewComponent", identity, Endpoint::Ptr());
|
||||||
SendDiscoveryMessage("discovery::NewComponent", identity, Endpoint::Ptr());
|
|
||||||
}
|
|
||||||
|
|
||||||
Endpoint::Ptr endpoint = endpointManager->GetEndpointByIdentity(identity);
|
Endpoint::Ptr endpoint = endpointManager->GetEndpointByIdentity(identity);
|
||||||
if (endpoint && endpoint->IsConnected()) {
|
if (endpoint && endpoint->IsConnected()) {
|
||||||
/* update LastSeen if we're still connected to this endpoint */
|
/* update LastSeen if we're still connected to this endpoint */
|
||||||
info->LastSeen = now;
|
info->LastSeen = now;
|
||||||
} else {
|
} else {
|
||||||
/* TODO: figure out whether we actually want to connect to this component (_always_ if IsBroker() == true) */
|
/* TODO: figure out whether we actually want to connect to this component */
|
||||||
/* try and reconnect to this component */
|
/* try and reconnect to this component */
|
||||||
endpointManager->AddConnection(info->Node, info->Service);
|
endpointManager->AddConnection(info->Node, info->Service);
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,6 @@ class DiscoveryComponent : public IcingaComponent
|
|||||||
private:
|
private:
|
||||||
VirtualEndpoint::Ptr m_DiscoveryEndpoint;
|
VirtualEndpoint::Ptr m_DiscoveryEndpoint;
|
||||||
map<string, ComponentDiscoveryInfo::Ptr> m_Components;
|
map<string, ComponentDiscoveryInfo::Ptr> m_Components;
|
||||||
bool m_Broker;
|
|
||||||
Timer::Ptr m_DiscoveryTimer;
|
Timer::Ptr m_DiscoveryTimer;
|
||||||
|
|
||||||
int NewEndpointHandler(const NewEndpointEventArgs& neea);
|
int NewEndpointHandler(const NewEndpointEventArgs& neea);
|
||||||
@ -66,8 +65,6 @@ private:
|
|||||||
|
|
||||||
int DiscoveryTimerHandler(const TimerEventArgs& tea);
|
int DiscoveryTimerHandler(const TimerEventArgs& tea);
|
||||||
|
|
||||||
bool IsBroker(void) const;
|
|
||||||
|
|
||||||
void FinishDiscoverySetup(Endpoint::Ptr endpoint);
|
void FinishDiscoverySetup(Endpoint::Ptr endpoint);
|
||||||
|
|
||||||
int EndpointConfigHandler(const EventArgs& ea);
|
int EndpointConfigHandler(const EventArgs& ea);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user