提交 65da2ea0 编写于 作者: S Shengliang Guan

refactor: node mgmt

上级 8fc5ce2e
......@@ -17,7 +17,7 @@
#include "dmInt.h"
#define dmSendLocalRecv(pMgmt, mtype, func, pInfo) \
{ \
if (!tsMultiProcess) { \
SRpcMsg rsp = {0}; \
SRpcMsg req = {.msgType = mtype}; \
SEpSet epset = {.inUse = 0, .numOfEps = 1}; \
......
......@@ -129,7 +129,7 @@ SDnode *dmCreate(const SDnodeOpt *pOption) {
goto _OVER;
}
if (ntype != DNODE && dmReadShmFile(pWrapper->path, pWrapper->name, &pWrapper->procShm) != 0) {
if (ntype != DNODE && dmReadShmFile(pWrapper->path, pWrapper->name, pDnode->ntype, &pWrapper->procShm) != 0) {
dError("node:%s, failed to read shm file since %s", pWrapper->name, terrstr());
goto _OVER;
}
......
......@@ -219,15 +219,21 @@ void dmCloseNode(SMgmtWrapper *pWrapper) {
}
static int32_t dmOpenNodes(SDnode *pDnode) {
if (pDnode->ptype == DND_PROC_CHILD) {
SMgmtWrapper *pWrapper = &pDnode->wrappers[pDnode->ntype];
pWrapper->procType = DND_PROC_CHILD;
return dmOpenNode(pWrapper);
} else {
for (EDndNodeType n = DNODE; n < NODE_END; ++n) {
SMgmtWrapper *pWrapper = &pDnode->wrappers[n];
if (!pWrapper->required) continue;
if (n == DNODE) {
for (EDndNodeType ntype = DNODE; ntype < NODE_END; ++ntype) {
SMgmtWrapper *pWrapper = &pDnode->wrappers[ntype];
if (!pWrapper->required) continue;
if (pDnode->ptype == DND_PROC_CHILD) {
if (pDnode->ntype == ntype) {
pWrapper->procType = DND_PROC_CHILD;
if (dmOpenNode(pWrapper) != 0) {
return -1;
}
} else {
pWrapper->required = false;
}
} else {
if (ntype == DNODE) {
pWrapper->procType = DND_PROC_SINGLE;
} else {
pWrapper->procType = pDnode->ptype;
......
......@@ -153,7 +153,7 @@ void dmGetMonitorSystemInfo(SMonSysInfo *pInfo);
int32_t dmReadFile(const char *path, const char *name, bool *pDeployed);
int32_t dmWriteFile(const char *path, const char *name, bool deployed);
TdFilePtr dmCheckRunning(const char *dataDir);
int32_t dmReadShmFile(const char *path, const char *name, SShm *pShm);
int32_t dmReadShmFile(const char *path, const char *name, EDndNodeType runType, SShm *pShm);
int32_t dmWriteShmFile(const char *path, const char *name, const SShm *pShm);
// common define
......
......@@ -139,7 +139,7 @@ TdFilePtr dmCheckRunning(const char *dataDir) {
return pFile;
}
int32_t dmReadShmFile(const char *path, const char *name, SShm *pShm) {
int32_t dmReadShmFile(const char *path, const char *name, EDndNodeType runType, SShm *pShm) {
int32_t code = -1;
char content[MAXLEN + 1] = {0};
char file[PATH_MAX] = {0};
......@@ -172,7 +172,7 @@ int32_t dmReadShmFile(const char *path, const char *name, SShm *pShm) {
}
}
if (!tsMultiProcess) {
if (!tsMultiProcess || runType == DNODE || runType == NODE_END) {
if (pShm->id >= 0) {
dDebug("node:%s, shmid:%d, is closed, size:%d", name, pShm->id, pShm->size);
taosDropShm(pShm);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册