Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
34e37463
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看板
提交
34e37463
编写于
12月 09, 2020
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-2393
上级
259e2941
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
23 addition
and
43 deletion
+23
-43
src/dnode/src/dnodeVMgmt.c
src/dnode/src/dnodeVMgmt.c
+23
-43
未找到文件。
src/dnode/src/dnodeVMgmt.c
浏览文件 @
34e37463
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "os.h"
#include "os.h"
#include "tqueue.h"
#include "tqueue.h"
#include "tworker.h"
#include "dnodeVMgmt.h"
#include "dnodeVMgmt.h"
typedef
struct
{
typedef
struct
{
...
@@ -23,9 +24,8 @@ typedef struct {
...
@@ -23,9 +24,8 @@ typedef struct {
char
pCont
[];
char
pCont
[];
}
SMgmtMsg
;
}
SMgmtMsg
;
static
taos_qset
tsMgmtQset
=
NULL
;
static
SWorkerPool
tsVMgmtWP
;
static
taos_queue
tsMgmtQueue
=
NULL
;
static
taos_queue
tsVMgmtQueue
=
NULL
;
static
pthread_t
tsQthread
;
static
void
*
dnodeProcessMgmtQueue
(
void
*
param
);
static
void
*
dnodeProcessMgmtQueue
(
void
*
param
);
static
int32_t
dnodeProcessCreateVnodeMsg
(
SRpcMsg
*
pMsg
);
static
int32_t
dnodeProcessCreateVnodeMsg
(
SRpcMsg
*
pMsg
);
...
@@ -47,45 +47,23 @@ int32_t dnodeInitVMgmt() {
...
@@ -47,45 +47,23 @@ int32_t dnodeInitVMgmt() {
int32_t
code
=
vnodeInitMgmt
();
int32_t
code
=
vnodeInitMgmt
();
if
(
code
!=
TSDB_CODE_SUCCESS
)
return
-
1
;
if
(
code
!=
TSDB_CODE_SUCCESS
)
return
-
1
;
tsMgmtQset
=
taosOpenQset
();
tsVMgmtWP
.
name
=
"vmgmt"
;
if
(
tsMgmtQset
==
NULL
)
{
tsVMgmtWP
.
workerFp
=
dnodeProcessMgmtQueue
;
dError
(
"failed to create the vmgmt queue set"
);
tsVMgmtWP
.
min
=
1
;
return
-
1
;
tsVMgmtWP
.
max
=
1
;
}
if
(
tWorkerInit
(
&
tsVMgmtWP
)
!=
0
)
return
-
1
;
tsMgmtQueue
=
taosOpenQueue
();
if
(
tsMgmtQueue
==
NULL
)
{
dError
(
"failed to create the vmgmt queue"
);
return
-
1
;
}
taosAddIntoQset
(
tsMgmtQset
,
tsMgmtQueue
,
NULL
);
pthread_attr_t
thAttr
;
tsVMgmtQueue
=
tWorkerAllocQueue
(
&
tsVMgmtWP
,
NULL
);
pthread_attr_init
(
&
thAttr
);
pthread_attr_setdetachstate
(
&
thAttr
,
PTHREAD_CREATE_JOINABLE
);
code
=
pthread_create
(
&
tsQthread
,
&
thAttr
,
dnodeProcessMgmtQueue
,
NULL
);
pthread_attr_destroy
(
&
thAttr
);
if
(
code
!=
0
)
{
dError
(
"failed to create thread to process vmgmt queue, reason:%s"
,
strerror
(
errno
));
return
-
1
;
}
dInfo
(
"dnode vmgmt is initialized"
);
dInfo
(
"dnode vmgmt is initialized"
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
void
dnodeCleanupVMgmt
()
{
void
dnodeCleanupVMgmt
()
{
if
(
tsMgmtQset
)
taosQsetThreadResume
(
tsMgmtQset
);
tWorkerFreeQueue
(
&
tsVMgmtWP
,
tsVMgmtQueue
);
if
(
tsQthread
)
pthread_join
(
tsQthread
,
NULL
);
tWorkerCleanup
(
&
tsVMgmtWP
);
if
(
tsMgmtQueue
)
taosCloseQueue
(
tsMgmtQueue
);
if
(
tsMgmtQset
)
taosCloseQset
(
tsMgmtQset
);
tsMgmtQset
=
NULL
;
tsMgmtQueue
=
NULL
;
tsVMgmtQueue
=
NULL
;
vnodeCleanupMgmt
();
vnodeCleanupMgmt
();
}
}
...
@@ -97,7 +75,7 @@ static int32_t dnodeWriteToMgmtQueue(SRpcMsg *pMsg) {
...
@@ -97,7 +75,7 @@ static int32_t dnodeWriteToMgmtQueue(SRpcMsg *pMsg) {
pMgmt
->
rpcMsg
=
*
pMsg
;
pMgmt
->
rpcMsg
=
*
pMsg
;
pMgmt
->
rpcMsg
.
pCont
=
pMgmt
->
pCont
;
pMgmt
->
rpcMsg
.
pCont
=
pMgmt
->
pCont
;
memcpy
(
pMgmt
->
pCont
,
pMsg
->
pCont
,
pMsg
->
contLen
);
memcpy
(
pMgmt
->
pCont
,
pMsg
->
pCont
,
pMsg
->
contLen
);
taosWriteQitem
(
tsMgmtQueue
,
TAOS_QTYPE_RPC
,
pMgmt
);
taosWriteQitem
(
ts
V
MgmtQueue
,
TAOS_QTYPE_RPC
,
pMgmt
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -112,16 +90,18 @@ void dnodeDispatchToVMgmtQueue(SRpcMsg *pMsg) {
...
@@ -112,16 +90,18 @@ void dnodeDispatchToVMgmtQueue(SRpcMsg *pMsg) {
rpcFreeCont
(
pMsg
->
pCont
);
rpcFreeCont
(
pMsg
->
pCont
);
}
}
static
void
*
dnodeProcessMgmtQueue
(
void
*
param
)
{
static
void
*
dnodeProcessMgmtQueue
(
void
*
wparam
)
{
SMgmtMsg
*
pMgmt
;
SWorker
*
pWorker
=
wparam
;
SWorkerPool
*
pPool
=
pWorker
->
pPool
;
SMgmtMsg
*
pMgmt
;
SRpcMsg
*
pMsg
;
SRpcMsg
*
pMsg
;
SRpcMsg
rsp
=
{
0
};
SRpcMsg
rsp
=
{
0
};
int32_t
qtype
;
int32_t
qtype
;
void
*
handle
;
void
*
handle
;
while
(
1
)
{
while
(
1
)
{
if
(
taosReadQitemFromQset
(
tsMgmtQ
set
,
&
qtype
,
(
void
**
)
&
pMgmt
,
&
handle
)
==
0
)
{
if
(
taosReadQitemFromQset
(
pPool
->
q
set
,
&
qtype
,
(
void
**
)
&
pMgmt
,
&
handle
)
==
0
)
{
dDebug
(
"q
set:%p, dnode mgmt got no message from qset, exit"
,
tsMgmtQ
set
);
dDebug
(
"q
dnode mgmt got no message from qset:%p, , exit"
,
pPool
->
q
set
);
break
;
break
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录