diff --git a/include/dnode/mgmt/dnode.h b/include/dnode/mgmt/dnode.h index 4f6f6ab878e5fa334a78f5f93520cdbdbecb209e..97a49e6b077b065851d5bae892106ff8d963f9fd 100644 --- a/include/dnode/mgmt/dnode.h +++ b/include/dnode/mgmt/dnode.h @@ -48,7 +48,7 @@ typedef struct { char secondEp[TSDB_EP_LEN]; SDiskCfg *pDisks; int32_t numOfDisks; -} SDnodeObjCfg; +} SDndCfg; typedef enum { DND_EVENT_STOP = 1, DND_EVENT_RELOAD } EDndEvent; @@ -58,7 +58,7 @@ typedef enum { DND_EVENT_STOP = 1, DND_EVENT_RELOAD } EDndEvent; * @param pCfg Config of the dnode. * @return SDnode* The dnode object. */ -SDnode *dndCreate(SDnodeObjCfg *pCfg); +SDnode *dndCreate(SDndCfg *pCfg); /** * @brief Stop and cleanup the dnode. diff --git a/source/dnode/mgmt/CMakeLists.txt b/source/dnode/mgmt/CMakeLists.txt index efab611452cf4143298df2135b173008af31281d..6440a42282bbf42d2e3162185994fec9f01c70d3 100644 --- a/source/dnode/mgmt/CMakeLists.txt +++ b/source/dnode/mgmt/CMakeLists.txt @@ -14,6 +14,6 @@ target_include_directories( add_subdirectory(exec) -#if(${BUILD_TEST}) -# add_subdirectory(test) -#endif(${BUILD_TEST}) +if(${BUILD_TEST}) + add_subdirectory(test) +endif(${BUILD_TEST}) diff --git a/source/dnode/mgmt/dnode/inc/dndInt.h b/source/dnode/mgmt/dnode/inc/dndInt.h index 21a8d992880900ed60319ffd55f88ee75ae168ef..c47d50597bbe3caa17d7d7f295041fd159283665 100644 --- a/source/dnode/mgmt/dnode/inc/dndInt.h +++ b/source/dnode/mgmt/dnode/inc/dndInt.h @@ -64,6 +64,26 @@ typedef enum { DND_ENV_INIT, DND_ENV_READY, DND_ENV_CLEANU } EEnvStat; typedef void (*DndMsgFp)(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEps); typedef int32_t (*MndMsgFp)(SDnode *pDnode, SMndMsg *pMsg); + + +typedef struct SDnode { + EDndStatus status; + SDndCfg cfg; + SDnodeDir dir; + TdFilePtr pLockFile; + SDnodeMgmt dmgmt; + SMndMgmt mmgmt; + SQnodeMgmt qmgmt; + SSnodeMgmt smgmt; + SBnodeMgmt bmgmt; + SVnodesMgmt vmgmt; + STransMgmt tmgmt; + STfs *pTfs; + SStartupReq startup; + EDndEvent event; +} SDnode; + + EDndStatus dndGetStatus(SDnode *pDnode); void dndSetStatus(SDnode *pDnode, EDndStatus stat); const char *dndStatStr(EDndStatus stat); diff --git a/source/dnode/mgmt/dnode/inc/dndMain.h b/source/dnode/mgmt/dnode/inc/dndMain.h index 9069ad27aa99f248a8983397a60a68c17bab57df..3a18db4590dc1867e66f3d8140162a7bbf5af9d8 100644 --- a/source/dnode/mgmt/dnode/inc/dndMain.h +++ b/source/dnode/mgmt/dnode/inc/dndMain.h @@ -138,22 +138,7 @@ typedef struct { DndMsgFp msgFp[TDMT_MAX]; } STransMgmt; -typedef struct SDnode { - EDndStatus status; - SDnodeObjCfg cfg; - SDnodeDir dir; - TdFilePtr pLockFile; - SDnodeMgmt dmgmt; - SMndMgmt mmgmt; - SQnodeMgmt qmgmt; - SSnodeMgmt smgmt; - SBnodeMgmt bmgmt; - SVnodesMgmt vmgmt; - STransMgmt tmgmt; - STfs *pTfs; - SStartupReq startup; - EDndEvent event; -} SDnode; + #ifdef __cplusplus } diff --git a/source/dnode/mgmt/dnode/src/dndMain.c b/source/dnode/mgmt/dnode/src/dndMain.c index 49c9602f666025b45e5435514f7c423d028336c3..385cb698ea56673d3d65c1a17b42b86db3fd86be 100644 --- a/source/dnode/mgmt/dnode/src/dndMain.c +++ b/source/dnode/mgmt/dnode/src/dndMain.c @@ -28,7 +28,7 @@ static int8_t once = DND_ENV_INIT; -static int32_t dndInitDir(SDnode *pDnode, SDnodeObjCfg *pCfg) { +static int32_t dndInitDir(SDnode *pDnode, SDndCfg *pCfg) { pDnode->pLockFile = dndCheckRunning(pCfg->dataDir); if (pDnode->pLockFile == NULL) { return -1; @@ -83,7 +83,7 @@ static int32_t dndInitDir(SDnode *pDnode, SDnodeObjCfg *pCfg) { return -1; } - memcpy(&pDnode->cfg, pCfg, sizeof(SDnodeObjCfg)); + memcpy(&pDnode->cfg, pCfg, sizeof(SDndCfg)); return 0; } @@ -101,7 +101,7 @@ static void dndCloseDir(SDnode *pDnode) { } } -SDnode *dndCreate(SDnodeObjCfg *pCfg) { +SDnode *dndCreate(SDndCfg *pCfg) { dInfo("start to create dnode object"); SDnode *pDnode = calloc(1, sizeof(SDnode)); diff --git a/source/dnode/mgmt/exec/inc/dndExec.h b/source/dnode/mgmt/exec/inc/dndExec.h index 72523e52ad77c898d88616c2be540d959b908eef..eb4549be69fbf251e277532162f4069a3242e746 100644 --- a/source/dnode/mgmt/exec/inc/dndExec.h +++ b/source/dnode/mgmt/exec/inc/dndExec.h @@ -36,11 +36,10 @@ extern "C" { #define dDebug(...) { if (dDebugFlag & DEBUG_DEBUG) { taosPrintLog("DND ", DEBUG_DEBUG, dDebugFlag, __VA_ARGS__); }} #define dTrace(...) { if (dDebugFlag & DEBUG_TRACE) { taosPrintLog("DND ", DEBUG_TRACE, dDebugFlag, __VA_ARGS__); }} -void dndDumpCfg(); -void dndPrintVersion(); -void dndGenerateGrant(); - -SDnodeObjCfg dndGetObjCfg(); +void dndDumpCfg(); +void dndPrintVersion(); +void dndGenerateGrant(); +SDndCfg dndGetCfg(); #ifdef __cplusplus } diff --git a/source/dnode/mgmt/exec/src/dndExec.c b/source/dnode/mgmt/exec/src/dndExec.c index 2576c80ff5c656eaea8de0f03a0601bf32c9673a..0621bfa48fc842017e2e2fdeeec3d98e9be5dde0 100644 --- a/source/dnode/mgmt/exec/src/dndExec.c +++ b/source/dnode/mgmt/exec/src/dndExec.c @@ -71,8 +71,8 @@ static int32_t dndRunDnode() { return -1; } - SDnodeObjCfg objCfg = dndGetObjCfg(); - SDnode *pDnode = dndCreate(&objCfg); + SDndCfg objCfg = dndGetCfg(); + SDnode *pDnode = dndCreate(&objCfg); if (pDnode == NULL) { dError("failed to to create dnode object since %s", terrstr()); return -1; diff --git a/source/dnode/mgmt/exec/src/dndUtil.c b/source/dnode/mgmt/exec/src/dndUtil.c index f0f613da177e95d854783e0c0e8116ce0d2dddd3..ce45a802d211359405c8e1dd9fb18c721b88e67d 100644 --- a/source/dnode/mgmt/exec/src/dndUtil.c +++ b/source/dnode/mgmt/exec/src/dndUtil.c @@ -32,3 +32,24 @@ void dndPrintVersion() { printf("gitinfo: %s\n", gitinfo); printf("builuInfo: %s\n", buildinfo); } + +void dndDumpCfg() { + SConfig *pCfg = taosGetCfg(); + cfgDumpCfg(pCfg, 0, 1); +} + +SDndCfg dndGetCfg() { + SConfig *pCfg = taosGetCfg(); + SDndCfg objCfg = {0}; + + objCfg.numOfSupportVnodes = cfgGetItem(pCfg, "supportVnodes")->i32; + tstrncpy(objCfg.dataDir, tsDataDir, sizeof(objCfg.dataDir)); + tstrncpy(objCfg.firstEp, tsFirst, sizeof(objCfg.firstEp)); + tstrncpy(objCfg.secondEp, tsSecond, sizeof(objCfg.firstEp)); + objCfg.serverPort = tsServerPort; + tstrncpy(objCfg.localFqdn, tsLocalFqdn, sizeof(objCfg.localFqdn)); + snprintf(objCfg.localEp, sizeof(objCfg.localEp), "%s:%u", objCfg.localFqdn, objCfg.serverPort); + objCfg.pDisks = tsDiskCfg; + objCfg.numOfDisks = tsDiskCfgNum; + return objCfg; +} diff --git a/source/dnode/mgmt/impl/test/CMakeLists.txt b/source/dnode/mgmt/test/CMakeLists.txt similarity index 100% rename from source/dnode/mgmt/impl/test/CMakeLists.txt rename to source/dnode/mgmt/test/CMakeLists.txt diff --git a/source/dnode/mgmt/impl/test/bnode/CMakeLists.txt b/source/dnode/mgmt/test/bnode/CMakeLists.txt similarity index 100% rename from source/dnode/mgmt/impl/test/bnode/CMakeLists.txt rename to source/dnode/mgmt/test/bnode/CMakeLists.txt diff --git a/source/dnode/mgmt/impl/test/bnode/dbnode.cpp b/source/dnode/mgmt/test/bnode/dbnode.cpp similarity index 100% rename from source/dnode/mgmt/impl/test/bnode/dbnode.cpp rename to source/dnode/mgmt/test/bnode/dbnode.cpp diff --git a/source/dnode/mgmt/impl/test/mnode/CMakeLists.txt b/source/dnode/mgmt/test/mnode/CMakeLists.txt similarity index 100% rename from source/dnode/mgmt/impl/test/mnode/CMakeLists.txt rename to source/dnode/mgmt/test/mnode/CMakeLists.txt diff --git a/source/dnode/mgmt/impl/test/mnode/dmnode.cpp b/source/dnode/mgmt/test/mnode/dmnode.cpp similarity index 100% rename from source/dnode/mgmt/impl/test/mnode/dmnode.cpp rename to source/dnode/mgmt/test/mnode/dmnode.cpp diff --git a/source/dnode/mgmt/impl/test/qnode/CMakeLists.txt b/source/dnode/mgmt/test/qnode/CMakeLists.txt similarity index 100% rename from source/dnode/mgmt/impl/test/qnode/CMakeLists.txt rename to source/dnode/mgmt/test/qnode/CMakeLists.txt diff --git a/source/dnode/mgmt/impl/test/qnode/dqnode.cpp b/source/dnode/mgmt/test/qnode/dqnode.cpp similarity index 100% rename from source/dnode/mgmt/impl/test/qnode/dqnode.cpp rename to source/dnode/mgmt/test/qnode/dqnode.cpp diff --git a/source/dnode/mgmt/impl/test/snode/CMakeLists.txt b/source/dnode/mgmt/test/snode/CMakeLists.txt similarity index 100% rename from source/dnode/mgmt/impl/test/snode/CMakeLists.txt rename to source/dnode/mgmt/test/snode/CMakeLists.txt diff --git a/source/dnode/mgmt/impl/test/snode/dsnode.cpp b/source/dnode/mgmt/test/snode/dsnode.cpp similarity index 100% rename from source/dnode/mgmt/impl/test/snode/dsnode.cpp rename to source/dnode/mgmt/test/snode/dsnode.cpp diff --git a/source/dnode/mgmt/impl/test/sut/CMakeLists.txt b/source/dnode/mgmt/test/sut/CMakeLists.txt similarity index 100% rename from source/dnode/mgmt/impl/test/sut/CMakeLists.txt rename to source/dnode/mgmt/test/sut/CMakeLists.txt diff --git a/source/dnode/mgmt/impl/test/sut/inc/client.h b/source/dnode/mgmt/test/sut/inc/client.h similarity index 100% rename from source/dnode/mgmt/impl/test/sut/inc/client.h rename to source/dnode/mgmt/test/sut/inc/client.h diff --git a/source/dnode/mgmt/impl/test/sut/inc/server.h b/source/dnode/mgmt/test/sut/inc/server.h similarity index 88% rename from source/dnode/mgmt/impl/test/sut/inc/server.h rename to source/dnode/mgmt/test/sut/inc/server.h index 99554a7aa78c2e3ffa57ab848a8ccc29c4c7281e..220e8e2090a5a9ad08c5a1f825b9439ac04ba4e5 100644 --- a/source/dnode/mgmt/impl/test/sut/inc/server.h +++ b/source/dnode/mgmt/test/sut/inc/server.h @@ -24,7 +24,7 @@ class TestServer { bool DoStart(); private: - SDnodeObjCfg BuildOption(const char* path, const char* fqdn, uint16_t port, const char* firstEp); + SDndCfg BuildOption(const char* path, const char* fqdn, uint16_t port, const char* firstEp); private: SDnode* pDnode; diff --git a/source/dnode/mgmt/impl/test/sut/inc/sut.h b/source/dnode/mgmt/test/sut/inc/sut.h similarity index 100% rename from source/dnode/mgmt/impl/test/sut/inc/sut.h rename to source/dnode/mgmt/test/sut/inc/sut.h diff --git a/source/dnode/mgmt/impl/test/sut/src/client.cpp b/source/dnode/mgmt/test/sut/src/client.cpp similarity index 100% rename from source/dnode/mgmt/impl/test/sut/src/client.cpp rename to source/dnode/mgmt/test/sut/src/client.cpp diff --git a/source/dnode/mgmt/impl/test/sut/src/server.cpp b/source/dnode/mgmt/test/sut/src/server.cpp similarity index 90% rename from source/dnode/mgmt/impl/test/sut/src/server.cpp rename to source/dnode/mgmt/test/sut/src/server.cpp index 985625b41c28d2518e13a7b01db022b4f276f890..8318d25150ade4c07a68b88e0fd8cca600ccbe15 100644 --- a/source/dnode/mgmt/impl/test/sut/src/server.cpp +++ b/source/dnode/mgmt/test/sut/src/server.cpp @@ -22,8 +22,8 @@ void* serverLoop(void* param) { } } -SDnodeObjCfg TestServer::BuildOption(const char* path, const char* fqdn, uint16_t port, const char* firstEp) { - SDnodeObjCfg cfg = {0}; +SDndCfg TestServer::BuildOption(const char* path, const char* fqdn, uint16_t port, const char* firstEp) { + SDndCfg cfg = {0}; cfg.numOfSupportVnodes = 16; cfg.serverPort = port; strcpy(cfg.dataDir, path); @@ -34,7 +34,7 @@ SDnodeObjCfg TestServer::BuildOption(const char* path, const char* fqdn, uint16_ } bool TestServer::DoStart() { - SDnodeObjCfg cfg = BuildOption(path, fqdn, port, firstEp); + SDndCfg cfg = BuildOption(path, fqdn, port, firstEp); taosMkDir(path); pDnode = dndCreate(&cfg); diff --git a/source/dnode/mgmt/impl/test/sut/src/sut.cpp b/source/dnode/mgmt/test/sut/src/sut.cpp similarity index 100% rename from source/dnode/mgmt/impl/test/sut/src/sut.cpp rename to source/dnode/mgmt/test/sut/src/sut.cpp diff --git a/source/dnode/mgmt/impl/test/vnode/CMakeLists.txt b/source/dnode/mgmt/test/vnode/CMakeLists.txt similarity index 100% rename from source/dnode/mgmt/impl/test/vnode/CMakeLists.txt rename to source/dnode/mgmt/test/vnode/CMakeLists.txt diff --git a/source/dnode/mgmt/impl/test/vnode/vnode.cpp b/source/dnode/mgmt/test/vnode/vnode.cpp similarity index 100% rename from source/dnode/mgmt/impl/test/vnode/vnode.cpp rename to source/dnode/mgmt/test/vnode/vnode.cpp