From abb7731a5e942ad158199904c016e8bad03c6a71 Mon Sep 17 00:00:00 2001 From: slguan Date: Wed, 5 Feb 2020 17:01:48 +0800 Subject: [PATCH] #1177 --- src/dnode/inc/dnodeMgmt.h | 38 +++++++++++++++++ src/dnode/inc/dnodePlugin.h | 44 ++++++++++++++++++++ src/dnode/inc/dnodeSystem.h | 2 +- src/dnode/src/dnodeMgmt.c | 2 +- src/dnode/src/dnodePlugin.c | 46 ++++++++++++++------- src/dnode/src/dnodeRead.c | 17 ++++++++ src/dnode/src/dnodeSystem.c | 43 +++++++++++++++++++- src/dnode/src/dnodeSystem.spec.c | 56 -------------------------- src/dnode/src/dnodeWrite.c | 17 ++++++++ src/dnode/src/vnodeMgmt.c | 2 +- src/mnode/lite/src/mgmtDnodeInt.spec.c | 4 +- src/vnode/detail/inc/vnode.h | 2 +- src/vnode/detail/inc/vnodeSystem.h | 2 +- 13 files changed, 197 insertions(+), 78 deletions(-) create mode 100644 src/dnode/inc/dnodeMgmt.h create mode 100644 src/dnode/inc/dnodePlugin.h create mode 100644 src/dnode/src/dnodeRead.c delete mode 100644 src/dnode/src/dnodeSystem.spec.c create mode 100644 src/dnode/src/dnodeWrite.c diff --git a/src/dnode/inc/dnodeMgmt.h b/src/dnode/inc/dnodeMgmt.h new file mode 100644 index 0000000000..453795e0bd --- /dev/null +++ b/src/dnode/inc/dnodeMgmt.h @@ -0,0 +1,38 @@ +/* + * 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_VNODEMGMT_H +#define TDENGINE_VNODEMGMT_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + char id[20]; + char sid; + void *thandle; + int mgmtIndex; + char status; // 0:offline, 1:online +} SMgmtObj; + +int vnodeProcessCreateMeterRequest(char *pMsg, int msgLen, SMgmtObj *pMgmtObj); +int vnodeProcessRemoveMeterRequest(char *pMsg, int msgLen, SMgmtObj *pMgmtObj); + +#ifdef __cplusplus +} +#endif + +#endif // TDENGINE_VNODEMGMT_H diff --git a/src/dnode/inc/dnodePlugin.h b/src/dnode/inc/dnodePlugin.h new file mode 100644 index 0000000000..697567dce7 --- /dev/null +++ b/src/dnode/inc/dnodePlugin.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 TDENGINE_DNODE_PLUGIN_H +#define TDENGINE_DNODE_PLUGIN_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +#include "tsched.h" +#include "mgmt.h" + +char *(*taosBuildRspMsgToMnodeWithSize)(SMgmtObj *pObj, char type, int size); +char *(*taosBuildReqMsgToMnodeWithSize)(SMgmtObj *pObj, char type, int size); +char *(*taosBuildRspMsgToMnode)(SMgmtObj *pObj, char type); +char *(*taosBuildReqMsgToMnode)(SMgmtObj *pObj, char type); +int (*taosSendMsgToMnode)(SMgmtObj *pObj, char *msg, int msgLen); +int (*taosSendSimpleRspToMnode)(SMgmtObj *pObj, char rsptype, char code); + +void (*dnodeInitMgmtIp)(); +void (*dnodeProcessMsgFromMgmt)(SSchedMsg *sched); +int (*dnodeInitMgmtConn)(); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/dnode/inc/dnodeSystem.h b/src/dnode/inc/dnodeSystem.h index 96e5699464..d3d6a28199 100644 --- a/src/dnode/inc/dnodeSystem.h +++ b/src/dnode/inc/dnodeSystem.h @@ -56,7 +56,7 @@ void dnodeCheckDbRunning(const char* dir); void vnodeCleanUpSystem(); int vnodeInitSystem(); -void vnodeInitMgmtIp(); +void dnodeInitMgmtIp(); void vnodeInitQHandle(); int mgmtInitSystem(); diff --git a/src/dnode/src/dnodeMgmt.c b/src/dnode/src/dnodeMgmt.c index 5e2b150cbb..9252a6ef30 100644 --- a/src/dnode/src/dnodeMgmt.c +++ b/src/dnode/src/dnodeMgmt.c @@ -51,7 +51,7 @@ char *taosBuildReqMsgToMnode(SMgmtObj *pObj, char type); int taosSendSimpleRspToMnode(SMgmtObj *pObj, char rsptype, char code); int taosSendMsgToMnode(SMgmtObj *pObj, char *msg, int msgLen); -void vnodeProcessMsgFromMgmt(char *content, int msgLen, int msgType, SMgmtObj *pObj) { +void dnodeProcessMsgFromMgmtImp(char *content, int msgLen, int msgType, SMgmtObj *pObj) { if (msgType == TSDB_MSG_TYPE_CREATE) { vnodeProcessCreateMeterRequest(content, msgLen, pObj); } else if (msgType == TSDB_MSG_TYPE_VPEERS) { diff --git a/src/dnode/src/dnodePlugin.c b/src/dnode/src/dnodePlugin.c index 576dbcb337..fe5f17bda0 100644 --- a/src/dnode/src/dnodePlugin.c +++ b/src/dnode/src/dnodePlugin.c @@ -14,14 +14,16 @@ */ #define _DEFAULT_SOURCE -#include "tsched.h" + +#include "dnodePlugin.h" +#include "dnodeMgmt.h" + + #include "vnode.h" #include "vnodeMgmt.h" -void*vnodeProcessMsgFromMgmt(char *content, int msgLen, int msgType, SMgmtObj *pObj); -void mgmtProcessMsgFromDnodeSpec(SSchedMsg *sched); -char *taosBuildRspMsgToMnodeWithSize(SMgmtObj *pObj, char type, int size) { +char *taosBuildRspMsgToMnodeWithSizeEdgeImp(SMgmtObj *pObj, char type, int size) { char *pStart = (char *)malloc(size); if (pStart == NULL) { return NULL; @@ -31,7 +33,7 @@ char *taosBuildRspMsgToMnodeWithSize(SMgmtObj *pObj, char type, int size) { return pStart + 1; } -char *taosBuildReqMsgToMnodeWithSize(SMgmtObj *pObj, char type, int size) { +char *taosBuildReqMsgToMnodeWithSizeEdgeImp(SMgmtObj *pObj, char type, int size) { char *pStart = (char *)malloc(size); if (pStart == NULL) { return NULL; @@ -41,15 +43,15 @@ char *taosBuildReqMsgToMnodeWithSize(SMgmtObj *pObj, char type, int size) { return pStart + 1; } -char *taosBuildRspMsgToMnode(SMgmtObj *pObj, char type) { +char *taosBuildRspMsgToMnodeEdgeImp(SMgmtObj *pObj, char type) { return taosBuildRspMsgToMnodeWithSize(pObj, type, 256); } -char *taosBuildReqMsgToMnode(SMgmtObj *pObj, char type) { +char *taosBuildReqMsgToMnodeEdgeImp(SMgmtObj *pObj, char type) { return taosBuildReqMsgToMnodeWithSize(pObj, type, 256); } -int taosSendMsgToMnode(SMgmtObj *pObj, char *msg, int msgLen) { +int taosSendMsgToMnodeEdgeImp(SMgmtObj *pObj, char *msg, int msgLen) { dTrace("msg:%s is sent to mnode", taosMsg[(uint8_t)(*(msg-1))]); /* @@ -65,7 +67,7 @@ int taosSendMsgToMnode(SMgmtObj *pObj, char *msg, int msgLen) { return 0; } -int taosSendSimpleRspToMnode(SMgmtObj *pObj, char rsptype, char code) { +int taosSendSimpleRspToMnodeEdgeImp(SMgmtObj *pObj, char rsptype, char code) { char *pStart = taosBuildRspMsgToMnode(0, rsptype); if (pStart == NULL) { return 0; @@ -77,19 +79,35 @@ int taosSendSimpleRspToMnode(SMgmtObj *pObj, char rsptype, char code) { return 0; } -void vnodeProcessMsgFromMgmtSpec(SSchedMsg *sched) { +void dnodeProcessMsgFromMgmtEdgeImp(SSchedMsg *sched) { char msgType = *sched->msg; char *content = sched->msg + 1; dTrace("msg:%s is received from mgmt", taosMsg[(uint8_t)msgType]); - vnodeProcessMsgFromMgmt(content, 0, msgType, 0); + dnodeProcessMsgFromMgmtImp(content, 0, msgType, 0); free(sched->msg); } -int vnodeInitMgmt() { return 0; } +int dnodeInitMgmtConnEdgeImp() { + return 0; +} + +void dnodeInitMgmtIpEdgeImp() {} + +void dnodeInitPlugin() { + dnodeInitMgmtConn = dnodeInitMgmtConnEdgeImp; + dnodeInitMgmtIp = dnodeInitMgmtIpEdgeImp; + dnodeProcessMsgFromMgmt = dnodeProcessMsgFromMgmtEdgeImp; + + taosBuildRspMsgToMnodeWithSize = taosBuildRspMsgToMnodeWithSizeEdgeImp; + taosBuildReqMsgToMnodeWithSize = taosBuildReqMsgToMnodeWithSizeEdgeImp; + taosBuildRspMsgToMnode = taosBuildRspMsgToMnodeEdgeImp; + taosBuildReqMsgToMnode = taosBuildReqMsgToMnodeEdgeImp; + taosSendMsgToMnode = taosSendMsgToMnodeEdgeImp; + taosSendSimpleRspToMnode = taosSendSimpleRspToMnodeEdgeImp; +} + -void vnodeInitMgmtIp() {} -int vnodeSaveCreateMsgIntoQueue(SVnodeObj *pVnode, char *pMsg, int msgLen) { return 0; } \ No newline at end of file diff --git a/src/dnode/src/dnodeRead.c b/src/dnode/src/dnodeRead.c new file mode 100644 index 0000000000..4a2012aa35 --- /dev/null +++ b/src/dnode/src/dnodeRead.c @@ -0,0 +1,17 @@ +/* + * 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 . + */ + +#define _DEFAULT_SOURCE + diff --git a/src/dnode/src/dnodeSystem.c b/src/dnode/src/dnodeSystem.c index 49e9a37590..d57c7580f4 100644 --- a/src/dnode/src/dnodeSystem.c +++ b/src/dnode/src/dnodeSystem.c @@ -133,7 +133,7 @@ int dnodeInitSystem() { return -1; } - vnodeInitMgmtIp(); + dnodeInitMgmtIp(); tsPrintGlobalConfig(); dPrint("Server IP address is:%s", tsPrivateIp); @@ -216,3 +216,44 @@ void dnodeCountRequest(SCountInfo *info) { info->selectReqNum = atomic_exchange_32(&vnodeSelectReqNum, 0); info->insertReqNum = atomic_exchange_32(&vnodeInsertReqNum, 0); } + + +//spec + +extern SModule tsModule[TSDB_MOD_MAX]; + +int taosCreateTierDirectory() { + struct stat dirstat; + strcpy(tsDirectory, dataDir); + if (stat(dataDir, &dirstat) < 0) { + mkdir(dataDir, 0755); + } + + char fileName[128]; + + sprintf(fileName, "%s/tsdb", tsDirectory); + mkdir(fileName, 0755); + + sprintf(fileName, "%s/data", tsDirectory); + mkdir(fileName, 0755); + + sprintf(mgmtDirectory, "%s/mgmt", tsDirectory); + sprintf(tsDirectory, "%s/tsdb", dataDir); + dnodeCheckDbRunning(dataDir); + + return 0; +} + +int dnodeInitSystemSpec() { return 0; } + +void dnodeStartModuleSpec() { + for (int mod = 1; mod < TSDB_MOD_MAX; ++mod) { + if (tsModule[mod].num != 0 && tsModule[mod].startFp) { + if ((*tsModule[mod].startFp)() != 0) { + dError("failed to start module:%d", mod); + } + } + } +} + +void dnodeParseParameterK() {} diff --git a/src/dnode/src/dnodeSystem.spec.c b/src/dnode/src/dnodeSystem.spec.c deleted file mode 100644 index 7d6602c463..0000000000 --- a/src/dnode/src/dnodeSystem.spec.c +++ /dev/null @@ -1,56 +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 . - */ - -#define _DEFAULT_SOURCE -#include "mgmt.h" -#include "dnodeSystem.h" - -extern SModule tsModule[TSDB_MOD_MAX]; - -int taosCreateTierDirectory() { - struct stat dirstat; - strcpy(tsDirectory, dataDir); - if (stat(dataDir, &dirstat) < 0) { - mkdir(dataDir, 0755); - } - - char fileName[128]; - - sprintf(fileName, "%s/tsdb", tsDirectory); - mkdir(fileName, 0755); - - sprintf(fileName, "%s/data", tsDirectory); - mkdir(fileName, 0755); - - sprintf(mgmtDirectory, "%s/mgmt", tsDirectory); - sprintf(tsDirectory, "%s/tsdb", dataDir); - dnodeCheckDbRunning(dataDir); - - return 0; -} - -int dnodeInitSystemSpec() { return 0; } - -void dnodeStartModuleSpec() { - for (int mod = 1; mod < TSDB_MOD_MAX; ++mod) { - if (tsModule[mod].num != 0 && tsModule[mod].startFp) { - if ((*tsModule[mod].startFp)() != 0) { - dError("failed to start module:%d", mod); - } - } - } -} - -void dnodeParseParameterK() {} \ No newline at end of file diff --git a/src/dnode/src/dnodeWrite.c b/src/dnode/src/dnodeWrite.c new file mode 100644 index 0000000000..4a2012aa35 --- /dev/null +++ b/src/dnode/src/dnodeWrite.c @@ -0,0 +1,17 @@ +/* + * 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 . + */ + +#define _DEFAULT_SOURCE + diff --git a/src/dnode/src/vnodeMgmt.c b/src/dnode/src/vnodeMgmt.c index b23050ab03..d8c600d1d9 100644 --- a/src/dnode/src/vnodeMgmt.c +++ b/src/dnode/src/vnodeMgmt.c @@ -80,7 +80,7 @@ int vnodeInitSystem() { return -1; } - if (vnodeInitMgmt() < 0) { + if (dnodeInitMgmtConn() < 0) { dError("failed to init communication to mgmt"); return -1; } diff --git a/src/mnode/lite/src/mgmtDnodeInt.spec.c b/src/mnode/lite/src/mgmtDnodeInt.spec.c index 734fa630c5..5a124d9d99 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 vnodeProcessMsgFromMgmtSpec(SSchedMsg *sched); +void dnodeProcessMsgFromMgmt(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 = vnodeProcessMsgFromMgmtSpec; + schedMsg.fp = dnodeProcessMsgFromMgmt; schedMsg.msg = msg - 1; schedMsg.ahandle = NULL; schedMsg.thandle = NULL; diff --git a/src/vnode/detail/inc/vnode.h b/src/vnode/detail/inc/vnode.h index 60449de9f5..232e9d358d 100644 --- a/src/vnode/detail/inc/vnode.h +++ b/src/vnode/detail/inc/vnode.h @@ -524,7 +524,7 @@ SConnSec *vnodeGetMeterSec(int vnode, int sid); int vnodeCreateMeterObjFile(int vnode); // mgmt -int vnodeInitMgmt(); +int dnodeInitMgmtConn(); void vnodeCleanUpMgmt(); diff --git a/src/vnode/detail/inc/vnodeSystem.h b/src/vnode/detail/inc/vnodeSystem.h index e436288fc1..d730c0ea8f 100644 --- a/src/vnode/detail/inc/vnodeSystem.h +++ b/src/vnode/detail/inc/vnodeSystem.h @@ -32,7 +32,7 @@ int vnodeInitStore(); int vnodeInitPeer(int numOfThreads); -int vnodeInitMgmt(); +int dnodeInitMgmtConn(); #ifdef __cplusplus } -- GitLab