From 78d9ffd72c98644b48ca1eefba722d8f52d9dcba Mon Sep 17 00:00:00 2001 From: slguan Date: Thu, 6 Feb 2020 21:28:17 +0800 Subject: [PATCH] #1177 --- src/CMakeLists.txt | 1 + src/dnode/inc/dnodeMgmt.h | 27 +-------------- src/dnode/inc/dnodeService.h | 27 --------------- src/dnode/src/dnodeMgmt.c | 48 ++++++++++++-------------- src/dnode/src/dnodeModule.c | 3 -- src/dnode/src/dnodeService.c | 2 +- src/dnode/src/dnodeSystem.c | 36 ++++--------------- src/inc/dnode.h | 18 ++++++++++ src/mnode/CMakeLists.txt | 1 - src/mnode/lite/src/mgmtDnodeInt.spec.c | 4 +-- src/{mnode => }/sdb/CMakeLists.txt | 0 src/{mnode => }/sdb/inc/hashint.h | 0 src/{mnode => }/sdb/inc/hashstr.h | 0 src/{mnode => }/sdb/inc/sdbint.h | 0 src/{mnode => }/sdb/src/hashint.c | 0 src/{mnode => }/sdb/src/hashstr.c | 0 src/{mnode => }/sdb/src/sdbEngine.c | 0 src/{mnode => }/sdb/src/sdbstr.c | 0 18 files changed, 52 insertions(+), 115 deletions(-) delete mode 100644 src/dnode/inc/dnodeService.h rename src/{mnode => }/sdb/CMakeLists.txt (100%) rename src/{mnode => }/sdb/inc/hashint.h (100%) rename src/{mnode => }/sdb/inc/hashstr.h (100%) rename src/{mnode => }/sdb/inc/sdbint.h (100%) rename src/{mnode => }/sdb/src/hashint.c (100%) rename src/{mnode => }/sdb/src/hashstr.c (100%) rename src/{mnode => }/sdb/src/sdbEngine.c (100%) rename src/{mnode => }/sdb/src/sdbstr.c (100%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 590dba01a3..712ccbffbf 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,6 +7,7 @@ ADD_SUBDIRECTORY(rpc) ADD_SUBDIRECTORY(client) ADD_SUBDIRECTORY(kit) ADD_SUBDIRECTORY(modules) +ADD_SUBDIRECTORY(sdb) ADD_SUBDIRECTORY(mnode) ADD_SUBDIRECTORY(dnode) ADD_SUBDIRECTORY(vnode) diff --git a/src/dnode/inc/dnodeMgmt.h b/src/dnode/inc/dnodeMgmt.h index 51e3e7c18e..194bde3054 100644 --- a/src/dnode/inc/dnodeMgmt.h +++ b/src/dnode/inc/dnodeMgmt.h @@ -21,14 +21,7 @@ extern "C" { #endif #include "tsched.h" - -typedef struct { - char id[20]; - char sid; - void *thandle; - int mgmtIndex; - char status; // 0:offline, 1:online -} SMgmtObj; +#include "dnode.h" int vnodeProcessCreateMeterRequest(char *pMsg, int msgLen, SMgmtObj *pMgmtObj); int vnodeProcessRemoveMeterRequest(char *pMsg, int msgLen, SMgmtObj *pMgmtObj); @@ -37,24 +30,6 @@ void dnodeDistributeMsgFromMgmt(char *content, int msgLen, int msgType, SMgmtObj void mgmtProcessMsgFromDnodeSpec(SSchedMsg *sched); extern void *dmQhandle; -extern char *(*taosBuildRspMsgToMnodeWithSize)(SMgmtObj *pObj, char type, int size); -extern char *(*taosBuildReqMsgToMnodeWithSize)(SMgmtObj *pObj, char type, int size); -extern char *(*taosBuildRspMsgToMnode)(SMgmtObj *pObj, char type); -extern char *(*taosBuildReqMsgToMnode)(SMgmtObj *pObj, char type); -extern int (*taosSendMsgToMnode)(SMgmtObj *pObj, char *msg, int msgLen); -extern int (*taosSendSimpleRspToMnode)(SMgmtObj *pObj, char rsptype, char code); -extern void (*dnodeInitMgmtIp)(); -extern int (*dnodeInitMgmtConn)(); - -char *taosBuildRspMsgToMnodeWithSizeEdgeImp(SMgmtObj *pObj, char type, int size); -char *taosBuildReqMsgToMnodeWithSizeEdgeImp(SMgmtObj *pObj, char type, int size); -char *taosBuildRspMsgToMnodeEdgeImp(SMgmtObj *pObj, char type); -char *taosBuildReqMsgToMnodeEdgeImp(SMgmtObj *pObj, char type); -int taosSendMsgToMnodeEdgeImp(SMgmtObj *pObj, char *msg, int msgLen); -int taosSendSimpleRspToMnodeEdgeImp(SMgmtObj *pObj, char rsptype, char code); -void dnodeInitMgmtIpEdgeImp(); -void* dnodeProcessMsgFromMgmtEdgeImp(SSchedMsg *sched); -int dnodeInitMgmtConnEdgeImp(); #ifdef __cplusplus } diff --git a/src/dnode/inc/dnodeService.h b/src/dnode/inc/dnodeService.h deleted file mode 100644 index 66bcb2d8ad..0000000000 --- a/src/dnode/inc/dnodeService.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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 TDENGINE_DNODE_SERVICE_H -#define TDENGINE_DNODE_SERVICE_H - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/dnode/src/dnodeMgmt.c b/src/dnode/src/dnodeMgmt.c index 2a10e0a746..482e6ae477 100644 --- a/src/dnode/src/dnodeMgmt.c +++ b/src/dnode/src/dnodeMgmt.c @@ -17,6 +17,7 @@ #include "os.h" +#include "dnode.h" #include "dnodeSystem.h" #include "dnodeMgmt.h" @@ -43,17 +44,7 @@ void vnodeUpdateHeadFile(int vnode, int oldTables, int newTables); void vnodeOpenVnode(int vnode); void vnodeCleanUpOneVnode(int vnode); - -char *(*taosBuildRspMsgToMnodeWithSize)(SMgmtObj *pObj, char type, int size) = NULL; -char *(*taosBuildReqMsgToMnodeWithSize)(SMgmtObj *pObj, char type, int size) = NULL; -char *(*taosBuildRspMsgToMnode)(SMgmtObj *pObj, char type) = NULL; -char *(*taosBuildReqMsgToMnode)(SMgmtObj *pObj, char type) = NULL; -int (*taosSendMsgToMnode)(SMgmtObj *pObj, char *msg, int msgLen) = NULL; -int (*taosSendSimpleRspToMnode)(SMgmtObj *pObj, char rsptype, char code) = NULL; -void (*dnodeInitMgmtIp)() = NULL; -int (*dnodeInitMgmtConn)() = NULL; - -char *taosBuildRspMsgToMnodeWithSizeEdgeImp(SMgmtObj *pObj, char type, int size) { +char *taosBuildRspMsgToMnodeWithSizeImp(SMgmtObj *pObj, char type, int size) { char *pStart = (char *)malloc(size); if (pStart == NULL) { return NULL; @@ -62,8 +53,9 @@ char *taosBuildRspMsgToMnodeWithSizeEdgeImp(SMgmtObj *pObj, char type, int size) *pStart = type; return pStart + 1; } +char *(*taosBuildRspMsgToMnodeWithSize)(SMgmtObj *pObj, char type, int size) = taosBuildRspMsgToMnodeWithSizeImp; -char *taosBuildReqMsgToMnodeWithSizeEdgeImp(SMgmtObj *pObj, char type, int size) { +char *taosBuildReqMsgToMnodeWithSizeImp(SMgmtObj *pObj, char type, int size) { char *pStart = (char *)malloc(size); if (pStart == NULL) { return NULL; @@ -72,16 +64,19 @@ char *taosBuildReqMsgToMnodeWithSizeEdgeImp(SMgmtObj *pObj, char type, int size) *pStart = type; return pStart + 1; } +char *(*taosBuildReqMsgToMnodeWithSize)(SMgmtObj *pObj, char type, int size) = taosBuildReqMsgToMnodeWithSizeImp; -char *taosBuildRspMsgToMnodeEdgeImp(SMgmtObj *pObj, char type) { - return taosBuildRspMsgToMnodeWithSize(pObj, type, 256); +char *taosBuildRspMsgToMnodeImp(SMgmtObj *pObj, char type) { + return taosBuildRspMsgToMnodeWithSizeImp(pObj, type, 256); } +char *(*taosBuildRspMsgToMnode)(SMgmtObj *pObj, char type) = taosBuildRspMsgToMnodeImp; -char *taosBuildReqMsgToMnodeEdgeImp(SMgmtObj *pObj, char type) { - return taosBuildReqMsgToMnodeWithSize(pObj, type, 256); +char *taosBuildReqMsgToMnodeImp(SMgmtObj *pObj, char type) { + return taosBuildReqMsgToMnodeWithSizeImp(pObj, type, 256); } +char *(*taosBuildReqMsgToMnode)(SMgmtObj *pObj, char type) = taosBuildReqMsgToMnodeImp; -int taosSendMsgToMnodeEdgeImp(SMgmtObj *pObj, char *msg, int msgLen) { +int taosSendMsgToMnodeImp(SMgmtObj *pObj, char *msg, int msgLen) { dTrace("msg:%s is sent to mnode", taosMsg[(uint8_t)(*(msg-1))]); /* @@ -96,8 +91,9 @@ int taosSendMsgToMnodeEdgeImp(SMgmtObj *pObj, char *msg, int msgLen) { return 0; } +int (*taosSendMsgToMnode)(SMgmtObj *pObj, char *msg, int msgLen) = taosSendMsgToMnodeImp; -int taosSendSimpleRspToMnodeEdgeImp(SMgmtObj *pObj, char rsptype, char code) { +int taosSendSimpleRspToMnodeImp(SMgmtObj *pObj, char rsptype, char code) { char *pStart = taosBuildRspMsgToMnode(0, rsptype); if (pStart == NULL) { return 0; @@ -108,8 +104,15 @@ int taosSendSimpleRspToMnodeEdgeImp(SMgmtObj *pObj, char rsptype, char code) { return 0; } +int (*taosSendSimpleRspToMnode)(SMgmtObj *pObj, char rsptype, char code) = taosSendSimpleRspToMnodeImp; + +int32_t dnodeInitMgmtImp() { return 0; } +int32_t (*dnodeInitMgmt)() = dnodeInitMgmtImp; -void* dnodeProcessMsgFromMgmtEdgeImp(SSchedMsg *sched) { +void dnodeInitMgmtIpImp() {} +void (*dnodeInitMgmtIp)() = dnodeInitMgmtIpImp; + +void* dnodeProcessMsgFromMgmtImp(SSchedMsg *sched) { char msgType = *sched->msg; char *content = sched->msg + 1; @@ -122,13 +125,6 @@ void* dnodeProcessMsgFromMgmtEdgeImp(SSchedMsg *sched) { return NULL; } -int dnodeInitMgmtConnEdgeImp() { - return 0; -} - -void dnodeInitMgmtIpEdgeImp() {} - - void dnodeDistributeMsgFromMgmt(char *content, int msgLen, int msgType, SMgmtObj *pObj) { if (msgType == TSDB_MSG_TYPE_CREATE) { vnodeProcessCreateMeterRequest(content, msgLen, pObj); diff --git a/src/dnode/src/dnodeModule.c b/src/dnode/src/dnodeModule.c index c64aeb39c2..5999ff3239 100644 --- a/src/dnode/src/dnodeModule.c +++ b/src/dnode/src/dnodeModule.c @@ -23,9 +23,6 @@ #include "httpSystem.h" #include "mgmtSystem.h" -#include "dcluster.h" -#include "mstorage.h" - SModule tsModule[TSDB_MOD_MAX] = {0}; uint32_t tsModuleStatus = 0; diff --git a/src/dnode/src/dnodeService.c b/src/dnode/src/dnodeService.c index acf93b037e..9558052458 100644 --- a/src/dnode/src/dnodeService.c +++ b/src/dnode/src/dnodeService.c @@ -36,7 +36,7 @@ mnodeAccountInit(); mnodeBalanceInit(); mnodeClusterInit(); - mnodeReplicaInit(); + sdbReplicaInit(); multilevelStorageInit(); vnodeClusterInit(); vnodeReplicaInit(); diff --git a/src/dnode/src/dnodeSystem.c b/src/dnode/src/dnodeSystem.c index 5d686c5dbe..7b2a273a14 100644 --- a/src/dnode/src/dnodeSystem.c +++ b/src/dnode/src/dnodeSystem.c @@ -21,7 +21,6 @@ #include "dnode.h" #include "dnodeMgmt.h" #include "dnodeModule.h" -#include "dnodeService.h" #include "dnodeSystem.h" #include "monitorSystem.h" #include "httpSystem.h" @@ -43,14 +42,10 @@ void * queryQhandle; int tsVnodePeers = TSDB_VNODES_SUPPORT - 1; int tsMaxQueues; uint32_t tsRebootTime; -int (*dnodeInitStorage)() = NULL; -void (*dnodeCleanupStorage)() = NULL; -int (*dnodeCheckSystem)() = NULL; int32_t dnodeInitRpcQHandle(); int32_t dnodeInitQueryQHandle(); int32_t dnodeInitTmrCtl(); -void dnodeInitPlugin(); void dnodeCountRequestImp(SCountInfo *info); void dnodeCleanUpSystem() { @@ -89,8 +84,6 @@ int dnodeInitSystem() { char temp[128]; struct stat dirstat; - dnodeInitPlugin(); - taosResolveCRC(); tsRebootTime = taosGetTimestampSec(); @@ -170,7 +163,7 @@ int dnodeInitSystem() { return -1; } - if (dnodeInitMgmtConn() < 0) { + if (dnodeInitMgmt() < 0) { dError("failed to init communication to mgmt"); return -1; } @@ -208,7 +201,7 @@ void dnodeCountRequestImp(SCountInfo *info) { info->insertReqNum = atomic_exchange_32(&vnodeInsertReqNum, 0); } -int dnodeInitStorageComImp() { +int dnodeInitStorageImp() { struct stat dirstat; strcpy(tsDirectory, dataDir); if (stat(dataDir, &dirstat) < 0) { @@ -229,8 +222,10 @@ int dnodeInitStorageComImp() { return 0; } +int32_t (*dnodeInitStorage)() = dnodeInitStorageImp; -void dnodeCleanupStorageComImp() {} +void dnodeCleanupStorageImp() {} +void (*dnodeCleanupStorage)() = dnodeCleanupStorageImp; int32_t dnodeInitQueryQHandle() { int numOfThreads = tsRatioOfQueryThreads * tsNumOfCores * tsNumOfThreadsPerCore; @@ -271,24 +266,7 @@ int32_t dnodeInitRpcQHandle() { } -int dnodeCheckSystemComImp() { - return 0; -} - -void dnodeInitPlugin() { - dnodeInitMgmtConn = dnodeInitMgmtConnEdgeImp; - dnodeInitMgmtIp = dnodeInitMgmtIpEdgeImp; - - taosBuildRspMsgToMnodeWithSize = taosBuildRspMsgToMnodeWithSizeEdgeImp; - taosBuildReqMsgToMnodeWithSize = taosBuildReqMsgToMnodeWithSizeEdgeImp; - taosBuildRspMsgToMnode = taosBuildRspMsgToMnodeEdgeImp; - taosBuildReqMsgToMnode = taosBuildReqMsgToMnodeEdgeImp; - taosSendMsgToMnode = taosSendMsgToMnodeEdgeImp; - taosSendSimpleRspToMnode = taosSendSimpleRspToMnodeEdgeImp; - - dnodeCheckSystem = dnodeCheckSystemComImp; - dnodeInitStorage = dnodeInitStorageComImp; - dnodeCleanupStorage = dnodeCleanupStorageComImp; -} +int dnodeCheckSystemImp() { return 0; } +int (*dnodeCheckSystem)() = dnodeCheckSystemImp; diff --git a/src/inc/dnode.h b/src/inc/dnode.h index e3d02470a5..8da538d6e7 100644 --- a/src/inc/dnode.h +++ b/src/inc/dnode.h @@ -23,12 +23,30 @@ extern "C" { #include #include +typedef struct { + char id[20]; + char sid; + void *thandle; + int mgmtIndex; + char status; // 0:offline, 1:online +} SMgmtObj; + +// global variables extern pthread_mutex_t dmutex; // dnodeCluster extern void (*dnodeStartModules)(); extern void (*dnodeParseParameterK)(); extern int32_t (*dnodeCheckSystem)(); +extern char *(*taosBuildRspMsgToMnodeWithSize)(SMgmtObj *pObj, char type, int size); +extern char *(*taosBuildReqMsgToMnodeWithSize)(SMgmtObj *pObj, char type, int size); +extern char *(*taosBuildRspMsgToMnode)(SMgmtObj *pObj, char type); +extern char *(*taosBuildReqMsgToMnode)(SMgmtObj *pObj, char type); +extern int (*taosSendMsgToMnode)(SMgmtObj *pObj, char *msg, int msgLen); +extern int (*taosSendSimpleRspToMnode)(SMgmtObj *pObj, char rsptype, char code); +extern void (*dnodeInitMgmtIp)(); +extern int (*dnodeInitMgmt)(); + // multilevelStorage extern int32_t (*dnodeInitStorage)(); diff --git a/src/mnode/CMakeLists.txt b/src/mnode/CMakeLists.txt index df4123d3c7..ca14d807b6 100644 --- a/src/mnode/CMakeLists.txt +++ b/src/mnode/CMakeLists.txt @@ -1,6 +1,5 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8) PROJECT(TDengine) -ADD_SUBDIRECTORY(sdb) ADD_SUBDIRECTORY(detail) ADD_SUBDIRECTORY(lite) \ No newline at end of file diff --git a/src/mnode/lite/src/mgmtDnodeInt.spec.c b/src/mnode/lite/src/mgmtDnodeInt.spec.c index ab6b7fff3b..2de08c795a 100644 --- a/src/mnode/lite/src/mgmtDnodeInt.spec.c +++ b/src/mnode/lite/src/mgmtDnodeInt.spec.c @@ -28,7 +28,7 @@ extern void *dmQhandle; void * mgmtStatusTimer = NULL; void mgmtProcessMsgFromDnode(char *content, int msgLen, int msgType, SDnodeObj *pObj); -void* dnodeProcessMsgFromMgmtEdgeImp(SSchedMsg *sched); +void* dnodeProcessMsgFromMgmtImp(SSchedMsg *sched); char *taosBuildRspMsgToDnodeWithSize(SDnodeObj *pObj, char type, int size) { char *pStart = (char *)malloc(size); @@ -67,7 +67,7 @@ int taosSendMsgToDnode(SDnodeObj *pObj, char *msg, int msgLen) { * Lite version has no message header, so minus one */ SSchedMsg schedMsg; - schedMsg.fp = dnodeProcessMsgFromMgmtEdgeImp; + schedMsg.fp = dnodeProcessMsgFromMgmtImp; schedMsg.msg = msg - 1; schedMsg.ahandle = NULL; schedMsg.thandle = NULL; diff --git a/src/mnode/sdb/CMakeLists.txt b/src/sdb/CMakeLists.txt similarity index 100% rename from src/mnode/sdb/CMakeLists.txt rename to src/sdb/CMakeLists.txt diff --git a/src/mnode/sdb/inc/hashint.h b/src/sdb/inc/hashint.h similarity index 100% rename from src/mnode/sdb/inc/hashint.h rename to src/sdb/inc/hashint.h diff --git a/src/mnode/sdb/inc/hashstr.h b/src/sdb/inc/hashstr.h similarity index 100% rename from src/mnode/sdb/inc/hashstr.h rename to src/sdb/inc/hashstr.h diff --git a/src/mnode/sdb/inc/sdbint.h b/src/sdb/inc/sdbint.h similarity index 100% rename from src/mnode/sdb/inc/sdbint.h rename to src/sdb/inc/sdbint.h diff --git a/src/mnode/sdb/src/hashint.c b/src/sdb/src/hashint.c similarity index 100% rename from src/mnode/sdb/src/hashint.c rename to src/sdb/src/hashint.c diff --git a/src/mnode/sdb/src/hashstr.c b/src/sdb/src/hashstr.c similarity index 100% rename from src/mnode/sdb/src/hashstr.c rename to src/sdb/src/hashstr.c diff --git a/src/mnode/sdb/src/sdbEngine.c b/src/sdb/src/sdbEngine.c similarity index 100% rename from src/mnode/sdb/src/sdbEngine.c rename to src/sdb/src/sdbEngine.c diff --git a/src/mnode/sdb/src/sdbstr.c b/src/sdb/src/sdbstr.c similarity index 100% rename from src/mnode/sdb/src/sdbstr.c rename to src/sdb/src/sdbstr.c -- GitLab