提交 7725aa1c 编写于 作者: S slguan

[TBASE-1129]

上级 86ad4166
......@@ -78,6 +78,8 @@ enum _TSDB_VN_STREAM_STATUS {
TSDB_VN_STREAM_STATUS_START
};
const char* taosGetVgroupStatusStr(int vgroupStatus);
const char* taosGetDbStatusStr(int dbStatus);
const char* taosGetVnodeStatusStr(int vnodeStatus);
const char* taosGetVnodeSyncStatusStr(int vnodeSyncStatus);
const char* taosGetVnodeDropStatusStr(int dropping);
......
......@@ -350,33 +350,33 @@ int vnodeProcessVPeerCfg(char *msg, int msgLen, SMgmtObj *pMgmtObj) {
pCfg->rowsInFileBlock = htonl(pCfg->rowsInFileBlock);
if (pCfg->replications > 0) {
dTrace("vid:%d, vpeer cfg received, replica:%d session:%d, vnodeList replica:%d session:%d",
dPrint("vid:%d, vpeer cfg received, replica:%d session:%d, vnodeList replica:%d session:%d",
vnode, pCfg->replications, pCfg->maxSessions, vnodeList[vnode].cfg.replications, vnodeList[vnode].cfg.maxSessions);
for (i = 0; i < pCfg->replications; ++i) {
pMsg->vpeerDesc[i].vnode = htonl(pMsg->vpeerDesc[i].vnode);
pMsg->vpeerDesc[i].ip = htonl(pMsg->vpeerDesc[i].ip);
dTrace("vid:%d, vpeer:%d ip:0x%x vid:%d ", vnode, i, pMsg->vpeerDesc[i].ip, pMsg->vpeerDesc[i].vnode);
dPrint("vid:%d, vpeer:%d ip:0x%x vid:%d ", vnode, i, pMsg->vpeerDesc[i].ip, pMsg->vpeerDesc[i].vnode);
}
}
if (vnodeList[vnode].cfg.maxSessions == 0) {
dTrace("vid:%d, vnode is empty", vnode);
dPrint("vid:%d, vnode is empty", vnode);
if (pCfg->maxSessions > 0) {
if (vnodeList[vnode].vnodeStatus == TSDB_VN_STATUS_OFFLINE) {
dTrace("vid:%d, status:%s, start to create vnode", vnode, taosGetVnodeStatusStr(vnodeList[vnode].vnodeStatus));
dPrint("vid:%d, status:%s, start to create vnode", vnode, taosGetVnodeStatusStr(vnodeList[vnode].vnodeStatus));
return vnodeCreateVnode(vnode, pCfg, pMsg->vpeerDesc);
} else {
dTrace("vid:%d, status:%s, cannot preform create vnode operation", vnode, taosGetVnodeStatusStr(vnodeList[vnode].vnodeStatus));
dPrint("vid:%d, status:%s, cannot preform create vnode operation", vnode, taosGetVnodeStatusStr(vnodeList[vnode].vnodeStatus));
return TSDB_CODE_INVALID_VNODE_STATUS;
}
}
} else {
dTrace("vid:%d, vnode is not empty", vnode);
dPrint("vid:%d, vnode is not empty", vnode);
if (pCfg->maxSessions > 0) {
if (vnodeList[vnode].vnodeStatus == TSDB_VN_STATUS_DELETING) {
dTrace("vid:%d, status:%s, wait vnode delete finished", vnode, taosGetVnodeStatusStr(vnodeList[vnode].vnodeStatus));
dPrint("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));
dPrint("vid:%d, status:%s, start to update vnode", vnode, taosGetVnodeStatusStr(vnodeList[vnode].vnodeStatus));
if (pCfg->maxSessions != vnodeList[vnode].cfg.maxSessions) {
vnodeCleanUpOneVnode(vnode);
......@@ -395,7 +395,7 @@ int vnodeProcessVPeerCfg(char *msg, int msgLen, SMgmtObj *pMgmtObj) {
}
return 0;
} else {
dTrace("vid:%d, status:%s, start to delete vnode", vnode, taosGetVnodeStatusStr(vnodeList[vnode].vnodeStatus));
dPrint("vid:%d, status:%s, start to delete vnode", vnode, taosGetVnodeStatusStr(vnodeList[vnode].vnodeStatus));
vnodeRemoveVnode(vnode);
}
}
......
......@@ -99,7 +99,7 @@ int mgmtProcessVpeerCfgMsg(char *cont, int contLen, SDnodeObj *pObj) {
*pMsg = 0;
pMsg++;
pMsg = mgmtBuildVpeersIe(pMsg, pVgroup, vnode);
mTrace("dnode:%s, vnode:%d, vgroup:%d, send create meter msg, code:%d", taosIpStr(pObj->privateIp), vnode, pVgroup->vgId, *pMsg);
mTrace("dnode:%s, vnode:%d, vgroup:%d, send create vnode msg, code:%d", taosIpStr(pObj->privateIp), vnode, pVgroup->vgId, *pMsg);
} else {
mTrace("dnode:%s, vnode:%d, no vgroup info, vgroup:%d", taosIpStr(pObj->privateIp), vnode, pObj->vload[vnode].vgId);
*pMsg = TSDB_CODE_NOT_ACTIVE_VNODE;
......@@ -128,7 +128,8 @@ int mgmtProcessVPeersRsp(char *msg, int msgLen, SDnodeObj *pObj) {
}
if (pDb->vgStatus != TSDB_VG_STATUS_IN_PROGRESS) {
mTrace("dnode:%s, db:%s vpeer rsp already disposed, vgroup status:%d code:%d", taosIpStr(pObj->privateIp), pRsp->more, pDb->vgStatus, pRsp->code);
mTrace("dnode:%s, db:%s vpeer rsp already disposed, vgroup status:%s code:%d",
taosIpStr(pObj->privateIp), pRsp->more, taosGetVgroupStatusStr(pDb->vgStatus), pRsp->code);
return 0;
}
......
......@@ -78,7 +78,7 @@ void *vnodeOpenCachePool(int vnode) {
}
}
dTrace("vid:%d, cache pool is allocated:0x%x", vnode, pCachePool);
dPrint("vid:%d, cache pool is allocated:0x%x", vnode, pCachePool);
return pCachePool;
......@@ -103,7 +103,7 @@ void vnodeCloseCachePool(int vnode) {
taosTmrStopA(&pVnode->commitTimer);
if (pVnode->commitInProcess) pthread_cancel(pVnode->commitThread);
dTrace("vid:%d, cache pool closed, count:%d", vnode, pCachePool->count);
dPrint("vid:%d, cache pool closed, count:%d", vnode, pCachePool->count);
int maxAllocBlock = (1024 * 1024 * 1024) / pVnode->cfg.cacheBlockSize;
while (blockId < pVnode->cfg.cacheNumOfBlocks.totalBlocks) {
......
......@@ -125,10 +125,8 @@ int vnodeCreateHeadDataFile(int vnode, int fileId, char *headName, char *dataNam
if (symlink(dDataName, dataName) != 0) return -1;
if (symlink(dLastName, lastName) != 0) return -1;
dTrace(
"vid:%d, fileId:%d, empty header file:%s dataFile:%s lastFile:%s on "
"disk:%s is created ",
vnode, fileId, headName, dataName, lastName, path);
dPrint("vid:%d, fileId:%d, empty header file:%s dataFile:%s lastFile:%s on disk:%s is created ",
vnode, fileId, headName, dataName, lastName, path);
return 0;
}
......@@ -309,7 +307,7 @@ int vnodeOpenCommitFiles(SVnodeObj *pVnode, int noTempLast) {
vnodeRecoverFromPeer(pVnode, fileId);
goto _error;
} else {
dTrace("vid:%d, data file:%s is opened to write", vnode, name);
dPrint("vid:%d, data file:%s is opened to write", vnode, name);
}
// open last file
......@@ -414,7 +412,7 @@ void vnodeRemoveFile(int vnode, int fileId) {
remove(dDataName);
remove(dLastName);
dTrace("vid:%d fileId:%d on disk: %s is removed, numOfFiles:%d maxFiles:%d", vnode, fileId, path,
dPrint("vid:%d fileId:%d on disk: %s is removed, numOfFiles:%d maxFiles:%d", vnode, fileId, path,
pVnode->numOfFiles, pVnode->maxFiles);
}
......
......@@ -59,7 +59,7 @@ static int vnodeInitStoreVnode(int vnode) {
}
pthread_mutex_init(&(pVnode->vmutex), NULL);
dTrace("vid:%d, storage initialized, version:%ld fileId:%d numOfFiles:%d", vnode, pVnode->version, pVnode->fileId,
dPrint("vid:%d, storage initialized, version:%ld fileId:%d numOfFiles:%d", vnode, pVnode->version, pVnode->fileId,
pVnode->numOfFiles);
return 0;
......@@ -83,7 +83,7 @@ int vnodeOpenVnode(int vnode) {
return TSDB_CODE_INVALID_VNODE_STATUS;
}
dTrace("vid:%d, status:%s, start to open", vnode, taosGetVnodeStatusStr(pVnode->vnodeStatus));
dPrint("vid:%d, status:%s, start to open", vnode, taosGetVnodeStatusStr(pVnode->vnodeStatus));
pthread_mutex_lock(&dmutex);
// not enough memory, abort
......@@ -104,7 +104,7 @@ int vnodeOpenVnode(int vnode) {
vnodeOpenStreams(pVnode, NULL);
#endif
dTrace("vid:%d, vnode is opened, openVnodes:%d, status:%s", vnode, tsOpenVnodes, taosGetVnodeStatusStr(pVnode->vnodeStatus));
dPrint("vid:%d, vnode is opened, openVnodes:%d, status:%s", vnode, tsOpenVnodes, taosGetVnodeStatusStr(pVnode->vnodeStatus));
return TSDB_CODE_SUCCESS;
}
......@@ -141,10 +141,10 @@ static int vnodeCloseVnode(int vnode) {
}
if (pVnode->vnodeStatus == TSDB_VN_STATUS_DELETING) {
dTrace("vid:%d, status:%s, another thread performed delete operation", vnode, taosGetVnodeStatusStr(pVnode->vnodeStatus));
dPrint("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));
dPrint("vid:%d, status:%s, enter close operation", vnode, taosGetVnodeStatusStr(pVnode->vnodeStatus));
pVnode->vnodeStatus = TSDB_VN_STATUS_CLOSING;
}
......@@ -154,7 +154,7 @@ static int vnodeCloseVnode(int vnode) {
return TSDB_CODE_ACTION_IN_PROGRESS;
}
dTrace("vid:%d, status:%s, enter delete operation", vnode, taosGetVnodeStatusStr(pVnode->vnodeStatus));
dPrint("vid:%d, status:%s, enter delete operation", vnode, taosGetVnodeStatusStr(pVnode->vnodeStatus));
pVnode->vnodeStatus = TSDB_VN_STATUS_DELETING;
vnodeCloseStream(vnodeList + vnode);
......@@ -235,7 +235,7 @@ static void vnodeRemoveDataFiles(int vnode) {
if (tcode >= 0) {
remove(dfilePath);
dTrace("Data file %s is removed, link file %s", dfilePath, linkFile);
dPrint("Data file %s is removed, link file %s", dfilePath, linkFile);
}
} else {
remove(de->d_name);
......@@ -250,7 +250,7 @@ static void vnodeRemoveDataFiles(int vnode) {
sprintf(vnodeDir, "%s/vnode%d", tsDirectory, vnode);
rmdir(vnodeDir);
dTrace("vid:%d, vnode is removed!", vnode);
dPrint("vid:%d, vnode is removed!", vnode);
}
int vnodeRemoveVnode(int vnode) {
......@@ -273,7 +273,7 @@ int vnodeRemoveVnode(int vnode) {
}
} else {
dTrace("vid:%d, max sessions:%d, this vnode already dropped!!!", vnode, vnodeList[vnode].cfg.maxSessions);
dPrint("vid:%d, max sessions:%d, this vnode already dropped!!!", vnode, vnodeList[vnode].cfg.maxSessions);
vnodeList[vnode].cfg.maxSessions = 0; //reset value
vnodeCalcOpenVnodes();
}
......
......@@ -155,7 +155,7 @@ void vnodeRemoveStream(SMeterObj *pObj) {
// Close all streams in a vnode
void vnodeCloseStream(SVnodeObj *pVnode) {
SMeterObj *pObj;
dTrace("vid:%d, stream is closed, old role %s", pVnode->vnode, taosGetVnodeStreamStatusStr(pVnode->streamRole));
dPrint("vid:%d, stream is closed, old role %s", pVnode->vnode, taosGetVnodeStreamStatusStr(pVnode->streamRole));
// stop stream computing
for (int sid = 0; sid < pVnode->cfg.maxSessions; ++sid) {
......@@ -174,16 +174,16 @@ void vnodeUpdateStreamRole(SVnodeObj *pVnode) {
int newRole = (pVnode->vnodeStatus == TSDB_VN_STATUS_MASTER) ? TSDB_VN_STREAM_STATUS_START : TSDB_VN_STREAM_STATUS_STOP;
if (newRole != pVnode->streamRole) {
dTrace("vid:%d, stream role is changed from %s to %s",
dPrint("vid:%d, stream role is changed from %s to %s",
pVnode->vnode, taosGetVnodeStreamStatusStr(pVnode->streamRole), taosGetVnodeStreamStatusStr(newRole));
pVnode->streamRole = newRole;
if (newRole) {
if (newRole == TSDB_VN_STREAM_STATUS_START) {
vnodeOpenStreams(pVnode, NULL);
} else {
vnodeCloseStream(pVnode);
}
} else {
dTrace("vid:%d, stream role is keep to %s", pVnode->vnode, taosGetVnodeStreamStatusStr(newRole));
dPrint("vid:%d, stream role is keep to %s", pVnode->vnode, taosGetVnodeStreamStatusStr(pVnode->streamRole));
}
}
......
......@@ -97,7 +97,7 @@ int vnodeCheckNewHeaderFile(int fd, SVnodeObj *pVnode) {
}
_correct_exit:
dTrace("vid: %d new header file %s is correct", pVnode->vnode, pVnode->nfn);
dPrint("vid: %d new header file %s is correct", pVnode->vnode, pVnode->nfn);
tfree(pBlocks);
tfree(pHeader);
return 0;
......
......@@ -32,7 +32,7 @@ void vnodeBroadcastStatusToUnsyncedPeer(SVnodeObj *pVnode) {}
int vnodeOpenPeerVnode(int vnode) {
SVnodeObj *pVnode = vnodeList + vnode;
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);
dPrint("vid:%d, status:%s numOfPeers:%d", vnode, taosGetVnodeStatusStr(pVnode->vnodeStatus), pVnode->cfg.replications - 1);
vnodeUpdateStreamRole(pVnode);
return 0;
}
......
......@@ -17,6 +17,26 @@
#include "tsdb.h"
#include "tstatus.h"
const char* taosGetVgroupStatusStr(int vgroupStatus) {
switch (vgroupStatus) {
case TSDB_VG_STATUS_READY: return "ready";
case TSDB_VG_STATUS_IN_PROGRESS: return "inprogress";
case TSDB_VG_STATUS_COMMITLOG_INIT_FAILED: return "commitlog_init_failed";
case TSDB_VG_STATUS_INIT_FAILED: return "init_failed";
case TSDB_VG_STATUS_FULL: return "full";
default: return "undefined";
}
}
const char* taosGetDbStatusStr(int dbStatus) {
switch (dbStatus) {
case TSDB_DB_STATUS_READY: return "ready";
case TSDB_DB_STATUS_DROPPING: return "dropping";
case TSDB_DB_STATUS_DROP_FROM_SDB: return "drop_from_sdb";
default: return "undefined";
}
}
const char* taosGetVnodeStatusStr(int vnodeStatus) {
switch (vnodeStatus) {
case TSDB_VN_STATUS_OFFLINE: return "offline";
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册