mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-24 22:24:44 +02:00
cluster: Heartbeat messages should include the endpoint's features.
This commit is contained in:
parent
7fcde9eca8
commit
05ba258500
@ -435,11 +435,13 @@ void ClusterComponent::NewClientHandler(const Socket::Ptr& client, TlsRole role)
|
|||||||
|
|
||||||
{
|
{
|
||||||
ObjectLock olock(this);
|
ObjectLock olock(this);
|
||||||
|
|
||||||
Stream::Ptr oldClient = endpoint->GetClient();
|
Stream::Ptr oldClient = endpoint->GetClient();
|
||||||
if (oldClient)
|
if (oldClient)
|
||||||
oldClient->Close();
|
oldClient->Close();
|
||||||
endpoint->SetClient(tlsStream);
|
|
||||||
ReplayLog(endpoint, tlsStream);
|
ReplayLog(endpoint, tlsStream);
|
||||||
|
endpoint->SetClient(tlsStream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -449,6 +451,12 @@ void ClusterComponent::ClusterTimerHandler(void)
|
|||||||
Dictionary::Ptr params = boost::make_shared<Dictionary>();
|
Dictionary::Ptr params = boost::make_shared<Dictionary>();
|
||||||
params->Set("identity", GetIdentity());
|
params->Set("identity", GetIdentity());
|
||||||
|
|
||||||
|
/* Eww. */
|
||||||
|
Dictionary::Ptr features = boost::make_shared<Dictionary>();
|
||||||
|
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<Dictionary>();
|
Dictionary::Ptr message = boost::make_shared<Dictionary>();
|
||||||
message->Set("jsonrpc", "2.0");
|
message->Set("jsonrpc", "2.0");
|
||||||
message->Set("method", "cluster::HeartBeat");
|
message->Set("method", "cluster::HeartBeat");
|
||||||
@ -456,16 +464,20 @@ void ClusterComponent::ClusterTimerHandler(void)
|
|||||||
|
|
||||||
RelayMessage(Endpoint::Ptr(), message, false);
|
RelayMessage(Endpoint::Ptr(), message, false);
|
||||||
|
|
||||||
/* check if we've recently seen heartbeat messages from our peers */
|
{
|
||||||
BOOST_FOREACH(const Endpoint::Ptr& endpoint, DynamicType::GetObjects<Endpoint>()) {
|
ObjectLock olock(this);
|
||||||
if (!endpoint->IsConnected() || endpoint->GetSeen() > Utility::GetTime() - 300)
|
/* check if we've recently seen heartbeat messages from our peers */
|
||||||
continue;
|
BOOST_FOREACH(const Endpoint::Ptr& endpoint, DynamicType::GetObjects<Endpoint>()) {
|
||||||
|
if (!endpoint->IsConnected() || endpoint->GetSeen() > Utility::GetTime() - 60)
|
||||||
|
continue;
|
||||||
|
|
||||||
Stream::Ptr client = endpoint->GetClient();
|
Stream::Ptr client = endpoint->GetClient();
|
||||||
|
|
||||||
if (client) {
|
if (client) {
|
||||||
Log(LogWarning, "cluster", "Closing connection for endpoiint '" + endpoint->GetName() + "' due to inactivity.");
|
Log(LogWarning, "cluster", "Closing connection for endpoint '" + endpoint->GetName() + "' due to inactivity.");
|
||||||
client->Close();
|
client->Close();
|
||||||
|
endpoint->SetClient(Endpoint::Ptr());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user