Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
47b9216b
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
47b9216b
编写于
5月 11, 2022
作者:
S
Shengliang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: node mgmt
上级
6296188f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
63 addition
and
57 deletion
+63
-57
source/dnode/mgmt/mgmt_bnode/inc/bmInt.h
source/dnode/mgmt/mgmt_bnode/inc/bmInt.h
+9
-8
source/dnode/mgmt/mgmt_bnode/src/bmHandle.c
source/dnode/mgmt/mgmt_bnode/src/bmHandle.c
+26
-15
source/dnode/mgmt/mgmt_bnode/src/bmInt.c
source/dnode/mgmt/mgmt_bnode/src/bmInt.c
+25
-29
source/dnode/mgmt/mgmt_bnode/src/bmWorker.c
source/dnode/mgmt/mgmt_bnode/src/bmWorker.c
+3
-5
未找到文件。
source/dnode/mgmt/mgmt_bnode/inc/bmInt.h
浏览文件 @
47b9216b
...
...
@@ -26,24 +26,25 @@ extern "C" {
typedef
struct
SBnodeMgmt
{
SBnode
*
pBnode
;
SDnode
*
pDnode
;
SMgmtWrapper
*
pWrapper
;
SMsgCb
msgCb
;
const
char
*
path
;
const
char
*
name
;
int32_t
dnodeId
;
SMultiWorker
writeWorker
;
SSingleWorker
monitorWorker
;
}
SBnodeMgmt
;
// bmHandle.c
void
bmInitMsgHandle
(
SMgmtWrapper
*
pWrapper
);
int32_t
bmProcessCreateReq
(
S
MgmtWrapper
*
pWrapper
,
SNodeMsg
*
pMsg
);
int32_t
bmProcessDropReq
(
S
MgmtWrapper
*
pWrapper
,
SNodeMsg
*
pMsg
);
int32_t
bmProcessGetMonBmInfoReq
(
S
MgmtWrapper
*
pWrapper
,
SNodeMsg
*
pReq
);
SArray
*
bmGetMsgHandles
(
);
int32_t
bmProcessCreateReq
(
S
BnodeMgmt
*
pMgmt
,
SNodeMsg
*
pMsg
);
int32_t
bmProcessDropReq
(
S
BnodeMgmt
*
pMgmt
,
SNodeMsg
*
pMsg
);
int32_t
bmProcessGetMonBmInfoReq
(
S
BnodeMgmt
*
pMgmt
,
SNodeMsg
*
pReq
);
// bmWorker.c
int32_t
bmStartWorker
(
SBnodeMgmt
*
pMgmt
);
void
bmStopWorker
(
SBnodeMgmt
*
pMgmt
);
int32_t
bmP
rocessWriteMsg
(
SMgmtWrapper
*
pWrapper
,
SNodeMsg
*
pMsg
);
int32_t
bmP
rocessMonitorMsg
(
SMgmtWrapper
*
pWrapper
,
SNodeMsg
*
pMsg
);
int32_t
bmP
utNodeMsgToWriteQueue
(
SBnodeMgmt
*
pMgmt
,
SNodeMsg
*
pMsg
);
int32_t
bmP
utNodeMsgToMonitorQueue
(
SBnodeMgmt
*
pMgmt
,
SNodeMsg
*
pMsg
);
#ifdef __cplusplus
}
...
...
source/dnode/mgmt/mgmt_bnode/src/bmHandle.c
浏览文件 @
47b9216b
...
...
@@ -16,12 +16,12 @@
#define _DEFAULT_SOURCE
#include "bmInt.h"
void
bmGetMonitorInfo
(
SMgmtWrapper
*
pWrapper
,
SMonBmInfo
*
bmInfo
)
{}
static
void
bmGetMonitorInfo
(
SBnodeMgmt
*
pMgmt
,
SMonBmInfo
*
bmInfo
)
{}
int32_t
bmProcessGetMonBmInfoReq
(
S
MgmtWrapper
*
pWrapper
,
SNodeMsg
*
pReq
)
{
int32_t
bmProcessGetMonBmInfoReq
(
S
BnodeMgmt
*
pMgmt
,
SNodeMsg
*
pReq
)
{
SMonBmInfo
bmInfo
=
{
0
};
bmGetMonitorInfo
(
p
Wrapper
,
&
bmInfo
);
dmGet
MonitorSys
Info
(
&
bmInfo
.
sys
);
bmGetMonitorInfo
(
p
Mgmt
,
&
bmInfo
);
dmGet
System
Info
(
&
bmInfo
.
sys
);
monGetLogs
(
&
bmInfo
.
log
);
int32_t
rspLen
=
tSerializeSMonBmInfo
(
NULL
,
0
,
&
bmInfo
);
...
...
@@ -43,8 +43,7 @@ int32_t bmProcessGetMonBmInfoReq(SMgmtWrapper *pWrapper, SNodeMsg *pReq) {
return
0
;
}
int32_t
bmProcessCreateReq
(
SMgmtWrapper
*
pWrapper
,
SNodeMsg
*
pMsg
)
{
SDnode
*
pDnode
=
pWrapper
->
pDnode
;
int32_t
bmProcessCreateReq
(
SBnodeMgmt
*
pMgmt
,
SNodeMsg
*
pMsg
)
{
SRpcMsg
*
pReq
=
&
pMsg
->
rpcMsg
;
SDCreateBnodeReq
createReq
=
{
0
};
...
...
@@ -53,14 +52,14 @@ int32_t bmProcessCreateReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
return
-
1
;
}
if
(
p
Dnode
->
data
.
dnodeId
!=
0
&&
createReq
.
dnodeId
!=
pDnode
->
data
.
dnodeId
)
{
if
(
p
Mgmt
->
dnodeId
!=
0
&&
createReq
.
dnodeId
!=
pMgmt
->
dnodeId
)
{
terrno
=
TSDB_CODE_INVALID_OPTION
;
dError
(
"failed to create bnode since %s, input:%d cur:%d"
,
terrstr
(),
createReq
.
dnodeId
,
p
Dnode
->
data
.
dnodeId
);
dError
(
"failed to create bnode since %s, input:%d cur:%d"
,
terrstr
(),
createReq
.
dnodeId
,
p
Mgmt
->
dnodeId
);
return
-
1
;
}
bool
deployed
=
true
;
if
(
dmWriteFile
(
p
Wrapper
,
deployed
)
!=
0
)
{
if
(
dmWriteFile
(
p
Mgmt
->
path
,
pMgmt
->
name
,
deployed
)
!=
0
)
{
dError
(
"failed to write bnode file since %s"
,
terrstr
());
return
-
1
;
}
...
...
@@ -68,8 +67,7 @@ int32_t bmProcessCreateReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
return
0
;
}
int32_t
bmProcessDropReq
(
SMgmtWrapper
*
pWrapper
,
SNodeMsg
*
pMsg
)
{
SDnode
*
pDnode
=
pWrapper
->
pDnode
;
int32_t
bmProcessDropReq
(
SBnodeMgmt
*
pMgmt
,
SNodeMsg
*
pMsg
)
{
SRpcMsg
*
pReq
=
&
pMsg
->
rpcMsg
;
SDDropBnodeReq
dropReq
=
{
0
};
...
...
@@ -78,14 +76,14 @@ int32_t bmProcessDropReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
return
-
1
;
}
if
(
dropReq
.
dnodeId
!=
p
Dnode
->
data
.
dnodeId
)
{
if
(
dropReq
.
dnodeId
!=
p
Mgmt
->
dnodeId
)
{
terrno
=
TSDB_CODE_INVALID_OPTION
;
dError
(
"failed to drop bnode since %s"
,
terrstr
());
return
-
1
;
}
bool
deployed
=
false
;
if
(
dmWriteFile
(
p
Wrapper
,
deployed
)
!=
0
)
{
if
(
dmWriteFile
(
p
Mgmt
->
path
,
pMgmt
->
name
,
deployed
)
!=
0
)
{
dError
(
"failed to write bnode file since %s"
,
terrstr
());
return
-
1
;
}
...
...
@@ -93,6 +91,19 @@ int32_t bmProcessDropReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
return
0
;
}
void
bmInitMsgHandle
(
SMgmtWrapper
*
pWrapper
)
{
dmSetMsgHandle
(
pWrapper
,
TDMT_MON_BM_INFO
,
bmProcessMonitorMsg
,
0
);
SArray
*
bmGetMsgHandles
()
{
int32_t
code
=
-
1
;
SArray
*
pArray
=
taosArrayInit
(
2
,
sizeof
(
SMgmtHandle
));
if
(
pArray
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MON_BM_INFO
,
bmPutNodeMsgToMonitorQueue
,
0
)
==
NULL
)
goto
_OVER
;
code
=
0
;
_OVER:
if
(
code
!=
0
)
{
taosArrayDestroy
(
pArray
);
return
NULL
;
}
else
{
return
pArray
;
}
}
source/dnode/mgmt/mgmt_bnode/src/bmInt.c
浏览文件 @
47b9216b
...
...
@@ -16,18 +16,13 @@
#define _DEFAULT_SOURCE
#include "bmInt.h"
static
int32_t
bmRequire
(
SMgmtWrapper
*
pWrapper
,
bool
*
required
)
{
return
dmReadFile
(
pWrapper
,
required
);
}
static
void
bmInitOption
(
SBnodeMgmt
*
pMgmt
,
SBnodeOpt
*
pOption
)
{
SMsgCb
msgCb
=
pMgmt
->
pDnode
->
data
.
msgCb
;
msgCb
.
pWrapper
=
pMgmt
->
pWrapper
;
pOption
->
msgCb
=
msgCb
;
static
int32_t
bmRequire
(
const
SMgmtInputOpt
*
pInput
,
bool
*
required
)
{
return
dmReadFile
(
pInput
->
path
,
pInput
->
name
,
required
);
}
static
void
bmClose
(
SMgmtWrapper
*
pWrapper
)
{
SBnodeMgmt
*
pMgmt
=
pWrapper
->
pMgmt
;
if
(
pMgmt
==
NULL
)
return
;
static
void
bmInitOption
(
SBnodeMgmt
*
pMgmt
,
SBnodeOpt
*
pOption
)
{
pOption
->
msgCb
=
pMgmt
->
msgCb
;
}
static
void
bmClose
(
SBnodeMgmt
*
pMgmt
)
{
dInfo
(
"bnode-mgmt start to cleanup"
);
if
(
pMgmt
->
pBnode
!=
NULL
)
{
bmStopWorker
(
pMgmt
);
...
...
@@ -35,12 +30,11 @@ static void bmClose(SMgmtWrapper *pWrapper) {
pMgmt
->
pBnode
=
NULL
;
}
pWrapper
->
pMgmt
=
NULL
;
taosMemoryFree
(
pMgmt
);
dInfo
(
"bnode-mgmt is cleaned up"
);
}
int32_t
bmOpen
(
SMgmtWrapper
*
pWrapper
)
{
int32_t
bmOpen
(
const
SMgmtInputOpt
*
pInput
,
SMgmtOutputOpt
*
pOutput
)
{
dInfo
(
"bnode-mgmt start to init"
);
SBnodeMgmt
*
pMgmt
=
taosMemoryCalloc
(
1
,
sizeof
(
SBnodeMgmt
));
if
(
pMgmt
==
NULL
)
{
...
...
@@ -48,40 +42,42 @@ int32_t bmOpen(SMgmtWrapper *pWrapper) {
return
-
1
;
}
pMgmt
->
path
=
pWrapper
->
path
;
pMgmt
->
pDnode
=
pWrapper
->
pDnode
;
pMgmt
->
pWrapper
=
pWrapper
;
pWrapper
->
pMgmt
=
pMgmt
;
pMgmt
->
path
=
pInput
->
path
;
pMgmt
->
name
=
pInput
->
name
;
pMgmt
->
dnodeId
=
pInput
->
dnodeId
;
pMgmt
->
msgCb
=
pInput
->
msgCb
;
pMgmt
->
msgCb
.
pMgmt
=
pMgmt
;
SBnodeOpt
option
=
{
0
};
bmInitOption
(
pMgmt
,
&
option
);
pMgmt
->
pBnode
=
bndOpen
(
pMgmt
->
path
,
&
option
);
if
(
pMgmt
->
pBnode
==
NULL
)
{
dError
(
"failed to open bnode since %s"
,
terrstr
());
bmClose
(
p
Wrapper
);
bmClose
(
p
Mgmt
);
return
-
1
;
}
dmReportStartup
(
pWrapper
->
pDnode
,
"bnode-impl"
,
"initialized"
);
tmsgReportStartup
(
"bnode-impl"
,
"initialized"
);
if
(
bmStartWorker
(
pMgmt
)
!=
0
)
{
dError
(
"failed to start bnode worker since %s"
,
terrstr
());
bmClose
(
p
Wrapper
);
bmClose
(
p
Mgmt
);
return
-
1
;
}
dmReportStartup
(
pWrapper
->
pDnode
,
"bnode-worker"
,
"initialized"
);
tmsgReportStartup
(
"bnode-worker"
,
"initialized"
);
pOutput
->
pMgmt
=
pMgmt
;
dInfo
(
"bnode-mgmt is initialized"
);
return
0
;
}
void
bmInitWrapper
(
SMgmtWrapper
*
pWrapper
)
{
SMgmtFp
mgmtFp
=
{
0
};
mgmtFp
.
openFp
=
bmOpen
;
mgmtFp
.
closeFp
=
bmClose
;
mgmtFp
.
createFp
=
bmProcessCreateReq
;
mgmtFp
.
dropFp
=
bmProcessDropReq
;
mgmtFp
.
requiredFp
=
bmRequire
;
SMgmtFunc
bmGetMgmtFunc
()
{
SMgmtFunc
mgmtFunc
=
{
0
};
mgmtFunc
.
openFp
=
bmOpen
;
mgmtFunc
.
closeFp
=
(
NodeCloseFp
)
bmClose
;
mgmtFunc
.
createFp
=
(
NodeCreateFp
)
bmProcessCreateReq
;
mgmtFunc
.
dropFp
=
(
NodeDropFp
)
bmProcessDropReq
;
mgmtFunc
.
requiredFp
=
bmRequire
;
mgmtFunc
.
getHandlesFp
=
bmGetMsgHandles
;
bmInitMsgHandle
(
pWrapper
);
pWrapper
->
name
=
"bnode"
;
pWrapper
->
fp
=
mgmtFp
;
return
mgmtFunc
;
}
source/dnode/mgmt/mgmt_bnode/src/bmWorker.c
浏览文件 @
47b9216b
...
...
@@ -58,7 +58,7 @@ static void bmProcessMonitorQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) {
int32_t
code
=
-
1
;
if
(
pMsg
->
rpcMsg
.
msgType
==
TDMT_MON_BM_INFO
)
{
code
=
bmProcessGetMonBmInfoReq
(
pMgmt
->
pWrapper
,
pMsg
);
code
=
bmProcessGetMonBmInfoReq
(
pMgmt
,
pMsg
);
}
else
{
terrno
=
TSDB_CODE_MSG_NOT_PROCESSED
;
}
...
...
@@ -106,8 +106,7 @@ static void bmProcessWriteQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO
taosArrayDestroy
(
pArray
);
}
int32_t
bmProcessWriteMsg
(
SMgmtWrapper
*
pWrapper
,
SNodeMsg
*
pMsg
)
{
SBnodeMgmt
*
pMgmt
=
pWrapper
->
pMgmt
;
int32_t
bmPutNodeMsgToWriteQueue
(
SBnodeMgmt
*
pMgmt
,
SNodeMsg
*
pMsg
)
{
SMultiWorker
*
pWorker
=
&
pMgmt
->
writeWorker
;
dTrace
(
"msg:%p, put into worker:%s"
,
pMsg
,
pWorker
->
name
);
...
...
@@ -115,8 +114,7 @@ int32_t bmProcessWriteMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
return
0
;
}
int32_t
bmProcessMonitorMsg
(
SMgmtWrapper
*
pWrapper
,
SNodeMsg
*
pMsg
)
{
SBnodeMgmt
*
pMgmt
=
pWrapper
->
pMgmt
;
int32_t
bmPutNodeMsgToMonitorQueue
(
SBnodeMgmt
*
pMgmt
,
SNodeMsg
*
pMsg
)
{
SSingleWorker
*
pWorker
=
&
pMgmt
->
monitorWorker
;
dTrace
(
"msg:%p, put into worker:%s"
,
pMsg
,
pWorker
->
name
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录