diff --git a/source/dnode/mgmt/CMakeLists.txt b/source/dnode/mgmt/CMakeLists.txt index 40c3f5b1d3d2c6a92066e6d41f71fe2feb690c55..d36a9b8de79e2b368a5a45553f5745f1480851d1 100644 --- a/source/dnode/mgmt/CMakeLists.txt +++ b/source/dnode/mgmt/CMakeLists.txt @@ -6,7 +6,7 @@ aux_source_directory(bm DNODE_SRC) aux_source_directory(sm DNODE_SRC) aux_source_directory(vm DNODE_SRC) aux_source_directory(mm DNODE_SRC) -aux_source_directory(main DNODE_SRC) +aux_source_directory(implement/src DNODE_SRC) add_library(dnode STATIC ${DNODE_SRC}) target_link_libraries( dnode dnode_interface @@ -15,14 +15,15 @@ target_include_directories( dnode PUBLIC "${TD_SOURCE_DIR}/include/dnode/mgmt" PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" - PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/interface/inc" + PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/implement/inc" ) aux_source_directory(exe EXEC_SRC) add_executable(taosd ${EXEC_SRC}) target_include_directories( taosd - PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/interface/inc" + PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" + PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/implement/inc" ) target_link_libraries(taosd dnode) diff --git a/source/dnode/mgmt/exe/dndMain.c b/source/dnode/mgmt/exe/dndMain.c index 3779f94620118f8dcb8dd592dc55bf1432659407..20a73fd893cbbc29402840da4bf014911d7d2982 100644 --- a/source/dnode/mgmt/exe/dndMain.c +++ b/source/dnode/mgmt/exe/dndMain.c @@ -14,7 +14,7 @@ */ #define _DEFAULT_SOURCE -#include "dndInt.h" +#include "dndNode.h" #include "tconfig.h" static struct { @@ -129,14 +129,14 @@ static SDnodeOpt dndGetOpt() { static int32_t dndInitLog() { char logName[12] = {0}; - snprintf(logName, sizeof(logName), "%slog", dndNodeLogStr(global.ntype)); + snprintf(logName, sizeof(logName), "%slog", dndLogName(global.ntype)); return taosCreateLog(logName, 1, configDir, global.envFile, global.apolloUrl, global.pArgs, 0); } static void dndSetProcInfo(int32_t argc, char **argv) { taosSetProcPath(argc, argv); if (global.ntype != NODE_BEGIN && global.ntype != NODE_END) { - const char *name = dndNodeProcStr(global.ntype); + const char *name = dndProcName(global.ntype); taosSetProcName(argc, argv, name); } } diff --git a/source/dnode/mgmt/implement/inc/dndNode.h b/source/dnode/mgmt/implement/inc/dndNode.h new file mode 100644 index 0000000000000000000000000000000000000000..f5d93d2f617c9ba6dd8708813d8c22fbcba534bf --- /dev/null +++ b/source/dnode/mgmt/implement/inc/dndNode.h @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#ifndef _TD_DND_NODE_H_ +#define _TD_DND_NODE_H_ + +#include "dndInt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +int32_t dndOpenNode(SMgmtWrapper *pWrapper); +void dndCloseNode(SMgmtWrapper *pWrapper); + +void dndSetMsgHandle(SMgmtWrapper *pWrapper, tmsg_t msgType, NodeMsgFp nodeMsgFp, int8_t vgId); +SMgmtWrapper *dndAcquireWrapper(SDnode *pDnode, EDndNodeType nType); +int32_t dndMarkWrapper(SMgmtWrapper *pWrapper); +void dndReleaseWrapper(SMgmtWrapper *pWrapper); +void dndHandleEvent(SDnode *pDnode, EDndEvent event); +void dndReportStartup(SDnode *pDnode, const char *pName, const char *pDesc); +void dndProcessStartupReq(SDnode *pDnode, SRpcMsg *pMsg); + +// dndTransport.c +int32_t dndInitTrans(SDnode *pDnode); +void dndCleanupTrans(SDnode *pDnode); +SMsgCb dndCreateMsgcb(SMgmtWrapper *pWrapper); +SProcCfg dndGenProcCfg(SMgmtWrapper *pWrapper); +int32_t dndInitMsgHandle(SDnode *pDnode); +void dndSendRecv(SDnode *pDnode, SEpSet *pEpSet, 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 dmGetMnodeEpSet(SDnodeData *pMgmt, SEpSet *pEpSet); +void dmUpdateMnodeEpSet(SDnodeData *pMgmt, SEpSet *pEpSet); +void dmSendRedirectRsp(SDnodeData *pMgmt, const SRpcMsg *pMsg); + +void dmGetMonitorSysInfo(SMonSysInfo *pInfo); +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 + +#endif /*_TD_DND_NODE_H_*/ \ No newline at end of file diff --git a/source/dnode/mgmt/main/dndEnv.c b/source/dnode/mgmt/implement/src/dndEnv.c similarity index 98% rename from source/dnode/mgmt/main/dndEnv.c rename to source/dnode/mgmt/implement/src/dndEnv.c index 9f75594335021553f2dd03b511c8f925c2238286..a7a3ee8c913f72b264ffb4efa6e0c8fe9d4e8be8 100644 --- a/source/dnode/mgmt/main/dndEnv.c +++ b/source/dnode/mgmt/implement/src/dndEnv.c @@ -14,7 +14,7 @@ */ #define _DEFAULT_SOURCE -#include "dndInt.h" +#include "dndNode.h" #include "wal.h" static int8_t once = DND_ENV_INIT; diff --git a/source/dnode/mgmt/main/dndExec.c b/source/dnode/mgmt/implement/src/dndExec.c similarity index 99% rename from source/dnode/mgmt/main/dndExec.c rename to source/dnode/mgmt/implement/src/dndExec.c index bdc9a2751aad056484502e3aff3908abfee9e36e..7bdf0f379120abde1835036f956954b8309db59f 100644 --- a/source/dnode/mgmt/main/dndExec.c +++ b/source/dnode/mgmt/implement/src/dndExec.c @@ -14,7 +14,7 @@ */ #define _DEFAULT_SOURCE -#include "dndInt.h" +#include "dndNode.h" static bool dndRequireNode(SMgmtWrapper *pWrapper) { bool required = false; diff --git a/source/dnode/mgmt/main/dndObj.c b/source/dnode/mgmt/implement/src/dndObj.c similarity index 99% rename from source/dnode/mgmt/main/dndObj.c rename to source/dnode/mgmt/implement/src/dndObj.c index ff2be4272266017d0ce7e7a870ffe2ea98fc85c7..4300ee08532da750c308d20194a7fbf1bbb65dae 100644 --- a/source/dnode/mgmt/main/dndObj.c +++ b/source/dnode/mgmt/implement/src/dndObj.c @@ -14,7 +14,7 @@ */ #define _DEFAULT_SOURCE -#include "dndInt.h" +#include "dndNode.h" static int32_t dndInitVars(SDnode *pDnode, const SDnodeOpt *pOption) { pDnode->data.supportVnodes = pOption->numOfSupportVnodes; diff --git a/source/dnode/mgmt/main/dndTransport.c b/source/dnode/mgmt/implement/src/dndTransport.c similarity index 99% rename from source/dnode/mgmt/main/dndTransport.c rename to source/dnode/mgmt/implement/src/dndTransport.c index c5f195d71e0e2cebe381812965fa377ed72d7e5b..2d38d6311f1a6ce172aa3a37c928eed2c9fcf569 100644 --- a/source/dnode/mgmt/main/dndTransport.c +++ b/source/dnode/mgmt/implement/src/dndTransport.c @@ -14,7 +14,7 @@ */ #define _DEFAULT_SOURCE -#include "dndInt.h" +#include "dndNode.h" #define INTERNAL_USER "_dnd" #define INTERNAL_CKEY "_key" diff --git a/source/dnode/mgmt/inc/bmInt.h b/source/dnode/mgmt/inc/bmInt.h index 3158fe7d34f37616745927925354dfdde18453ba..627df93b01b01eed4b55f32d463e27f6d5bdef0f 100644 --- a/source/dnode/mgmt/inc/bmInt.h +++ b/source/dnode/mgmt/inc/bmInt.h @@ -16,7 +16,7 @@ #ifndef _TD_DND_BNODE_INT_H_ #define _TD_DND_BNODE_INT_H_ -#include "dndInt.h" +#include "dndNode.h" #include "bnode.h" diff --git a/source/dnode/mgmt/inc/dmInt.h b/source/dnode/mgmt/inc/dmInt.h index 4d6ebd63d2dc7c1572455a758cab8f5407ed3df2..5d787b36b58f546a6c5d8508e3149ee1736d0e20 100644 --- a/source/dnode/mgmt/inc/dmInt.h +++ b/source/dnode/mgmt/inc/dmInt.h @@ -16,7 +16,7 @@ #ifndef _TD_DND_DNODE_INT_H_ #define _TD_DND_DNODE_INT_H_ -#include "dndInt.h" +#include "dndNode.h" #ifdef __cplusplus extern "C" { diff --git a/source/dnode/mgmt/inc/mmInt.h b/source/dnode/mgmt/inc/mmInt.h index 74b1cc44bf58767b9c2345c574b3243280aac18e..4f7c1d9d8ce358034c9ff2d48ceb20165d1f590c 100644 --- a/source/dnode/mgmt/inc/mmInt.h +++ b/source/dnode/mgmt/inc/mmInt.h @@ -16,7 +16,7 @@ #ifndef _TD_DND_MNODE_INT_H_ #define _TD_DND_MNODE_INT_H_ -#include "dndInt.h" +#include "dndNode.h" #include "mnode.h" #ifdef __cplusplus diff --git a/source/dnode/mgmt/inc/qmInt.h b/source/dnode/mgmt/inc/qmInt.h index 012869d6375e5a8102273e67f920b1fda8da9f32..67a00396eadf3c58b20cff1ca725b6e1da1a8e23 100644 --- a/source/dnode/mgmt/inc/qmInt.h +++ b/source/dnode/mgmt/inc/qmInt.h @@ -16,7 +16,7 @@ #ifndef _TD_DND_QNODE_INT_H_ #define _TD_DND_QNODE_INT_H_ -#include "dndInt.h" +#include "dndNode.h" #include "qnode.h" #ifdef __cplusplus diff --git a/source/dnode/mgmt/inc/smInt.h b/source/dnode/mgmt/inc/smInt.h index 039dea24919eefa551c6c332c11f790747156f4a..56cb954c222e9cef8abb61244b457ab9bfc984ff 100644 --- a/source/dnode/mgmt/inc/smInt.h +++ b/source/dnode/mgmt/inc/smInt.h @@ -16,7 +16,7 @@ #ifndef _TD_DND_SNODE_INT_H_ #define _TD_DND_SNODE_INT_H_ -#include "dndInt.h" +#include "dndNode.h" #include "snode.h" #ifdef __cplusplus diff --git a/source/dnode/mgmt/inc/vmInt.h b/source/dnode/mgmt/inc/vmInt.h index f8466fe4f232979baa12867e13cfbe01d68a46ff..da5ab8387e5e061b8108223c72053b6b887bb137 100644 --- a/source/dnode/mgmt/inc/vmInt.h +++ b/source/dnode/mgmt/inc/vmInt.h @@ -17,7 +17,7 @@ #define _TD_DND_VNODES_INT_H_ #include "sync.h" -#include "dndInt.h" +#include "dndNode.h" #include "vnode.h" #ifdef __cplusplus diff --git a/source/dnode/mgmt/interface/inc/dndInt.h b/source/dnode/mgmt/interface/inc/dndInt.h index b08f372daa9c785b916ae410fe2499d4a50c79e2..1f9d5cd8f411907f54b5f39037480059d5b4df86 100644 --- a/source/dnode/mgmt/interface/inc/dndInt.h +++ b/source/dnode/mgmt/interface/inc/dndInt.h @@ -23,11 +23,10 @@ extern "C" { #endif -// dndEnv.c -const char *dndStatStr(EDndRunStatus stat); -const char *dndNodeLogStr(EDndNodeType ntype); -const char *dndNodeProcStr(EDndNodeType ntype); -const char *dndEventStr(EDndEvent ev); +const char *dndStatName(EDndRunStatus stat); +const char *dndLogName(EDndNodeType ntype); +const char *dndProcName(EDndNodeType ntype); +const char *dndEventName(EDndEvent ev); // dndExec.c int32_t dndOpenNode(SMgmtWrapper *pWrapper); diff --git a/source/dnode/mgmt/main/dndFile.c b/source/dnode/mgmt/interface/src/dndFile.c similarity index 95% rename from source/dnode/mgmt/main/dndFile.c rename to source/dnode/mgmt/interface/src/dndFile.c index 45d80543a10f344d4f0e023cf4a99ef187ce6ae0..c35d7fbb4af383bf7ed773147a26d256117f03c6 100644 --- a/source/dnode/mgmt/main/dndFile.c +++ b/source/dnode/mgmt/interface/src/dndFile.c @@ -23,7 +23,7 @@ int32_t dndReadFile(SMgmtWrapper *pWrapper, bool *pDeployed) { int64_t len = 0; char content[MAXLEN + 1] = {0}; cJSON *root = NULL; - char file[PATH_MAX]; + char file[PATH_MAX] = {0}; TdFilePtr pFile = NULL; snprintf(file, sizeof(file), "%s%s%s.json", pWrapper->path, TD_DIRSEP, pWrapper->name); @@ -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", dndNodeProcStr(ntype)); + snprintf(itemName, sizeof(itemName), "%s_shmid", dndProcName(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", dndNodeProcStr(ntype)); + snprintf(itemName, sizeof(itemName), "%s_shmsize", dndProcName(ntype)); cJSON *shmsize = cJSON_GetObjectItem(root, itemName); if (shmsize && shmsize->type == cJSON_Number) { pDnode->wrappers[ntype].procShm.size = shmsize->valueint; @@ -228,11 +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", dndNodeProcStr(ntype), pWrapper->procShm.id); + len += snprintf(content + len, MAXLEN - len, " \"%s_shmid\":%d,\n", dndProcName(ntype), pWrapper->procShm.id); if (ntype == NODE_END - 1) { - len += snprintf(content + len, MAXLEN - len, " \"%s_shmsize\":%d\n", dndNodeProcStr(ntype), pWrapper->procShm.size); + len += snprintf(content + len, MAXLEN - len, " \"%s_shmsize\":%d\n", dndProcName(ntype), pWrapper->procShm.size); } else { - len += snprintf(content + len, MAXLEN - len, " \"%s_shmsize\":%d,\n", dndNodeProcStr(ntype), pWrapper->procShm.size); + len += snprintf(content + len, MAXLEN - len, " \"%s_shmsize\":%d,\n", dndProcName(ntype), pWrapper->procShm.size); } } len += snprintf(content + len, MAXLEN - len, "}\n"); diff --git a/source/dnode/mgmt/interface/src/dndInt.c b/source/dnode/mgmt/interface/src/dndInt.c index 9ec37b5d04a6b948bbc3f271befd65bb1f544424..5e4cd47824dc094a6b0198b310f8a8183aca456f 100644 --- a/source/dnode/mgmt/interface/src/dndInt.c +++ b/source/dnode/mgmt/interface/src/dndInt.c @@ -20,12 +20,12 @@ EDndRunStatus dndGetStatus(SDnode *pDnode) { return pDnode->status; } void dndSetStatus(SDnode *pDnode, EDndRunStatus status) { if (pDnode->status != status) { - dDebug("dnode status set from %s to %s", dndStatStr(pDnode->status), dndStatStr(status)); + dDebug("dnode status set from %s to %s", dndStatName(pDnode->status), dndStatName(status)); pDnode->status = status; } } -const char *dndStatStr(EDndRunStatus status) { +const char *dndStatName(EDndRunStatus status) { switch (status) { case DND_STAT_INIT: return "init"; @@ -38,7 +38,7 @@ const char *dndStatStr(EDndRunStatus status) { } } -const char *dndNodeLogStr(EDndNodeType ntype) { +const char *dndLogName(EDndNodeType ntype) { switch (ntype) { case VNODE: return "vnode"; @@ -55,7 +55,7 @@ const char *dndNodeLogStr(EDndNodeType ntype) { } } -const char *dndNodeProcStr(EDndNodeType ntype) { +const char *dndProcName(EDndNodeType ntype) { switch (ntype) { case VNODE: return "taosv"; @@ -72,7 +72,7 @@ const char *dndNodeProcStr(EDndNodeType ntype) { } } -const char *dndEventStr(EDndEvent ev) { +const char *dndEventName(EDndEvent ev) { switch (ev) { case DND_EVENT_START: return "start";