Add getter for endpoint 'connected' attribute

fixes #10394
This commit is contained in:
Gunnar Beutner 2015-10-22 10:52:38 +02:00
parent 3473731034
commit 4aa0165701
9 changed files with 19 additions and 15 deletions

View File

@ -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())

View File

@ -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");

View File

@ -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())

View File

@ -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);

View File

@ -154,7 +154,7 @@ Endpoint::Ptr ApiListener::GetMaster(void) const
std::vector<String> 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<Endpoint>()) {
if (!endpoint->IsConnected())
if (!endpoint->GetConnected())
continue;
double ts = endpoint->GetRemoteLogPosition();
@ -522,7 +522,7 @@ void ApiListener::ApiTimerHandler(void)
std::vector<String> names;
BOOST_FOREACH(const Endpoint::Ptr& endpoint, ConfigType::GetObjectsByType<Endpoint>())
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<Dictionary::Ptr, Dictionary::Ptr> 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;

View File

@ -49,7 +49,7 @@ static void AuthorityTimerHandler(void)
std::vector<Endpoint::Ptr> 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);

View File

@ -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();

View File

@ -50,7 +50,7 @@ public:
intrusive_ptr<Zone> GetZone(void) const;
bool IsConnected(void) const;
virtual bool GetConnected(void) const override;
static Endpoint::Ptr GetLocalEndpoint(void);

View File

@ -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;
};
};
}