提交 9f4d41fe 编写于 作者: S Shengliang Guan

refactor: node mgmt

上级 bf2d1a79
......@@ -88,7 +88,6 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) {
SMonMloadInfo minfo = {0};
dmGetMnodeLoads(pMgmt, &minfo);
pMgmt->data.isMnode = minfo.isMnode;
pMgmt->data.mndState = minfo.load.syncState;
int32_t contLen = tSerializeSStatusReq(NULL, 0, &req);
......
......@@ -45,23 +45,18 @@ static int32_t dmOpenMgmt(const SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput)
pMgmt->data.updateTime = 0;
pMgmt->data.rebootTime = taosGetTimestampMs();
pMgmt->data.dropped = 0;
pMgmt->data.localEp = strdup(pInput->localEp);
pMgmt->data.localFqdn = strdup(pInput->localFqdn);
pMgmt->data.firstEp = strdup(pInput->firstEp);
pMgmt->data.secondEp = strdup(pInput->secondEp);
pMgmt->data.dataDir = strdup(pInput->dataDir);
pMgmt->data.disks = pInput->disks;
pMgmt->data.numOfDisks = pInput->numOfDisks;
pMgmt->data.localEp = pInput->localEp;
pMgmt->data.localFqdn = pInput->localFqdn;
pMgmt->data.firstEp = pInput->firstEp;
pMgmt->data.secondEp = pInput->secondEp;
pMgmt->data.supportVnodes = pInput->supportVnodes;
pMgmt->data.serverPort = pInput->serverPort;
pMgmt->pDnode = pInput->pDnode;
pMgmt->processCreateNodeFp = pInput->processCreateNodeFp;
pMgmt->processDropNodeFp = pInput->processDropNodeFp;
pMgmt->isNodeDeployedFp = pInput->isNodeDeployedFp;
taosInitRWLatch(&pMgmt->data.latch);
if (pMgmt->data.dataDir == NULL || pMgmt->data.localEp == NULL || pMgmt->data.localFqdn == NULL ||
pMgmt->data.firstEp == NULL || pMgmt->data.secondEp == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1;
}
pMgmt->data.dnodeHash = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK);
if (pMgmt->data.dnodeHash == NULL) {
dError("failed to init dnode hash");
......@@ -87,6 +82,7 @@ static int32_t dmOpenMgmt(const SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput)
dError("failed to start udfd");
}
pOutput->pMgmt = pMgmt;
dInfo("dnode-mgmt is initialized");
return 0;
}
......@@ -110,7 +106,6 @@ static void dmCloseMgmt(SDnodeMgmt *pMgmt) {
taosMemoryFreeClear(pMgmt->data.localFqdn);
taosMemoryFreeClear(pMgmt->data.firstEp);
taosMemoryFreeClear(pMgmt->data.secondEp);
taosMemoryFreeClear(pMgmt->data.dataDir);
dInfo("dnode-mgmt is cleaned up");
}
......
......@@ -228,7 +228,9 @@ static int32_t dmOpenNodes(SDnode *pDnode) {
} else {
pWrapper->procType = pDnode->ptype;
}
return dmOpenNode(pWrapper);
if (dmOpenNode(pWrapper) != 0) {
return -1;
}
}
}
......
......@@ -158,31 +158,26 @@ int32_t dmWriteShmFile(const char *path, const char *name, const SShm *pShm);
// common define
typedef struct {
int32_t dnodeId;
int64_t clusterId;
int64_t dnodeVer;
int64_t updateTime;
int64_t rebootTime;
int32_t unsyncedVgId;
ESyncState vndState;
ESyncState mndState;
bool isMnode;
bool dropped;
SEpSet mnodeEps;
SArray *dnodeEps;
SHashObj *dnodeHash;
SRWLatch latch;
SMsgCb msgCb;
TdFilePtr lockfile;
char *localEp;
char *localFqdn;
char *firstEp;
char *secondEp;
char *dataDir;
SDiskCfg *disks;
int32_t numOfDisks;
int32_t supportVnodes;
uint16_t serverPort;
int32_t dnodeId;
int64_t clusterId;
int64_t dnodeVer;
int64_t updateTime;
int64_t rebootTime;
int32_t unsyncedVgId;
ESyncState vndState;
ESyncState mndState;
bool dropped;
SEpSet mnodeEps;
SArray *dnodeEps;
SHashObj *dnodeHash;
SRWLatch latch;
SMsgCb msgCb;
const char *localEp;
const char *localFqdn;
const char *firstEp;
const char *secondEp;
int32_t supportVnodes;
uint16_t serverPort;
} SDnodeData;
#ifdef __cplusplus
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册