refactor: node mgmt
This commit is contained in:
parent
8fc5ce2edb
commit
65da2ea014
|
@ -17,7 +17,7 @@
|
||||||
#include "dmInt.h"
|
#include "dmInt.h"
|
||||||
|
|
||||||
#define dmSendLocalRecv(pMgmt, mtype, func, pInfo) \
|
#define dmSendLocalRecv(pMgmt, mtype, func, pInfo) \
|
||||||
{ \
|
if (!tsMultiProcess) { \
|
||||||
SRpcMsg rsp = {0}; \
|
SRpcMsg rsp = {0}; \
|
||||||
SRpcMsg req = {.msgType = mtype}; \
|
SRpcMsg req = {.msgType = mtype}; \
|
||||||
SEpSet epset = {.inUse = 0, .numOfEps = 1}; \
|
SEpSet epset = {.inUse = 0, .numOfEps = 1}; \
|
||||||
|
|
|
@ -129,7 +129,7 @@ SDnode *dmCreate(const SDnodeOpt *pOption) {
|
||||||
goto _OVER;
|
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());
|
dError("node:%s, failed to read shm file since %s", pWrapper->name, terrstr());
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
|
@ -219,15 +219,21 @@ void dmCloseNode(SMgmtWrapper *pWrapper) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t dmOpenNodes(SDnode *pDnode) {
|
static int32_t dmOpenNodes(SDnode *pDnode) {
|
||||||
if (pDnode->ptype == DND_PROC_CHILD) {
|
for (EDndNodeType ntype = DNODE; ntype < NODE_END; ++ntype) {
|
||||||
SMgmtWrapper *pWrapper = &pDnode->wrappers[pDnode->ntype];
|
SMgmtWrapper *pWrapper = &pDnode->wrappers[ntype];
|
||||||
pWrapper->procType = DND_PROC_CHILD;
|
if (!pWrapper->required) continue;
|
||||||
return dmOpenNode(pWrapper);
|
|
||||||
} else {
|
if (pDnode->ptype == DND_PROC_CHILD) {
|
||||||
for (EDndNodeType n = DNODE; n < NODE_END; ++n) {
|
if (pDnode->ntype == ntype) {
|
||||||
SMgmtWrapper *pWrapper = &pDnode->wrappers[n];
|
pWrapper->procType = DND_PROC_CHILD;
|
||||||
if (!pWrapper->required) continue;
|
if (dmOpenNode(pWrapper) != 0) {
|
||||||
if (n == DNODE) {
|
return -1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
pWrapper->required = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (ntype == DNODE) {
|
||||||
pWrapper->procType = DND_PROC_SINGLE;
|
pWrapper->procType = DND_PROC_SINGLE;
|
||||||
} else {
|
} else {
|
||||||
pWrapper->procType = pDnode->ptype;
|
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 dmReadFile(const char *path, const char *name, bool *pDeployed);
|
||||||
int32_t dmWriteFile(const char *path, const char *name, bool deployed);
|
int32_t dmWriteFile(const char *path, const char *name, bool deployed);
|
||||||
TdFilePtr dmCheckRunning(const char *dataDir);
|
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);
|
int32_t dmWriteShmFile(const char *path, const char *name, const SShm *pShm);
|
||||||
|
|
||||||
// common define
|
// common define
|
||||||
|
|
|
@ -139,7 +139,7 @@ TdFilePtr dmCheckRunning(const char *dataDir) {
|
||||||
return pFile;
|
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;
|
int32_t code = -1;
|
||||||
char content[MAXLEN + 1] = {0};
|
char content[MAXLEN + 1] = {0};
|
||||||
char file[PATH_MAX] = {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) {
|
if (pShm->id >= 0) {
|
||||||
dDebug("node:%s, shmid:%d, is closed, size:%d", name, pShm->id, pShm->size);
|
dDebug("node:%s, shmid:%d, is closed, size:%d", name, pShm->id, pShm->size);
|
||||||
taosDropShm(pShm);
|
taosDropShm(pShm);
|
||||||
|
|
Loading…
Reference in New Issue