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

refactor: node mgmt

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