mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-22 21:24:41 +02:00
Bugfixes.
This commit is contained in:
parent
d4fb11d427
commit
7ed19cd533
@ -110,7 +110,7 @@ void Timer::Call(void)
|
|||||||
if (et - st > 3) {
|
if (et - st > 3) {
|
||||||
stringstream msgbuf;
|
stringstream msgbuf;
|
||||||
msgbuf << "Timer call took " << et - st << " seconds.";
|
msgbuf << "Timer call took " << et - st << " seconds.";
|
||||||
Application::Log(LogInformation, "base", msgbuf.str());
|
Application::Log(LogWarning, "base", msgbuf.str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,6 +66,10 @@ void ConfigRpcComponent::Stop(void)
|
|||||||
|
|
||||||
void ConfigRpcComponent::NewEndpointHandler(const Endpoint::Ptr& endpoint)
|
void ConfigRpcComponent::NewEndpointHandler(const Endpoint::Ptr& endpoint)
|
||||||
{
|
{
|
||||||
|
/* no need to sync the config with local endpoints */
|
||||||
|
if (endpoint->IsLocal())
|
||||||
|
return;
|
||||||
|
|
||||||
endpoint->OnSessionEstablished.connect(boost::bind(&ConfigRpcComponent::SessionEstablishedHandler, this, _1));
|
endpoint->OnSessionEstablished.connect(boost::bind(&ConfigRpcComponent::SessionEstablishedHandler, this, _1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,9 +30,6 @@ string DelegationComponent::GetName(void) const
|
|||||||
void DelegationComponent::Start(void)
|
void DelegationComponent::Start(void)
|
||||||
{
|
{
|
||||||
m_AllServices = boost::make_shared<ConfigObject::Set>(ConfigObject::GetAllObjects(), ConfigObject::MakeTypePredicate("service"));
|
m_AllServices = boost::make_shared<ConfigObject::Set>(ConfigObject::GetAllObjects(), ConfigObject::MakeTypePredicate("service"));
|
||||||
/* m_AllServices->OnObjectAdded.connect(boost::bind(&DelegationComponent::NewServiceHandler, this, _2));
|
|
||||||
m_AllServices->OnObjectCommitted.connect(boost::bind(&DelegationComponent::NewServiceHandler, this, _2));
|
|
||||||
m_AllServices->OnObjectRemoved.connect(boost::bind(&DelegationComponent::RemovedServiceHandler, this, _2));*/
|
|
||||||
m_AllServices->Start();
|
m_AllServices->Start();
|
||||||
|
|
||||||
m_DelegationTimer = boost::make_shared<Timer>();
|
m_DelegationTimer = boost::make_shared<Timer>();
|
||||||
@ -45,6 +42,8 @@ void DelegationComponent::Start(void)
|
|||||||
m_DelegationEndpoint->RegisterPublication("checker::AssignService");
|
m_DelegationEndpoint->RegisterPublication("checker::AssignService");
|
||||||
m_DelegationEndpoint->RegisterPublication("checker::ClearServices");
|
m_DelegationEndpoint->RegisterPublication("checker::ClearServices");
|
||||||
GetEndpointManager()->RegisterEndpoint(m_DelegationEndpoint);
|
GetEndpointManager()->RegisterEndpoint(m_DelegationEndpoint);
|
||||||
|
|
||||||
|
GetEndpointManager()->OnNewEndpoint.connect(bind(&DelegationComponent::NewEndpointHandler, this, _2));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DelegationComponent::Stop(void)
|
void DelegationComponent::Stop(void)
|
||||||
@ -110,6 +109,29 @@ vector<Endpoint::Ptr> DelegationComponent::GetCheckerCandidates(const Service& s
|
|||||||
return candidates;
|
return candidates;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DelegationComponent::NewEndpointHandler(const Endpoint::Ptr& endpoint)
|
||||||
|
{
|
||||||
|
endpoint->OnSessionEstablished.connect(bind(&DelegationComponent::SessionEstablishedHandler, this, _1));
|
||||||
|
}
|
||||||
|
void DelegationComponent::SessionEstablishedHandler(const Endpoint::Ptr& endpoint)
|
||||||
|
{
|
||||||
|
stringstream msgbuf;
|
||||||
|
msgbuf << "Clearing assigned services for endpoint '" << endpoint->GetIdentity() << "'";
|
||||||
|
Application::Log(LogInformation, "delegation", msgbuf.str());
|
||||||
|
|
||||||
|
/* locally clear checker for all services that previously belonged to this endpoint */
|
||||||
|
ConfigObject::Set::Iterator it;
|
||||||
|
for (it = m_AllServices->Begin(); it != m_AllServices->End(); it++) {
|
||||||
|
Service service = *it;
|
||||||
|
|
||||||
|
if (service.GetChecker() == endpoint->GetIdentity())
|
||||||
|
service.SetChecker("");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* remotely clear services for this endpoint */
|
||||||
|
ClearServices(endpoint);
|
||||||
|
}
|
||||||
|
|
||||||
void DelegationComponent::DelegationTimerHandler(void)
|
void DelegationComponent::DelegationTimerHandler(void)
|
||||||
{
|
{
|
||||||
map<Endpoint::Ptr, int> histogram;
|
map<Endpoint::Ptr, int> histogram;
|
||||||
@ -208,9 +230,6 @@ void DelegationComponent::DelegationTimerHandler(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (delegated > 0) {
|
if (delegated > 0) {
|
||||||
// TODO: send clear message when session is established
|
|
||||||
// TODO: clear local assignments when session is lost
|
|
||||||
need_clear = true; /* remove this once clear messages are properly sent */
|
|
||||||
if (need_clear) {
|
if (need_clear) {
|
||||||
map<Endpoint::Ptr, int>::iterator hit;
|
map<Endpoint::Ptr, int>::iterator hit;
|
||||||
for (hit = histogram.begin(); hit != histogram.end(); hit++) {
|
for (hit = histogram.begin(); hit != histogram.end(); hit++) {
|
||||||
@ -230,7 +249,7 @@ void DelegationComponent::DelegationTimerHandler(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
stringstream msgbuf;
|
stringstream msgbuf;
|
||||||
msgbuf << "Re-delegated " << delegated << " services";
|
msgbuf << "Updated delegations for " << delegated << " services";
|
||||||
Application::Log(LogInformation, "delegation", msgbuf.str());
|
Application::Log(LogInformation, "delegation", msgbuf.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,6 +38,9 @@ private:
|
|||||||
ConfigObject::Set::Ptr m_AllServices;
|
ConfigObject::Set::Ptr m_AllServices;
|
||||||
Timer::Ptr m_DelegationTimer;
|
Timer::Ptr m_DelegationTimer;
|
||||||
|
|
||||||
|
void NewEndpointHandler(const Endpoint::Ptr& endpoint);
|
||||||
|
void SessionEstablishedHandler(const Endpoint::Ptr& endpoint);
|
||||||
|
|
||||||
void AssignServiceResponseHandler(Service& service, const Endpoint::Ptr& sender, bool timedOut);
|
void AssignServiceResponseHandler(Service& service, const Endpoint::Ptr& sender, bool timedOut);
|
||||||
|
|
||||||
void DelegationTimerHandler(void);
|
void DelegationTimerHandler(void);
|
||||||
|
@ -105,9 +105,11 @@ void DiscoveryComponent::CheckExistingEndpoint(const Endpoint::Ptr& self, const
|
|||||||
*/
|
*/
|
||||||
void DiscoveryComponent::NewEndpointHandler(const Endpoint::Ptr& endpoint)
|
void DiscoveryComponent::NewEndpointHandler(const Endpoint::Ptr& endpoint)
|
||||||
{
|
{
|
||||||
/* ignore local endpoints */
|
/* immediately finish session setup for local endpoints */
|
||||||
if (endpoint->IsLocal())
|
if (endpoint->IsLocal()) {
|
||||||
|
endpoint->OnSessionEstablished(endpoint);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* accept discovery::RegisterComponent messages from any endpoint */
|
/* accept discovery::RegisterComponent messages from any endpoint */
|
||||||
endpoint->RegisterPublication("discovery::RegisterComponent");
|
endpoint->RegisterPublication("discovery::RegisterComponent");
|
||||||
@ -414,8 +416,8 @@ void DiscoveryComponent::ProcessDiscoveryMessage(const string& identity, const D
|
|||||||
|
|
||||||
SendDiscoveryMessage("discovery::NewComponent", identity, Endpoint::Ptr());
|
SendDiscoveryMessage("discovery::NewComponent", identity, Endpoint::Ptr());
|
||||||
|
|
||||||
/* don't send a welcome message for discovery::RegisterComponent messages */
|
/* don't send a welcome message for discovery::NewComponent messages */
|
||||||
if (endpoint && trusted)
|
if (endpoint && !trusted)
|
||||||
FinishDiscoverySetup(endpoint);
|
FinishDiscoverySetup(endpoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -485,6 +487,12 @@ void DiscoveryComponent::DiscoveryTimerHandler(void)
|
|||||||
if (identity == GetEndpointManager()->GetIdentity())
|
if (identity == GetEndpointManager()->GetIdentity())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
/* for explicitly-configured upstream endpoints
|
||||||
|
* we prefer to use the node/service from the
|
||||||
|
* config object - which is what the for loop above does */
|
||||||
|
if (ConfigObject::GetObject("endpoint", identity))
|
||||||
|
continue;
|
||||||
|
|
||||||
curr = i;
|
curr = i;
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user