diff --git a/src/dnode/CMakeLists.txt b/src/dnode/CMakeLists.txt index f0be3f9044c0b2d8278192ea512c265a77a12517..a41b3734ebd2f56a9f1a387088c6ee5f124d57f9 100644 --- a/src/dnode/CMakeLists.txt +++ b/src/dnode/CMakeLists.txt @@ -25,6 +25,10 @@ IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM)) IF (TD_CLUSTER) TARGET_LINK_LIBRARIES(taosd cluster) ENDIF () + + IF (TD_VPEER) + TARGET_LINK_LIBRARIES(taosd balance) + ENDIF () SET(PREPARE_ENV_CMD "prepare_env_cmd") SET(PREPARE_ENV_TARGET "prepare_env_target") diff --git a/src/mnode/inc/mgmtBalance.h b/src/mnode/inc/mgmtBalance.h index 401074d1713b6ebe1ce95c3c882eaaf1499a85fe..05f2ed94a7f77a0c5314fe008106de62ff7b07c8 100644 --- a/src/mnode/inc/mgmtBalance.h +++ b/src/mnode/inc/mgmtBalance.h @@ -23,7 +23,7 @@ extern "C" { int32_t mgmtInitBalance(); void mgmtCleanupBalance(); -void mgmtStartBalanceTimer(int32_t afterMs) ; +void mgmtBalanceNotify() ; int32_t mgmtAllocVnodes(SVgObj *pVgroup); #ifdef __cplusplus diff --git a/src/mnode/src/mgmtBalance.c b/src/mnode/src/mgmtBalance.c index 3a7ae8dcde4f9cfecf5367fd8faddf917921339a..e3d7f61708c1ddc7840a8e45180ff6722a4f398d 100644 --- a/src/mnode/src/mgmtBalance.c +++ b/src/mnode/src/mgmtBalance.c @@ -18,11 +18,37 @@ #include "mgmtBalance.h" #include "mgmtDnode.h" -int32_t mgmtInitBalance() { return 0; } -void mgmtCleanupBalance() {} -void mgmtStartBalanceTimer(int32_t afterMs) {} +extern int32_t balanceInit(); +extern void balanceCleanUp(); +extern void balanceNotify(); +extern int32_t balanceAllocVnodes(SVgObj *pVgroup); + +int32_t mgmtInitBalance() { +#ifdef _VPEER + return balanceInit(); +#else + return 0; +#endif +} + +void mgmtCleanupBalance() { +#ifdef _VPEER + balanceCleanUp(); +#endif +} + +void mgmtBalanceNotify() { +#ifdef _VPEER + balanceNotify(); +#else + return 0; +#endif +} int32_t mgmtAllocVnodes(SVgObj *pVgroup) { +#ifdef _VPEER + return balanceAllocVnodes(pVgroup); +#else void * pNode = NULL; SDnodeObj *pDnode = NULL; SDnodeObj *pSelDnode = NULL; @@ -53,4 +79,5 @@ int32_t mgmtAllocVnodes(SVgObj *pVgroup) { mTrace("dnode:%d, alloc one vnode to vgroup, openVnodes:%d", pSelDnode->dnodeId, pSelDnode->openVnodes); return TSDB_CODE_SUCCESS; +#endif } diff --git a/src/mnode/src/mgmtDnode.c b/src/mnode/src/mgmtDnode.c index 14e23bad9f037fb0f3d13f82abdbe2c9220dbadc..ada0bce2e99881a7b91c17ccdbdf00384cdc1cc5 100644 --- a/src/mnode/src/mgmtDnode.c +++ b/src/mnode/src/mgmtDnode.c @@ -251,7 +251,7 @@ void mgmtProcessDnodeStatusMsg(SRpcMsg *rpcMsg) { if (pDnode->status != TSDB_DN_STATUS_READY) { mTrace("dnode:%d, from offline to online", pDnode->dnodeId); pDnode->status = TSDB_DN_STATUS_READY; - mgmtStartBalanceTimer(200); + mgmtBalanceNotify(); } mgmtDecDnodeRef(pDnode); diff --git a/src/mnode/src/mgmtVgroup.c b/src/mnode/src/mgmtVgroup.c index 9f6edb17e52d05d42859161c24a2d5d75b8f41eb..bbf960203a533285e857a14b9299d155791cd0a5 100644 --- a/src/mnode/src/mgmtVgroup.c +++ b/src/mnode/src/mgmtVgroup.c @@ -32,7 +32,7 @@ #include "mgmtVgroup.h" void *tsVgroupSdb = NULL; -static int32_t tsVgUpdateSize = 0; +int32_t tsVgUpdateSize = 0; static int32_t mgmtGetVgroupMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn); static int32_t mgmtRetrieveVgroups(SShowObj *pShow, char *data, int32_t rows, void *pConn); @@ -93,10 +93,12 @@ static int32_t mgmtVgroupActionInsert(SSdbOperDesc *pOper) { for (int32_t i = 0; i < pVgroup->numOfVnodes; ++i) { SDnodeObj *pDnode = mgmtGetDnode(pVgroup->vnodeGid[i].dnodeId); - pVgroup->vnodeGid[i].privateIp = pDnode->privateIp; - pVgroup->vnodeGid[i].publicIp = pDnode->publicIp; - atomic_add_fetch_32(&pDnode->openVnodes, 1); - mgmtDecDnodeRef(pDnode); + if (pDnode != NULL) { + pVgroup->vnodeGid[i].privateIp = pDnode->privateIp; + pVgroup->vnodeGid[i].publicIp = pDnode->publicIp; + atomic_add_fetch_32(&pDnode->openVnodes, 1); + mgmtDecDnodeRef(pDnode); + } } mgmtAddVgroupIntoDb(pVgroup);