Merge pull request #5152 from taosdata/fix/TD-2910
[TD-2910]<fix>: fix onlineDnodes > totalDnodes issue
This commit is contained in:
commit
21d7ba3ef7
|
@ -67,6 +67,7 @@ void mnodeCleanupDnodes();
|
||||||
int32_t mnodeGetDnodesNum();
|
int32_t mnodeGetDnodesNum();
|
||||||
int32_t mnodeGetOnlinDnodesCpuCoreNum();
|
int32_t mnodeGetOnlinDnodesCpuCoreNum();
|
||||||
int32_t mnodeGetOnlineDnodesNum();
|
int32_t mnodeGetOnlineDnodesNum();
|
||||||
|
void mnodeGetOnlineAndTotalDnodesNum(int32_t *onlineNum, int32_t *totalNum);
|
||||||
void * mnodeGetNextDnode(void *pIter, SDnodeObj **pDnode);
|
void * mnodeGetNextDnode(void *pIter, SDnodeObj **pDnode);
|
||||||
void mnodeCancelGetNextDnode(void *pIter);
|
void mnodeCancelGetNextDnode(void *pIter);
|
||||||
void mnodeIncDnodeRef(SDnodeObj *pDnode);
|
void mnodeIncDnodeRef(SDnodeObj *pDnode);
|
||||||
|
|
|
@ -263,6 +263,28 @@ int32_t mnodeGetOnlineDnodesNum() {
|
||||||
return onlineDnodes;
|
return onlineDnodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void mnodeGetOnlineAndTotalDnodesNum(int32_t *onlineNum, int32_t *totalNum) {
|
||||||
|
SDnodeObj *pDnode = NULL;
|
||||||
|
void * pIter = NULL;
|
||||||
|
int32_t onlineDnodes = 0, totalDnodes = 0;
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
pIter = mnodeGetNextDnode(pIter, &pDnode);
|
||||||
|
if (pDnode == NULL) break;
|
||||||
|
if (pDnode->status != TAOS_DN_STATUS_OFFLINE) ++onlineDnodes;
|
||||||
|
++totalDnodes;
|
||||||
|
mnodeDecDnodeRef(pDnode);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (onlineNum) {
|
||||||
|
*onlineNum = onlineDnodes;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (totalNum) {
|
||||||
|
*totalNum = totalDnodes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void *mnodeGetDnode(int32_t dnodeId) {
|
void *mnodeGetDnode(int32_t dnodeId) {
|
||||||
return sdbGetRow(tsDnodeSdb, &dnodeId);
|
return sdbGetRow(tsDnodeSdb, &dnodeId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -280,8 +280,11 @@ static int32_t mnodeProcessHeartBeatMsg(SMnodeMsg *pMsg) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pRsp->onlineDnodes = htonl(mnodeGetOnlineDnodesNum());
|
int32_t onlineDnodes = 0, totalDnodes = 0;
|
||||||
pRsp->totalDnodes = htonl(mnodeGetDnodesNum());
|
mnodeGetOnlineAndTotalDnodesNum(&onlineDnodes, &totalDnodes);
|
||||||
|
|
||||||
|
pRsp->onlineDnodes = htonl(onlineDnodes);
|
||||||
|
pRsp->totalDnodes = htonl(totalDnodes);
|
||||||
mnodeGetMnodeEpSetForShell(&pRsp->epSet, false);
|
mnodeGetMnodeEpSetForShell(&pRsp->epSet, false);
|
||||||
|
|
||||||
pMsg->rpcRsp.rsp = pRsp;
|
pMsg->rpcRsp.rsp = pRsp;
|
||||||
|
|
Loading…
Reference in New Issue