forked from Mirrors/privacore-open-source-search-engine
Moved dead host counting logic from PingServer to Hostdb
This commit is contained in:
@ -1274,6 +1274,14 @@ bool Hostdb::hasDeadHost ( ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int Hostdb::getNumHostsDead() {
|
||||
int count=0;
|
||||
for(int32_t i = 0; i < m_numHosts; i++)
|
||||
if(isDead(i))
|
||||
count++;
|
||||
return count;
|
||||
}
|
||||
|
||||
bool Hostdb::isDead ( int32_t hostId ) {
|
||||
Host *h = getHost ( hostId );
|
||||
return isDead ( h );
|
||||
|
1
Hostdb.h
1
Hostdb.h
@ -252,6 +252,7 @@ class Hostdb {
|
||||
bool isDead(const Host *h);
|
||||
|
||||
bool hasDeadHost ( );
|
||||
int getNumHostsDead();
|
||||
|
||||
int64_t getNumGlobalRecs ( );
|
||||
|
||||
|
11
Pages.cpp
11
Pages.cpp
@ -2321,8 +2321,6 @@ bool printRedBox2 ( SafeBuf *sb , TcpSocket *sock , HttpRequest *hr ) {
|
||||
// emergency message box
|
||||
bool printRedBox ( SafeBuf *mb , TcpSocket *sock , HttpRequest *hr ) {
|
||||
|
||||
PingServer *ps = &g_pingServer;
|
||||
|
||||
const char *box =
|
||||
"<table cellpadding=5 "
|
||||
// full width of enclosing div
|
||||
@ -2536,16 +2534,13 @@ bool printRedBox ( SafeBuf *mb , TcpSocket *sock , HttpRequest *hr ) {
|
||||
}
|
||||
|
||||
|
||||
if ( ps->getNumHostsDead() ) {
|
||||
if ( g_hostdb.hasDeadHost() ) {
|
||||
if ( adds ) mb->safePrintf("<br>");
|
||||
adds++;
|
||||
const char *s = "hosts are";
|
||||
if ( ps->getNumHostsDead() == 1 ) s = "host is";
|
||||
mb->safePrintf("%s",box);
|
||||
mb->safePrintf("%" PRId32" %s dead and not responding to "
|
||||
"pings. See the "
|
||||
mb->safePrintf("%d hosts are dead and not responding to pings. See the "
|
||||
"<a href=/admin/hosts?c=%s>hosts table</a>.",
|
||||
ps->getNumHostsDead() ,s ,coll);
|
||||
g_hostdb.getNumHostsDead(), coll);
|
||||
mb->safePrintf("%s",boxEnd);
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,6 @@ bool PingServer::init ( ) {
|
||||
m_minRepairModeBesides0Host = NULL;
|
||||
|
||||
m_numHostsWithForeignRecs = 0;
|
||||
m_numHostsDead = 0;
|
||||
m_hostsConfInDisagreement = false;
|
||||
m_hostsConfInAgreement = false;
|
||||
|
||||
@ -459,7 +458,6 @@ void PingServer::handleRequest11(UdpSlot *slot , int32_t /*niceness*/) {
|
||||
|
||||
PingServer *ps = &g_pingServer;
|
||||
ps->m_numHostsWithForeignRecs = 0;
|
||||
ps->m_numHostsDead = 0;
|
||||
ps->m_hostsConfInDisagreement = false;
|
||||
ps->m_hostsConfInAgreement = false;
|
||||
|
||||
@ -480,10 +478,6 @@ void PingServer::handleRequest11(UdpSlot *slot , int32_t /*niceness*/) {
|
||||
ps->m_numHostsWithForeignRecs++;
|
||||
}
|
||||
|
||||
if ( g_hostdb.isDead ( h2 ) ) {
|
||||
ps->m_numHostsDead++;
|
||||
}
|
||||
|
||||
// skip if not received yet
|
||||
if ( ! h2->m_pingInfo.m_hostsConfCRC ) {
|
||||
continue;
|
||||
|
@ -43,7 +43,6 @@ class PingServer {
|
||||
|
||||
bool hostsConfInDisagreement() const { return m_hostsConfInDisagreement; }
|
||||
bool hostsConfInAgreement() const { return m_hostsConfInAgreement; }
|
||||
int getNumHostsDead() const { return m_numHostsDead; }
|
||||
|
||||
Host *getMinRepairModeHost() const { return m_minRepairModeHost; }
|
||||
|
||||
@ -113,7 +112,6 @@ private:
|
||||
|
||||
// some cluster stats
|
||||
int32_t m_numHostsWithForeignRecs;
|
||||
int32_t m_numHostsDead;
|
||||
bool m_hostsConfInAgreement;
|
||||
bool m_hostsConfInDisagreement;
|
||||
};
|
||||
|
Reference in New Issue
Block a user