diff --git a/lib/db_ido/endpointdbobject.cpp b/lib/db_ido/endpointdbobject.cpp index db024f4cb..5f6b46870 100644 --- a/lib/db_ido/endpointdbobject.cpp +++ b/lib/db_ido/endpointdbobject.cpp @@ -100,7 +100,7 @@ void EndpointDbObject::UpdateConnectedStatus(const Endpoint::Ptr& endpoint) int EndpointDbObject::EndpointIsConnected(const Endpoint::Ptr& endpoint) { - unsigned int is_connected = endpoint->IsConnected() ? 1 : 0; + unsigned int is_connected = endpoint->GetConnected() ? 1 : 0; /* if identity is equal to node, fake is_connected */ if (endpoint->GetName() == IcingaApplication::GetInstance()->GetNodeName()) diff --git a/lib/icinga/checkable-check.cpp b/lib/icinga/checkable-check.cpp index 6305a5ee3..da1bbd7ec 100644 --- a/lib/icinga/checkable-check.cpp +++ b/lib/icinga/checkable-check.cpp @@ -436,7 +436,7 @@ void Checkable::ExecuteCheck() Dictionary::Ptr macros = new Dictionary(); GetCheckCommand()->Execute(this, cr, macros, false); - if (endpoint->IsConnected()) { + if (endpoint->GetConnected()) { /* perform check on remote endpoint */ Dictionary::Ptr message = new Dictionary(); message->Set("jsonrpc", "2.0"); diff --git a/lib/livestatus/endpointstable.cpp b/lib/livestatus/endpointstable.cpp index fe8e53d51..0733b5527 100644 --- a/lib/livestatus/endpointstable.cpp +++ b/lib/livestatus/endpointstable.cpp @@ -105,7 +105,7 @@ Value EndpointsTable::IsConnectedAccessor(const Value& row) if (!endpoint) return Empty; - unsigned int is_connected = endpoint->IsConnected() ? 1 : 0; + unsigned int is_connected = endpoint->GetConnected() ? 1 : 0; /* if identity is equal to node, fake is_connected */ if (endpoint->GetName() == IcingaApplication::GetInstance()->GetNodeName()) diff --git a/lib/methods/clusterzonechecktask.cpp b/lib/methods/clusterzonechecktask.cpp index 38c8a718d..a3937eb80 100644 --- a/lib/methods/clusterzonechecktask.cpp +++ b/lib/methods/clusterzonechecktask.cpp @@ -84,7 +84,7 @@ void ClusterZoneCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const Che double zoneLag = 0; BOOST_FOREACH(const Endpoint::Ptr& endpoint, zone->GetEndpoints()) { - if (endpoint->IsConnected()) + if (endpoint->GetConnected()) connected = true; double eplag = ApiListener::CalculateZoneLag(endpoint); diff --git a/lib/remote/apilistener.cpp b/lib/remote/apilistener.cpp index 0b91b40cd..ba3b4fda7 100644 --- a/lib/remote/apilistener.cpp +++ b/lib/remote/apilistener.cpp @@ -154,7 +154,7 @@ Endpoint::Ptr ApiListener::GetMaster(void) const std::vector names; BOOST_FOREACH(const Endpoint::Ptr& endpoint, zone->GetEndpoints()) - if (endpoint->IsConnected() || endpoint->GetName() == GetIdentity()) + if (endpoint->GetConnected() || endpoint->GetName() == GetIdentity()) names.push_back(endpoint->GetName()); std::sort(names.begin(), names.end()); @@ -337,7 +337,7 @@ void ApiListener::NewClientHandlerInternal(const Socket::Ptr& client, const Stri bool need_sync = false; if (endpoint) - need_sync = !endpoint->IsConnected(); + need_sync = !endpoint->GetConnected(); ClientType ctype; @@ -477,7 +477,7 @@ void ApiListener::ApiTimerHandler(void) } /* don't try to connect if we're already connected */ - if (endpoint->IsConnected()) { + if (endpoint->GetConnected()) { Log(LogDebug, "ApiListener") << "Not connecting to Endpoint '" << endpoint->GetName() << "' because we're already connected to it."; @@ -490,7 +490,7 @@ void ApiListener::ApiTimerHandler(void) } BOOST_FOREACH(const Endpoint::Ptr& endpoint, ConfigType::GetObjectsByType()) { - if (!endpoint->IsConnected()) + if (!endpoint->GetConnected()) continue; double ts = endpoint->GetRemoteLogPosition(); @@ -522,7 +522,7 @@ void ApiListener::ApiTimerHandler(void) std::vector names; BOOST_FOREACH(const Endpoint::Ptr& endpoint, ConfigType::GetObjectsByType()) - if (endpoint->IsConnected()) + if (endpoint->GetConnected()) names.push_back(endpoint->GetName() + " (" + Convert::ToString(endpoint->GetClients().size()) + ")"); Log(LogNotice, "ApiListener") @@ -615,7 +615,7 @@ void ApiListener::SyncRelayMessage(const MessageOrigin::Ptr& origin, } /* don't relay messages to disconnected endpoints */ - if (!endpoint->IsConnected()) { + if (!endpoint->GetConnected()) { if (target_zone == my_zone) finishedLogZones.erase(target_zone); @@ -930,7 +930,7 @@ std::pair ApiListener::GetStatus(void) allEndpoints++; countZoneEndpoints++; - if (!endpoint->IsConnected()) { + if (!endpoint->GetConnected()) { allNotConnectedEndpoints->Add(endpoint->GetName()); } else { allConnectedEndpoints->Add(endpoint->GetName()); @@ -977,7 +977,7 @@ double ApiListener::CalculateZoneLag(const Endpoint::Ptr& endpoint) double remoteLogPosition = endpoint->GetRemoteLogPosition(); double eplag = Utility::GetTime() - remoteLogPosition; - if ((endpoint->GetSyncing() || !endpoint->IsConnected()) && remoteLogPosition != 0) + if ((endpoint->GetSyncing() || !endpoint->GetConnected()) && remoteLogPosition != 0) return eplag; return 0; diff --git a/lib/remote/authority.cpp b/lib/remote/authority.cpp index e737a99db..9f68925b5 100644 --- a/lib/remote/authority.cpp +++ b/lib/remote/authority.cpp @@ -49,7 +49,7 @@ static void AuthorityTimerHandler(void) std::vector endpoints; BOOST_FOREACH(const Endpoint::Ptr& endpoint, my_zone->GetEndpoints()) { - if (!endpoint->IsConnected() && endpoint != my_endpoint) + if (!endpoint->GetConnected() && endpoint != my_endpoint) continue; endpoints.push_back(endpoint); diff --git a/lib/remote/endpoint.cpp b/lib/remote/endpoint.cpp index b3cd83ea5..fc8c98642 100644 --- a/lib/remote/endpoint.cpp +++ b/lib/remote/endpoint.cpp @@ -109,7 +109,7 @@ Zone::Ptr Endpoint::GetZone(void) const return m_Zone; } -bool Endpoint::IsConnected(void) const +bool Endpoint::GetConnected(void) const { boost::mutex::scoped_lock lock(m_ClientsLock); return !m_Clients.empty(); diff --git a/lib/remote/endpoint.hpp b/lib/remote/endpoint.hpp index 0738572fe..7b40aa86a 100644 --- a/lib/remote/endpoint.hpp +++ b/lib/remote/endpoint.hpp @@ -50,7 +50,7 @@ public: intrusive_ptr GetZone(void) const; - bool IsConnected(void) const; + virtual bool GetConnected(void) const override; static Endpoint::Ptr GetLocalEndpoint(void); diff --git a/lib/remote/endpoint.ti b/lib/remote/endpoint.ti index f4eccef99..37a62ddce 100644 --- a/lib/remote/endpoint.ti +++ b/lib/remote/endpoint.ti @@ -39,6 +39,10 @@ class Endpoint : ConfigObject [no_user_modify] bool connecting; [no_user_modify] bool syncing; + + [no_user_modify, no_storage] bool connected { + get; + }; }; }