From b90b77b275fb70a02e3f5441f25fea317b3b8de4 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Thu, 14 Jan 2021 17:28:46 +0100 Subject: [PATCH] cluster-zone: consider own zone connected if there's only one endpoint ... because in this case only the checking node can be (not) connected to itself. refs #8570 --- lib/methods/clusterzonechecktask.cpp | 44 ++++++++++++++++------------ 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/lib/methods/clusterzonechecktask.cpp b/lib/methods/clusterzonechecktask.cpp index c5b6bbbf3..983719795 100644 --- a/lib/methods/clusterzonechecktask.cpp +++ b/lib/methods/clusterzonechecktask.cpp @@ -139,25 +139,33 @@ void ClusterZoneCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const Che double bytesSentPerSecond = 0; double bytesReceivedPerSecond = 0; - for (const Endpoint::Ptr& endpoint : zone->GetEndpoints()) { - if (endpoint->GetConnected()) + { + auto endpoints (zone->GetEndpoints()); + + for (const Endpoint::Ptr& endpoint : endpoints) { + if (endpoint->GetConnected()) + connected = true; + + double eplag = ApiListener::CalculateZoneLag(endpoint); + + if (eplag > 0 && eplag > zoneLag) + zoneLag = eplag; + + if (endpoint->GetLastMessageSent() > lastMessageSent) + lastMessageSent = endpoint->GetLastMessageSent(); + + if (endpoint->GetLastMessageReceived() > lastMessageReceived) + lastMessageReceived = endpoint->GetLastMessageReceived(); + + messagesSentPerSecond += endpoint->GetMessagesSentPerSecond(); + messagesReceivedPerSecond += endpoint->GetMessagesReceivedPerSecond(); + bytesSentPerSecond += endpoint->GetBytesSentPerSecond(); + bytesReceivedPerSecond += endpoint->GetBytesReceivedPerSecond(); + } + + if (!connected && endpoints.size() == 1u && *endpoints.begin() == Endpoint::GetLocalEndpoint()) { connected = true; - - double eplag = ApiListener::CalculateZoneLag(endpoint); - - if (eplag > 0 && eplag > zoneLag) - zoneLag = eplag; - - if (endpoint->GetLastMessageSent() > lastMessageSent) - lastMessageSent = endpoint->GetLastMessageSent(); - - if (endpoint->GetLastMessageReceived() > lastMessageReceived) - lastMessageReceived = endpoint->GetLastMessageReceived(); - - messagesSentPerSecond += endpoint->GetMessagesSentPerSecond(); - messagesReceivedPerSecond += endpoint->GetMessagesReceivedPerSecond(); - bytesSentPerSecond += endpoint->GetBytesSentPerSecond(); - bytesReceivedPerSecond += endpoint->GetBytesReceivedPerSecond(); + } } ServiceState state;