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

refactror: node mgmt

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