refactor: node mgmt
This commit is contained in:
parent
add51b499c
commit
2623202c38
|
@ -39,6 +39,29 @@ static int32_t dmOpenMgmt(const SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput)
|
||||||
return -1;
|
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);
|
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");
|
||||||
|
@ -83,6 +106,12 @@ static void dmCloseMgmt(SDnodeMgmt *pMgmt) {
|
||||||
}
|
}
|
||||||
taosWUnLockLatch(&pMgmt->data.latch);
|
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");
|
dInfo("dnode-mgmt is cleaned up");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,6 +93,7 @@ typedef struct {
|
||||||
int64_t clusterId;
|
int64_t clusterId;
|
||||||
const char *localEp;
|
const char *localEp;
|
||||||
const char *firstEp;
|
const char *firstEp;
|
||||||
|
const char *secondEp;
|
||||||
const char *localFqdn;
|
const char *localFqdn;
|
||||||
uint16_t serverPort;
|
uint16_t serverPort;
|
||||||
int32_t supportVnodes;
|
int32_t supportVnodes;
|
||||||
|
@ -156,32 +157,31 @@ 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 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;
|
||||||
TdFilePtr lockfile;
|
TdFilePtr lockfile;
|
||||||
char *localEp;
|
char *localEp;
|
||||||
char *localFqdn;
|
char *localFqdn;
|
||||||
char *firstEp;
|
char *firstEp;
|
||||||
char *secondEp;
|
char *secondEp;
|
||||||
char *dataDir;
|
char *dataDir;
|
||||||
SDiskCfg *disks;
|
SDiskCfg *disks;
|
||||||
int32_t numOfDisks;
|
int32_t numOfDisks;
|
||||||
int32_t supportVnodes;
|
int32_t supportVnodes;
|
||||||
uint16_t serverPort;
|
uint16_t serverPort;
|
||||||
EDndRunStatus status;
|
|
||||||
} SDnodeData;
|
} SDnodeData;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "dmUtil.h"
|
#include "dmUtil.h"
|
||||||
|
|
||||||
|
|
||||||
const char *dmStatStr(EDndRunStatus stype) {
|
const char *dmStatStr(EDndRunStatus stype) {
|
||||||
switch (stype) {
|
switch (stype) {
|
||||||
case DND_STAT_INIT:
|
case DND_STAT_INIT:
|
||||||
|
|
Loading…
Reference in New Issue