minor changes
This commit is contained in:
parent
da1bf2a2a8
commit
99cb481b6b
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue