From: Gunnar Beutner Date: Wed, 11 Sep 2013 07:40:29 +0000 (+0200) Subject: cluster: Heartbeat messages should include the endpoint's features. X-Git-Tag: v0.0.3~565 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=05ba2585000a687d2d449cb9cb277698c9c3e48e;p=icinga2 cluster: Heartbeat messages should include the endpoint's features. --- diff --git a/components/cluster/clustercomponent.cpp b/components/cluster/clustercomponent.cpp index fc70b7fbc..1044ce5c2 100644 --- a/components/cluster/clustercomponent.cpp +++ b/components/cluster/clustercomponent.cpp @@ -435,11 +435,13 @@ void ClusterComponent::NewClientHandler(const Socket::Ptr& client, TlsRole role) { ObjectLock olock(this); + Stream::Ptr oldClient = endpoint->GetClient(); if (oldClient) oldClient->Close(); - endpoint->SetClient(tlsStream); + ReplayLog(endpoint, tlsStream); + endpoint->SetClient(tlsStream); } } @@ -449,6 +451,12 @@ void ClusterComponent::ClusterTimerHandler(void) Dictionary::Ptr params = boost::make_shared(); params->Set("identity", GetIdentity()); + /* Eww. */ + Dictionary::Ptr features = boost::make_shared(); + features->Set("checker", DynamicType::GetByName("CheckerComponent") ? 1 : 0); + features->Set("notification", DynamicType::GetByName("NotificationComponent") ? 1 : 0); + params->Set("features", features); + Dictionary::Ptr message = boost::make_shared(); message->Set("jsonrpc", "2.0"); message->Set("method", "cluster::HeartBeat"); @@ -456,16 +464,20 @@ void ClusterComponent::ClusterTimerHandler(void) RelayMessage(Endpoint::Ptr(), message, false); - /* check if we've recently seen heartbeat messages from our peers */ - BOOST_FOREACH(const Endpoint::Ptr& endpoint, DynamicType::GetObjects()) { - if (!endpoint->IsConnected() || endpoint->GetSeen() > Utility::GetTime() - 300) - continue; + { + ObjectLock olock(this); + /* check if we've recently seen heartbeat messages from our peers */ + BOOST_FOREACH(const Endpoint::Ptr& endpoint, DynamicType::GetObjects()) { + if (!endpoint->IsConnected() || endpoint->GetSeen() > Utility::GetTime() - 60) + continue; - Stream::Ptr client = endpoint->GetClient(); + Stream::Ptr client = endpoint->GetClient(); - if (client) { - Log(LogWarning, "cluster", "Closing connection for endpoiint '" + endpoint->GetName() + "' due to inactivity."); - client->Close(); + if (client) { + Log(LogWarning, "cluster", "Closing connection for endpoint '" + endpoint->GetName() + "' due to inactivity."); + client->Close(); + endpoint->SetClient(Endpoint::Ptr()); + } } }