Keep our own Host::m_flags up-to-date
This commit is contained in:
parent
5a78eac74f
commit
61dc9e4573
@ -1,6 +1,7 @@
|
||||
// Copyright 2008, Gigablast Inc.
|
||||
#include "DailyMerge.h"
|
||||
#include "Hostdb.h"
|
||||
#include "HostFlags.h"
|
||||
#include "Repair.h"
|
||||
#include "Rdb.h"
|
||||
#include "Process.h" // g_process.m_processStartTime
|
||||
|
27
HostFlags.cpp
Normal file
27
HostFlags.cpp
Normal file
@ -0,0 +1,27 @@
|
||||
#include "HostFlags.h"
|
||||
#include "SpiderLoop.h"
|
||||
#include "Process.h"
|
||||
#include "Rebalance.h"
|
||||
#include "Repair.h"
|
||||
#include "DailyMerge.h"
|
||||
#include "PingServer.h" //g_recoveryMode
|
||||
|
||||
|
||||
int getOurHostFlags() {
|
||||
// flags indicating our state
|
||||
int32_t flags = 0;
|
||||
// let others know we are doing our daily merge and have turned off
|
||||
// our spiders. when host #0 indicates this state it will wait
|
||||
// for all other hosts to enter the mergeMode. when other hosts
|
||||
// receive this state from host #0, they will start their daily merge.
|
||||
if ( g_spiderLoop.getNumSpidersOut() > 0 ) flags |= PFLAG_HASSPIDERS;
|
||||
if ( g_process.isRdbMerging() ) flags |= PFLAG_MERGING;
|
||||
if ( g_process.isRdbDumping() ) flags |= PFLAG_DUMPING;
|
||||
if ( g_rebalance.m_isScanning ) flags |= PFLAG_REBALANCING;
|
||||
if ( g_recoveryMode ) flags |= PFLAG_RECOVERYMODE;
|
||||
if ( g_rebalance.m_numForeignRecs ) flags |= PFLAG_FOREIGNRECS;
|
||||
if ( g_dailyMerge.m_mergeMode == 0 ) flags |= PFLAG_MERGEMODE0;
|
||||
if ( g_dailyMerge.m_mergeMode ==0 || g_dailyMerge.m_mergeMode == 6 )
|
||||
flags |= PFLAG_MERGEMODE0OR6;
|
||||
return flags;
|
||||
}
|
19
HostFlags.h
Normal file
19
HostFlags.h
Normal file
@ -0,0 +1,19 @@
|
||||
#ifndef HOSTFLAGS_H_
|
||||
#define HOSTFLAGS_H_
|
||||
|
||||
// for the Host::m_flags
|
||||
#define PFLAG_HASSPIDERS 0x01
|
||||
#define PFLAG_MERGING 0x02
|
||||
#define PFLAG_DUMPING 0x04
|
||||
// these two flags are used by DailyMerge.cpp to sync the daily merge
|
||||
// between all the hosts in the cluster
|
||||
#define PFLAG_MERGEMODE0 0x08
|
||||
#define PFLAG_MERGEMODE0OR6 0x10
|
||||
#define PFLAG_REBALANCING 0x20
|
||||
#define PFLAG_FOREIGNRECS 0x40
|
||||
#define PFLAG_RECOVERYMODE 0x80
|
||||
|
||||
|
||||
int getOurHostFlags();
|
||||
|
||||
#endif
|
@ -10,6 +10,7 @@
|
||||
#include "Titledb.h"
|
||||
#include "Spider.h"
|
||||
#include "Clusterdb.h"
|
||||
#include "HostFlags.h"
|
||||
#include "Dns.h"
|
||||
#include "File.h"
|
||||
#include "IPAddressChecks.h"
|
||||
@ -1458,6 +1459,11 @@ void Hostdb::updateAliveHosts(const int32_t alive_hosts_ids[], size_t n) {
|
||||
m_numHostsAlive++;
|
||||
}
|
||||
|
||||
void Hostdb::setOurFlags() {
|
||||
m_myHost->m_flags = getOurHostFlags();
|
||||
m_myHost->m_flagsValid = true;
|
||||
}
|
||||
|
||||
|
||||
// assume to be from posdb here
|
||||
uint32_t Hostdb::getShardNumByTermId(const void *k) const {
|
||||
|
14
Hostdb.h
14
Hostdb.h
@ -21,18 +21,6 @@
|
||||
/// @note ALC there used to be a sync host functionality that was removed
|
||||
/// in commit 08e8eeb2a53b41763b5d7f97a0b953bebb04517a because it wasn't working
|
||||
|
||||
// for the Host::m_flags
|
||||
#define PFLAG_HASSPIDERS 0x01
|
||||
#define PFLAG_MERGING 0x02
|
||||
#define PFLAG_DUMPING 0x04
|
||||
// these two flags are used by DailyMerge.cpp to sync the daily merge
|
||||
// between all the hosts in the cluster
|
||||
#define PFLAG_MERGEMODE0 0x08
|
||||
#define PFLAG_MERGEMODE0OR6 0x10
|
||||
#define PFLAG_REBALANCING 0x20
|
||||
#define PFLAG_FOREIGNRECS 0x40
|
||||
#define PFLAG_RECOVERYMODE 0x80
|
||||
|
||||
#define HT_GRUNT 0x01
|
||||
#define HT_SPARE 0x02
|
||||
#define HT_PROXY 0x04
|
||||
@ -358,6 +346,8 @@ class Hostdb {
|
||||
void updatePingInfo(Host *h, const PingInfo &pi);
|
||||
void updateAliveHosts(const int32_t alive_hosts_ids[], size_t n);
|
||||
|
||||
void setOurFlags();
|
||||
|
||||
// our host's info used by Udp* classes for internal communication
|
||||
uint32_t m_myIp;
|
||||
uint32_t m_myIpShotgun;
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include "Collectiondb.h"
|
||||
#include "Version.h"
|
||||
#include "repair_mode.h"
|
||||
#include "PingServer.h"
|
||||
#include "HostFlags.h"
|
||||
#include "Process.h"
|
||||
#include "IOBuffer.h"
|
||||
#include <pthread.h>
|
||||
|
2
Makefile
2
Makefile
@ -25,7 +25,7 @@ OBJS_O0 = \
|
||||
Mem.o Msg0.o Msg4In.o Msg4Out.o MsgC.o Msg13.o Msg20.o Msg22.o Msg39.o Msg3a.o Msg51.o Msge0.o Msge1.o Multicast.o \
|
||||
Parms.o Pages.o PageAddColl.o PageAddUrl.o PageBasic.o PageCrawlBot.o PageGet.o PageHealthCheck.o PageHosts.o PageInject.o \
|
||||
PageParser.o PagePerf.o PageReindex.o PageResults.o PageRoot.o PageSockets.o PageStats.o PageThreads.o PageTitledb.o PageSpider.o \
|
||||
Phrases.o PingServer.o Process.o Proxy.o Punycode.o \
|
||||
Phrases.o PingServer.o HostFlags.o Process.o Proxy.o Punycode.o \
|
||||
InstanceInfoExchange.o \
|
||||
Query.o \
|
||||
RdbCache.o RdbDump.o RdbMem.o RdbMerge.o RdbScan.o RdbTree.o \
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "HttpServer.h"
|
||||
#include "Pages.h"
|
||||
#include "Hostdb.h"
|
||||
#include "HostFlags.h"
|
||||
#include "sort.h"
|
||||
#include "Conf.h"
|
||||
#include "ip.h"
|
||||
@ -253,6 +254,8 @@ skipReplaceHost:
|
||||
if(format==FORMAT_JSON)
|
||||
sb.safePrintf("\t\"hosts\": [\n");
|
||||
|
||||
g_hostdb.setOurFlags();
|
||||
|
||||
//int32_t ng = g_hostdb.getNumGroups();
|
||||
for ( int32_t si = 0 ; si < nh ; si++ ) {
|
||||
int32_t i = hostSort[si];
|
||||
@ -1004,7 +1007,7 @@ static int32_t generatePingMsg( Host *h, int64_t nowms, char *buf ) {
|
||||
sprintf ( buf , "%" PRId32"ms", ping );
|
||||
// ping time ptr
|
||||
// make it "DEAD" if > 6000
|
||||
if ( ping >= g_conf.m_deadHostTimeout ) {
|
||||
if ( g_hostdb.isDead(h) ) {
|
||||
sprintf(buf, "<font color=#ff0000><b>DEAD</b></font>");
|
||||
}
|
||||
|
||||
|
@ -1022,23 +1022,3 @@ void PingServer::sendEmailMsg ( int32_t *lastTimeStamp , const char *msg ) {
|
||||
*lastTimeStamp = now;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int getOurHostFlags() {
|
||||
// flags indicating our state
|
||||
int32_t flags = 0;
|
||||
// let others know we are doing our daily merge and have turned off
|
||||
// our spiders. when host #0 indicates this state it will wait
|
||||
// for all other hosts to enter the mergeMode. when other hosts
|
||||
// receive this state from host #0, they will start their daily merge.
|
||||
if ( g_spiderLoop.getNumSpidersOut() > 0 ) flags |= PFLAG_HASSPIDERS;
|
||||
if ( g_process.isRdbMerging() ) flags |= PFLAG_MERGING;
|
||||
if ( g_process.isRdbDumping() ) flags |= PFLAG_DUMPING;
|
||||
if ( g_rebalance.m_isScanning ) flags |= PFLAG_REBALANCING;
|
||||
if ( g_recoveryMode ) flags |= PFLAG_RECOVERYMODE;
|
||||
if ( g_rebalance.m_numForeignRecs ) flags |= PFLAG_FOREIGNRECS;
|
||||
if ( g_dailyMerge.m_mergeMode == 0 ) flags |= PFLAG_MERGEMODE0;
|
||||
if ( g_dailyMerge.m_mergeMode ==0 || g_dailyMerge.m_mergeMode == 6 )
|
||||
flags |= PFLAG_MERGEMODE0OR6;
|
||||
return flags;
|
||||
}
|
||||
|
@ -120,6 +120,4 @@ extern class PingServer g_pingServer;
|
||||
extern bool g_recoveryMode;
|
||||
extern int32_t g_recoveryLevel;
|
||||
|
||||
int getOurHostFlags();
|
||||
|
||||
#endif // GB_PINGSERVER_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user