fix: check server status
This commit is contained in:
parent
992a64e7c8
commit
e9586c693e
|
@ -2,7 +2,7 @@ aux_source_directory(src MGMT_DNODE)
|
||||||
add_library(mgmt_dnode STATIC ${MGMT_DNODE})
|
add_library(mgmt_dnode STATIC ${MGMT_DNODE})
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
mgmt_dnode
|
mgmt_dnode
|
||||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||||
)
|
)
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
mgmt_dnode node_util
|
mgmt_dnode node_util
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "uv.h"
|
#include "uv.h"
|
||||||
|
|
||||||
#include "dmUtil.h"
|
#include "dmUtil.h"
|
||||||
|
#include "dmInt.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
|
@ -236,29 +236,43 @@ void dmReportStartupByWrapper(SMgmtWrapper *pWrapper, const char *pName, const c
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dmGetServerStatus(SDnode *pDnode, SServerStatusRsp *pStatus) {
|
static void dmGetServerStatus(SDnode *pDnode, SServerStatusRsp *pStatus) {
|
||||||
|
SDnodeMgmt *pMgmt = pDnode->wrappers[DNODE].pMgmt;
|
||||||
|
pStatus->statusCode = TSDB_SRV_STATUS_SERVICE_OK;
|
||||||
pStatus->details[0] = 0;
|
pStatus->details[0] = 0;
|
||||||
|
|
||||||
if (pDnode->status == DND_STAT_INIT) {
|
if (pDnode->status == DND_STAT_INIT) {
|
||||||
pStatus->statusCode = TSDB_SRV_STATUS_NETWORK_OK;
|
pStatus->statusCode = TSDB_SRV_STATUS_NETWORK_OK;
|
||||||
snprintf(pStatus->details, sizeof(pStatus->details), "%s: %s", pDnode->startup.name, pDnode->startup.desc);
|
snprintf(pStatus->details, sizeof(pStatus->details), "%s: %s", pDnode->startup.name, pDnode->startup.desc);
|
||||||
} else if (pDnode->status == DND_STAT_STOPPED) {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pDnode->status == DND_STAT_STOPPED) {
|
||||||
pStatus->statusCode = TSDB_SRV_STATUS_EXTING;
|
pStatus->statusCode = TSDB_SRV_STATUS_EXTING;
|
||||||
} else {
|
return;
|
||||||
#if 0
|
|
||||||
SDnodeData *pData = &pDnode->data;
|
|
||||||
if (pData->isMnode && pData->mndState != TAOS_SYNC_STATE_LEADER && pData->mndState == TAOS_SYNC_STATE_CANDIDATE) {
|
|
||||||
pStatus->statusCode = TSDB_SRV_STATUS_SERVICE_DEGRADED;
|
|
||||||
snprintf(pStatus->details, sizeof(pStatus->details), "mnode sync state is %s", syncStr(pData->mndState));
|
|
||||||
} else if (pData->unsyncedVgId != 0 && pData->vndState != TAOS_SYNC_STATE_LEADER &&
|
|
||||||
pData->vndState != TAOS_SYNC_STATE_CANDIDATE) {
|
|
||||||
pStatus->statusCode = TSDB_SRV_STATUS_SERVICE_DEGRADED;
|
|
||||||
snprintf(pStatus->details, sizeof(pStatus->details), "vnode:%d sync state is %s", pData->unsyncedVgId,
|
|
||||||
syncStr(pData->vndState));
|
|
||||||
} else {
|
|
||||||
pStatus->statusCode = TSDB_SRV_STATUS_SERVICE_OK;
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
SMonMloadInfo minfo = {0};
|
||||||
|
dmGetMnodeLoads(pMgmt, &minfo);
|
||||||
|
if (minfo.isMnode && minfo.load.syncState != TAOS_SYNC_STATE_LEADER &&
|
||||||
|
minfo.load.syncState != TAOS_SYNC_STATE_CANDIDATE) {
|
||||||
|
pStatus->statusCode = TSDB_SRV_STATUS_SERVICE_DEGRADED;
|
||||||
|
snprintf(pStatus->details, sizeof(pStatus->details), "mnode sync state is %s", syncStr(minfo.load.syncState));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SMonVloadInfo vinfo = {0};
|
||||||
|
dmGetVnodeLoads(pMgmt, &vinfo);
|
||||||
|
for (int32_t i = 0; i < taosArrayGetSize(vinfo.pVloads); ++i) {
|
||||||
|
SVnodeLoad *pLoad = taosArrayGet(vinfo.pVloads, i);
|
||||||
|
if (pLoad->syncState != TAOS_SYNC_STATE_LEADER && pLoad->syncState != TAOS_SYNC_STATE_FOLLOWER) {
|
||||||
|
pStatus->statusCode = TSDB_SRV_STATUS_SERVICE_DEGRADED;
|
||||||
|
snprintf(pStatus->details, sizeof(pStatus->details), "vnode:%d sync state is %s", pLoad->vgId,
|
||||||
|
syncStr(pLoad->syncState));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
taosArrayDestroy(vinfo.pVloads);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dmProcessNetTestReq(SDnode *pDnode, SRpcMsg *pReq) {
|
void dmProcessNetTestReq(SDnode *pDnode, SRpcMsg *pReq) {
|
||||||
|
|
Loading…
Reference in New Issue