diff --git a/include/dnode/bnode/bnode.h b/include/dnode/bnode/bnode.h new file mode 100644 index 0000000000..74574f5462 --- /dev/null +++ b/include/dnode/bnode/bnode.h @@ -0,0 +1,86 @@ +/* + * 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_BNODE_H_ +#define _TD_BNODE_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* ------------------------ TYPES EXPOSED ------------------------ */ +typedef struct SDnode SDnode; +typedef struct SBnode SBnode; +typedef void (*SendMsgToDnodeFp)(SDnode *pDnode, struct SEpSet *epSet, struct SRpcMsg *rpcMsg); +typedef void (*SendMsgToMnodeFp)(SDnode *pDnode, struct SRpcMsg *rpcMsg); +typedef void (*SendRedirectMsgFp)(SDnode *pDnode, struct SRpcMsg *rpcMsg); + +typedef struct { + int64_t numOfErrors; +} SBnodeLoad; + +typedef struct { + int32_t sver; +} SBnodeCfg; + +typedef struct { + int32_t dnodeId; + int64_t clusterId; + SBnodeCfg cfg; + SDnode *pDnode; + SendMsgToDnodeFp sendMsgToDnodeFp; + SendMsgToMnodeFp sendMsgToMnodeFp; + SendRedirectMsgFp sendRedirectMsgFp; +} SBnodeOpt; + +/* ------------------------ SBnode ------------------------ */ +/** + * @brief Start one Bnode in Dnode. + * + * @param pOption Option of the bnode. + * @return SBnode* The bnode object. + */ +SBnode *bndOpen(const SBnodeOpt *pOption); + +/** + * @brief Stop Bnode in Dnode. + * + * @param pBnode The bnode object to close. + */ +void bndClose(SBnode *pBnode); + +/** + * @brief Get the statistical information of Bnode + * + * @param pBnode The bnode object. + * @param pLoad Statistics of the bnode. + * @return int32_t 0 for success, -1 for failure. + */ +int32_t bndGetLoad(SBnode *pBnode, SBnodeLoad *pLoad); + +/** + * @brief Process a query message. + * + * @param pBnode The bnode object. + * @param pMsgs The array of SRpcMsg + * @return int32_t 0 for success, -1 for failure + */ +int32_t bndProcessWMsgs(SBnode *pBnode, SArray *pMsgs); + +#ifdef __cplusplus +} +#endif + +#endif /*_TD_BNODE_H_*/ \ No newline at end of file diff --git a/include/dnode/mgmt/dnode.h b/include/dnode/mgmt/dnode.h index b7f3cea7fc..e12ce09422 100644 --- a/include/dnode/mgmt/dnode.h +++ b/include/dnode/mgmt/dnode.h @@ -29,6 +29,7 @@ typedef struct { int32_t sver; int16_t numOfCores; int16_t numOfSupportVnodes; + int16_t numOfCommitThreads; int8_t enableTelem; int32_t statusInterval; float numOfThreadsPerCore; diff --git a/include/dnode/qnode/qnode.h b/include/dnode/qnode/qnode.h index aa4c3af392..29a3d1af20 100644 --- a/include/dnode/qnode/qnode.h +++ b/include/dnode/qnode/qnode.h @@ -19,52 +19,83 @@ #ifdef __cplusplus extern "C" { #endif -#include "trpc.h" + +/* ------------------------ TYPES EXPOSED ------------------------ */ +typedef struct SDnode SDnode; +typedef struct SQnode SQnode; +typedef void (*SendMsgToDnodeFp)(SDnode *pDnode, struct SEpSet *epSet, struct SRpcMsg *rpcMsg); +typedef void (*SendMsgToMnodeFp)(SDnode *pDnode, struct SRpcMsg *rpcMsg); +typedef void (*SendRedirectMsgFp)(SDnode *pDnode, struct SRpcMsg *rpcMsg); typedef struct { - uint64_t numOfStartTask; - uint64_t numOfStopTask; - uint64_t numOfRecvedFetch; - uint64_t numOfSentHb; - uint64_t numOfSentFetch; - uint64_t numOfTaskInQueue; - uint64_t numOfFetchInQueue; - uint64_t numOfErrors; -} SQnodeStat; + int64_t numOfStartTask; + int64_t numOfStopTask; + int64_t numOfRecvedFetch; + int64_t numOfSentHb; + int64_t numOfSentFetch; + int64_t numOfTaskInQueue; + int64_t numOfFetchInQueue; + int64_t numOfErrors; +} SQnodeLoad; +typedef struct { + int32_t sver; +} SQnodeCfg; +typedef struct { + int32_t dnodeId; + int64_t clusterId; + SQnodeCfg cfg; + SDnode *pDnode; + SendMsgToDnodeFp sendMsgToDnodeFp; + SendMsgToMnodeFp sendMsgToMnodeFp; + SendRedirectMsgFp sendRedirectMsgFp; +} SQnodeOpt; + +/* ------------------------ SQnode ------------------------ */ /** - * Start one Qnode in Dnode. - * @return Error Code. - */ -int32_t qnodeStart(); - -/** - * Stop Qnode in Dnode. + * @brief Start one Qnode in Dnode. * - * @param qnodeId Qnode ID to stop, -1 for all Qnodes. + * @param pOption Option of the qnode. + * @return SQnode* The qnode object. */ -void qnodeStop(int64_t qnodeId); +SQnode *qndOpen(const SQnodeOpt *pOption); - /** - * Get the statistical information of Qnode + * @brief Stop Qnode in Dnode. * - * @param qnodeId Qnode ID to get statistics, -1 for all - * @param stat Statistical information. - * @return Error Code. + * @param pQnode The qnode object to close. */ -int32_t qnodeGetStatistics(int64_t qnodeId, SQnodeStat *stat); +void qndClose(SQnode *pQnode); /** - * Interface for processing Qnode messages. - * - * @param pMsg Message to be processed. - * @return Error code + * @brief Get the statistical information of Qnode + * + * @param pQnode The qnode object. + * @param pLoad Statistics of the qnode. + * @return int32_t 0 for success, -1 for failure. */ -void qnodeProcessReq(SRpcMsg *pMsg); +int32_t qndGetLoad(SQnode *pQnode, SQnodeLoad *pLoad); +/** + * @brief Process a query message. + * + * @param pQnode The qnode object. + * @param pMsg The request message + * @param pRsp The response message + * @return int32_t 0 for success, -1 for failure + */ +int32_t qndProcessQueryReq(SQnode *pQnode, SRpcMsg *pMsg, SRpcMsg **pRsp); +/** + * @brief Process a fetch message. + * + * @param pQnode The qnode object. + * @param pMsg The request message + * @param pRsp The response message + * @return int32_t 0 for success, -1 for failure + */ +int32_t qndProcessFetchReq(SQnode *pQnode, SRpcMsg *pMsg, SRpcMsg **pRsp); #ifdef __cplusplus } diff --git a/include/dnode/snode/snode.h b/include/dnode/snode/snode.h new file mode 100644 index 0000000000..1d30bd1e43 --- /dev/null +++ b/include/dnode/snode/snode.h @@ -0,0 +1,87 @@ +/* + * 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_SNODE_H_ +#define _TD_SNODE_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* ------------------------ TYPES EXPOSED ------------------------ */ +typedef struct SDnode SDnode; +typedef struct SSnode SSnode; +typedef void (*SendMsgToDnodeFp)(SDnode *pDnode, struct SEpSet *epSet, struct SRpcMsg *rpcMsg); +typedef void (*SendMsgToMnodeFp)(SDnode *pDnode, struct SRpcMsg *rpcMsg); +typedef void (*SendRedirectMsgFp)(SDnode *pDnode, struct SRpcMsg *rpcMsg); + +typedef struct { + int64_t numOfErrors; +} SSnodeLoad; + +typedef struct { + int32_t sver; +} SSnodeCfg; + +typedef struct { + int32_t dnodeId; + int64_t clusterId; + SSnodeCfg cfg; + SDnode *pDnode; + SendMsgToDnodeFp sendMsgToDnodeFp; + SendMsgToMnodeFp sendMsgToMnodeFp; + SendRedirectMsgFp sendRedirectMsgFp; +} SSnodeOpt; + +/* ------------------------ SSnode ------------------------ */ +/** + * @brief Start one Snode in Dnode. + * + * @param pOption Option of the snode. + * @return SSnode* The snode object. + */ +SSnode *sndOpen(const SSnodeOpt *pOption); + +/** + * @brief Stop Snode in Dnode. + * + * @param pSnode The snode object to close. + */ +void sndClose(SSnode *pSnode); + +/** + * @brief Get the statistical information of Snode + * + * @param pSnode The snode object. + * @param pLoad Statistics of the snode. + * @return int32_t 0 for success, -1 for failure. + */ +int32_t sndGetLoad(SSnode *pSnode, SSnodeLoad *pLoad); + +/** + * @brief Process a query message. + * + * @param pSnode The snode object. + * @param pMsg The request message + * @param pRsp The response message + * @return int32_t 0 for success, -1 for failure + */ +int32_t sndProcessWriteMsg(SSnode *pSnode, SRpcMsg *pMsg, SRpcMsg **pRsp); + +#ifdef __cplusplus +} +#endif + +#endif /*_TD_SNODE_H_*/ \ No newline at end of file diff --git a/source/dnode/CMakeLists.txt b/source/dnode/CMakeLists.txt index af132dea80..87e4c5fc46 100644 --- a/source/dnode/CMakeLists.txt +++ b/source/dnode/CMakeLists.txt @@ -1,4 +1,6 @@ add_subdirectory(mnode) add_subdirectory(vnode) add_subdirectory(qnode) +add_subdirectory(snode) +add_subdirectory(bnode) add_subdirectory(mgmt) \ No newline at end of file diff --git a/source/dnode/bnode/CMakeLists.txt b/source/dnode/bnode/CMakeLists.txt new file mode 100644 index 0000000000..a284437450 --- /dev/null +++ b/source/dnode/bnode/CMakeLists.txt @@ -0,0 +1,14 @@ +aux_source_directory(src BNODE_SRC) +add_library(bnode ${BNODE_SRC}) +target_include_directories( + bnode + PUBLIC "${CMAKE_SOURCE_DIR}/include/dnode/bnode" + private "${CMAKE_CURRENT_SOURCE_DIR}/inc" +) +target_link_libraries( + bnode + PRIVATE transport + PRIVATE os + PRIVATE common + PRIVATE util +) \ No newline at end of file diff --git a/source/dnode/bnode/inc/bndInt.h b/source/dnode/bnode/inc/bndInt.h new file mode 100644 index 0000000000..d44c520a26 --- /dev/null +++ b/source/dnode/bnode/inc/bndInt.h @@ -0,0 +1,45 @@ +/* + * 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_BNODE_INT_H_ +#define _TD_BNODE_INT_H_ + +#include "os.h" + +#include "tarray.h" +#include "tlog.h" +#include "tmsg.h" +#include "trpc.h" + +#include "bnode.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct SBnode { + int32_t dnodeId; + int64_t clusterId; + SBnodeCfg cfg; + SendMsgToDnodeFp sendMsgToDnodeFp; + SendMsgToMnodeFp sendMsgToMnodeFp; + SendRedirectMsgFp sendRedirectMsgFp; +} SBnode; + +#ifdef __cplusplus +} +#endif + +#endif /*_TD_BNODE_INT_H_*/ \ No newline at end of file diff --git a/source/dnode/bnode/src/bnode.c b/source/dnode/bnode/src/bnode.c new file mode 100644 index 0000000000..40b22dd58d --- /dev/null +++ b/source/dnode/bnode/src/bnode.c @@ -0,0 +1,27 @@ +/* + * 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 . + */ + +#include "bndInt.h" + +SBnode *bndOpen(const SBnodeOpt *pOption) { + SBnode *pBnode = calloc(1, sizeof(SBnode)); + return pBnode; +} + +void bndClose(SBnode *pBnode) { free(pBnode); } + +int32_t bndGetLoad(SBnode *pBnode, SBnodeLoad *pLoad) { return 0; } + +int32_t bndProcessWMsgs(SBnode *pBnode, SArray *pMsgs) { return 0; } diff --git a/source/dnode/mgmt/daemon/src/daemon.c b/source/dnode/mgmt/daemon/src/daemon.c index 75c2ff00e0..6c4fae406e 100644 --- a/source/dnode/mgmt/daemon/src/daemon.c +++ b/source/dnode/mgmt/daemon/src/daemon.c @@ -140,6 +140,7 @@ void dmnInitOption(SDnodeOpt *pOption) { pOption->sver = 30000000; //3.0.0.0 pOption->numOfCores = tsNumOfCores; pOption->numOfSupportVnodes = 1; + pOption->numOfCommitThreads = 1; pOption->statusInterval = tsStatusInterval; pOption->numOfThreadsPerCore = tsNumOfThreadsPerCore; pOption->ratioOfQueryCores = tsRatioOfQueryCores; diff --git a/source/dnode/mgmt/impl/CMakeLists.txt b/source/dnode/mgmt/impl/CMakeLists.txt index 51131ede6a..866eced51a 100644 --- a/source/dnode/mgmt/impl/CMakeLists.txt +++ b/source/dnode/mgmt/impl/CMakeLists.txt @@ -5,6 +5,9 @@ target_link_libraries( PUBLIC cjson PUBLIC mnode PUBLIC vnode + PUBLIC qnode + PUBLIC snode + PUBLIC bnode PUBLIC wal PUBLIC sync PUBLIC taos diff --git a/source/dnode/mgmt/impl/inc/dndBnode.h b/source/dnode/mgmt/impl/inc/dndBnode.h new file mode 100644 index 0000000000..a350eae2d4 --- /dev/null +++ b/source/dnode/mgmt/impl/inc/dndBnode.h @@ -0,0 +1,35 @@ +/* + * 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_BNODE_H_ +#define _TD_DND_BNODE_H_ + +#ifdef __cplusplus +extern "C" { +#endif +#include "dndInt.h" + +int32_t dndInitBnode(SDnode *pDnode); +void dndCleanupBnode(SDnode *pDnode); + +ioid dndProcessBnodeWriteMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet); +int32_t dndProcessCreateBnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg); +int32_t dndProcessDropBnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg); + +#ifdef __cplusplus +} +#endif + +#endif /*_TD_DND_BNODE_H_*/ \ No newline at end of file diff --git a/source/dnode/mgmt/impl/inc/dndInt.h b/source/dnode/mgmt/impl/inc/dndInt.h index d6e9a6b4a1..b7a414672e 100644 --- a/source/dnode/mgmt/impl/inc/dndInt.h +++ b/source/dnode/mgmt/impl/inc/dndInt.h @@ -20,8 +20,11 @@ extern "C" { #endif -#include "cJSON.h" #include "os.h" + +#include "cJSON.h" +#include "tcache.h" +#include "tcrc32c.h" #include "tep.h" #include "thash.h" #include "tlockfree.h" @@ -34,7 +37,11 @@ extern "C" { #include "tworker.h" #include "dnode.h" + +#include "bnode.h" #include "mnode.h" +#include "qnode.h" +#include "snode.h" #include "vnode.h" extern int32_t dDebugFlag; @@ -93,6 +100,41 @@ typedef struct { SWorkerPool syncPool; } SMnodeMgmt; +typedef struct { + int32_t refCount; + int8_t deployed; + int8_t dropped; + char *file; + SQnode *pQnode; + SRWLatch latch; + taos_queue pQueryQ; + taos_queue pFetchQ; + SWorkerPool queryPool; + SWorkerPool fetchPool; +} SQnodeMgmt; + +typedef struct { + int32_t refCount; + int8_t deployed; + int8_t dropped; + char *file; + SSnode *pSnode; + SRWLatch latch; + taos_queue pWriteQ; + SWorkerPool writePool; +} SSnodeMgmt; + +typedef struct { + int32_t refCount; + int8_t deployed; + int8_t dropped; + char *file; + SBnode *pBnode; + SRWLatch latch; + taos_queue pWriteQ; + SMWorkerPool writePool; +} SBnodeMgmt; + typedef struct { SHashObj *hash; int32_t openVnodes; @@ -117,6 +159,9 @@ typedef struct SDnode { FileFd lockFd; SDnodeMgmt dmgmt; SMnodeMgmt mmgmt; + SQnodeMgmt qmgmt; + SSnodeMgmt smgmt; + SBnodeMgmt bmgmt; SVnodesMgmt vmgmt; STransMgmt tmgmt; SStartupMsg startup; diff --git a/source/dnode/mgmt/impl/inc/dndQnode.h b/source/dnode/mgmt/impl/inc/dndQnode.h new file mode 100644 index 0000000000..951209a193 --- /dev/null +++ b/source/dnode/mgmt/impl/inc/dndQnode.h @@ -0,0 +1,36 @@ +/* + * 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_QNODE_H_ +#define _TD_DND_QNODE_H_ + +#ifdef __cplusplus +extern "C" { +#endif +#include "dndInt.h" + +int32_t dndInitQnode(SDnode *pDnode); +void dndCleanupQnode(SDnode *pDnode); + +ioid dndProcessQnodeQueryMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet); +void dndProcessQnodeFetchMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet); +int32_t dndProcessCreateQnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg); +int32_t dndProcessDropQnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg); + +#ifdef __cplusplus +} +#endif + +#endif /*_TD_DND_QNODE_H_*/ \ No newline at end of file diff --git a/source/dnode/mgmt/impl/inc/dndSnode.h b/source/dnode/mgmt/impl/inc/dndSnode.h new file mode 100644 index 0000000000..8cb883794d --- /dev/null +++ b/source/dnode/mgmt/impl/inc/dndSnode.h @@ -0,0 +1,35 @@ +/* + * 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_SNODE_H_ +#define _TD_DND_SNODE_H_ + +#ifdef __cplusplus +extern "C" { +#endif +#include "dndInt.h" + +int32_t dndInitSnode(SDnode *pDnode); +void dndCleanupSnode(SDnode *pDnode); + +void dndProcessSnodeWriteMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet); +int32_t dndProcessCreateSnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg); +int32_t dndProcessDropSnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg); + +#ifdef __cplusplus +} +#endif + +#endif /*_TD_DND_SNODE_H_*/ \ No newline at end of file diff --git a/source/dnode/mgmt/impl/src/dnode.c b/source/dnode/mgmt/impl/src/dnode.c index a4996ecb3b..c8ab35dd96 100644 --- a/source/dnode/mgmt/impl/src/dnode.c +++ b/source/dnode/mgmt/impl/src/dnode.c @@ -19,8 +19,6 @@ #include "dndTransport.h" #include "dndVnodes.h" #include "sync.h" -#include "tcache.h" -#include "tcrc32c.h" #include "wal.h" EStat dndGetStat(SDnode *pDnode) { return pDnode->stat; } @@ -93,6 +91,15 @@ static int32_t dndInitEnv(SDnode *pDnode, SDnodeOpt *pOption) { snprintf(path, sizeof(path), "%s%sdnode", pOption->dataDir, TD_DIRSEP); pDnode->dir.dnode = tstrdup(path); + snprintf(path, sizeof(path), "%s%sqnode", pOption->dataDir, TD_DIRSEP); + pDnode->dir.dnode = tstrdup(path); + + snprintf(path, sizeof(path), "%s%ssnode", pOption->dataDir, TD_DIRSEP); + pDnode->dir.dnode = tstrdup(path); + + snprintf(path, sizeof(path), "%s%sbnode", pOption->dataDir, TD_DIRSEP); + pDnode->dir.dnode = tstrdup(path); + if (pDnode->dir.mnode == NULL || pDnode->dir.vnodes == NULL || pDnode->dir.dnode == NULL) { dError("failed to malloc dir object"); terrno = TSDB_CODE_OUT_OF_MEMORY; @@ -117,6 +124,24 @@ static int32_t dndInitEnv(SDnode *pDnode, SDnodeOpt *pOption) { return -1; } + if (taosMkDir(pDnode->dir.qnode) != 0) { + dError("failed to create dir:%s since %s", pDnode->dir.qnode, strerror(errno)); + terrno = TAOS_SYSTEM_ERROR(errno); + return -1; + } + + if (taosMkDir(pDnode->dir.snode) != 0) { + dError("failed to create dir:%s since %s", pDnode->dir.snode, strerror(errno)); + terrno = TAOS_SYSTEM_ERROR(errno); + return -1; + } + + if (taosMkDir(pDnode->dir.bnode) != 0) { + dError("failed to create dir:%s since %s", pDnode->dir.bnode, strerror(errno)); + terrno = TAOS_SYSTEM_ERROR(errno); + return -1; + } + memcpy(&pDnode->opt, pOption, sizeof(SDnodeOpt)); return 0; } @@ -134,6 +159,18 @@ static void dndCleanupEnv(SDnode *pDnode) { tfree(pDnode->dir.dnode); } + if (pDnode->dir.qnode != NULL) { + tfree(pDnode->dir.qnode); + } + + if (pDnode->dir.bnode != NULL) { + tfree(pDnode->dir.snode); + } + + if (pDnode->dir.snode != NULL) { + tfree(pDnode->dir.bnode); + } + if (pDnode->lockFd >= 0) { taosUnLockFile(pDnode->lockFd); taosCloseFile(pDnode->lockFd); @@ -176,7 +213,7 @@ SDnode *dndInit(SDnodeOpt *pOption) { return NULL; } - if (vnodeInit(1) != 0) { + if (vnodeInit(pDnode->opt.numOfCommitThreads) != 0) { dError("failed to init vnode env"); dndCleanup(pDnode); return NULL; diff --git a/source/dnode/mgmt/impl/test/sut/src/server.cpp b/source/dnode/mgmt/impl/test/sut/src/server.cpp index a001748a12..f29b2fad1d 100644 --- a/source/dnode/mgmt/impl/test/sut/src/server.cpp +++ b/source/dnode/mgmt/impl/test/sut/src/server.cpp @@ -27,6 +27,7 @@ SDnodeOpt TestServer::BuildOption(const char* path, const char* fqdn, uint16_t p option.sver = 1; option.numOfCores = 1; option.numOfSupportVnodes = 1; + option.numOfCommitThreads = 1; option.statusInterval = 1; option.numOfThreadsPerCore = 1; option.ratioOfQueryCores = 1; diff --git a/source/dnode/qnode/CMakeLists.txt b/source/dnode/qnode/CMakeLists.txt index d9f932a631..f6f78f7357 100644 --- a/source/dnode/qnode/CMakeLists.txt +++ b/source/dnode/qnode/CMakeLists.txt @@ -4,4 +4,11 @@ target_include_directories( qnode PUBLIC "${CMAKE_SOURCE_DIR}/include/dnode/qnode" private "${CMAKE_CURRENT_SOURCE_DIR}/inc" +) +target_link_libraries( + qnode + PRIVATE transport + PRIVATE os + PRIVATE common + PRIVATE util ) \ No newline at end of file diff --git a/source/dnode/qnode/inc/qnodeInt.h b/source/dnode/qnode/inc/qndInt.h similarity index 70% rename from source/dnode/qnode/inc/qnodeInt.h rename to source/dnode/qnode/inc/qndInt.h index 43df47845b..e9f1229a9d 100644 --- a/source/dnode/qnode/inc/qnodeInt.h +++ b/source/dnode/qnode/inc/qndInt.h @@ -16,10 +16,27 @@ #ifndef _TD_QNODE_INT_H_ #define _TD_QNODE_INT_H_ +#include "os.h" + +#include "tlog.h" +#include "tmsg.h" +#include "trpc.h" + +#include "qnode.h" + #ifdef __cplusplus extern "C" { #endif +typedef struct SQnode { + int32_t dnodeId; + int64_t clusterId; + SQnodeCfg cfg; + SendMsgToDnodeFp sendMsgToDnodeFp; + SendMsgToMnodeFp sendMsgToMnodeFp; + SendRedirectMsgFp sendRedirectMsgFp; +} SQnode; + #ifdef __cplusplus } #endif diff --git a/source/dnode/qnode/src/qnode.c b/source/dnode/qnode/src/qnode.c index 6dea4a4e57..ff1a460228 100644 --- a/source/dnode/qnode/src/qnode.c +++ b/source/dnode/qnode/src/qnode.c @@ -11,4 +11,25 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . - */ \ No newline at end of file + */ + +#include "qndInt.h" + +SQnode *qndOpen(const SQnodeOpt *pOption) { + SQnode *pQnode = calloc(1, sizeof(SQnode)); + return pQnode; +} + +void qndClose(SQnode *pQnode) { free(pQnode); } + +int32_t qndGetLoad(SQnode *pQnode, SQnodeLoad *pLoad) { return 0; } + +int32_t qndProcessQueryReq(SQnode *pQnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { + *pRsp = NULL; + return 0; +} + +int32_t qndProcessFetchReq(SQnode *pQnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { + *pRsp = NULL; + return 0; +} diff --git a/source/dnode/snode/CMakeLists.txt b/source/dnode/snode/CMakeLists.txt new file mode 100644 index 0000000000..a94dd9edd8 --- /dev/null +++ b/source/dnode/snode/CMakeLists.txt @@ -0,0 +1,14 @@ +aux_source_directory(src SNODE_SRC) +add_library(snode ${SNODE_SRC}) +target_include_directories( + snode + PUBLIC "${CMAKE_SOURCE_DIR}/include/dnode/snode" + private "${CMAKE_CURRENT_SOURCE_DIR}/inc" +) +target_link_libraries( + snode + PRIVATE transport + PRIVATE os + PRIVATE common + PRIVATE util +) \ No newline at end of file diff --git a/source/dnode/snode/inc/sndInt.h b/source/dnode/snode/inc/sndInt.h new file mode 100644 index 0000000000..8827c92eef --- /dev/null +++ b/source/dnode/snode/inc/sndInt.h @@ -0,0 +1,44 @@ +/* + * 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_SNODE_INT_H_ +#define _TD_SNODE_INT_H_ + +#include "os.h" + +#include "tlog.h" +#include "tmsg.h" +#include "trpc.h" + +#include "snode.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct SSnode { + int32_t dnodeId; + int64_t clusterId; + SSnodeCfg cfg; + SendMsgToDnodeFp sendMsgToDnodeFp; + SendMsgToMnodeFp sendMsgToMnodeFp; + SendRedirectMsgFp sendRedirectMsgFp; +} SSnode; + +#ifdef __cplusplus +} +#endif + +#endif /*_TD_SNODE_INT_H_*/ \ No newline at end of file diff --git a/source/dnode/snode/src/snode.c b/source/dnode/snode/src/snode.c new file mode 100644 index 0000000000..3423ce41e2 --- /dev/null +++ b/source/dnode/snode/src/snode.c @@ -0,0 +1,30 @@ +/* + * 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 . + */ + +#include "sndInt.h" + +SSnode *sndOpen(const SSnodeOpt *pOption) { + SSnode *pSnode = calloc(1, sizeof(SSnode)); + return pSnode; +} + +void sndClose(SSnode *pSnode) { free(pSnode); } + +int32_t sndGetLoad(SSnode *pSnode, SSnodeLoad *pLoad) { return 0; } + +int32_t sndProcessWriteMsg(SSnode *pSnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { + *pRsp = NULL; + return 0; +}