Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
34fd89aa
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
34fd89aa
编写于
5月 16, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: make more object global
上级
d751ff6a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
27 addition
and
94 deletion
+27
-94
include/dnode/mgmt/dnode.h
include/dnode/mgmt/dnode.h
+6
-49
source/dnode/mgmt/node_util/inc/dmUtil.h
source/dnode/mgmt/node_util/inc/dmUtil.h
+15
-26
source/dnode/mgmt/node_util/src/dmEps.c
source/dnode/mgmt/node_util/src/dmEps.c
+6
-6
source/dnode/mgmt/node_util/src/dmUtil.c
source/dnode/mgmt/node_util/src/dmUtil.c
+0
-13
未找到文件。
include/dnode/mgmt/dnode.h
浏览文件 @
34fd89aa
...
...
@@ -22,66 +22,23 @@
extern
"C"
{
#endif
/* ------------------------ TYPES EXPOSED ---------------- */
typedef
struct
SDnode
SDnode
;
/**
* @brief Initialize the
environment
* @brief Initialize the
dnode
*
* @param rtype for internal debug usage, default is 0
* @return int32_t 0 for success and -1 for failure
*/
int32_t
dmInit
();
int32_t
dmInit
(
int8_t
rtype
);
/**
* @brief Clea
r the environment
* @brief Clea
nup the dnode
*/
void
dmCleanup
();
/* ------------------------ SDnode ----------------------- */
typedef
struct
{
int32_t
numOfSupportVnodes
;
uint16_t
serverPort
;
char
dataDir
[
PATH_MAX
];
char
localEp
[
TSDB_EP_LEN
];
char
localFqdn
[
TSDB_FQDN_LEN
];
char
firstEp
[
TSDB_EP_LEN
];
char
secondEp
[
TSDB_EP_LEN
];
SDiskCfg
*
disks
;
int32_t
numOfDisks
;
int8_t
ntype
;
}
SDnodeOpt
;
typedef
enum
{
DND_EVENT_START
=
0
,
DND_EVENT_STOP
=
1
,
DND_EVENT_CHILD
=
2
}
EDndEvent
;
/**
* @brief Initialize and start the dnode.
*
* @param pOption Option of the dnode.
* @return SDnode* The dnode object.
*/
SDnode
*
dmCreate
(
const
SDnodeOpt
*
pOption
);
/**
* @brief Stop and cleanup the dnode.
*
* @param pDnode The dnode object to close.
*/
void
dmClose
(
SDnode
*
pDnode
);
/**
* @brief Run dnode until specific event is receive.
*
* @param pDnode The dnode object to run.
*/
int32_t
dmRun
(
SDnode
*
pDnode
);
/**
* @brief Handle event in the dnode.
*
* @param pDnode The dnode object to close.
* @param event The event to handle.
* @brief Run dnode.
*/
void
dmSetEvent
(
SDnode
*
pDnode
,
EDndEvent
event
);
int32_t
dmRun
(
);
#ifdef __cplusplus
}
...
...
source/dnode/mgmt/node_util/inc/dmUtil.h
浏览文件 @
34fd89aa
...
...
@@ -87,38 +87,28 @@ typedef enum {
DND_FUNC_RELEASE
=
4
,
}
EProcFuncType
;
typedef
int32_t
(
*
ProcessCreateNodeFp
)(
struct
SDnode
*
pDnode
,
EDndNodeType
ntype
,
SRpcMsg
*
pMsg
);
typedef
int32_t
(
*
ProcessDropNodeFp
)(
struct
SDnode
*
pDnode
,
EDndNodeType
ntype
,
SRpcMsg
*
pMsg
);
typedef
bool
(
*
IsNodeRequiredFp
)(
struct
SDnode
*
pDnode
,
EDndNodeType
ntype
);
typedef
int32_t
(
*
ProcessCreateNodeFp
)(
EDndNodeType
ntype
,
SRpcMsg
*
pMsg
);
typedef
int32_t
(
*
ProcessDropNodeFp
)(
EDndNodeType
ntype
,
SRpcMsg
*
pMsg
);
typedef
bool
(
*
IsNodeRequiredFp
)(
EDndNodeType
ntype
);
typedef
struct
{
int32_t
dnodeId
;
int64_t
clusterId
;
int64_t
dnodeVer
;
int64_t
updateTime
;
int64_t
rebootTime
;
bool
dropped
;
bool
stopped
;
SEpSet
mnodeEps
;
SArray
*
dnodeEps
;
SHashObj
*
dnodeHash
;
SRWLatch
latch
;
SMsgCb
msgCb
;
const
char
*
localEp
;
const
char
*
localFqdn
;
const
char
*
firstEp
;
const
char
*
secondEp
;
int32_t
supportVnodes
;
uint16_t
serverPort
;
int32_t
numOfDisks
;
SDiskCfg
*
disks
;
const
char
*
dataDir
;
int32_t
dnodeId
;
int64_t
clusterId
;
int64_t
dnodeVer
;
int64_t
updateTime
;
int64_t
rebootTime
;
bool
dropped
;
bool
stopped
;
SEpSet
mnodeEps
;
SArray
*
dnodeEps
;
SHashObj
*
dnodeHash
;
SRWLatch
latch
;
SMsgCb
msgCb
;
}
SDnodeData
;
typedef
struct
{
const
char
*
path
;
const
char
*
name
;
struct
SDnode
*
pDnode
;
SDnodeData
*
pData
;
SMsgCb
msgCb
;
ProcessCreateNodeFp
processCreateNodeFp
;
...
...
@@ -162,7 +152,6 @@ const char *dmStatStr(EDndRunStatus stype);
const
char
*
dmNodeLogName
(
EDndNodeType
ntype
);
const
char
*
dmNodeProcName
(
EDndNodeType
ntype
);
const
char
*
dmNodeName
(
EDndNodeType
ntype
);
const
char
*
dmEventStr
(
EDndEvent
etype
);
const
char
*
dmProcStr
(
EDndProcType
ptype
);
const
char
*
dmFuncStr
(
EProcFuncType
etype
);
void
*
dmSetMgmtHandle
(
SArray
*
pArray
,
tmsg_t
msgType
,
void
*
nodeMsgFp
,
bool
needCheckVgId
);
...
...
source/dnode/mgmt/node_util/src/dmEps.c
浏览文件 @
34fd89aa
...
...
@@ -54,7 +54,7 @@ int32_t dmReadEps(SDnodeData *pData) {
goto
_OVER
;
}
snprintf
(
file
,
sizeof
(
file
),
"%s%sdnode%sdnode.json"
,
pData
->
d
ataDir
,
TD_DIRSEP
,
TD_DIRSEP
);
snprintf
(
file
,
sizeof
(
file
),
"%s%sdnode%sdnode.json"
,
tsD
ataDir
,
TD_DIRSEP
,
TD_DIRSEP
);
pFile
=
taosOpenFile
(
file
,
TD_FILE_READ
);
if
(
pFile
==
NULL
)
{
code
=
0
;
...
...
@@ -158,14 +158,14 @@ _OVER:
if
(
taosArrayGetSize
(
pData
->
dnodeEps
)
==
0
)
{
SDnodeEp
dnodeEp
=
{
0
};
dnodeEp
.
isMnode
=
1
;
taosGetFqdnPortFromEp
(
pData
->
firstEp
,
&
dnodeEp
.
ep
);
taosGetFqdnPortFromEp
(
tsFirst
,
&
dnodeEp
.
ep
);
taosArrayPush
(
pData
->
dnodeEps
,
&
dnodeEp
);
}
dmResetEps
(
pData
,
pData
->
dnodeEps
);
if
(
dmIsEpChanged
(
pData
,
pData
->
dnodeId
,
pData
->
l
ocalEp
))
{
dError
(
"localEp %s different with %s and need reconfigured"
,
pData
->
l
ocalEp
,
file
);
if
(
dmIsEpChanged
(
pData
,
pData
->
dnodeId
,
tsL
ocalEp
))
{
dError
(
"localEp %s different with %s and need reconfigured"
,
tsL
ocalEp
,
file
);
return
-
1
;
}
...
...
@@ -177,8 +177,8 @@ int32_t dmWriteEps(SDnodeData *pData) {
char
file
[
PATH_MAX
]
=
{
0
};
char
realfile
[
PATH_MAX
]
=
{
0
};
snprintf
(
file
,
sizeof
(
file
),
"%s%sdnode%sdnode.json.bak"
,
pData
->
d
ataDir
,
TD_DIRSEP
,
TD_DIRSEP
);
snprintf
(
realfile
,
sizeof
(
realfile
),
"%s%sdnode%sdnode.json"
,
pData
->
d
ataDir
,
TD_DIRSEP
,
TD_DIRSEP
);
snprintf
(
file
,
sizeof
(
file
),
"%s%sdnode%sdnode.json.bak"
,
tsD
ataDir
,
TD_DIRSEP
,
TD_DIRSEP
);
snprintf
(
realfile
,
sizeof
(
realfile
),
"%s%sdnode%sdnode.json"
,
tsD
ataDir
,
TD_DIRSEP
,
TD_DIRSEP
);
TdFilePtr
pFile
=
taosOpenFile
(
file
,
TD_FILE_CREATE
|
TD_FILE_WRITE
|
TD_FILE_TRUNC
);
if
(
pFile
==
NULL
)
{
...
...
source/dnode/mgmt/node_util/src/dmUtil.c
浏览文件 @
34fd89aa
...
...
@@ -80,19 +80,6 @@ const char *dmNodeName(EDndNodeType ntype) {
}
}
const
char
*
dmEventStr
(
EDndEvent
ev
)
{
switch
(
ev
)
{
case
DND_EVENT_START
:
return
"start"
;
case
DND_EVENT_STOP
:
return
"stop"
;
case
DND_EVENT_CHILD
:
return
"child"
;
default:
return
"UNKNOWN"
;
}
}
const
char
*
dmProcStr
(
EDndProcType
etype
)
{
switch
(
etype
)
{
case
DND_PROC_SINGLE
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录