提交 2623202c 编写于 作者: S Shengliang Guan

refactor: node mgmt

上级 add51b49
......@@ -39,6 +39,29 @@ static int32_t dmOpenMgmt(const SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput)
return -1;
}
pMgmt->data.dnodeId = 0;
pMgmt->data.clusterId = 0;
pMgmt->data.dnodeVer = 0;
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.supportVnodes = pInput->supportVnodes;
pMgmt->data.serverPort = pInput->serverPort;
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");
......@@ -83,6 +106,12 @@ static void dmCloseMgmt(SDnodeMgmt *pMgmt) {
}
taosWUnLockLatch(&pMgmt->data.latch);
taosMemoryFreeClear(pMgmt->data.localEp);
taosMemoryFreeClear(pMgmt->data.localFqdn);
taosMemoryFreeClear(pMgmt->data.firstEp);
taosMemoryFreeClear(pMgmt->data.secondEp);
taosMemoryFreeClear(pMgmt->data.dataDir);
dInfo("dnode-mgmt is cleaned up");
}
......
......@@ -93,6 +93,7 @@ typedef struct {
int64_t clusterId;
const char *localEp;
const char *firstEp;
const char *secondEp;
const char *localFqdn;
uint16_t serverPort;
int32_t supportVnodes;
......@@ -156,32 +157,31 @@ 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;
EDndRunStatus status;
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;
} SDnodeData;
#ifdef __cplusplus
......
......@@ -16,7 +16,6 @@
#define _DEFAULT_SOURCE
#include "dmUtil.h"
const char *dmStatStr(EDndRunStatus stype) {
switch (stype) {
case DND_STAT_INIT:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册