diff --git a/include/common/tmsg.h b/include/common/tmsg.h index eab32a5dacef5654e1d2af06ec2b4de5e676229f..c0812bc780423a790eec0e67eb47cd772ac0f6f0 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -614,10 +614,11 @@ typedef struct { typedef struct { int32_t vgId; int8_t role; + int64_t numOfTables; + int64_t numOfTimeSeries; int64_t totalStorage; int64_t compStorage; int64_t pointsWritten; - int64_t tablesNum; } SVnodeLoad; typedef struct { diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index d9d3cca86272a987b563f5babb740cb0174a5d53..a1140689368a9de222354b9f78bb568d1f6e4d7b 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -489,10 +489,11 @@ int32_t tSerializeSStatusReq(void **buf, SStatusReq *pReq) { SVnodeLoad *pload = taosArrayGet(pReq->pVloads, i); tlen += taosEncodeFixedI32(buf, pload->vgId); tlen += taosEncodeFixedI8(buf, pload->role); + tlen += taosEncodeFixedI64(buf, pload->numOfTables); + tlen += taosEncodeFixedI64(buf, pload->numOfTimeSeries); tlen += taosEncodeFixedI64(buf, pload->totalStorage); tlen += taosEncodeFixedI64(buf, pload->compStorage); tlen += taosEncodeFixedI64(buf, pload->pointsWritten); - tlen += taosEncodeFixedI64(buf, pload->tablesNum); } return tlen; @@ -531,10 +532,11 @@ void *tDeserializeSStatusReq(void *buf, SStatusReq *pReq) { SVnodeLoad vload = {0}; buf = taosDecodeFixedI32(buf, &vload.vgId); buf = taosDecodeFixedI8(buf, &vload.role); + buf = taosDecodeFixedI64(buf, &vload.numOfTables); + buf = taosDecodeFixedI64(buf, &vload.numOfTimeSeries); buf = taosDecodeFixedI64(buf, &vload.totalStorage); buf = taosDecodeFixedI64(buf, &vload.compStorage); buf = taosDecodeFixedI64(buf, &vload.pointsWritten); - buf = taosDecodeFixedI64(buf, &vload.tablesNum); if (taosArrayPush(pReq->pVloads, &vload) == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; return NULL; diff --git a/source/dnode/mnode/impl/inc/mndDef.h b/source/dnode/mnode/impl/inc/mndDef.h index 445726fbe2cc197084b578d5228d36e28cc8744a..30e3fce34c8a3ecf1421c5f374212447139c32a4 100644 --- a/source/dnode/mnode/impl/inc/mndDef.h +++ b/source/dnode/mnode/impl/inc/mndDef.h @@ -283,8 +283,8 @@ typedef struct { uint32_t hashEnd; char dbName[TSDB_DB_FNAME_LEN]; int64_t dbUid; - int32_t numOfTables; - int32_t numOfTimeSeries; + int64_t numOfTables; + int64_t numOfTimeSeries; int64_t totalStorage; int64_t compStorage; int64_t pointsWritten; diff --git a/source/dnode/mnode/impl/src/mndDnode.c b/source/dnode/mnode/impl/src/mndDnode.c index c7a2724a44417f6b0d6922126e12b4c465477f77..4cbf7ea07ce4da8861590eac70872d16311c1eee 100644 --- a/source/dnode/mnode/impl/src/mndDnode.c +++ b/source/dnode/mnode/impl/src/mndDnode.c @@ -374,6 +374,27 @@ static int32_t mndProcessStatusReq(SMnodeMsg *pReq) { pDnode->numOfCores = statusReq.numOfCores; pDnode->numOfSupportVnodes = statusReq.numOfSupportVnodes; + int32_t numOfVloads = (int32_t)taosArrayGetSize(statusReq.pVloads); + for (int32_t v = 0; v < numOfVloads; ++v) { + SVnodeLoad *pVload = taosArrayGet(statusReq.pVloads, v); + + SVgObj *pVgroup = mndAcquireVgroup(pMnode, pVload->vgId); + if (pVgroup != NULL) { + if (pVload->role == TAOS_SYNC_STATE_LEADER) { + pVgroup->numOfTables = pVload->numOfTables; + pVgroup->numOfTimeSeries = pVload->numOfTimeSeries; + pVgroup->totalStorage = pVload->totalStorage; + pVgroup->compStorage = pVload->compStorage; + pVgroup->pointsWritten = pVload->pointsWritten; + } + for (int32_t vg = 0; vg < pVgroup->replica; ++vg) { + pVgroup->vnodeGid[vg].role = pVload->role; + } + } + + mndReleaseVgroup(pMnode, pVgroup); + } + SStatusRsp statusRsp = {0}; statusRsp.dver = sdbGetTableVer(pMnode->pSdb, SDB_DNODE); statusRsp.dnodeCfg.dnodeId = pDnode->id; diff --git a/source/dnode/vnode/CMakeLists.txt b/source/dnode/vnode/CMakeLists.txt index e625c56db177f6d4e1b2879796ebca547ca3fb70..e15a2ee8837eb88e20728b1aefc1420bf4f0339e 100644 --- a/source/dnode/vnode/CMakeLists.txt +++ b/source/dnode/vnode/CMakeLists.txt @@ -28,6 +28,7 @@ target_link_libraries( PUBLIC scheduler PUBLIC executor PUBLIC qworker + PUBLIC sync ) if(${BUILD_TEST}) diff --git a/source/dnode/vnode/src/vnd/vnodeInt.c b/source/dnode/vnode/src/vnd/vnodeInt.c index 3d23784e133f88138ec04ee5340323f8dde7d180..6d3fa5f7f35c07c4cc781921338eab85c8af6a3a 100644 --- a/source/dnode/vnode/src/vnd/vnodeInt.c +++ b/source/dnode/vnode/src/vnd/vnodeInt.c @@ -15,6 +15,7 @@ #define _DEFAULT_SOURCE #include "vnd.h" +#include "sync.h" // #include "vnodeInt.h" int32_t vnodeAlter(SVnode *pVnode, const SVnodeCfg *pCfg) { return 0; } @@ -23,7 +24,16 @@ int32_t vnodeCompact(SVnode *pVnode) { return 0; } int32_t vnodeSync(SVnode *pVnode) { return 0; } -int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad) { return 0; } +int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad) { + pLoad->vgId = pVnode->vgId; + pLoad->role = TAOS_SYNC_STATE_LEADER; + pLoad->numOfTables = 500; + pLoad->numOfTimeSeries = 400; + pLoad->totalStorage = 300; + pLoad->compStorage = 200; + pLoad->pointsWritten = 100; + return 0; +} int vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { vInfo("sync message is processed");