diff --git a/src/dnode/inc/dnodeMgmt.h b/src/dnode/inc/dnodeMgmt.h new file mode 100644 index 0000000000000000000000000000000000000000..453795e0bd4126ee2df1d668cd6977a309e8861a --- /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 0000000000000000000000000000000000000000..697567dce7b03cbc800d330434aa3d55113e5a8e --- /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 96e5699464af1095ae92e74b4e96dd67ae11c81d..d3d6a281994826cb5bcb3b5200d39c5c59494e10 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 5e2b150cbb1960daa4990bbd7aef81154be3111b..9252a6ef308c76a47a8a56fbbde69314e931d1c0 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 576dbcb337b329571296d331e043e2ab1bc8d92c..fe5f17bda02b5901792eb07f516e04e16fb20b98 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 0000000000000000000000000000000000000000..4a2012aa35cb2219d62e1bbf8c1ce696ddbc76ab --- /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 49e9a37590996921b1784c56e5edca4246fd2bd0..d57c7580f4f3faf802ad7f21d6b15feb8d934265 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 7d6602c463ae43d77369469e00be716d145bbe09..0000000000000000000000000000000000000000 --- 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 0000000000000000000000000000000000000000..4a2012aa35cb2219d62e1bbf8c1ce696ddbc76ab --- /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 b23050ab03eeeeb9de329d7259da352d48fda23b..d8c600d1d9be249517dd549a944c82f2acd8f4a2 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 734fa630c5303faddb510093c20de21aafc521b9..5a124d9d99e894a5a021bd69d360e3dd80b760ff 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 60449de9f5467ed6341215733156d1d8de3fb4d1..232e9d358deaf0c4254c3788c114eeff6bcfb899 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 e436288fc149cb5381b1e7f583d9450fd8772f5d..d730c0ea8f7a48c0655a70dacc53ebf5d6075f14 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 }