Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
8fc5ce2e
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
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看板
提交
8fc5ce2e
编写于
5月 12, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: node mgmt
上级
5257e812
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
62 addition
and
66 deletion
+62
-66
source/common/src/tmsgcb.c
source/common/src/tmsgcb.c
+3
-3
source/dnode/mgmt/test/bnode/dbnode.cpp
source/dnode/mgmt/test/bnode/dbnode.cpp
+2
-1
source/dnode/mgmt/test/qnode/dqnode.cpp
source/dnode/mgmt/test/qnode/dqnode.cpp
+2
-0
source/dnode/mgmt/test/snode/dsnode.cpp
source/dnode/mgmt/test/snode/dsnode.cpp
+2
-0
source/dnode/mnode/impl/inc/mndInt.h
source/dnode/mnode/impl/inc/mndInt.h
+2
-4
source/dnode/mnode/impl/src/mnode.c
source/dnode/mnode/impl/src/mnode.c
+50
-57
source/dnode/mnode/impl/test/CMakeLists.txt
source/dnode/mnode/impl/test/CMakeLists.txt
+1
-1
未找到文件。
source/common/src/tmsgcb.c
浏览文件 @
8fc5ce2e
...
...
@@ -20,9 +20,9 @@
static
SMsgCb
tsDefaultMsgCb
;
void
tmsgSetDefaultMsgCb
(
const
SMsgCb
*
pMsgCb
)
{
if
(
tsDefaultMsgCb
.
pWrapper
==
NULL
)
{
tsDefaultMsgCb
=
*
pMsgCb
;
}
//
if (tsDefaultMsgCb.pWrapper == NULL) {
tsDefaultMsgCb
=
*
pMsgCb
;
//
}
}
int32_t
tmsgPutToQueue
(
const
SMsgCb
*
pMsgCb
,
EQueueType
qtype
,
SRpcMsg
*
pReq
)
{
...
...
source/dnode/mgmt/test/bnode/dbnode.cpp
浏览文件 @
8fc5ce2e
...
...
@@ -84,6 +84,7 @@ TEST_F(DndTestBnode, 01_Create_Bnode) {
}
TEST_F
(
DndTestBnode
,
02
_Drop_Bnode
)
{
#if 0
{
SDDropBnodeReq dropReq = {0};
dropReq.dnodeId = 2;
...
...
@@ -96,7 +97,7 @@ TEST_F(DndTestBnode, 02_Drop_Bnode) {
ASSERT_NE(pRsp, nullptr);
ASSERT_EQ(pRsp->code, TSDB_CODE_INVALID_OPTION);
}
#endif
{
SDDropBnodeReq
dropReq
=
{
0
};
dropReq
.
dnodeId
=
1
;
...
...
source/dnode/mgmt/test/qnode/dqnode.cpp
浏览文件 @
8fc5ce2e
...
...
@@ -82,6 +82,7 @@ TEST_F(DndTestQnode, 01_Create_Qnode) {
}
TEST_F
(
DndTestQnode
,
02
_Drop_Qnode
)
{
#if 0
{
SDDropQnodeReq dropReq = {0};
dropReq.dnodeId = 2;
...
...
@@ -94,6 +95,7 @@ TEST_F(DndTestQnode, 02_Drop_Qnode) {
ASSERT_NE(pRsp, nullptr);
ASSERT_EQ(pRsp->code, TSDB_CODE_INVALID_OPTION);
}
#endif
{
SDDropQnodeReq
dropReq
=
{
0
};
...
...
source/dnode/mgmt/test/snode/dsnode.cpp
浏览文件 @
8fc5ce2e
...
...
@@ -82,6 +82,7 @@ TEST_F(DndTestSnode, 01_Create_Snode) {
}
TEST_F
(
DndTestSnode
,
01
_Drop_Snode
)
{
#if 0
{
SDDropSnodeReq dropReq = {0};
dropReq.dnodeId = 2;
...
...
@@ -94,6 +95,7 @@ TEST_F(DndTestSnode, 01_Drop_Snode) {
ASSERT_NE(pRsp, nullptr);
ASSERT_EQ(pRsp->code, TSDB_CODE_INVALID_OPTION);
}
#endif
{
SDDropSnodeReq
dropReq
=
{
0
};
...
...
source/dnode/mnode/impl/inc/mndInt.h
浏览文件 @
8fc5ce2e
...
...
@@ -87,13 +87,11 @@ typedef struct {
typedef
struct
SMnode
{
int32_t
selfId
;
int64_t
clusterId
;
TdThread
thread
;
bool
stopped
;
int8_t
replica
;
int8_t
selfIndex
;
SReplica
replicas
[
TSDB_MAX_REPLICA
];
tmr_h
timer
;
tmr_h
transTimer
;
tmr_h
mqTimer
;
tmr_h
telemTimer
;
char
*
path
;
int64_t
checkTime
;
SSdb
*
pSdb
;
...
...
source/dnode/mnode/impl/src/mnode.c
浏览文件 @
8fc5ce2e
...
...
@@ -56,82 +56,75 @@ static void *mndBuildTimerMsg(int32_t *pContLen) {
return
pReq
;
}
static
void
mndPullupTrans
(
void
*
param
,
void
*
tmrId
)
{
SMnode
*
pMnode
=
param
;
if
(
mndIsMaster
(
pMnode
))
{
int32_t
contLen
=
0
;
void
*
pReq
=
mndBuildTimerMsg
(
&
contLen
);
SRpcMsg
rpcMsg
=
{.
msgType
=
TDMT_MND_TRANS_TIMER
,
.
pCont
=
pReq
,
.
contLen
=
contLen
};
tmsgPutToQueue
(
&
pMnode
->
msgCb
,
WRITE_QUEUE
,
&
rpcMsg
);
}
taosTmrReset
(
mndPullupTrans
,
tsTransPullupInterval
*
1000
,
pMnode
,
pMnode
->
timer
,
&
pMnode
->
transTimer
);
static
void
mndPullupTrans
(
SMnode
*
pMnode
)
{
int32_t
contLen
=
0
;
void
*
pReq
=
mndBuildTimerMsg
(
&
contLen
);
SRpcMsg
rpcMsg
=
{.
msgType
=
TDMT_MND_TRANS_TIMER
,
.
pCont
=
pReq
,
.
contLen
=
contLen
};
tmsgPutToQueue
(
&
pMnode
->
msgCb
,
WRITE_QUEUE
,
&
rpcMsg
);
}
static
void
mndCalMqRebalance
(
void
*
param
,
void
*
tmrId
)
{
SMnode
*
pMnode
=
param
;
if
(
mndIsMaster
(
pMnode
))
{
int32_t
contLen
=
0
;
void
*
pReq
=
mndBuildTimerMsg
(
&
contLen
);
SRpcMsg
rpcMsg
=
{
.
msgType
=
TDMT_MND_MQ_TIMER
,
.
pCont
=
pReq
,
.
contLen
=
contLen
,
};
tmsgPutToQueue
(
&
pMnode
->
msgCb
,
READ_QUEUE
,
&
rpcMsg
);
}
static
void
mndCalMqRebalance
(
SMnode
*
pMnode
)
{
int32_t
contLen
=
0
;
void
*
pReq
=
mndBuildTimerMsg
(
&
contLen
);
SRpcMsg
rpcMsg
=
{
.
msgType
=
TDMT_MND_MQ_TIMER
,
.
pCont
=
pReq
,
.
contLen
=
contLen
,
};
tmsgPutToQueue
(
&
pMnode
->
msgCb
,
READ_QUEUE
,
&
rpcMsg
);
}
taosTmrReset
(
mndCalMqRebalance
,
tsMqRebalanceInterval
*
1000
,
pMnode
,
pMnode
->
timer
,
&
pMnode
->
mqTimer
);
static
void
mndPullupTelem
(
SMnode
*
pMnode
)
{
int32_t
contLen
=
0
;
void
*
pReq
=
mndBuildTimerMsg
(
&
contLen
);
SRpcMsg
rpcMsg
=
{.
msgType
=
TDMT_MND_TELEM_TIMER
,
.
pCont
=
pReq
,
.
contLen
=
contLen
};
}
static
void
mndPullupTelem
(
void
*
param
,
void
*
tmrId
)
{
static
void
*
mndThreadFp
(
void
*
param
)
{
SMnode
*
pMnode
=
param
;
if
(
mndIsMaster
(
pMnode
))
{
int32_t
contLen
=
0
;
void
*
pReq
=
mndBuildTimerMsg
(
&
contLen
);
SRpcMsg
rpcMsg
=
{.
msgType
=
TDMT_MND_TELEM_TIMER
,
.
pCont
=
pReq
,
.
contLen
=
contLen
};
tmsgPutToQueue
(
&
pMnode
->
msgCb
,
READ_QUEUE
,
&
rpcMsg
);
}
int64_t
lastTime
=
0
;
setThreadName
(
"mnode-timer"
);
taosTmrReset
(
mndPullupTelem
,
tsTelemInterval
*
1000
,
pMnode
,
pMnode
->
timer
,
&
pMnode
->
telemTimer
);
}
while
(
1
)
{
lastTime
++
;
taosMsleep
(
100
);
if
(
pMnode
->
stopped
)
break
;
if
(
!
mndIsMaster
(
pMnode
))
continue
;
static
int32_t
mndInitTimer
(
SMnode
*
pMnode
)
{
pMnode
->
timer
=
taosTmrInit
(
5000
,
200
,
3600000
,
"MND"
);
if
(
pMnode
->
timer
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
if
(
lastTime
%
(
tsTransPullupInterval
*
10
)
==
0
)
{
mndPullupTrans
(
pMnode
);
}
if
(
taosTmrReset
(
mndPullupTrans
,
tsTransPullupInterval
*
1000
,
pMnode
,
pMnode
->
timer
,
&
pMnode
->
transTimer
))
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
if
(
lastTime
%
(
tsMqRebalanceInterval
*
10
)
==
0
)
{
mndCalMqRebalance
(
pMnode
);
}
if
(
taosTmrReset
(
mndCalMqRebalance
,
tsMqRebalanceInterval
*
1000
,
pMnode
,
pMnode
->
timer
,
&
pMnode
->
mqTimer
)
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
if
(
lastTime
%
(
tsTelemInterval
*
10
)
==
0
)
{
mndPullupTelem
(
pMnode
)
;
}
}
int32_t
interval
=
tsTelemInterval
<
10
?
tsTelemInterval
:
10
;
if
(
taosTmrReset
(
mndPullupTelem
,
interval
*
1000
,
pMnode
,
pMnode
->
timer
,
&
pMnode
->
telemTimer
))
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
}
static
int32_t
mndInitTimer
(
SMnode
*
pMnode
)
{
TdThreadAttr
thAttr
;
taosThreadAttrInit
(
&
thAttr
);
taosThreadAttrSetDetachState
(
&
thAttr
,
PTHREAD_CREATE_JOINABLE
);
if
(
taosThreadCreate
(
&
pMnode
->
thread
,
&
thAttr
,
mndThreadFp
,
pMnode
)
!=
0
)
{
mError
(
"failed to create timer thread since %s"
,
strerror
(
errno
));
return
-
1
;
}
taosThreadAttrDestroy
(
&
thAttr
);
tmsgReportStartup
(
"mnode-timer"
,
"initialized"
);
return
0
;
}
static
void
mndCleanupTimer
(
SMnode
*
pMnode
)
{
if
(
pMnode
->
timer
!=
NULL
)
{
taosTmrStop
(
pMnode
->
transTimer
);
pMnode
->
transTimer
=
NULL
;
taosTmrStop
(
pMnode
->
mqTimer
);
pMnode
->
mqTimer
=
NULL
;
taosTmrStop
(
pMnode
->
telemTimer
);
pMnode
->
telemTimer
=
NULL
;
taosTmrCleanUp
(
pMnode
->
timer
);
pMnode
->
timer
=
NULL
;
pMnode
->
stopped
=
true
;
if
(
taosCheckPthreadValid
(
pMnode
->
thread
))
{
taosThreadJoin
(
pMnode
->
thread
,
NULL
);
}
}
...
...
source/dnode/mnode/impl/test/CMakeLists.txt
浏览文件 @
8fc5ce2e
...
...
@@ -5,7 +5,7 @@ add_subdirectory(bnode)
add_subdirectory
(
db
)
add_subdirectory
(
dnode
)
add_subdirectory
(
func
)
add_subdirectory
(
mnode
)
#
add_subdirectory(mnode)
add_subdirectory
(
profile
)
add_subdirectory
(
qnode
)
add_subdirectory
(
sdb
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录