minor changes
This commit is contained in:
parent
da1bf2a2a8
commit
99cb481b6b
|
@ -31,29 +31,25 @@ typedef struct {
|
||||||
int64_t totalPoints;
|
int64_t totalPoints;
|
||||||
int64_t totalStorage;
|
int64_t totalStorage;
|
||||||
int64_t compStorage;
|
int64_t compStorage;
|
||||||
} SMnodeStat;
|
} SMnodeLoad;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
int32_t dnodeId;
|
||||||
|
int64_t clusterId;
|
||||||
void (*SendMsgToDnode)(struct SEpSet *epSet, struct SRpcMsg *rpcMsg);
|
void (*SendMsgToDnode)(struct SEpSet *epSet, struct SRpcMsg *rpcMsg);
|
||||||
void (*SendMsgToMnode)(struct SRpcMsg *rpcMsg);
|
void (*SendMsgToMnode)(struct SRpcMsg *rpcMsg);
|
||||||
void (*SendRedirectMsg)(struct SRpcMsg *rpcMsg, bool forShell);
|
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;
|
} SMnodePara;
|
||||||
|
|
||||||
int32_t mnodeInit(SMnodePara para);
|
int32_t mnodeInit(SMnodePara para);
|
||||||
void mnodeCleanup();
|
void mnodeCleanup();
|
||||||
|
|
||||||
int32_t mnodeDeploy();
|
int32_t mnodeDeploy();
|
||||||
void mnodeUnDeploy();
|
void mnodeUnDeploy();
|
||||||
int32_t mnodeStart();
|
int32_t mnodeStart();
|
||||||
void mnodeStop();
|
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);
|
int32_t mnodeRetriveAuth(char *user, char *spi, char *encrypt, char *secret, char *ckey);
|
||||||
|
|
||||||
void mnodeProcessMsg(SRpcMsg *rpcMsg);
|
void mnodeProcessMsg(SRpcMsg *rpcMsg);
|
||||||
|
|
|
@ -223,10 +223,9 @@ int32_t dnodeInitMnode() {
|
||||||
snprintf(tsMnode.file, sizeof(tsMnode.file), "%s/mnode.json", tsDnodeDir);
|
snprintf(tsMnode.file, sizeof(tsMnode.file), "%s/mnode.json", tsDnodeDir);
|
||||||
|
|
||||||
SMnodePara para;
|
SMnodePara para;
|
||||||
para.fp.GetDnodeEp = dnodeGetDnodeEp;
|
para.SendMsgToDnode = dnodeSendMsgToDnode;
|
||||||
para.fp.SendMsgToDnode = dnodeSendMsgToDnode;
|
para.SendMsgToMnode = dnodeSendMsgToMnode;
|
||||||
para.fp.SendMsgToMnode = dnodeSendMsgToMnode;
|
para.SendRedirectMsg = dnodeSendRedirectMsg;
|
||||||
para.fp.SendRedirectMsg = dnodeSendRedirectMsg;
|
|
||||||
para.dnodeId = dnodeGetDnodeId();
|
para.dnodeId = dnodeGetDnodeId();
|
||||||
para.clusterId = dnodeGetClusterId();
|
para.clusterId = dnodeGetClusterId();
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,6 @@ EMnStatus mnodeGetStatus();
|
||||||
void mnodeSendMsgToDnode(struct SEpSet *epSet, struct SRpcMsg *rpcMsg);
|
void mnodeSendMsgToDnode(struct SEpSet *epSet, struct SRpcMsg *rpcMsg);
|
||||||
void mnodeSendMsgToMnode(struct SRpcMsg *rpcMsg);
|
void mnodeSendMsgToMnode(struct SRpcMsg *rpcMsg);
|
||||||
void mnodeSendRedirectMsg(struct SRpcMsg *rpcMsg, bool forShell);
|
void mnodeSendRedirectMsg(struct SRpcMsg *rpcMsg, bool forShell);
|
||||||
void mnodeGetDnodeEp(int32_t dnodeId, char *ep, char *fqdn, uint16_t *port);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,21 +172,21 @@ static void mnodeAddVersionInfo(SBufferWriter* bw) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mnodeAddRuntimeInfo(SBufferWriter* bw) {
|
static void mnodeAddRuntimeInfo(SBufferWriter* bw) {
|
||||||
SMnodeStat stat = {0};
|
SMnodeLoad load = {0};
|
||||||
if (mnodeGetStatistics(&stat) != 0) {
|
if (mnodeGetLoad(&load) != 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mnodeAddIntField(bw, "numOfDnode", stat.numOfDnode);
|
mnodeAddIntField(bw, "numOfDnode", load.numOfDnode);
|
||||||
mnodeAddIntField(bw, "numOfMnode", stat.numOfMnode);
|
mnodeAddIntField(bw, "numOfMnode", load.numOfMnode);
|
||||||
mnodeAddIntField(bw, "numOfVgroup", stat.numOfVgroup);
|
mnodeAddIntField(bw, "numOfVgroup", load.numOfVgroup);
|
||||||
mnodeAddIntField(bw, "numOfDatabase", stat.numOfDatabase);
|
mnodeAddIntField(bw, "numOfDatabase", load.numOfDatabase);
|
||||||
mnodeAddIntField(bw, "numOfSuperTable", stat.numOfSuperTable);
|
mnodeAddIntField(bw, "numOfSuperTable", load.numOfSuperTable);
|
||||||
mnodeAddIntField(bw, "numOfChildTable", stat.numOfChildTable);
|
mnodeAddIntField(bw, "numOfChildTable", load.numOfChildTable);
|
||||||
mnodeAddIntField(bw, "numOfColumn", stat.numOfColumn);
|
mnodeAddIntField(bw, "numOfColumn", load.numOfColumn);
|
||||||
mnodeAddIntField(bw, "numOfPoint", stat.totalPoints);
|
mnodeAddIntField(bw, "numOfPoint", load.totalPoints);
|
||||||
mnodeAddIntField(bw, "totalStorage", stat.totalStorage);
|
mnodeAddIntField(bw, "totalStorage", load.totalStorage);
|
||||||
mnodeAddIntField(bw, "compStorage", stat.compStorage);
|
mnodeAddIntField(bw, "compStorage", load.compStorage);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mnodeSendTelemetryReport() {
|
static void mnodeSendTelemetryReport() {
|
||||||
|
|
|
@ -37,48 +37,41 @@
|
||||||
#include "mnodeTelem.h"
|
#include "mnodeTelem.h"
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
int32_t state;
|
int32_t state;
|
||||||
int32_t dnodeId;
|
int32_t dnodeId;
|
||||||
int64_t clusterId;
|
int64_t clusterId;
|
||||||
tmr_h timer;
|
tmr_h timer;
|
||||||
SMnodeFp fp;
|
SSteps *steps1;
|
||||||
SSteps * steps1;
|
SSteps *steps2;
|
||||||
SSteps * steps2;
|
SMnodePara para;
|
||||||
} tsMint;
|
} tsMint;
|
||||||
|
|
||||||
tmr_h mnodeGetTimer() { return tsMint.timer; }
|
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; }
|
EMnStatus mnodeGetStatus() { return tsMint.state; }
|
||||||
|
|
||||||
void mnodeSendMsgToDnode(struct SEpSet *epSet, struct SRpcMsg *rpcMsg) {
|
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) {
|
int32_t mnodeGetLoad(SMnodeLoad *pLoad) { return 0; }
|
||||||
(*tsMint.fp.GetDnodeEp)(dnodeId, ep, fqdn, port);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t mnodeGetStatistics(SMnodeStat *stat) { return 0; }
|
|
||||||
|
|
||||||
static int32_t mnodeSetPara(SMnodePara para) {
|
static int32_t mnodeSetPara(SMnodePara para) {
|
||||||
tsMint.fp = para.fp;
|
tsMint.para = para;
|
||||||
tsMint.dnodeId = para.dnodeId;
|
|
||||||
tsMint.clusterId = para.clusterId;
|
|
||||||
|
|
||||||
if (tsMint.fp.SendMsgToDnode == NULL) return -1;
|
if (tsMint.para.SendMsgToDnode == NULL) return -1;
|
||||||
if (tsMint.fp.SendMsgToMnode == NULL) return -1;
|
if (tsMint.para.SendMsgToMnode == NULL) return -1;
|
||||||
if (tsMint.fp.SendRedirectMsg == NULL) return -1;
|
if (tsMint.para.SendRedirectMsg == NULL) return -1;
|
||||||
if (tsMint.fp.GetDnodeEp == NULL) return -1;
|
if (tsMint.para.dnodeId < 0) return -1;
|
||||||
if (tsMint.dnodeId < 0) return -1;
|
if (tsMint.para.clusterId < 0) return -1;
|
||||||
if (tsMint.clusterId < 0) return -1;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -142,8 +135,8 @@ static void mnodeCleanupStep1() { taosStepCleanup(tsMint.steps1); }
|
||||||
static void mnodeCleanupStep2() { taosStepCleanup(tsMint.steps2); }
|
static void mnodeCleanupStep2() { taosStepCleanup(tsMint.steps2); }
|
||||||
|
|
||||||
static bool mnodeNeedDeploy() {
|
static bool mnodeNeedDeploy() {
|
||||||
if (tsMint.dnodeId > 0) return false;
|
if (tsMint.para.dnodeId > 0) return false;
|
||||||
if (tsMint.clusterId > 0) return false;
|
if (tsMint.para.clusterId > 0) return false;
|
||||||
if (strcmp(tsFirst, tsLocalEp) != 0) return false;
|
if (strcmp(tsFirst, tsLocalEp) != 0) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -156,7 +149,7 @@ int32_t mnodeDeploy() {
|
||||||
tsMint.state = MN_STATUS_INIT;
|
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");
|
mError("failed to deploy mnode since cluster not ready");
|
||||||
return TSDB_CODE_MND_NOT_READY;
|
return TSDB_CODE_MND_NOT_READY;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue