提交 d320f261 编写于 作者: S slguan

[TBASE-1128]

上级 0eeae785
......@@ -44,40 +44,6 @@ extern "C" {
#define TSDB_TIME_PRECISION_MILLI_STR "ms"
#define TSDB_TIME_PRECISION_MICRO_STR "us"
enum _vnode_status {
TSDB_VNODE_STATUS_OFFLINE,
TSDB_VNODE_STATUS_CREATING,
TSDB_VNODE_STATUS_UNSYNCED,
TSDB_VNODE_STATUS_SLAVE,
TSDB_VNODE_STATUS_MASTER,
TSDB_VNODE_STATUS_CLOSING,
TSDB_VNODE_STATUS_DELETING,
};
enum _vnode_sync_status {
STDB_SSTATUS_INIT,
TSDB_SSTATUS_SYNCING,
TSDB_SSTATUS_SYNC_CACHE,
TSDB_SSTATUS_SYNC_FILE,
};
enum _dnode_status {
TSDB_DNODE_STATUS_OFFLINE,
TSDB_DNODE_STATUS_READY
};
enum _dnode_balance_status {
LB_DNODE_STATE_BALANCED,
LB_DNODE_STATE_BALANCING,
LB_DNODE_STATE_OFFLINE_REMOVING,
LB_DNODE_STATE_SHELL_REMOVING
};
enum _vgroup_status {
LB_VGROUP_STATE_READY,
LB_VGROUP_STATE_UPDATE
};
#define TSDB_DATA_TYPE_BOOL 1 // 1 bytes
#define TSDB_DATA_TYPE_TINYINT 2 // 1 byte
#define TSDB_DATA_TYPE_SMALLINT 3 // 2 bytes
......
......@@ -20,11 +20,77 @@
extern "C" {
#endif
enum _TSDB_VG_STATUS {
TSDB_VG_STATUS_READY,
TSDB_VG_STATUS_IN_PROGRESS,
TSDB_VG_STATUS_COMMITLOG_INIT_FAILED,
TSDB_VG_STATUS_INIT_FAILED,
TSDB_VG_STATUS_FULL
};
enum _TSDB_DB_STATUS {
TSDB_DB_STATUS_READY,
TSDB_DB_STATUS_DROPPING,
TSDB_DB_STATUS_DROP_FROM_SDB
};
enum _TSDB_VN_STATUS {
TSDB_VN_STATUS_OFFLINE,
TSDB_VN_STATUS_CREATING,
TSDB_VN_STATUS_UNSYNCED,
TSDB_VN_STATUS_SLAVE,
TSDB_VN_STATUS_MASTER,
TSDB_VN_STATUS_CLOSING,
TSDB_VN_STATUS_DELETING,
};
enum _TSDB_VN_SYNC_STATUS {
TSDB_VN_SYNC_STATUS_INIT,
TSDB_VN_SYNC_STATUS_SYNCING,
TSDB_VN_SYNC_STATUS_SYNC_CACHE,
TSDB_VN_SYNC_STATUS_SYNC_FILE
};
enum _TSDB_VN_DROP_STATUS {
TSDB_VN_DROP_STATUS_READY,
TSDB_VN_DROP_STATUS_DROPPING
};
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_LB_TYPE {
TSDB_LB_TYPE_SCHEDULE,
TSDB_LB_TYPE_SOON,
};
enum _TSDB_LB_REASON {
TSDB_LB_REASON_PERIOD,
TSDB_LB_REASON_EVENT,
};
const char* taosGetVnodeStatusStr(int vnodeStatus);
const char* taosGetDnodeStatusStr(int dnodeStatus);
const char* taosGetDnodeBalanceStateStr(int dnodeBalanceStatus);
const char* taosGetVnodeSyncStatusStr(int vnodeSyncStatus);
const char* taosGetVnodeDropStatusStr(int dropping);
const char* taosGetDnodeStatusStr(int dnodeStatus);
const char* taosGetDnodeLbStatusStr(int dnodeBalanceStatus);
const char* taosGetBalanceTypeStr(int type);
const char* taosBalanceReasonStr(int reason);
const char* taosGetVgroupLbStatusStr(int vglbStatus);
#ifdef __cplusplus
}
......
......@@ -45,17 +45,6 @@ extern int mgmtShellConns;
extern int mgmtDnodeConns;
extern char mgmtDirectory[];
enum _TSDB_VG_STATUS {
TSDB_VG_STATUS_READY,
TSDB_VG_STATUS_IN_PROGRESS,
TSDB_VG_STATUS_COMMITLOG_INIT_FAILED,
TSDB_VG_STATUS_INIT_FAILED,
TSDB_VG_STATUS_FULL
};
enum _TSDB_DB_STATUS { TSDB_DB_STATUS_READY, TSDB_DB_STATUS_DROPPING, TSDB_DB_STATUS_DROP_FROM_SDB };
enum _TSDB_VN_STATUS { TSDB_VN_STATUS_READY, TSDB_VN_STATUS_DROPPING };
typedef struct {
uint32_t privateIp;
......@@ -86,7 +75,7 @@ typedef struct {
uint16_t slot;
int32_t customScore; // config by user
float lbScore; // calc in balance function
int16_t lbState; // set in balance function
int16_t lbStatus; // set in balance function
int16_t lastAllocVnode; // increase while create vnode
SVnodeLoad vload[TSDB_MAX_VNODES];
char reserved[16];
......@@ -148,7 +137,7 @@ typedef struct _vg_obj {
int32_t numOfMeters;
int32_t lbIp;
int32_t lbTime;
int8_t lbState;
int8_t lbStatus;
char reserved[16];
char updateEnd[1];
struct _vg_obj *prev, *next;
......@@ -426,7 +415,7 @@ void mgmtSetDnodeShellRemoving(SDnodeObj *pDnode);
void mgmtSetDnodeUnRemove(SDnodeObj *pDnode);
void mgmtStartBalanceTimer(int mseconds);
void mgmtSetDnodeOfflineOnSdbChanged();
void mgmtUpdateVgroupState(SVgObj *pVgroup, int lbState, int srcIp);
void mgmtUpdateVgroupState(SVgObj *pVgroup, int lbStatus, int srcIp);
bool mgmtAddVnode(SVgObj *pVgroup, SDnodeObj *pSrcDnode, SDnodeObj *pDestDnode);
void mgmtSetModuleInDnode(SDnodeObj *pDnode, int moduleType);
......
......@@ -116,7 +116,7 @@ int vnodeProcessCreateMeterRequest(char *pMsg, int msgLen, SMgmtObj *pObj) {
goto _over;
}
if (pVnode->syncStatus == TSDB_SSTATUS_SYNCING) {
if (pVnode->syncStatus == TSDB_VN_SYNC_STATUS_SYNCING) {
code = vnodeSaveCreateMsgIntoQueue(pVnode, pMsg, msgLen);
dTrace("vid:%d, create msg is saved into sync queue", vid);
} else {
......@@ -331,7 +331,7 @@ int vnodeProcessVPeerCfg(char *msg, int msgLen, SMgmtObj *pMgmtObj) {
return -1;
}
if (vnodeList[vnode].vnodeStatus == TSDB_VNODE_STATUS_CREATING) {
if (vnodeList[vnode].vnodeStatus == TSDB_VN_STATUS_CREATING) {
dTrace("vid:%d, vnode is still under creating", vnode);
return 0;
}
......@@ -362,7 +362,7 @@ int vnodeProcessVPeerCfg(char *msg, int msgLen, SMgmtObj *pMgmtObj) {
if (vnodeList[vnode].cfg.maxSessions == 0) {
dTrace("vid:%d, vnode is empty", vnode);
if (pCfg->maxSessions > 0) {
if (vnodeList[vnode].vnodeStatus == TSDB_VNODE_STATUS_OFFLINE) {
if (vnodeList[vnode].vnodeStatus == TSDB_VN_STATUS_OFFLINE) {
dTrace("vid:%d, status:%s, start to create vnode", vnode, taosGetVnodeStatusStr(vnodeList[vnode].vnodeStatus));
return vnodeCreateVnode(vnode, pCfg, pMsg->vpeerDesc);
} else {
......@@ -373,7 +373,7 @@ int vnodeProcessVPeerCfg(char *msg, int msgLen, SMgmtObj *pMgmtObj) {
} else {
dTrace("vid:%d, vnode is not empty", vnode);
if (pCfg->maxSessions > 0) {
if (vnodeList[vnode].vnodeStatus == TSDB_VNODE_STATUS_DELETING) {
if (vnodeList[vnode].vnodeStatus == TSDB_VN_STATUS_DELETING) {
dTrace("vid:%d, status:%s, wait vnode delete finished", vnode, taosGetVnodeStatusStr(vnodeList[vnode].vnodeStatus));
} else {
dTrace("vid:%d, status:%s, start to update vnode", vnode, taosGetVnodeStatusStr(vnodeList[vnode].vnodeStatus));
......
......@@ -20,6 +20,7 @@
#include "mgmtBalance.h"
#include "mgmtUtil.h"
#include "tschemautil.h"
#include "tstatus.h"
void *dbSdb = NULL;
int tsDbUpdateSize;
......@@ -281,8 +282,8 @@ int mgmtSetDbDropping(SDbObj *pDb) {
if (pDnode == NULL) continue;
SVnodeLoad *pVload = &pDnode->vload[pVnodeGid->vnode];
if (pVload->dropStatus != TSDB_VN_STATUS_DROPPING) {
pVload->dropStatus = TSDB_VN_STATUS_DROPPING;
if (pVload->dropStatus != TSDB_VN_DROP_STATUS_DROPPING) {
pVload->dropStatus = TSDB_VN_DROP_STATUS_DROPPING;
mPrint("dnode:%s vnode:%d db:%s set to dropping status", taosIpStr(pDnode->privateIp), pVnodeGid->vnode, pDb->name);
if (mgmtUpdateDnode(pDnode) < 0) {
......@@ -315,10 +316,10 @@ bool mgmtCheckDropDbFinished(SDbObj *pDb) {
SDnodeObj *pDnode = mgmtGetDnode(pVnodeGid->ip);
if (pDnode == NULL) continue;
if (pDnode->status == TSDB_DNODE_STATUS_OFFLINE) continue;
if (pDnode->status == TSDB_DN_STATUS_OFFLINE) continue;
SVnodeLoad *pVload = &pDnode->vload[pVnodeGid->vnode];
if (pVload->dropStatus == TSDB_VN_STATUS_DROPPING) {
if (pVload->dropStatus == TSDB_VN_DROP_STATUS_DROPPING) {
mTrace("dnode:%s, vnode:%d db:%s wait dropping", taosIpStr(pDnode->privateIp), pVnodeGid->vnode, pDb->name);
return false;
}
......@@ -444,7 +445,7 @@ int mgmtAlterDb(SAcctObj *pAcct, SAlterDbMsg *pAlter) {
SVgObj *pVgroup = pDb->pHead;
while (pVgroup != NULL) {
mgmtUpdateVgroupState(pVgroup, LB_VGROUP_STATE_UPDATE, 0);
mgmtUpdateVgroupState(pVgroup, TSDB_VG_LB_STATUS_UPDATE, 0);
if (oldReplicaNum < pDb->cfg.replications) {
if (!mgmtAddVnode(pVgroup, NULL, NULL)) {
mWarn("db:%s vgroup:%d not enough dnode to add vnode", pAlter->db, pVgroup->vgId);
......
......@@ -44,9 +44,9 @@ void mgmtSetDnodeMaxVnodes(SDnodeObj *pDnode) {
pDnode->openVnodes = 0;
#ifdef CLUSTER
pDnode->status = TSDB_DNODE_STATUS_OFFLINE;
pDnode->status = TSDB_DN_STATUS_OFFLINE;
#else
pDnode->status = TSDB_DNODE_STATUS_READY;
pDnode->status = TSDB_DN_STATUS_READY;
#endif
}
......@@ -201,7 +201,7 @@ int mgmtRetrieveDnodes(SShowObj *pShow, char *data, int rows, SConnObj *pConn) {
cols++;
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
strcpy(pWrite, taosGetDnodeBalanceStateStr(pDnode->lbState));
strcpy(pWrite, taosGetDnodeLbStatusStr(pDnode->lbStatus));
cols++;
tinet_ntoa(ipstr, pDnode->publicIp);
......
......@@ -27,6 +27,7 @@
#include "tsqlfunction.h"
#include "ttime.h"
#include "vnodeTagMgmt.h"
#include "tstatus.h"
extern int64_t sdbVersion;
......@@ -661,7 +662,7 @@ int mgmtCreateMeter(SDbObj *pDb, SCreateTableMsg *pCreate) {
pMeter->uid = (((uint64_t)pMeter->gid.vgId) << 40) + ((((uint64_t)pMeter->gid.sid) & ((1ul << 24) - 1ul)) << 16) +
((uint64_t)sdbVersion & ((1ul << 16) - 1ul));
mTrace("table:%s, create table in vgroup, vgId:%d sid:%d vnode:%d uid:%d db:%s",
mTrace("table:%s, create table in vgroup, vgId:%d sid:%d vnode:%d uid:%ld db:%s",
pMeter->meterId, pVgroup->vgId, sid, pVgroup->vnodeGid[0].vnode, pMeter->uid, pDb->name);
} else {
pMeter->uid = (((uint64_t)pMeter->createdTime) << 16) + ((uint64_t)sdbVersion & ((1ul << 16) - 1ul));
......
......@@ -21,6 +21,7 @@
#include "mgmtProfile.h"
#include "taosmsg.h"
#include "tlog.h"
#include "tstatus.h"
#pragma GCC diagnostic push
......
......@@ -19,6 +19,7 @@
#include "mgmt.h"
#include "tschemautil.h"
#include "tlog.h"
#include "tstatus.h"
void * vgSdb = NULL;
int tsVgUpdateSize;
......@@ -312,7 +313,7 @@ int mgmtRetrieveVgroups(SShowObj *pShow, char *data, int rows, SConnObj *pConn)
cols++;
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
strcpy(pWrite, pVgroup->lbState ? "updating" : "ready");
strcpy(pWrite, taosGetVgroupLbStatusStr(pVgroup->lbStatus));
cols++;
for (int i = 0; i < maxReplica; ++i) {
......
......@@ -20,6 +20,7 @@
#include "vnode.h"
#include "vnodeCache.h"
#include "vnodeUtil.h"
#include "tstatus.h"
void vnodeSearchPointInCache(SMeterObj *pObj, SQuery *pQuery);
void vnodeProcessCommitTimer(void *param, void *tmrId);
......@@ -297,7 +298,7 @@ pthread_t vnodeCreateCommitThread(SVnodeObj *pVnode) {
taosTmrStopA(&pVnode->commitTimer);
if (pVnode->vnodeStatus == TSDB_VNODE_STATUS_UNSYNCED) {
if (pVnode->vnodeStatus == TSDB_VN_STATUS_UNSYNCED) {
taosTmrReset(vnodeProcessCommitTimer, pVnode->cfg.commitTime * 1000, pVnode, vnodeTmrCtrl, &pVnode->commitTimer);
dTrace("vid:%d, it is in unsyc state, commit later", pVnode->vnode);
return pVnode->commitThread;
......
......@@ -484,7 +484,7 @@ int vnodeCreateMeterObj(SMeterObj *pNew, SConnSec *pSec) {
vnodeSaveMeterObjToFile(pNew);
// vnodeCreateMeterMgmt(pNew, pSec);
vnodeCreateStream(pNew);
dTrace("vid:%d sid:%d id:%s, meterObj is created, uid:%ld", pNew->vnode, pNew->sid, pNew->meterId, pNew->uid);
dTrace("vid:%d, sid:%d id:%s, meterObj is created, uid:%ld", pNew->vnode, pNew->sid, pNew->meterId, pNew->uid);
}
return code;
......
......@@ -28,6 +28,7 @@
#include "vnodeRead.h"
#include "vnodeUtil.h"
#include "vnodeStore.h"
#include "tstatus.h"
#pragma GCC diagnostic ignored "-Wint-conversion"
extern int tsMaxQueues;
......@@ -90,7 +91,7 @@ void *vnodeProcessMsgFromShell(char *msg, void *ahandle, void *thandle) {
// if ( vnodeList[vnode].status != TSDB_STATUS_MASTER && pMsg->msgType != TSDB_MSG_TYPE_RETRIEVE ) {
#ifdef CLUSTER
if (vnodeList[vnode].vnodeStatus != TSDB_VNODE_STATUS_MASTER) {
if (vnodeList[vnode].vnodeStatus != TSDB_VN_STATUS_MASTER) {
taosSendSimpleRsp(thandle, pMsg->msgType + 1, TSDB_CODE_NOT_READY);
dTrace("vid:%d sid:%d, shell msg is ignored since in state:%d", vnode, sid, vnodeList[vnode].vnodeStatus);
} else {
......
......@@ -78,7 +78,7 @@ int vnodeOpenVnode(int vnode) {
return TSDB_CODE_SUCCESS;
}
if (!(pVnode->vnodeStatus == TSDB_VNODE_STATUS_OFFLINE || pVnode->vnodeStatus == TSDB_VNODE_STATUS_CREATING)) {
if (!(pVnode->vnodeStatus == TSDB_VN_STATUS_OFFLINE || pVnode->vnodeStatus == TSDB_VN_STATUS_CREATING)) {
dError("vid:%d, status:%s, cannot enter open operation", vnode, taosGetVnodeStatusStr(pVnode->vnodeStatus));
return TSDB_CODE_INVALID_VNODE_STATUS;
}
......@@ -140,12 +140,12 @@ static int vnodeCloseVnode(int vnode) {
return TSDB_CODE_SUCCESS;
}
if (pVnode->vnodeStatus == TSDB_VNODE_STATUS_DELETING) {
if (pVnode->vnodeStatus == TSDB_VN_STATUS_DELETING) {
dTrace("vid:%d, status:%s, another thread performed delete operation", vnode, taosGetVnodeStatusStr(pVnode->vnodeStatus));
return TSDB_CODE_SUCCESS;
} else {
dTrace("vid:%d, status:%s, enter close operation", vnode, taosGetVnodeStatusStr(pVnode->vnodeStatus));
pVnode->vnodeStatus = TSDB_VNODE_STATUS_CLOSING;
pVnode->vnodeStatus = TSDB_VN_STATUS_CLOSING;
}
// set the meter is dropped flag
......@@ -155,7 +155,7 @@ static int vnodeCloseVnode(int vnode) {
}
dTrace("vid:%d, status:%s, enter delete operation", vnode, taosGetVnodeStatusStr(pVnode->vnodeStatus));
pVnode->vnodeStatus = TSDB_VNODE_STATUS_DELETING;
pVnode->vnodeStatus = TSDB_VN_STATUS_DELETING;
vnodeCloseStream(vnodeList + vnode);
vnodeCancelCommit(vnodeList + vnode);
......@@ -178,12 +178,12 @@ static int vnodeCloseVnode(int vnode) {
int vnodeCreateVnode(int vnode, SVnodeCfg *pCfg, SVPeerDesc *pDesc) {
char fileName[128];
if (vnodeList[vnode].vnodeStatus != TSDB_VNODE_STATUS_OFFLINE) {
if (vnodeList[vnode].vnodeStatus != TSDB_VN_STATUS_OFFLINE) {
dError("vid:%d, status:%s, cannot enter create operation", vnode, taosGetVnodeStatusStr(vnodeList[vnode].vnodeStatus));
return TSDB_CODE_INVALID_VNODE_STATUS;
}
vnodeList[vnode].vnodeStatus = TSDB_VNODE_STATUS_CREATING;
vnodeList[vnode].vnodeStatus = TSDB_VN_STATUS_CREATING;
sprintf(fileName, "%s/vnode%d", tsDirectory, vnode);
mkdir(fileName, 0755);
......@@ -258,9 +258,9 @@ int vnodeRemoveVnode(int vnode) {
if (vnodeList[vnode].cfg.maxSessions > 0) {
SVnodeObj* pVnode = &vnodeList[vnode];
if (pVnode->vnodeStatus == TSDB_VNODE_STATUS_CREATING
|| pVnode->vnodeStatus == TSDB_VNODE_STATUS_OFFLINE
|| pVnode->vnodeStatus == TSDB_VNODE_STATUS_DELETING) {
if (pVnode->vnodeStatus == TSDB_VN_STATUS_CREATING
|| pVnode->vnodeStatus == TSDB_VN_STATUS_OFFLINE
|| pVnode->vnodeStatus == TSDB_VN_STATUS_DELETING) {
dError("vid:%d, status:%s, cannot enter close/delete operation", vnode, taosGetVnodeStatusStr(pVnode->vnodeStatus));
return TSDB_CODE_ACTION_IN_PROGRESS;
} else {
......@@ -325,7 +325,7 @@ void vnodeCleanUpOneVnode(int vnode) {
again = 1;
if (vnodeList[vnode].pCachePool) {
vnodeList[vnode].vnodeStatus = TSDB_VNODE_STATUS_OFFLINE;
vnodeList[vnode].vnodeStatus = TSDB_VN_STATUS_OFFLINE;
vnodeClosePeerVnode(vnode);
}
......@@ -354,7 +354,7 @@ void vnodeCleanUpVnodes() {
for (int vnode = 0; vnode < TSDB_MAX_VNODES; ++vnode) {
if (vnodeList[vnode].pCachePool) {
vnodeList[vnode].vnodeStatus = TSDB_VNODE_STATUS_OFFLINE;
vnodeList[vnode].vnodeStatus = TSDB_VN_STATUS_OFFLINE;
vnodeClosePeerVnode(vnode);
}
}
......
......@@ -17,6 +17,7 @@
#include "taosmsg.h"
#include "vnode.h"
#include "vnodeUtil.h"
#include "tstatus.h"
/* static TAOS *dbConn = NULL; */
void vnodeCloseStreamCallback(void *param);
......@@ -171,7 +172,7 @@ void vnodeCloseStream(SVnodeObj *pVnode) {
void vnodeUpdateStreamRole(SVnodeObj *pVnode) {
/* SMeterObj *pObj; */
int newRole = (pVnode->vnodeStatus == TSDB_VNODE_STATUS_MASTER) ? 1 : 0;
int newRole = (pVnode->vnodeStatus == TSDB_VN_STATUS_MASTER) ? 1 : 0;
if (newRole != pVnode->streamRole) {
dTrace("vid:%d, stream role is changed to:%d", pVnode->vnode, newRole);
pVnode->streamRole = newRole;
......
......@@ -53,8 +53,8 @@ bool mgmtCheckModuleInDnode(SDnodeObj *pDnode, int moduleType) {
bool mgmtCheckVnodeReady(SDnodeObj *pDnode, SVgObj *pVgroup, SVnodeGid *pVnode) { return true; }
void mgmtUpdateDnodeState(SDnodeObj *pDnode, int lbState) {}
void mgmtUpdateDnodeState(SDnodeObj *pDnode, int lbStatus) {}
void mgmtUpdateVgroupState(SVgObj *pVgroup, int lbState, int srcIp) {}
void mgmtUpdateVgroupState(SVgObj *pVgroup, int lbStatus, int srcIp) {}
bool mgmtAddVnode(SVgObj *pVgroup, SDnodeObj *pSrcDnode, SDnodeObj *pDestDnode) { return false; }
\ No newline at end of file
......@@ -30,7 +30,7 @@ int mgmtInitDnodes() {
dnodeObj.createdTime = (int64_t)tsRebootTime * 1000;
dnodeObj.lastReboot = tsRebootTime;
dnodeObj.numOfCores = (uint16_t)tsNumOfCores;
dnodeObj.status = TSDB_DNODE_STATUS_READY;
dnodeObj.status = TSDB_DN_STATUS_READY;
dnodeObj.alternativeRole = TSDB_DNODE_ROLE_ANY;
dnodeObj.numOfTotalVnodes = tsNumOfTotalVnodes;
dnodeObj.thandle = (void*)(1); //hack way
......
......@@ -82,7 +82,7 @@ void mgmtCleanUpDnodeInt() {}
void mgmtProcessDnodeStatus(void *handle, void *tmrId) {
SDnodeObj *pObj = &dnodeObj;
pObj->openVnodes = tsOpenVnodes;
pObj->status = TSDB_DNODE_STATUS_READY;
pObj->status = TSDB_DN_STATUS_READY;
float memoryUsedMB = 0;
taosGetSysMemory(&memoryUsedMB);
......@@ -95,8 +95,8 @@ void mgmtProcessDnodeStatus(void *handle, void *tmrId) {
// wait vnode dropped
if (pVload->dropStatus == TSDB_VN_STATUS_DROPPING) {
if (vnodeList[vnode].cfg.maxSessions <= 0) {
pVload->dropStatus = TSDB_VN_STATUS_READY;
pVload->status = TSDB_VN_STATUS_READY;
pVload->dropStatus = TSDB_VN_DROP_STATUS_READY;
pVload->status = TSDB_VN_STATUS_OFFLINE;
mPrint("dnode:%s, vid:%d, drop finished", taosIpStr(pObj->privateIp), vnode);
taosTmrStart(mgmtMonitorDbDrop, 10000, NULL, mgmtTmr);
}
......@@ -107,7 +107,7 @@ void mgmtProcessDnodeStatus(void *handle, void *tmrId) {
}
pVload->vnode = vnode;
pVload->status = TSDB_VN_STATUS_READY;
pVload->status = TSDB_VN_STATUS_MASTER;
pVload->totalStorage = pVnode->vnodeStatistic.totalStorage;
pVload->compStorage = pVnode->vnodeStatistic.compStorage;
pVload->pointsWritten = pVnode->vnodeStatistic.pointsWritten;
......
......@@ -31,7 +31,7 @@ void vnodeBroadcastStatusToUnsyncedPeer(SVnodeObj *pVnode) {}
int vnodeOpenPeerVnode(int vnode) {
SVnodeObj *pVnode = vnodeList + vnode;
pVnode->vnodeStatus = (pVnode->cfg.replications > 1) ? TSDB_VNODE_STATUS_UNSYNCED : TSDB_VNODE_STATUS_MASTER;
pVnode->vnodeStatus = (pVnode->cfg.replications > 1) ? TSDB_VN_STATUS_UNSYNCED : TSDB_VN_STATUS_MASTER;
dTrace("vid:%d, status:%s numOfPeers:%d", vnode, taosGetVnodeStatusStr(pVnode->vnodeStatus), pVnode->cfg.replications - 1);
vnodeUpdateStreamRole(pVnode);
return 0;
......
......@@ -15,52 +15,78 @@
#include "taosmsg.h"
#include "tsdb.h"
#include "tstatus.h"
const char* taosGetVnodeStatusStr(int vnodeStatus) {
switch (vnodeStatus) {
case TSDB_VNODE_STATUS_OFFLINE:return "offline";
case TSDB_VNODE_STATUS_CREATING: return "creating";
case TSDB_VNODE_STATUS_UNSYNCED: return "unsynced";
case TSDB_VNODE_STATUS_SLAVE: return "slave";
case TSDB_VNODE_STATUS_MASTER: return "master";
case TSDB_VNODE_STATUS_CLOSING: return "closing";
case TSDB_VNODE_STATUS_DELETING: return "deleting";
default: return "undefined";
case TSDB_VN_STATUS_OFFLINE: return "offline";
case TSDB_VN_STATUS_CREATING: return "creating";
case TSDB_VN_STATUS_UNSYNCED: return "unsynced";
case TSDB_VN_STATUS_SLAVE: return "slave";
case TSDB_VN_STATUS_MASTER: return "master";
case TSDB_VN_STATUS_CLOSING: return "closing";
case TSDB_VN_STATUS_DELETING: return "deleting";
default: return "undefined";
}
}
const char* taosGetVnodeSyncStatusStr(int vnodeSyncStatus) {
switch (vnodeSyncStatus) {
case TSDB_VN_SYNC_STATUS_INIT: return "init";
case TSDB_VN_SYNC_STATUS_SYNCING: return "syncing";
case TSDB_VN_SYNC_STATUS_SYNC_CACHE: return "sync_cache";
case TSDB_VN_SYNC_STATUS_SYNC_FILE: return "sync_file";
default: return "undefined";
}
}
const char* taosGetVnodeDropStatusStr(int dropping) {
switch (dropping) {
case TSDB_VN_DROP_STATUS_READY: return "ready";
case TSDB_VN_DROP_STATUS_DROPPING: return "dropping";
default: return "undefined";
}
}
const char* taosGetDnodeStatusStr(int dnodeStatus) {
switch (dnodeStatus) {
case TSDB_DNODE_STATUS_OFFLINE: return "offline";
case TSDB_DNODE_STATUS_READY: return "ready";
default: return "undefined";
case TSDB_DN_STATUS_OFFLINE: return "offline";
case TSDB_DN_STATUS_READY: return "ready";
default: return "undefined";
}
}
const char* taosGetDnodeBalanceStateStr(int dnodeBalanceStatus) {
const char* taosGetDnodeLbStatusStr(int dnodeBalanceStatus) {
switch (dnodeBalanceStatus) {
case LB_DNODE_STATE_BALANCED: return "balanced";
case LB_DNODE_STATE_BALANCING: return "balancing";
case LB_DNODE_STATE_OFFLINE_REMOVING: return "offline removing";
case LB_DNODE_STATE_SHELL_REMOVING: return "removing";
default: return "undefined";
case TSDB_DN_LB_STATUS_BALANCED: return "balanced";
case TSDB_DN_LB_STATUS_BALANCING: return "balancing";
case TSDB_DN_LB_STATUS_OFFLINE_REMOVING: return "offline removing";
case TSDB_DN_LB_STATE_SHELL_REMOVING: return "removing";
default: return "undefined";
}
}
const char* taosGetVnodeSyncStatusStr(int vnodeSyncStatus) {
switch (vnodeSyncStatus) {
case STDB_SSTATUS_INIT: return "init";
case TSDB_SSTATUS_SYNCING: return "syncing";
case TSDB_SSTATUS_SYNC_CACHE: return "sync_cache";
case TSDB_SSTATUS_SYNC_FILE: return "sync_file";
default: return "undefined";
const char* taosGetVgroupLbStatusStr(int vglbStatus) {
switch (vglbStatus) {
case TSDB_VG_LB_STATUS_READY: return "ready";
case TSDB_VG_LB_STATUS_UPDATE: return "updating";
default: return "undefined";
}
}
const char* taosGetVnodeDropStatusStr(int dropping) {
switch (dropping) {
case 0: return "ready";
case 1: return "dropping";
default: return "undefined";
const char* taosGetBalanceTypeStr(int type) {
switch (type) {
case TSDB_LB_TYPE_SCHEDULE: return "schedule";
case TSDB_LB_TYPE_SOON: return "soon";
default: return "undefined";
}
}
\ No newline at end of file
}
const char* taosBalanceReasonStr(int reason) {
switch (reason) {
case TSDB_LB_REASON_PERIOD: return "period";
case TSDB_LB_REASON_EVENT: return "event";
default: return "undefined";
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册