Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
08b087ec
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
08b087ec
编写于
5月 30, 2020
作者:
陶建辉(Jeff)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add a queue for mgmt message from mnode
上级
72e8540c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
91 addition
and
23 deletion
+91
-23
src/dnode/inc/dnodeMgmt.h
src/dnode/inc/dnodeMgmt.h
+1
-1
src/dnode/src/dnodeMgmt.c
src/dnode/src/dnodeMgmt.c
+86
-18
src/dnode/src/dnodePeer.c
src/dnode/src/dnodePeer.c
+4
-4
未找到文件。
src/dnode/inc/dnodeMgmt.h
浏览文件 @
08b087ec
...
...
@@ -22,7 +22,7 @@ extern "C" {
int32_t
dnodeInitMgmt
();
void
dnodeCleanupMgmt
();
void
dnodeDispatchTo
DnodeMgmt
(
SRpcMsg
*
rpcMsg
);
void
dnodeDispatchTo
MgmtQueue
(
SRpcMsg
*
rpcMsg
);
void
*
dnodeGetVnode
(
int32_t
vgId
);
int32_t
dnodeGetVnodeStatus
(
void
*
pVnode
);
...
...
src/dnode/src/dnodeMgmt.c
浏览文件 @
08b087ec
...
...
@@ -22,6 +22,7 @@
#include "ttimer.h"
#include "tsdb.h"
#include "twal.h"
#include "tqueue.h"
#include "tsync.h"
#include "ttime.h"
#include "ttimer.h"
...
...
@@ -46,6 +47,9 @@ static SRpcIpSet tsDMnodeIpSetForPeer = {0};
static
SRpcIpSet
tsDMnodeIpSetForShell
=
{
0
};
static
SDMMnodeInfos
tsDMnodeInfos
=
{
0
};
static
SDMDnodeCfg
tsDnodeCfg
=
{
0
};
static
taos_qset
tsMgmtQset
=
NULL
;
static
taos_queue
tsMgmtQueue
=
NULL
;
static
pthread_t
tsQthread
;
static
void
dnodeUpdateMnodeInfos
(
SDMMnodeInfos
*
pMnodes
);
static
bool
dnodeReadMnodeInfos
();
...
...
@@ -55,6 +59,7 @@ static bool dnodeReadDnodeCfg();
static
void
dnodeSaveDnodeCfg
();
static
void
dnodeProcessStatusRsp
(
SRpcMsg
*
pMsg
);
static
void
dnodeSendStatusMsg
(
void
*
handle
,
void
*
tmrId
);
static
void
*
dnodeProcessMgmtQueue
(
void
*
param
);
static
int32_t
dnodeOpenVnodes
();
static
void
dnodeCloseVnodes
();
...
...
@@ -74,12 +79,6 @@ int32_t dnodeInitMgmt() {
dnodeReadDnodeCfg
();
tsRebootTime
=
taosGetTimestampSec
();
tsDnodeTmr
=
taosTmrInit
(
100
,
200
,
60000
,
"DND-DM"
);
if
(
tsDnodeTmr
==
NULL
)
{
dError
(
"failed to init dnode timer"
);
return
-
1
;
}
if
(
!
dnodeReadMnodeInfos
())
{
memset
(
&
tsDMnodeIpSetForPeer
,
0
,
sizeof
(
SRpcIpSet
));
memset
(
&
tsDMnodeIpSetForShell
,
0
,
sizeof
(
SRpcIpSet
));
...
...
@@ -118,8 +117,45 @@ int32_t dnodeInitMgmt() {
}
}
int32_t
code
=
dnodeOpenVnodes
();
// create the queue and thread to handle the message
tsMgmtQset
=
taosOpenQset
();
if
(
tsMgmtQset
==
NULL
)
{
dError
(
"failed to create the mgmt queue set"
);
dnodeCleanupMgmt
();
return
-
1
;
}
tsMgmtQueue
=
taosOpenQueue
();
if
(
tsMgmtQueue
==
NULL
)
{
dError
(
"failed to create the mgmt queue"
);
dnodeCleanupMgmt
();
return
-
1
;
}
taosAddIntoQset
(
tsMgmtQset
,
tsMgmtQueue
,
NULL
);
pthread_attr_t
thAttr
;
pthread_attr_init
(
&
thAttr
);
pthread_attr_setdetachstate
(
&
thAttr
,
PTHREAD_CREATE_JOINABLE
);
int32_t
code
=
pthread_create
(
&
tsQthread
,
&
thAttr
,
dnodeProcessMgmtQueue
,
NULL
);
pthread_attr_destroy
(
&
thAttr
);
if
(
code
!=
0
)
{
dError
(
"failed to create thread to process mgmt queue, reason:%s"
,
strerror
(
errno
));
dnodeCleanupMgmt
();
return
-
1
;
}
code
=
dnodeOpenVnodes
();
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
dnodeCleanupMgmt
();
return
-
1
;
}
tsDnodeTmr
=
taosTmrInit
(
100
,
200
,
60000
,
"DND-DM"
);
if
(
tsDnodeTmr
==
NULL
)
{
dError
(
"failed to init dnode timer"
);
dnodeCleanupMgmt
();
return
-
1
;
}
...
...
@@ -142,22 +178,54 @@ void dnodeCleanupMgmt() {
}
dnodeCloseVnodes
();
if
(
tsMgmtQset
)
taosQsetThreadResume
(
tsMgmtQset
);
if
(
tsQthread
)
pthread_join
(
tsQthread
,
NULL
);
if
(
tsMgmtQueue
)
taosCloseQueue
(
tsMgmtQueue
);
if
(
tsMgmtQset
)
taosCloseQset
(
tsMgmtQset
);
tsMgmtQset
=
NULL
;
tsMgmtQueue
=
NULL
;
}
void
dnodeDispatchTo
DnodeMgmt
(
SRpcMsg
*
pMsg
)
{
SRpcMsg
rsp
;
void
dnodeDispatchTo
MgmtQueue
(
SRpcMsg
*
pMsg
)
{
void
*
item
;
if
(
dnodeProcessMgmtMsgFp
[
pMsg
->
msgType
])
{
rsp
.
code
=
(
*
dnodeProcessMgmtMsgFp
[
pMsg
->
msgType
])(
pMsg
);
}
else
{
rsp
.
code
=
TSDB_CODE_MSG_NOT_PROCESSED
;
}
item
=
taosAllocateQitem
(
sizeof
(
SRpcMsg
));
memcpy
(
item
,
pMsg
,
sizeof
(
SRpcMsg
));
taosWriteQitem
(
tsMgmtQueue
,
1
,
item
);
}
static
void
*
dnodeProcessMgmtQueue
(
void
*
param
)
{
SRpcMsg
*
pMsg
;
SRpcMsg
rsp
;
int
type
;
void
*
handle
;
rsp
.
handle
=
pMsg
->
handle
;
rsp
.
pCont
=
NULL
;
rpcSendResponse
(
&
rsp
);
while
(
1
)
{
if
(
taosReadQitemFromQset
(
tsMgmtQset
,
&
type
,
(
void
**
)
&
pMsg
,
&
handle
)
==
0
)
{
dTrace
(
"dnode mgmt got no message from qset, exit ..."
);
break
;
}
dTrace
(
"%p, msg:%s will be processed"
,
pMsg
->
ahandle
,
taosMsg
[
pMsg
->
msgType
]);
if
(
dnodeProcessMgmtMsgFp
[
pMsg
->
msgType
])
{
rsp
.
code
=
(
*
dnodeProcessMgmtMsgFp
[
pMsg
->
msgType
])(
pMsg
);
}
else
{
rsp
.
code
=
TSDB_CODE_MSG_NOT_PROCESSED
;
}
rsp
.
handle
=
pMsg
->
handle
;
rsp
.
pCont
=
NULL
;
rpcSendResponse
(
&
rsp
);
rpcFreeCont
(
pMsg
->
pCont
);
taosFreeQitem
(
pMsg
);
}
r
pcFreeCont
(
pMsg
->
pCont
)
;
r
eturn
NULL
;
}
static
int32_t
dnodeGetVnodeList
(
int32_t
vnodeList
[],
int32_t
*
numOfVnodes
)
{
...
...
src/dnode/src/dnodePeer.c
浏览文件 @
08b087ec
...
...
@@ -43,10 +43,10 @@ int32_t dnodeInitServer() {
dnodeProcessReqMsgFp
[
TSDB_MSG_TYPE_MD_ALTER_TABLE
]
=
dnodeDispatchToVnodeWriteQueue
;
dnodeProcessReqMsgFp
[
TSDB_MSG_TYPE_MD_DROP_STABLE
]
=
dnodeDispatchToVnodeWriteQueue
;
dnodeProcessReqMsgFp
[
TSDB_MSG_TYPE_MD_CREATE_VNODE
]
=
dnodeDispatchTo
DnodeMgmt
;
dnodeProcessReqMsgFp
[
TSDB_MSG_TYPE_MD_DROP_VNODE
]
=
dnodeDispatchTo
DnodeMgmt
;
dnodeProcessReqMsgFp
[
TSDB_MSG_TYPE_MD_ALTER_STREAM
]
=
dnodeDispatchTo
DnodeMgmt
;
dnodeProcessReqMsgFp
[
TSDB_MSG_TYPE_MD_CONFIG_DNODE
]
=
dnodeDispatchTo
DnodeMgmt
;
dnodeProcessReqMsgFp
[
TSDB_MSG_TYPE_MD_CREATE_VNODE
]
=
dnodeDispatchTo
MgmtQueue
;
dnodeProcessReqMsgFp
[
TSDB_MSG_TYPE_MD_DROP_VNODE
]
=
dnodeDispatchTo
MgmtQueue
;
dnodeProcessReqMsgFp
[
TSDB_MSG_TYPE_MD_ALTER_STREAM
]
=
dnodeDispatchTo
MgmtQueue
;
dnodeProcessReqMsgFp
[
TSDB_MSG_TYPE_MD_CONFIG_DNODE
]
=
dnodeDispatchTo
MgmtQueue
;
dnodeProcessReqMsgFp
[
TSDB_MSG_TYPE_DM_CONFIG_TABLE
]
=
dnodeDispatchToMnodePeerQueue
;
dnodeProcessReqMsgFp
[
TSDB_MSG_TYPE_DM_CONFIG_VNODE
]
=
dnodeDispatchToMnodePeerQueue
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录