From 99cb481b6b4257cd14ed071f79d76196000c03f2 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 4 Nov 2021 20:24:34 +0800 Subject: [PATCH] minor changes --- include/server/mnode/mnode.h | 14 +++----- source/dnode/mgmt/src/dnodeMnode.c | 7 ++-- source/dnode/mnode/inc/mnodeInt.h | 1 - source/dnode/mnode/src/mnodeTelem.c | 24 +++++++------- source/dnode/mnode/src/mondeInt.c | 51 +++++++++++++---------------- 5 files changed, 42 insertions(+), 55 deletions(-) diff --git a/include/server/mnode/mnode.h b/include/server/mnode/mnode.h index e0fcdec560..d9674e2c8c 100644 --- a/include/server/mnode/mnode.h +++ b/include/server/mnode/mnode.h @@ -31,29 +31,25 @@ typedef struct { int64_t totalPoints; int64_t totalStorage; int64_t compStorage; -} SMnodeStat; +} SMnodeLoad; typedef struct { + int32_t dnodeId; + int64_t clusterId; void (*SendMsgToDnode)(struct SEpSet *epSet, struct SRpcMsg *rpcMsg); void (*SendMsgToMnode)(struct SRpcMsg *rpcMsg); void (*SendRedirectMsg)(struct SRpcMsg *rpcMsg, bool forShell); - void (*GetDnodeEp)(int32_t dnodeId, char *ep, char *fqdn, uint16_t *port); -} SMnodeFp; - -typedef struct { - SMnodeFp fp; - int64_t clusterId; - int32_t dnodeId; } SMnodePara; int32_t mnodeInit(SMnodePara para); void mnodeCleanup(); + int32_t mnodeDeploy(); void mnodeUnDeploy(); int32_t mnodeStart(); void mnodeStop(); -int32_t mnodeGetStatistics(SMnodeStat *stat); +int32_t mnodeGetLoad(SMnodeLoad *pLoad); int32_t mnodeRetriveAuth(char *user, char *spi, char *encrypt, char *secret, char *ckey); void mnodeProcessMsg(SRpcMsg *rpcMsg); diff --git a/source/dnode/mgmt/src/dnodeMnode.c b/source/dnode/mgmt/src/dnodeMnode.c index 4414d57f3e..be85abdc23 100644 --- a/source/dnode/mgmt/src/dnodeMnode.c +++ b/source/dnode/mgmt/src/dnodeMnode.c @@ -223,10 +223,9 @@ int32_t dnodeInitMnode() { snprintf(tsMnode.file, sizeof(tsMnode.file), "%s/mnode.json", tsDnodeDir); SMnodePara para; - para.fp.GetDnodeEp = dnodeGetDnodeEp; - para.fp.SendMsgToDnode = dnodeSendMsgToDnode; - para.fp.SendMsgToMnode = dnodeSendMsgToMnode; - para.fp.SendRedirectMsg = dnodeSendRedirectMsg; + para.SendMsgToDnode = dnodeSendMsgToDnode; + para.SendMsgToMnode = dnodeSendMsgToMnode; + para.SendRedirectMsg = dnodeSendRedirectMsg; para.dnodeId = dnodeGetDnodeId(); para.clusterId = dnodeGetClusterId(); diff --git a/source/dnode/mnode/inc/mnodeInt.h b/source/dnode/mnode/inc/mnodeInt.h index 5fcd7173ee..77ed79f82c 100644 --- a/source/dnode/mnode/inc/mnodeInt.h +++ b/source/dnode/mnode/inc/mnodeInt.h @@ -32,7 +32,6 @@ EMnStatus mnodeGetStatus(); void mnodeSendMsgToDnode(struct SEpSet *epSet, struct SRpcMsg *rpcMsg); void mnodeSendMsgToMnode(struct SRpcMsg *rpcMsg); void mnodeSendRedirectMsg(struct SRpcMsg *rpcMsg, bool forShell); -void mnodeGetDnodeEp(int32_t dnodeId, char *ep, char *fqdn, uint16_t *port); #ifdef __cplusplus } diff --git a/source/dnode/mnode/src/mnodeTelem.c b/source/dnode/mnode/src/mnodeTelem.c index 8b8e4f9ce0..a3977f5b17 100644 --- a/source/dnode/mnode/src/mnodeTelem.c +++ b/source/dnode/mnode/src/mnodeTelem.c @@ -172,21 +172,21 @@ static void mnodeAddVersionInfo(SBufferWriter* bw) { } static void mnodeAddRuntimeInfo(SBufferWriter* bw) { - SMnodeStat stat = {0}; - if (mnodeGetStatistics(&stat) != 0) { + SMnodeLoad load = {0}; + if (mnodeGetLoad(&load) != 0) { return; } - mnodeAddIntField(bw, "numOfDnode", stat.numOfDnode); - mnodeAddIntField(bw, "numOfMnode", stat.numOfMnode); - mnodeAddIntField(bw, "numOfVgroup", stat.numOfVgroup); - mnodeAddIntField(bw, "numOfDatabase", stat.numOfDatabase); - mnodeAddIntField(bw, "numOfSuperTable", stat.numOfSuperTable); - mnodeAddIntField(bw, "numOfChildTable", stat.numOfChildTable); - mnodeAddIntField(bw, "numOfColumn", stat.numOfColumn); - mnodeAddIntField(bw, "numOfPoint", stat.totalPoints); - mnodeAddIntField(bw, "totalStorage", stat.totalStorage); - mnodeAddIntField(bw, "compStorage", stat.compStorage); + mnodeAddIntField(bw, "numOfDnode", load.numOfDnode); + mnodeAddIntField(bw, "numOfMnode", load.numOfMnode); + mnodeAddIntField(bw, "numOfVgroup", load.numOfVgroup); + mnodeAddIntField(bw, "numOfDatabase", load.numOfDatabase); + mnodeAddIntField(bw, "numOfSuperTable", load.numOfSuperTable); + mnodeAddIntField(bw, "numOfChildTable", load.numOfChildTable); + mnodeAddIntField(bw, "numOfColumn", load.numOfColumn); + mnodeAddIntField(bw, "numOfPoint", load.totalPoints); + mnodeAddIntField(bw, "totalStorage", load.totalStorage); + mnodeAddIntField(bw, "compStorage", load.compStorage); } static void mnodeSendTelemetryReport() { diff --git a/source/dnode/mnode/src/mondeInt.c b/source/dnode/mnode/src/mondeInt.c index 669273d8dc..7f1f572432 100644 --- a/source/dnode/mnode/src/mondeInt.c +++ b/source/dnode/mnode/src/mondeInt.c @@ -37,48 +37,41 @@ #include "mnodeTelem.h" static struct { - int32_t state; - int32_t dnodeId; - int64_t clusterId; - tmr_h timer; - SMnodeFp fp; - SSteps * steps1; - SSteps * steps2; + int32_t state; + int32_t dnodeId; + int64_t clusterId; + tmr_h timer; + SSteps *steps1; + SSteps *steps2; + SMnodePara para; } tsMint; tmr_h mnodeGetTimer() { return tsMint.timer; } -int32_t mnodeGetDnodeId() { return tsMint.dnodeId; } +int32_t mnodeGetDnodeId() { return tsMint.para.dnodeId; } -int64_t mnodeGetClusterId() { return tsMint.clusterId; } +int64_t mnodeGetClusterId() { return tsMint.para.clusterId; } EMnStatus mnodeGetStatus() { return tsMint.state; } void mnodeSendMsgToDnode(struct SEpSet *epSet, struct SRpcMsg *rpcMsg) { - (*tsMint.fp.SendMsgToDnode)(epSet, rpcMsg); + (*tsMint.para.SendMsgToDnode)(epSet, rpcMsg); } -void mnodeSendMsgToMnode(struct SRpcMsg *rpcMsg) { return (*tsMint.fp.SendMsgToMnode)(rpcMsg); } +void mnodeSendMsgToMnode(struct SRpcMsg *rpcMsg) { return (*tsMint.para.SendMsgToMnode)(rpcMsg); } -void mnodeSendRedirectMsg(struct SRpcMsg *rpcMsg, bool forShell) { (*tsMint.fp.SendRedirectMsg)(rpcMsg, forShell); } +void mnodeSendRedirectMsg(struct SRpcMsg *rpcMsg, bool forShell) { (*tsMint.para.SendRedirectMsg)(rpcMsg, forShell); } -void mnodeGetDnodeEp(int32_t dnodeId, char *ep, char *fqdn, uint16_t *port) { - (*tsMint.fp.GetDnodeEp)(dnodeId, ep, fqdn, port); -} - -int32_t mnodeGetStatistics(SMnodeStat *stat) { return 0; } +int32_t mnodeGetLoad(SMnodeLoad *pLoad) { return 0; } static int32_t mnodeSetPara(SMnodePara para) { - tsMint.fp = para.fp; - tsMint.dnodeId = para.dnodeId; - tsMint.clusterId = para.clusterId; + tsMint.para = para; - if (tsMint.fp.SendMsgToDnode == NULL) return -1; - if (tsMint.fp.SendMsgToMnode == NULL) return -1; - if (tsMint.fp.SendRedirectMsg == NULL) return -1; - if (tsMint.fp.GetDnodeEp == NULL) return -1; - if (tsMint.dnodeId < 0) return -1; - if (tsMint.clusterId < 0) return -1; + if (tsMint.para.SendMsgToDnode == NULL) return -1; + if (tsMint.para.SendMsgToMnode == NULL) return -1; + if (tsMint.para.SendRedirectMsg == NULL) return -1; + if (tsMint.para.dnodeId < 0) return -1; + if (tsMint.para.clusterId < 0) return -1; return 0; } @@ -142,8 +135,8 @@ static void mnodeCleanupStep1() { taosStepCleanup(tsMint.steps1); } static void mnodeCleanupStep2() { taosStepCleanup(tsMint.steps2); } static bool mnodeNeedDeploy() { - if (tsMint.dnodeId > 0) return false; - if (tsMint.clusterId > 0) return false; + if (tsMint.para.dnodeId > 0) return false; + if (tsMint.para.clusterId > 0) return false; if (strcmp(tsFirst, tsLocalEp) != 0) return false; return true; } @@ -156,7 +149,7 @@ int32_t mnodeDeploy() { tsMint.state = MN_STATUS_INIT; } - if (tsMint.dnodeId <= 0 || tsMint.clusterId <= 0) { + if (tsMint.para.dnodeId <= 0 || tsMint.para.clusterId <= 0) { mError("failed to deploy mnode since cluster not ready"); return TSDB_CODE_MND_NOT_READY; }