提交 8e61859d 编写于 作者: S Shengliang Guan

refactror: node mgmt

上级 b219224e
......@@ -16,7 +16,9 @@
#ifndef _TD_DM_DEF_H_
#define _TD_DM_DEF_H_
// tobe deleted
#include "uv.h"
#include "dmLog.h"
#include "cJSON.h"
......@@ -40,6 +42,7 @@
#include "mnode.h"
#include "monitor.h"
#include "sync.h"
#include "wal.h"
#include "libs/function/function.h"
......@@ -47,10 +50,34 @@
extern "C" {
#endif
typedef enum { DNODE, VNODE, QNODE, SNODE, MNODE, BNODE, NODE_END } EDndNodeType;
typedef enum { DND_STAT_INIT, DND_STAT_RUNNING, DND_STAT_STOPPED } EDndRunStatus;
typedef enum { DND_ENV_INIT, DND_ENV_READY, DND_ENV_CLEANUP } EDndEnvStatus;
typedef enum { DND_PROC_SINGLE, DND_PROC_CHILD, DND_PROC_PARENT } EDndProcType;
typedef enum {
DNODE = 0,
VNODE = 1,
QNODE = 2,
SNODE = 3,
MNODE = 4,
BNODE = 5,
NODE_END = 6,
} EDndNodeType;
typedef enum {
DND_STAT_INIT,
DND_STAT_RUNNING,
DND_STAT_STOPPED,
} EDndRunStatus;
typedef enum {
DND_ENV_INIT,
DND_ENV_READY,
DND_ENV_CLEANUP,
} EDndEnvStatus;
typedef enum {
DND_PROC_SINGLE,
DND_PROC_CHILD,
DND_PROC_PARENT,
DND_PROC_TEST,
} EDndProcType;
typedef int32_t (*NodeMsgFp)(struct SMgmtWrapper *pWrapper, SNodeMsg *pMsg);
typedef int32_t (*OpenNodeFp)(struct SMgmtWrapper *pWrapper);
......@@ -146,18 +173,17 @@ typedef struct {
} SStartupInfo;
typedef struct SUdfdData {
bool startCalled;
bool needCleanUp;
uv_loop_t loop;
uv_thread_t thread;
uv_barrier_t barrier;
uv_process_t process;
int spawnErr;
uv_pipe_t ctrlPipe;
uv_async_t stopAsync;
int32_t stopCalled;
int32_t dnodeId;
bool startCalled;
bool needCleanUp;
uv_loop_t loop;
uv_thread_t thread;
uv_barrier_t barrier;
uv_process_t process;
int spawnErr;
uv_pipe_t ctrlPipe;
uv_async_t stopAsync;
int32_t stopCalled;
int32_t dnodeId;
} SUdfdData;
typedef struct SDnode {
......
......@@ -15,15 +15,14 @@
#define _DEFAULT_SOURCE
#include "dmInt.h"
#include "wal.h"
static int8_t once = DND_ENV_INIT;
int32_t dmInit() {
dDebug("start to init dnode env");
dInfo("start to init env");
if (atomic_val_compare_exchange_8(&once, DND_ENV_INIT, DND_ENV_READY) != DND_ENV_INIT) {
dError("env is already initialized");
terrno = TSDB_CODE_REPEAT_INIT;
dError("failed to init dnode env since %s", terrstr());
return -1;
}
......@@ -31,24 +30,14 @@ int32_t dmInit() {
taosBlockSIGPIPE();
taosResolveCRC();
SMonCfg monCfg = {0};
monCfg.maxLogs = tsMonitorMaxLogs;
monCfg.port = tsMonitorPort;
monCfg.server = tsMonitorFqdn;
monCfg.comp = tsMonitorComp;
if (monInit(&monCfg) != 0) {
dError("failed to init monitor since %s", terrstr());
return -1;
}
dInfo("dnode env is initialized");
dInfo("env is initialized");
return 0;
}
void dmCleanup() {
dDebug("start to cleanup dnode env");
dDebug("start to cleanup env");
if (atomic_val_compare_exchange_8(&once, DND_ENV_READY, DND_ENV_CLEANUP) != DND_ENV_READY) {
dError("dnode env is already cleaned up");
dError("env is already cleaned up");
return;
}
......@@ -57,5 +46,5 @@ void dmCleanup() {
walCleanUp();
udfcClose();
taosStopCacheRefreshWorker();
dInfo("dnode env is cleaned up");
dInfo("env is cleaned up");
}
......@@ -29,7 +29,6 @@ int32_t dmReadFile(SMgmtWrapper *pWrapper, bool *pDeployed) {
snprintf(file, sizeof(file), "%s%s%s.json", pWrapper->path, TD_DIRSEP, pWrapper->name);
pFile = taosOpenFile(file, TD_FILE_READ);
if (pFile == NULL) {
// dDebug("file %s not exist", file);
code = 0;
goto _OVER;
}
......
......@@ -221,6 +221,16 @@ static int32_t dmInitMgmt(SMgmtWrapper *pWrapper) {
dInfo("dnode-mgmt start to init");
SDnode *pDnode = pWrapper->pDnode;
SMonCfg monCfg = {0};
monCfg.maxLogs = tsMonitorMaxLogs;
monCfg.port = tsMonitorPort;
monCfg.server = tsMonitorFqdn;
monCfg.comp = tsMonitorComp;
if (monInit(&monCfg) != 0) {
dError("failed to init monitor since %s", terrstr());
return -1;
}
pDnode->data.dnodeHash = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK);
if (pDnode->data.dnodeHash == NULL) {
dError("failed to init dnode hash");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册