refact(cluster): node mgmt
This commit is contained in:
parent
271264f626
commit
318d774ba9
|
@ -759,6 +759,7 @@ typedef struct {
|
||||||
|
|
||||||
int32_t tSerializeSStatusReq(void* buf, int32_t bufLen, SStatusReq* pReq);
|
int32_t tSerializeSStatusReq(void* buf, int32_t bufLen, SStatusReq* pReq);
|
||||||
int32_t tDeserializeSStatusReq(void* buf, int32_t bufLen, SStatusReq* pReq);
|
int32_t tDeserializeSStatusReq(void* buf, int32_t bufLen, SStatusReq* pReq);
|
||||||
|
void tFreeSStatusReq(SStatusReq* pReq);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t dnodeId;
|
int32_t dnodeId;
|
||||||
|
|
|
@ -30,12 +30,12 @@ typedef struct SDnode SDnode;
|
||||||
*
|
*
|
||||||
* @return int32_t 0 for success and -1 for failure
|
* @return int32_t 0 for success and -1 for failure
|
||||||
*/
|
*/
|
||||||
int32_t dndInit();
|
int32_t dmInit();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Clear the environment
|
* @brief Clear the environment
|
||||||
*/
|
*/
|
||||||
void dndCleanup();
|
void dmCleanup();
|
||||||
|
|
||||||
/* ------------------------ SDnode ----------------------- */
|
/* ------------------------ SDnode ----------------------- */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -59,21 +59,21 @@ typedef enum { DND_EVENT_START, DND_EVENT_STOP = 1, DND_EVENT_CHILD } EDndEvent;
|
||||||
* @param pOption Option of the dnode.
|
* @param pOption Option of the dnode.
|
||||||
* @return SDnode* The dnode object.
|
* @return SDnode* The dnode object.
|
||||||
*/
|
*/
|
||||||
SDnode *dndCreate(const SDnodeOpt *pOption);
|
SDnode *dmCreate(const SDnodeOpt *pOption);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Stop and cleanup the dnode.
|
* @brief Stop and cleanup the dnode.
|
||||||
*
|
*
|
||||||
* @param pDnode The dnode object to close.
|
* @param pDnode The dnode object to close.
|
||||||
*/
|
*/
|
||||||
void dndClose(SDnode *pDnode);
|
void dmClose(SDnode *pDnode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Run dnode until specific event is receive.
|
* @brief Run dnode until specific event is receive.
|
||||||
*
|
*
|
||||||
* @param pDnode The dnode object to run.
|
* @param pDnode The dnode object to run.
|
||||||
*/
|
*/
|
||||||
int32_t dndRun(SDnode *pDnode);
|
int32_t dmRun(SDnode *pDnode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Handle event in the dnode.
|
* @brief Handle event in the dnode.
|
||||||
|
@ -81,7 +81,7 @@ int32_t dndRun(SDnode *pDnode);
|
||||||
* @param pDnode The dnode object to close.
|
* @param pDnode The dnode object to close.
|
||||||
* @param event The event to handle.
|
* @param event The event to handle.
|
||||||
*/
|
*/
|
||||||
void dndSetEvent(SDnode *pDnode, EDndEvent event);
|
void dmSetEvent(SDnode *pDnode, EDndEvent event);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -958,6 +958,8 @@ int32_t tDeserializeSStatusReq(void *buf, int32_t bufLen, SStatusReq *pReq) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tFreeSStatusReq(SStatusReq *pReq) { taosArrayDestroy(pReq->pVloads); }
|
||||||
|
|
||||||
int32_t tSerializeSStatusRsp(void *buf, int32_t bufLen, SStatusRsp *pRsp) {
|
int32_t tSerializeSStatusRsp(void *buf, int32_t bufLen, SStatusRsp *pRsp) {
|
||||||
SCoder encoder = {0};
|
SCoder encoder = {0};
|
||||||
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
||||||
|
|
|
@ -18,32 +18,32 @@
|
||||||
#include "tconfig.h"
|
#include "tconfig.h"
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
bool dumpConfig;
|
bool dumpConfig;
|
||||||
bool generateGrant;
|
bool generateGrant;
|
||||||
bool printAuth;
|
bool printAuth;
|
||||||
bool printVersion;
|
bool printVersion;
|
||||||
char envFile[PATH_MAX];
|
char envFile[PATH_MAX];
|
||||||
char apolloUrl[PATH_MAX];
|
char apolloUrl[PATH_MAX];
|
||||||
SArray *pArgs; // SConfigPair
|
SArray *pArgs; // SConfigPair
|
||||||
SDnode *pDnode;
|
SDnode *pDnode;
|
||||||
EDndNodeType ntype;
|
EDndNodeType ntype;
|
||||||
} global = {0};
|
} global = {0};
|
||||||
|
|
||||||
static void dndStopDnode(int signum, void *info, void *ctx) {
|
static void dmStopDnode(int signum, void *info, void *ctx) {
|
||||||
SDnode *pDnode = atomic_val_compare_exchange_ptr(&global.pDnode, 0, global.pDnode);
|
SDnode *pDnode = atomic_val_compare_exchange_ptr(&global.pDnode, 0, global.pDnode);
|
||||||
if (pDnode != NULL) {
|
if (pDnode != NULL) {
|
||||||
dndSetEvent(pDnode, DND_EVENT_STOP);
|
dmSetEvent(pDnode, DND_EVENT_STOP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dndSetSignalHandle() {
|
static void dmSetSignalHandle() {
|
||||||
taosSetSignal(SIGTERM, dndStopDnode);
|
taosSetSignal(SIGTERM, dmStopDnode);
|
||||||
taosSetSignal(SIGHUP, dndStopDnode);
|
taosSetSignal(SIGHUP, dmStopDnode);
|
||||||
taosSetSignal(SIGINT, dndStopDnode);
|
taosSetSignal(SIGINT, dmStopDnode);
|
||||||
taosSetSignal(SIGTSTP, dndStopDnode);
|
taosSetSignal(SIGTSTP, dmStopDnode);
|
||||||
taosSetSignal(SIGABRT, dndStopDnode);
|
taosSetSignal(SIGABRT, dmStopDnode);
|
||||||
taosSetSignal(SIGBREAK, dndStopDnode);
|
taosSetSignal(SIGBREAK, dmStopDnode);
|
||||||
taosSetSignal(SIGQUIT, dndStopDnode);
|
taosSetSignal(SIGQUIT, dmStopDnode);
|
||||||
|
|
||||||
if (!tsMultiProcess) {
|
if (!tsMultiProcess) {
|
||||||
} else if (global.ntype == NODE_BEGIN || global.ntype == NODE_END) {
|
} else if (global.ntype == NODE_BEGIN || global.ntype == NODE_END) {
|
||||||
|
@ -53,7 +53,7 @@ static void dndSetSignalHandle() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t dndParseArgs(int32_t argc, char const *argv[]) {
|
static int32_t dmParseArgs(int32_t argc, char const *argv[]) {
|
||||||
for (int32_t i = 1; i < argc; ++i) {
|
for (int32_t i = 1; i < argc; ++i) {
|
||||||
if (strcmp(argv[i], "-c") == 0) {
|
if (strcmp(argv[i], "-c") == 0) {
|
||||||
if (i < argc - 1) {
|
if (i < argc - 1) {
|
||||||
|
@ -89,12 +89,12 @@ static int32_t dndParseArgs(int32_t argc, char const *argv[]) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dndGenerateGrant() {
|
static void dmGenerateGrant() {
|
||||||
// grantParseParameter();
|
// grantParseParameter();
|
||||||
printf("this feature is not implemented yet\n");
|
printf("this feature is not implemented yet\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dndPrintVersion() {
|
static void dmPrintVersion() {
|
||||||
#ifdef TD_ENTERPRISE
|
#ifdef TD_ENTERPRISE
|
||||||
char *releaseName = "enterprise";
|
char *releaseName = "enterprise";
|
||||||
#else
|
#else
|
||||||
|
@ -105,12 +105,12 @@ static void dndPrintVersion() {
|
||||||
printf("buildInfo: %s\n", buildinfo);
|
printf("buildInfo: %s\n", buildinfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dndDumpCfg() {
|
static void dmDumpCfg() {
|
||||||
SConfig *pCfg = taosGetCfg();
|
SConfig *pCfg = taosGetCfg();
|
||||||
cfgDumpCfg(pCfg, 0, 1);
|
cfgDumpCfg(pCfg, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDnodeOpt dndGetOpt() {
|
static SDnodeOpt dmGetOpt() {
|
||||||
SConfig *pCfg = taosGetCfg();
|
SConfig *pCfg = taosGetCfg();
|
||||||
SDnodeOpt option = {0};
|
SDnodeOpt option = {0};
|
||||||
|
|
||||||
|
@ -127,43 +127,43 @@ static SDnodeOpt dndGetOpt() {
|
||||||
return option;
|
return option;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t dndInitLog() {
|
static int32_t dmInitLog() {
|
||||||
char logName[12] = {0};
|
char logName[12] = {0};
|
||||||
snprintf(logName, sizeof(logName), "%slog", dndLogName(global.ntype));
|
snprintf(logName, sizeof(logName), "%slog", dmLogName(global.ntype));
|
||||||
return taosCreateLog(logName, 1, configDir, global.envFile, global.apolloUrl, global.pArgs, 0);
|
return taosCreateLog(logName, 1, configDir, global.envFile, global.apolloUrl, global.pArgs, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dndSetProcInfo(int32_t argc, char **argv) {
|
static void dmSetProcInfo(int32_t argc, char **argv) {
|
||||||
taosSetProcPath(argc, argv);
|
taosSetProcPath(argc, argv);
|
||||||
if (global.ntype != NODE_BEGIN && global.ntype != NODE_END) {
|
if (global.ntype != NODE_BEGIN && global.ntype != NODE_END) {
|
||||||
const char *name = dndProcName(global.ntype);
|
const char *name = dmProcName(global.ntype);
|
||||||
taosSetProcName(argc, argv, name);
|
taosSetProcName(argc, argv, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t dndRunDnode() {
|
static int32_t dmRunDnode() {
|
||||||
if (dndInit() != 0) {
|
if (dmInit() != 0) {
|
||||||
dError("failed to init environment since %s", terrstr());
|
dError("failed to init environment since %s", terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDnodeOpt option = dndGetOpt();
|
SDnodeOpt option = dmGetOpt();
|
||||||
SDnode *pDnode = dndCreate(&option);
|
SDnode *pDnode = dmCreate(&option);
|
||||||
if (pDnode == NULL) {
|
if (pDnode == NULL) {
|
||||||
dError("failed to to create dnode since %s", terrstr());
|
dError("failed to to create dnode since %s", terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
global.pDnode = pDnode;
|
global.pDnode = pDnode;
|
||||||
dndSetSignalHandle();
|
dmSetSignalHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
dInfo("start the service");
|
dInfo("start the service");
|
||||||
int32_t code = dndRun(pDnode);
|
int32_t code = dmRun(pDnode);
|
||||||
dInfo("start shutting down the service");
|
dInfo("start shutting down the service");
|
||||||
|
|
||||||
global.pDnode = NULL;
|
global.pDnode = NULL;
|
||||||
dndClose(pDnode);
|
dmClose(pDnode);
|
||||||
dndCleanup();
|
dmCleanup();
|
||||||
taosCloseLog();
|
taosCloseLog();
|
||||||
taosCleanupCfg();
|
taosCleanupCfg();
|
||||||
return code;
|
return code;
|
||||||
|
@ -175,22 +175,22 @@ int main(int argc, char const *argv[]) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dndParseArgs(argc, argv) != 0) {
|
if (dmParseArgs(argc, argv) != 0) {
|
||||||
printf("failed to start since parse args error\n");
|
printf("failed to start since parse args error\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (global.generateGrant) {
|
if (global.generateGrant) {
|
||||||
dndGenerateGrant();
|
dmGenerateGrant();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (global.printVersion) {
|
if (global.printVersion) {
|
||||||
dndPrintVersion();
|
dmPrintVersion();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dndInitLog() != 0) {
|
if (dmInitLog() != 0) {
|
||||||
printf("failed to start since init log error\n");
|
printf("failed to start since init log error\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -201,12 +201,12 @@ int main(int argc, char const *argv[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (global.dumpConfig) {
|
if (global.dumpConfig) {
|
||||||
dndDumpCfg();
|
dmDumpCfg();
|
||||||
taosCleanupCfg();
|
taosCleanupCfg();
|
||||||
taosCloseLog();
|
taosCloseLog();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
dndSetProcInfo(argc, (char **)argv);
|
dmSetProcInfo(argc, (char **)argv);
|
||||||
return dndRunDnode();
|
return dmRunDnode();
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,25 +22,51 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int32_t dndOpenNode(SMgmtWrapper *pWrapper);
|
int32_t dmOpenNode(SMgmtWrapper *pWrapper);
|
||||||
void dndCloseNode(SMgmtWrapper *pWrapper);
|
void dmCloseNode(SMgmtWrapper *pWrapper);
|
||||||
|
|
||||||
// dndTransport.c
|
// dmTransport.c
|
||||||
int32_t dmInitTrans(SDnode *pDnode);
|
int32_t dmInitTrans(SDnode *pDnode);
|
||||||
void dndCleanupTrans(SDnode *pDnode);
|
void dmCleanupTrans(SDnode *pDnode);
|
||||||
SProcCfg dndGenProcCfg(SMgmtWrapper *pWrapper);
|
SProcCfg dmGenProcCfg(SMgmtWrapper *pWrapper);
|
||||||
int32_t dndInitMsgHandle(SDnode *pDnode);
|
int32_t dmInitMsgHandle(SDnode *pDnode);
|
||||||
int32_t dndSendMsgToMnode(SDnode *pDnode, SRpcMsg *pReq);
|
void dmSendRecv(SDnode *pDnode, SEpSet *pEpSet, SRpcMsg *pReq, SRpcMsg *pRsp);
|
||||||
void dndSendRecv(SDnode *pDnode, SEpSet *pEpSet, SRpcMsg *pReq, SRpcMsg *pRsp);
|
|
||||||
void dmSendToMnodeRecv(SDnode *pDnode, SRpcMsg *pReq, SRpcMsg *pRsp);
|
void dmSendToMnodeRecv(SDnode *pDnode, SRpcMsg *pReq, SRpcMsg *pRsp);
|
||||||
|
|
||||||
// mgmt
|
// dmEps.c
|
||||||
|
int32_t dmReadEps(SDnode *pDnode);
|
||||||
|
int32_t dmWriteEps(SDnode *pDnode);
|
||||||
|
void dmUpdateEps(SDnode *pDnode, SArray *pDnodeEps);
|
||||||
|
|
||||||
|
// dmHandle.c
|
||||||
|
void dmSendStatusReq(SDnode *pDnode);
|
||||||
|
int32_t dmProcessConfigReq(SDnode *pDnode, SNodeMsg *pMsg);
|
||||||
|
int32_t dmProcessAuthRsp(SDnode *pDnode, SNodeMsg *pMsg);
|
||||||
|
int32_t dmProcessGrantRsp(SDnode *pDnode, SNodeMsg *pMsg);
|
||||||
|
int32_t dmProcessCreateNodeReq(SDnode *pDnode, EDndNodeType ntype, SNodeMsg *pMsg);
|
||||||
|
int32_t dmProcessDropNodeReq(SDnode *pDnode, EDndNodeType ntype, SNodeMsg *pMsg);
|
||||||
|
|
||||||
|
// dmMonitor.c
|
||||||
|
void dmGetVnodeLoads(SDnode *pDnode, SMonVloadInfo *pInfo);
|
||||||
|
void dmSendMonitorReport(SDnode *pDnode);
|
||||||
|
|
||||||
|
// dmWorker.c
|
||||||
|
int32_t dmStartStatusThread(SDnode *pDnode);
|
||||||
|
void dmStopStatusThread(SDnode *pDnode);
|
||||||
|
int32_t dmStartMonitorThread(SDnode *pDnode);
|
||||||
|
void dmStopMonitorThread(SDnode *pDnode);
|
||||||
|
int32_t dmStartWorker(SDnode *pDnode);
|
||||||
|
void dmStopWorker(SDnode *pDnode);
|
||||||
|
int32_t dmProcessMgmtMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg);
|
||||||
|
int32_t dmProcessStatusMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg);
|
||||||
|
|
||||||
|
// mgmt nodes
|
||||||
void dmSetMgmtFp(SMgmtWrapper *pWrapper);
|
void dmSetMgmtFp(SMgmtWrapper *pWrapper);
|
||||||
void bmSetMgmtFp(SMgmtWrapper *pWrapper);
|
void bmSetMgmtFp(SMgmtWrapper *pWrapper);
|
||||||
void qmSetMgmtFp(SMgmtWrapper *pMgmt);
|
void qmSetMgmtFp(SMgmtWrapper *pWrapper);
|
||||||
void smSetMgmtFp(SMgmtWrapper *pWrapper);
|
void smSetMgmtFp(SMgmtWrapper *pWrapper);
|
||||||
void vmSetMgmtFp(SMgmtWrapper *pWrapper);
|
void vmSetMgmtFp(SMgmtWrapper *pWrapper);
|
||||||
void mmSetMgmtFp(SMgmtWrapper *pMgmt);
|
void mmSetMgmtFp(SMgmtWrapper *pWrapper);
|
||||||
|
|
||||||
void vmGetVnodeLoads(SMgmtWrapper *pWrapper, SMonVloadInfo *pInfo);
|
void vmGetVnodeLoads(SMgmtWrapper *pWrapper, SMonVloadInfo *pInfo);
|
||||||
void mmGetMonitorInfo(SMgmtWrapper *pWrapper, SMonMmInfo *mmInfo);
|
void mmGetMonitorInfo(SMgmtWrapper *pWrapper, SMonMmInfo *mmInfo);
|
||||||
|
@ -49,34 +75,6 @@ void qmGetMonitorInfo(SMgmtWrapper *pWrapper, SMonQmInfo *qmInfo);
|
||||||
void smGetMonitorInfo(SMgmtWrapper *pWrapper, SMonSmInfo *smInfo);
|
void smGetMonitorInfo(SMgmtWrapper *pWrapper, SMonSmInfo *smInfo);
|
||||||
void bmGetMonitorInfo(SMgmtWrapper *pWrapper, SMonBmInfo *bmInfo);
|
void bmGetMonitorInfo(SMgmtWrapper *pWrapper, SMonBmInfo *bmInfo);
|
||||||
|
|
||||||
// dmFile.c
|
|
||||||
int32_t dmReadFile(SDnodeData *pMgmt);
|
|
||||||
int32_t dmWriteFile(SDnodeData *pMgmt);
|
|
||||||
void dmUpdateDnodeEps(SDnodeData *pMgmt, SArray *pDnodeEps);
|
|
||||||
|
|
||||||
// dmHandle.c
|
|
||||||
void dmSendStatusReq(SDnode *pDnode);
|
|
||||||
int32_t dmProcessConfigReq(SDnode *pDnode, SNodeMsg *pMsg);
|
|
||||||
int32_t dmProcessStatusRsp(SDnode *pDnode, SNodeMsg *pMsg);
|
|
||||||
int32_t dmProcessAuthRsp(SDnode *pDnode, SNodeMsg *pMsg);
|
|
||||||
int32_t dmProcessGrantRsp(SDnode *pDnode, SNodeMsg *pMsg);
|
|
||||||
int32_t dmProcessCDnodeReq(SDnode *pDnode, SNodeMsg *pMsg);
|
|
||||||
|
|
||||||
// dmMonitor.c
|
|
||||||
void dmGetVnodeLoads(SMgmtWrapper *pWrapper, SMonVloadInfo *pInfo);
|
|
||||||
void dmSendMonitorReport(SDnode *pDnode);
|
|
||||||
|
|
||||||
// dmWorker.c
|
|
||||||
int32_t dmStartStatusThread(SDnode *pDnode);
|
|
||||||
void dmStopStatusThread(SDnode *pDnode);
|
|
||||||
int32_t dmStartMonitorThread(SDnode *pDnode);
|
|
||||||
void dmStopMonitorThread(SDnode *pDnode);
|
|
||||||
|
|
||||||
int32_t dmStartWorker(SDnode *pDnode);
|
|
||||||
void dmStopWorker(SDnode *pDnode);
|
|
||||||
int32_t dmProcessMgmtMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg);
|
|
||||||
int32_t dmProcessStatusMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -16,15 +16,14 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "dmImp.h"
|
#include "dmImp.h"
|
||||||
|
|
||||||
static void dmPrintDnodes(SDnodeData *pMgmt);
|
static void dmPrintEps(SDnode *pDnode);
|
||||||
static bool dmIsEpChanged(SDnodeData *pMgmt, int32_t dnodeId, const char *ep);
|
static bool dmIsEpChanged(SDnode *pDnode, int32_t dnodeId, const char *ep);
|
||||||
static void dmResetDnodes(SDnodeData *pMgmt, SArray *dnodeEps);
|
static void dmResetEps(SDnode *pDnode, SArray *dnodeEps);
|
||||||
|
|
||||||
void dmGetDnodeEp(SMgmtWrapper *pWrapper, int32_t dnodeId, char *pEp, char *pFqdn, uint16_t *pPort) {
|
static void dmGetDnodeEp(SDnode *pDnode, int32_t dnodeId, char *pEp, char *pFqdn, uint16_t *pPort) {
|
||||||
SDnodeData *pMgmt = pWrapper->pMgmt;
|
taosRLockLatch(&pDnode->data.latch);
|
||||||
taosRLockLatch(&pMgmt->latch);
|
|
||||||
|
|
||||||
SDnodeEp *pDnodeEp = taosHashGet(pMgmt->dnodeHash, &dnodeId, sizeof(int32_t));
|
SDnodeEp *pDnodeEp = taosHashGet(pDnode->data.dnodeHash, &dnodeId, sizeof(int32_t));
|
||||||
if (pDnodeEp != NULL) {
|
if (pDnodeEp != NULL) {
|
||||||
if (pPort != NULL) {
|
if (pPort != NULL) {
|
||||||
*pPort = pDnodeEp->ep.port;
|
*pPort = pDnodeEp->ep.port;
|
||||||
|
@ -37,10 +36,10 @@ void dmGetDnodeEp(SMgmtWrapper *pWrapper, int32_t dnodeId, char *pEp, char *pFqd
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
taosRUnLockLatch(&pMgmt->latch);
|
taosRUnLockLatch(&pDnode->data.latch);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t dmReadFile(SDnodeData *pMgmt) {
|
int32_t dmReadEps(SDnode *pDnode) {
|
||||||
int32_t code = TSDB_CODE_INVALID_JSON_FORMAT;
|
int32_t code = TSDB_CODE_INVALID_JSON_FORMAT;
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
int32_t maxLen = 256 * 1024;
|
int32_t maxLen = 256 * 1024;
|
||||||
|
@ -48,15 +47,14 @@ int32_t dmReadFile(SDnodeData *pMgmt) {
|
||||||
cJSON *root = NULL;
|
cJSON *root = NULL;
|
||||||
char file[PATH_MAX];
|
char file[PATH_MAX];
|
||||||
TdFilePtr pFile = NULL;
|
TdFilePtr pFile = NULL;
|
||||||
SDnode *pDnode = pMgmt->pDnode;
|
|
||||||
|
|
||||||
pMgmt->dnodeEps = taosArrayInit(1, sizeof(SDnodeEp));
|
pDnode->data.dnodeEps = taosArrayInit(1, sizeof(SDnodeEp));
|
||||||
if (pMgmt->dnodeEps == NULL) {
|
if (pDnode->data.dnodeEps == NULL) {
|
||||||
dError("failed to calloc dnodeEp array since %s", strerror(errno));
|
dError("failed to calloc dnodeEp array since %s", strerror(errno));
|
||||||
goto PRASE_DNODE_OVER;
|
goto PRASE_DNODE_OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(file, sizeof(file), "%s%sdnode.json", pMgmt->path, TD_DIRSEP);
|
snprintf(file, sizeof(file), "%s%sdnode.json", pDnode->data.path, TD_DIRSEP);
|
||||||
pFile = taosOpenFile(file, TD_FILE_READ);
|
pFile = taosOpenFile(file, TD_FILE_READ);
|
||||||
if (pFile == NULL) {
|
if (pFile == NULL) {
|
||||||
dDebug("file %s not exist", file);
|
dDebug("file %s not exist", file);
|
||||||
|
@ -146,41 +144,39 @@ int32_t dmReadFile(SDnodeData *pMgmt) {
|
||||||
}
|
}
|
||||||
dnodeEp.isMnode = isMnode->valueint;
|
dnodeEp.isMnode = isMnode->valueint;
|
||||||
|
|
||||||
taosArrayPush(pMgmt->dnodeEps, &dnodeEp);
|
taosArrayPush(pDnode->data.dnodeEps, &dnodeEp);
|
||||||
}
|
}
|
||||||
|
|
||||||
code = 0;
|
code = 0;
|
||||||
dDebug("succcessed to read file %s", file);
|
dDebug("succcessed to read file %s", file);
|
||||||
dmPrintDnodes(pMgmt);
|
dmPrintEps(pDnode);
|
||||||
|
|
||||||
PRASE_DNODE_OVER:
|
PRASE_DNODE_OVER:
|
||||||
if (content != NULL) taosMemoryFree(content);
|
if (content != NULL) taosMemoryFree(content);
|
||||||
if (root != NULL) cJSON_Delete(root);
|
if (root != NULL) cJSON_Delete(root);
|
||||||
if (pFile != NULL) taosCloseFile(&pFile);
|
if (pFile != NULL) taosCloseFile(&pFile);
|
||||||
|
|
||||||
if (dmIsEpChanged(pMgmt, pDnode->data.dnodeId, pDnode->data.localEp)) {
|
if (dmIsEpChanged(pDnode, pDnode->data.dnodeId, pDnode->data.localEp)) {
|
||||||
dError("localEp %s different with %s and need reconfigured", pDnode->data.localEp, file);
|
dError("localEp %s different with %s and need reconfigured", pDnode->data.localEp, file);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosArrayGetSize(pMgmt->dnodeEps) == 0) {
|
if (taosArrayGetSize(pDnode->data.dnodeEps) == 0) {
|
||||||
SDnodeEp dnodeEp = {0};
|
SDnodeEp dnodeEp = {0};
|
||||||
dnodeEp.isMnode = 1;
|
dnodeEp.isMnode = 1;
|
||||||
taosGetFqdnPortFromEp(pDnode->data.firstEp, &dnodeEp.ep);
|
taosGetFqdnPortFromEp(pDnode->data.firstEp, &dnodeEp.ep);
|
||||||
taosArrayPush(pMgmt->dnodeEps, &dnodeEp);
|
taosArrayPush(pDnode->data.dnodeEps, &dnodeEp);
|
||||||
}
|
}
|
||||||
|
|
||||||
dmResetDnodes(pMgmt, pMgmt->dnodeEps);
|
dmResetEps(pDnode, pDnode->data.dnodeEps);
|
||||||
|
|
||||||
terrno = code;
|
terrno = code;
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t dmWriteFile(SDnodeData *pMgmt) {
|
int32_t dmWriteEps(SDnode *pDnode) {
|
||||||
SDnode *pDnode = pMgmt->pDnode;
|
|
||||||
|
|
||||||
char file[PATH_MAX];
|
char file[PATH_MAX];
|
||||||
snprintf(file, sizeof(file), "%s%sdnode.json.bak", pMgmt->path, TD_DIRSEP);
|
snprintf(file, sizeof(file), "%s%sdnode.json.bak", pDnode->data.path, TD_DIRSEP);
|
||||||
|
|
||||||
TdFilePtr pFile = taosOpenFile(file, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC);
|
TdFilePtr pFile = taosOpenFile(file, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC);
|
||||||
if (pFile == NULL) {
|
if (pFile == NULL) {
|
||||||
|
@ -199,9 +195,9 @@ int32_t dmWriteFile(SDnodeData *pMgmt) {
|
||||||
len += snprintf(content + len, maxLen - len, " \"dropped\": %d,\n", pDnode->data.dropped);
|
len += snprintf(content + len, maxLen - len, " \"dropped\": %d,\n", pDnode->data.dropped);
|
||||||
len += snprintf(content + len, maxLen - len, " \"dnodes\": [{\n");
|
len += snprintf(content + len, maxLen - len, " \"dnodes\": [{\n");
|
||||||
|
|
||||||
int32_t numOfEps = (int32_t)taosArrayGetSize(pMgmt->dnodeEps);
|
int32_t numOfEps = (int32_t)taosArrayGetSize(pDnode->data.dnodeEps);
|
||||||
for (int32_t i = 0; i < numOfEps; ++i) {
|
for (int32_t i = 0; i < numOfEps; ++i) {
|
||||||
SDnodeEp *pDnodeEp = taosArrayGet(pMgmt->dnodeEps, i);
|
SDnodeEp *pDnodeEp = taosArrayGet(pDnode->data.dnodeEps, i);
|
||||||
len += snprintf(content + len, maxLen - len, " \"id\": %d,\n", pDnodeEp->id);
|
len += snprintf(content + len, maxLen - len, " \"id\": %d,\n", pDnodeEp->id);
|
||||||
len += snprintf(content + len, maxLen - len, " \"fqdn\": \"%s\",\n", pDnodeEp->ep.fqdn);
|
len += snprintf(content + len, maxLen - len, " \"fqdn\": \"%s\",\n", pDnodeEp->ep.fqdn);
|
||||||
len += snprintf(content + len, maxLen - len, " \"port\": %u,\n", pDnodeEp->ep.port);
|
len += snprintf(content + len, maxLen - len, " \"port\": %u,\n", pDnodeEp->ep.port);
|
||||||
|
@ -220,7 +216,7 @@ int32_t dmWriteFile(SDnodeData *pMgmt) {
|
||||||
taosMemoryFree(content);
|
taosMemoryFree(content);
|
||||||
|
|
||||||
char realfile[PATH_MAX];
|
char realfile[PATH_MAX];
|
||||||
snprintf(realfile, sizeof(realfile), "%s%sdnode.json", pMgmt->path, TD_DIRSEP);
|
snprintf(realfile, sizeof(realfile), "%s%sdnode.json", pDnode->data.path, TD_DIRSEP);
|
||||||
|
|
||||||
if (taosRenameFile(file, realfile) != 0) {
|
if (taosRenameFile(file, realfile) != 0) {
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
@ -228,41 +224,41 @@ int32_t dmWriteFile(SDnodeData *pMgmt) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
pMgmt->updateTime = taosGetTimestampMs();
|
pDnode->data.updateTime = taosGetTimestampMs();
|
||||||
dDebug("successed to write %s", realfile);
|
dDebug("successed to write %s", realfile);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dmUpdateDnodeEps(SDnodeData *pMgmt, SArray *dnodeEps) {
|
void dmUpdateEps(SDnode *pDnode, SArray *eps) {
|
||||||
int32_t numOfEps = taosArrayGetSize(dnodeEps);
|
int32_t numOfEps = taosArrayGetSize(eps);
|
||||||
if (numOfEps <= 0) return;
|
if (numOfEps <= 0) return;
|
||||||
|
|
||||||
taosWLockLatch(&pMgmt->latch);
|
taosWLockLatch(&pDnode->data.latch);
|
||||||
|
|
||||||
int32_t numOfEpsOld = (int32_t)taosArrayGetSize(pMgmt->dnodeEps);
|
int32_t numOfEpsOld = (int32_t)taosArrayGetSize(pDnode->data.dnodeEps);
|
||||||
if (numOfEps != numOfEpsOld) {
|
if (numOfEps != numOfEpsOld) {
|
||||||
dmResetDnodes(pMgmt, dnodeEps);
|
dmResetEps(pDnode, eps);
|
||||||
dmWriteFile(pMgmt);
|
dmWriteEps(pDnode);
|
||||||
} else {
|
} else {
|
||||||
int32_t size = numOfEps * sizeof(SDnodeEp);
|
int32_t size = numOfEps * sizeof(SDnodeEp);
|
||||||
if (memcmp(pMgmt->dnodeEps->pData, dnodeEps->pData, size) != 0) {
|
if (memcmp(pDnode->data.dnodeEps->pData, eps->pData, size) != 0) {
|
||||||
dmResetDnodes(pMgmt, dnodeEps);
|
dmResetEps(pDnode, eps);
|
||||||
dmWriteFile(pMgmt);
|
dmWriteEps(pDnode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
taosWUnLockLatch(&pMgmt->latch);
|
taosWUnLockLatch(&pDnode->data.latch);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dmResetDnodes(SDnodeData *pMgmt, SArray *dnodeEps) {
|
static void dmResetEps(SDnode *pDnode, SArray *dnodeEps) {
|
||||||
if (pMgmt->dnodeEps != dnodeEps) {
|
if (pDnode->data.dnodeEps != dnodeEps) {
|
||||||
SArray *tmp = pMgmt->dnodeEps;
|
SArray *tmp = pDnode->data.dnodeEps;
|
||||||
pMgmt->dnodeEps = taosArrayDup(dnodeEps);
|
pDnode->data.dnodeEps = taosArrayDup(dnodeEps);
|
||||||
taosArrayDestroy(tmp);
|
taosArrayDestroy(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
pMgmt->mnodeEpSet.inUse = 0;
|
pDnode->data.mnodeEps.inUse = 0;
|
||||||
pMgmt->mnodeEpSet.numOfEps = 0;
|
pDnode->data.mnodeEps.numOfEps = 0;
|
||||||
|
|
||||||
int32_t mIndex = 0;
|
int32_t mIndex = 0;
|
||||||
int32_t numOfEps = (int32_t)taosArrayGetSize(dnodeEps);
|
int32_t numOfEps = (int32_t)taosArrayGetSize(dnodeEps);
|
||||||
|
@ -271,40 +267,40 @@ static void dmResetDnodes(SDnodeData *pMgmt, SArray *dnodeEps) {
|
||||||
SDnodeEp *pDnodeEp = taosArrayGet(dnodeEps, i);
|
SDnodeEp *pDnodeEp = taosArrayGet(dnodeEps, i);
|
||||||
if (!pDnodeEp->isMnode) continue;
|
if (!pDnodeEp->isMnode) continue;
|
||||||
if (mIndex >= TSDB_MAX_REPLICA) continue;
|
if (mIndex >= TSDB_MAX_REPLICA) continue;
|
||||||
pMgmt->mnodeEpSet.numOfEps++;
|
pDnode->data.mnodeEps.numOfEps++;
|
||||||
|
|
||||||
pMgmt->mnodeEpSet.eps[mIndex] = pDnodeEp->ep;
|
pDnode->data.mnodeEps.eps[mIndex] = pDnodeEp->ep;
|
||||||
mIndex++;
|
mIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfEps; i++) {
|
for (int32_t i = 0; i < numOfEps; i++) {
|
||||||
SDnodeEp *pDnodeEp = taosArrayGet(dnodeEps, i);
|
SDnodeEp *pDnodeEp = taosArrayGet(dnodeEps, i);
|
||||||
taosHashPut(pMgmt->dnodeHash, &pDnodeEp->id, sizeof(int32_t), pDnodeEp, sizeof(SDnodeEp));
|
taosHashPut(pDnode->data.dnodeHash, &pDnodeEp->id, sizeof(int32_t), pDnodeEp, sizeof(SDnodeEp));
|
||||||
}
|
}
|
||||||
|
|
||||||
dmPrintDnodes(pMgmt);
|
dmPrintEps(pDnode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dmPrintDnodes(SDnodeData *pMgmt) {
|
static void dmPrintEps(SDnode *pDnode) {
|
||||||
int32_t numOfEps = (int32_t)taosArrayGetSize(pMgmt->dnodeEps);
|
int32_t numOfEps = (int32_t)taosArrayGetSize(pDnode->data.dnodeEps);
|
||||||
dDebug("print dnode ep list, num:%d", numOfEps);
|
dDebug("print dnode ep list, num:%d", numOfEps);
|
||||||
for (int32_t i = 0; i < numOfEps; i++) {
|
for (int32_t i = 0; i < numOfEps; i++) {
|
||||||
SDnodeEp *pEp = taosArrayGet(pMgmt->dnodeEps, i);
|
SDnodeEp *pEp = taosArrayGet(pDnode->data.dnodeEps, i);
|
||||||
dDebug("dnode:%d, fqdn:%s port:%u isMnode:%d", pEp->id, pEp->ep.fqdn, pEp->ep.port, pEp->isMnode);
|
dDebug("dnode:%d, fqdn:%s port:%u isMnode:%d", pEp->id, pEp->ep.fqdn, pEp->ep.port, pEp->isMnode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool dmIsEpChanged(SDnodeData *pMgmt, int32_t dnodeId, const char *ep) {
|
static bool dmIsEpChanged(SDnode *pDnode, int32_t dnodeId, const char *ep) {
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
taosRLockLatch(&pMgmt->latch);
|
taosRLockLatch(&pDnode->data.latch);
|
||||||
|
|
||||||
SDnodeEp *pDnodeEp = taosHashGet(pMgmt->dnodeHash, &dnodeId, sizeof(int32_t));
|
SDnodeEp *pDnodeEp = taosHashGet(pDnode->data.dnodeHash, &dnodeId, sizeof(int32_t));
|
||||||
if (pDnodeEp != NULL) {
|
if (pDnodeEp != NULL) {
|
||||||
char epstr[TSDB_EP_LEN + 1];
|
char epstr[TSDB_EP_LEN + 1];
|
||||||
snprintf(epstr, TSDB_EP_LEN, "%s:%u", pDnodeEp->ep.fqdn, pDnodeEp->ep.port);
|
snprintf(epstr, TSDB_EP_LEN, "%s:%u", pDnodeEp->ep.fqdn, pDnodeEp->ep.port);
|
||||||
changed = strcmp(ep, epstr) != 0;
|
changed = strcmp(ep, epstr) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosRUnLockLatch(&pMgmt->latch);
|
taosRUnLockLatch(&pDnode->data.latch);
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "dmImp.h"
|
#include "dmImp.h"
|
||||||
|
|
||||||
static bool dndRequireNode(SMgmtWrapper *pWrapper) {
|
static bool dmRequireNode(SMgmtWrapper *pWrapper) {
|
||||||
bool required = false;
|
bool required = false;
|
||||||
int32_t code = (*pWrapper->fp.requiredFp)(pWrapper, &required);
|
int32_t code = (*pWrapper->fp.requiredFp)(pWrapper, &required);
|
||||||
if (!required) {
|
if (!required) {
|
||||||
|
@ -27,7 +27,7 @@ static bool dndRequireNode(SMgmtWrapper *pWrapper) {
|
||||||
return required;
|
return required;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t dndInitNodeProc(SMgmtWrapper *pWrapper) {
|
static int32_t dmInitNodeProc(SMgmtWrapper *pWrapper) {
|
||||||
int32_t shmsize = tsMnodeShmSize;
|
int32_t shmsize = tsMnodeShmSize;
|
||||||
if (pWrapper->ntype == VNODE) {
|
if (pWrapper->ntype == VNODE) {
|
||||||
shmsize = tsVnodeShmSize;
|
shmsize = tsVnodeShmSize;
|
||||||
|
@ -50,7 +50,7 @@ static int32_t dndInitNodeProc(SMgmtWrapper *pWrapper) {
|
||||||
}
|
}
|
||||||
dInfo("node:%s, shm:%d is created, size:%d", pWrapper->name, pWrapper->procShm.id, shmsize);
|
dInfo("node:%s, shm:%d is created, size:%d", pWrapper->name, pWrapper->procShm.id, shmsize);
|
||||||
|
|
||||||
SProcCfg cfg = dndGenProcCfg(pWrapper);
|
SProcCfg cfg = dmGenProcCfg(pWrapper);
|
||||||
cfg.isChild = false;
|
cfg.isChild = false;
|
||||||
pWrapper->procType = DND_PROC_PARENT;
|
pWrapper->procType = DND_PROC_PARENT;
|
||||||
pWrapper->procObj = taosProcInit(&cfg);
|
pWrapper->procObj = taosProcInit(&cfg);
|
||||||
|
@ -62,7 +62,7 @@ static int32_t dndInitNodeProc(SMgmtWrapper *pWrapper) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t dndNewNodeProc(SMgmtWrapper *pWrapper, EDndNodeType n) {
|
static int32_t dmNewNodeProc(SMgmtWrapper *pWrapper, EDndNodeType n) {
|
||||||
char tstr[8] = {0};
|
char tstr[8] = {0};
|
||||||
char *args[6] = {0};
|
char *args[6] = {0};
|
||||||
snprintf(tstr, sizeof(tstr), "%d", n);
|
snprintf(tstr, sizeof(tstr), "%d", n);
|
||||||
|
@ -84,11 +84,11 @@ static int32_t dndNewNodeProc(SMgmtWrapper *pWrapper, EDndNodeType n) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t dndRunNodeProc(SMgmtWrapper *pWrapper) {
|
static int32_t dmRunNodeProc(SMgmtWrapper *pWrapper) {
|
||||||
if (pWrapper->pDnode->ntype == NODE_END) {
|
if (pWrapper->pDnode->ntype == NODE_END) {
|
||||||
dInfo("node:%s, should be started manually", pWrapper->name);
|
dInfo("node:%s, should be started manually", pWrapper->name);
|
||||||
} else {
|
} else {
|
||||||
if (dndNewNodeProc(pWrapper, pWrapper->ntype) != 0) {
|
if (dmNewNodeProc(pWrapper, pWrapper->ntype) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ static int32_t dndRunNodeProc(SMgmtWrapper *pWrapper) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t dndOpenNodeImp(SMgmtWrapper *pWrapper) {
|
static int32_t dmOpenNodeImp(SMgmtWrapper *pWrapper) {
|
||||||
if (taosMkDir(pWrapper->path) != 0) {
|
if (taosMkDir(pWrapper->path) != 0) {
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
dError("node:%s, failed to create dir:%s since %s", pWrapper->name, pWrapper->path, terrstr());
|
dError("node:%s, failed to create dir:%s since %s", pWrapper->name, pWrapper->path, terrstr());
|
||||||
|
@ -118,19 +118,19 @@ static int32_t dndOpenNodeImp(SMgmtWrapper *pWrapper) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t dndOpenNode(SMgmtWrapper *pWrapper) {
|
int32_t dmOpenNode(SMgmtWrapper *pWrapper) {
|
||||||
SDnode *pDnode = pWrapper->pDnode;
|
SDnode *pDnode = pWrapper->pDnode;
|
||||||
if (pDnode->ptype == DND_PROC_SINGLE) {
|
if (pDnode->ptype == DND_PROC_SINGLE) {
|
||||||
return dndOpenNodeImp(pWrapper);
|
return dmOpenNodeImp(pWrapper);
|
||||||
} else if (pDnode->ptype == DND_PROC_PARENT) {
|
} else if (pDnode->ptype == DND_PROC_PARENT) {
|
||||||
if (dndInitNodeProc(pWrapper) != 0) return -1;
|
if (dmInitNodeProc(pWrapper) != 0) return -1;
|
||||||
if (dndWriteShmFile(pDnode) != 0) return -1;
|
if (dmWriteShmFile(pDnode) != 0) return -1;
|
||||||
if (dndRunNodeProc(pWrapper) != 0) return -1;
|
if (dmRunNodeProc(pWrapper) != 0) return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dndCloseNodeImp(SMgmtWrapper *pWrapper) {
|
static void dmCloseNodeImp(SMgmtWrapper *pWrapper) {
|
||||||
dDebug("node:%s, mgmt start to close", pWrapper->name);
|
dDebug("node:%s, mgmt start to close", pWrapper->name);
|
||||||
pWrapper->required = false;
|
pWrapper->required = false;
|
||||||
taosWLockLatch(&pWrapper->latch);
|
taosWLockLatch(&pWrapper->latch);
|
||||||
|
@ -151,7 +151,7 @@ static void dndCloseNodeImp(SMgmtWrapper *pWrapper) {
|
||||||
dDebug("node:%s, mgmt has been closed", pWrapper->name);
|
dDebug("node:%s, mgmt has been closed", pWrapper->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dndCloseNode(SMgmtWrapper *pWrapper) {
|
void dmCloseNode(SMgmtWrapper *pWrapper) {
|
||||||
if (pWrapper->pDnode->ptype == DND_PROC_PARENT) {
|
if (pWrapper->pDnode->ptype == DND_PROC_PARENT) {
|
||||||
if (pWrapper->procId > 0 && taosProcExist(pWrapper->procId)) {
|
if (pWrapper->procId > 0 && taosProcExist(pWrapper->procId)) {
|
||||||
dInfo("node:%s, send kill signal to the child process:%d", pWrapper->name, pWrapper->procId);
|
dInfo("node:%s, send kill signal to the child process:%d", pWrapper->name, pWrapper->procId);
|
||||||
|
@ -161,31 +161,31 @@ void dndCloseNode(SMgmtWrapper *pWrapper) {
|
||||||
dInfo("node:%s, child process:%d is stopped", pWrapper->name, pWrapper->procId);
|
dInfo("node:%s, child process:%d is stopped", pWrapper->name, pWrapper->procId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dndCloseNodeImp(pWrapper);
|
dmCloseNodeImp(pWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dndProcessProcHandle(void *handle) {
|
static void dmProcessProcHandle(void *handle) {
|
||||||
dWarn("handle:%p, the child process dies and send an offline rsp", handle);
|
dWarn("handle:%p, the child process dies and send an offline rsp", handle);
|
||||||
SRpcMsg rpcMsg = {.handle = handle, .code = TSDB_CODE_NODE_OFFLINE};
|
SRpcMsg rpcMsg = {.handle = handle, .code = TSDB_CODE_NODE_OFFLINE};
|
||||||
rpcSendResponse(&rpcMsg);
|
rpcSendResponse(&rpcMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t dndRunInSingleProcess(SDnode *pDnode) {
|
static int32_t dmRunInSingleProcess(SDnode *pDnode) {
|
||||||
dInfo("dnode run in single process");
|
dInfo("dnode run in single process");
|
||||||
pDnode->ptype = DND_PROC_SINGLE;
|
pDnode->ptype = DND_PROC_SINGLE;
|
||||||
|
|
||||||
for (EDndNodeType n = NODE_BEGIN; n < NODE_END; ++n) {
|
for (EDndNodeType n = NODE_BEGIN; n < NODE_END; ++n) {
|
||||||
SMgmtWrapper *pWrapper = &pDnode->wrappers[n];
|
SMgmtWrapper *pWrapper = &pDnode->wrappers[n];
|
||||||
pWrapper->required = dndRequireNode(pWrapper);
|
pWrapper->required = dmRequireNode(pWrapper);
|
||||||
if (!pWrapper->required) continue;
|
if (!pWrapper->required) continue;
|
||||||
|
|
||||||
if (dndOpenNodeImp(pWrapper) != 0) {
|
if (dmOpenNodeImp(pWrapper) != 0) {
|
||||||
dError("node:%s, failed to start since %s", pWrapper->name, terrstr());
|
dError("node:%s, failed to start since %s", pWrapper->name, terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dndSetStatus(pDnode, DND_STAT_RUNNING);
|
dmSetStatus(pDnode, DND_STAT_RUNNING);
|
||||||
|
|
||||||
for (EDndNodeType n = 0; n < NODE_END; ++n) {
|
for (EDndNodeType n = 0; n < NODE_END; ++n) {
|
||||||
SMgmtWrapper *pWrapper = &pDnode->wrappers[n];
|
SMgmtWrapper *pWrapper = &pDnode->wrappers[n];
|
||||||
|
@ -198,11 +198,11 @@ static int32_t dndRunInSingleProcess(SDnode *pDnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
dInfo("TDengine initialized successfully");
|
dInfo("TDengine initialized successfully");
|
||||||
dndReportStartup(pDnode, "TDengine", "initialized successfully");
|
dmReportStartup(pDnode, "TDengine", "initialized successfully");
|
||||||
while (1) {
|
while (1) {
|
||||||
if (pDnode->event == DND_EVENT_STOP) {
|
if (pDnode->event == DND_EVENT_STOP) {
|
||||||
dInfo("dnode is about to stop");
|
dInfo("dnode is about to stop");
|
||||||
dndSetStatus(pDnode, DND_STAT_STOPPED);
|
dmSetStatus(pDnode, DND_STAT_STOPPED);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
taosMsleep(100);
|
taosMsleep(100);
|
||||||
|
@ -211,24 +211,24 @@ static int32_t dndRunInSingleProcess(SDnode *pDnode) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t dndRunInParentProcess(SDnode *pDnode) {
|
static int32_t dmRunInParentProcess(SDnode *pDnode) {
|
||||||
dInfo("dnode run in parent process");
|
dInfo("dnode run in parent process");
|
||||||
pDnode->ptype = DND_PROC_PARENT;
|
pDnode->ptype = DND_PROC_PARENT;
|
||||||
|
|
||||||
SMgmtWrapper *pDWrapper = &pDnode->wrappers[NODE_BEGIN];
|
SMgmtWrapper *pDWrapper = &pDnode->wrappers[NODE_BEGIN];
|
||||||
if (dndOpenNodeImp(pDWrapper) != 0) {
|
if (dmOpenNodeImp(pDWrapper) != 0) {
|
||||||
dError("node:%s, failed to start since %s", pDWrapper->name, terrstr());
|
dError("node:%s, failed to start since %s", pDWrapper->name, terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (EDndNodeType n = NODE_BEGIN + 1; n < NODE_END; ++n) {
|
for (EDndNodeType n = NODE_BEGIN + 1; n < NODE_END; ++n) {
|
||||||
SMgmtWrapper *pWrapper = &pDnode->wrappers[n];
|
SMgmtWrapper *pWrapper = &pDnode->wrappers[n];
|
||||||
pWrapper->required = dndRequireNode(pWrapper);
|
pWrapper->required = dmRequireNode(pWrapper);
|
||||||
if (!pWrapper->required) continue;
|
if (!pWrapper->required) continue;
|
||||||
if (dndInitNodeProc(pWrapper) != 0) return -1;
|
if (dmInitNodeProc(pWrapper) != 0) return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dndWriteShmFile(pDnode) != 0) {
|
if (dmWriteShmFile(pDnode) != 0) {
|
||||||
dError("failed to write runtime file since %s", terrstr());
|
dError("failed to write runtime file since %s", terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -236,10 +236,10 @@ static int32_t dndRunInParentProcess(SDnode *pDnode) {
|
||||||
for (EDndNodeType n = NODE_BEGIN + 1; n < NODE_END; ++n) {
|
for (EDndNodeType n = NODE_BEGIN + 1; n < NODE_END; ++n) {
|
||||||
SMgmtWrapper *pWrapper = &pDnode->wrappers[n];
|
SMgmtWrapper *pWrapper = &pDnode->wrappers[n];
|
||||||
if (!pWrapper->required) continue;
|
if (!pWrapper->required) continue;
|
||||||
if (dndRunNodeProc(pWrapper) != 0) return -1;
|
if (dmRunNodeProc(pWrapper) != 0) return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
dndSetStatus(pDnode, DND_STAT_RUNNING);
|
dmSetStatus(pDnode, DND_STAT_RUNNING);
|
||||||
|
|
||||||
if ((*pDWrapper->fp.startFp)(pDWrapper) != 0) {
|
if ((*pDWrapper->fp.startFp)(pDWrapper) != 0) {
|
||||||
dError("node:%s, failed to start since %s", pDWrapper->name, terrstr());
|
dError("node:%s, failed to start since %s", pDWrapper->name, terrstr());
|
||||||
|
@ -247,12 +247,12 @@ static int32_t dndRunInParentProcess(SDnode *pDnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
dInfo("TDengine initialized successfully");
|
dInfo("TDengine initialized successfully");
|
||||||
dndReportStartup(pDnode, "TDengine", "initialized successfully");
|
dmReportStartup(pDnode, "TDengine", "initialized successfully");
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (pDnode->event == DND_EVENT_STOP) {
|
if (pDnode->event == DND_EVENT_STOP) {
|
||||||
dInfo("dnode is about to stop");
|
dInfo("dnode is about to stop");
|
||||||
dndSetStatus(pDnode, DND_STAT_STOPPED);
|
dmSetStatus(pDnode, DND_STAT_STOPPED);
|
||||||
|
|
||||||
for (EDndNodeType n = NODE_BEGIN + 1; n < NODE_END; ++n) {
|
for (EDndNodeType n = NODE_BEGIN + 1; n < NODE_END; ++n) {
|
||||||
SMgmtWrapper *pWrapper = &pDnode->wrappers[n];
|
SMgmtWrapper *pWrapper = &pDnode->wrappers[n];
|
||||||
|
@ -276,8 +276,8 @@ static int32_t dndRunInParentProcess(SDnode *pDnode) {
|
||||||
|
|
||||||
if (pWrapper->procId <= 0 || !taosProcExist(pWrapper->procId)) {
|
if (pWrapper->procId <= 0 || !taosProcExist(pWrapper->procId)) {
|
||||||
dWarn("node:%s, process:%d is killed and needs to be restarted", pWrapper->name, pWrapper->procId);
|
dWarn("node:%s, process:%d is killed and needs to be restarted", pWrapper->name, pWrapper->procId);
|
||||||
taosProcCloseHandles(pWrapper->procObj, dndProcessProcHandle);
|
taosProcCloseHandles(pWrapper->procObj, dmProcessProcHandle);
|
||||||
dndNewNodeProc(pWrapper, n);
|
dmNewNodeProc(pWrapper, n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -288,12 +288,12 @@ static int32_t dndRunInParentProcess(SDnode *pDnode) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t dndRunInChildProcess(SDnode *pDnode) {
|
static int32_t dmRunInChildProcess(SDnode *pDnode) {
|
||||||
SMgmtWrapper *pWrapper = &pDnode->wrappers[pDnode->ntype];
|
SMgmtWrapper *pWrapper = &pDnode->wrappers[pDnode->ntype];
|
||||||
dInfo("%s run in child process", pWrapper->name);
|
dInfo("%s run in child process", pWrapper->name);
|
||||||
pDnode->ptype = DND_PROC_CHILD;
|
pDnode->ptype = DND_PROC_CHILD;
|
||||||
|
|
||||||
pWrapper->required = dndRequireNode(pWrapper);
|
pWrapper->required = dmRequireNode(pWrapper);
|
||||||
if (!pWrapper->required) {
|
if (!pWrapper->required) {
|
||||||
dError("%s does not require startup", pWrapper->name);
|
dError("%s does not require startup", pWrapper->name);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -303,12 +303,12 @@ static int32_t dndRunInChildProcess(SDnode *pDnode) {
|
||||||
tmsgSetDefaultMsgCb(&msgCb);
|
tmsgSetDefaultMsgCb(&msgCb);
|
||||||
pWrapper->procType = DND_PROC_CHILD;
|
pWrapper->procType = DND_PROC_CHILD;
|
||||||
|
|
||||||
if (dndOpenNodeImp(pWrapper) != 0) {
|
if (dmOpenNodeImp(pWrapper) != 0) {
|
||||||
dError("node:%s, failed to start since %s", pWrapper->name, terrstr());
|
dError("node:%s, failed to start since %s", pWrapper->name, terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SProcCfg cfg = dndGenProcCfg(pWrapper);
|
SProcCfg cfg = dmGenProcCfg(pWrapper);
|
||||||
cfg.isChild = true;
|
cfg.isChild = true;
|
||||||
pWrapper->procObj = taosProcInit(&cfg);
|
pWrapper->procObj = taosProcInit(&cfg);
|
||||||
if (pWrapper->procObj == NULL) {
|
if (pWrapper->procObj == NULL) {
|
||||||
|
@ -323,7 +323,7 @@ static int32_t dndRunInChildProcess(SDnode *pDnode) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dndSetStatus(pDnode, DND_STAT_RUNNING);
|
dmSetStatus(pDnode, DND_STAT_RUNNING);
|
||||||
|
|
||||||
if (taosProcRun(pWrapper->procObj) != 0) {
|
if (taosProcRun(pWrapper->procObj) != 0) {
|
||||||
dError("node:%s, failed to run proc since %s", pWrapper->name, terrstr());
|
dError("node:%s, failed to run proc since %s", pWrapper->name, terrstr());
|
||||||
|
@ -331,11 +331,11 @@ static int32_t dndRunInChildProcess(SDnode *pDnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
dInfo("TDengine initialized successfully");
|
dInfo("TDengine initialized successfully");
|
||||||
dndReportStartup(pDnode, "TDengine", "initialized successfully");
|
dmReportStartup(pDnode, "TDengine", "initialized successfully");
|
||||||
while (1) {
|
while (1) {
|
||||||
if (pDnode->event == DND_EVENT_STOP) {
|
if (pDnode->event == DND_EVENT_STOP) {
|
||||||
dInfo("%s is about to stop", pWrapper->name);
|
dInfo("%s is about to stop", pWrapper->name);
|
||||||
dndSetStatus(pDnode, DND_STAT_STOPPED);
|
dmSetStatus(pDnode, DND_STAT_STOPPED);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
taosMsleep(100);
|
taosMsleep(100);
|
||||||
|
@ -344,13 +344,13 @@ static int32_t dndRunInChildProcess(SDnode *pDnode) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t dndRun(SDnode *pDnode) {
|
int32_t dmRun(SDnode *pDnode) {
|
||||||
if (!tsMultiProcess) {
|
if (!tsMultiProcess) {
|
||||||
return dndRunInSingleProcess(pDnode);
|
return dmRunInSingleProcess(pDnode);
|
||||||
} else if (pDnode->ntype == NODE_BEGIN || pDnode->ntype == NODE_END) {
|
} else if (pDnode->ntype == NODE_BEGIN || pDnode->ntype == NODE_END) {
|
||||||
return dndRunInParentProcess(pDnode);
|
return dmRunInParentProcess(pDnode);
|
||||||
} else {
|
} else {
|
||||||
return dndRunInChildProcess(pDnode);
|
return dmRunInChildProcess(pDnode);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -16,22 +16,31 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "dmImp.h"
|
#include "dmImp.h"
|
||||||
|
|
||||||
static int32_t dmProcessStatusRsp(SDnode *pDnode, SRpcMsg *pRsp) {
|
static void dmUpdateDnodeCfg(SDnode *pDnode, SDnodeCfg *pCfg) {
|
||||||
SDnode *pDnode = pMgmt->pDnode;
|
if (pDnode->data.dnodeId == 0) {
|
||||||
|
dInfo("set dnodeId:%d clusterId:%" PRId64, pCfg->dnodeId, pCfg->clusterId);
|
||||||
|
taosWLockLatch(&pDnode->data.latch);
|
||||||
|
pDnode->data.dnodeId = pCfg->dnodeId;
|
||||||
|
pDnode->data.clusterId = pCfg->clusterId;
|
||||||
|
dmWriteEps(pDnode);
|
||||||
|
taosWUnLockLatch(&pDnode->data.latch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t dmProcessStatusRsp(SDnode *pDnode, SRpcMsg *pRsp) {
|
||||||
if (pRsp->code != TSDB_CODE_SUCCESS) {
|
if (pRsp->code != TSDB_CODE_SUCCESS) {
|
||||||
if (pRsp->code == TSDB_CODE_MND_DNODE_NOT_EXIST && !pDnode->data.dropped && pDnode->data.dnodeId > 0) {
|
if (pRsp->code == TSDB_CODE_MND_DNODE_NOT_EXIST && !pDnode->data.dropped && pDnode->data.dnodeId > 0) {
|
||||||
dInfo("dnode:%d, set to dropped since not exist in mnode", pDnode->data.dnodeId);
|
dInfo("dnode:%d, set to dropped since not exist in mnode", pDnode->data.dnodeId);
|
||||||
pDnode->data.dropped = 1;
|
pDnode->data.dropped = 1;
|
||||||
dmWriteFile(pMgmt);
|
dmWriteEps(pDnode);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SStatusRsp statusRsp = {0};
|
SStatusRsp statusRsp = {0};
|
||||||
if (pRsp->pCont != NULL && pRsp->contLen != 0 &&
|
if (pRsp->pCont != NULL && pRsp->contLen > 0 &&
|
||||||
tDeserializeSStatusRsp(pRsp->pCont, pRsp->contLen, &statusRsp) == 0) {
|
tDeserializeSStatusRsp(pRsp->pCont, pRsp->contLen, &statusRsp) == 0) {
|
||||||
pMgmt->dnodeVer = statusRsp.dnodeVer;
|
pDnode->data.dnodeVer = statusRsp.dnodeVer;
|
||||||
dmUpdateDnodeCfg(pMgmt, &statusRsp.dnodeCfg);
|
dmUpdateDnodeCfg(pDnode, &statusRsp.dnodeCfg);
|
||||||
dmUpdateDnodeEps(pMgmt, statusRsp.pDnodeEps);
|
dmUpdateEps(pDnode, statusRsp.pDnodeEps);
|
||||||
}
|
}
|
||||||
tFreeSStatusRsp(&statusRsp);
|
tFreeSStatusRsp(&statusRsp);
|
||||||
}
|
}
|
||||||
|
@ -44,11 +53,11 @@ void dmSendStatusReq(SDnode *pDnode) {
|
||||||
|
|
||||||
taosRLockLatch(&pDnode->data.latch);
|
taosRLockLatch(&pDnode->data.latch);
|
||||||
req.sver = tsVersion;
|
req.sver = tsVersion;
|
||||||
req.dnodeVer = pMgmt->dnodeVer;
|
req.dnodeVer = pDnode->data.dnodeVer;
|
||||||
req.dnodeId = pDnode->data.dnodeId;
|
req.dnodeId = pDnode->data.dnodeId;
|
||||||
req.clusterId = pDnode->data.clusterId;
|
req.clusterId = pDnode->data.clusterId;
|
||||||
req.rebootTime = pDnode->data.rebootTime;
|
req.rebootTime = pDnode->data.rebootTime;
|
||||||
req.updateTime = pMgmt->updateTime;
|
req.updateTime = pDnode->data.updateTime;
|
||||||
req.numOfCores = tsNumOfCores;
|
req.numOfCores = tsNumOfCores;
|
||||||
req.numOfSupportVnodes = pDnode->data.supportVnodes;
|
req.numOfSupportVnodes = pDnode->data.supportVnodes;
|
||||||
tstrncpy(req.dnodeEp, pDnode->data.localEp, TSDB_EP_LEN);
|
tstrncpy(req.dnodeEp, pDnode->data.localEp, TSDB_EP_LEN);
|
||||||
|
@ -62,68 +71,52 @@ void dmSendStatusReq(SDnode *pDnode) {
|
||||||
memcpy(req.clusterCfg.charset, tsCharset, TD_LOCALE_LEN);
|
memcpy(req.clusterCfg.charset, tsCharset, TD_LOCALE_LEN);
|
||||||
taosRUnLockLatch(&pDnode->data.latch);
|
taosRUnLockLatch(&pDnode->data.latch);
|
||||||
|
|
||||||
SMgmtWrapper *pWrapper = dndAcquireWrapper(pDnode, VNODE);
|
SMonVloadInfo info = {0};
|
||||||
if (pWrapper != NULL) {
|
dmGetVnodeLoads(pDnode, &info);
|
||||||
SMonVloadInfo info = {0};
|
req.pVloads = info.pVloads;
|
||||||
dmGetVnodeLoads(pWrapper, &info);
|
|
||||||
req.pVloads = info.pVloads;
|
|
||||||
dndReleaseWrapper(pWrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t contLen = tSerializeSStatusReq(NULL, 0, &req);
|
int32_t contLen = tSerializeSStatusReq(NULL, 0, &req);
|
||||||
void *pHead = rpcMallocCont(contLen);
|
void *pHead = rpcMallocCont(contLen);
|
||||||
tSerializeSStatusReq(pHead, contLen, &req);
|
tSerializeSStatusReq(pHead, contLen, &req);
|
||||||
taosArrayDestroy(req.pVloads);
|
tFreeSStatusReq(&req);
|
||||||
|
|
||||||
SRpcMsg rpcMsg = {.pCont = pHead, .contLen = contLen, .msgType = TDMT_MND_STATUS, .ahandle = (void *)0x9527};
|
SRpcMsg rpcMsg = {.pCont = pHead, .contLen = contLen, .msgType = TDMT_MND_STATUS, .ahandle = (void *)0x9527};
|
||||||
SRpcMsg rspMsg = {0};
|
SRpcMsg rpcRsp = {0};
|
||||||
|
|
||||||
dTrace("send req:%s to mnode, app:%p", TMSG_INFO(rpcMsg.msgType), rpcMsg.ahandle);
|
dTrace("send req:%s to mnode, app:%p", TMSG_INFO(rpcMsg.msgType), rpcMsg.ahandle);
|
||||||
dmSendToMnodeRecv(pDnode, rpcMsg, &rpcRsp);
|
dmSendToMnodeRecv(pDnode, &rpcMsg, &rpcRsp);
|
||||||
dmProcessStatusRsp(pDnode, &rpcRsp);
|
dmProcessStatusRsp(pDnode, &rpcRsp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dmUpdateDnodeCfg(SDnodeData *pMgmt, SDnodeCfg *pCfg) {
|
int32_t dmProcessAuthRsp(SDnode *pDnode, SNodeMsg *pMsg) {
|
||||||
SDnode *pDnode = pMgmt->pDnode;
|
|
||||||
|
|
||||||
if (pDnode->data.dnodeId == 0) {
|
|
||||||
dInfo("set dnodeId:%d clusterId:%" PRId64, pCfg->dnodeId, pCfg->clusterId);
|
|
||||||
taosWLockLatch(&pDnode->data.latch);
|
|
||||||
pDnode->data.dnodeId = pCfg->dnodeId;
|
|
||||||
pDnode->data.clusterId = pCfg->clusterId;
|
|
||||||
dmWriteFile(pMgmt);
|
|
||||||
taosWUnLockLatch(&pDnode->data.latch);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t dmProcessAuthRsp(SDnodeData *pMgmt, SNodeMsg *pMsg) {
|
|
||||||
SRpcMsg *pRsp = &pMsg->rpcMsg;
|
SRpcMsg *pRsp = &pMsg->rpcMsg;
|
||||||
dError("auth rsp is received, but not supported yet");
|
dError("auth rsp is received, but not supported yet");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t dmProcessGrantRsp(SDnodeData *pMgmt, SNodeMsg *pMsg) {
|
int32_t dmProcessGrantRsp(SDnode *pDnode, SNodeMsg *pMsg) {
|
||||||
SRpcMsg *pRsp = &pMsg->rpcMsg;
|
SRpcMsg *pRsp = &pMsg->rpcMsg;
|
||||||
dError("grant rsp is received, but not supported yet");
|
dError("grant rsp is received, but not supported yet");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t dmProcessConfigReq(SDnodeData *pMgmt, SNodeMsg *pMsg) {
|
int32_t dmProcessConfigReq(SDnode *pDnode, SNodeMsg *pMsg) {
|
||||||
SRpcMsg *pReq = &pMsg->rpcMsg;
|
SRpcMsg *pReq = &pMsg->rpcMsg;
|
||||||
SDCfgDnodeReq *pCfg = pReq->pCont;
|
SDCfgDnodeReq *pCfg = pReq->pCont;
|
||||||
dError("config req is received, but not supported yet");
|
dError("config req is received, but not supported yet");
|
||||||
return TSDB_CODE_OPS_NOT_SUPPORT;
|
return TSDB_CODE_OPS_NOT_SUPPORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t dmProcessCreateNodeMsg(SDnode *pDnode, EDndNodeType ntype, SNodeMsg *pMsg) {
|
int32_t dmProcessCreateNodeReq(SDnode *pDnode, EDndNodeType ntype, SNodeMsg *pMsg) {
|
||||||
SMgmtWrapper *pWrapper = dndAcquireWrapper(pDnode, ntype);
|
SMgmtWrapper *pWrapper = dmAcquireWrapper(pDnode, ntype);
|
||||||
if (pWrapper != NULL) {
|
if (pWrapper != NULL) {
|
||||||
dndReleaseWrapper(pWrapper);
|
dmReleaseWrapper(pWrapper);
|
||||||
terrno = TSDB_CODE_NODE_ALREADY_DEPLOYED;
|
terrno = TSDB_CODE_NODE_ALREADY_DEPLOYED;
|
||||||
dError("failed to create node since %s", terrstr());
|
dError("failed to create node since %s", terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
taosWLockLatch(&pDnode->wrapperLock);
|
||||||
pWrapper = &pDnode->wrappers[ntype];
|
pWrapper = &pDnode->wrappers[ntype];
|
||||||
|
|
||||||
if (taosMkDir(pWrapper->path) != 0) {
|
if (taosMkDir(pWrapper->path) != 0) {
|
||||||
|
@ -134,17 +127,20 @@ static int32_t dmProcessCreateNodeMsg(SDnode *pDnode, EDndNodeType ntype, SNodeM
|
||||||
|
|
||||||
int32_t code = (*pWrapper->fp.createFp)(pWrapper, pMsg);
|
int32_t code = (*pWrapper->fp.createFp)(pWrapper, pMsg);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
dError("node:%s, failed to open since %s", pWrapper->name, terrstr());
|
dError("node:%s, failed to create since %s", pWrapper->name, terrstr());
|
||||||
} else {
|
} else {
|
||||||
dDebug("node:%s, has been opened", pWrapper->name);
|
dDebug("node:%s, has been created", pWrapper->name);
|
||||||
|
pWrapper->required = true;
|
||||||
pWrapper->deployed = true;
|
pWrapper->deployed = true;
|
||||||
|
(void)dmOpenNode(pWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
taosWUnLockLatch(&pDnode->wrapperLock);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t dmProcessDropNodeMsg(SDnode *pDnode, EDndNodeType ntype, SNodeMsg *pMsg) {
|
int32_t dmProcessDropNodeReq(SDnode *pDnode, EDndNodeType ntype, SNodeMsg *pMsg) {
|
||||||
SMgmtWrapper *pWrapper = dndAcquireWrapper(pDnode, ntype);
|
SMgmtWrapper *pWrapper = dmAcquireWrapper(pDnode, ntype);
|
||||||
if (pWrapper == NULL) {
|
if (pWrapper == NULL) {
|
||||||
terrno = TSDB_CODE_NODE_NOT_DEPLOYED;
|
terrno = TSDB_CODE_NODE_NOT_DEPLOYED;
|
||||||
dError("failed to drop node since %s", terrstr());
|
dError("failed to drop node since %s", terrstr());
|
||||||
|
@ -152,68 +148,57 @@ static int32_t dmProcessDropNodeMsg(SDnode *pDnode, EDndNodeType ntype, SNodeMsg
|
||||||
}
|
}
|
||||||
|
|
||||||
taosWLockLatch(&pWrapper->latch);
|
taosWLockLatch(&pWrapper->latch);
|
||||||
pWrapper->deployed = false;
|
|
||||||
|
|
||||||
int32_t code = (*pWrapper->fp.dropFp)(pWrapper, pMsg);
|
int32_t code = (*pWrapper->fp.dropFp)(pWrapper, pMsg);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
pWrapper->deployed = true;
|
|
||||||
dError("node:%s, failed to drop since %s", pWrapper->name, terrstr());
|
dError("node:%s, failed to drop since %s", pWrapper->name, terrstr());
|
||||||
|
pWrapper->required = true;
|
||||||
|
pWrapper->deployed = true;
|
||||||
} else {
|
} else {
|
||||||
pWrapper->deployed = false;
|
|
||||||
dDebug("node:%s, has been dropped", pWrapper->name);
|
dDebug("node:%s, has been dropped", pWrapper->name);
|
||||||
|
pWrapper->required = false;
|
||||||
|
pWrapper->deployed = false;
|
||||||
|
dmCloseNode(pWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosWUnLockLatch(&pWrapper->latch);
|
taosWUnLockLatch(&pWrapper->latch);
|
||||||
dndReleaseWrapper(pWrapper);
|
dmReleaseWrapper(pWrapper);
|
||||||
return code;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t dmProcessCDnodeReq(SDnode *pDnode, SNodeMsg *pMsg) {
|
static void dmSetMgmtMsgHandle(SMgmtWrapper *pWrapper) {
|
||||||
switch (pMsg->rpcMsg.msgType) {
|
|
||||||
case TDMT_DND_CREATE_MNODE:
|
|
||||||
return dmProcessCreateNodeMsg(pDnode, MNODE, pMsg);
|
|
||||||
case TDMT_DND_DROP_MNODE:
|
|
||||||
return dmProcessDropNodeMsg(pDnode, MNODE, pMsg);
|
|
||||||
case TDMT_DND_CREATE_QNODE:
|
|
||||||
return dmProcessCreateNodeMsg(pDnode, QNODE, pMsg);
|
|
||||||
case TDMT_DND_DROP_QNODE:
|
|
||||||
return dmProcessDropNodeMsg(pDnode, QNODE, pMsg);
|
|
||||||
case TDMT_DND_CREATE_SNODE:
|
|
||||||
return dmProcessCreateNodeMsg(pDnode, SNODE, pMsg);
|
|
||||||
case TDMT_DND_DROP_SNODE:
|
|
||||||
return dmProcessDropNodeMsg(pDnode, SNODE, pMsg);
|
|
||||||
case TDMT_DND_CREATE_BNODE:
|
|
||||||
return dmProcessCreateNodeMsg(pDnode, BNODE, pMsg);
|
|
||||||
case TDMT_DND_DROP_BNODE:
|
|
||||||
return dmProcessDropNodeMsg(pDnode, BNODE, pMsg);
|
|
||||||
default:
|
|
||||||
terrno = TSDB_CODE_MSG_NOT_PROCESSED;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void dmSetMsgHandle(SMgmtWrapper *pWrapper) {
|
|
||||||
// Requests handled by DNODE
|
// Requests handled by DNODE
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_MNODE, dmProcessMgmtMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_DND_CREATE_MNODE, dmProcessMgmtMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_MNODE, dmProcessMgmtMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_DND_DROP_MNODE, dmProcessMgmtMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_QNODE, dmProcessMgmtMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_DND_CREATE_QNODE, dmProcessMgmtMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_QNODE, dmProcessMgmtMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_DND_DROP_QNODE, dmProcessMgmtMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_SNODE, dmProcessMgmtMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_DND_CREATE_SNODE, dmProcessMgmtMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_SNODE, dmProcessMgmtMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_DND_DROP_SNODE, dmProcessMgmtMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_BNODE, dmProcessMgmtMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_DND_CREATE_BNODE, dmProcessMgmtMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_BNODE, dmProcessMgmtMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_DND_DROP_BNODE, dmProcessMgmtMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_CONFIG_DNODE, dmProcessMgmtMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_DND_CONFIG_DNODE, dmProcessMgmtMsg, DEFAULT_HANDLE);
|
||||||
|
|
||||||
// Requests handled by MNODE
|
// Requests handled by MNODE
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_GRANT_RSP, dmProcessMgmtMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_GRANT_RSP, dmProcessMgmtMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_AUTH_RSP, dmProcessMgmtMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_AUTH_RSP, dmProcessMgmtMsg, DEFAULT_HANDLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t dmStart(SMgmtWrapper *pWrapper) { return dmStartStatusThread(pWrapper->pDnode); }
|
static int32_t dmStartMgmt(SMgmtWrapper *pWrapper) {
|
||||||
|
if (dmStartStatusThread(pWrapper->pDnode) != 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (dmStartMonitorThread(pWrapper->pDnode) != 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void dmStop(SMgmtWrapper *pWrapper) { dmStopThread(pWrapper->pDnode); }
|
static void dmStopMgmt(SMgmtWrapper *pWrapper) {
|
||||||
|
dmStopMonitorThread(pWrapper->pDnode);
|
||||||
|
dmStopStatusThread(pWrapper->pDnode);
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t dmInit(SMgmtWrapper *pWrapper) {
|
static int32_t dmInitMgmt(SMgmtWrapper *pWrapper) {
|
||||||
dInfo("dnode-data start to init");
|
dInfo("dnode-data start to init");
|
||||||
SDnode *pDnode = pWrapper->pDnode;
|
SDnode *pDnode = pWrapper->pDnode;
|
||||||
|
|
||||||
|
@ -224,7 +209,7 @@ static int32_t dmInit(SMgmtWrapper *pWrapper) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dmReadFile(pDnode) != 0) {
|
if (dmReadEps(pDnode) != 0) {
|
||||||
dError("failed to read file since %s", terrstr());
|
dError("failed to read file since %s", terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -247,40 +232,40 @@ static int32_t dmInit(SMgmtWrapper *pWrapper) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dmCleanup(SMgmtWrapper *pWrapper) {
|
static void dmCleanupMgmt(SMgmtWrapper *pWrapper) {
|
||||||
dInfo("dnode-data start to clean up");
|
dInfo("dnode-data start to clean up");
|
||||||
SDnode *pDnode = pWrapper->pDnode;
|
SDnode *pDnode = pWrapper->pDnode;
|
||||||
dmStopWorker(pDnode);
|
dmStopWorker(pDnode);
|
||||||
|
|
||||||
taosWLockLatch(&pDnode->data.latch);
|
taosWLockLatch(&pDnode->data.latch);
|
||||||
if (pMgmt->dnodeEps != NULL) {
|
if (pDnode->data.dnodeEps != NULL) {
|
||||||
taosArrayDestroy(pMgmt->dnodeEps);
|
taosArrayDestroy(pDnode->data.dnodeEps);
|
||||||
pMgmt->dnodeEps = NULL;
|
pDnode->data.dnodeEps = NULL;
|
||||||
}
|
}
|
||||||
if (pMgmt->dnodeHash != NULL) {
|
if (pDnode->data.dnodeHash != NULL) {
|
||||||
taosHashCleanup(pMgmt->dnodeHash);
|
taosHashCleanup(pDnode->data.dnodeHash);
|
||||||
pMgmt->dnodeHash = NULL;
|
pDnode->data.dnodeHash = NULL;
|
||||||
}
|
}
|
||||||
taosWUnLockLatch(&pDnode->data.latch);
|
taosWUnLockLatch(&pDnode->data.latch);
|
||||||
|
|
||||||
dndCleanupTrans(pDnode);
|
dmCleanupTrans(pDnode);
|
||||||
dInfo("dnode-data is cleaned up");
|
dInfo("dnode-data is cleaned up");
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t dmRequire(SMgmtWrapper *pWrapper, bool *required) {
|
static int32_t dmRequireMgmt(SMgmtWrapper *pWrapper, bool *required) {
|
||||||
*required = true;
|
*required = true;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dmSetMgmtFp(SMgmtWrapper *pWrapper) {
|
void dmSetMgmtFp(SMgmtWrapper *pWrapper) {
|
||||||
SMgmtFp mgmtFp = {0};
|
SMgmtFp mgmtFp = {0};
|
||||||
mgmtFp.openFp = dmInit;
|
mgmtFp.openFp = dmInitMgmt;
|
||||||
mgmtFp.closeFp = dmCleanup;
|
mgmtFp.closeFp = dmCleanupMgmt;
|
||||||
mgmtFp.startFp = dmStart;
|
mgmtFp.startFp = dmStartMgmt;
|
||||||
mgmtFp.stopFp = dmStop;
|
mgmtFp.stopFp = dmStopMgmt;
|
||||||
mgmtFp.requiredFp = dmRequire;
|
mgmtFp.requiredFp = dmRequireMgmt;
|
||||||
|
|
||||||
dmSetMsgHandle(pWrapper);
|
dmSetMgmtMsgHandle(pWrapper);
|
||||||
pWrapper->name = "dnode";
|
pWrapper->name = "dnode";
|
||||||
pWrapper->fp = mgmtFp;
|
pWrapper->fp = mgmtFp;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ static void dmGetMonitorDnodeInfo(SDnode *pDnode, SMonDnodeInfo *pInfo) {
|
||||||
|
|
||||||
static void dmGetMonitorInfo(SDnode *pDnode, SMonDmInfo *pInfo) {
|
static void dmGetMonitorInfo(SDnode *pDnode, SMonDmInfo *pInfo) {
|
||||||
dmGetMonitorBasicInfo(pDnode, &pInfo->basic);
|
dmGetMonitorBasicInfo(pDnode, &pInfo->basic);
|
||||||
dndGetMonitorSysInfo(&pInfo->sys);
|
dmGetMonitorSysInfo(&pInfo->sys);
|
||||||
dmGetMonitorDnodeInfo(pDnode, &pInfo->dnode);
|
dmGetMonitorDnodeInfo(pDnode, &pInfo->dnode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,14 +64,14 @@ void dmSendMonitorReport(SDnode *pDnode) {
|
||||||
bool getFromAPI = !tsMultiProcess;
|
bool getFromAPI = !tsMultiProcess;
|
||||||
pWrapper = &pDnode->wrappers[MNODE];
|
pWrapper = &pDnode->wrappers[MNODE];
|
||||||
if (getFromAPI) {
|
if (getFromAPI) {
|
||||||
if (dndMarkWrapper(pWrapper) == 0) {
|
if (dmMarkWrapper(pWrapper) == 0) {
|
||||||
mmGetMonitorInfo(pWrapper, &mmInfo);
|
mmGetMonitorInfo(pWrapper, &mmInfo);
|
||||||
dndReleaseWrapper(pWrapper);
|
dmReleaseWrapper(pWrapper);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (pWrapper->required) {
|
if (pWrapper->required) {
|
||||||
req.msgType = TDMT_MON_MM_INFO;
|
req.msgType = TDMT_MON_MM_INFO;
|
||||||
dndSendRecv(pDnode, &epset, &req, &rsp);
|
dmSendRecv(pDnode, &epset, &req, &rsp);
|
||||||
if (rsp.code == 0 && rsp.contLen > 0) {
|
if (rsp.code == 0 && rsp.contLen > 0) {
|
||||||
tDeserializeSMonMmInfo(rsp.pCont, rsp.contLen, &mmInfo);
|
tDeserializeSMonMmInfo(rsp.pCont, rsp.contLen, &mmInfo);
|
||||||
}
|
}
|
||||||
|
@ -81,14 +81,14 @@ void dmSendMonitorReport(SDnode *pDnode) {
|
||||||
|
|
||||||
pWrapper = &pDnode->wrappers[VNODE];
|
pWrapper = &pDnode->wrappers[VNODE];
|
||||||
if (getFromAPI) {
|
if (getFromAPI) {
|
||||||
if (dndMarkWrapper(pWrapper) == 0) {
|
if (dmMarkWrapper(pWrapper) == 0) {
|
||||||
vmGetMonitorInfo(pWrapper, &vmInfo);
|
vmGetMonitorInfo(pWrapper, &vmInfo);
|
||||||
dndReleaseWrapper(pWrapper);
|
dmReleaseWrapper(pWrapper);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (pWrapper->required) {
|
if (pWrapper->required) {
|
||||||
req.msgType = TDMT_MON_VM_INFO;
|
req.msgType = TDMT_MON_VM_INFO;
|
||||||
dndSendRecv(pDnode, &epset, &req, &rsp);
|
dmSendRecv(pDnode, &epset, &req, &rsp);
|
||||||
if (rsp.code == 0 && rsp.contLen > 0) {
|
if (rsp.code == 0 && rsp.contLen > 0) {
|
||||||
tDeserializeSMonVmInfo(rsp.pCont, rsp.contLen, &vmInfo);
|
tDeserializeSMonVmInfo(rsp.pCont, rsp.contLen, &vmInfo);
|
||||||
}
|
}
|
||||||
|
@ -98,14 +98,14 @@ void dmSendMonitorReport(SDnode *pDnode) {
|
||||||
|
|
||||||
pWrapper = &pDnode->wrappers[QNODE];
|
pWrapper = &pDnode->wrappers[QNODE];
|
||||||
if (getFromAPI) {
|
if (getFromAPI) {
|
||||||
if (dndMarkWrapper(pWrapper) == 0) {
|
if (dmMarkWrapper(pWrapper) == 0) {
|
||||||
qmGetMonitorInfo(pWrapper, &qmInfo);
|
qmGetMonitorInfo(pWrapper, &qmInfo);
|
||||||
dndReleaseWrapper(pWrapper);
|
dmReleaseWrapper(pWrapper);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (pWrapper->required) {
|
if (pWrapper->required) {
|
||||||
req.msgType = TDMT_MON_QM_INFO;
|
req.msgType = TDMT_MON_QM_INFO;
|
||||||
dndSendRecv(pDnode, &epset, &req, &rsp);
|
dmSendRecv(pDnode, &epset, &req, &rsp);
|
||||||
if (rsp.code == 0 && rsp.contLen > 0) {
|
if (rsp.code == 0 && rsp.contLen > 0) {
|
||||||
tDeserializeSMonQmInfo(rsp.pCont, rsp.contLen, &qmInfo);
|
tDeserializeSMonQmInfo(rsp.pCont, rsp.contLen, &qmInfo);
|
||||||
}
|
}
|
||||||
|
@ -115,14 +115,14 @@ void dmSendMonitorReport(SDnode *pDnode) {
|
||||||
|
|
||||||
pWrapper = &pDnode->wrappers[SNODE];
|
pWrapper = &pDnode->wrappers[SNODE];
|
||||||
if (getFromAPI) {
|
if (getFromAPI) {
|
||||||
if (dndMarkWrapper(pWrapper) == 0) {
|
if (dmMarkWrapper(pWrapper) == 0) {
|
||||||
smGetMonitorInfo(pWrapper, &smInfo);
|
smGetMonitorInfo(pWrapper, &smInfo);
|
||||||
dndReleaseWrapper(pWrapper);
|
dmReleaseWrapper(pWrapper);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (pWrapper->required) {
|
if (pWrapper->required) {
|
||||||
req.msgType = TDMT_MON_SM_INFO;
|
req.msgType = TDMT_MON_SM_INFO;
|
||||||
dndSendRecv(pDnode, &epset, &req, &rsp);
|
dmSendRecv(pDnode, &epset, &req, &rsp);
|
||||||
if (rsp.code == 0 && rsp.contLen > 0) {
|
if (rsp.code == 0 && rsp.contLen > 0) {
|
||||||
tDeserializeSMonSmInfo(rsp.pCont, rsp.contLen, &smInfo);
|
tDeserializeSMonSmInfo(rsp.pCont, rsp.contLen, &smInfo);
|
||||||
}
|
}
|
||||||
|
@ -132,14 +132,14 @@ void dmSendMonitorReport(SDnode *pDnode) {
|
||||||
|
|
||||||
pWrapper = &pDnode->wrappers[BNODE];
|
pWrapper = &pDnode->wrappers[BNODE];
|
||||||
if (getFromAPI) {
|
if (getFromAPI) {
|
||||||
if (dndMarkWrapper(pWrapper) == 0) {
|
if (dmMarkWrapper(pWrapper) == 0) {
|
||||||
bmGetMonitorInfo(pWrapper, &bmInfo);
|
bmGetMonitorInfo(pWrapper, &bmInfo);
|
||||||
dndReleaseWrapper(pWrapper);
|
dmReleaseWrapper(pWrapper);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (pWrapper->required) {
|
if (pWrapper->required) {
|
||||||
req.msgType = TDMT_MON_BM_INFO;
|
req.msgType = TDMT_MON_BM_INFO;
|
||||||
dndSendRecv(pDnode, &epset, &req, &rsp);
|
dmSendRecv(pDnode, &epset, &req, &rsp);
|
||||||
if (rsp.code == 0 && rsp.contLen > 0) {
|
if (rsp.code == 0 && rsp.contLen > 0) {
|
||||||
tDeserializeSMonBmInfo(rsp.pCont, rsp.contLen, &bmInfo);
|
tDeserializeSMonBmInfo(rsp.pCont, rsp.contLen, &bmInfo);
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,10 @@ void dmSendMonitorReport(SDnode *pDnode) {
|
||||||
monSendReport();
|
monSendReport();
|
||||||
}
|
}
|
||||||
|
|
||||||
void dmGetVnodeLoads(SMgmtWrapper *pWrapper, SMonVloadInfo *pInfo) {
|
void dmGetVnodeLoads(SDnode *pDnode, SMonVloadInfo *pInfo) {
|
||||||
|
SMgmtWrapper *pWrapper = dmAcquireWrapper(pDnode, VNODE);
|
||||||
|
if (pWrapper == NULL) return;
|
||||||
|
|
||||||
bool getFromAPI = !tsMultiProcess;
|
bool getFromAPI = !tsMultiProcess;
|
||||||
if (getFromAPI) {
|
if (getFromAPI) {
|
||||||
vmGetVnodeLoads(pWrapper, pInfo);
|
vmGetVnodeLoads(pWrapper, pInfo);
|
||||||
|
@ -172,10 +175,11 @@ void dmGetVnodeLoads(SMgmtWrapper *pWrapper, SMonVloadInfo *pInfo) {
|
||||||
tstrncpy(epset.eps[0].fqdn, tsLocalFqdn, TSDB_FQDN_LEN);
|
tstrncpy(epset.eps[0].fqdn, tsLocalFqdn, TSDB_FQDN_LEN);
|
||||||
epset.eps[0].port = tsServerPort;
|
epset.eps[0].port = tsServerPort;
|
||||||
|
|
||||||
dndSendRecv(pWrapper->pDnode, &epset, &req, &rsp);
|
dmSendRecv(pDnode, &epset, &req, &rsp);
|
||||||
if (rsp.code == 0 && rsp.contLen > 0) {
|
if (rsp.code == 0 && rsp.contLen > 0) {
|
||||||
tDeserializeSMonVloadInfo(rsp.pCont, rsp.contLen, pInfo);
|
tDeserializeSMonVloadInfo(rsp.pCont, rsp.contLen, pInfo);
|
||||||
}
|
}
|
||||||
rpcFreeCont(rsp.pCont);
|
rpcFreeCont(rsp.pCont);
|
||||||
}
|
}
|
||||||
|
dmReleaseWrapper(pWrapper);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,12 +16,10 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "dmImp.h"
|
#include "dmImp.h"
|
||||||
|
|
||||||
|
static int32_t dmInitVars(SDnode *pDnode, const SDnodeOpt *pOption) {
|
||||||
static int32_t dndInitVars(SDnode *pDnode, const SDnodeOpt *pOption) {
|
|
||||||
pDnode->data.dnodeId = 0;
|
pDnode->data.dnodeId = 0;
|
||||||
pDnode->data.dropped = 0;
|
pDnode->data.dropped = 0;
|
||||||
pDnode->data.clusterId = 0;
|
pDnode->data.clusterId = 0;
|
||||||
|
|
||||||
pDnode->data.supportVnodes = pOption->numOfSupportVnodes;
|
pDnode->data.supportVnodes = pOption->numOfSupportVnodes;
|
||||||
pDnode->data.serverPort = pOption->serverPort;
|
pDnode->data.serverPort = pOption->serverPort;
|
||||||
pDnode->data.dataDir = strdup(pOption->dataDir);
|
pDnode->data.dataDir = strdup(pOption->dataDir);
|
||||||
|
@ -34,24 +32,25 @@ static int32_t dndInitVars(SDnode *pDnode, const SDnodeOpt *pOption) {
|
||||||
pDnode->ntype = pOption->ntype;
|
pDnode->ntype = pOption->ntype;
|
||||||
pDnode->data.rebootTime = taosGetTimestampMs();
|
pDnode->data.rebootTime = taosGetTimestampMs();
|
||||||
|
|
||||||
if (pDnode->data.dataDir == NULL || pDnode->data.localEp == NULL || pDnode->data.localFqdn == NULL || pDnode->data.firstEp == NULL ||
|
if (pDnode->data.dataDir == NULL || pDnode->data.localEp == NULL || pDnode->data.localFqdn == NULL ||
|
||||||
pDnode->data.secondEp == NULL) {
|
pDnode->data.firstEp == NULL || pDnode->data.secondEp == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tsMultiProcess || pDnode->ntype == NODE_BEGIN || pDnode->ntype == NODE_END) {
|
if (!tsMultiProcess || pDnode->ntype == NODE_BEGIN || pDnode->ntype == NODE_END) {
|
||||||
pDnode->data.lockfile = dndCheckRunning(pDnode->data.dataDir);
|
pDnode->data.lockfile = dmCheckRunning(pDnode->data.dataDir);
|
||||||
if (pDnode->data.lockfile == NULL) {
|
if (pDnode->data.lockfile == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
taosInitRWLatch(&pDnode->data.latch);
|
taosInitRWLatch(&pDnode->data.latch);
|
||||||
|
taosInitRWLatch(&pDnode->wrapperLock);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dndClearVars(SDnode *pDnode) {
|
static void dmClearVars(SDnode *pDnode) {
|
||||||
for (EDndNodeType n = 0; n < NODE_END; ++n) {
|
for (EDndNodeType n = 0; n < NODE_END; ++n) {
|
||||||
SMgmtWrapper *pMgmt = &pDnode->wrappers[n];
|
SMgmtWrapper *pMgmt = &pDnode->wrappers[n];
|
||||||
taosMemoryFreeClear(pMgmt->path);
|
taosMemoryFreeClear(pMgmt->path);
|
||||||
|
@ -70,7 +69,7 @@ static void dndClearVars(SDnode *pDnode) {
|
||||||
dDebug("dnode memory is cleared, data:%p", pDnode);
|
dDebug("dnode memory is cleared, data:%p", pDnode);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDnode *dndCreate(const SDnodeOpt *pOption) {
|
SDnode *dmCreate(const SDnodeOpt *pOption) {
|
||||||
dDebug("start to create dnode object");
|
dDebug("start to create dnode object");
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
char path[PATH_MAX] = {0};
|
char path[PATH_MAX] = {0};
|
||||||
|
@ -82,12 +81,12 @@ SDnode *dndCreate(const SDnodeOpt *pOption) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dndInitVars(pDnode, pOption) != 0) {
|
if (dmInitVars(pDnode, pOption) != 0) {
|
||||||
dError("failed to init variables since %s", terrstr());
|
dError("failed to init variables since %s", terrstr());
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
dndSetStatus(pDnode, DND_STAT_INIT);
|
dmSetStatus(pDnode, DND_STAT_INIT);
|
||||||
dmSetMgmtFp(&pDnode->wrappers[NODE_BEGIN]);
|
dmSetMgmtFp(&pDnode->wrappers[NODE_BEGIN]);
|
||||||
mmSetMgmtFp(&pDnode->wrappers[MNODE]);
|
mmSetMgmtFp(&pDnode->wrappers[MNODE]);
|
||||||
vmSetMgmtFp(&pDnode->wrappers[VNODE]);
|
vmSetMgmtFp(&pDnode->wrappers[VNODE]);
|
||||||
|
@ -111,12 +110,12 @@ SDnode *dndCreate(const SDnodeOpt *pOption) {
|
||||||
taosInitRWLatch(&pWrapper->latch);
|
taosInitRWLatch(&pWrapper->latch);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dndInitMsgHandle(pDnode) != 0) {
|
if (dmInitMsgHandle(pDnode) != 0) {
|
||||||
dError("failed to init msg handles since %s", terrstr());
|
dError("failed to init msg handles since %s", terrstr());
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dndReadShmFile(pDnode) != 0) {
|
if (dmReadShmFile(pDnode) != 0) {
|
||||||
dError("failed to read shm file since %s", terrstr());
|
dError("failed to read shm file since %s", terrstr());
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
@ -129,7 +128,7 @@ SDnode *dndCreate(const SDnodeOpt *pOption) {
|
||||||
|
|
||||||
_OVER:
|
_OVER:
|
||||||
if (code != 0 && pDnode) {
|
if (code != 0 && pDnode) {
|
||||||
dndClearVars(pDnode);
|
dmClearVars(pDnode);
|
||||||
pDnode = NULL;
|
pDnode = NULL;
|
||||||
dError("failed to create dnode since %s", terrstr());
|
dError("failed to create dnode since %s", terrstr());
|
||||||
}
|
}
|
||||||
|
@ -137,20 +136,14 @@ _OVER:
|
||||||
return pDnode;
|
return pDnode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dndClose(SDnode *pDnode) {
|
void dmClose(SDnode *pDnode) {
|
||||||
if (pDnode == NULL) return;
|
if (pDnode == NULL) return;
|
||||||
|
|
||||||
for (EDndNodeType n = 0; n < NODE_END; ++n) {
|
for (EDndNodeType n = 0; n < NODE_END; ++n) {
|
||||||
SMgmtWrapper *pWrapper = &pDnode->wrappers[n];
|
SMgmtWrapper *pWrapper = &pDnode->wrappers[n];
|
||||||
dndCloseNode(pWrapper);
|
dmCloseNode(pWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
dndClearVars(pDnode);
|
dmClearVars(pDnode);
|
||||||
dInfo("dnode is closed, data:%p", pDnode);
|
dInfo("dnode is closed, data:%p", pDnode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dndHandleEvent(SDnode *pDnode, EDndEvent event) {
|
|
||||||
if (event == DND_EVENT_STOP) {
|
|
||||||
pDnode->event = event;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -20,17 +20,17 @@
|
||||||
#define INTERNAL_CKEY "_key"
|
#define INTERNAL_CKEY "_key"
|
||||||
#define INTERNAL_SECRET "_pwd"
|
#define INTERNAL_SECRET "_pwd"
|
||||||
|
|
||||||
static void dndGetMnodeEpSet(SDnode *pDnode, SEpSet *pEpSet) {
|
static void dmGetMnodeEpSet(SDnode *pDnode, SEpSet *pEpSet) {
|
||||||
taosRLockLatch(&pDnode->data.latch);
|
taosRLockLatch(&pDnode->data.latch);
|
||||||
*pEpSet = pDnode->data.mnodeEpSet;
|
*pEpSet = pDnode->data.mnodeEps;
|
||||||
taosRUnLockLatch(&pDnode->data.latch);
|
taosRUnLockLatch(&pDnode->data.latch);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dndSetMnodeEpSet(SDnode *pDnode, SEpSet *pEpSet) {
|
static void dmSetMnodeEpSet(SDnode *pDnode, SEpSet *pEpSet) {
|
||||||
dInfo("mnode is changed, num:%d use:%d", pEpSet->numOfEps, pEpSet->inUse);
|
dInfo("mnode is changed, num:%d use:%d", pEpSet->numOfEps, pEpSet->inUse);
|
||||||
|
|
||||||
taosWLockLatch(&pDnode->data.latch);
|
taosWLockLatch(&pDnode->data.latch);
|
||||||
pDnode->data.mnodeEpSet = *pEpSet;
|
pDnode->data.mnodeEps = *pEpSet;
|
||||||
for (int32_t i = 0; i < pEpSet->numOfEps; ++i) {
|
for (int32_t i = 0; i < pEpSet->numOfEps; ++i) {
|
||||||
dInfo("mnode index:%d %s:%u", i, pEpSet->eps[i].fqdn, pEpSet->eps[i].port);
|
dInfo("mnode index:%d %s:%u", i, pEpSet->eps[i].fqdn, pEpSet->eps[i].port);
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ static void dndSetMnodeEpSet(SDnode *pDnode, SEpSet *pEpSet) {
|
||||||
taosWUnLockLatch(&pDnode->data.latch);
|
taosWUnLockLatch(&pDnode->data.latch);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline NodeMsgFp dndGetMsgFp(SMgmtWrapper *pWrapper, SRpcMsg *pRpc) {
|
static inline NodeMsgFp dmGetMsgFp(SMgmtWrapper *pWrapper, SRpcMsg *pRpc) {
|
||||||
NodeMsgFp msgFp = pWrapper->msgFps[TMSG_INDEX(pRpc->msgType)];
|
NodeMsgFp msgFp = pWrapper->msgFps[TMSG_INDEX(pRpc->msgType)];
|
||||||
if (msgFp == NULL) {
|
if (msgFp == NULL) {
|
||||||
terrno = TSDB_CODE_MSG_NOT_PROCESSED;
|
terrno = TSDB_CODE_MSG_NOT_PROCESSED;
|
||||||
|
@ -47,7 +47,7 @@ static inline NodeMsgFp dndGetMsgFp(SMgmtWrapper *pWrapper, SRpcMsg *pRpc) {
|
||||||
return msgFp;
|
return msgFp;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int32_t dndBuildMsg(SNodeMsg *pMsg, SRpcMsg *pRpc) {
|
static inline int32_t dmBuildMsg(SNodeMsg *pMsg, SRpcMsg *pRpc) {
|
||||||
SRpcConnInfo connInfo = {0};
|
SRpcConnInfo connInfo = {0};
|
||||||
if ((pRpc->msgType & 1U) && rpcGetConnInfo(pRpc->handle, &connInfo) != 0) {
|
if ((pRpc->msgType & 1U) && rpcGetConnInfo(pRpc->handle, &connInfo) != 0) {
|
||||||
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
||||||
|
@ -62,20 +62,20 @@ static inline int32_t dndBuildMsg(SNodeMsg *pMsg, SRpcMsg *pRpc) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dndProcessRpcMsg(SMgmtWrapper *pWrapper, SRpcMsg *pRpc, SEpSet *pEpSet) {
|
static void dmProcessRpcMsg(SMgmtWrapper *pWrapper, SRpcMsg *pRpc, SEpSet *pEpSet) {
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SNodeMsg *pMsg = NULL;
|
SNodeMsg *pMsg = NULL;
|
||||||
NodeMsgFp msgFp = NULL;
|
NodeMsgFp msgFp = NULL;
|
||||||
uint16_t msgType = pRpc->msgType;
|
uint16_t msgType = pRpc->msgType;
|
||||||
|
|
||||||
if (pEpSet && pEpSet->numOfEps > 0 && msgType == TDMT_MND_STATUS_RSP) {
|
if (pEpSet && pEpSet->numOfEps > 0 && msgType == TDMT_MND_STATUS_RSP) {
|
||||||
dndSetMnodeEpSet(pWrapper->pDnode, pEpSet);
|
dmSetMnodeEpSet(pWrapper->pDnode, pEpSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dndMarkWrapper(pWrapper) != 0) goto _OVER;
|
if (dmMarkWrapper(pWrapper) != 0) goto _OVER;
|
||||||
if ((msgFp = dndGetMsgFp(pWrapper, pRpc)) == NULL) goto _OVER;
|
if ((msgFp = dmGetMsgFp(pWrapper, pRpc)) == NULL) goto _OVER;
|
||||||
if ((pMsg = taosAllocateQitem(sizeof(SNodeMsg))) == NULL) goto _OVER;
|
if ((pMsg = taosAllocateQitem(sizeof(SNodeMsg))) == NULL) goto _OVER;
|
||||||
if (dndBuildMsg(pMsg, pRpc) != 0) goto _OVER;
|
if (dmBuildMsg(pMsg, pRpc) != 0) goto _OVER;
|
||||||
|
|
||||||
if (pWrapper->procType == DND_PROC_SINGLE) {
|
if (pWrapper->procType == DND_PROC_SINGLE) {
|
||||||
dTrace("msg:%p, is created, handle:%p user:%s", pMsg, pRpc->handle, pMsg->user);
|
dTrace("msg:%p, is created, handle:%p user:%s", pMsg, pRpc->handle, pMsg->user);
|
||||||
|
@ -114,10 +114,10 @@ _OVER:
|
||||||
rpcFreeCont(pRpc->pCont);
|
rpcFreeCont(pRpc->pCont);
|
||||||
}
|
}
|
||||||
|
|
||||||
dndReleaseWrapper(pWrapper);
|
dmReleaseWrapper(pWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dndProcessMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) {
|
static void dmProcessMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) {
|
||||||
SDnodeTrans *pTrans = &pDnode->trans;
|
SDnodeTrans *pTrans = &pDnode->trans;
|
||||||
tmsg_t msgType = pMsg->msgType;
|
tmsg_t msgType = pMsg->msgType;
|
||||||
bool isReq = msgType & 1u;
|
bool isReq = msgType & 1u;
|
||||||
|
@ -126,11 +126,11 @@ static void dndProcessMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) {
|
||||||
|
|
||||||
if (msgType == TDMT_DND_NETWORK_TEST) {
|
if (msgType == TDMT_DND_NETWORK_TEST) {
|
||||||
dTrace("network test req will be processed, handle:%p, app:%p", pMsg->handle, pMsg->ahandle);
|
dTrace("network test req will be processed, handle:%p, app:%p", pMsg->handle, pMsg->ahandle);
|
||||||
dndProcessStartupReq(pDnode, pMsg);
|
dmProcessStartupReq(pDnode, pMsg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dndGetStatus(pDnode) != DND_STAT_RUNNING) {
|
if (pDnode->status != DND_STAT_RUNNING) {
|
||||||
dError("msg:%s ignored since dnode not running, handle:%p app:%p", TMSG_INFO(msgType), pMsg->handle, pMsg->ahandle);
|
dError("msg:%s ignored since dnode not running, handle:%p app:%p", TMSG_INFO(msgType), pMsg->handle, pMsg->ahandle);
|
||||||
if (isReq) {
|
if (isReq) {
|
||||||
SRpcMsg rspMsg = {.handle = pMsg->handle, .code = TSDB_CODE_APP_NOT_READY, .ahandle = pMsg->ahandle};
|
SRpcMsg rspMsg = {.handle = pMsg->handle, .code = TSDB_CODE_APP_NOT_READY, .ahandle = pMsg->ahandle};
|
||||||
|
@ -168,10 +168,10 @@ static void dndProcessMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) {
|
||||||
}
|
}
|
||||||
|
|
||||||
dTrace("msg:%s will be processed by %s, app:%p", TMSG_INFO(msgType), pWrapper->name, pMsg->ahandle);
|
dTrace("msg:%s will be processed by %s, app:%p", TMSG_INFO(msgType), pWrapper->name, pMsg->ahandle);
|
||||||
dndProcessRpcMsg(pWrapper, pMsg, pEpSet);
|
dmProcessRpcMsg(pWrapper, pMsg, pEpSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t dndInitMsgHandle(SDnode *pDnode) {
|
int32_t dmInitMsgHandle(SDnode *pDnode) {
|
||||||
SDnodeTrans *pTrans = &pDnode->trans;
|
SDnodeTrans *pTrans = &pDnode->trans;
|
||||||
|
|
||||||
for (EDndNodeType n = NODE_BEGIN + 1; n < NODE_END; ++n) {
|
for (EDndNodeType n = NODE_BEGIN + 1; n < NODE_END; ++n) {
|
||||||
|
@ -208,7 +208,7 @@ int32_t dndInitMsgHandle(SDnode *pDnode) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int32_t dndSendRpcReq(SDnode *pDnode, const SEpSet *pEpSet, SRpcMsg *pReq) {
|
static inline int32_t dmSendRpcReq(SDnode *pDnode, const SEpSet *pEpSet, SRpcMsg *pReq) {
|
||||||
if (pDnode->trans.clientRpc == NULL) {
|
if (pDnode->trans.clientRpc == NULL) {
|
||||||
terrno = TSDB_CODE_NODE_OFFLINE;
|
terrno = TSDB_CODE_NODE_OFFLINE;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -218,9 +218,9 @@ static inline int32_t dndSendRpcReq(SDnode *pDnode, const SEpSet *pEpSet, SRpcMs
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dndSendRpcRedirectRsp(SDnode *pDnode, const SRpcMsg *pReq) {
|
static void dmSendRpcRedirectRsp(SDnode *pDnode, const SRpcMsg *pReq) {
|
||||||
SEpSet epSet = {0};
|
SEpSet epSet = {0};
|
||||||
dndGetMnodeEpSet(pDnode, &epSet);
|
dmGetMnodeEpSet(pDnode, &epSet);
|
||||||
|
|
||||||
dDebug("RPC %p, req is redirected, num:%d use:%d", pReq->handle, epSet.numOfEps, epSet.inUse);
|
dDebug("RPC %p, req is redirected, num:%d use:%d", pReq->handle, epSet.numOfEps, epSet.inUse);
|
||||||
for (int32_t i = 0; i < epSet.numOfEps; ++i) {
|
for (int32_t i = 0; i < epSet.numOfEps; ++i) {
|
||||||
|
@ -235,39 +235,33 @@ static void dndSendRpcRedirectRsp(SDnode *pDnode, const SRpcMsg *pReq) {
|
||||||
rpcSendRedirectRsp(pReq->handle, &epSet);
|
rpcSendRedirectRsp(pReq->handle, &epSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void dndSendRpcRsp(SDnode *pDnode, const SRpcMsg *pRsp) {
|
static inline void dmSendRpcRsp(SDnode *pDnode, const SRpcMsg *pRsp) {
|
||||||
if (pRsp->code == TSDB_CODE_NODE_REDIRECT) {
|
if (pRsp->code == TSDB_CODE_NODE_REDIRECT) {
|
||||||
dndSendRpcRedirectRsp(pDnode, pRsp);
|
dmSendRpcRedirectRsp(pDnode, pRsp);
|
||||||
} else {
|
} else {
|
||||||
rpcSendResponse(pRsp);
|
rpcSendResponse(pRsp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void dndSendRecv(SDnode *pDnode, SEpSet *pEpSet, SRpcMsg *pReq, SRpcMsg *pRsp) {
|
void dmSendRecv(SDnode *pDnode, SEpSet *pEpSet, SRpcMsg *pReq, SRpcMsg *pRsp) {
|
||||||
rpcSendRecv(pDnode->trans.clientRpc, pEpSet, pReq, pRsp);
|
rpcSendRecv(pDnode->trans.clientRpc, pEpSet, pReq, pRsp);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t dndSendMsgToMnode(SDnode *pDnode, SRpcMsg *pReq) {
|
|
||||||
SEpSet epSet = {0};
|
|
||||||
dndGetMnodeEpSet(pDnode, &epSet);
|
|
||||||
return dndSendRpcReq(pDnode, &epSet, pReq);
|
|
||||||
}
|
|
||||||
|
|
||||||
void dmSendToMnodeRecv(SDnode *pDnode, SRpcMsg *pReq, SRpcMsg *pRsp) {
|
void dmSendToMnodeRecv(SDnode *pDnode, SRpcMsg *pReq, SRpcMsg *pRsp) {
|
||||||
SEpSet epSet = {0};
|
SEpSet epSet = {0};
|
||||||
dndGetMnodeEpSet(pDnode, &epSet);
|
dmGetMnodeEpSet(pDnode, &epSet);
|
||||||
rpcSendRecv(pDnode->trans.clientRpc, &epSet, pReq, pRsp);
|
rpcSendRecv(pDnode->trans.clientRpc, &epSet, pReq, pRsp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int32_t dndSendReq(SMgmtWrapper *pWrapper, const SEpSet *pEpSet, SRpcMsg *pReq) {
|
static inline int32_t dmSendReq(SMgmtWrapper *pWrapper, const SEpSet *pEpSet, SRpcMsg *pReq) {
|
||||||
if (dndGetStatus(pWrapper->pDnode) != DND_STAT_RUNNING) {
|
if (pWrapper->pDnode->status != DND_STAT_RUNNING) {
|
||||||
terrno = TSDB_CODE_NODE_OFFLINE;
|
terrno = TSDB_CODE_NODE_OFFLINE;
|
||||||
dError("failed to send rpc msg since %s, handle:%p", terrstr(), pReq->handle);
|
dError("failed to send rpc msg since %s, handle:%p", terrstr(), pReq->handle);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pWrapper->procType != DND_PROC_CHILD) {
|
if (pWrapper->procType != DND_PROC_CHILD) {
|
||||||
return dndSendRpcReq(pWrapper->pDnode, pEpSet, pReq);
|
return dmSendRpcReq(pWrapper->pDnode, pEpSet, pReq);
|
||||||
} else {
|
} else {
|
||||||
char *pHead = taosMemoryMalloc(sizeof(SRpcMsg) + sizeof(SEpSet));
|
char *pHead = taosMemoryMalloc(sizeof(SRpcMsg) + sizeof(SEpSet));
|
||||||
if (pHead == NULL) {
|
if (pHead == NULL) {
|
||||||
|
@ -284,15 +278,15 @@ static inline int32_t dndSendReq(SMgmtWrapper *pWrapper, const SEpSet *pEpSet, S
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void dndSendRsp(SMgmtWrapper *pWrapper, const SRpcMsg *pRsp) {
|
static inline void dmSendRsp(SMgmtWrapper *pWrapper, const SRpcMsg *pRsp) {
|
||||||
if (pWrapper->procType != DND_PROC_CHILD) {
|
if (pWrapper->procType != DND_PROC_CHILD) {
|
||||||
dndSendRpcRsp(pWrapper->pDnode, pRsp);
|
dmSendRpcRsp(pWrapper->pDnode, pRsp);
|
||||||
} else {
|
} else {
|
||||||
taosProcPutToParentQ(pWrapper->procObj, pRsp, sizeof(SRpcMsg), pRsp->pCont, pRsp->contLen, PROC_FUNC_RSP);
|
taosProcPutToParentQ(pWrapper->procObj, pRsp, sizeof(SRpcMsg), pRsp->pCont, pRsp->contLen, PROC_FUNC_RSP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void dndRegisterBrokenLinkArg(SMgmtWrapper *pWrapper, SRpcMsg *pMsg) {
|
static inline void dmRegisterBrokenLinkArg(SMgmtWrapper *pWrapper, SRpcMsg *pMsg) {
|
||||||
if (pWrapper->procType != DND_PROC_CHILD) {
|
if (pWrapper->procType != DND_PROC_CHILD) {
|
||||||
rpcRegisterBrokenLinkArg(pMsg);
|
rpcRegisterBrokenLinkArg(pMsg);
|
||||||
} else {
|
} else {
|
||||||
|
@ -300,7 +294,7 @@ static inline void dndRegisterBrokenLinkArg(SMgmtWrapper *pWrapper, SRpcMsg *pMs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void dndReleaseHandle(SMgmtWrapper *pWrapper, void *handle, int8_t type) {
|
static inline void dmReleaseHandle(SMgmtWrapper *pWrapper, void *handle, int8_t type) {
|
||||||
if (pWrapper->procType != DND_PROC_CHILD) {
|
if (pWrapper->procType != DND_PROC_CHILD) {
|
||||||
rpcReleaseHandle(handle, type);
|
rpcReleaseHandle(handle, type);
|
||||||
} else {
|
} else {
|
||||||
|
@ -309,8 +303,8 @@ static inline void dndReleaseHandle(SMgmtWrapper *pWrapper, void *handle, int8_t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dndConsumeChildQueue(SMgmtWrapper *pWrapper, SNodeMsg *pMsg, int16_t msgLen, void *pCont, int32_t contLen,
|
static void dmConsumeChildQueue(SMgmtWrapper *pWrapper, SNodeMsg *pMsg, int16_t msgLen, void *pCont, int32_t contLen,
|
||||||
EProcFuncType ftype) {
|
EProcFuncType ftype) {
|
||||||
SRpcMsg *pRpc = &pMsg->rpcMsg;
|
SRpcMsg *pRpc = &pMsg->rpcMsg;
|
||||||
pRpc->pCont = pCont;
|
pRpc->pCont = pCont;
|
||||||
dTrace("msg:%p, get from child queue, handle:%p app:%p", pMsg, pRpc->handle, pRpc->ahandle);
|
dTrace("msg:%p, get from child queue, handle:%p app:%p", pMsg, pRpc->handle, pRpc->ahandle);
|
||||||
|
@ -322,7 +316,7 @@ static void dndConsumeChildQueue(SMgmtWrapper *pWrapper, SNodeMsg *pMsg, int16_t
|
||||||
dError("msg:%p, failed to process since code:0x%04x:%s", pMsg, code & 0XFFFF, tstrerror(code));
|
dError("msg:%p, failed to process since code:0x%04x:%s", pMsg, code & 0XFFFF, tstrerror(code));
|
||||||
if (pRpc->msgType & 1U) {
|
if (pRpc->msgType & 1U) {
|
||||||
SRpcMsg rsp = {.handle = pRpc->handle, .ahandle = pRpc->ahandle, .code = terrno};
|
SRpcMsg rsp = {.handle = pRpc->handle, .ahandle = pRpc->ahandle, .code = terrno};
|
||||||
dndSendRsp(pWrapper, &rsp);
|
dmSendRsp(pWrapper, &rsp);
|
||||||
}
|
}
|
||||||
|
|
||||||
dTrace("msg:%p, is freed", pMsg);
|
dTrace("msg:%p, is freed", pMsg);
|
||||||
|
@ -331,8 +325,8 @@ static void dndConsumeChildQueue(SMgmtWrapper *pWrapper, SNodeMsg *pMsg, int16_t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dndConsumeParentQueue(SMgmtWrapper *pWrapper, SRpcMsg *pMsg, int16_t msgLen, void *pCont, int32_t contLen,
|
static void dmConsumeParentQueue(SMgmtWrapper *pWrapper, SRpcMsg *pMsg, int16_t msgLen, void *pCont, int32_t contLen,
|
||||||
EProcFuncType ftype) {
|
EProcFuncType ftype) {
|
||||||
pMsg->pCont = pCont;
|
pMsg->pCont = pCont;
|
||||||
dTrace("msg:%p, get from parent queue, ftype:%d handle:%p code:0x%04x mtype:%d, app:%p", pMsg, ftype, pMsg->handle,
|
dTrace("msg:%p, get from parent queue, ftype:%d handle:%p code:0x%04x mtype:%d, app:%p", pMsg, ftype, pMsg->handle,
|
||||||
pMsg->code & 0xFFFF, pMsg->msgType, pMsg->ahandle);
|
pMsg->code & 0xFFFF, pMsg->msgType, pMsg->ahandle);
|
||||||
|
@ -347,11 +341,11 @@ static void dndConsumeParentQueue(SMgmtWrapper *pWrapper, SRpcMsg *pMsg, int16_t
|
||||||
rpcFreeCont(pCont);
|
rpcFreeCont(pCont);
|
||||||
break;
|
break;
|
||||||
case PROC_FUNC_REQ:
|
case PROC_FUNC_REQ:
|
||||||
dndSendRpcReq(pWrapper->pDnode, (SEpSet *)((char *)pMsg + sizeof(SRpcMsg)), pMsg);
|
dmSendRpcReq(pWrapper->pDnode, (SEpSet *)((char *)pMsg + sizeof(SRpcMsg)), pMsg);
|
||||||
break;
|
break;
|
||||||
case PROC_FUNC_RSP:
|
case PROC_FUNC_RSP:
|
||||||
taosProcRemoveHandle(pWrapper->procObj, pMsg->handle);
|
taosProcRemoveHandle(pWrapper->procObj, pMsg->handle);
|
||||||
dndSendRpcRsp(pWrapper->pDnode, pMsg);
|
dmSendRpcRsp(pWrapper->pDnode, pMsg);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -359,13 +353,13 @@ static void dndConsumeParentQueue(SMgmtWrapper *pWrapper, SRpcMsg *pMsg, int16_t
|
||||||
taosMemoryFree(pMsg);
|
taosMemoryFree(pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
SProcCfg dndGenProcCfg(SMgmtWrapper *pWrapper) {
|
SProcCfg dmGenProcCfg(SMgmtWrapper *pWrapper) {
|
||||||
SProcCfg cfg = {.childConsumeFp = (ProcConsumeFp)dndConsumeChildQueue,
|
SProcCfg cfg = {.childConsumeFp = (ProcConsumeFp)dmConsumeChildQueue,
|
||||||
.childMallocHeadFp = (ProcMallocFp)taosAllocateQitem,
|
.childMallocHeadFp = (ProcMallocFp)taosAllocateQitem,
|
||||||
.childFreeHeadFp = (ProcFreeFp)taosFreeQitem,
|
.childFreeHeadFp = (ProcFreeFp)taosFreeQitem,
|
||||||
.childMallocBodyFp = (ProcMallocFp)rpcMallocCont,
|
.childMallocBodyFp = (ProcMallocFp)rpcMallocCont,
|
||||||
.childFreeBodyFp = (ProcFreeFp)rpcFreeCont,
|
.childFreeBodyFp = (ProcFreeFp)rpcFreeCont,
|
||||||
.parentConsumeFp = (ProcConsumeFp)dndConsumeParentQueue,
|
.parentConsumeFp = (ProcConsumeFp)dmConsumeParentQueue,
|
||||||
.parentMallocHeadFp = (ProcMallocFp)taosMemoryMalloc,
|
.parentMallocHeadFp = (ProcMallocFp)taosMemoryMalloc,
|
||||||
.parentFreeHeadFp = (ProcFreeFp)taosMemoryFree,
|
.parentFreeHeadFp = (ProcFreeFp)taosMemoryFree,
|
||||||
.parentMallocBodyFp = (ProcMallocFp)rpcMallocCont,
|
.parentMallocBodyFp = (ProcMallocFp)rpcMallocCont,
|
||||||
|
@ -376,13 +370,13 @@ SProcCfg dndGenProcCfg(SMgmtWrapper *pWrapper) {
|
||||||
return cfg;
|
return cfg;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t dndInitClient(SDnode *pDnode) {
|
static int32_t dmInitClient(SDnode *pDnode) {
|
||||||
SDnodeTrans *pTrans = &pDnode->trans;
|
SDnodeTrans *pTrans = &pDnode->trans;
|
||||||
|
|
||||||
SRpcInit rpcInit = {0};
|
SRpcInit rpcInit = {0};
|
||||||
rpcInit.label = "DND";
|
rpcInit.label = "DND";
|
||||||
rpcInit.numOfThreads = 1;
|
rpcInit.numOfThreads = 1;
|
||||||
rpcInit.cfp = (RpcCfp)dndProcessMsg;
|
rpcInit.cfp = (RpcCfp)dmProcessMsg;
|
||||||
rpcInit.sessions = 1024;
|
rpcInit.sessions = 1024;
|
||||||
rpcInit.connType = TAOS_CONN_CLIENT;
|
rpcInit.connType = TAOS_CONN_CLIENT;
|
||||||
rpcInit.idleTime = tsShellActivityTimer * 1000;
|
rpcInit.idleTime = tsShellActivityTimer * 1000;
|
||||||
|
@ -405,7 +399,7 @@ static int32_t dndInitClient(SDnode *pDnode) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dndCleanupClient(SDnode *pDnode) {
|
static void dmCleanupClient(SDnode *pDnode) {
|
||||||
SDnodeTrans *pTrans = &pDnode->trans;
|
SDnodeTrans *pTrans = &pDnode->trans;
|
||||||
if (pTrans->clientRpc) {
|
if (pTrans->clientRpc) {
|
||||||
rpcClose(pTrans->clientRpc);
|
rpcClose(pTrans->clientRpc);
|
||||||
|
@ -414,8 +408,8 @@ static void dndCleanupClient(SDnode *pDnode) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int32_t dndGetHideUserAuth(SDnode *pDnode, char *user, char *spi, char *encrypt, char *secret,
|
static inline int32_t dmGetHideUserAuth(SDnode *pDnode, char *user, char *spi, char *encrypt, char *secret,
|
||||||
char *ckey) {
|
char *ckey) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
char pass[TSDB_PASSWORD_LEN + 1] = {0};
|
char pass[TSDB_PASSWORD_LEN + 1] = {0};
|
||||||
|
|
||||||
|
@ -437,9 +431,9 @@ static inline int32_t dndGetHideUserAuth(SDnode *pDnode, char *user, char *spi,
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int32_t dndRetrieveUserAuthInfo(SDnode *pDnode, char *user, char *spi, char *encrypt, char *secret,
|
static inline int32_t dmRetrieveUserAuthInfo(SDnode *pDnode, char *user, char *spi, char *encrypt, char *secret,
|
||||||
char *ckey) {
|
char *ckey) {
|
||||||
if (dndGetHideUserAuth(pDnode, user, spi, encrypt, secret, ckey) == 0) {
|
if (dmGetHideUserAuth(pDnode, user, spi, encrypt, secret, ckey) == 0) {
|
||||||
dTrace("user:%s, get auth from mnode, spi:%d encrypt:%d", user, *spi, *encrypt);
|
dTrace("user:%s, get auth from mnode, spi:%d encrypt:%d", user, *spi, *encrypt);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -473,18 +467,18 @@ static inline int32_t dndRetrieveUserAuthInfo(SDnode *pDnode, char *user, char *
|
||||||
return rpcRsp.code;
|
return rpcRsp.code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t dndInitServer(SDnode *pDnode) {
|
static int32_t dmInitServer(SDnode *pDnode) {
|
||||||
SDnodeTrans *pTrans = &pDnode->trans;
|
SDnodeTrans *pTrans = &pDnode->trans;
|
||||||
|
|
||||||
SRpcInit rpcInit = {0};
|
SRpcInit rpcInit = {0};
|
||||||
rpcInit.localPort = pDnode->data.serverPort;
|
rpcInit.localPort = pDnode->data.serverPort;
|
||||||
rpcInit.label = "DND";
|
rpcInit.label = "DND";
|
||||||
rpcInit.numOfThreads = tsNumOfRpcThreads;
|
rpcInit.numOfThreads = tsNumOfRpcThreads;
|
||||||
rpcInit.cfp = (RpcCfp)dndProcessMsg;
|
rpcInit.cfp = (RpcCfp)dmProcessMsg;
|
||||||
rpcInit.sessions = tsMaxShellConns;
|
rpcInit.sessions = tsMaxShellConns;
|
||||||
rpcInit.connType = TAOS_CONN_SERVER;
|
rpcInit.connType = TAOS_CONN_SERVER;
|
||||||
rpcInit.idleTime = tsShellActivityTimer * 1000;
|
rpcInit.idleTime = tsShellActivityTimer * 1000;
|
||||||
rpcInit.afp = (RpcAfp)dndRetrieveUserAuthInfo;
|
rpcInit.afp = (RpcAfp)dmRetrieveUserAuthInfo;
|
||||||
rpcInit.parent = pDnode;
|
rpcInit.parent = pDnode;
|
||||||
|
|
||||||
pTrans->serverRpc = rpcOpen(&rpcInit);
|
pTrans->serverRpc = rpcOpen(&rpcInit);
|
||||||
|
@ -497,7 +491,7 @@ static int32_t dndInitServer(SDnode *pDnode) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dndCleanupServer(SDnode *pDnode) {
|
static void dmCleanupServer(SDnode *pDnode) {
|
||||||
SDnodeTrans *pTrans = &pDnode->trans;
|
SDnodeTrans *pTrans = &pDnode->trans;
|
||||||
if (pTrans->serverRpc) {
|
if (pTrans->serverRpc) {
|
||||||
rpcClose(pTrans->serverRpc);
|
rpcClose(pTrans->serverRpc);
|
||||||
|
@ -507,21 +501,21 @@ static void dndCleanupServer(SDnode *pDnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t dmInitTrans(SDnode *pDnode) {
|
int32_t dmInitTrans(SDnode *pDnode) {
|
||||||
if (dndInitServer(pDnode) != 0) return -1;
|
if (dmInitServer(pDnode) != 0) return -1;
|
||||||
if (dndInitClient(pDnode) != 0) return -1;
|
if (dmInitClient(pDnode) != 0) return -1;
|
||||||
|
|
||||||
SMsgCb msgCb = {
|
SMsgCb msgCb = {
|
||||||
.sendReqFp = dndSendReq,
|
.sendReqFp = dmSendReq,
|
||||||
.sendRspFp = dndSendRsp,
|
.sendRspFp = dmSendRsp,
|
||||||
.registerBrokenLinkArgFp = dndRegisterBrokenLinkArg,
|
.registerBrokenLinkArgFp = dmRegisterBrokenLinkArg,
|
||||||
.releaseHandleFp = dndReleaseHandle,
|
.releaseHandleFp = dmReleaseHandle,
|
||||||
};
|
};
|
||||||
pDnode->data.msgCb = msgCb;
|
pDnode->data.msgCb = msgCb;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dndCleanupTrans(SDnode *pDnode) {
|
void dmCleanupTrans(SDnode *pDnode) {
|
||||||
dndCleanupServer(pDnode);
|
dmCleanupServer(pDnode);
|
||||||
dndCleanupClient(pDnode);
|
dmCleanupClient(pDnode);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ static void *dmStatusThreadFp(void *param) {
|
||||||
int64_t curTime = taosGetTimestampMs();
|
int64_t curTime = taosGetTimestampMs();
|
||||||
float interval = (curTime - lastTime) / 1000.0f;
|
float interval = (curTime - lastTime) / 1000.0f;
|
||||||
if (interval >= tsStatusInterval) {
|
if (interval >= tsStatusInterval) {
|
||||||
dmSendStatusReq(pMgmt);
|
dmSendStatusReq(pDnode);
|
||||||
lastTime = curTime;
|
lastTime = curTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,8 +67,8 @@ static void *dmMonitorThreadFp(void *param) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t dmStartStatusThread(SDnode *pDnode) {
|
int32_t dmStartStatusThread(SDnode *pDnode) {
|
||||||
pDnode->statusThreadId = taosCreateThread(dmStatusThreadFp, pDnode);
|
pDnode->data.statusThreadId = taosCreateThread(dmStatusThreadFp, pDnode);
|
||||||
if (pDnode->statusThreadId == NULL) {
|
if (pDnode->data.statusThreadId == NULL) {
|
||||||
dError("failed to init dnode status thread");
|
dError("failed to init dnode status thread");
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -78,15 +78,15 @@ int32_t dmStartStatusThread(SDnode *pDnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void dmStopStatusThread(SDnode *pDnode) {
|
void dmStopStatusThread(SDnode *pDnode) {
|
||||||
if (pDnode->statusThreadId != NULL) {
|
if (pDnode->data.statusThreadId != NULL) {
|
||||||
taosDestoryThread(pDnode->statusThreadId);
|
taosDestoryThread(pDnode->data.statusThreadId);
|
||||||
pDnode->statusThreadId = NULL;
|
pDnode->data.statusThreadId = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t dmStartMonitorThread(SDnode *pDnode) {
|
int32_t dmStartMonitorThread(SDnode *pDnode) {
|
||||||
pDnode->monitorThreadId = taosCreateThread(dmMonitorThreadFp, pDnode);
|
pDnode->data.monitorThreadId = taosCreateThread(dmMonitorThreadFp, pDnode);
|
||||||
if (pDnode->monitorThreadId == NULL) {
|
if (pDnode->data.monitorThreadId == NULL) {
|
||||||
dError("failed to init dnode monitor thread");
|
dError("failed to init dnode monitor thread");
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -96,9 +96,9 @@ int32_t dmStartMonitorThread(SDnode *pDnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void dmStopMonitorThread(SDnode *pDnode) {
|
void dmStopMonitorThread(SDnode *pDnode) {
|
||||||
if (pMgmt->monitorThreadId != NULL) {
|
if (pDnode->data.monitorThreadId != NULL) {
|
||||||
taosDestoryThread(pMgmt->monitorThreadId);
|
taosDestoryThread(pDnode->data.monitorThreadId);
|
||||||
pMgmt->monitorThreadId = NULL;
|
pDnode->data.monitorThreadId = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,16 +110,39 @@ static void dmProcessMgmtQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) {
|
||||||
|
|
||||||
switch (pRpc->msgType) {
|
switch (pRpc->msgType) {
|
||||||
case TDMT_DND_CONFIG_DNODE:
|
case TDMT_DND_CONFIG_DNODE:
|
||||||
code = dmProcessConfigReq(pMgmt, pMsg);
|
code = dmProcessConfigReq(pDnode, pMsg);
|
||||||
break;
|
break;
|
||||||
case TDMT_MND_AUTH_RSP:
|
case TDMT_MND_AUTH_RSP:
|
||||||
code = dmProcessAuthRsp(pMgmt, pMsg);
|
code = dmProcessAuthRsp(pDnode, pMsg);
|
||||||
break;
|
break;
|
||||||
case TDMT_MND_GRANT_RSP:
|
case TDMT_MND_GRANT_RSP:
|
||||||
code = dmProcessGrantRsp(pMgmt, pMsg);
|
code = dmProcessGrantRsp(pDnode, pMsg);
|
||||||
|
break;
|
||||||
|
case TDMT_DND_CREATE_MNODE:
|
||||||
|
code = dmProcessCreateNodeReq(pDnode, MNODE, pMsg);
|
||||||
|
break;
|
||||||
|
case TDMT_DND_DROP_MNODE:
|
||||||
|
code = dmProcessDropNodeReq(pDnode, MNODE, pMsg);
|
||||||
|
break;
|
||||||
|
case TDMT_DND_CREATE_QNODE:
|
||||||
|
code = dmProcessCreateNodeReq(pDnode, QNODE, pMsg);
|
||||||
|
break;
|
||||||
|
case TDMT_DND_DROP_QNODE:
|
||||||
|
code = dmProcessDropNodeReq(pDnode, QNODE, pMsg);
|
||||||
|
break;
|
||||||
|
case TDMT_DND_CREATE_SNODE:
|
||||||
|
code = dmProcessCreateNodeReq(pDnode, SNODE, pMsg);
|
||||||
|
break;
|
||||||
|
case TDMT_DND_DROP_SNODE:
|
||||||
|
code = dmProcessDropNodeReq(pDnode, SNODE, pMsg);
|
||||||
|
break;
|
||||||
|
case TDMT_DND_CREATE_BNODE:
|
||||||
|
code = dmProcessCreateNodeReq(pDnode, BNODE, pMsg);
|
||||||
|
break;
|
||||||
|
case TDMT_DND_DROP_BNODE:
|
||||||
|
code = dmProcessDropNodeReq(pDnode, BNODE, pMsg);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
code = dmProcessCDnodeReq(pMgmt->pDnode, pMsg);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,9 +157,9 @@ static void dmProcessMgmtQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) {
|
||||||
taosFreeQitem(pMsg);
|
taosFreeQitem(pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t dmStartWorker(SDnodeData *pMgmt) {
|
int32_t dmStartWorker(SDnode *pDnode) {
|
||||||
SSingleWorkerCfg cfg = {.min = 1, .max = 1, .name = "dnode-mgmt", .fp = (FItem)dmProcessMgmtQueue, .param = pMgmt};
|
SSingleWorkerCfg cfg = {.min = 1, .max = 1, .name = "dnode-mgmt", .fp = (FItem)dmProcessMgmtQueue, .param = pDnode};
|
||||||
if (tSingleWorkerInit(&pMgmt->mgmtWorker, &cfg) != 0) {
|
if (tSingleWorkerInit(&pDnode->data.mgmtWorker, &cfg) != 0) {
|
||||||
dError("failed to start dnode-mgmt worker since %s", terrstr());
|
dError("failed to start dnode-mgmt worker since %s", terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -145,24 +168,13 @@ int32_t dmStartWorker(SDnodeData *pMgmt) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dmStopWorker(SDnodeData *pMgmt) {
|
void dmStopWorker(SDnode *pDnode) {
|
||||||
tSingleWorkerCleanup(&pMgmt->mgmtWorker);
|
tSingleWorkerCleanup(&pDnode->data.mgmtWorker);
|
||||||
dDebug("dnode workers are closed");
|
dDebug("dnode workers are closed");
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t dmProcessMgmtMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
int32_t dmProcessMgmtMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
||||||
SDnodeData *pMgmt = pWrapper->pMgmt;
|
SSingleWorker *pWorker = &pWrapper->pDnode->data.mgmtWorker;
|
||||||
SSingleWorker *pWorker = &pMgmt->mgmtWorker;
|
|
||||||
|
|
||||||
dTrace("msg:%p, put into worker %s", pMsg, pWorker->name);
|
|
||||||
taosWriteQitem(pWorker->queue, pMsg);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t dmProcessStatusMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
|
||||||
SDnodeData *pMgmt = pWrapper->pMgmt;
|
|
||||||
SSingleWorker *pWorker = &pMgmt->monitorWorker;
|
|
||||||
|
|
||||||
dTrace("msg:%p, put into worker %s", pMsg, pWorker->name);
|
dTrace("msg:%p, put into worker %s", pMsg, pWorker->name);
|
||||||
taosWriteQitem(pWorker->queue, pMsg);
|
taosWriteQitem(pWorker->queue, pMsg);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _TD_DND_DEF_H_
|
#ifndef _TD_DM_DEF_H_
|
||||||
#define _TD_DND_DEF_H_
|
#define _TD_DM_DEF_H_
|
||||||
|
|
||||||
#include "dmLog.h"
|
#include "dmLog.h"
|
||||||
|
|
||||||
|
@ -110,9 +110,9 @@ typedef struct {
|
||||||
int64_t updateTime;
|
int64_t updateTime;
|
||||||
int64_t rebootTime;
|
int64_t rebootTime;
|
||||||
bool dropped;
|
bool dropped;
|
||||||
SEpSet mnodeEpSet;
|
SEpSet mnodeEps;
|
||||||
SHashObj *dnodeHash;
|
|
||||||
SArray *dnodeEps;
|
SArray *dnodeEps;
|
||||||
|
SHashObj *dnodeHash;
|
||||||
TdThread *statusThreadId;
|
TdThread *statusThreadId;
|
||||||
TdThread *monitorThreadId;
|
TdThread *monitorThreadId;
|
||||||
SRWLatch latch;
|
SRWLatch latch;
|
||||||
|
@ -140,6 +140,7 @@ typedef struct SDnode {
|
||||||
SStartupReq startup;
|
SStartupReq startup;
|
||||||
SDnodeTrans trans;
|
SDnodeTrans trans;
|
||||||
SDnodeData data;
|
SDnodeData data;
|
||||||
|
SRWLatch wrapperLock;
|
||||||
SMgmtWrapper wrappers[NODE_END];
|
SMgmtWrapper wrappers[NODE_END];
|
||||||
} SDnode;
|
} SDnode;
|
||||||
|
|
||||||
|
@ -147,4 +148,4 @@ typedef struct SDnode {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /*_TD_DND_DEF_H_*/
|
#endif /*_TD_DM_DEF_H_*/
|
|
@ -13,8 +13,8 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _TD_DND_INT_H_
|
#ifndef _TD_DM_INT_H_
|
||||||
#define _TD_DND_INT_H_
|
#define _TD_DM_INT_H_
|
||||||
|
|
||||||
#include "dmDef.h"
|
#include "dmDef.h"
|
||||||
|
|
||||||
|
@ -22,32 +22,32 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// dndInt.c
|
// dmInt.c
|
||||||
const char *dndStatName(EDndRunStatus stat);
|
SMgmtWrapper *dmAcquireWrapper(SDnode *pDnode, EDndNodeType nType);
|
||||||
const char *dndLogName(EDndNodeType ntype);
|
int32_t dmMarkWrapper(SMgmtWrapper *pWrapper);
|
||||||
const char *dndProcName(EDndNodeType ntype);
|
void dmReleaseWrapper(SMgmtWrapper *pWrapper);
|
||||||
const char *dndEventName(EDndEvent ev);
|
const char *dmStatName(EDndRunStatus stat);
|
||||||
SMgmtWrapper *dndAcquireWrapper(SDnode *pDnode, EDndNodeType nType);
|
const char *dmLogName(EDndNodeType ntype);
|
||||||
int32_t dndMarkWrapper(SMgmtWrapper *pWrapper);
|
const char *dmProcName(EDndNodeType ntype);
|
||||||
void dndReleaseWrapper(SMgmtWrapper *pWrapper);
|
const char *dmEventName(EDndEvent ev);
|
||||||
EDndRunStatus dndGetStatus(SDnode *pDnode);
|
|
||||||
void dndSetStatus(SDnode *pDnode, EDndRunStatus stat);
|
|
||||||
void dndSetEvent(SDnode *pDnode, EDndEvent event);
|
|
||||||
void dndSetMsgHandle(SMgmtWrapper *pWrapper, tmsg_t msgType, NodeMsgFp nodeMsgFp, int8_t vgId);
|
|
||||||
void dndReportStartup(SDnode *pDnode, const char *pName, const char *pDesc);
|
|
||||||
void dndProcessStartupReq(SDnode *pDnode, SRpcMsg *pMsg);
|
|
||||||
void dndGetMonitorSysInfo(SMonSysInfo *pInfo);
|
|
||||||
SMsgCb dmGetMsgcb(SMgmtWrapper *pWrapper);
|
|
||||||
|
|
||||||
// dndFile.c
|
void dmSetStatus(SDnode *pDnode, EDndRunStatus stat);
|
||||||
int32_t dndReadFile(SMgmtWrapper *pWrapper, bool *pDeployed);
|
void dmSetEvent(SDnode *pDnode, EDndEvent event);
|
||||||
int32_t dndWriteFile(SMgmtWrapper *pWrapper, bool deployed);
|
void dmSetMsgHandle(SMgmtWrapper *pWrapper, tmsg_t msgType, NodeMsgFp nodeMsgFp, int8_t vgId);
|
||||||
TdFilePtr dndCheckRunning(const char *dataDir);
|
void dmReportStartup(SDnode *pDnode, const char *pName, const char *pDesc);
|
||||||
int32_t dndReadShmFile(SDnode *pDnode);
|
void dmProcessStartupReq(SDnode *pDnode, SRpcMsg *pMsg);
|
||||||
int32_t dndWriteShmFile(SDnode *pDnode);
|
void dmGetMonitorSysInfo(SMonSysInfo *pInfo);
|
||||||
|
SMsgCb dmGetMsgcb(SMgmtWrapper *pWrapper);
|
||||||
|
|
||||||
|
// dmFile.c
|
||||||
|
int32_t dmReadFile(SMgmtWrapper *pWrapper, bool *pDeployed);
|
||||||
|
int32_t dmWriteFile(SMgmtWrapper *pWrapper, bool deployed);
|
||||||
|
TdFilePtr dmCheckRunning(const char *dataDir);
|
||||||
|
int32_t dmReadShmFile(SDnode *pDnode);
|
||||||
|
int32_t dmWriteShmFile(SDnode *pDnode);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /*_TD_DND_INT_H_*/
|
#endif /*_TD_DM_INT_H_*/
|
|
@ -13,8 +13,8 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _TD_DND_LOG_H_
|
#ifndef _TD_DM_LOG_H_
|
||||||
#define _TD_DND_LOG_H_
|
#define _TD_DM_LOG_H_
|
||||||
|
|
||||||
#include "tlog.h"
|
#include "tlog.h"
|
||||||
|
|
||||||
|
@ -33,4 +33,4 @@ extern "C" {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /*_TD_DND_LOG_H_*/
|
#endif /*_TD_DM_LOG_H_*/
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
static int8_t once = DND_ENV_INIT;
|
static int8_t once = DND_ENV_INIT;
|
||||||
|
|
||||||
int32_t dndInit() {
|
int32_t dmInit() {
|
||||||
dDebug("start to init dnode env");
|
dDebug("start to init dnode env");
|
||||||
if (atomic_val_compare_exchange_8(&once, DND_ENV_INIT, DND_ENV_READY) != DND_ENV_INIT) {
|
if (atomic_val_compare_exchange_8(&once, DND_ENV_INIT, DND_ENV_READY) != DND_ENV_INIT) {
|
||||||
terrno = TSDB_CODE_REPEAT_INIT;
|
terrno = TSDB_CODE_REPEAT_INIT;
|
||||||
|
@ -45,7 +45,7 @@ int32_t dndInit() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dndCleanup() {
|
void dmCleanup() {
|
||||||
dDebug("start to cleanup dnode env");
|
dDebug("start to cleanup dnode env");
|
||||||
if (atomic_val_compare_exchange_8(&once, DND_ENV_READY, DND_ENV_CLEANUP) != DND_ENV_READY) {
|
if (atomic_val_compare_exchange_8(&once, DND_ENV_READY, DND_ENV_CLEANUP) != DND_ENV_READY) {
|
||||||
dError("dnode env is already cleaned up");
|
dError("dnode env is already cleaned up");
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
#define MAXLEN 1024
|
#define MAXLEN 1024
|
||||||
|
|
||||||
int32_t dndReadFile(SMgmtWrapper *pWrapper, bool *pDeployed) {
|
int32_t dmReadFile(SMgmtWrapper *pWrapper, bool *pDeployed) {
|
||||||
int32_t code = TSDB_CODE_INVALID_JSON_FORMAT;
|
int32_t code = TSDB_CODE_INVALID_JSON_FORMAT;
|
||||||
int64_t len = 0;
|
int64_t len = 0;
|
||||||
char content[MAXLEN + 1] = {0};
|
char content[MAXLEN + 1] = {0};
|
||||||
|
@ -64,7 +64,7 @@ _OVER:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t dndWriteFile(SMgmtWrapper *pWrapper, bool deployed) {
|
int32_t dmWriteFile(SMgmtWrapper *pWrapper, bool deployed) {
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
char content[MAXLEN + 1] = {0};
|
char content[MAXLEN + 1] = {0};
|
||||||
|
@ -117,7 +117,7 @@ _OVER:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
TdFilePtr dndCheckRunning(const char *dataDir) {
|
TdFilePtr dmCheckRunning(const char *dataDir) {
|
||||||
char filepath[PATH_MAX] = {0};
|
char filepath[PATH_MAX] = {0};
|
||||||
snprintf(filepath, sizeof(filepath), "%s%s.running", dataDir, TD_DIRSEP);
|
snprintf(filepath, sizeof(filepath), "%s%s.running", dataDir, TD_DIRSEP);
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ TdFilePtr dndCheckRunning(const char *dataDir) {
|
||||||
return pFile;
|
return pFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t dndReadShmFile(SDnode *pDnode) {
|
int32_t dmReadShmFile(SDnode *pDnode) {
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
char itemName[24] = {0};
|
char itemName[24] = {0};
|
||||||
char content[MAXLEN + 1] = {0};
|
char content[MAXLEN + 1] = {0};
|
||||||
|
@ -165,13 +165,13 @@ int32_t dndReadShmFile(SDnode *pDnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (EDndNodeType ntype = NODE_BEGIN + 1; ntype < NODE_END; ++ntype) {
|
for (EDndNodeType ntype = NODE_BEGIN + 1; ntype < NODE_END; ++ntype) {
|
||||||
snprintf(itemName, sizeof(itemName), "%s_shmid", dndProcName(ntype));
|
snprintf(itemName, sizeof(itemName), "%s_shmid", dmProcName(ntype));
|
||||||
cJSON *shmid = cJSON_GetObjectItem(root, itemName);
|
cJSON *shmid = cJSON_GetObjectItem(root, itemName);
|
||||||
if (shmid && shmid->type == cJSON_Number) {
|
if (shmid && shmid->type == cJSON_Number) {
|
||||||
pDnode->wrappers[ntype].procShm.id = shmid->valueint;
|
pDnode->wrappers[ntype].procShm.id = shmid->valueint;
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(itemName, sizeof(itemName), "%s_shmsize", dndProcName(ntype));
|
snprintf(itemName, sizeof(itemName), "%s_shmsize", dmProcName(ntype));
|
||||||
cJSON *shmsize = cJSON_GetObjectItem(root, itemName);
|
cJSON *shmsize = cJSON_GetObjectItem(root, itemName);
|
||||||
if (shmsize && shmsize->type == cJSON_Number) {
|
if (shmsize && shmsize->type == cJSON_Number) {
|
||||||
pDnode->wrappers[ntype].procShm.size = shmsize->valueint;
|
pDnode->wrappers[ntype].procShm.size = shmsize->valueint;
|
||||||
|
@ -207,7 +207,7 @@ _OVER:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t dndWriteShmFile(SDnode *pDnode) {
|
int32_t dmWriteShmFile(SDnode *pDnode) {
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
char content[MAXLEN + 1] = {0};
|
char content[MAXLEN + 1] = {0};
|
||||||
|
@ -228,12 +228,11 @@ int32_t dndWriteShmFile(SDnode *pDnode) {
|
||||||
len += snprintf(content + len, MAXLEN - len, "{\n");
|
len += snprintf(content + len, MAXLEN - len, "{\n");
|
||||||
for (EDndNodeType ntype = NODE_BEGIN + 1; ntype < NODE_END; ++ntype) {
|
for (EDndNodeType ntype = NODE_BEGIN + 1; ntype < NODE_END; ++ntype) {
|
||||||
SMgmtWrapper *pWrapper = &pDnode->wrappers[ntype];
|
SMgmtWrapper *pWrapper = &pDnode->wrappers[ntype];
|
||||||
len += snprintf(content + len, MAXLEN - len, " \"%s_shmid\":%d,\n", dndProcName(ntype), pWrapper->procShm.id);
|
len += snprintf(content + len, MAXLEN - len, " \"%s_shmid\":%d,\n", dmProcName(ntype), pWrapper->procShm.id);
|
||||||
if (ntype == NODE_END - 1) {
|
if (ntype == NODE_END - 1) {
|
||||||
len += snprintf(content + len, MAXLEN - len, " \"%s_shmsize\":%d\n", dndProcName(ntype), pWrapper->procShm.size);
|
len += snprintf(content + len, MAXLEN - len, " \"%s_shmsize\":%d\n", dmProcName(ntype), pWrapper->procShm.size);
|
||||||
} else {
|
} else {
|
||||||
len +=
|
len += snprintf(content + len, MAXLEN - len, " \"%s_shmsize\":%d,\n", dmProcName(ntype), pWrapper->procShm.size);
|
||||||
snprintf(content + len, MAXLEN - len, " \"%s_shmsize\":%d,\n", dndProcName(ntype), pWrapper->procShm.size);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
len += snprintf(content + len, MAXLEN - len, "}\n");
|
len += snprintf(content + len, MAXLEN - len, "}\n");
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "dmInt.h"
|
#include "dmInt.h"
|
||||||
|
|
||||||
const char *dndStatName(EDndRunStatus status) {
|
const char *dmStatName(EDndRunStatus status) {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case DND_STAT_INIT:
|
case DND_STAT_INIT:
|
||||||
return "init";
|
return "init";
|
||||||
|
@ -29,7 +29,7 @@ const char *dndStatName(EDndRunStatus status) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *dndLogName(EDndNodeType ntype) {
|
const char *dmLogName(EDndNodeType ntype) {
|
||||||
switch (ntype) {
|
switch (ntype) {
|
||||||
case VNODE:
|
case VNODE:
|
||||||
return "vnode";
|
return "vnode";
|
||||||
|
@ -46,7 +46,7 @@ const char *dndLogName(EDndNodeType ntype) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *dndProcName(EDndNodeType ntype) {
|
const char *dmProcName(EDndNodeType ntype) {
|
||||||
switch (ntype) {
|
switch (ntype) {
|
||||||
case VNODE:
|
case VNODE:
|
||||||
return "taosv";
|
return "taosv";
|
||||||
|
@ -63,7 +63,7 @@ const char *dndProcName(EDndNodeType ntype) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *dndEventName(EDndEvent ev) {
|
const char *dmEventName(EDndEvent ev) {
|
||||||
switch (ev) {
|
switch (ev) {
|
||||||
case DND_EVENT_START:
|
case DND_EVENT_START:
|
||||||
return "start";
|
return "start";
|
||||||
|
@ -76,27 +76,25 @@ const char *dndEventName(EDndEvent ev) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EDndRunStatus dndGetStatus(SDnode *pDnode) { return pDnode->status; }
|
void dmSetStatus(SDnode *pDnode, EDndRunStatus status) {
|
||||||
|
|
||||||
void dndSetStatus(SDnode *pDnode, EDndRunStatus status) {
|
|
||||||
if (pDnode->status != status) {
|
if (pDnode->status != status) {
|
||||||
dDebug("dnode status set from %s to %s", dndStatName(pDnode->status), dndStatName(status));
|
dDebug("dnode status set from %s to %s", dmStatName(pDnode->status), dmStatName(status));
|
||||||
pDnode->status = status;
|
pDnode->status = status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void dndSetEvent(SDnode *pDnode, EDndEvent event) {
|
void dmSetEvent(SDnode *pDnode, EDndEvent event) {
|
||||||
if (event == DND_EVENT_STOP) {
|
if (event == DND_EVENT_STOP) {
|
||||||
pDnode->event = event;
|
pDnode->event = event;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void dndSetMsgHandle(SMgmtWrapper *pWrapper, tmsg_t msgType, NodeMsgFp nodeMsgFp, int8_t vgId) {
|
void dmSetMsgHandle(SMgmtWrapper *pWrapper, tmsg_t msgType, NodeMsgFp nodeMsgFp, int8_t vgId) {
|
||||||
pWrapper->msgFps[TMSG_INDEX(msgType)] = nodeMsgFp;
|
pWrapper->msgFps[TMSG_INDEX(msgType)] = nodeMsgFp;
|
||||||
pWrapper->msgVgIds[TMSG_INDEX(msgType)] = vgId;
|
pWrapper->msgVgIds[TMSG_INDEX(msgType)] = vgId;
|
||||||
}
|
}
|
||||||
|
|
||||||
SMgmtWrapper *dndAcquireWrapper(SDnode *pDnode, EDndNodeType ntype) {
|
SMgmtWrapper *dmAcquireWrapper(SDnode *pDnode, EDndNodeType ntype) {
|
||||||
SMgmtWrapper *pWrapper = &pDnode->wrappers[ntype];
|
SMgmtWrapper *pWrapper = &pDnode->wrappers[ntype];
|
||||||
SMgmtWrapper *pRetWrapper = pWrapper;
|
SMgmtWrapper *pRetWrapper = pWrapper;
|
||||||
|
|
||||||
|
@ -113,7 +111,7 @@ SMgmtWrapper *dndAcquireWrapper(SDnode *pDnode, EDndNodeType ntype) {
|
||||||
return pRetWrapper;
|
return pRetWrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t dndMarkWrapper(SMgmtWrapper *pWrapper) {
|
int32_t dmMarkWrapper(SMgmtWrapper *pWrapper) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
taosRLockLatch(&pWrapper->latch);
|
taosRLockLatch(&pWrapper->latch);
|
||||||
|
@ -129,7 +127,7 @@ int32_t dndMarkWrapper(SMgmtWrapper *pWrapper) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dndReleaseWrapper(SMgmtWrapper *pWrapper) {
|
void dmReleaseWrapper(SMgmtWrapper *pWrapper) {
|
||||||
if (pWrapper == NULL) return;
|
if (pWrapper == NULL) return;
|
||||||
|
|
||||||
taosRLockLatch(&pWrapper->latch);
|
taosRLockLatch(&pWrapper->latch);
|
||||||
|
@ -138,22 +136,22 @@ void dndReleaseWrapper(SMgmtWrapper *pWrapper) {
|
||||||
dTrace("node:%s, is released, refCount:%d", pWrapper->name, refCount);
|
dTrace("node:%s, is released, refCount:%d", pWrapper->name, refCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dndReportStartup(SDnode *pDnode, const char *pName, const char *pDesc) {
|
void dmReportStartup(SDnode *pDnode, const char *pName, const char *pDesc) {
|
||||||
SStartupReq *pStartup = &pDnode->startup;
|
SStartupReq *pStartup = &pDnode->startup;
|
||||||
tstrncpy(pStartup->name, pName, TSDB_STEP_NAME_LEN);
|
tstrncpy(pStartup->name, pName, TSDB_STEP_NAME_LEN);
|
||||||
tstrncpy(pStartup->desc, pDesc, TSDB_STEP_DESC_LEN);
|
tstrncpy(pStartup->desc, pDesc, TSDB_STEP_DESC_LEN);
|
||||||
pStartup->finished = 0;
|
pStartup->finished = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dndGetStartup(SDnode *pDnode, SStartupReq *pStartup) {
|
static void dmGetStartup(SDnode *pDnode, SStartupReq *pStartup) {
|
||||||
memcpy(pStartup, &pDnode->startup, sizeof(SStartupReq));
|
memcpy(pStartup, &pDnode->startup, sizeof(SStartupReq));
|
||||||
pStartup->finished = (dndGetStatus(pDnode) == DND_STAT_RUNNING);
|
pStartup->finished = (pDnode->status == DND_STAT_RUNNING);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dndProcessStartupReq(SDnode *pDnode, SRpcMsg *pReq) {
|
void dmProcessStartupReq(SDnode *pDnode, SRpcMsg *pReq) {
|
||||||
dDebug("startup req is received");
|
dDebug("startup req is received");
|
||||||
SStartupReq *pStartup = rpcMallocCont(sizeof(SStartupReq));
|
SStartupReq *pStartup = rpcMallocCont(sizeof(SStartupReq));
|
||||||
dndGetStartup(pDnode, pStartup);
|
dmGetStartup(pDnode, pStartup);
|
||||||
|
|
||||||
dDebug("startup req is sent, step:%s desc:%s finished:%d", pStartup->name, pStartup->desc, pStartup->finished);
|
dDebug("startup req is sent, step:%s desc:%s finished:%d", pStartup->name, pStartup->desc, pStartup->finished);
|
||||||
SRpcMsg rpcRsp = {
|
SRpcMsg rpcRsp = {
|
||||||
|
@ -161,7 +159,7 @@ void dndProcessStartupReq(SDnode *pDnode, SRpcMsg *pReq) {
|
||||||
rpcSendResponse(&rpcRsp);
|
rpcSendResponse(&rpcRsp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dndGetMonitorSysInfo(SMonSysInfo *pInfo) {
|
void dmGetMonitorSysInfo(SMonSysInfo *pInfo) {
|
||||||
taosGetCpuUsage(&pInfo->cpu_engine, &pInfo->cpu_system);
|
taosGetCpuUsage(&pInfo->cpu_engine, &pInfo->cpu_system);
|
||||||
taosGetCpuCores(&pInfo->cpu_cores);
|
taosGetCpuCores(&pInfo->cpu_cores);
|
||||||
taosGetProcMemory(&pInfo->mem_engine);
|
taosGetProcMemory(&pInfo->mem_engine);
|
||||||
|
|
|
@ -21,7 +21,7 @@ void bmGetMonitorInfo(SMgmtWrapper *pWrapper, SMonBmInfo *bmInfo) {}
|
||||||
int32_t bmProcessGetMonBmInfoReq(SMgmtWrapper *pWrapper, SNodeMsg *pReq) {
|
int32_t bmProcessGetMonBmInfoReq(SMgmtWrapper *pWrapper, SNodeMsg *pReq) {
|
||||||
SMonBmInfo bmInfo = {0};
|
SMonBmInfo bmInfo = {0};
|
||||||
bmGetMonitorInfo(pWrapper, &bmInfo);
|
bmGetMonitorInfo(pWrapper, &bmInfo);
|
||||||
dndGetMonitorSysInfo(&bmInfo.sys);
|
dmGetMonitorSysInfo(&bmInfo.sys);
|
||||||
monGetLogs(&bmInfo.log);
|
monGetLogs(&bmInfo.log);
|
||||||
|
|
||||||
int32_t rspLen = tSerializeSMonBmInfo(NULL, 0, &bmInfo);
|
int32_t rspLen = tSerializeSMonBmInfo(NULL, 0, &bmInfo);
|
||||||
|
@ -58,7 +58,7 @@ int32_t bmProcessCreateReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
||||||
dError("failed to create bnode since %s, input:%d cur:%d", terrstr(), createReq.dnodeId, pDnode->data.dnodeId);
|
dError("failed to create bnode since %s, input:%d cur:%d", terrstr(), createReq.dnodeId, pDnode->data.dnodeId);
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
// return dndOpenNode(pWrapper);
|
// return dmOpenNode(pWrapper);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,11 +78,11 @@ int32_t bmProcessDropReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
||||||
dError("failed to drop bnode since %s", terrstr());
|
dError("failed to drop bnode since %s", terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
// dndCloseNode(pWrapper);
|
// dmCloseNode(pWrapper);
|
||||||
return bmDrop(pWrapper);
|
return bmDrop(pWrapper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void bmInitMsgHandle(SMgmtWrapper *pWrapper) {
|
void bmInitMsgHandle(SMgmtWrapper *pWrapper) {
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MON_BM_INFO, bmProcessMonitorMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MON_BM_INFO, bmProcessMonitorMsg, DEFAULT_HANDLE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "bmInt.h"
|
#include "bmInt.h"
|
||||||
|
|
||||||
static int32_t bmRequire(SMgmtWrapper *pWrapper, bool *required) { return dndReadFile(pWrapper, required); }
|
static int32_t bmRequire(SMgmtWrapper *pWrapper, bool *required) { return dmReadFile(pWrapper, required); }
|
||||||
|
|
||||||
static void bmInitOption(SBnodeMgmt *pMgmt, SBnodeOpt *pOption) {
|
static void bmInitOption(SBnodeMgmt *pMgmt, SBnodeOpt *pOption) {
|
||||||
SMsgCb msgCb = dmGetMsgcb(pMgmt->pWrapper);
|
SMsgCb msgCb = dmGetMsgcb(pMgmt->pWrapper);
|
||||||
|
@ -39,7 +39,7 @@ static int32_t bmOpenImp(SBnodeMgmt *pMgmt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool deployed = true;
|
bool deployed = true;
|
||||||
if (dndWriteFile(pMgmt->pWrapper, deployed) != 0) {
|
if (dmWriteFile(pMgmt->pWrapper, deployed) != 0) {
|
||||||
dError("failed to write bnode file since %s", terrstr());
|
dError("failed to write bnode file since %s", terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ int32_t bmDrop(SMgmtWrapper *pWrapper) {
|
||||||
|
|
||||||
dInfo("bnode-mgmt start to drop");
|
dInfo("bnode-mgmt start to drop");
|
||||||
bool deployed = false;
|
bool deployed = false;
|
||||||
if (dndWriteFile(pWrapper, deployed) != 0) {
|
if (dmWriteFile(pWrapper, deployed) != 0) {
|
||||||
dError("failed to drop bnode since %s", terrstr());
|
dError("failed to drop bnode since %s", terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ void mmGetMonitorInfo(SMgmtWrapper *pWrapper, SMonMmInfo *mmInfo) {
|
||||||
int32_t mmProcessGetMonMmInfoReq(SMgmtWrapper *pWrapper, SNodeMsg *pReq) {
|
int32_t mmProcessGetMonMmInfoReq(SMgmtWrapper *pWrapper, SNodeMsg *pReq) {
|
||||||
SMonMmInfo mmInfo = {0};
|
SMonMmInfo mmInfo = {0};
|
||||||
mmGetMonitorInfo(pWrapper, &mmInfo);
|
mmGetMonitorInfo(pWrapper, &mmInfo);
|
||||||
dndGetMonitorSysInfo(&mmInfo.sys);
|
dmGetMonitorSysInfo(&mmInfo.sys);
|
||||||
monGetLogs(&mmInfo.log);
|
monGetLogs(&mmInfo.log);
|
||||||
|
|
||||||
int32_t rspLen = tSerializeSMonMmInfo(NULL, 0, &mmInfo);
|
int32_t rspLen = tSerializeSMonMmInfo(NULL, 0, &mmInfo);
|
||||||
|
@ -80,7 +80,7 @@ int32_t mmProcessDropReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
||||||
dError("failed to drop mnode since %s", terrstr());
|
dError("failed to drop mnode since %s", terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
// dndCloseNode(pWrapper);
|
// dmCloseNode(pWrapper);
|
||||||
return mmDrop(pWrapper);
|
return mmDrop(pWrapper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,96 +105,96 @@ int32_t mmProcessAlterReq(SMnodeMgmt *pMgmt, SNodeMsg *pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void mmInitMsgHandle(SMgmtWrapper *pWrapper) {
|
void mmInitMsgHandle(SMgmtWrapper *pWrapper) {
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MON_MM_INFO, mmProcessMonitorMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MON_MM_INFO, mmProcessMonitorMsg, DEFAULT_HANDLE);
|
||||||
|
|
||||||
// Requests handled by DNODE
|
// Requests handled by DNODE
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_MNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_DND_CREATE_MNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_ALTER_MNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_DND_ALTER_MNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_MNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_DND_DROP_MNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_QNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_DND_CREATE_QNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_QNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_DND_DROP_QNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_SNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_DND_CREATE_SNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_SNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_DND_DROP_SNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_BNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_DND_CREATE_BNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_BNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_DND_DROP_BNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_VNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_DND_CREATE_VNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_ALTER_VNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_DND_ALTER_VNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_VNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_DND_DROP_VNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_SYNC_VNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_DND_SYNC_VNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_COMPACT_VNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_DND_COMPACT_VNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_CONFIG_DNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_DND_CONFIG_DNODE_RSP, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
|
|
||||||
// Requests handled by MNODE
|
// Requests handled by MNODE
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_CONNECT, mmProcessReadMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_CONNECT, mmProcessReadMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_ACCT, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_CREATE_ACCT, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_ACCT, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_ALTER_ACCT, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_ACCT, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_DROP_ACCT, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_USER, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_CREATE_USER, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_USER, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_ALTER_USER, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_USER, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_DROP_USER, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_GET_USER_AUTH, mmProcessReadMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_GET_USER_AUTH, mmProcessReadMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_DNODE, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_CREATE_DNODE, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_CONFIG_DNODE, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_CONFIG_DNODE, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_DNODE, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_DROP_DNODE, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_MNODE, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_CREATE_MNODE, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_MNODE, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_DROP_MNODE, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_QNODE, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_CREATE_QNODE, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_QNODE, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_DROP_QNODE, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_SNODE, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_CREATE_SNODE, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_SNODE, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_DROP_SNODE, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_BNODE, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_CREATE_BNODE, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_BNODE, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_DROP_BNODE, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_DB, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_CREATE_DB, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_DB, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_DROP_DB, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_USE_DB, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_USE_DB, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_DB, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_ALTER_DB, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_SYNC_DB, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_SYNC_DB, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_COMPACT_DB, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_COMPACT_DB, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_FUNC, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_CREATE_FUNC, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_RETRIEVE_FUNC, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_RETRIEVE_FUNC, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_FUNC, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_DROP_FUNC, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_STB, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_CREATE_STB, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_STB, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_ALTER_STB, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_STB, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_DROP_STB, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_SMA, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_CREATE_SMA, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_SMA, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_DROP_SMA, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_TABLE_META, mmProcessReadMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_TABLE_META, mmProcessReadMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_VGROUP_LIST, mmProcessReadMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_VGROUP_LIST, mmProcessReadMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_KILL_QUERY, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_KILL_QUERY, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_KILL_CONN, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_KILL_CONN, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_HEARTBEAT, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_HEARTBEAT, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_SHOW, mmProcessReadMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_SHOW, mmProcessReadMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_SHOW_RETRIEVE, mmProcessReadMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_SHOW_RETRIEVE, mmProcessReadMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_SYSTABLE_RETRIEVE, mmProcessReadMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_SYSTABLE_RETRIEVE, mmProcessReadMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_STATUS, mmProcessReadMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_STATUS, mmProcessReadMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_KILL_TRANS, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_KILL_TRANS, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_GRANT, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_GRANT, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_AUTH, mmProcessReadMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_AUTH, mmProcessReadMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_ALTER_MNODE, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_DND_ALTER_MNODE, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_TOPIC, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_CREATE_TOPIC, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_TOPIC, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_ALTER_TOPIC, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_TOPIC, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_DROP_TOPIC, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_SUBSCRIBE, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_SUBSCRIBE, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_MQ_COMMIT_OFFSET, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_MQ_COMMIT_OFFSET, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_GET_SUB_EP, mmProcessReadMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_GET_SUB_EP, mmProcessReadMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_STREAM, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_CREATE_STREAM, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_TASK_DEPLOY_RSP, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_TASK_DEPLOY_RSP, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_GET_DB_CFG, mmProcessReadMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_GET_DB_CFG, mmProcessReadMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_GET_INDEX, mmProcessReadMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MND_GET_INDEX, mmProcessReadMsg, DEFAULT_HANDLE);
|
||||||
|
|
||||||
// Requests handled by VNODE
|
// Requests handled by VNODE
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_SET_CONN_RSP, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_MQ_SET_CONN_RSP, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_REB_RSP, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_MQ_REB_RSP, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_CANCEL_CONN_RSP, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_MQ_CANCEL_CONN_RSP, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_CREATE_STB_RSP, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_CREATE_STB_RSP, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_ALTER_STB_RSP, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_ALTER_STB_RSP, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_DROP_STB_RSP, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_DROP_STB_RSP, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_CREATE_SMA_RSP, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_CREATE_SMA_RSP, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_DROP_SMA_RSP, mmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_DROP_SMA_RSP, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_QUERY, mmProcessQueryMsg, MNODE_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_QUERY, mmProcessQueryMsg, MNODE_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_QUERY_CONTINUE, mmProcessQueryMsg, MNODE_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_QUERY_CONTINUE, mmProcessQueryMsg, MNODE_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_FETCH, mmProcessQueryMsg, MNODE_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_FETCH, mmProcessQueryMsg, MNODE_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_DROP_TASK, mmProcessQueryMsg, MNODE_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_DROP_TASK, mmProcessQueryMsg, MNODE_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_QUERY_HEARTBEAT, mmProcessQueryMsg, MNODE_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_QUERY_HEARTBEAT, mmProcessQueryMsg, MNODE_HANDLE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ void qmGetMonitorInfo(SMgmtWrapper *pWrapper, SMonQmInfo *qmInfo) {}
|
||||||
int32_t qmProcessGetMonQmInfoReq(SMgmtWrapper *pWrapper, SNodeMsg *pReq) {
|
int32_t qmProcessGetMonQmInfoReq(SMgmtWrapper *pWrapper, SNodeMsg *pReq) {
|
||||||
SMonQmInfo qmInfo = {0};
|
SMonQmInfo qmInfo = {0};
|
||||||
qmGetMonitorInfo(pWrapper, &qmInfo);
|
qmGetMonitorInfo(pWrapper, &qmInfo);
|
||||||
dndGetMonitorSysInfo(&qmInfo.sys);
|
dmGetMonitorSysInfo(&qmInfo.sys);
|
||||||
monGetLogs(&qmInfo.log);
|
monGetLogs(&qmInfo.log);
|
||||||
|
|
||||||
int32_t rspLen = tSerializeSMonQmInfo(NULL, 0, &qmInfo);
|
int32_t rspLen = tSerializeSMonQmInfo(NULL, 0, &qmInfo);
|
||||||
|
@ -58,7 +58,7 @@ int32_t qmProcessCreateReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
||||||
dError("failed to create qnode since %s", terrstr());
|
dError("failed to create qnode since %s", terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
// return dndOpenNode(pWrapper);
|
// return dmOpenNode(pWrapper);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,23 +78,23 @@ int32_t qmProcessDropReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
||||||
dError("failed to drop qnode since %s", terrstr());
|
dError("failed to drop qnode since %s", terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
// dndCloseNode(pWrapper);
|
// dmCloseNode(pWrapper);
|
||||||
return qmDrop(pWrapper);
|
return qmDrop(pWrapper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void qmInitMsgHandle(SMgmtWrapper *pWrapper) {
|
void qmInitMsgHandle(SMgmtWrapper *pWrapper) {
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MON_QM_INFO, qmProcessMonitorMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MON_QM_INFO, qmProcessMonitorMsg, DEFAULT_HANDLE);
|
||||||
|
|
||||||
// Requests handled by VNODE
|
// Requests handled by VNODE
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_QUERY, qmProcessQueryMsg, QNODE_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_QUERY, qmProcessQueryMsg, QNODE_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_QUERY_CONTINUE, qmProcessQueryMsg, QNODE_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_QUERY_CONTINUE, qmProcessQueryMsg, QNODE_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_FETCH, qmProcessFetchMsg, QNODE_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_FETCH, qmProcessFetchMsg, QNODE_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_FETCH_RSP, qmProcessFetchMsg, QNODE_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_FETCH_RSP, qmProcessFetchMsg, QNODE_HANDLE);
|
||||||
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_RES_READY, qmProcessFetchMsg, QNODE_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_RES_READY, qmProcessFetchMsg, QNODE_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_TASKS_STATUS, qmProcessFetchMsg, QNODE_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_TASKS_STATUS, qmProcessFetchMsg, QNODE_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_CANCEL_TASK, qmProcessFetchMsg, QNODE_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_CANCEL_TASK, qmProcessFetchMsg, QNODE_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_DROP_TASK, qmProcessFetchMsg, QNODE_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_DROP_TASK, qmProcessFetchMsg, QNODE_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_SHOW_TABLES, qmProcessFetchMsg, QNODE_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_SHOW_TABLES, qmProcessFetchMsg, QNODE_HANDLE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "qmInt.h"
|
#include "qmInt.h"
|
||||||
|
|
||||||
static int32_t qmRequire(SMgmtWrapper *pWrapper, bool *required) { return dndReadFile(pWrapper, required); }
|
static int32_t qmRequire(SMgmtWrapper *pWrapper, bool *required) { return dmReadFile(pWrapper, required); }
|
||||||
|
|
||||||
static void qmInitOption(SQnodeMgmt *pMgmt, SQnodeOpt *pOption) {
|
static void qmInitOption(SQnodeMgmt *pMgmt, SQnodeOpt *pOption) {
|
||||||
SMsgCb msgCb = dmGetMsgcb(pMgmt->pWrapper);
|
SMsgCb msgCb = dmGetMsgcb(pMgmt->pWrapper);
|
||||||
|
@ -42,7 +42,7 @@ static int32_t qmOpenImp(SQnodeMgmt *pMgmt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool deployed = true;
|
bool deployed = true;
|
||||||
if (dndWriteFile(pMgmt->pWrapper, deployed) != 0) {
|
if (dmWriteFile(pMgmt->pWrapper, deployed) != 0) {
|
||||||
dError("failed to write qnode file since %s", terrstr());
|
dError("failed to write qnode file since %s", terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ int32_t qmDrop(SMgmtWrapper *pWrapper) {
|
||||||
|
|
||||||
dInfo("qnode-mgmt start to drop");
|
dInfo("qnode-mgmt start to drop");
|
||||||
bool deployed = false;
|
bool deployed = false;
|
||||||
if (dndWriteFile(pWrapper, deployed) != 0) {
|
if (dmWriteFile(pWrapper, deployed) != 0) {
|
||||||
dError("failed to drop qnode since %s", terrstr());
|
dError("failed to drop qnode since %s", terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ void smGetMonitorInfo(SMgmtWrapper *pWrapper, SMonSmInfo *smInfo) {}
|
||||||
int32_t smProcessGetMonSmInfoReq(SMgmtWrapper *pWrapper, SNodeMsg *pReq) {
|
int32_t smProcessGetMonSmInfoReq(SMgmtWrapper *pWrapper, SNodeMsg *pReq) {
|
||||||
SMonSmInfo smInfo = {0};
|
SMonSmInfo smInfo = {0};
|
||||||
smGetMonitorInfo(pWrapper, &smInfo);
|
smGetMonitorInfo(pWrapper, &smInfo);
|
||||||
dndGetMonitorSysInfo(&smInfo.sys);
|
dmGetMonitorSysInfo(&smInfo.sys);
|
||||||
monGetLogs(&smInfo.log);
|
monGetLogs(&smInfo.log);
|
||||||
|
|
||||||
int32_t rspLen = tSerializeSMonSmInfo(NULL, 0, &smInfo);
|
int32_t rspLen = tSerializeSMonSmInfo(NULL, 0, &smInfo);
|
||||||
|
@ -58,7 +58,7 @@ int32_t smProcessCreateReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
||||||
dError("failed to create snode since %s", terrstr());
|
dError("failed to create snode since %s", terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
// return dndOpenNode(pWrapper);
|
// return dmOpenNode(pWrapper);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,14 +79,14 @@ int32_t smProcessDropReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
return smDrop(pWrapper);
|
return smDrop(pWrapper);
|
||||||
// return dndCloseNode(pWrapper);
|
// return dmCloseNode(pWrapper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void smInitMsgHandle(SMgmtWrapper *pWrapper) {
|
void smInitMsgHandle(SMgmtWrapper *pWrapper) {
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MON_SM_INFO, smProcessMonitorMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MON_SM_INFO, smProcessMonitorMsg, DEFAULT_HANDLE);
|
||||||
|
|
||||||
// Requests handled by SNODE
|
// Requests handled by SNODE
|
||||||
dndSetMsgHandle(pWrapper, TDMT_SND_TASK_DEPLOY, smProcessMgmtMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_SND_TASK_DEPLOY, smProcessMgmtMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_SND_TASK_EXEC, smProcessExecMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_SND_TASK_EXEC, smProcessExecMsg, DEFAULT_HANDLE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "smInt.h"
|
#include "smInt.h"
|
||||||
|
|
||||||
static int32_t smRequire(SMgmtWrapper *pWrapper, bool *required) { return dndReadFile(pWrapper, required); }
|
static int32_t smRequire(SMgmtWrapper *pWrapper, bool *required) { return dmReadFile(pWrapper, required); }
|
||||||
|
|
||||||
static void smInitOption(SSnodeMgmt *pMgmt, SSnodeOpt *pOption) {
|
static void smInitOption(SSnodeMgmt *pMgmt, SSnodeOpt *pOption) {
|
||||||
SMsgCb msgCb = dmGetMsgcb(pMgmt->pWrapper);
|
SMsgCb msgCb = dmGetMsgcb(pMgmt->pWrapper);
|
||||||
|
@ -39,7 +39,7 @@ static int32_t smOpenImp(SSnodeMgmt *pMgmt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool deployed = true;
|
bool deployed = true;
|
||||||
if (dndWriteFile(pMgmt->pWrapper, deployed) != 0) {
|
if (dmWriteFile(pMgmt->pWrapper, deployed) != 0) {
|
||||||
dError("failed to write snode file since %s", terrstr());
|
dError("failed to write snode file since %s", terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ int32_t smDrop(SMgmtWrapper *pWrapper) {
|
||||||
|
|
||||||
dInfo("snode-mgmt start to drop");
|
dInfo("snode-mgmt start to drop");
|
||||||
bool deployed = false;
|
bool deployed = false;
|
||||||
if (dndWriteFile(pWrapper, deployed) != 0) {
|
if (dmWriteFile(pWrapper, deployed) != 0) {
|
||||||
dError("failed to drop snode since %s", terrstr());
|
dError("failed to drop snode since %s", terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ void vmGetMonitorInfo(SMgmtWrapper *pWrapper, SMonVmInfo *vmInfo) {
|
||||||
int32_t vmProcessGetMonVmInfoReq(SMgmtWrapper *pWrapper, SNodeMsg *pReq) {
|
int32_t vmProcessGetMonVmInfoReq(SMgmtWrapper *pWrapper, SNodeMsg *pReq) {
|
||||||
SMonVmInfo vmInfo = {0};
|
SMonVmInfo vmInfo = {0};
|
||||||
vmGetMonitorInfo(pWrapper, &vmInfo);
|
vmGetMonitorInfo(pWrapper, &vmInfo);
|
||||||
dndGetMonitorSysInfo(&vmInfo.sys);
|
dmGetMonitorSysInfo(&vmInfo.sys);
|
||||||
monGetLogs(&vmInfo.log);
|
monGetLogs(&vmInfo.log);
|
||||||
|
|
||||||
int32_t rspLen = tSerializeSMonVmInfo(NULL, 0, &vmInfo);
|
int32_t rspLen = tSerializeSMonVmInfo(NULL, 0, &vmInfo);
|
||||||
|
@ -304,54 +304,54 @@ int32_t vmProcessCompactVnodeReq(SVnodesMgmt *pMgmt, SNodeMsg *pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void vmInitMsgHandle(SMgmtWrapper *pWrapper) {
|
void vmInitMsgHandle(SMgmtWrapper *pWrapper) {
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MON_VM_INFO, vmProcessMonitorMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MON_VM_INFO, vmProcessMonitorMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MON_VM_LOAD, vmProcessMonitorMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_MON_VM_LOAD, vmProcessMonitorMsg, DEFAULT_HANDLE);
|
||||||
|
|
||||||
// Requests handled by VNODE
|
// Requests handled by VNODE
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_SUBMIT, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_SUBMIT, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_QUERY, (NodeMsgFp)vmProcessQueryMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_QUERY, (NodeMsgFp)vmProcessQueryMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_QUERY_CONTINUE, (NodeMsgFp)vmProcessQueryMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_QUERY_CONTINUE, (NodeMsgFp)vmProcessQueryMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_FETCH, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_FETCH, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_FETCH_RSP, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_FETCH_RSP, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_ALTER_TABLE, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_ALTER_TABLE, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_UPDATE_TAG_VAL, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_UPDATE_TAG_VAL, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_TABLE_META, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_TABLE_META, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_TABLES_META, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_TABLES_META, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_CONSUME, (NodeMsgFp)vmProcessQueryMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_MQ_CONSUME, (NodeMsgFp)vmProcessQueryMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_QUERY, (NodeMsgFp)vmProcessQueryMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_MQ_QUERY, (NodeMsgFp)vmProcessQueryMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_CONNECT, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_MQ_CONNECT, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_DISCONNECT, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_MQ_DISCONNECT, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_SET_CUR, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_MQ_SET_CUR, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_RES_READY, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_RES_READY, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_TASKS_STATUS, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_TASKS_STATUS, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_CANCEL_TASK, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_CANCEL_TASK, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_DROP_TASK, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_DROP_TASK, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_CREATE_STB, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_CREATE_STB, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_ALTER_STB, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_ALTER_STB, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_DROP_STB, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_DROP_STB, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_CREATE_TABLE, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_CREATE_TABLE, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_ALTER_TABLE, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_ALTER_TABLE, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_DROP_TABLE, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_DROP_TABLE, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_CREATE_SMA, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_CREATE_SMA, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_CANCEL_SMA, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_CANCEL_SMA, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_DROP_SMA, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_DROP_SMA, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_SHOW_TABLES, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_SHOW_TABLES, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_SHOW_TABLES_FETCH, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_SHOW_TABLES_FETCH, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_SET_CONN, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_MQ_SET_CONN, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_REB, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_MQ_REB, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_CANCEL_CONN, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_MQ_CANCEL_CONN, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_SET_CUR, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_MQ_SET_CUR, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_CONSUME, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_CONSUME, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_TASK_DEPLOY, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_TASK_DEPLOY, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_QUERY_HEARTBEAT, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_QUERY_HEARTBEAT, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_TASK_PIPE_EXEC, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_TASK_PIPE_EXEC, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_TASK_MERGE_EXEC, (NodeMsgFp)vmProcessMergeMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_TASK_MERGE_EXEC, (NodeMsgFp)vmProcessMergeMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_TASK_WRITE_EXEC, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_TASK_WRITE_EXEC, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_STREAM_TRIGGER, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_STREAM_TRIGGER, (NodeMsgFp)vmProcessFetchMsg, DEFAULT_HANDLE);
|
||||||
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_VNODE, vmProcessMgmtMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_DND_CREATE_VNODE, vmProcessMgmtMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_ALTER_VNODE, vmProcessMgmtMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_DND_ALTER_VNODE, vmProcessMgmtMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_VNODE, vmProcessMgmtMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_DND_DROP_VNODE, vmProcessMgmtMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_SYNC_VNODE, vmProcessMgmtMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_DND_SYNC_VNODE, vmProcessMgmtMsg, DEFAULT_HANDLE);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_COMPACT_VNODE, vmProcessMgmtMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_DND_COMPACT_VNODE, vmProcessMgmtMsg, DEFAULT_HANDLE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,7 +126,7 @@ static void *vmOpenVnodeFunc(void *param) {
|
||||||
char stepDesc[TSDB_STEP_DESC_LEN] = {0};
|
char stepDesc[TSDB_STEP_DESC_LEN] = {0};
|
||||||
snprintf(stepDesc, TSDB_STEP_DESC_LEN, "vgId:%d, start to restore, %d of %d have been opened", pCfg->vgId,
|
snprintf(stepDesc, TSDB_STEP_DESC_LEN, "vgId:%d, start to restore, %d of %d have been opened", pCfg->vgId,
|
||||||
pMgmt->state.openVnodes, pMgmt->state.totalVnodes);
|
pMgmt->state.openVnodes, pMgmt->state.totalVnodes);
|
||||||
dndReportStartup(pDnode, "open-vnodes", stepDesc);
|
dmReportStartup(pDnode, "open-vnodes", stepDesc);
|
||||||
|
|
||||||
SMsgCb msgCb = dmGetMsgcb(pMgmt->pWrapper);
|
SMsgCb msgCb = dmGetMsgcb(pMgmt->pWrapper);
|
||||||
msgCb.pWrapper = pMgmt->pWrapper;
|
msgCb.pWrapper = pMgmt->pWrapper;
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
void* serverLoop(void* param) {
|
void* serverLoop(void* param) {
|
||||||
SDnode* pDnode = (SDnode*)param;
|
SDnode* pDnode = (SDnode*)param;
|
||||||
dndRun(pDnode);
|
dmRun(pDnode);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ bool TestServer::DoStart() {
|
||||||
SDnodeOpt option = BuildOption(path, fqdn, port, firstEp);
|
SDnodeOpt option = BuildOption(path, fqdn, port, firstEp);
|
||||||
taosMkDir(path);
|
taosMkDir(path);
|
||||||
|
|
||||||
pDnode = dndCreate(&option);
|
pDnode = dmCreate(&option);
|
||||||
if (pDnode == NULL) {
|
if (pDnode == NULL) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -68,11 +68,11 @@ bool TestServer::Start(const char* path, const char* fqdn, uint16_t port, const
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestServer::Stop() {
|
void TestServer::Stop() {
|
||||||
dndSetEvent(pDnode, DND_EVENT_STOP);
|
dmSetEvent(pDnode, DND_EVENT_STOP);
|
||||||
taosThreadJoin(threadId, NULL);
|
taosThreadJoin(threadId, NULL);
|
||||||
|
|
||||||
if (pDnode != NULL) {
|
if (pDnode != NULL) {
|
||||||
dndClose(pDnode);
|
dmClose(pDnode);
|
||||||
pDnode = NULL;
|
pDnode = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ void Testbase::InitLog(const char* path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Testbase::Init(const char* path, int16_t port) {
|
void Testbase::Init(const char* path, int16_t port) {
|
||||||
dndInit();
|
dmInit();
|
||||||
|
|
||||||
char fqdn[] = "localhost";
|
char fqdn[] = "localhost";
|
||||||
char firstEp[TSDB_EP_LEN] = {0};
|
char firstEp[TSDB_EP_LEN] = {0};
|
||||||
|
@ -62,7 +62,7 @@ void Testbase::Cleanup() {
|
||||||
client.Cleanup();
|
client.Cleanup();
|
||||||
taosMsleep(10);
|
taosMsleep(10);
|
||||||
server.Stop();
|
server.Stop();
|
||||||
dndCleanup();
|
dmCleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Testbase::Restart() {
|
void Testbase::Restart() {
|
||||||
|
|
Loading…
Reference in New Issue