diff --git a/src/inc/mnode.h b/src/inc/mnode.h index 3f66c46d7b31ce4e0e690c539bb5f273aab649c6..651ad0036edf9f80abad52660e9cdc813b89dcde 100644 --- a/src/inc/mnode.h +++ b/src/inc/mnode.h @@ -147,9 +147,10 @@ typedef struct _vg_obj { int64_t createdTime; SVnodeGid vnodeGid[TSDB_VNODES_SUPPORT]; int32_t numOfVnodes; - int32_t lbIp; + int32_t lbDnodeId; int32_t lbTime; - int8_t lbStatus; + int8_t status; + int8_t reserved[14]; int8_t updateEnd[1]; int32_t refCount; diff --git a/src/mnode/inc/mgmtDnode.h b/src/mnode/inc/mgmtDnode.h index f262cd3c5e8d9ed95db23112e62b65d8c4b35c75..9c9ddea3467471ec24aef91e0f642e6c555ffd1c 100644 --- a/src/mnode/inc/mgmtDnode.h +++ b/src/mnode/inc/mgmtDnode.h @@ -21,12 +21,19 @@ extern "C" { #endif #include "mnode.h" +enum _TSDB_DN_STATUS { + TSDB_DN_STATUS_OFFLINE, + TSDB_DN_STATUS_DROPING, + TSDB_DN_STATUS_BALANCING, + TSDB_DN_STATUS_READY +}; + int32_t mgmtInitDnodes(); void mgmtCleanUpDnodes(); int32_t mgmtGetDnodesNum(); void * mgmtGetNextDnode(void *pNode, SDnodeObj **pDnode); -void mgmtIncDnodeRef(SDnodeObj *pDnode); -void mgmtDecDnodeRef(SDnodeObj *pDnode); +void mgmtReleaseDnode(SDnodeObj *pDnode); +char* mgmtGetDnodeStatusStr(int32_t dnodeStatus); SDnodeObj* mgmtGetDnode(int32_t dnodeId); SDnodeObj* mgmtGetDnodeByIp(uint32_t ip); diff --git a/src/mnode/inc/mgmtVgroup.h b/src/mnode/inc/mgmtVgroup.h index d0b1e0de971a0adea6f2aec65bb0eeb6da337438..b4d50a83187a5dfe9160221ad1a731c4124ea8e6 100644 --- a/src/mnode/inc/mgmtVgroup.h +++ b/src/mnode/inc/mgmtVgroup.h @@ -27,10 +27,12 @@ extern "C" { int32_t mgmtInitVgroups(); void mgmtCleanUpVgroups(); SVgObj *mgmtGetVgroup(int32_t vgId); -void mgmtIncVgroupRef(SVgObj *pVgroup); -void mgmtDecVgroupRef(SVgObj *pVgroup); +void mgmtReleaseVgroup(SVgObj *pVgroup); void mgmtDropAllVgroups(SDbObj *pDropDb); +void * mgmtGetNextVgroup(void *pNode, SVgObj **pVgroup); +void mgmtUpdateVgroup(SVgObj *pVgroup); + void mgmtCreateVgroup(SQueuedMsg *pMsg, SDbObj *pDb); void mgmtDropVgroup(SVgObj *pVgroup, void *ahandle); void mgmtAlterVgroup(SVgObj *pVgroup, void *ahandle); diff --git a/src/mnode/src/mgmtDnode.c b/src/mnode/src/mgmtDnode.c index ada0bce2e99881a7b91c17ccdbdf00384cdc1cc5..7019d8e20a49f6fb83a52864202041043f1f5e42 100644 --- a/src/mnode/src/mgmtDnode.c +++ b/src/mnode/src/mgmtDnode.c @@ -42,8 +42,7 @@ extern int32_t clusterInit(); extern void clusterCleanUp(); extern int32_t clusterGetDnodesNum(); extern void * clusterGetNextDnode(void *pNode, SDnodeObj **pDnode); -extern void clusterIncDnodeRef(SDnodeObj *pDnode); -extern void clusterDecDnodeRef(SDnodeObj *pDnode); +extern void clusterReleaseDnode(SDnodeObj *pDnode); extern SDnodeObj* clusterGetDnode(int32_t dnodeId); extern SDnodeObj* clusterGetDnodeByIp(uint32_t ip); #ifndef _CLUSTER @@ -120,15 +119,9 @@ int32_t mgmtGetDnodesNum() { #endif } -void mgmtIncDnodeRef(SDnodeObj *pDnode) { +void mgmtReleaseDnode(SDnodeObj *pDnode) { #ifdef _CLUSTER - return clusterIncDnodeRef(pDnode); -#endif -} - -void mgmtDecDnodeRef(SDnodeObj *pDnode) { -#ifdef _CLUSTER - return clusterDecDnodeRef(pDnode); + return clusterReleaseDnode(pDnode); #endif } @@ -724,4 +717,14 @@ static int32_t mgmtRetrieveVnodes(SShowObj *pShow, char *data, int32_t rows, voi pShow->numOfReads += numOfRows; return numOfRows; -} \ No newline at end of file +} + +char* mgmtGetDnodeStatusStr(int32_t dnodeStatus) { + switch (dnodeStatus) { + case TSDB_DN_STATUS_OFFLINE: return "offline"; + case TSDB_DN_STATUS_DROPING: return "dropping"; + case TSDB_DN_STATUS_BALANCING: return "balancing"; + case TSDB_DN_STATUS_READY: return "ready"; + default: return "undefined"; + } +} diff --git a/src/mnode/src/mgmtVgroup.c b/src/mnode/src/mgmtVgroup.c index bbf960203a533285e857a14b9299d155791cd0a5..c16cae775cfacd23c8637d382bfd19ee3c2c30fd 100644 --- a/src/mnode/src/mgmtVgroup.c +++ b/src/mnode/src/mgmtVgroup.c @@ -190,11 +190,7 @@ int32_t mgmtInitVgroups() { return 0; } -void mgmtIncVgroupRef(SVgObj *pVgroup) { - return sdbIncRef(tsVgroupSdb, pVgroup); -} - -void mgmtDecVgroupRef(SVgObj *pVgroup) { +void mgmtReleaseVgroup(SVgObj *pVgroup) { return sdbDecRef(tsVgroupSdb, pVgroup); } @@ -202,6 +198,18 @@ SVgObj *mgmtGetVgroup(int32_t vgId) { return (SVgObj *)sdbGetRow(tsVgroupSdb, &vgId); } +void mgmtUpdateVgroup(SVgObj *pVgroup) { + SSdbOperDesc oper = { + .type = SDB_OPER_TYPE_GLOBAL, + .table = tsVgroupSdb, + .pObj = pVgroup, + .rowSize = tsVgUpdateSize + }; + + sdbUpdateRow(&oper); + mgmtSendCreateVgroupMsg(pVgroup, NULL); +} + SVgObj *mgmtGetAvailableVgroup(SDbObj *pDb) { return pDb->pHead; } diff --git a/src/util/inc/tstatus.h b/src/util/inc/tstatus.h index 223ed1d52dcb8dea8f832fd26f7972333eb9550c..4fa392ca35846168e26c20637df2d7e3dd97c126 100644 --- a/src/util/inc/tstatus.h +++ b/src/util/inc/tstatus.h @@ -24,15 +24,6 @@ extern "C" { #include #include "taoserror.h" -enum _TSDB_VG_STATUS { - TSDB_VG_STATUS_READY = TSDB_CODE_SUCCESS, - TSDB_VG_STATUS_IN_PROGRESS = 1, //TSDB_CODE_ACTION_IN_PROGRESS, - TSDB_VG_STATUS_NO_DISK_PERMISSIONS = 73,//TSDB_CODE_NO_DISK_PERMISSIONS, - TSDB_VG_STATUS_SERVER_NO_PACE = 110, //TSDB_CODE_SERV_NO_DISKSPACE, - TSDB_VG_STATUS_SERV_OUT_OF_MEMORY = 69, //TSDB_CODE_SERV_OUT_OF_MEMORY, - TSDB_VG_STATUS_INIT_FAILED = 74, //TSDB_CODE_VG_INIT_FAILED, - TSDB_VG_STATUS_FULL = 48, //TSDB_CODE_NO_ENOUGH_DNODES, -}; enum _TSDB_DB_STATUS { TSDB_DB_STATUS_READY, @@ -75,21 +66,9 @@ enum _TSDB_MN_ROLE { TSDB_MN_ROLE_MASTER }; -enum _TSDB_DN_STATUS { - TSDB_DN_STATUS_OFFLINE, - TSDB_DN_STATUS_READY -}; - -enum _TSDB_DN_LB_STATUS { - TSDB_DN_LB_STATUS_BALANCED, - TSDB_DN_LB_STATUS_BALANCING, - TSDB_DN_LB_STATUS_OFFLINE_REMOVING, - TSDB_DN_LB_STATE_SHELL_REMOVING -}; - -enum _TSDB_VG_LB_STATUS { - TSDB_VG_LB_STATUS_READY, - TSDB_VG_LB_STATUS_UPDATE +enum _TSDB_VG_STATUS { + TSDB_VG_STATUS_READY, + TSDB_VG_STATUS_UPDATE }; enum _TSDB_VN_STREAM_STATUS { @@ -111,7 +90,6 @@ char* taosGetDbStatusStr(int32_t dbStatus); char* taosGetVnodeStatusStr(int32_t vnodeStatus); char* taosGetVnodeSyncStatusStr(int32_t vnodeSyncStatus); char* taosGetVnodeDropStatusStr(int32_t dropping); -char* taosGetDnodeStatusStr(int32_t dnodeStatus); char* taosGetDnodeLbStatusStr(int32_t dnodeBalanceStatus); char* taosGetVgroupLbStatusStr(int32_t vglbStatus); char* taosGetVnodeStreamStatusStr(int32_t vnodeStreamStatus); diff --git a/src/util/src/tstatus.c b/src/util/src/tstatus.c index e8534de30b82edd1f6182137d85342e7d6f6094b..cfcbea0ca14400192ef2b9d6ffc821cae2a6df09 100644 --- a/src/util/src/tstatus.c +++ b/src/util/src/tstatus.c @@ -69,14 +69,6 @@ char* taosGetVnodeDropStatusStr(int32_t dropping) { } } -char* taosGetDnodeStatusStr(int32_t dnodeStatus) { - switch (dnodeStatus) { - case TSDB_DN_STATUS_OFFLINE: return "offline"; - case TSDB_DN_STATUS_READY: return "ready"; - default: return "undefined"; - } -} - char* taosGetDnodeLbStatusStr(int32_t dnodeBalanceStatus) { switch (dnodeBalanceStatus) { case TSDB_DN_LB_STATUS_BALANCED: return "balanced";