From 318d774ba986f18922e0c4768af3de3381e3f1fe Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Wed, 13 Apr 2022 14:00:56 +0800 Subject: [PATCH] refact(cluster): node mgmt --- include/common/tmsg.h | 1 + include/dnode/mgmt/dnode.h | 12 +- source/common/src/tmsg.c | 2 + source/dnode/mgmt/exe/dmMain.c | 84 ++++---- source/dnode/mgmt/implement/inc/dmImp.h | 60 +++--- source/dnode/mgmt/implement/src/dmEps.c | 104 +++++----- source/dnode/mgmt/implement/src/dmExec.c | 88 ++++---- source/dnode/mgmt/implement/src/dmHandle.c | 191 ++++++++---------- source/dnode/mgmt/implement/src/dmMonitor.c | 40 ++-- source/dnode/mgmt/implement/src/dmObj.c | 37 ++-- source/dnode/mgmt/implement/src/dmTransport.c | 130 ++++++------ source/dnode/mgmt/implement/src/dmWorker.c | 76 ++++--- source/dnode/mgmt/interface/inc/dmDef.h | 11 +- source/dnode/mgmt/interface/inc/dmInt.h | 52 ++--- source/dnode/mgmt/interface/inc/dmLog.h | 6 +- source/dnode/mgmt/interface/src/dmEnv.c | 4 +- source/dnode/mgmt/interface/src/dmFile.c | 21 +- source/dnode/mgmt/interface/src/dmInt.c | 36 ++-- source/dnode/mgmt/mgmt_bnode/src/bmHandle.c | 8 +- source/dnode/mgmt/mgmt_bnode/src/bmInt.c | 6 +- source/dnode/mgmt/mgmt_mnode/src/mmHandle.c | 176 ++++++++-------- source/dnode/mgmt/mgmt_qnode/src/qmHandle.c | 26 +-- source/dnode/mgmt/mgmt_qnode/src/qmInt.c | 6 +- source/dnode/mgmt/mgmt_snode/src/smHandle.c | 12 +- source/dnode/mgmt/mgmt_snode/src/smInt.c | 6 +- source/dnode/mgmt/mgmt_vnode/src/vmHandle.c | 98 ++++----- source/dnode/mgmt/mgmt_vnode/src/vmInt.c | 2 +- source/dnode/mgmt/test/sut/src/server.cpp | 8 +- source/dnode/mgmt/test/sut/src/sut.cpp | 4 +- 29 files changed, 645 insertions(+), 662 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 7839754735..7a4625289b 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -759,6 +759,7 @@ typedef struct { int32_t tSerializeSStatusReq(void* buf, int32_t bufLen, SStatusReq* pReq); int32_t tDeserializeSStatusReq(void* buf, int32_t bufLen, SStatusReq* pReq); +void tFreeSStatusReq(SStatusReq* pReq); typedef struct { int32_t dnodeId; diff --git a/include/dnode/mgmt/dnode.h b/include/dnode/mgmt/dnode.h index 576b44e14b..352f6d5b53 100644 --- a/include/dnode/mgmt/dnode.h +++ b/include/dnode/mgmt/dnode.h @@ -30,12 +30,12 @@ typedef struct SDnode SDnode; * * @return int32_t 0 for success and -1 for failure */ -int32_t dndInit(); +int32_t dmInit(); /** * @brief Clear the environment */ -void dndCleanup(); +void dmCleanup(); /* ------------------------ SDnode ----------------------- */ typedef struct { @@ -59,21 +59,21 @@ typedef enum { DND_EVENT_START, DND_EVENT_STOP = 1, DND_EVENT_CHILD } EDndEvent; * @param pOption Option of the dnode. * @return SDnode* The dnode object. */ -SDnode *dndCreate(const SDnodeOpt *pOption); +SDnode *dmCreate(const SDnodeOpt *pOption); /** * @brief Stop and cleanup the dnode. * * @param pDnode The dnode object to close. */ -void dndClose(SDnode *pDnode); +void dmClose(SDnode *pDnode); /** * @brief Run dnode until specific event is receive. * * @param pDnode The dnode object to run. */ -int32_t dndRun(SDnode *pDnode); +int32_t dmRun(SDnode *pDnode); /** * @brief Handle event in the dnode. @@ -81,7 +81,7 @@ int32_t dndRun(SDnode *pDnode); * @param pDnode The dnode object to close. * @param event The event to handle. */ -void dndSetEvent(SDnode *pDnode, EDndEvent event); +void dmSetEvent(SDnode *pDnode, EDndEvent event); #ifdef __cplusplus } diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index a9ecdd659f..83f8646364 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -958,6 +958,8 @@ int32_t tDeserializeSStatusReq(void *buf, int32_t bufLen, SStatusReq *pReq) { return 0; } +void tFreeSStatusReq(SStatusReq *pReq) { taosArrayDestroy(pReq->pVloads); } + int32_t tSerializeSStatusRsp(void *buf, int32_t bufLen, SStatusRsp *pRsp) { SCoder encoder = {0}; tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER); diff --git a/source/dnode/mgmt/exe/dmMain.c b/source/dnode/mgmt/exe/dmMain.c index 9213090a4e..12de4103a4 100644 --- a/source/dnode/mgmt/exe/dmMain.c +++ b/source/dnode/mgmt/exe/dmMain.c @@ -18,32 +18,32 @@ #include "tconfig.h" static struct { - bool dumpConfig; - bool generateGrant; - bool printAuth; - bool printVersion; - char envFile[PATH_MAX]; - char apolloUrl[PATH_MAX]; - SArray *pArgs; // SConfigPair - SDnode *pDnode; + bool dumpConfig; + bool generateGrant; + bool printAuth; + bool printVersion; + char envFile[PATH_MAX]; + char apolloUrl[PATH_MAX]; + SArray *pArgs; // SConfigPair + SDnode *pDnode; EDndNodeType ntype; } global = {0}; -static void dndStopDnode(int signum, void *info, void *ctx) { +static void dmStopDnode(int signum, void *info, void *ctx) { SDnode *pDnode = atomic_val_compare_exchange_ptr(&global.pDnode, 0, global.pDnode); if (pDnode != NULL) { - dndSetEvent(pDnode, DND_EVENT_STOP); + dmSetEvent(pDnode, DND_EVENT_STOP); } } -static void dndSetSignalHandle() { - taosSetSignal(SIGTERM, dndStopDnode); - taosSetSignal(SIGHUP, dndStopDnode); - taosSetSignal(SIGINT, dndStopDnode); - taosSetSignal(SIGTSTP, dndStopDnode); - taosSetSignal(SIGABRT, dndStopDnode); - taosSetSignal(SIGBREAK, dndStopDnode); - taosSetSignal(SIGQUIT, dndStopDnode); +static void dmSetSignalHandle() { + taosSetSignal(SIGTERM, dmStopDnode); + taosSetSignal(SIGHUP, dmStopDnode); + taosSetSignal(SIGINT, dmStopDnode); + taosSetSignal(SIGTSTP, dmStopDnode); + taosSetSignal(SIGABRT, dmStopDnode); + taosSetSignal(SIGBREAK, dmStopDnode); + taosSetSignal(SIGQUIT, dmStopDnode); if (!tsMultiProcess) { } else if (global.ntype == NODE_BEGIN || global.ntype == NODE_END) { @@ -53,7 +53,7 @@ static void dndSetSignalHandle() { } } -static int32_t dndParseArgs(int32_t argc, char const *argv[]) { +static int32_t dmParseArgs(int32_t argc, char const *argv[]) { for (int32_t i = 1; i < argc; ++i) { if (strcmp(argv[i], "-c") == 0) { if (i < argc - 1) { @@ -89,12 +89,12 @@ static int32_t dndParseArgs(int32_t argc, char const *argv[]) { return 0; } -static void dndGenerateGrant() { +static void dmGenerateGrant() { // grantParseParameter(); printf("this feature is not implemented yet\n"); } -static void dndPrintVersion() { +static void dmPrintVersion() { #ifdef TD_ENTERPRISE char *releaseName = "enterprise"; #else @@ -105,12 +105,12 @@ static void dndPrintVersion() { printf("buildInfo: %s\n", buildinfo); } -static void dndDumpCfg() { +static void dmDumpCfg() { SConfig *pCfg = taosGetCfg(); cfgDumpCfg(pCfg, 0, 1); } -static SDnodeOpt dndGetOpt() { +static SDnodeOpt dmGetOpt() { SConfig *pCfg = taosGetCfg(); SDnodeOpt option = {0}; @@ -127,43 +127,43 @@ static SDnodeOpt dndGetOpt() { return option; } -static int32_t dndInitLog() { +static int32_t dmInitLog() { char logName[12] = {0}; - snprintf(logName, sizeof(logName), "%slog", dndLogName(global.ntype)); + snprintf(logName, sizeof(logName), "%slog", dmLogName(global.ntype)); return taosCreateLog(logName, 1, configDir, global.envFile, global.apolloUrl, global.pArgs, 0); } -static void dndSetProcInfo(int32_t argc, char **argv) { +static void dmSetProcInfo(int32_t argc, char **argv) { taosSetProcPath(argc, argv); if (global.ntype != NODE_BEGIN && global.ntype != NODE_END) { - const char *name = dndProcName(global.ntype); + const char *name = dmProcName(global.ntype); taosSetProcName(argc, argv, name); } } -static int32_t dndRunDnode() { - if (dndInit() != 0) { +static int32_t dmRunDnode() { + if (dmInit() != 0) { dError("failed to init environment since %s", terrstr()); return -1; } - SDnodeOpt option = dndGetOpt(); - SDnode *pDnode = dndCreate(&option); + SDnodeOpt option = dmGetOpt(); + SDnode *pDnode = dmCreate(&option); if (pDnode == NULL) { dError("failed to to create dnode since %s", terrstr()); return -1; } else { global.pDnode = pDnode; - dndSetSignalHandle(); + dmSetSignalHandle(); } dInfo("start the service"); - int32_t code = dndRun(pDnode); + int32_t code = dmRun(pDnode); dInfo("start shutting down the service"); global.pDnode = NULL; - dndClose(pDnode); - dndCleanup(); + dmClose(pDnode); + dmCleanup(); taosCloseLog(); taosCleanupCfg(); return code; @@ -175,22 +175,22 @@ int main(int argc, char const *argv[]) { return -1; } - if (dndParseArgs(argc, argv) != 0) { + if (dmParseArgs(argc, argv) != 0) { printf("failed to start since parse args error\n"); return -1; } if (global.generateGrant) { - dndGenerateGrant(); + dmGenerateGrant(); return 0; } if (global.printVersion) { - dndPrintVersion(); + dmPrintVersion(); return 0; } - if (dndInitLog() != 0) { + if (dmInitLog() != 0) { printf("failed to start since init log error\n"); return -1; } @@ -201,12 +201,12 @@ int main(int argc, char const *argv[]) { } if (global.dumpConfig) { - dndDumpCfg(); + dmDumpCfg(); taosCleanupCfg(); taosCloseLog(); return 0; } - dndSetProcInfo(argc, (char **)argv); - return dndRunDnode(); + dmSetProcInfo(argc, (char **)argv); + return dmRunDnode(); } diff --git a/source/dnode/mgmt/implement/inc/dmImp.h b/source/dnode/mgmt/implement/inc/dmImp.h index d001c7be98..61dd7800b1 100644 --- a/source/dnode/mgmt/implement/inc/dmImp.h +++ b/source/dnode/mgmt/implement/inc/dmImp.h @@ -22,48 +22,32 @@ extern "C" { #endif -int32_t dndOpenNode(SMgmtWrapper *pWrapper); -void dndCloseNode(SMgmtWrapper *pWrapper); +int32_t dmOpenNode(SMgmtWrapper *pWrapper); +void dmCloseNode(SMgmtWrapper *pWrapper); -// dndTransport.c +// dmTransport.c int32_t dmInitTrans(SDnode *pDnode); -void dndCleanupTrans(SDnode *pDnode); -SProcCfg dndGenProcCfg(SMgmtWrapper *pWrapper); -int32_t dndInitMsgHandle(SDnode *pDnode); -int32_t dndSendMsgToMnode(SDnode *pDnode, SRpcMsg *pReq); -void dndSendRecv(SDnode *pDnode, SEpSet *pEpSet, SRpcMsg *pReq, SRpcMsg *pRsp); +void dmCleanupTrans(SDnode *pDnode); +SProcCfg dmGenProcCfg(SMgmtWrapper *pWrapper); +int32_t dmInitMsgHandle(SDnode *pDnode); +void dmSendRecv(SDnode *pDnode, SEpSet *pEpSet, SRpcMsg *pReq, SRpcMsg *pRsp); void dmSendToMnodeRecv(SDnode *pDnode, SRpcMsg *pReq, SRpcMsg *pRsp); -// mgmt -void dmSetMgmtFp(SMgmtWrapper *pWrapper); -void bmSetMgmtFp(SMgmtWrapper *pWrapper); -void qmSetMgmtFp(SMgmtWrapper *pMgmt); -void smSetMgmtFp(SMgmtWrapper *pWrapper); -void vmSetMgmtFp(SMgmtWrapper *pWrapper); -void mmSetMgmtFp(SMgmtWrapper *pMgmt); - -void vmGetVnodeLoads(SMgmtWrapper *pWrapper, SMonVloadInfo *pInfo); -void mmGetMonitorInfo(SMgmtWrapper *pWrapper, SMonMmInfo *mmInfo); -void vmGetMonitorInfo(SMgmtWrapper *pWrapper, SMonVmInfo *vmInfo); -void qmGetMonitorInfo(SMgmtWrapper *pWrapper, SMonQmInfo *qmInfo); -void smGetMonitorInfo(SMgmtWrapper *pWrapper, SMonSmInfo *smInfo); -void bmGetMonitorInfo(SMgmtWrapper *pWrapper, SMonBmInfo *bmInfo); - -// dmFile.c -int32_t dmReadFile(SDnodeData *pMgmt); -int32_t dmWriteFile(SDnodeData *pMgmt); -void dmUpdateDnodeEps(SDnodeData *pMgmt, SArray *pDnodeEps); +// dmEps.c +int32_t dmReadEps(SDnode *pDnode); +int32_t dmWriteEps(SDnode *pDnode); +void dmUpdateEps(SDnode *pDnode, SArray *pDnodeEps); // dmHandle.c void dmSendStatusReq(SDnode *pDnode); int32_t dmProcessConfigReq(SDnode *pDnode, SNodeMsg *pMsg); -int32_t dmProcessStatusRsp(SDnode *pDnode, SNodeMsg *pMsg); int32_t dmProcessAuthRsp(SDnode *pDnode, SNodeMsg *pMsg); int32_t dmProcessGrantRsp(SDnode *pDnode, SNodeMsg *pMsg); -int32_t dmProcessCDnodeReq(SDnode *pDnode, SNodeMsg *pMsg); +int32_t dmProcessCreateNodeReq(SDnode *pDnode, EDndNodeType ntype, SNodeMsg *pMsg); +int32_t dmProcessDropNodeReq(SDnode *pDnode, EDndNodeType ntype, SNodeMsg *pMsg); // dmMonitor.c -void dmGetVnodeLoads(SMgmtWrapper *pWrapper, SMonVloadInfo *pInfo); +void dmGetVnodeLoads(SDnode *pDnode, SMonVloadInfo *pInfo); void dmSendMonitorReport(SDnode *pDnode); // dmWorker.c @@ -71,12 +55,26 @@ int32_t dmStartStatusThread(SDnode *pDnode); void dmStopStatusThread(SDnode *pDnode); int32_t dmStartMonitorThread(SDnode *pDnode); void dmStopMonitorThread(SDnode *pDnode); - int32_t dmStartWorker(SDnode *pDnode); void dmStopWorker(SDnode *pDnode); int32_t dmProcessMgmtMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg); int32_t dmProcessStatusMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg); +// mgmt nodes +void dmSetMgmtFp(SMgmtWrapper *pWrapper); +void bmSetMgmtFp(SMgmtWrapper *pWrapper); +void qmSetMgmtFp(SMgmtWrapper *pWrapper); +void smSetMgmtFp(SMgmtWrapper *pWrapper); +void vmSetMgmtFp(SMgmtWrapper *pWrapper); +void mmSetMgmtFp(SMgmtWrapper *pWrapper); + +void vmGetVnodeLoads(SMgmtWrapper *pWrapper, SMonVloadInfo *pInfo); +void mmGetMonitorInfo(SMgmtWrapper *pWrapper, SMonMmInfo *mmInfo); +void vmGetMonitorInfo(SMgmtWrapper *pWrapper, SMonVmInfo *vmInfo); +void qmGetMonitorInfo(SMgmtWrapper *pWrapper, SMonQmInfo *qmInfo); +void smGetMonitorInfo(SMgmtWrapper *pWrapper, SMonSmInfo *smInfo); +void bmGetMonitorInfo(SMgmtWrapper *pWrapper, SMonBmInfo *bmInfo); + #ifdef __cplusplus } #endif diff --git a/source/dnode/mgmt/implement/src/dmEps.c b/source/dnode/mgmt/implement/src/dmEps.c index 31ebb9955f..5dcdccfa4e 100644 --- a/source/dnode/mgmt/implement/src/dmEps.c +++ b/source/dnode/mgmt/implement/src/dmEps.c @@ -16,15 +16,14 @@ #define _DEFAULT_SOURCE #include "dmImp.h" -static void dmPrintDnodes(SDnodeData *pMgmt); -static bool dmIsEpChanged(SDnodeData *pMgmt, int32_t dnodeId, const char *ep); -static void dmResetDnodes(SDnodeData *pMgmt, SArray *dnodeEps); +static void dmPrintEps(SDnode *pDnode); +static bool dmIsEpChanged(SDnode *pDnode, int32_t dnodeId, const char *ep); +static void dmResetEps(SDnode *pDnode, SArray *dnodeEps); -void dmGetDnodeEp(SMgmtWrapper *pWrapper, int32_t dnodeId, char *pEp, char *pFqdn, uint16_t *pPort) { - SDnodeData *pMgmt = pWrapper->pMgmt; - taosRLockLatch(&pMgmt->latch); +static void dmGetDnodeEp(SDnode *pDnode, int32_t dnodeId, char *pEp, char *pFqdn, uint16_t *pPort) { + taosRLockLatch(&pDnode->data.latch); - SDnodeEp *pDnodeEp = taosHashGet(pMgmt->dnodeHash, &dnodeId, sizeof(int32_t)); + SDnodeEp *pDnodeEp = taosHashGet(pDnode->data.dnodeHash, &dnodeId, sizeof(int32_t)); if (pDnodeEp != NULL) { if (pPort != NULL) { *pPort = pDnodeEp->ep.port; @@ -37,10 +36,10 @@ void dmGetDnodeEp(SMgmtWrapper *pWrapper, int32_t dnodeId, char *pEp, char *pFqd } } - taosRUnLockLatch(&pMgmt->latch); + taosRUnLockLatch(&pDnode->data.latch); } -int32_t dmReadFile(SDnodeData *pMgmt) { +int32_t dmReadEps(SDnode *pDnode) { int32_t code = TSDB_CODE_INVALID_JSON_FORMAT; int32_t len = 0; int32_t maxLen = 256 * 1024; @@ -48,15 +47,14 @@ int32_t dmReadFile(SDnodeData *pMgmt) { cJSON *root = NULL; char file[PATH_MAX]; TdFilePtr pFile = NULL; - SDnode *pDnode = pMgmt->pDnode; - pMgmt->dnodeEps = taosArrayInit(1, sizeof(SDnodeEp)); - if (pMgmt->dnodeEps == NULL) { + pDnode->data.dnodeEps = taosArrayInit(1, sizeof(SDnodeEp)); + if (pDnode->data.dnodeEps == NULL) { dError("failed to calloc dnodeEp array since %s", strerror(errno)); goto PRASE_DNODE_OVER; } - snprintf(file, sizeof(file), "%s%sdnode.json", pMgmt->path, TD_DIRSEP); + snprintf(file, sizeof(file), "%s%sdnode.json", pDnode->data.path, TD_DIRSEP); pFile = taosOpenFile(file, TD_FILE_READ); if (pFile == NULL) { dDebug("file %s not exist", file); @@ -146,41 +144,39 @@ int32_t dmReadFile(SDnodeData *pMgmt) { } dnodeEp.isMnode = isMnode->valueint; - taosArrayPush(pMgmt->dnodeEps, &dnodeEp); + taosArrayPush(pDnode->data.dnodeEps, &dnodeEp); } code = 0; dDebug("succcessed to read file %s", file); - dmPrintDnodes(pMgmt); + dmPrintEps(pDnode); PRASE_DNODE_OVER: if (content != NULL) taosMemoryFree(content); if (root != NULL) cJSON_Delete(root); if (pFile != NULL) taosCloseFile(&pFile); - if (dmIsEpChanged(pMgmt, pDnode->data.dnodeId, pDnode->data.localEp)) { + if (dmIsEpChanged(pDnode, pDnode->data.dnodeId, pDnode->data.localEp)) { dError("localEp %s different with %s and need reconfigured", pDnode->data.localEp, file); return -1; } - if (taosArrayGetSize(pMgmt->dnodeEps) == 0) { + if (taosArrayGetSize(pDnode->data.dnodeEps) == 0) { SDnodeEp dnodeEp = {0}; dnodeEp.isMnode = 1; taosGetFqdnPortFromEp(pDnode->data.firstEp, &dnodeEp.ep); - taosArrayPush(pMgmt->dnodeEps, &dnodeEp); + taosArrayPush(pDnode->data.dnodeEps, &dnodeEp); } - dmResetDnodes(pMgmt, pMgmt->dnodeEps); + dmResetEps(pDnode, pDnode->data.dnodeEps); terrno = code; return code; } -int32_t dmWriteFile(SDnodeData *pMgmt) { - SDnode *pDnode = pMgmt->pDnode; - +int32_t dmWriteEps(SDnode *pDnode) { char file[PATH_MAX]; - snprintf(file, sizeof(file), "%s%sdnode.json.bak", pMgmt->path, TD_DIRSEP); + snprintf(file, sizeof(file), "%s%sdnode.json.bak", pDnode->data.path, TD_DIRSEP); TdFilePtr pFile = taosOpenFile(file, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC); if (pFile == NULL) { @@ -199,9 +195,9 @@ int32_t dmWriteFile(SDnodeData *pMgmt) { len += snprintf(content + len, maxLen - len, " \"dropped\": %d,\n", pDnode->data.dropped); len += snprintf(content + len, maxLen - len, " \"dnodes\": [{\n"); - int32_t numOfEps = (int32_t)taosArrayGetSize(pMgmt->dnodeEps); + int32_t numOfEps = (int32_t)taosArrayGetSize(pDnode->data.dnodeEps); for (int32_t i = 0; i < numOfEps; ++i) { - SDnodeEp *pDnodeEp = taosArrayGet(pMgmt->dnodeEps, i); + SDnodeEp *pDnodeEp = taosArrayGet(pDnode->data.dnodeEps, i); len += snprintf(content + len, maxLen - len, " \"id\": %d,\n", pDnodeEp->id); len += snprintf(content + len, maxLen - len, " \"fqdn\": \"%s\",\n", pDnodeEp->ep.fqdn); len += snprintf(content + len, maxLen - len, " \"port\": %u,\n", pDnodeEp->ep.port); @@ -220,7 +216,7 @@ int32_t dmWriteFile(SDnodeData *pMgmt) { taosMemoryFree(content); char realfile[PATH_MAX]; - snprintf(realfile, sizeof(realfile), "%s%sdnode.json", pMgmt->path, TD_DIRSEP); + snprintf(realfile, sizeof(realfile), "%s%sdnode.json", pDnode->data.path, TD_DIRSEP); if (taosRenameFile(file, realfile) != 0) { terrno = TAOS_SYSTEM_ERROR(errno); @@ -228,41 +224,41 @@ int32_t dmWriteFile(SDnodeData *pMgmt) { return -1; } - pMgmt->updateTime = taosGetTimestampMs(); + pDnode->data.updateTime = taosGetTimestampMs(); dDebug("successed to write %s", realfile); return 0; } -void dmUpdateDnodeEps(SDnodeData *pMgmt, SArray *dnodeEps) { - int32_t numOfEps = taosArrayGetSize(dnodeEps); +void dmUpdateEps(SDnode *pDnode, SArray *eps) { + int32_t numOfEps = taosArrayGetSize(eps); if (numOfEps <= 0) return; - taosWLockLatch(&pMgmt->latch); + taosWLockLatch(&pDnode->data.latch); - int32_t numOfEpsOld = (int32_t)taosArrayGetSize(pMgmt->dnodeEps); + int32_t numOfEpsOld = (int32_t)taosArrayGetSize(pDnode->data.dnodeEps); if (numOfEps != numOfEpsOld) { - dmResetDnodes(pMgmt, dnodeEps); - dmWriteFile(pMgmt); + dmResetEps(pDnode, eps); + dmWriteEps(pDnode); } else { int32_t size = numOfEps * sizeof(SDnodeEp); - if (memcmp(pMgmt->dnodeEps->pData, dnodeEps->pData, size) != 0) { - dmResetDnodes(pMgmt, dnodeEps); - dmWriteFile(pMgmt); + if (memcmp(pDnode->data.dnodeEps->pData, eps->pData, size) != 0) { + dmResetEps(pDnode, eps); + dmWriteEps(pDnode); } } - taosWUnLockLatch(&pMgmt->latch); + taosWUnLockLatch(&pDnode->data.latch); } -static void dmResetDnodes(SDnodeData *pMgmt, SArray *dnodeEps) { - if (pMgmt->dnodeEps != dnodeEps) { - SArray *tmp = pMgmt->dnodeEps; - pMgmt->dnodeEps = taosArrayDup(dnodeEps); +static void dmResetEps(SDnode *pDnode, SArray *dnodeEps) { + if (pDnode->data.dnodeEps != dnodeEps) { + SArray *tmp = pDnode->data.dnodeEps; + pDnode->data.dnodeEps = taosArrayDup(dnodeEps); taosArrayDestroy(tmp); } - pMgmt->mnodeEpSet.inUse = 0; - pMgmt->mnodeEpSet.numOfEps = 0; + pDnode->data.mnodeEps.inUse = 0; + pDnode->data.mnodeEps.numOfEps = 0; int32_t mIndex = 0; int32_t numOfEps = (int32_t)taosArrayGetSize(dnodeEps); @@ -271,40 +267,40 @@ static void dmResetDnodes(SDnodeData *pMgmt, SArray *dnodeEps) { SDnodeEp *pDnodeEp = taosArrayGet(dnodeEps, i); if (!pDnodeEp->isMnode) continue; if (mIndex >= TSDB_MAX_REPLICA) continue; - pMgmt->mnodeEpSet.numOfEps++; + pDnode->data.mnodeEps.numOfEps++; - pMgmt->mnodeEpSet.eps[mIndex] = pDnodeEp->ep; + pDnode->data.mnodeEps.eps[mIndex] = pDnodeEp->ep; mIndex++; } for (int32_t i = 0; i < numOfEps; i++) { SDnodeEp *pDnodeEp = taosArrayGet(dnodeEps, i); - taosHashPut(pMgmt->dnodeHash, &pDnodeEp->id, sizeof(int32_t), pDnodeEp, sizeof(SDnodeEp)); + taosHashPut(pDnode->data.dnodeHash, &pDnodeEp->id, sizeof(int32_t), pDnodeEp, sizeof(SDnodeEp)); } - dmPrintDnodes(pMgmt); + dmPrintEps(pDnode); } -static void dmPrintDnodes(SDnodeData *pMgmt) { - int32_t numOfEps = (int32_t)taosArrayGetSize(pMgmt->dnodeEps); +static void dmPrintEps(SDnode *pDnode) { + int32_t numOfEps = (int32_t)taosArrayGetSize(pDnode->data.dnodeEps); dDebug("print dnode ep list, num:%d", numOfEps); for (int32_t i = 0; i < numOfEps; i++) { - SDnodeEp *pEp = taosArrayGet(pMgmt->dnodeEps, i); + SDnodeEp *pEp = taosArrayGet(pDnode->data.dnodeEps, i); dDebug("dnode:%d, fqdn:%s port:%u isMnode:%d", pEp->id, pEp->ep.fqdn, pEp->ep.port, pEp->isMnode); } } -static bool dmIsEpChanged(SDnodeData *pMgmt, int32_t dnodeId, const char *ep) { +static bool dmIsEpChanged(SDnode *pDnode, int32_t dnodeId, const char *ep) { bool changed = false; - taosRLockLatch(&pMgmt->latch); + taosRLockLatch(&pDnode->data.latch); - SDnodeEp *pDnodeEp = taosHashGet(pMgmt->dnodeHash, &dnodeId, sizeof(int32_t)); + SDnodeEp *pDnodeEp = taosHashGet(pDnode->data.dnodeHash, &dnodeId, sizeof(int32_t)); if (pDnodeEp != NULL) { char epstr[TSDB_EP_LEN + 1]; snprintf(epstr, TSDB_EP_LEN, "%s:%u", pDnodeEp->ep.fqdn, pDnodeEp->ep.port); changed = strcmp(ep, epstr) != 0; } - taosRUnLockLatch(&pMgmt->latch); + taosRUnLockLatch(&pDnode->data.latch); return changed; } diff --git a/source/dnode/mgmt/implement/src/dmExec.c b/source/dnode/mgmt/implement/src/dmExec.c index c73e79a2da..a348cdf914 100644 --- a/source/dnode/mgmt/implement/src/dmExec.c +++ b/source/dnode/mgmt/implement/src/dmExec.c @@ -16,7 +16,7 @@ #define _DEFAULT_SOURCE #include "dmImp.h" -static bool dndRequireNode(SMgmtWrapper *pWrapper) { +static bool dmRequireNode(SMgmtWrapper *pWrapper) { bool required = false; int32_t code = (*pWrapper->fp.requiredFp)(pWrapper, &required); if (!required) { @@ -27,7 +27,7 @@ static bool dndRequireNode(SMgmtWrapper *pWrapper) { return required; } -static int32_t dndInitNodeProc(SMgmtWrapper *pWrapper) { +static int32_t dmInitNodeProc(SMgmtWrapper *pWrapper) { int32_t shmsize = tsMnodeShmSize; if (pWrapper->ntype == VNODE) { shmsize = tsVnodeShmSize; @@ -50,7 +50,7 @@ static int32_t dndInitNodeProc(SMgmtWrapper *pWrapper) { } dInfo("node:%s, shm:%d is created, size:%d", pWrapper->name, pWrapper->procShm.id, shmsize); - SProcCfg cfg = dndGenProcCfg(pWrapper); + SProcCfg cfg = dmGenProcCfg(pWrapper); cfg.isChild = false; pWrapper->procType = DND_PROC_PARENT; pWrapper->procObj = taosProcInit(&cfg); @@ -62,7 +62,7 @@ static int32_t dndInitNodeProc(SMgmtWrapper *pWrapper) { return 0; } -static int32_t dndNewNodeProc(SMgmtWrapper *pWrapper, EDndNodeType n) { +static int32_t dmNewNodeProc(SMgmtWrapper *pWrapper, EDndNodeType n) { char tstr[8] = {0}; char *args[6] = {0}; snprintf(tstr, sizeof(tstr), "%d", n); @@ -84,11 +84,11 @@ static int32_t dndNewNodeProc(SMgmtWrapper *pWrapper, EDndNodeType n) { return 0; } -static int32_t dndRunNodeProc(SMgmtWrapper *pWrapper) { +static int32_t dmRunNodeProc(SMgmtWrapper *pWrapper) { if (pWrapper->pDnode->ntype == NODE_END) { dInfo("node:%s, should be started manually", pWrapper->name); } else { - if (dndNewNodeProc(pWrapper, pWrapper->ntype) != 0) { + if (dmNewNodeProc(pWrapper, pWrapper->ntype) != 0) { return -1; } } @@ -101,7 +101,7 @@ static int32_t dndRunNodeProc(SMgmtWrapper *pWrapper) { return 0; } -static int32_t dndOpenNodeImp(SMgmtWrapper *pWrapper) { +static int32_t dmOpenNodeImp(SMgmtWrapper *pWrapper) { if (taosMkDir(pWrapper->path) != 0) { terrno = TAOS_SYSTEM_ERROR(errno); dError("node:%s, failed to create dir:%s since %s", pWrapper->name, pWrapper->path, terrstr()); @@ -118,19 +118,19 @@ static int32_t dndOpenNodeImp(SMgmtWrapper *pWrapper) { return 0; } -int32_t dndOpenNode(SMgmtWrapper *pWrapper) { +int32_t dmOpenNode(SMgmtWrapper *pWrapper) { SDnode *pDnode = pWrapper->pDnode; if (pDnode->ptype == DND_PROC_SINGLE) { - return dndOpenNodeImp(pWrapper); + return dmOpenNodeImp(pWrapper); } else if (pDnode->ptype == DND_PROC_PARENT) { - if (dndInitNodeProc(pWrapper) != 0) return -1; - if (dndWriteShmFile(pDnode) != 0) return -1; - if (dndRunNodeProc(pWrapper) != 0) return -1; + if (dmInitNodeProc(pWrapper) != 0) return -1; + if (dmWriteShmFile(pDnode) != 0) return -1; + if (dmRunNodeProc(pWrapper) != 0) return -1; } return 0; } -static void dndCloseNodeImp(SMgmtWrapper *pWrapper) { +static void dmCloseNodeImp(SMgmtWrapper *pWrapper) { dDebug("node:%s, mgmt start to close", pWrapper->name); pWrapper->required = false; taosWLockLatch(&pWrapper->latch); @@ -151,7 +151,7 @@ static void dndCloseNodeImp(SMgmtWrapper *pWrapper) { dDebug("node:%s, mgmt has been closed", pWrapper->name); } -void dndCloseNode(SMgmtWrapper *pWrapper) { +void dmCloseNode(SMgmtWrapper *pWrapper) { if (pWrapper->pDnode->ptype == DND_PROC_PARENT) { if (pWrapper->procId > 0 && taosProcExist(pWrapper->procId)) { dInfo("node:%s, send kill signal to the child process:%d", pWrapper->name, pWrapper->procId); @@ -161,31 +161,31 @@ void dndCloseNode(SMgmtWrapper *pWrapper) { dInfo("node:%s, child process:%d is stopped", pWrapper->name, pWrapper->procId); } } - dndCloseNodeImp(pWrapper); + dmCloseNodeImp(pWrapper); } -static void dndProcessProcHandle(void *handle) { +static void dmProcessProcHandle(void *handle) { dWarn("handle:%p, the child process dies and send an offline rsp", handle); SRpcMsg rpcMsg = {.handle = handle, .code = TSDB_CODE_NODE_OFFLINE}; rpcSendResponse(&rpcMsg); } -static int32_t dndRunInSingleProcess(SDnode *pDnode) { +static int32_t dmRunInSingleProcess(SDnode *pDnode) { dInfo("dnode run in single process"); pDnode->ptype = DND_PROC_SINGLE; for (EDndNodeType n = NODE_BEGIN; n < NODE_END; ++n) { SMgmtWrapper *pWrapper = &pDnode->wrappers[n]; - pWrapper->required = dndRequireNode(pWrapper); + pWrapper->required = dmRequireNode(pWrapper); if (!pWrapper->required) continue; - if (dndOpenNodeImp(pWrapper) != 0) { + if (dmOpenNodeImp(pWrapper) != 0) { dError("node:%s, failed to start since %s", pWrapper->name, terrstr()); return -1; } } - dndSetStatus(pDnode, DND_STAT_RUNNING); + dmSetStatus(pDnode, DND_STAT_RUNNING); for (EDndNodeType n = 0; n < NODE_END; ++n) { SMgmtWrapper *pWrapper = &pDnode->wrappers[n]; @@ -198,11 +198,11 @@ static int32_t dndRunInSingleProcess(SDnode *pDnode) { } dInfo("TDengine initialized successfully"); - dndReportStartup(pDnode, "TDengine", "initialized successfully"); + dmReportStartup(pDnode, "TDengine", "initialized successfully"); while (1) { if (pDnode->event == DND_EVENT_STOP) { dInfo("dnode is about to stop"); - dndSetStatus(pDnode, DND_STAT_STOPPED); + dmSetStatus(pDnode, DND_STAT_STOPPED); break; } taosMsleep(100); @@ -211,24 +211,24 @@ static int32_t dndRunInSingleProcess(SDnode *pDnode) { return 0; } -static int32_t dndRunInParentProcess(SDnode *pDnode) { +static int32_t dmRunInParentProcess(SDnode *pDnode) { dInfo("dnode run in parent process"); pDnode->ptype = DND_PROC_PARENT; SMgmtWrapper *pDWrapper = &pDnode->wrappers[NODE_BEGIN]; - if (dndOpenNodeImp(pDWrapper) != 0) { + if (dmOpenNodeImp(pDWrapper) != 0) { dError("node:%s, failed to start since %s", pDWrapper->name, terrstr()); return -1; } for (EDndNodeType n = NODE_BEGIN + 1; n < NODE_END; ++n) { SMgmtWrapper *pWrapper = &pDnode->wrappers[n]; - pWrapper->required = dndRequireNode(pWrapper); + pWrapper->required = dmRequireNode(pWrapper); if (!pWrapper->required) continue; - if (dndInitNodeProc(pWrapper) != 0) return -1; + if (dmInitNodeProc(pWrapper) != 0) return -1; } - if (dndWriteShmFile(pDnode) != 0) { + if (dmWriteShmFile(pDnode) != 0) { dError("failed to write runtime file since %s", terrstr()); return -1; } @@ -236,10 +236,10 @@ static int32_t dndRunInParentProcess(SDnode *pDnode) { for (EDndNodeType n = NODE_BEGIN + 1; n < NODE_END; ++n) { SMgmtWrapper *pWrapper = &pDnode->wrappers[n]; if (!pWrapper->required) continue; - if (dndRunNodeProc(pWrapper) != 0) return -1; + if (dmRunNodeProc(pWrapper) != 0) return -1; } - dndSetStatus(pDnode, DND_STAT_RUNNING); + dmSetStatus(pDnode, DND_STAT_RUNNING); if ((*pDWrapper->fp.startFp)(pDWrapper) != 0) { dError("node:%s, failed to start since %s", pDWrapper->name, terrstr()); @@ -247,12 +247,12 @@ static int32_t dndRunInParentProcess(SDnode *pDnode) { } dInfo("TDengine initialized successfully"); - dndReportStartup(pDnode, "TDengine", "initialized successfully"); + dmReportStartup(pDnode, "TDengine", "initialized successfully"); while (1) { if (pDnode->event == DND_EVENT_STOP) { dInfo("dnode is about to stop"); - dndSetStatus(pDnode, DND_STAT_STOPPED); + dmSetStatus(pDnode, DND_STAT_STOPPED); for (EDndNodeType n = NODE_BEGIN + 1; n < NODE_END; ++n) { SMgmtWrapper *pWrapper = &pDnode->wrappers[n]; @@ -276,8 +276,8 @@ static int32_t dndRunInParentProcess(SDnode *pDnode) { if (pWrapper->procId <= 0 || !taosProcExist(pWrapper->procId)) { dWarn("node:%s, process:%d is killed and needs to be restarted", pWrapper->name, pWrapper->procId); - taosProcCloseHandles(pWrapper->procObj, dndProcessProcHandle); - dndNewNodeProc(pWrapper, n); + taosProcCloseHandles(pWrapper->procObj, dmProcessProcHandle); + dmNewNodeProc(pWrapper, n); } } } @@ -288,12 +288,12 @@ static int32_t dndRunInParentProcess(SDnode *pDnode) { return 0; } -static int32_t dndRunInChildProcess(SDnode *pDnode) { +static int32_t dmRunInChildProcess(SDnode *pDnode) { SMgmtWrapper *pWrapper = &pDnode->wrappers[pDnode->ntype]; dInfo("%s run in child process", pWrapper->name); pDnode->ptype = DND_PROC_CHILD; - pWrapper->required = dndRequireNode(pWrapper); + pWrapper->required = dmRequireNode(pWrapper); if (!pWrapper->required) { dError("%s does not require startup", pWrapper->name); return -1; @@ -303,12 +303,12 @@ static int32_t dndRunInChildProcess(SDnode *pDnode) { tmsgSetDefaultMsgCb(&msgCb); pWrapper->procType = DND_PROC_CHILD; - if (dndOpenNodeImp(pWrapper) != 0) { + if (dmOpenNodeImp(pWrapper) != 0) { dError("node:%s, failed to start since %s", pWrapper->name, terrstr()); return -1; } - SProcCfg cfg = dndGenProcCfg(pWrapper); + SProcCfg cfg = dmGenProcCfg(pWrapper); cfg.isChild = true; pWrapper->procObj = taosProcInit(&cfg); if (pWrapper->procObj == NULL) { @@ -323,7 +323,7 @@ static int32_t dndRunInChildProcess(SDnode *pDnode) { } } - dndSetStatus(pDnode, DND_STAT_RUNNING); + dmSetStatus(pDnode, DND_STAT_RUNNING); if (taosProcRun(pWrapper->procObj) != 0) { dError("node:%s, failed to run proc since %s", pWrapper->name, terrstr()); @@ -331,11 +331,11 @@ static int32_t dndRunInChildProcess(SDnode *pDnode) { } dInfo("TDengine initialized successfully"); - dndReportStartup(pDnode, "TDengine", "initialized successfully"); + dmReportStartup(pDnode, "TDengine", "initialized successfully"); while (1) { if (pDnode->event == DND_EVENT_STOP) { dInfo("%s is about to stop", pWrapper->name); - dndSetStatus(pDnode, DND_STAT_STOPPED); + dmSetStatus(pDnode, DND_STAT_STOPPED); break; } taosMsleep(100); @@ -344,13 +344,13 @@ static int32_t dndRunInChildProcess(SDnode *pDnode) { return 0; } -int32_t dndRun(SDnode *pDnode) { +int32_t dmRun(SDnode *pDnode) { if (!tsMultiProcess) { - return dndRunInSingleProcess(pDnode); + return dmRunInSingleProcess(pDnode); } else if (pDnode->ntype == NODE_BEGIN || pDnode->ntype == NODE_END) { - return dndRunInParentProcess(pDnode); + return dmRunInParentProcess(pDnode); } else { - return dndRunInChildProcess(pDnode); + return dmRunInChildProcess(pDnode); } return 0; diff --git a/source/dnode/mgmt/implement/src/dmHandle.c b/source/dnode/mgmt/implement/src/dmHandle.c index 1beb36054b..1b0abd8c09 100644 --- a/source/dnode/mgmt/implement/src/dmHandle.c +++ b/source/dnode/mgmt/implement/src/dmHandle.c @@ -16,22 +16,31 @@ #define _DEFAULT_SOURCE #include "dmImp.h" -static int32_t dmProcessStatusRsp(SDnode *pDnode, SRpcMsg *pRsp) { - SDnode *pDnode = pMgmt->pDnode; +static void dmUpdateDnodeCfg(SDnode *pDnode, SDnodeCfg *pCfg) { + if (pDnode->data.dnodeId == 0) { + dInfo("set dnodeId:%d clusterId:%" PRId64, pCfg->dnodeId, pCfg->clusterId); + taosWLockLatch(&pDnode->data.latch); + pDnode->data.dnodeId = pCfg->dnodeId; + pDnode->data.clusterId = pCfg->clusterId; + dmWriteEps(pDnode); + taosWUnLockLatch(&pDnode->data.latch); + } +} +static int32_t dmProcessStatusRsp(SDnode *pDnode, SRpcMsg *pRsp) { if (pRsp->code != TSDB_CODE_SUCCESS) { if (pRsp->code == TSDB_CODE_MND_DNODE_NOT_EXIST && !pDnode->data.dropped && pDnode->data.dnodeId > 0) { dInfo("dnode:%d, set to dropped since not exist in mnode", pDnode->data.dnodeId); pDnode->data.dropped = 1; - dmWriteFile(pMgmt); + dmWriteEps(pDnode); } } else { SStatusRsp statusRsp = {0}; - if (pRsp->pCont != NULL && pRsp->contLen != 0 && + if (pRsp->pCont != NULL && pRsp->contLen > 0 && tDeserializeSStatusRsp(pRsp->pCont, pRsp->contLen, &statusRsp) == 0) { - pMgmt->dnodeVer = statusRsp.dnodeVer; - dmUpdateDnodeCfg(pMgmt, &statusRsp.dnodeCfg); - dmUpdateDnodeEps(pMgmt, statusRsp.pDnodeEps); + pDnode->data.dnodeVer = statusRsp.dnodeVer; + dmUpdateDnodeCfg(pDnode, &statusRsp.dnodeCfg); + dmUpdateEps(pDnode, statusRsp.pDnodeEps); } tFreeSStatusRsp(&statusRsp); } @@ -44,11 +53,11 @@ void dmSendStatusReq(SDnode *pDnode) { taosRLockLatch(&pDnode->data.latch); req.sver = tsVersion; - req.dnodeVer = pMgmt->dnodeVer; + req.dnodeVer = pDnode->data.dnodeVer; req.dnodeId = pDnode->data.dnodeId; req.clusterId = pDnode->data.clusterId; req.rebootTime = pDnode->data.rebootTime; - req.updateTime = pMgmt->updateTime; + req.updateTime = pDnode->data.updateTime; req.numOfCores = tsNumOfCores; req.numOfSupportVnodes = pDnode->data.supportVnodes; tstrncpy(req.dnodeEp, pDnode->data.localEp, TSDB_EP_LEN); @@ -62,68 +71,52 @@ void dmSendStatusReq(SDnode *pDnode) { memcpy(req.clusterCfg.charset, tsCharset, TD_LOCALE_LEN); taosRUnLockLatch(&pDnode->data.latch); - SMgmtWrapper *pWrapper = dndAcquireWrapper(pDnode, VNODE); - if (pWrapper != NULL) { - SMonVloadInfo info = {0}; - dmGetVnodeLoads(pWrapper, &info); - req.pVloads = info.pVloads; - dndReleaseWrapper(pWrapper); - } + SMonVloadInfo info = {0}; + dmGetVnodeLoads(pDnode, &info); + req.pVloads = info.pVloads; int32_t contLen = tSerializeSStatusReq(NULL, 0, &req); void *pHead = rpcMallocCont(contLen); tSerializeSStatusReq(pHead, contLen, &req); - taosArrayDestroy(req.pVloads); + tFreeSStatusReq(&req); SRpcMsg rpcMsg = {.pCont = pHead, .contLen = contLen, .msgType = TDMT_MND_STATUS, .ahandle = (void *)0x9527}; - SRpcMsg rspMsg = {0}; - + SRpcMsg rpcRsp = {0}; + dTrace("send req:%s to mnode, app:%p", TMSG_INFO(rpcMsg.msgType), rpcMsg.ahandle); - dmSendToMnodeRecv(pDnode, rpcMsg, &rpcRsp); + dmSendToMnodeRecv(pDnode, &rpcMsg, &rpcRsp); dmProcessStatusRsp(pDnode, &rpcRsp); } -static void dmUpdateDnodeCfg(SDnodeData *pMgmt, SDnodeCfg *pCfg) { - SDnode *pDnode = pMgmt->pDnode; - - if (pDnode->data.dnodeId == 0) { - dInfo("set dnodeId:%d clusterId:%" PRId64, pCfg->dnodeId, pCfg->clusterId); - taosWLockLatch(&pDnode->data.latch); - pDnode->data.dnodeId = pCfg->dnodeId; - pDnode->data.clusterId = pCfg->clusterId; - dmWriteFile(pMgmt); - taosWUnLockLatch(&pDnode->data.latch); - } -} - -int32_t dmProcessAuthRsp(SDnodeData *pMgmt, SNodeMsg *pMsg) { +int32_t dmProcessAuthRsp(SDnode *pDnode, SNodeMsg *pMsg) { SRpcMsg *pRsp = &pMsg->rpcMsg; dError("auth rsp is received, but not supported yet"); return 0; } -int32_t dmProcessGrantRsp(SDnodeData *pMgmt, SNodeMsg *pMsg) { +int32_t dmProcessGrantRsp(SDnode *pDnode, SNodeMsg *pMsg) { SRpcMsg *pRsp = &pMsg->rpcMsg; dError("grant rsp is received, but not supported yet"); return 0; } -int32_t dmProcessConfigReq(SDnodeData *pMgmt, SNodeMsg *pMsg) { +int32_t dmProcessConfigReq(SDnode *pDnode, SNodeMsg *pMsg) { SRpcMsg *pReq = &pMsg->rpcMsg; SDCfgDnodeReq *pCfg = pReq->pCont; dError("config req is received, but not supported yet"); return TSDB_CODE_OPS_NOT_SUPPORT; } -static int32_t dmProcessCreateNodeMsg(SDnode *pDnode, EDndNodeType ntype, SNodeMsg *pMsg) { - SMgmtWrapper *pWrapper = dndAcquireWrapper(pDnode, ntype); +int32_t dmProcessCreateNodeReq(SDnode *pDnode, EDndNodeType ntype, SNodeMsg *pMsg) { + SMgmtWrapper *pWrapper = dmAcquireWrapper(pDnode, ntype); if (pWrapper != NULL) { - dndReleaseWrapper(pWrapper); + dmReleaseWrapper(pWrapper); terrno = TSDB_CODE_NODE_ALREADY_DEPLOYED; dError("failed to create node since %s", terrstr()); return -1; } + taosWLockLatch(&pDnode->wrapperLock); pWrapper = &pDnode->wrappers[ntype]; if (taosMkDir(pWrapper->path) != 0) { @@ -134,17 +127,20 @@ static int32_t dmProcessCreateNodeMsg(SDnode *pDnode, EDndNodeType ntype, SNodeM int32_t code = (*pWrapper->fp.createFp)(pWrapper, pMsg); if (code != 0) { - dError("node:%s, failed to open since %s", pWrapper->name, terrstr()); + dError("node:%s, failed to create since %s", pWrapper->name, terrstr()); } else { - dDebug("node:%s, has been opened", pWrapper->name); + dDebug("node:%s, has been created", pWrapper->name); + pWrapper->required = true; pWrapper->deployed = true; + (void)dmOpenNode(pWrapper); } + taosWUnLockLatch(&pDnode->wrapperLock); return code; } -static int32_t dmProcessDropNodeMsg(SDnode *pDnode, EDndNodeType ntype, SNodeMsg *pMsg) { - SMgmtWrapper *pWrapper = dndAcquireWrapper(pDnode, ntype); +int32_t dmProcessDropNodeReq(SDnode *pDnode, EDndNodeType ntype, SNodeMsg *pMsg) { + SMgmtWrapper *pWrapper = dmAcquireWrapper(pDnode, ntype); if (pWrapper == NULL) { terrno = TSDB_CODE_NODE_NOT_DEPLOYED; dError("failed to drop node since %s", terrstr()); @@ -152,68 +148,57 @@ static int32_t dmProcessDropNodeMsg(SDnode *pDnode, EDndNodeType ntype, SNodeMsg } taosWLockLatch(&pWrapper->latch); - pWrapper->deployed = false; int32_t code = (*pWrapper->fp.dropFp)(pWrapper, pMsg); if (code != 0) { - pWrapper->deployed = true; dError("node:%s, failed to drop since %s", pWrapper->name, terrstr()); + pWrapper->required = true; + pWrapper->deployed = true; } else { - pWrapper->deployed = false; dDebug("node:%s, has been dropped", pWrapper->name); + pWrapper->required = false; + pWrapper->deployed = false; + dmCloseNode(pWrapper); } taosWUnLockLatch(&pWrapper->latch); - dndReleaseWrapper(pWrapper); - return code; -} - -int32_t dmProcessCDnodeReq(SDnode *pDnode, SNodeMsg *pMsg) { - switch (pMsg->rpcMsg.msgType) { - case TDMT_DND_CREATE_MNODE: - return dmProcessCreateNodeMsg(pDnode, MNODE, pMsg); - case TDMT_DND_DROP_MNODE: - return dmProcessDropNodeMsg(pDnode, MNODE, pMsg); - case TDMT_DND_CREATE_QNODE: - return dmProcessCreateNodeMsg(pDnode, QNODE, pMsg); - case TDMT_DND_DROP_QNODE: - return dmProcessDropNodeMsg(pDnode, QNODE, pMsg); - case TDMT_DND_CREATE_SNODE: - return dmProcessCreateNodeMsg(pDnode, SNODE, pMsg); - case TDMT_DND_DROP_SNODE: - return dmProcessDropNodeMsg(pDnode, SNODE, pMsg); - case TDMT_DND_CREATE_BNODE: - return dmProcessCreateNodeMsg(pDnode, BNODE, pMsg); - case TDMT_DND_DROP_BNODE: - return dmProcessDropNodeMsg(pDnode, BNODE, pMsg); - default: - terrno = TSDB_CODE_MSG_NOT_PROCESSED; - return -1; - } + dmReleaseWrapper(pWrapper); + return 0; } -static void dmSetMsgHandle(SMgmtWrapper *pWrapper) { +static void dmSetMgmtMsgHandle(SMgmtWrapper *pWrapper) { // Requests handled by DNODE - dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_MNODE, dmProcessMgmtMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_DND_DROP_MNODE, dmProcessMgmtMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_QNODE, dmProcessMgmtMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_DND_DROP_QNODE, dmProcessMgmtMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_SNODE, dmProcessMgmtMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_DND_DROP_SNODE, dmProcessMgmtMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_BNODE, dmProcessMgmtMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_DND_DROP_BNODE, dmProcessMgmtMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_DND_CONFIG_DNODE, dmProcessMgmtMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_DND_CREATE_MNODE, dmProcessMgmtMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_DND_DROP_MNODE, dmProcessMgmtMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_DND_CREATE_QNODE, dmProcessMgmtMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_DND_DROP_QNODE, dmProcessMgmtMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_DND_CREATE_SNODE, dmProcessMgmtMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_DND_DROP_SNODE, dmProcessMgmtMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_DND_CREATE_BNODE, dmProcessMgmtMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_DND_DROP_BNODE, dmProcessMgmtMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_DND_CONFIG_DNODE, dmProcessMgmtMsg, DEFAULT_HANDLE); // Requests handled by MNODE - dndSetMsgHandle(pWrapper, TDMT_MND_GRANT_RSP, dmProcessMgmtMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_AUTH_RSP, dmProcessMgmtMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_GRANT_RSP, dmProcessMgmtMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_AUTH_RSP, dmProcessMgmtMsg, DEFAULT_HANDLE); } -static int32_t dmStart(SMgmtWrapper *pWrapper) { return dmStartStatusThread(pWrapper->pDnode); } +static int32_t dmStartMgmt(SMgmtWrapper *pWrapper) { + if (dmStartStatusThread(pWrapper->pDnode) != 0) { + return -1; + } + if (dmStartMonitorThread(pWrapper->pDnode) != 0) { + return -1; + } + return 0; +} -static void dmStop(SMgmtWrapper *pWrapper) { dmStopThread(pWrapper->pDnode); } +static void dmStopMgmt(SMgmtWrapper *pWrapper) { + dmStopMonitorThread(pWrapper->pDnode); + dmStopStatusThread(pWrapper->pDnode); +} -static int32_t dmInit(SMgmtWrapper *pWrapper) { +static int32_t dmInitMgmt(SMgmtWrapper *pWrapper) { dInfo("dnode-data start to init"); SDnode *pDnode = pWrapper->pDnode; @@ -224,7 +209,7 @@ static int32_t dmInit(SMgmtWrapper *pWrapper) { return -1; } - if (dmReadFile(pDnode) != 0) { + if (dmReadEps(pDnode) != 0) { dError("failed to read file since %s", terrstr()); return -1; } @@ -247,40 +232,40 @@ static int32_t dmInit(SMgmtWrapper *pWrapper) { return 0; } -static void dmCleanup(SMgmtWrapper *pWrapper) { +static void dmCleanupMgmt(SMgmtWrapper *pWrapper) { dInfo("dnode-data start to clean up"); SDnode *pDnode = pWrapper->pDnode; dmStopWorker(pDnode); taosWLockLatch(&pDnode->data.latch); - if (pMgmt->dnodeEps != NULL) { - taosArrayDestroy(pMgmt->dnodeEps); - pMgmt->dnodeEps = NULL; + if (pDnode->data.dnodeEps != NULL) { + taosArrayDestroy(pDnode->data.dnodeEps); + pDnode->data.dnodeEps = NULL; } - if (pMgmt->dnodeHash != NULL) { - taosHashCleanup(pMgmt->dnodeHash); - pMgmt->dnodeHash = NULL; + if (pDnode->data.dnodeHash != NULL) { + taosHashCleanup(pDnode->data.dnodeHash); + pDnode->data.dnodeHash = NULL; } taosWUnLockLatch(&pDnode->data.latch); - dndCleanupTrans(pDnode); + dmCleanupTrans(pDnode); dInfo("dnode-data is cleaned up"); } -static int32_t dmRequire(SMgmtWrapper *pWrapper, bool *required) { +static int32_t dmRequireMgmt(SMgmtWrapper *pWrapper, bool *required) { *required = true; return 0; } void dmSetMgmtFp(SMgmtWrapper *pWrapper) { SMgmtFp mgmtFp = {0}; - mgmtFp.openFp = dmInit; - mgmtFp.closeFp = dmCleanup; - mgmtFp.startFp = dmStart; - mgmtFp.stopFp = dmStop; - mgmtFp.requiredFp = dmRequire; + mgmtFp.openFp = dmInitMgmt; + mgmtFp.closeFp = dmCleanupMgmt; + mgmtFp.startFp = dmStartMgmt; + mgmtFp.stopFp = dmStopMgmt; + mgmtFp.requiredFp = dmRequireMgmt; - dmSetMsgHandle(pWrapper); + dmSetMgmtMsgHandle(pWrapper); pWrapper->name = "dnode"; pWrapper->fp = mgmtFp; } diff --git a/source/dnode/mgmt/implement/src/dmMonitor.c b/source/dnode/mgmt/implement/src/dmMonitor.c index 467aab112b..00eefc01d1 100644 --- a/source/dnode/mgmt/implement/src/dmMonitor.c +++ b/source/dnode/mgmt/implement/src/dmMonitor.c @@ -37,7 +37,7 @@ static void dmGetMonitorDnodeInfo(SDnode *pDnode, SMonDnodeInfo *pInfo) { static void dmGetMonitorInfo(SDnode *pDnode, SMonDmInfo *pInfo) { dmGetMonitorBasicInfo(pDnode, &pInfo->basic); - dndGetMonitorSysInfo(&pInfo->sys); + dmGetMonitorSysInfo(&pInfo->sys); dmGetMonitorDnodeInfo(pDnode, &pInfo->dnode); } @@ -64,14 +64,14 @@ void dmSendMonitorReport(SDnode *pDnode) { bool getFromAPI = !tsMultiProcess; pWrapper = &pDnode->wrappers[MNODE]; if (getFromAPI) { - if (dndMarkWrapper(pWrapper) == 0) { + if (dmMarkWrapper(pWrapper) == 0) { mmGetMonitorInfo(pWrapper, &mmInfo); - dndReleaseWrapper(pWrapper); + dmReleaseWrapper(pWrapper); } } else { if (pWrapper->required) { req.msgType = TDMT_MON_MM_INFO; - dndSendRecv(pDnode, &epset, &req, &rsp); + dmSendRecv(pDnode, &epset, &req, &rsp); if (rsp.code == 0 && rsp.contLen > 0) { tDeserializeSMonMmInfo(rsp.pCont, rsp.contLen, &mmInfo); } @@ -81,14 +81,14 @@ void dmSendMonitorReport(SDnode *pDnode) { pWrapper = &pDnode->wrappers[VNODE]; if (getFromAPI) { - if (dndMarkWrapper(pWrapper) == 0) { + if (dmMarkWrapper(pWrapper) == 0) { vmGetMonitorInfo(pWrapper, &vmInfo); - dndReleaseWrapper(pWrapper); + dmReleaseWrapper(pWrapper); } } else { if (pWrapper->required) { req.msgType = TDMT_MON_VM_INFO; - dndSendRecv(pDnode, &epset, &req, &rsp); + dmSendRecv(pDnode, &epset, &req, &rsp); if (rsp.code == 0 && rsp.contLen > 0) { tDeserializeSMonVmInfo(rsp.pCont, rsp.contLen, &vmInfo); } @@ -98,14 +98,14 @@ void dmSendMonitorReport(SDnode *pDnode) { pWrapper = &pDnode->wrappers[QNODE]; if (getFromAPI) { - if (dndMarkWrapper(pWrapper) == 0) { + if (dmMarkWrapper(pWrapper) == 0) { qmGetMonitorInfo(pWrapper, &qmInfo); - dndReleaseWrapper(pWrapper); + dmReleaseWrapper(pWrapper); } } else { if (pWrapper->required) { req.msgType = TDMT_MON_QM_INFO; - dndSendRecv(pDnode, &epset, &req, &rsp); + dmSendRecv(pDnode, &epset, &req, &rsp); if (rsp.code == 0 && rsp.contLen > 0) { tDeserializeSMonQmInfo(rsp.pCont, rsp.contLen, &qmInfo); } @@ -115,14 +115,14 @@ void dmSendMonitorReport(SDnode *pDnode) { pWrapper = &pDnode->wrappers[SNODE]; if (getFromAPI) { - if (dndMarkWrapper(pWrapper) == 0) { + if (dmMarkWrapper(pWrapper) == 0) { smGetMonitorInfo(pWrapper, &smInfo); - dndReleaseWrapper(pWrapper); + dmReleaseWrapper(pWrapper); } } else { if (pWrapper->required) { req.msgType = TDMT_MON_SM_INFO; - dndSendRecv(pDnode, &epset, &req, &rsp); + dmSendRecv(pDnode, &epset, &req, &rsp); if (rsp.code == 0 && rsp.contLen > 0) { tDeserializeSMonSmInfo(rsp.pCont, rsp.contLen, &smInfo); } @@ -132,14 +132,14 @@ void dmSendMonitorReport(SDnode *pDnode) { pWrapper = &pDnode->wrappers[BNODE]; if (getFromAPI) { - if (dndMarkWrapper(pWrapper) == 0) { + if (dmMarkWrapper(pWrapper) == 0) { bmGetMonitorInfo(pWrapper, &bmInfo); - dndReleaseWrapper(pWrapper); + dmReleaseWrapper(pWrapper); } } else { if (pWrapper->required) { req.msgType = TDMT_MON_BM_INFO; - dndSendRecv(pDnode, &epset, &req, &rsp); + dmSendRecv(pDnode, &epset, &req, &rsp); if (rsp.code == 0 && rsp.contLen > 0) { tDeserializeSMonBmInfo(rsp.pCont, rsp.contLen, &bmInfo); } @@ -161,7 +161,10 @@ void dmSendMonitorReport(SDnode *pDnode) { monSendReport(); } -void dmGetVnodeLoads(SMgmtWrapper *pWrapper, SMonVloadInfo *pInfo) { +void dmGetVnodeLoads(SDnode *pDnode, SMonVloadInfo *pInfo) { + SMgmtWrapper *pWrapper = dmAcquireWrapper(pDnode, VNODE); + if (pWrapper == NULL) return; + bool getFromAPI = !tsMultiProcess; if (getFromAPI) { vmGetVnodeLoads(pWrapper, pInfo); @@ -172,10 +175,11 @@ void dmGetVnodeLoads(SMgmtWrapper *pWrapper, SMonVloadInfo *pInfo) { tstrncpy(epset.eps[0].fqdn, tsLocalFqdn, TSDB_FQDN_LEN); epset.eps[0].port = tsServerPort; - dndSendRecv(pWrapper->pDnode, &epset, &req, &rsp); + dmSendRecv(pDnode, &epset, &req, &rsp); if (rsp.code == 0 && rsp.contLen > 0) { tDeserializeSMonVloadInfo(rsp.pCont, rsp.contLen, pInfo); } rpcFreeCont(rsp.pCont); } + dmReleaseWrapper(pWrapper); } diff --git a/source/dnode/mgmt/implement/src/dmObj.c b/source/dnode/mgmt/implement/src/dmObj.c index 3e9877292f..eec061b26d 100644 --- a/source/dnode/mgmt/implement/src/dmObj.c +++ b/source/dnode/mgmt/implement/src/dmObj.c @@ -16,12 +16,10 @@ #define _DEFAULT_SOURCE #include "dmImp.h" - -static int32_t dndInitVars(SDnode *pDnode, const SDnodeOpt *pOption) { +static int32_t dmInitVars(SDnode *pDnode, const SDnodeOpt *pOption) { pDnode->data.dnodeId = 0; pDnode->data.dropped = 0; pDnode->data.clusterId = 0; - pDnode->data.supportVnodes = pOption->numOfSupportVnodes; pDnode->data.serverPort = pOption->serverPort; pDnode->data.dataDir = strdup(pOption->dataDir); @@ -34,24 +32,25 @@ static int32_t dndInitVars(SDnode *pDnode, const SDnodeOpt *pOption) { pDnode->ntype = pOption->ntype; pDnode->data.rebootTime = taosGetTimestampMs(); - if (pDnode->data.dataDir == NULL || pDnode->data.localEp == NULL || pDnode->data.localFqdn == NULL || pDnode->data.firstEp == NULL || - pDnode->data.secondEp == NULL) { + if (pDnode->data.dataDir == NULL || pDnode->data.localEp == NULL || pDnode->data.localFqdn == NULL || + pDnode->data.firstEp == NULL || pDnode->data.secondEp == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; return -1; } if (!tsMultiProcess || pDnode->ntype == NODE_BEGIN || pDnode->ntype == NODE_END) { - pDnode->data.lockfile = dndCheckRunning(pDnode->data.dataDir); + pDnode->data.lockfile = dmCheckRunning(pDnode->data.dataDir); if (pDnode->data.lockfile == NULL) { return -1; } } taosInitRWLatch(&pDnode->data.latch); + taosInitRWLatch(&pDnode->wrapperLock); return 0; } -static void dndClearVars(SDnode *pDnode) { +static void dmClearVars(SDnode *pDnode) { for (EDndNodeType n = 0; n < NODE_END; ++n) { SMgmtWrapper *pMgmt = &pDnode->wrappers[n]; taosMemoryFreeClear(pMgmt->path); @@ -70,7 +69,7 @@ static void dndClearVars(SDnode *pDnode) { dDebug("dnode memory is cleared, data:%p", pDnode); } -SDnode *dndCreate(const SDnodeOpt *pOption) { +SDnode *dmCreate(const SDnodeOpt *pOption) { dDebug("start to create dnode object"); int32_t code = -1; char path[PATH_MAX] = {0}; @@ -82,12 +81,12 @@ SDnode *dndCreate(const SDnodeOpt *pOption) { goto _OVER; } - if (dndInitVars(pDnode, pOption) != 0) { + if (dmInitVars(pDnode, pOption) != 0) { dError("failed to init variables since %s", terrstr()); goto _OVER; } - dndSetStatus(pDnode, DND_STAT_INIT); + dmSetStatus(pDnode, DND_STAT_INIT); dmSetMgmtFp(&pDnode->wrappers[NODE_BEGIN]); mmSetMgmtFp(&pDnode->wrappers[MNODE]); vmSetMgmtFp(&pDnode->wrappers[VNODE]); @@ -111,12 +110,12 @@ SDnode *dndCreate(const SDnodeOpt *pOption) { taosInitRWLatch(&pWrapper->latch); } - if (dndInitMsgHandle(pDnode) != 0) { + if (dmInitMsgHandle(pDnode) != 0) { dError("failed to init msg handles since %s", terrstr()); goto _OVER; } - if (dndReadShmFile(pDnode) != 0) { + if (dmReadShmFile(pDnode) != 0) { dError("failed to read shm file since %s", terrstr()); goto _OVER; } @@ -129,7 +128,7 @@ SDnode *dndCreate(const SDnodeOpt *pOption) { _OVER: if (code != 0 && pDnode) { - dndClearVars(pDnode); + dmClearVars(pDnode); pDnode = NULL; dError("failed to create dnode since %s", terrstr()); } @@ -137,20 +136,14 @@ _OVER: return pDnode; } -void dndClose(SDnode *pDnode) { +void dmClose(SDnode *pDnode) { if (pDnode == NULL) return; for (EDndNodeType n = 0; n < NODE_END; ++n) { SMgmtWrapper *pWrapper = &pDnode->wrappers[n]; - dndCloseNode(pWrapper); + dmCloseNode(pWrapper); } - dndClearVars(pDnode); + dmClearVars(pDnode); dInfo("dnode is closed, data:%p", pDnode); } - -void dndHandleEvent(SDnode *pDnode, EDndEvent event) { - if (event == DND_EVENT_STOP) { - pDnode->event = event; - } -} diff --git a/source/dnode/mgmt/implement/src/dmTransport.c b/source/dnode/mgmt/implement/src/dmTransport.c index a0251a69f5..3db856b5fa 100644 --- a/source/dnode/mgmt/implement/src/dmTransport.c +++ b/source/dnode/mgmt/implement/src/dmTransport.c @@ -20,17 +20,17 @@ #define INTERNAL_CKEY "_key" #define INTERNAL_SECRET "_pwd" -static void dndGetMnodeEpSet(SDnode *pDnode, SEpSet *pEpSet) { +static void dmGetMnodeEpSet(SDnode *pDnode, SEpSet *pEpSet) { taosRLockLatch(&pDnode->data.latch); - *pEpSet = pDnode->data.mnodeEpSet; + *pEpSet = pDnode->data.mnodeEps; taosRUnLockLatch(&pDnode->data.latch); } -static void dndSetMnodeEpSet(SDnode *pDnode, SEpSet *pEpSet) { +static void dmSetMnodeEpSet(SDnode *pDnode, SEpSet *pEpSet) { dInfo("mnode is changed, num:%d use:%d", pEpSet->numOfEps, pEpSet->inUse); taosWLockLatch(&pDnode->data.latch); - pDnode->data.mnodeEpSet = *pEpSet; + pDnode->data.mnodeEps = *pEpSet; for (int32_t i = 0; i < pEpSet->numOfEps; ++i) { dInfo("mnode index:%d %s:%u", i, pEpSet->eps[i].fqdn, pEpSet->eps[i].port); } @@ -38,7 +38,7 @@ static void dndSetMnodeEpSet(SDnode *pDnode, SEpSet *pEpSet) { taosWUnLockLatch(&pDnode->data.latch); } -static inline NodeMsgFp dndGetMsgFp(SMgmtWrapper *pWrapper, SRpcMsg *pRpc) { +static inline NodeMsgFp dmGetMsgFp(SMgmtWrapper *pWrapper, SRpcMsg *pRpc) { NodeMsgFp msgFp = pWrapper->msgFps[TMSG_INDEX(pRpc->msgType)]; if (msgFp == NULL) { terrno = TSDB_CODE_MSG_NOT_PROCESSED; @@ -47,7 +47,7 @@ static inline NodeMsgFp dndGetMsgFp(SMgmtWrapper *pWrapper, SRpcMsg *pRpc) { return msgFp; } -static inline int32_t dndBuildMsg(SNodeMsg *pMsg, SRpcMsg *pRpc) { +static inline int32_t dmBuildMsg(SNodeMsg *pMsg, SRpcMsg *pRpc) { SRpcConnInfo connInfo = {0}; if ((pRpc->msgType & 1U) && rpcGetConnInfo(pRpc->handle, &connInfo) != 0) { terrno = TSDB_CODE_MND_NO_USER_FROM_CONN; @@ -62,20 +62,20 @@ static inline int32_t dndBuildMsg(SNodeMsg *pMsg, SRpcMsg *pRpc) { return 0; } -static void dndProcessRpcMsg(SMgmtWrapper *pWrapper, SRpcMsg *pRpc, SEpSet *pEpSet) { +static void dmProcessRpcMsg(SMgmtWrapper *pWrapper, SRpcMsg *pRpc, SEpSet *pEpSet) { int32_t code = -1; SNodeMsg *pMsg = NULL; NodeMsgFp msgFp = NULL; uint16_t msgType = pRpc->msgType; if (pEpSet && pEpSet->numOfEps > 0 && msgType == TDMT_MND_STATUS_RSP) { - dndSetMnodeEpSet(pWrapper->pDnode, pEpSet); + dmSetMnodeEpSet(pWrapper->pDnode, pEpSet); } - if (dndMarkWrapper(pWrapper) != 0) goto _OVER; - if ((msgFp = dndGetMsgFp(pWrapper, pRpc)) == NULL) goto _OVER; + if (dmMarkWrapper(pWrapper) != 0) goto _OVER; + if ((msgFp = dmGetMsgFp(pWrapper, pRpc)) == NULL) goto _OVER; if ((pMsg = taosAllocateQitem(sizeof(SNodeMsg))) == NULL) goto _OVER; - if (dndBuildMsg(pMsg, pRpc) != 0) goto _OVER; + if (dmBuildMsg(pMsg, pRpc) != 0) goto _OVER; if (pWrapper->procType == DND_PROC_SINGLE) { dTrace("msg:%p, is created, handle:%p user:%s", pMsg, pRpc->handle, pMsg->user); @@ -114,10 +114,10 @@ _OVER: rpcFreeCont(pRpc->pCont); } - dndReleaseWrapper(pWrapper); + dmReleaseWrapper(pWrapper); } -static void dndProcessMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) { +static void dmProcessMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) { SDnodeTrans *pTrans = &pDnode->trans; tmsg_t msgType = pMsg->msgType; bool isReq = msgType & 1u; @@ -126,11 +126,11 @@ static void dndProcessMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) { if (msgType == TDMT_DND_NETWORK_TEST) { dTrace("network test req will be processed, handle:%p, app:%p", pMsg->handle, pMsg->ahandle); - dndProcessStartupReq(pDnode, pMsg); + dmProcessStartupReq(pDnode, pMsg); return; } - if (dndGetStatus(pDnode) != DND_STAT_RUNNING) { + if (pDnode->status != DND_STAT_RUNNING) { dError("msg:%s ignored since dnode not running, handle:%p app:%p", TMSG_INFO(msgType), pMsg->handle, pMsg->ahandle); if (isReq) { SRpcMsg rspMsg = {.handle = pMsg->handle, .code = TSDB_CODE_APP_NOT_READY, .ahandle = pMsg->ahandle}; @@ -168,10 +168,10 @@ static void dndProcessMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) { } dTrace("msg:%s will be processed by %s, app:%p", TMSG_INFO(msgType), pWrapper->name, pMsg->ahandle); - dndProcessRpcMsg(pWrapper, pMsg, pEpSet); + dmProcessRpcMsg(pWrapper, pMsg, pEpSet); } -int32_t dndInitMsgHandle(SDnode *pDnode) { +int32_t dmInitMsgHandle(SDnode *pDnode) { SDnodeTrans *pTrans = &pDnode->trans; for (EDndNodeType n = NODE_BEGIN + 1; n < NODE_END; ++n) { @@ -208,7 +208,7 @@ int32_t dndInitMsgHandle(SDnode *pDnode) { return 0; } -static inline int32_t dndSendRpcReq(SDnode *pDnode, const SEpSet *pEpSet, SRpcMsg *pReq) { +static inline int32_t dmSendRpcReq(SDnode *pDnode, const SEpSet *pEpSet, SRpcMsg *pReq) { if (pDnode->trans.clientRpc == NULL) { terrno = TSDB_CODE_NODE_OFFLINE; return -1; @@ -218,9 +218,9 @@ static inline int32_t dndSendRpcReq(SDnode *pDnode, const SEpSet *pEpSet, SRpcMs return 0; } -static void dndSendRpcRedirectRsp(SDnode *pDnode, const SRpcMsg *pReq) { +static void dmSendRpcRedirectRsp(SDnode *pDnode, const SRpcMsg *pReq) { SEpSet epSet = {0}; - dndGetMnodeEpSet(pDnode, &epSet); + dmGetMnodeEpSet(pDnode, &epSet); dDebug("RPC %p, req is redirected, num:%d use:%d", pReq->handle, epSet.numOfEps, epSet.inUse); for (int32_t i = 0; i < epSet.numOfEps; ++i) { @@ -235,39 +235,33 @@ static void dndSendRpcRedirectRsp(SDnode *pDnode, const SRpcMsg *pReq) { rpcSendRedirectRsp(pReq->handle, &epSet); } -static inline void dndSendRpcRsp(SDnode *pDnode, const SRpcMsg *pRsp) { +static inline void dmSendRpcRsp(SDnode *pDnode, const SRpcMsg *pRsp) { if (pRsp->code == TSDB_CODE_NODE_REDIRECT) { - dndSendRpcRedirectRsp(pDnode, pRsp); + dmSendRpcRedirectRsp(pDnode, pRsp); } else { rpcSendResponse(pRsp); } } -void dndSendRecv(SDnode *pDnode, SEpSet *pEpSet, SRpcMsg *pReq, SRpcMsg *pRsp) { +void dmSendRecv(SDnode *pDnode, SEpSet *pEpSet, SRpcMsg *pReq, SRpcMsg *pRsp) { rpcSendRecv(pDnode->trans.clientRpc, pEpSet, pReq, pRsp); } -int32_t dndSendMsgToMnode(SDnode *pDnode, SRpcMsg *pReq) { - SEpSet epSet = {0}; - dndGetMnodeEpSet(pDnode, &epSet); - return dndSendRpcReq(pDnode, &epSet, pReq); -} - void dmSendToMnodeRecv(SDnode *pDnode, SRpcMsg *pReq, SRpcMsg *pRsp) { SEpSet epSet = {0}; - dndGetMnodeEpSet(pDnode, &epSet); + dmGetMnodeEpSet(pDnode, &epSet); rpcSendRecv(pDnode->trans.clientRpc, &epSet, pReq, pRsp); } -static inline int32_t dndSendReq(SMgmtWrapper *pWrapper, const SEpSet *pEpSet, SRpcMsg *pReq) { - if (dndGetStatus(pWrapper->pDnode) != DND_STAT_RUNNING) { +static inline int32_t dmSendReq(SMgmtWrapper *pWrapper, const SEpSet *pEpSet, SRpcMsg *pReq) { + if (pWrapper->pDnode->status != DND_STAT_RUNNING) { terrno = TSDB_CODE_NODE_OFFLINE; dError("failed to send rpc msg since %s, handle:%p", terrstr(), pReq->handle); return -1; } if (pWrapper->procType != DND_PROC_CHILD) { - return dndSendRpcReq(pWrapper->pDnode, pEpSet, pReq); + return dmSendRpcReq(pWrapper->pDnode, pEpSet, pReq); } else { char *pHead = taosMemoryMalloc(sizeof(SRpcMsg) + sizeof(SEpSet)); if (pHead == NULL) { @@ -284,15 +278,15 @@ static inline int32_t dndSendReq(SMgmtWrapper *pWrapper, const SEpSet *pEpSet, S } } -static inline void dndSendRsp(SMgmtWrapper *pWrapper, const SRpcMsg *pRsp) { +static inline void dmSendRsp(SMgmtWrapper *pWrapper, const SRpcMsg *pRsp) { if (pWrapper->procType != DND_PROC_CHILD) { - dndSendRpcRsp(pWrapper->pDnode, pRsp); + dmSendRpcRsp(pWrapper->pDnode, pRsp); } else { taosProcPutToParentQ(pWrapper->procObj, pRsp, sizeof(SRpcMsg), pRsp->pCont, pRsp->contLen, PROC_FUNC_RSP); } } -static inline void dndRegisterBrokenLinkArg(SMgmtWrapper *pWrapper, SRpcMsg *pMsg) { +static inline void dmRegisterBrokenLinkArg(SMgmtWrapper *pWrapper, SRpcMsg *pMsg) { if (pWrapper->procType != DND_PROC_CHILD) { rpcRegisterBrokenLinkArg(pMsg); } else { @@ -300,7 +294,7 @@ static inline void dndRegisterBrokenLinkArg(SMgmtWrapper *pWrapper, SRpcMsg *pMs } } -static inline void dndReleaseHandle(SMgmtWrapper *pWrapper, void *handle, int8_t type) { +static inline void dmReleaseHandle(SMgmtWrapper *pWrapper, void *handle, int8_t type) { if (pWrapper->procType != DND_PROC_CHILD) { rpcReleaseHandle(handle, type); } else { @@ -309,8 +303,8 @@ static inline void dndReleaseHandle(SMgmtWrapper *pWrapper, void *handle, int8_t } } -static void dndConsumeChildQueue(SMgmtWrapper *pWrapper, SNodeMsg *pMsg, int16_t msgLen, void *pCont, int32_t contLen, - EProcFuncType ftype) { +static void dmConsumeChildQueue(SMgmtWrapper *pWrapper, SNodeMsg *pMsg, int16_t msgLen, void *pCont, int32_t contLen, + EProcFuncType ftype) { SRpcMsg *pRpc = &pMsg->rpcMsg; pRpc->pCont = pCont; dTrace("msg:%p, get from child queue, handle:%p app:%p", pMsg, pRpc->handle, pRpc->ahandle); @@ -322,7 +316,7 @@ static void dndConsumeChildQueue(SMgmtWrapper *pWrapper, SNodeMsg *pMsg, int16_t dError("msg:%p, failed to process since code:0x%04x:%s", pMsg, code & 0XFFFF, tstrerror(code)); if (pRpc->msgType & 1U) { SRpcMsg rsp = {.handle = pRpc->handle, .ahandle = pRpc->ahandle, .code = terrno}; - dndSendRsp(pWrapper, &rsp); + dmSendRsp(pWrapper, &rsp); } dTrace("msg:%p, is freed", pMsg); @@ -331,8 +325,8 @@ static void dndConsumeChildQueue(SMgmtWrapper *pWrapper, SNodeMsg *pMsg, int16_t } } -static void dndConsumeParentQueue(SMgmtWrapper *pWrapper, SRpcMsg *pMsg, int16_t msgLen, void *pCont, int32_t contLen, - EProcFuncType ftype) { +static void dmConsumeParentQueue(SMgmtWrapper *pWrapper, SRpcMsg *pMsg, int16_t msgLen, void *pCont, int32_t contLen, + EProcFuncType ftype) { pMsg->pCont = pCont; dTrace("msg:%p, get from parent queue, ftype:%d handle:%p code:0x%04x mtype:%d, app:%p", pMsg, ftype, pMsg->handle, pMsg->code & 0xFFFF, pMsg->msgType, pMsg->ahandle); @@ -347,11 +341,11 @@ static void dndConsumeParentQueue(SMgmtWrapper *pWrapper, SRpcMsg *pMsg, int16_t rpcFreeCont(pCont); break; case PROC_FUNC_REQ: - dndSendRpcReq(pWrapper->pDnode, (SEpSet *)((char *)pMsg + sizeof(SRpcMsg)), pMsg); + dmSendRpcReq(pWrapper->pDnode, (SEpSet *)((char *)pMsg + sizeof(SRpcMsg)), pMsg); break; case PROC_FUNC_RSP: taosProcRemoveHandle(pWrapper->procObj, pMsg->handle); - dndSendRpcRsp(pWrapper->pDnode, pMsg); + dmSendRpcRsp(pWrapper->pDnode, pMsg); break; default: break; @@ -359,13 +353,13 @@ static void dndConsumeParentQueue(SMgmtWrapper *pWrapper, SRpcMsg *pMsg, int16_t taosMemoryFree(pMsg); } -SProcCfg dndGenProcCfg(SMgmtWrapper *pWrapper) { - SProcCfg cfg = {.childConsumeFp = (ProcConsumeFp)dndConsumeChildQueue, +SProcCfg dmGenProcCfg(SMgmtWrapper *pWrapper) { + SProcCfg cfg = {.childConsumeFp = (ProcConsumeFp)dmConsumeChildQueue, .childMallocHeadFp = (ProcMallocFp)taosAllocateQitem, .childFreeHeadFp = (ProcFreeFp)taosFreeQitem, .childMallocBodyFp = (ProcMallocFp)rpcMallocCont, .childFreeBodyFp = (ProcFreeFp)rpcFreeCont, - .parentConsumeFp = (ProcConsumeFp)dndConsumeParentQueue, + .parentConsumeFp = (ProcConsumeFp)dmConsumeParentQueue, .parentMallocHeadFp = (ProcMallocFp)taosMemoryMalloc, .parentFreeHeadFp = (ProcFreeFp)taosMemoryFree, .parentMallocBodyFp = (ProcMallocFp)rpcMallocCont, @@ -376,13 +370,13 @@ SProcCfg dndGenProcCfg(SMgmtWrapper *pWrapper) { return cfg; } -static int32_t dndInitClient(SDnode *pDnode) { +static int32_t dmInitClient(SDnode *pDnode) { SDnodeTrans *pTrans = &pDnode->trans; SRpcInit rpcInit = {0}; rpcInit.label = "DND"; rpcInit.numOfThreads = 1; - rpcInit.cfp = (RpcCfp)dndProcessMsg; + rpcInit.cfp = (RpcCfp)dmProcessMsg; rpcInit.sessions = 1024; rpcInit.connType = TAOS_CONN_CLIENT; rpcInit.idleTime = tsShellActivityTimer * 1000; @@ -405,7 +399,7 @@ static int32_t dndInitClient(SDnode *pDnode) { return 0; } -static void dndCleanupClient(SDnode *pDnode) { +static void dmCleanupClient(SDnode *pDnode) { SDnodeTrans *pTrans = &pDnode->trans; if (pTrans->clientRpc) { rpcClose(pTrans->clientRpc); @@ -414,8 +408,8 @@ static void dndCleanupClient(SDnode *pDnode) { } } -static inline int32_t dndGetHideUserAuth(SDnode *pDnode, char *user, char *spi, char *encrypt, char *secret, - char *ckey) { +static inline int32_t dmGetHideUserAuth(SDnode *pDnode, char *user, char *spi, char *encrypt, char *secret, + char *ckey) { int32_t code = 0; char pass[TSDB_PASSWORD_LEN + 1] = {0}; @@ -437,9 +431,9 @@ static inline int32_t dndGetHideUserAuth(SDnode *pDnode, char *user, char *spi, return code; } -static inline int32_t dndRetrieveUserAuthInfo(SDnode *pDnode, char *user, char *spi, char *encrypt, char *secret, - char *ckey) { - if (dndGetHideUserAuth(pDnode, user, spi, encrypt, secret, ckey) == 0) { +static inline int32_t dmRetrieveUserAuthInfo(SDnode *pDnode, char *user, char *spi, char *encrypt, char *secret, + char *ckey) { + if (dmGetHideUserAuth(pDnode, user, spi, encrypt, secret, ckey) == 0) { dTrace("user:%s, get auth from mnode, spi:%d encrypt:%d", user, *spi, *encrypt); return 0; } @@ -473,18 +467,18 @@ static inline int32_t dndRetrieveUserAuthInfo(SDnode *pDnode, char *user, char * return rpcRsp.code; } -static int32_t dndInitServer(SDnode *pDnode) { +static int32_t dmInitServer(SDnode *pDnode) { SDnodeTrans *pTrans = &pDnode->trans; SRpcInit rpcInit = {0}; rpcInit.localPort = pDnode->data.serverPort; rpcInit.label = "DND"; rpcInit.numOfThreads = tsNumOfRpcThreads; - rpcInit.cfp = (RpcCfp)dndProcessMsg; + rpcInit.cfp = (RpcCfp)dmProcessMsg; rpcInit.sessions = tsMaxShellConns; rpcInit.connType = TAOS_CONN_SERVER; rpcInit.idleTime = tsShellActivityTimer * 1000; - rpcInit.afp = (RpcAfp)dndRetrieveUserAuthInfo; + rpcInit.afp = (RpcAfp)dmRetrieveUserAuthInfo; rpcInit.parent = pDnode; pTrans->serverRpc = rpcOpen(&rpcInit); @@ -497,7 +491,7 @@ static int32_t dndInitServer(SDnode *pDnode) { return 0; } -static void dndCleanupServer(SDnode *pDnode) { +static void dmCleanupServer(SDnode *pDnode) { SDnodeTrans *pTrans = &pDnode->trans; if (pTrans->serverRpc) { rpcClose(pTrans->serverRpc); @@ -507,21 +501,21 @@ static void dndCleanupServer(SDnode *pDnode) { } int32_t dmInitTrans(SDnode *pDnode) { - if (dndInitServer(pDnode) != 0) return -1; - if (dndInitClient(pDnode) != 0) return -1; + if (dmInitServer(pDnode) != 0) return -1; + if (dmInitClient(pDnode) != 0) return -1; SMsgCb msgCb = { - .sendReqFp = dndSendReq, - .sendRspFp = dndSendRsp, - .registerBrokenLinkArgFp = dndRegisterBrokenLinkArg, - .releaseHandleFp = dndReleaseHandle, + .sendReqFp = dmSendReq, + .sendRspFp = dmSendRsp, + .registerBrokenLinkArgFp = dmRegisterBrokenLinkArg, + .releaseHandleFp = dmReleaseHandle, }; pDnode->data.msgCb = msgCb; return 0; } -void dndCleanupTrans(SDnode *pDnode) { - dndCleanupServer(pDnode); - dndCleanupClient(pDnode); +void dmCleanupTrans(SDnode *pDnode) { + dmCleanupServer(pDnode); + dmCleanupClient(pDnode); } diff --git a/source/dnode/mgmt/implement/src/dmWorker.c b/source/dnode/mgmt/implement/src/dmWorker.c index 9c32d0bda6..6ffb8e1a23 100644 --- a/source/dnode/mgmt/implement/src/dmWorker.c +++ b/source/dnode/mgmt/implement/src/dmWorker.c @@ -33,7 +33,7 @@ static void *dmStatusThreadFp(void *param) { int64_t curTime = taosGetTimestampMs(); float interval = (curTime - lastTime) / 1000.0f; if (interval >= tsStatusInterval) { - dmSendStatusReq(pMgmt); + dmSendStatusReq(pDnode); lastTime = curTime; } } @@ -67,8 +67,8 @@ static void *dmMonitorThreadFp(void *param) { } int32_t dmStartStatusThread(SDnode *pDnode) { - pDnode->statusThreadId = taosCreateThread(dmStatusThreadFp, pDnode); - if (pDnode->statusThreadId == NULL) { + pDnode->data.statusThreadId = taosCreateThread(dmStatusThreadFp, pDnode); + if (pDnode->data.statusThreadId == NULL) { dError("failed to init dnode status thread"); terrno = TSDB_CODE_OUT_OF_MEMORY; return -1; @@ -78,15 +78,15 @@ int32_t dmStartStatusThread(SDnode *pDnode) { } void dmStopStatusThread(SDnode *pDnode) { - if (pDnode->statusThreadId != NULL) { - taosDestoryThread(pDnode->statusThreadId); - pDnode->statusThreadId = NULL; + if (pDnode->data.statusThreadId != NULL) { + taosDestoryThread(pDnode->data.statusThreadId); + pDnode->data.statusThreadId = NULL; } } int32_t dmStartMonitorThread(SDnode *pDnode) { - pDnode->monitorThreadId = taosCreateThread(dmMonitorThreadFp, pDnode); - if (pDnode->monitorThreadId == NULL) { + pDnode->data.monitorThreadId = taosCreateThread(dmMonitorThreadFp, pDnode); + if (pDnode->data.monitorThreadId == NULL) { dError("failed to init dnode monitor thread"); terrno = TSDB_CODE_OUT_OF_MEMORY; return -1; @@ -96,9 +96,9 @@ int32_t dmStartMonitorThread(SDnode *pDnode) { } void dmStopMonitorThread(SDnode *pDnode) { - if (pMgmt->monitorThreadId != NULL) { - taosDestoryThread(pMgmt->monitorThreadId); - pMgmt->monitorThreadId = NULL; + if (pDnode->data.monitorThreadId != NULL) { + taosDestoryThread(pDnode->data.monitorThreadId); + pDnode->data.monitorThreadId = NULL; } } @@ -110,16 +110,39 @@ static void dmProcessMgmtQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) { switch (pRpc->msgType) { case TDMT_DND_CONFIG_DNODE: - code = dmProcessConfigReq(pMgmt, pMsg); + code = dmProcessConfigReq(pDnode, pMsg); break; case TDMT_MND_AUTH_RSP: - code = dmProcessAuthRsp(pMgmt, pMsg); + code = dmProcessAuthRsp(pDnode, pMsg); break; case TDMT_MND_GRANT_RSP: - code = dmProcessGrantRsp(pMgmt, pMsg); + code = dmProcessGrantRsp(pDnode, pMsg); + break; + case TDMT_DND_CREATE_MNODE: + code = dmProcessCreateNodeReq(pDnode, MNODE, pMsg); + break; + case TDMT_DND_DROP_MNODE: + code = dmProcessDropNodeReq(pDnode, MNODE, pMsg); + break; + case TDMT_DND_CREATE_QNODE: + code = dmProcessCreateNodeReq(pDnode, QNODE, pMsg); + break; + case TDMT_DND_DROP_QNODE: + code = dmProcessDropNodeReq(pDnode, QNODE, pMsg); + break; + case TDMT_DND_CREATE_SNODE: + code = dmProcessCreateNodeReq(pDnode, SNODE, pMsg); + break; + case TDMT_DND_DROP_SNODE: + code = dmProcessDropNodeReq(pDnode, SNODE, pMsg); + break; + case TDMT_DND_CREATE_BNODE: + code = dmProcessCreateNodeReq(pDnode, BNODE, pMsg); + break; + case TDMT_DND_DROP_BNODE: + code = dmProcessDropNodeReq(pDnode, BNODE, pMsg); break; default: - code = dmProcessCDnodeReq(pMgmt->pDnode, pMsg); break; } @@ -134,9 +157,9 @@ static void dmProcessMgmtQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) { taosFreeQitem(pMsg); } -int32_t dmStartWorker(SDnodeData *pMgmt) { - SSingleWorkerCfg cfg = {.min = 1, .max = 1, .name = "dnode-mgmt", .fp = (FItem)dmProcessMgmtQueue, .param = pMgmt}; - if (tSingleWorkerInit(&pMgmt->mgmtWorker, &cfg) != 0) { +int32_t dmStartWorker(SDnode *pDnode) { + SSingleWorkerCfg cfg = {.min = 1, .max = 1, .name = "dnode-mgmt", .fp = (FItem)dmProcessMgmtQueue, .param = pDnode}; + if (tSingleWorkerInit(&pDnode->data.mgmtWorker, &cfg) != 0) { dError("failed to start dnode-mgmt worker since %s", terrstr()); return -1; } @@ -145,24 +168,13 @@ int32_t dmStartWorker(SDnodeData *pMgmt) { return 0; } -void dmStopWorker(SDnodeData *pMgmt) { - tSingleWorkerCleanup(&pMgmt->mgmtWorker); +void dmStopWorker(SDnode *pDnode) { + tSingleWorkerCleanup(&pDnode->data.mgmtWorker); dDebug("dnode workers are closed"); } int32_t dmProcessMgmtMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { - SDnodeData *pMgmt = pWrapper->pMgmt; - SSingleWorker *pWorker = &pMgmt->mgmtWorker; - - dTrace("msg:%p, put into worker %s", pMsg, pWorker->name); - taosWriteQitem(pWorker->queue, pMsg); - return 0; -} - -int32_t dmProcessStatusMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { - SDnodeData *pMgmt = pWrapper->pMgmt; - SSingleWorker *pWorker = &pMgmt->monitorWorker; - + SSingleWorker *pWorker = &pWrapper->pDnode->data.mgmtWorker; dTrace("msg:%p, put into worker %s", pMsg, pWorker->name); taosWriteQitem(pWorker->queue, pMsg); return 0; diff --git a/source/dnode/mgmt/interface/inc/dmDef.h b/source/dnode/mgmt/interface/inc/dmDef.h index 26d7d42af9..09771af2f2 100644 --- a/source/dnode/mgmt/interface/inc/dmDef.h +++ b/source/dnode/mgmt/interface/inc/dmDef.h @@ -13,8 +13,8 @@ * along with this program. If not, see . */ -#ifndef _TD_DND_DEF_H_ -#define _TD_DND_DEF_H_ +#ifndef _TD_DM_DEF_H_ +#define _TD_DM_DEF_H_ #include "dmLog.h" @@ -110,9 +110,9 @@ typedef struct { int64_t updateTime; int64_t rebootTime; bool dropped; - SEpSet mnodeEpSet; - SHashObj *dnodeHash; + SEpSet mnodeEps; SArray *dnodeEps; + SHashObj *dnodeHash; TdThread *statusThreadId; TdThread *monitorThreadId; SRWLatch latch; @@ -140,6 +140,7 @@ typedef struct SDnode { SStartupReq startup; SDnodeTrans trans; SDnodeData data; + SRWLatch wrapperLock; SMgmtWrapper wrappers[NODE_END]; } SDnode; @@ -147,4 +148,4 @@ typedef struct SDnode { } #endif -#endif /*_TD_DND_DEF_H_*/ \ No newline at end of file +#endif /*_TD_DM_DEF_H_*/ \ No newline at end of file diff --git a/source/dnode/mgmt/interface/inc/dmInt.h b/source/dnode/mgmt/interface/inc/dmInt.h index 7b633671f8..9e8ac82195 100644 --- a/source/dnode/mgmt/interface/inc/dmInt.h +++ b/source/dnode/mgmt/interface/inc/dmInt.h @@ -13,8 +13,8 @@ * along with this program. If not, see . */ -#ifndef _TD_DND_INT_H_ -#define _TD_DND_INT_H_ +#ifndef _TD_DM_INT_H_ +#define _TD_DM_INT_H_ #include "dmDef.h" @@ -22,32 +22,32 @@ extern "C" { #endif -// dndInt.c -const char *dndStatName(EDndRunStatus stat); -const char *dndLogName(EDndNodeType ntype); -const char *dndProcName(EDndNodeType ntype); -const char *dndEventName(EDndEvent ev); -SMgmtWrapper *dndAcquireWrapper(SDnode *pDnode, EDndNodeType nType); -int32_t dndMarkWrapper(SMgmtWrapper *pWrapper); -void dndReleaseWrapper(SMgmtWrapper *pWrapper); -EDndRunStatus dndGetStatus(SDnode *pDnode); -void dndSetStatus(SDnode *pDnode, EDndRunStatus stat); -void dndSetEvent(SDnode *pDnode, EDndEvent event); -void dndSetMsgHandle(SMgmtWrapper *pWrapper, tmsg_t msgType, NodeMsgFp nodeMsgFp, int8_t vgId); -void dndReportStartup(SDnode *pDnode, const char *pName, const char *pDesc); -void dndProcessStartupReq(SDnode *pDnode, SRpcMsg *pMsg); -void dndGetMonitorSysInfo(SMonSysInfo *pInfo); -SMsgCb dmGetMsgcb(SMgmtWrapper *pWrapper); - -// dndFile.c -int32_t dndReadFile(SMgmtWrapper *pWrapper, bool *pDeployed); -int32_t dndWriteFile(SMgmtWrapper *pWrapper, bool deployed); -TdFilePtr dndCheckRunning(const char *dataDir); -int32_t dndReadShmFile(SDnode *pDnode); -int32_t dndWriteShmFile(SDnode *pDnode); +// dmInt.c +SMgmtWrapper *dmAcquireWrapper(SDnode *pDnode, EDndNodeType nType); +int32_t dmMarkWrapper(SMgmtWrapper *pWrapper); +void dmReleaseWrapper(SMgmtWrapper *pWrapper); +const char *dmStatName(EDndRunStatus stat); +const char *dmLogName(EDndNodeType ntype); +const char *dmProcName(EDndNodeType ntype); +const char *dmEventName(EDndEvent ev); + +void dmSetStatus(SDnode *pDnode, EDndRunStatus stat); +void dmSetEvent(SDnode *pDnode, EDndEvent event); +void dmSetMsgHandle(SMgmtWrapper *pWrapper, tmsg_t msgType, NodeMsgFp nodeMsgFp, int8_t vgId); +void dmReportStartup(SDnode *pDnode, const char *pName, const char *pDesc); +void dmProcessStartupReq(SDnode *pDnode, SRpcMsg *pMsg); +void dmGetMonitorSysInfo(SMonSysInfo *pInfo); +SMsgCb dmGetMsgcb(SMgmtWrapper *pWrapper); + +// dmFile.c +int32_t dmReadFile(SMgmtWrapper *pWrapper, bool *pDeployed); +int32_t dmWriteFile(SMgmtWrapper *pWrapper, bool deployed); +TdFilePtr dmCheckRunning(const char *dataDir); +int32_t dmReadShmFile(SDnode *pDnode); +int32_t dmWriteShmFile(SDnode *pDnode); #ifdef __cplusplus } #endif -#endif /*_TD_DND_INT_H_*/ \ No newline at end of file +#endif /*_TD_DM_INT_H_*/ \ No newline at end of file diff --git a/source/dnode/mgmt/interface/inc/dmLog.h b/source/dnode/mgmt/interface/inc/dmLog.h index 78d24e0ef5..c21933fc01 100644 --- a/source/dnode/mgmt/interface/inc/dmLog.h +++ b/source/dnode/mgmt/interface/inc/dmLog.h @@ -13,8 +13,8 @@ * along with this program. If not, see . */ -#ifndef _TD_DND_LOG_H_ -#define _TD_DND_LOG_H_ +#ifndef _TD_DM_LOG_H_ +#define _TD_DM_LOG_H_ #include "tlog.h" @@ -33,4 +33,4 @@ extern "C" { } #endif -#endif /*_TD_DND_LOG_H_*/ \ No newline at end of file +#endif /*_TD_DM_LOG_H_*/ \ No newline at end of file diff --git a/source/dnode/mgmt/interface/src/dmEnv.c b/source/dnode/mgmt/interface/src/dmEnv.c index e7dc0e3e77..b6f309ec6f 100644 --- a/source/dnode/mgmt/interface/src/dmEnv.c +++ b/source/dnode/mgmt/interface/src/dmEnv.c @@ -19,7 +19,7 @@ static int8_t once = DND_ENV_INIT; -int32_t dndInit() { +int32_t dmInit() { dDebug("start to init dnode env"); if (atomic_val_compare_exchange_8(&once, DND_ENV_INIT, DND_ENV_READY) != DND_ENV_INIT) { terrno = TSDB_CODE_REPEAT_INIT; @@ -45,7 +45,7 @@ int32_t dndInit() { return 0; } -void dndCleanup() { +void dmCleanup() { dDebug("start to cleanup dnode env"); if (atomic_val_compare_exchange_8(&once, DND_ENV_READY, DND_ENV_CLEANUP) != DND_ENV_READY) { dError("dnode env is already cleaned up"); diff --git a/source/dnode/mgmt/interface/src/dmFile.c b/source/dnode/mgmt/interface/src/dmFile.c index 70dbcc009f..2bf5acc800 100644 --- a/source/dnode/mgmt/interface/src/dmFile.c +++ b/source/dnode/mgmt/interface/src/dmFile.c @@ -18,7 +18,7 @@ #define MAXLEN 1024 -int32_t dndReadFile(SMgmtWrapper *pWrapper, bool *pDeployed) { +int32_t dmReadFile(SMgmtWrapper *pWrapper, bool *pDeployed) { int32_t code = TSDB_CODE_INVALID_JSON_FORMAT; int64_t len = 0; char content[MAXLEN + 1] = {0}; @@ -64,7 +64,7 @@ _OVER: return code; } -int32_t dndWriteFile(SMgmtWrapper *pWrapper, bool deployed) { +int32_t dmWriteFile(SMgmtWrapper *pWrapper, bool deployed) { int32_t code = -1; int32_t len = 0; char content[MAXLEN + 1] = {0}; @@ -117,7 +117,7 @@ _OVER: return code; } -TdFilePtr dndCheckRunning(const char *dataDir) { +TdFilePtr dmCheckRunning(const char *dataDir) { char filepath[PATH_MAX] = {0}; snprintf(filepath, sizeof(filepath), "%s%s.running", dataDir, TD_DIRSEP); @@ -140,7 +140,7 @@ TdFilePtr dndCheckRunning(const char *dataDir) { return pFile; } -int32_t dndReadShmFile(SDnode *pDnode) { +int32_t dmReadShmFile(SDnode *pDnode) { int32_t code = -1; char itemName[24] = {0}; char content[MAXLEN + 1] = {0}; @@ -165,13 +165,13 @@ int32_t dndReadShmFile(SDnode *pDnode) { } for (EDndNodeType ntype = NODE_BEGIN + 1; ntype < NODE_END; ++ntype) { - snprintf(itemName, sizeof(itemName), "%s_shmid", dndProcName(ntype)); + snprintf(itemName, sizeof(itemName), "%s_shmid", dmProcName(ntype)); cJSON *shmid = cJSON_GetObjectItem(root, itemName); if (shmid && shmid->type == cJSON_Number) { pDnode->wrappers[ntype].procShm.id = shmid->valueint; } - snprintf(itemName, sizeof(itemName), "%s_shmsize", dndProcName(ntype)); + snprintf(itemName, sizeof(itemName), "%s_shmsize", dmProcName(ntype)); cJSON *shmsize = cJSON_GetObjectItem(root, itemName); if (shmsize && shmsize->type == cJSON_Number) { pDnode->wrappers[ntype].procShm.size = shmsize->valueint; @@ -207,7 +207,7 @@ _OVER: return code; } -int32_t dndWriteShmFile(SDnode *pDnode) { +int32_t dmWriteShmFile(SDnode *pDnode) { int32_t code = -1; int32_t len = 0; char content[MAXLEN + 1] = {0}; @@ -228,12 +228,11 @@ int32_t dndWriteShmFile(SDnode *pDnode) { len += snprintf(content + len, MAXLEN - len, "{\n"); for (EDndNodeType ntype = NODE_BEGIN + 1; ntype < NODE_END; ++ntype) { SMgmtWrapper *pWrapper = &pDnode->wrappers[ntype]; - len += snprintf(content + len, MAXLEN - len, " \"%s_shmid\":%d,\n", dndProcName(ntype), pWrapper->procShm.id); + len += snprintf(content + len, MAXLEN - len, " \"%s_shmid\":%d,\n", dmProcName(ntype), pWrapper->procShm.id); if (ntype == NODE_END - 1) { - len += snprintf(content + len, MAXLEN - len, " \"%s_shmsize\":%d\n", dndProcName(ntype), pWrapper->procShm.size); + len += snprintf(content + len, MAXLEN - len, " \"%s_shmsize\":%d\n", dmProcName(ntype), pWrapper->procShm.size); } else { - len += - snprintf(content + len, MAXLEN - len, " \"%s_shmsize\":%d,\n", dndProcName(ntype), pWrapper->procShm.size); + len += snprintf(content + len, MAXLEN - len, " \"%s_shmsize\":%d,\n", dmProcName(ntype), pWrapper->procShm.size); } } len += snprintf(content + len, MAXLEN - len, "}\n"); diff --git a/source/dnode/mgmt/interface/src/dmInt.c b/source/dnode/mgmt/interface/src/dmInt.c index eab6c074b6..ad5b35a3f8 100644 --- a/source/dnode/mgmt/interface/src/dmInt.c +++ b/source/dnode/mgmt/interface/src/dmInt.c @@ -16,7 +16,7 @@ #define _DEFAULT_SOURCE #include "dmInt.h" -const char *dndStatName(EDndRunStatus status) { +const char *dmStatName(EDndRunStatus status) { switch (status) { case DND_STAT_INIT: return "init"; @@ -29,7 +29,7 @@ const char *dndStatName(EDndRunStatus status) { } } -const char *dndLogName(EDndNodeType ntype) { +const char *dmLogName(EDndNodeType ntype) { switch (ntype) { case VNODE: return "vnode"; @@ -46,7 +46,7 @@ const char *dndLogName(EDndNodeType ntype) { } } -const char *dndProcName(EDndNodeType ntype) { +const char *dmProcName(EDndNodeType ntype) { switch (ntype) { case VNODE: return "taosv"; @@ -63,7 +63,7 @@ const char *dndProcName(EDndNodeType ntype) { } } -const char *dndEventName(EDndEvent ev) { +const char *dmEventName(EDndEvent ev) { switch (ev) { case DND_EVENT_START: return "start"; @@ -76,27 +76,25 @@ const char *dndEventName(EDndEvent ev) { } } -EDndRunStatus dndGetStatus(SDnode *pDnode) { return pDnode->status; } - -void dndSetStatus(SDnode *pDnode, EDndRunStatus status) { +void dmSetStatus(SDnode *pDnode, EDndRunStatus status) { if (pDnode->status != status) { - dDebug("dnode status set from %s to %s", dndStatName(pDnode->status), dndStatName(status)); + dDebug("dnode status set from %s to %s", dmStatName(pDnode->status), dmStatName(status)); pDnode->status = status; } } -void dndSetEvent(SDnode *pDnode, EDndEvent event) { +void dmSetEvent(SDnode *pDnode, EDndEvent event) { if (event == DND_EVENT_STOP) { pDnode->event = event; } } -void dndSetMsgHandle(SMgmtWrapper *pWrapper, tmsg_t msgType, NodeMsgFp nodeMsgFp, int8_t vgId) { +void dmSetMsgHandle(SMgmtWrapper *pWrapper, tmsg_t msgType, NodeMsgFp nodeMsgFp, int8_t vgId) { pWrapper->msgFps[TMSG_INDEX(msgType)] = nodeMsgFp; pWrapper->msgVgIds[TMSG_INDEX(msgType)] = vgId; } -SMgmtWrapper *dndAcquireWrapper(SDnode *pDnode, EDndNodeType ntype) { +SMgmtWrapper *dmAcquireWrapper(SDnode *pDnode, EDndNodeType ntype) { SMgmtWrapper *pWrapper = &pDnode->wrappers[ntype]; SMgmtWrapper *pRetWrapper = pWrapper; @@ -113,7 +111,7 @@ SMgmtWrapper *dndAcquireWrapper(SDnode *pDnode, EDndNodeType ntype) { return pRetWrapper; } -int32_t dndMarkWrapper(SMgmtWrapper *pWrapper) { +int32_t dmMarkWrapper(SMgmtWrapper *pWrapper) { int32_t code = 0; taosRLockLatch(&pWrapper->latch); @@ -129,7 +127,7 @@ int32_t dndMarkWrapper(SMgmtWrapper *pWrapper) { return code; } -void dndReleaseWrapper(SMgmtWrapper *pWrapper) { +void dmReleaseWrapper(SMgmtWrapper *pWrapper) { if (pWrapper == NULL) return; taosRLockLatch(&pWrapper->latch); @@ -138,22 +136,22 @@ void dndReleaseWrapper(SMgmtWrapper *pWrapper) { dTrace("node:%s, is released, refCount:%d", pWrapper->name, refCount); } -void dndReportStartup(SDnode *pDnode, const char *pName, const char *pDesc) { +void dmReportStartup(SDnode *pDnode, const char *pName, const char *pDesc) { SStartupReq *pStartup = &pDnode->startup; tstrncpy(pStartup->name, pName, TSDB_STEP_NAME_LEN); tstrncpy(pStartup->desc, pDesc, TSDB_STEP_DESC_LEN); pStartup->finished = 0; } -static void dndGetStartup(SDnode *pDnode, SStartupReq *pStartup) { +static void dmGetStartup(SDnode *pDnode, SStartupReq *pStartup) { memcpy(pStartup, &pDnode->startup, sizeof(SStartupReq)); - pStartup->finished = (dndGetStatus(pDnode) == DND_STAT_RUNNING); + pStartup->finished = (pDnode->status == DND_STAT_RUNNING); } -void dndProcessStartupReq(SDnode *pDnode, SRpcMsg *pReq) { +void dmProcessStartupReq(SDnode *pDnode, SRpcMsg *pReq) { dDebug("startup req is received"); SStartupReq *pStartup = rpcMallocCont(sizeof(SStartupReq)); - dndGetStartup(pDnode, pStartup); + dmGetStartup(pDnode, pStartup); dDebug("startup req is sent, step:%s desc:%s finished:%d", pStartup->name, pStartup->desc, pStartup->finished); SRpcMsg rpcRsp = { @@ -161,7 +159,7 @@ void dndProcessStartupReq(SDnode *pDnode, SRpcMsg *pReq) { rpcSendResponse(&rpcRsp); } -void dndGetMonitorSysInfo(SMonSysInfo *pInfo) { +void dmGetMonitorSysInfo(SMonSysInfo *pInfo) { taosGetCpuUsage(&pInfo->cpu_engine, &pInfo->cpu_system); taosGetCpuCores(&pInfo->cpu_cores); taosGetProcMemory(&pInfo->mem_engine); diff --git a/source/dnode/mgmt/mgmt_bnode/src/bmHandle.c b/source/dnode/mgmt/mgmt_bnode/src/bmHandle.c index fef5670aa8..ac96a5fd91 100644 --- a/source/dnode/mgmt/mgmt_bnode/src/bmHandle.c +++ b/source/dnode/mgmt/mgmt_bnode/src/bmHandle.c @@ -21,7 +21,7 @@ void bmGetMonitorInfo(SMgmtWrapper *pWrapper, SMonBmInfo *bmInfo) {} int32_t bmProcessGetMonBmInfoReq(SMgmtWrapper *pWrapper, SNodeMsg *pReq) { SMonBmInfo bmInfo = {0}; bmGetMonitorInfo(pWrapper, &bmInfo); - dndGetMonitorSysInfo(&bmInfo.sys); + dmGetMonitorSysInfo(&bmInfo.sys); monGetLogs(&bmInfo.log); int32_t rspLen = tSerializeSMonBmInfo(NULL, 0, &bmInfo); @@ -58,7 +58,7 @@ int32_t bmProcessCreateReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { dError("failed to create bnode since %s, input:%d cur:%d", terrstr(), createReq.dnodeId, pDnode->data.dnodeId); return -1; } else { - // return dndOpenNode(pWrapper); + // return dmOpenNode(pWrapper); return 0; } } @@ -78,11 +78,11 @@ int32_t bmProcessDropReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { dError("failed to drop bnode since %s", terrstr()); return -1; } else { - // dndCloseNode(pWrapper); + // dmCloseNode(pWrapper); return bmDrop(pWrapper); } } void bmInitMsgHandle(SMgmtWrapper *pWrapper) { - dndSetMsgHandle(pWrapper, TDMT_MON_BM_INFO, bmProcessMonitorMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MON_BM_INFO, bmProcessMonitorMsg, DEFAULT_HANDLE); } diff --git a/source/dnode/mgmt/mgmt_bnode/src/bmInt.c b/source/dnode/mgmt/mgmt_bnode/src/bmInt.c index bca6e0432a..ec261d654c 100644 --- a/source/dnode/mgmt/mgmt_bnode/src/bmInt.c +++ b/source/dnode/mgmt/mgmt_bnode/src/bmInt.c @@ -16,7 +16,7 @@ #define _DEFAULT_SOURCE #include "bmInt.h" -static int32_t bmRequire(SMgmtWrapper *pWrapper, bool *required) { return dndReadFile(pWrapper, required); } +static int32_t bmRequire(SMgmtWrapper *pWrapper, bool *required) { return dmReadFile(pWrapper, required); } static void bmInitOption(SBnodeMgmt *pMgmt, SBnodeOpt *pOption) { SMsgCb msgCb = dmGetMsgcb(pMgmt->pWrapper); @@ -39,7 +39,7 @@ static int32_t bmOpenImp(SBnodeMgmt *pMgmt) { } bool deployed = true; - if (dndWriteFile(pMgmt->pWrapper, deployed) != 0) { + if (dmWriteFile(pMgmt->pWrapper, deployed) != 0) { dError("failed to write bnode file since %s", terrstr()); return -1; } @@ -61,7 +61,7 @@ int32_t bmDrop(SMgmtWrapper *pWrapper) { dInfo("bnode-mgmt start to drop"); bool deployed = false; - if (dndWriteFile(pWrapper, deployed) != 0) { + if (dmWriteFile(pWrapper, deployed) != 0) { dError("failed to drop bnode since %s", terrstr()); return -1; } diff --git a/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c b/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c index d98cadb295..5e277b6ed2 100644 --- a/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c +++ b/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c @@ -24,7 +24,7 @@ void mmGetMonitorInfo(SMgmtWrapper *pWrapper, SMonMmInfo *mmInfo) { int32_t mmProcessGetMonMmInfoReq(SMgmtWrapper *pWrapper, SNodeMsg *pReq) { SMonMmInfo mmInfo = {0}; mmGetMonitorInfo(pWrapper, &mmInfo); - dndGetMonitorSysInfo(&mmInfo.sys); + dmGetMonitorSysInfo(&mmInfo.sys); monGetLogs(&mmInfo.log); int32_t rspLen = tSerializeSMonMmInfo(NULL, 0, &mmInfo); @@ -80,7 +80,7 @@ int32_t mmProcessDropReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { dError("failed to drop mnode since %s", terrstr()); return -1; } else { - // dndCloseNode(pWrapper); + // dmCloseNode(pWrapper); return mmDrop(pWrapper); } } @@ -105,96 +105,96 @@ int32_t mmProcessAlterReq(SMnodeMgmt *pMgmt, SNodeMsg *pMsg) { } void mmInitMsgHandle(SMgmtWrapper *pWrapper) { - dndSetMsgHandle(pWrapper, TDMT_MON_MM_INFO, mmProcessMonitorMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MON_MM_INFO, mmProcessMonitorMsg, DEFAULT_HANDLE); // Requests handled by DNODE - dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_MNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_DND_ALTER_MNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_DND_DROP_MNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_QNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_DND_DROP_QNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_SNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_DND_DROP_SNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_BNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_DND_DROP_BNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_VNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_DND_ALTER_VNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_DND_DROP_VNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_DND_SYNC_VNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_DND_COMPACT_VNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_DND_CONFIG_DNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_DND_CREATE_MNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_DND_ALTER_MNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_DND_DROP_MNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_DND_CREATE_QNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_DND_DROP_QNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_DND_CREATE_SNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_DND_DROP_SNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_DND_CREATE_BNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_DND_DROP_BNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_DND_CREATE_VNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_DND_ALTER_VNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_DND_DROP_VNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_DND_SYNC_VNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_DND_COMPACT_VNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_DND_CONFIG_DNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE); // Requests handled by MNODE - dndSetMsgHandle(pWrapper, TDMT_MND_CONNECT, mmProcessReadMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_ACCT, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_ACCT, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_DROP_ACCT, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_USER, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_USER, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_DROP_USER, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_GET_USER_AUTH, mmProcessReadMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_DNODE, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_CONFIG_DNODE, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_DROP_DNODE, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_MNODE, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_DROP_MNODE, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_QNODE, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_DROP_QNODE, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_SNODE, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_DROP_SNODE, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_BNODE, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_DROP_BNODE, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_DB, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_DROP_DB, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_USE_DB, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_DB, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_SYNC_DB, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_COMPACT_DB, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_FUNC, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_RETRIEVE_FUNC, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_DROP_FUNC, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_STB, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_STB, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_DROP_STB, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_SMA, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_DROP_SMA, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_TABLE_META, mmProcessReadMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_VGROUP_LIST, mmProcessReadMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_KILL_QUERY, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_KILL_CONN, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_HEARTBEAT, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_SHOW, mmProcessReadMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_SHOW_RETRIEVE, mmProcessReadMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_SYSTABLE_RETRIEVE, mmProcessReadMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_STATUS, mmProcessReadMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_KILL_TRANS, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_GRANT, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_AUTH, mmProcessReadMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_DND_ALTER_MNODE, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_TOPIC, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_TOPIC, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_DROP_TOPIC, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_SUBSCRIBE, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_MQ_COMMIT_OFFSET, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_GET_SUB_EP, mmProcessReadMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_STREAM, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_TASK_DEPLOY_RSP, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_GET_DB_CFG, mmProcessReadMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MND_GET_INDEX, mmProcessReadMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_CONNECT, mmProcessReadMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_CREATE_ACCT, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_ALTER_ACCT, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_DROP_ACCT, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_CREATE_USER, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_ALTER_USER, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_DROP_USER, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_GET_USER_AUTH, mmProcessReadMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_CREATE_DNODE, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_CONFIG_DNODE, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_DROP_DNODE, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_CREATE_MNODE, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_DROP_MNODE, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_CREATE_QNODE, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_DROP_QNODE, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_CREATE_SNODE, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_DROP_SNODE, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_CREATE_BNODE, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_DROP_BNODE, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_CREATE_DB, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_DROP_DB, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_USE_DB, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_ALTER_DB, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_SYNC_DB, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_COMPACT_DB, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_CREATE_FUNC, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_RETRIEVE_FUNC, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_DROP_FUNC, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_CREATE_STB, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_ALTER_STB, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_DROP_STB, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_CREATE_SMA, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_DROP_SMA, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_TABLE_META, mmProcessReadMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_VGROUP_LIST, mmProcessReadMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_KILL_QUERY, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_KILL_CONN, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_HEARTBEAT, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_SHOW, mmProcessReadMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_SHOW_RETRIEVE, mmProcessReadMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_SYSTABLE_RETRIEVE, mmProcessReadMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_STATUS, mmProcessReadMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_KILL_TRANS, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_GRANT, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_AUTH, mmProcessReadMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_DND_ALTER_MNODE, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_CREATE_TOPIC, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_ALTER_TOPIC, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_DROP_TOPIC, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_SUBSCRIBE, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_MQ_COMMIT_OFFSET, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_GET_SUB_EP, mmProcessReadMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_CREATE_STREAM, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_TASK_DEPLOY_RSP, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_GET_DB_CFG, mmProcessReadMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MND_GET_INDEX, mmProcessReadMsg, DEFAULT_HANDLE); // Requests handled by VNODE - dndSetMsgHandle(pWrapper, TDMT_VND_MQ_SET_CONN_RSP, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_MQ_REB_RSP, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_MQ_CANCEL_CONN_RSP, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_CREATE_STB_RSP, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_ALTER_STB_RSP, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_DROP_STB_RSP, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_CREATE_SMA_RSP, mmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_DROP_SMA_RSP, mmProcessWriteMsg, DEFAULT_HANDLE); - - dndSetMsgHandle(pWrapper, TDMT_VND_QUERY, mmProcessQueryMsg, MNODE_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_QUERY_CONTINUE, mmProcessQueryMsg, MNODE_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_FETCH, mmProcessQueryMsg, MNODE_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_DROP_TASK, mmProcessQueryMsg, MNODE_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_QUERY_HEARTBEAT, mmProcessQueryMsg, MNODE_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_MQ_SET_CONN_RSP, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_MQ_REB_RSP, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_MQ_CANCEL_CONN_RSP, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_CREATE_STB_RSP, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_ALTER_STB_RSP, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_DROP_STB_RSP, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_CREATE_SMA_RSP, mmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_DROP_SMA_RSP, mmProcessWriteMsg, DEFAULT_HANDLE); + + dmSetMsgHandle(pWrapper, TDMT_VND_QUERY, mmProcessQueryMsg, MNODE_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_QUERY_CONTINUE, mmProcessQueryMsg, MNODE_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_FETCH, mmProcessQueryMsg, MNODE_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_DROP_TASK, mmProcessQueryMsg, MNODE_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_QUERY_HEARTBEAT, mmProcessQueryMsg, MNODE_HANDLE); } diff --git a/source/dnode/mgmt/mgmt_qnode/src/qmHandle.c b/source/dnode/mgmt/mgmt_qnode/src/qmHandle.c index 935c6b2093..209c0b3f6c 100644 --- a/source/dnode/mgmt/mgmt_qnode/src/qmHandle.c +++ b/source/dnode/mgmt/mgmt_qnode/src/qmHandle.c @@ -21,7 +21,7 @@ void qmGetMonitorInfo(SMgmtWrapper *pWrapper, SMonQmInfo *qmInfo) {} int32_t qmProcessGetMonQmInfoReq(SMgmtWrapper *pWrapper, SNodeMsg *pReq) { SMonQmInfo qmInfo = {0}; qmGetMonitorInfo(pWrapper, &qmInfo); - dndGetMonitorSysInfo(&qmInfo.sys); + dmGetMonitorSysInfo(&qmInfo.sys); monGetLogs(&qmInfo.log); int32_t rspLen = tSerializeSMonQmInfo(NULL, 0, &qmInfo); @@ -58,7 +58,7 @@ int32_t qmProcessCreateReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { dError("failed to create qnode since %s", terrstr()); return -1; } else { - // return dndOpenNode(pWrapper); + // return dmOpenNode(pWrapper); return 0; } } @@ -78,23 +78,23 @@ int32_t qmProcessDropReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { dError("failed to drop qnode since %s", terrstr()); return -1; } else { - // dndCloseNode(pWrapper); + // dmCloseNode(pWrapper); return qmDrop(pWrapper); } } void qmInitMsgHandle(SMgmtWrapper *pWrapper) { - dndSetMsgHandle(pWrapper, TDMT_MON_QM_INFO, qmProcessMonitorMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MON_QM_INFO, qmProcessMonitorMsg, DEFAULT_HANDLE); // Requests handled by VNODE - dndSetMsgHandle(pWrapper, TDMT_VND_QUERY, qmProcessQueryMsg, QNODE_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_QUERY_CONTINUE, qmProcessQueryMsg, QNODE_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_FETCH, qmProcessFetchMsg, QNODE_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_FETCH_RSP, qmProcessFetchMsg, QNODE_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_QUERY, qmProcessQueryMsg, QNODE_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_QUERY_CONTINUE, qmProcessQueryMsg, QNODE_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_FETCH, qmProcessFetchMsg, QNODE_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_FETCH_RSP, qmProcessFetchMsg, QNODE_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_RES_READY, qmProcessFetchMsg, QNODE_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_TASKS_STATUS, qmProcessFetchMsg, QNODE_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_CANCEL_TASK, qmProcessFetchMsg, QNODE_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_DROP_TASK, qmProcessFetchMsg, QNODE_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_SHOW_TABLES, qmProcessFetchMsg, QNODE_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_RES_READY, qmProcessFetchMsg, QNODE_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_TASKS_STATUS, qmProcessFetchMsg, QNODE_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_CANCEL_TASK, qmProcessFetchMsg, QNODE_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_DROP_TASK, qmProcessFetchMsg, QNODE_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_SHOW_TABLES, qmProcessFetchMsg, QNODE_HANDLE); } diff --git a/source/dnode/mgmt/mgmt_qnode/src/qmInt.c b/source/dnode/mgmt/mgmt_qnode/src/qmInt.c index d211faaa35..76c4f2af0d 100644 --- a/source/dnode/mgmt/mgmt_qnode/src/qmInt.c +++ b/source/dnode/mgmt/mgmt_qnode/src/qmInt.c @@ -16,7 +16,7 @@ #define _DEFAULT_SOURCE #include "qmInt.h" -static int32_t qmRequire(SMgmtWrapper *pWrapper, bool *required) { return dndReadFile(pWrapper, required); } +static int32_t qmRequire(SMgmtWrapper *pWrapper, bool *required) { return dmReadFile(pWrapper, required); } static void qmInitOption(SQnodeMgmt *pMgmt, SQnodeOpt *pOption) { SMsgCb msgCb = dmGetMsgcb(pMgmt->pWrapper); @@ -42,7 +42,7 @@ static int32_t qmOpenImp(SQnodeMgmt *pMgmt) { } bool deployed = true; - if (dndWriteFile(pMgmt->pWrapper, deployed) != 0) { + if (dmWriteFile(pMgmt->pWrapper, deployed) != 0) { dError("failed to write qnode file since %s", terrstr()); return -1; } @@ -64,7 +64,7 @@ int32_t qmDrop(SMgmtWrapper *pWrapper) { dInfo("qnode-mgmt start to drop"); bool deployed = false; - if (dndWriteFile(pWrapper, deployed) != 0) { + if (dmWriteFile(pWrapper, deployed) != 0) { dError("failed to drop qnode since %s", terrstr()); return -1; } diff --git a/source/dnode/mgmt/mgmt_snode/src/smHandle.c b/source/dnode/mgmt/mgmt_snode/src/smHandle.c index cd8153fd60..4c0e0aef8d 100644 --- a/source/dnode/mgmt/mgmt_snode/src/smHandle.c +++ b/source/dnode/mgmt/mgmt_snode/src/smHandle.c @@ -21,7 +21,7 @@ void smGetMonitorInfo(SMgmtWrapper *pWrapper, SMonSmInfo *smInfo) {} int32_t smProcessGetMonSmInfoReq(SMgmtWrapper *pWrapper, SNodeMsg *pReq) { SMonSmInfo smInfo = {0}; smGetMonitorInfo(pWrapper, &smInfo); - dndGetMonitorSysInfo(&smInfo.sys); + dmGetMonitorSysInfo(&smInfo.sys); monGetLogs(&smInfo.log); int32_t rspLen = tSerializeSMonSmInfo(NULL, 0, &smInfo); @@ -58,7 +58,7 @@ int32_t smProcessCreateReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { dError("failed to create snode since %s", terrstr()); return -1; } else { - // return dndOpenNode(pWrapper); + // return dmOpenNode(pWrapper); return 0; } } @@ -79,14 +79,14 @@ int32_t smProcessDropReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { return -1; } else { return smDrop(pWrapper); - // return dndCloseNode(pWrapper); + // return dmCloseNode(pWrapper); } } void smInitMsgHandle(SMgmtWrapper *pWrapper) { - dndSetMsgHandle(pWrapper, TDMT_MON_SM_INFO, smProcessMonitorMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MON_SM_INFO, smProcessMonitorMsg, DEFAULT_HANDLE); // Requests handled by SNODE - dndSetMsgHandle(pWrapper, TDMT_SND_TASK_DEPLOY, smProcessMgmtMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_SND_TASK_EXEC, smProcessExecMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_SND_TASK_DEPLOY, smProcessMgmtMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_SND_TASK_EXEC, smProcessExecMsg, DEFAULT_HANDLE); } diff --git a/source/dnode/mgmt/mgmt_snode/src/smInt.c b/source/dnode/mgmt/mgmt_snode/src/smInt.c index 7d3bfd6ab2..911c1b6f70 100644 --- a/source/dnode/mgmt/mgmt_snode/src/smInt.c +++ b/source/dnode/mgmt/mgmt_snode/src/smInt.c @@ -16,7 +16,7 @@ #define _DEFAULT_SOURCE #include "smInt.h" -static int32_t smRequire(SMgmtWrapper *pWrapper, bool *required) { return dndReadFile(pWrapper, required); } +static int32_t smRequire(SMgmtWrapper *pWrapper, bool *required) { return dmReadFile(pWrapper, required); } static void smInitOption(SSnodeMgmt *pMgmt, SSnodeOpt *pOption) { SMsgCb msgCb = dmGetMsgcb(pMgmt->pWrapper); @@ -39,7 +39,7 @@ static int32_t smOpenImp(SSnodeMgmt *pMgmt) { } bool deployed = true; - if (dndWriteFile(pMgmt->pWrapper, deployed) != 0) { + if (dmWriteFile(pMgmt->pWrapper, deployed) != 0) { dError("failed to write snode file since %s", terrstr()); return -1; } @@ -61,7 +61,7 @@ int32_t smDrop(SMgmtWrapper *pWrapper) { dInfo("snode-mgmt start to drop"); bool deployed = false; - if (dndWriteFile(pWrapper, deployed) != 0) { + if (dmWriteFile(pWrapper, deployed) != 0) { dError("failed to drop snode since %s", terrstr()); return -1; } diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c index 813bc9c5f7..dfe79c2dde 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c @@ -36,7 +36,7 @@ void vmGetMonitorInfo(SMgmtWrapper *pWrapper, SMonVmInfo *vmInfo) { int32_t vmProcessGetMonVmInfoReq(SMgmtWrapper *pWrapper, SNodeMsg *pReq) { SMonVmInfo vmInfo = {0}; vmGetMonitorInfo(pWrapper, &vmInfo); - dndGetMonitorSysInfo(&vmInfo.sys); + dmGetMonitorSysInfo(&vmInfo.sys); monGetLogs(&vmInfo.log); int32_t rspLen = tSerializeSMonVmInfo(NULL, 0, &vmInfo); @@ -304,54 +304,54 @@ int32_t vmProcessCompactVnodeReq(SVnodesMgmt *pMgmt, SNodeMsg *pMsg) { } void vmInitMsgHandle(SMgmtWrapper *pWrapper) { - dndSetMsgHandle(pWrapper, TDMT_MON_VM_INFO, vmProcessMonitorMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_MON_VM_LOAD, vmProcessMonitorMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MON_VM_INFO, vmProcessMonitorMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_MON_VM_LOAD, vmProcessMonitorMsg, DEFAULT_HANDLE); // Requests handled by VNODE - dndSetMsgHandle(pWrapper, TDMT_VND_SUBMIT, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_QUERY, (NodeMsgFp)vmProcessQueryMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_QUERY_CONTINUE, (NodeMsgFp)vmProcessQueryMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_FETCH, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_FETCH_RSP, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_ALTER_TABLE, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_UPDATE_TAG_VAL, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_TABLE_META, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_TABLES_META, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_MQ_CONSUME, (NodeMsgFp)vmProcessQueryMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_MQ_QUERY, (NodeMsgFp)vmProcessQueryMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_MQ_CONNECT, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_MQ_DISCONNECT, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_MQ_SET_CUR, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_RES_READY, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_TASKS_STATUS, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_CANCEL_TASK, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_DROP_TASK, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_CREATE_STB, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_ALTER_STB, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_DROP_STB, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_CREATE_TABLE, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_ALTER_TABLE, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_DROP_TABLE, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_CREATE_SMA, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_CANCEL_SMA, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_DROP_SMA, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_SHOW_TABLES, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_SHOW_TABLES_FETCH, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_MQ_SET_CONN, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_MQ_REB, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_MQ_CANCEL_CONN, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_MQ_SET_CUR, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_CONSUME, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_TASK_DEPLOY, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_QUERY_HEARTBEAT, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_TASK_PIPE_EXEC, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_TASK_MERGE_EXEC, (NodeMsgFp)vmProcessMergeMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_TASK_WRITE_EXEC, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_VND_STREAM_TRIGGER, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE); - - dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_VNODE, vmProcessMgmtMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_DND_ALTER_VNODE, vmProcessMgmtMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_DND_DROP_VNODE, vmProcessMgmtMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_DND_SYNC_VNODE, vmProcessMgmtMsg, DEFAULT_HANDLE); - dndSetMsgHandle(pWrapper, TDMT_DND_COMPACT_VNODE, vmProcessMgmtMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_SUBMIT, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_QUERY, (NodeMsgFp)vmProcessQueryMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_QUERY_CONTINUE, (NodeMsgFp)vmProcessQueryMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_FETCH, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_FETCH_RSP, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_ALTER_TABLE, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_UPDATE_TAG_VAL, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_TABLE_META, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_TABLES_META, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_MQ_CONSUME, (NodeMsgFp)vmProcessQueryMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_MQ_QUERY, (NodeMsgFp)vmProcessQueryMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_MQ_CONNECT, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_MQ_DISCONNECT, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_MQ_SET_CUR, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_RES_READY, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_TASKS_STATUS, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_CANCEL_TASK, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_DROP_TASK, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_CREATE_STB, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_ALTER_STB, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_DROP_STB, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_CREATE_TABLE, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_ALTER_TABLE, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_DROP_TABLE, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_CREATE_SMA, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_CANCEL_SMA, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_DROP_SMA, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_SHOW_TABLES, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_SHOW_TABLES_FETCH, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_MQ_SET_CONN, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_MQ_REB, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_MQ_CANCEL_CONN, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_MQ_SET_CUR, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_CONSUME, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_TASK_DEPLOY, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_QUERY_HEARTBEAT, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_TASK_PIPE_EXEC, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_TASK_MERGE_EXEC, (NodeMsgFp)vmProcessMergeMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_TASK_WRITE_EXEC, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_VND_STREAM_TRIGGER, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE); + + dmSetMsgHandle(pWrapper, TDMT_DND_CREATE_VNODE, vmProcessMgmtMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_DND_ALTER_VNODE, vmProcessMgmtMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_DND_DROP_VNODE, vmProcessMgmtMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_DND_SYNC_VNODE, vmProcessMgmtMsg, DEFAULT_HANDLE); + dmSetMsgHandle(pWrapper, TDMT_DND_COMPACT_VNODE, vmProcessMgmtMsg, DEFAULT_HANDLE); } diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmInt.c b/source/dnode/mgmt/mgmt_vnode/src/vmInt.c index 94a6910ba3..d70377e9ad 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmInt.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmInt.c @@ -126,7 +126,7 @@ static void *vmOpenVnodeFunc(void *param) { char stepDesc[TSDB_STEP_DESC_LEN] = {0}; snprintf(stepDesc, TSDB_STEP_DESC_LEN, "vgId:%d, start to restore, %d of %d have been opened", pCfg->vgId, pMgmt->state.openVnodes, pMgmt->state.totalVnodes); - dndReportStartup(pDnode, "open-vnodes", stepDesc); + dmReportStartup(pDnode, "open-vnodes", stepDesc); SMsgCb msgCb = dmGetMsgcb(pMgmt->pWrapper); msgCb.pWrapper = pMgmt->pWrapper; diff --git a/source/dnode/mgmt/test/sut/src/server.cpp b/source/dnode/mgmt/test/sut/src/server.cpp index 332dc9327c..91db59757b 100644 --- a/source/dnode/mgmt/test/sut/src/server.cpp +++ b/source/dnode/mgmt/test/sut/src/server.cpp @@ -17,7 +17,7 @@ void* serverLoop(void* param) { SDnode* pDnode = (SDnode*)param; - dndRun(pDnode); + dmRun(pDnode); return NULL; } @@ -36,7 +36,7 @@ bool TestServer::DoStart() { SDnodeOpt option = BuildOption(path, fqdn, port, firstEp); taosMkDir(path); - pDnode = dndCreate(&option); + pDnode = dmCreate(&option); if (pDnode == NULL) { return false; } @@ -68,11 +68,11 @@ bool TestServer::Start(const char* path, const char* fqdn, uint16_t port, const } void TestServer::Stop() { - dndSetEvent(pDnode, DND_EVENT_STOP); + dmSetEvent(pDnode, DND_EVENT_STOP); taosThreadJoin(threadId, NULL); if (pDnode != NULL) { - dndClose(pDnode); + dmClose(pDnode); pDnode = NULL; } } diff --git a/source/dnode/mgmt/test/sut/src/sut.cpp b/source/dnode/mgmt/test/sut/src/sut.cpp index 14197153b4..8427df3e79 100644 --- a/source/dnode/mgmt/test/sut/src/sut.cpp +++ b/source/dnode/mgmt/test/sut/src/sut.cpp @@ -40,7 +40,7 @@ void Testbase::InitLog(const char* path) { } void Testbase::Init(const char* path, int16_t port) { - dndInit(); + dmInit(); char fqdn[] = "localhost"; char firstEp[TSDB_EP_LEN] = {0}; @@ -62,7 +62,7 @@ void Testbase::Cleanup() { client.Cleanup(); taosMsleep(10); server.Stop(); - dndCleanup(); + dmCleanup(); } void Testbase::Restart() { -- GitLab