From e770a6e974753f7160054697a8fe89250728ad59 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Wed, 13 Apr 2022 16:23:03 +0800 Subject: [PATCH] refact(cluster): node mgmt --- source/common/src/tglobal.c | 8 ++++---- source/dnode/mgmt/CMakeLists.txt | 9 ++++++++- source/dnode/mgmt/exe/CMakeLists.txt | 7 ------- source/dnode/mgmt/implement/src/dmEps.c | 2 +- source/dnode/mgmt/implement/src/dmExec.c | 2 -- source/dnode/mgmt/implement/src/dmHandle.c | 8 ++++---- source/dnode/mgmt/interface/src/dmFile.c | 4 ++-- source/dnode/mgmt/mgmt_bnode/src/bmInt.c | 3 ++- source/dnode/mgmt/mgmt_mnode/src/mmFile.c | 2 +- source/dnode/mgmt/mgmt_mnode/src/mmInt.c | 1 + source/dnode/mgmt/mgmt_qnode/src/qmInt.c | 1 + source/dnode/mgmt/mgmt_snode/src/smInt.c | 1 + 12 files changed, 25 insertions(+), 23 deletions(-) delete mode 100644 source/dnode/mgmt/exe/CMakeLists.txt diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index 58bc7235a1..2ab8af31b1 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -189,7 +189,7 @@ static int32_t taosSetTfsCfg(SConfig *pCfg) { tsDiskCfgNum = 1; taosAddDataDir(0, pItem->str, 0, 1); tstrncpy(tsDataDir, pItem->str, PATH_MAX); - if (taosMkDir(tsDataDir) != 0) { + if (taosMulMkDir(tsDataDir) != 0) { uError("failed to create dataDir:%s since %s", tsDataDir, terrstr()); return -1; } @@ -200,12 +200,12 @@ static int32_t taosSetTfsCfg(SConfig *pCfg) { memcpy(&tsDiskCfg[index], pCfg, sizeof(SDiskCfg)); if (pCfg->level == 0 && pCfg->primary == 1) { tstrncpy(tsDataDir, pCfg->dir, PATH_MAX); - if (taosMkDir(tsDataDir) != 0) { + if (taosMulMkDir(tsDataDir) != 0) { uError("failed to create dataDir:%s since %s", tsDataDir, terrstr()); return -1; } } - if (taosMkDir(pCfg->dir) != 0) { + if (taosMulMkDir(pCfg->dir) != 0) { uError("failed to create tfsDir:%s since %s", tsDataDir, terrstr()); return -1; } @@ -486,7 +486,7 @@ static int32_t taosSetClientCfg(SConfig *pCfg) { tstrncpy(tsTempDir, cfgGetItem(pCfg, "tempDir")->str, PATH_MAX); taosExpandDir(tsTempDir, tsTempDir, PATH_MAX); tsTempSpace.reserved = cfgGetItem(pCfg, "minimalTempDirGB")->fval; - if (taosMkDir(tsTempDir) != 0) { + if (taosMulMkDir(tsTempDir) != 0) { uError("failed to create tempDir:%s since %s", tsTempDir, terrstr()); return -1; } diff --git a/source/dnode/mgmt/CMakeLists.txt b/source/dnode/mgmt/CMakeLists.txt index 52761ab646..49ea54e928 100644 --- a/source/dnode/mgmt/CMakeLists.txt +++ b/source/dnode/mgmt/CMakeLists.txt @@ -1,4 +1,3 @@ -add_subdirectory(exe) add_subdirectory(interface) add_subdirectory(implement) add_subdirectory(mgmt_bnode) @@ -7,3 +6,11 @@ add_subdirectory(mgmt_qnode) add_subdirectory(mgmt_snode) add_subdirectory(mgmt_vnode) add_subdirectory(test) + +aux_source_directory(exe EXEC_SRC) +add_executable(taosd ${EXEC_SRC}) +target_include_directories( + taosd + PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/implement/inc" +) +target_link_libraries(taosd dnode) diff --git a/source/dnode/mgmt/exe/CMakeLists.txt b/source/dnode/mgmt/exe/CMakeLists.txt deleted file mode 100644 index 931a07d261..0000000000 --- a/source/dnode/mgmt/exe/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -aux_source_directory(. EXEC_SRC) -add_executable(taosd ${EXEC_SRC}) -target_include_directories( - taosd - PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../implement/inc" -) -target_link_libraries(taosd dnode) diff --git a/source/dnode/mgmt/implement/src/dmEps.c b/source/dnode/mgmt/implement/src/dmEps.c index 5dcdccfa4e..e4ff536b5f 100644 --- a/source/dnode/mgmt/implement/src/dmEps.c +++ b/source/dnode/mgmt/implement/src/dmEps.c @@ -57,7 +57,7 @@ int32_t dmReadEps(SDnode *pDnode) { 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); + // dDebug("file %s not exist", file); code = 0; goto PRASE_DNODE_OVER; } diff --git a/source/dnode/mgmt/implement/src/dmExec.c b/source/dnode/mgmt/implement/src/dmExec.c index 354e2372a4..ad8653edd6 100644 --- a/source/dnode/mgmt/implement/src/dmExec.c +++ b/source/dnode/mgmt/implement/src/dmExec.c @@ -21,8 +21,6 @@ static bool dmRequireNode(SMgmtWrapper *pWrapper) { int32_t code = (*pWrapper->fp.requiredFp)(pWrapper, &required); if (!required) { dDebug("node:%s, does not require startup", pWrapper->name); - } else { - dDebug("node:%s, needs to be started", pWrapper->name); } return required; } diff --git a/source/dnode/mgmt/implement/src/dmHandle.c b/source/dnode/mgmt/implement/src/dmHandle.c index 1b0abd8c09..b5c81850ef 100644 --- a/source/dnode/mgmt/implement/src/dmHandle.c +++ b/source/dnode/mgmt/implement/src/dmHandle.c @@ -199,7 +199,7 @@ static void dmStopMgmt(SMgmtWrapper *pWrapper) { } static int32_t dmInitMgmt(SMgmtWrapper *pWrapper) { - dInfo("dnode-data start to init"); + dInfo("dnode-mgmt start to init"); SDnode *pDnode = pWrapper->pDnode; pDnode->data.dnodeHash = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK); @@ -228,12 +228,12 @@ static int32_t dmInitMgmt(SMgmtWrapper *pWrapper) { return -1; } - dInfo("dnode-data is initialized"); + dInfo("dnode-mgmt is initialized"); return 0; } static void dmCleanupMgmt(SMgmtWrapper *pWrapper) { - dInfo("dnode-data start to clean up"); + dInfo("dnode-mgmt start to clean up"); SDnode *pDnode = pWrapper->pDnode; dmStopWorker(pDnode); @@ -249,7 +249,7 @@ static void dmCleanupMgmt(SMgmtWrapper *pWrapper) { taosWUnLockLatch(&pDnode->data.latch); dmCleanupTrans(pDnode); - dInfo("dnode-data is cleaned up"); + dInfo("dnode-mgmt is cleaned up"); } static int32_t dmRequireMgmt(SMgmtWrapper *pWrapper, bool *required) { diff --git a/source/dnode/mgmt/interface/src/dmFile.c b/source/dnode/mgmt/interface/src/dmFile.c index 3256b8b4b0..e9117939d7 100644 --- a/source/dnode/mgmt/interface/src/dmFile.c +++ b/source/dnode/mgmt/interface/src/dmFile.c @@ -29,7 +29,7 @@ int32_t dmReadFile(SMgmtWrapper *pWrapper, bool *pDeployed) { snprintf(file, sizeof(file), "%s%s%s.json", pWrapper->path, TD_DIRSEP, pWrapper->name); pFile = taosOpenFile(file, TD_FILE_READ); if (pFile == NULL) { - dDebug("file %s not exist", file); + // dDebug("file %s not exist", file); code = 0; goto _OVER; } @@ -150,7 +150,7 @@ int32_t dmReadShmFile(SMgmtWrapper *pWrapper) { snprintf(file, sizeof(file), "%s%sshmfile", pWrapper->path, TD_DIRSEP); pFile = taosOpenFile(file, TD_FILE_READ); if (pFile == NULL) { - dDebug("node:%s, file %s not exist", pWrapper->name, file); + // dDebug("node:%s, file %s not exist", pWrapper->name, file); code = 0; goto _OVER; } diff --git a/source/dnode/mgmt/mgmt_bnode/src/bmInt.c b/source/dnode/mgmt/mgmt_bnode/src/bmInt.c index 72a7f2cc86..860c5d465c 100644 --- a/source/dnode/mgmt/mgmt_bnode/src/bmInt.c +++ b/source/dnode/mgmt/mgmt_bnode/src/bmInt.c @@ -19,7 +19,8 @@ static int32_t bmRequire(SMgmtWrapper *pWrapper, bool *required) { return dmReadFile(pWrapper, required); } static void bmInitOption(SBnodeMgmt *pMgmt, SBnodeOpt *pOption) { - SMsgCb msgCb = pMgmt->pDnode->data.msgCb;; + SMsgCb msgCb = pMgmt->pDnode->data.msgCb; + msgCb.pWrapper = pMgmt->pWrapper; pOption->msgCb = msgCb; } diff --git a/source/dnode/mgmt/mgmt_mnode/src/mmFile.c b/source/dnode/mgmt/mgmt_mnode/src/mmFile.c index 44027780de..f3d0d666bb 100644 --- a/source/dnode/mgmt/mgmt_mnode/src/mmFile.c +++ b/source/dnode/mgmt/mgmt_mnode/src/mmFile.c @@ -28,7 +28,7 @@ int32_t mmReadFile(SMnodeMgmt *pMgmt, bool *pDeployed) { snprintf(file, sizeof(file), "%s%smnode.json", pMgmt->path, TD_DIRSEP); pFile = taosOpenFile(file, TD_FILE_READ); if (pFile == NULL) { - dDebug("file %s not exist", file); + // dDebug("file %s not exist", file); code = 0; goto PRASE_MNODE_OVER; } diff --git a/source/dnode/mgmt/mgmt_mnode/src/mmInt.c b/source/dnode/mgmt/mgmt_mnode/src/mmInt.c index 9e83c317ea..ce0459686c 100644 --- a/source/dnode/mgmt/mgmt_mnode/src/mmInt.c +++ b/source/dnode/mgmt/mgmt_mnode/src/mmInt.c @@ -40,6 +40,7 @@ static int32_t mmRequire(SMgmtWrapper *pWrapper, bool *required) { static void mmInitOption(SMnodeMgmt *pMgmt, SMnodeOpt *pOption) { SMsgCb msgCb = pMgmt->pDnode->data.msgCb; + msgCb.pWrapper = pMgmt->pWrapper; msgCb.queueFps[QUERY_QUEUE] = mmPutMsgToQueryQueue; msgCb.queueFps[READ_QUEUE] = mmPutMsgToReadQueue; msgCb.queueFps[WRITE_QUEUE] = mmPutMsgToWriteQueue; diff --git a/source/dnode/mgmt/mgmt_qnode/src/qmInt.c b/source/dnode/mgmt/mgmt_qnode/src/qmInt.c index 53d4cefbff..c73d337136 100644 --- a/source/dnode/mgmt/mgmt_qnode/src/qmInt.c +++ b/source/dnode/mgmt/mgmt_qnode/src/qmInt.c @@ -20,6 +20,7 @@ static int32_t qmRequire(SMgmtWrapper *pWrapper, bool *required) { return dmRead static void qmInitOption(SQnodeMgmt *pMgmt, SQnodeOpt *pOption) { SMsgCb msgCb = pMgmt->pDnode->data.msgCb; + msgCb.pWrapper = pMgmt->pWrapper; msgCb.queueFps[QUERY_QUEUE] = qmPutMsgToQueryQueue; msgCb.queueFps[FETCH_QUEUE] = qmPutMsgToFetchQueue; msgCb.qsizeFp = qmGetQueueSize; diff --git a/source/dnode/mgmt/mgmt_snode/src/smInt.c b/source/dnode/mgmt/mgmt_snode/src/smInt.c index ad7909a8f7..3b17d775f7 100644 --- a/source/dnode/mgmt/mgmt_snode/src/smInt.c +++ b/source/dnode/mgmt/mgmt_snode/src/smInt.c @@ -20,6 +20,7 @@ static int32_t smRequire(SMgmtWrapper *pWrapper, bool *required) { return dmRead static void smInitOption(SSnodeMgmt *pMgmt, SSnodeOpt *pOption) { SMsgCb msgCb = pMgmt->pDnode->data.msgCb; + msgCb.pWrapper = pMgmt->pWrapper; pOption->msgCb = msgCb; }