From 89a19fdbe19a9e4d11e938a6707e69a1d95248e4 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Mon, 1 Nov 2021 20:22:16 +0800 Subject: [PATCH 1/2] fix compile errors --- source/dnode/mgmt/inc/dnodeDnode.h | 4 ++-- source/dnode/mgmt/inc/dnodeVnodes.h | 4 ++-- source/dnode/mgmt/src/dnodeConfig.c | 2 +- source/dnode/mgmt/src/dnodeDnode.c | 26 +++++++++++++------------- source/dnode/mgmt/src/dnodeInt.c | 24 ++++++++++++------------ 5 files changed, 30 insertions(+), 30 deletions(-) diff --git a/source/dnode/mgmt/inc/dnodeDnode.h b/source/dnode/mgmt/inc/dnodeDnode.h index 35f68f0306..b126b39d1c 100644 --- a/source/dnode/mgmt/inc/dnodeDnode.h +++ b/source/dnode/mgmt/inc/dnodeDnode.h @@ -21,8 +21,8 @@ extern "C" { #endif #include "dnodeInt.h" -int32_t dnodeInitMsg(); -void dnodeCleanupMsg(); +int32_t dnodeInitDnode(); +void dnodeCleanupDnode(); void dnodeProcessStatusRsp(SRpcMsg *pMsg); void dnodeProcessStartupReq(SRpcMsg *pMsg); void dnodeProcessConfigDnodeReq(SRpcMsg *pMsg); diff --git a/source/dnode/mgmt/inc/dnodeVnodes.h b/source/dnode/mgmt/inc/dnodeVnodes.h index d54fda654a..33848042bd 100644 --- a/source/dnode/mgmt/inc/dnodeVnodes.h +++ b/source/dnode/mgmt/inc/dnodeVnodes.h @@ -21,8 +21,8 @@ extern "C" { #endif #include "dnodeInt.h" -int32_t dnodeInitMsg(); -void dnodeCleanupMsg(); +int32_t dnodeInitDnode(); +void dnodeCleanupDnode(); void dnodeProcessStatusRsp(SRpcMsg *pMsg); void dnodeProcessStartupReq(SRpcMsg *pMsg); void dnodeProcessCreateMnodeReq(SRpcMsg *pMsg); diff --git a/source/dnode/mgmt/src/dnodeConfig.c b/source/dnode/mgmt/src/dnodeConfig.c index d6189eb632..2a0374ffaf 100644 --- a/source/dnode/mgmt/src/dnodeConfig.c +++ b/source/dnode/mgmt/src/dnodeConfig.c @@ -30,7 +30,7 @@ static struct { pthread_mutex_t mutex; } tsConfig; -vstaticoid dnodeGetEpSetForPeer(SRpcEpSet *epSet) { +void dnodeGetEpSetForPeer(SRpcEpSet *epSet) { pthread_mutex_lock(&tsConfig.mutex); *epSet = tsConfig.mnodeEpSetForPeer; pthread_mutex_unlock(&tsConfig.mutex); diff --git a/source/dnode/mgmt/src/dnodeDnode.c b/source/dnode/mgmt/src/dnodeDnode.c index 0a598527b4..3c6a743e05 100644 --- a/source/dnode/mgmt/src/dnodeDnode.c +++ b/source/dnode/mgmt/src/dnodeDnode.c @@ -25,7 +25,7 @@ static struct { pthread_t *threadId; bool stop; uint32_t rebootTime; -} tsMsg; +} tsDnode; static void dnodeSendStatusMsg() { int32_t contLen = sizeof(SStatusMsg) + TSDB_MAX_VNODES * sizeof(SVnodeLoad); @@ -39,7 +39,7 @@ static void dnodeSendStatusMsg() { pStatus->dnodeId = htonl(dnodeGetDnodeId()); tstrncpy(pStatus->dnodeEp, tsLocalEp, TSDB_EP_LEN); pStatus->clusterId = htobe64(dnodeGetClusterId()); - pStatus->lastReboot = htonl(tsMsg.rebootTime); + pStatus->lastReboot = htonl(tsDnode.rebootTime); pStatus->numOfCores = htonl(tsNumOfCores); pStatus->diskAvailable = tsAvailDataDirGB; @@ -93,17 +93,17 @@ void dnodeProcessStatusRsp(SRpcMsg *pMsg) { static void *dnodeThreadRoutine(void *param) { int32_t ms = tsStatusInterval * 1000; - while (!tsMsg.stop) { + while (!tsDnode.stop) { taosMsleep(ms); dnodeSendStatusMsg(); } } -int32_t dnodeInitMsg() { - tsMsg.stop = false; - tsMsg.rebootTime = taosGetTimestampSec(); - tsMsg.threadId = taosCreateThread(dnodeThreadRoutine, NULL); - if (tsMsg.threadId == NULL) { +int32_t dnodeInitDnode() { + tsDnode.stop = false; + tsDnode.rebootTime = taosGetTimestampSec(); + tsDnode.threadId = taosCreateThread(dnodeThreadRoutine, NULL); + if (tsDnode.threadId == NULL) { return -1; } @@ -111,11 +111,11 @@ int32_t dnodeInitMsg() { return 0; } -void dnodeCleanupMsg() { - if (tsMsg.threadId != NULL) { - tsMsg.stop = true; - taosDestoryThread(tsMsg.threadId); - tsMsg.threadId = NULL; +void dnodeCleanupDnode() { + if (tsDnode.threadId != NULL) { + tsDnode.stop = true; + taosDestoryThread(tsDnode.threadId); + tsDnode.threadId = NULL; } dInfo("dnode msg is cleanuped"); diff --git a/source/dnode/mgmt/src/dnodeInt.c b/source/dnode/mgmt/src/dnodeInt.c index de1d03ae7a..6368fe95f7 100644 --- a/source/dnode/mgmt/src/dnodeInt.c +++ b/source/dnode/mgmt/src/dnodeInt.c @@ -31,27 +31,27 @@ static struct { EDnStat runStatus; SStartupStep startup; SSteps *steps; -} tsDnode; +} tsInt; -EDnStat dnodeGetRunStat() { return tsDnode.runStatus; } +EDnStat dnodeGetRunStat() { return tsInt.runStatus; } -void dnodeSetRunStat(EDnStat stat) { tsDnode.runStatus = stat; } +void dnodeSetRunStat(EDnStat stat) { tsInt.runStatus = stat; } void dnodeReportStartup(char *name, char *desc) { - SStartupStep *startup = &tsDnode.startup; + SStartupStep *startup = &tsInt.startup; tstrncpy(startup->name, name, strlen(startup->name)); tstrncpy(startup->desc, desc, strlen(startup->desc)); startup->finished = 0; } static void dnodeReportStartupFinished(char *name, char *desc) { - SStartupStep *startup = &tsDnode.startup; + SStartupStep *startup = &tsInt.startup; tstrncpy(startup->name, name, strlen(startup->name)); tstrncpy(startup->desc, desc, strlen(startup->desc)); startup->finished = 1; } -void dnodeGetStartup(SStartupStep *pStep) { memcpy(pStep, &tsDnode.startup, sizeof(SStartupStep)); } +void dnodeGetStartup(SStartupStep *pStep) { memcpy(pStep, &tsInt.startup, sizeof(SStartupStep)); } static int32_t dnodeInitVnode() { return vnodeInit(); @@ -72,7 +72,7 @@ static int32_t dnodeInitMnode() { static int32_t dnodeInitTfs() {} static int32_t dnodeInitMain() { - tsDnode.runStatus = DN_RUN_STAT_STOPPED; + tsInt.runStatus = DN_RUN_STAT_STOPPED; tscEmbedded = 1; taosIgnSIGPIPE(); taosBlockSIGPIPE(); @@ -175,10 +175,10 @@ int32_t dnodeInit() { taosStepAdd(steps, "dnode-vnode", dnodeInitVnode, vnodeCleanup); taosStepAdd(steps, "dnode-mnode", dnodeInitMnode, mnodeCleanup); taosStepAdd(steps, "dnode-trans", dnodeInitTrans, dnodeCleanupTrans); - taosStepAdd(steps, "dnode-msg", dnodeInitMsg, dnodeCleanupMsg); + taosStepAdd(steps, "dnode-msg", dnodeInitDnode, dnodeCleanupDnode); - tsDnode.steps = steps; - taosStepExec(tsDnode.steps); + tsInt.steps = steps; + taosStepExec(tsInt.steps); dnodeSetRunStat(DN_RUN_STAT_RUNNING); dnodeReportStartupFinished("TDengine", "initialized successfully"); @@ -190,8 +190,8 @@ int32_t dnodeInit() { void dnodeCleanup() { if (dnodeGetRunStat() != DN_RUN_STAT_STOPPED) { dnodeSetRunStat(DN_RUN_STAT_STOPPED); - taosStepCleanup(tsDnode.steps); - tsDnode.steps = NULL; + taosStepCleanup(tsInt.steps); + tsInt.steps = NULL; } } From 7354b9e193ea2160d169209723c6a0c99b96d566 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Mon, 1 Nov 2021 20:38:50 +0800 Subject: [PATCH 2/2] minor changes --- source/dnode/mgmt/inc/dnodeInt.h | 1 - source/dnode/mgmt/inc/dnodeMnode.h | 3 +++ source/dnode/mgmt/inc/dnodeVnodes.h | 8 ++---- source/dnode/mgmt/src/dnodeInt.c | 42 ++++++----------------------- source/dnode/mgmt/src/dnodeMain.c | 6 ++--- source/dnode/mgmt/src/dnodeMnode.c | 34 +++++++++++++++++++++++ source/dnode/mgmt/src/dnodeVnodes.c | 22 +++++++++++++++ 7 files changed, 71 insertions(+), 45 deletions(-) create mode 100644 source/dnode/mgmt/src/dnodeMnode.c diff --git a/source/dnode/mgmt/inc/dnodeInt.h b/source/dnode/mgmt/inc/dnodeInt.h index 20257140d6..bccafcee85 100644 --- a/source/dnode/mgmt/inc/dnodeInt.h +++ b/source/dnode/mgmt/inc/dnodeInt.h @@ -24,7 +24,6 @@ extern "C" { #include "tglobal.h" #include "tlog.h" #include "trpc.h" -#include "ttimer.h" extern int32_t dDebugFlag; diff --git a/source/dnode/mgmt/inc/dnodeMnode.h b/source/dnode/mgmt/inc/dnodeMnode.h index 0dccb8c39d..00868535c1 100644 --- a/source/dnode/mgmt/inc/dnodeMnode.h +++ b/source/dnode/mgmt/inc/dnodeMnode.h @@ -21,6 +21,9 @@ extern "C" { #endif #include "dnodeInt.h" +int32_t dnodeInitMnode(); +void dnodeCleanupMnode(); + void dnodeProcessCreateMnodeReq(SRpcMsg *pMsg); #ifdef __cplusplus diff --git a/source/dnode/mgmt/inc/dnodeVnodes.h b/source/dnode/mgmt/inc/dnodeVnodes.h index 33848042bd..fae1de7217 100644 --- a/source/dnode/mgmt/inc/dnodeVnodes.h +++ b/source/dnode/mgmt/inc/dnodeVnodes.h @@ -21,12 +21,8 @@ extern "C" { #endif #include "dnodeInt.h" -int32_t dnodeInitDnode(); -void dnodeCleanupDnode(); -void dnodeProcessStatusRsp(SRpcMsg *pMsg); -void dnodeProcessStartupReq(SRpcMsg *pMsg); -void dnodeProcessCreateMnodeReq(SRpcMsg *pMsg); -void dnodeProcessConfigDnodeReq(SRpcMsg *pMsg); +int32_t dnodeInitVnodes(); +void dnodeCleanupVnodes(); #ifdef __cplusplus } diff --git a/source/dnode/mgmt/src/dnodeInt.c b/source/dnode/mgmt/src/dnodeInt.c index 6368fe95f7..df84896be7 100644 --- a/source/dnode/mgmt/src/dnodeInt.c +++ b/source/dnode/mgmt/src/dnodeInt.c @@ -17,14 +17,14 @@ #include "dnodeCheck.h" #include "dnodeConfig.h" #include "dnodeDnode.h" +#include "dnodeMnode.h" #include "dnodeTransport.h" -#include "mnode.h" +#include "dnodeVnodes.h" #include "sync.h" #include "tcache.h" #include "tconfig.h" #include "tnote.h" #include "tstep.h" -#include "vnode.h" #include "wal.h" static struct { @@ -37,7 +37,7 @@ EDnStat dnodeGetRunStat() { return tsInt.runStatus; } void dnodeSetRunStat(EDnStat stat) { tsInt.runStatus = stat; } -void dnodeReportStartup(char *name, char *desc) { +static void dnodeReportStartup(char *name, char *desc) { SStartupStep *startup = &tsInt.startup; tstrncpy(startup->name, name, strlen(startup->name)); tstrncpy(startup->desc, desc, strlen(startup->desc)); @@ -53,24 +53,6 @@ static void dnodeReportStartupFinished(char *name, char *desc) { void dnodeGetStartup(SStartupStep *pStep) { memcpy(pStep, &tsInt.startup, sizeof(SStartupStep)); } -static int32_t dnodeInitVnode() { - return vnodeInit(); -} - -static int32_t dnodeInitMnode() { - SMnodePara para; - para.fp.GetDnodeEp = dnodeGetEp; - para.fp.SendMsgToDnode = dnodeSendMsgToDnode; - para.fp.SendMsgToMnode = dnodeSendMsgToMnode; - para.fp.SendRedirectMsg = dnodeSendRedirectMsg; - para.dnodeId = dnodeGetDnodeId(); - para.clusterId = dnodeGetClusterId(); - - return mnodeInit(para); -} - -static int32_t dnodeInitTfs() {} - static int32_t dnodeInitMain() { tsInt.runStatus = DN_RUN_STAT_STOPPED; tscEmbedded = 1; @@ -168,14 +150,14 @@ int32_t dnodeInit() { taosStepAdd(steps, "dnode-dir", dnodeInitDir, dnodeCleanupDir); taosStepAdd(steps, "dnode-check", dnodeInitCheck, dnodeCleanupCheck); taosStepAdd(steps, "dnode-rpc", rpcInit, rpcCleanup); - taosStepAdd(steps, "dnode-tfs", dnodeInitTfs, NULL); + taosStepAdd(steps, "dnode-tfs", NULL, NULL); taosStepAdd(steps, "dnode-wal", walInit, walCleanUp); taosStepAdd(steps, "dnode-sync", syncInit, syncCleanUp); - taosStepAdd(steps, "dnode-eps", dnodeInitConfig, dnodeCleanupConfig); - taosStepAdd(steps, "dnode-vnode", dnodeInitVnode, vnodeCleanup); - taosStepAdd(steps, "dnode-mnode", dnodeInitMnode, mnodeCleanup); + taosStepAdd(steps, "dnode-config", dnodeInitConfig, dnodeCleanupConfig); + taosStepAdd(steps, "dnode-vnodes", dnodeInitVnodes, dnodeCleanupVnodes); + taosStepAdd(steps, "dnode-mnode", dnodeInitMnode, dnodeCleanupMnode); taosStepAdd(steps, "dnode-trans", dnodeInitTrans, dnodeCleanupTrans); - taosStepAdd(steps, "dnode-msg", dnodeInitDnode, dnodeCleanupDnode); + taosStepAdd(steps, "dnode-dnode", dnodeInitDnode, dnodeCleanupDnode); tsInt.steps = steps; taosStepExec(tsInt.steps); @@ -194,11 +176,3 @@ void dnodeCleanup() { tsInt.steps = NULL; } } - -// tsVnode.msgFp[TSDB_MSG_TYPE_MD_CREATE_VNODE] = vnodeProcessMgmtMsg; -// tsVnode.msgFp[TSDB_MSG_TYPE_MD_ALTER_VNODE] = vnodeProcessMgmtMsg; -// tsVnode.msgFp[TSDB_MSG_TYPE_MD_SYNC_VNODE] = vnodeProcessMgmtMsg; -// tsVnode.msgFp[TSDB_MSG_TYPE_MD_COMPACT_VNODE] = vnodeProcessMgmtMsg; -// tsVnode.msgFp[TSDB_MSG_TYPE_MD_DROP_VNODE] = vnodeProcessMgmtMsg; -// tsVnode.msgFp[TSDB_MSG_TYPE_MD_ALTER_STREAM] = vnodeProcessMgmtMsg; - \ No newline at end of file diff --git a/source/dnode/mgmt/src/dnodeMain.c b/source/dnode/mgmt/src/dnodeMain.c index 69960173f4..1fbeb1e732 100644 --- a/source/dnode/mgmt/src/dnodeMain.c +++ b/source/dnode/mgmt/src/dnodeMain.c @@ -12,8 +12,8 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -#include "os.h" -#include "ulog.h" + +#define _DEFAULT_SOURCE #include "dnodeInt.h" static bool stop = false; @@ -35,8 +35,6 @@ int main(int argc, char const *argv[]) { exit(EXIT_FAILURE); } - dInfo("Started TDengine service successfully."); - while (!stop) { taosMsleep(100); } diff --git a/source/dnode/mgmt/src/dnodeMnode.c b/source/dnode/mgmt/src/dnodeMnode.c new file mode 100644 index 0000000000..47b1d89bb8 --- /dev/null +++ b/source/dnode/mgmt/src/dnodeMnode.c @@ -0,0 +1,34 @@ +/* + * 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 "dnodeMnode.h" +#include "dnodeConfig.h" +#include "dnodeTransport.h" +#include "mnode.h" + +int32_t dnodeInitMnode() { + SMnodePara para; + para.fp.GetDnodeEp = dnodeGetEp; + para.fp.SendMsgToDnode = dnodeSendMsgToDnode; + para.fp.SendMsgToMnode = dnodeSendMsgToMnode; + para.fp.SendRedirectMsg = dnodeSendRedirectMsg; + para.dnodeId = dnodeGetDnodeId(); + para.clusterId = dnodeGetClusterId(); + + return mnodeInit(para); +} + +void dnodeCleanupMnode() { mnodeCleanup(); } \ No newline at end of file diff --git a/source/dnode/mgmt/src/dnodeVnodes.c b/source/dnode/mgmt/src/dnodeVnodes.c index e69de29bb2..765bd6fc22 100644 --- a/source/dnode/mgmt/src/dnodeVnodes.c +++ b/source/dnode/mgmt/src/dnodeVnodes.c @@ -0,0 +1,22 @@ +/* + * 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 "dnodeDnode.h" +#include "vnode.h" + +int32_t dnodeInitVnodes() { return vnodeInit(); } + +void dnodeCleanupVnodes() { vnodeCleanup(); } \ No newline at end of file