Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
2af212f4
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看板
提交
2af212f4
编写于
3月 22, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refact worker
上级
f48fddc7
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
84 addition
and
92 deletion
+84
-92
include/util/tworker.h
include/util/tworker.h
+8
-8
source/dnode/mgmt/bnode/inc/bmInt.h
source/dnode/mgmt/bnode/inc/bmInt.h
+1
-1
source/dnode/mgmt/bnode/src/bmWorker.c
source/dnode/mgmt/bnode/src/bmWorker.c
+4
-4
source/dnode/mgmt/dnode/inc/dmInt.h
source/dnode/mgmt/dnode/inc/dmInt.h
+2
-2
source/dnode/mgmt/dnode/src/dmWorker.c
source/dnode/mgmt/dnode/src/dmWorker.c
+7
-7
source/dnode/mgmt/mnode/inc/mmInt.h
source/dnode/mgmt/mnode/inc/mmInt.h
+3
-3
source/dnode/mgmt/mnode/src/mmWorker.c
source/dnode/mgmt/mnode/src/mmWorker.c
+9
-9
source/dnode/mgmt/qnode/inc/qmInt.h
source/dnode/mgmt/qnode/inc/qmInt.h
+2
-2
source/dnode/mgmt/qnode/src/qmWorker.c
source/dnode/mgmt/qnode/src/qmWorker.c
+16
-16
source/dnode/mgmt/snode/inc/smInt.h
source/dnode/mgmt/snode/inc/smInt.h
+2
-2
source/dnode/mgmt/snode/src/smWorker.c
source/dnode/mgmt/snode/src/smWorker.c
+17
-17
source/dnode/mgmt/vnode/inc/vmInt.h
source/dnode/mgmt/vnode/inc/vmInt.h
+1
-1
source/dnode/mgmt/vnode/src/vmWorker.c
source/dnode/mgmt/vnode/src/vmWorker.c
+8
-16
source/util/src/tworker.c
source/util/src/tworker.c
+4
-4
未找到文件。
include/util/tworker.h
浏览文件 @
2af212f4
...
...
@@ -74,31 +74,31 @@ typedef struct {
int32_t
maxNum
;
FItem
fp
;
void
*
param
;
}
S
QWorkerAll
Cfg
;
}
S
SingleWorker
Cfg
;
typedef
struct
{
const
char
*
name
;
STaosQueue
*
queue
;
SQWorkerPool
pool
;
}
S
QWorkerAll
;
}
S
SingleWorker
;
typedef
struct
{
const
char
*
name
;
int32_t
maxNum
;
FItems
fp
;
void
*
param
;
}
S
WWorkerAll
Cfg
;
}
S
MultiWorker
Cfg
;
typedef
struct
{
const
char
*
name
;
STaosQueue
*
queue
;
SWWorkerPool
pool
;
}
S
WWorkerAll
;
}
S
MultiWorker
;
int32_t
t
QWorkerAllInit
(
SQWorkerAll
*
pWorker
,
const
SQWorkerAll
Cfg
*
pCfg
);
void
t
QWorkerAllCleanup
(
SQWorkerAll
*
pWorker
);
int32_t
t
WWorkerAllInit
(
SWWorkerAll
*
pWorker
,
const
SWWorkerAll
Cfg
*
pCfg
);
void
t
WWorkerAllCleanup
(
SWWorkerAll
*
pWorker
);
int32_t
t
SingleWorkerInit
(
SSingleWorker
*
pWorker
,
const
SSingleWorker
Cfg
*
pCfg
);
void
t
SingleWorkerCleanup
(
SSingleWorker
*
pWorker
);
int32_t
t
MultiWorkerInit
(
SMultiWorker
*
pWorker
,
const
SMultiWorker
Cfg
*
pCfg
);
void
t
MultiWorkerCleanup
(
SMultiWorker
*
pWorker
);
#ifdef __cplusplus
}
...
...
source/dnode/mgmt/bnode/inc/bmInt.h
浏览文件 @
2af212f4
...
...
@@ -28,7 +28,7 @@ typedef struct SBnodeMgmt {
SDnode
*
pDnode
;
SMgmtWrapper
*
pWrapper
;
const
char
*
path
;
S
WWorkerAll
writeWorker
;
S
MultiWorker
writeWorker
;
}
SBnodeMgmt
;
// bmInt.c
...
...
source/dnode/mgmt/bnode/src/bmWorker.c
浏览文件 @
2af212f4
...
...
@@ -64,15 +64,15 @@ static void bmProcessQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs
}
int32_t
bmProcessWriteMsg
(
SBnodeMgmt
*
pMgmt
,
SNodeMsg
*
pMsg
)
{
S
WWorkerAll
*
pWorker
=
&
pMgmt
->
writeWorker
;
S
MultiWorker
*
pWorker
=
&
pMgmt
->
writeWorker
;
dTrace
(
"msg:%p, put into worker:%s"
,
pMsg
,
pWorker
->
name
);
return
taosWriteQitem
(
pWorker
->
queue
,
pMsg
);
}
int32_t
bmStartWorker
(
SBnodeMgmt
*
pMgmt
)
{
S
WWorkerAll
Cfg
cfg
=
{.
maxNum
=
1
,
.
name
=
"bnode-write"
,
.
fp
=
(
FItems
)
bmProcessQueue
,
.
param
=
pMgmt
};
if
(
t
WWorkerAll
Init
(
&
pMgmt
->
writeWorker
,
&
cfg
)
!=
0
)
{
S
MultiWorker
Cfg
cfg
=
{.
maxNum
=
1
,
.
name
=
"bnode-write"
,
.
fp
=
(
FItems
)
bmProcessQueue
,
.
param
=
pMgmt
};
if
(
t
MultiWorker
Init
(
&
pMgmt
->
writeWorker
,
&
cfg
)
!=
0
)
{
dError
(
"failed to start bnode write worker since %s"
,
terrstr
());
return
-
1
;
}
...
...
@@ -80,4 +80,4 @@ int32_t bmStartWorker(SBnodeMgmt *pMgmt) {
return
0
;
}
void
bmStopWorker
(
SBnodeMgmt
*
pMgmt
)
{
t
WWorkerAll
Cleanup
(
&
pMgmt
->
writeWorker
);
}
void
bmStopWorker
(
SBnodeMgmt
*
pMgmt
)
{
t
MultiWorker
Cleanup
(
&
pMgmt
->
writeWorker
);
}
source/dnode/mgmt/dnode/inc/dmInt.h
浏览文件 @
2af212f4
...
...
@@ -31,8 +31,8 @@ typedef struct SDnodeMgmt {
SArray
*
dnodeEps
;
TdThread
*
threadId
;
SRWLatch
latch
;
S
QWorkerAll
mgmtWorker
;
S
QWorkerAll
statusWorker
;
S
SingleWorker
mgmtWorker
;
S
SingleWorker
statusWorker
;
const
char
*
path
;
SDnode
*
pDnode
;
SMgmtWrapper
*
pWrapper
;
...
...
source/dnode/mgmt/dnode/src/dmWorker.c
浏览文件 @
2af212f4
...
...
@@ -100,16 +100,16 @@ static void dmProcessQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) {
}
int32_t
dmStartWorker
(
SDnodeMgmt
*
pMgmt
)
{
S
QWorkerAll
Cfg
mgmtCfg
=
{
S
SingleWorker
Cfg
mgmtCfg
=
{
.
minNum
=
1
,
.
maxNum
=
1
,
.
name
=
"dnode-mgmt"
,
.
fp
=
(
FItem
)
dmProcessQueue
,
.
param
=
pMgmt
};
if
(
t
QWorkerAll
Init
(
&
pMgmt
->
mgmtWorker
,
&
mgmtCfg
)
!=
0
)
{
if
(
t
SingleWorker
Init
(
&
pMgmt
->
mgmtWorker
,
&
mgmtCfg
)
!=
0
)
{
dError
(
"failed to start dnode mgmt worker since %s"
,
terrstr
());
return
-
1
;
}
S
QWorkerAll
Cfg
statusCfg
=
{
S
SingleWorker
Cfg
statusCfg
=
{
.
minNum
=
1
,
.
maxNum
=
1
,
.
name
=
"dnode-status"
,
.
fp
=
(
FItem
)
dmProcessQueue
,
.
param
=
pMgmt
};
if
(
t
QWorkerAll
Init
(
&
pMgmt
->
statusWorker
,
&
statusCfg
)
!=
0
)
{
if
(
t
SingleWorker
Init
(
&
pMgmt
->
statusWorker
,
&
statusCfg
)
!=
0
)
{
dError
(
"failed to start dnode status worker since %s"
,
terrstr
());
return
-
1
;
}
...
...
@@ -129,8 +129,8 @@ int32_t dmStartThread(SDnodeMgmt *pMgmt) {
}
void
dmStopWorker
(
SDnodeMgmt
*
pMgmt
)
{
t
QWorkerAll
Cleanup
(
&
pMgmt
->
mgmtWorker
);
t
QWorkerAll
Cleanup
(
&
pMgmt
->
statusWorker
);
t
SingleWorker
Cleanup
(
&
pMgmt
->
mgmtWorker
);
t
SingleWorker
Cleanup
(
&
pMgmt
->
statusWorker
);
if
(
pMgmt
->
threadId
!=
NULL
)
{
taosDestoryThread
(
pMgmt
->
threadId
);
...
...
@@ -139,7 +139,7 @@ void dmStopWorker(SDnodeMgmt *pMgmt) {
}
int32_t
dmProcessMgmtMsg
(
SDnodeMgmt
*
pMgmt
,
SNodeMsg
*
pMsg
)
{
S
QWorkerAll
*
pWorker
=
&
pMgmt
->
mgmtWorker
;
S
SingleWorker
*
pWorker
=
&
pMgmt
->
mgmtWorker
;
if
(
pMsg
->
rpcMsg
.
msgType
==
TDMT_MND_STATUS_RSP
)
{
pWorker
=
&
pMgmt
->
statusWorker
;
}
...
...
source/dnode/mgmt/mnode/inc/mmInt.h
浏览文件 @
2af212f4
...
...
@@ -28,9 +28,9 @@ typedef struct SMnodeMgmt {
SDnode
*
pDnode
;
SMgmtWrapper
*
pWrapper
;
const
char
*
path
;
S
QWorkerAll
readWorker
;
S
QWorkerAll
writeWorker
;
S
QWorkerAll
syncWorker
;
S
SingleWorker
readWorker
;
S
SingleWorker
writeWorker
;
S
SingleWorker
syncWorker
;
SReplica
replicas
[
TSDB_MAX_REPLICA
];
int8_t
replica
;
int8_t
selfIndex
;
...
...
source/dnode/mgmt/mnode/src/mmWorker.c
浏览文件 @
2af212f4
...
...
@@ -44,7 +44,7 @@ static void mmProcessQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) {
taosFreeQitem
(
pMsg
);
}
static
int32_t
mmPutMsgToWorker
(
SMnodeMgmt
*
pMgmt
,
S
QWorkerAll
*
pWorker
,
SNodeMsg
*
pMsg
)
{
static
int32_t
mmPutMsgToWorker
(
SMnodeMgmt
*
pMgmt
,
S
SingleWorker
*
pWorker
,
SNodeMsg
*
pMsg
)
{
dTrace
(
"msg:%p, put into worker %s"
,
pMsg
,
pWorker
->
name
);
return
taosWriteQitem
(
pWorker
->
queue
,
pMsg
);
}
...
...
@@ -61,7 +61,7 @@ int32_t mmProcessReadMsg(SMnodeMgmt *pMgmt, SNodeMsg *pMsg) {
return
mmPutMsgToWorker
(
pMgmt
,
&
pMgmt
->
readWorker
,
pMsg
);
}
static
int32_t
mmPutRpcMsgToWorker
(
SMnodeMgmt
*
pMgmt
,
S
QWorkerAll
*
pWorker
,
SRpcMsg
*
pRpc
)
{
static
int32_t
mmPutRpcMsgToWorker
(
SMnodeMgmt
*
pMgmt
,
S
SingleWorker
*
pWorker
,
SRpcMsg
*
pRpc
)
{
SNodeMsg
*
pMsg
=
taosAllocateQitem
(
sizeof
(
SNodeMsg
));
if
(
pMsg
==
NULL
)
{
return
-
1
;
...
...
@@ -91,19 +91,19 @@ int32_t mmPutMsgToReadQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRpc) {
}
int32_t
mmStartWorker
(
SMnodeMgmt
*
pMgmt
)
{
S
QWorkerAll
Cfg
cfg
=
{.
minNum
=
0
,
.
maxNum
=
1
,
.
name
=
"mnode-read"
,
.
fp
=
(
FItem
)
mmProcessQueue
,
.
param
=
pMgmt
};
S
SingleWorker
Cfg
cfg
=
{.
minNum
=
0
,
.
maxNum
=
1
,
.
name
=
"mnode-read"
,
.
fp
=
(
FItem
)
mmProcessQueue
,
.
param
=
pMgmt
};
if
(
t
QWorkerAll
Init
(
&
pMgmt
->
readWorker
,
&
cfg
)
!=
0
)
{
if
(
t
SingleWorker
Init
(
&
pMgmt
->
readWorker
,
&
cfg
)
!=
0
)
{
dError
(
"failed to start mnode-read worker since %s"
,
terrstr
());
return
-
1
;
}
if
(
t
QWorkerAll
Init
(
&
pMgmt
->
writeWorker
,
&
cfg
)
!=
0
)
{
if
(
t
SingleWorker
Init
(
&
pMgmt
->
writeWorker
,
&
cfg
)
!=
0
)
{
dError
(
"failed to start mnode-write worker since %s"
,
terrstr
());
return
-
1
;
}
if
(
t
QWorkerAll
Init
(
&
pMgmt
->
syncWorker
,
&
cfg
)
!=
0
)
{
if
(
t
SingleWorker
Init
(
&
pMgmt
->
syncWorker
,
&
cfg
)
!=
0
)
{
dError
(
"failed to start mnode sync-worker since %s"
,
terrstr
());
return
-
1
;
}
...
...
@@ -112,7 +112,7 @@ int32_t mmStartWorker(SMnodeMgmt *pMgmt) {
}
void
mmStopWorker
(
SMnodeMgmt
*
pMgmt
)
{
t
QWorkerAll
Cleanup
(
&
pMgmt
->
readWorker
);
t
QWorkerAll
Cleanup
(
&
pMgmt
->
writeWorker
);
t
QWorkerAll
Cleanup
(
&
pMgmt
->
syncWorker
);
t
SingleWorker
Cleanup
(
&
pMgmt
->
readWorker
);
t
SingleWorker
Cleanup
(
&
pMgmt
->
writeWorker
);
t
SingleWorker
Cleanup
(
&
pMgmt
->
syncWorker
);
}
source/dnode/mgmt/qnode/inc/qmInt.h
浏览文件 @
2af212f4
...
...
@@ -28,8 +28,8 @@ typedef struct SQnodeMgmt {
SDnode
*
pDnode
;
SMgmtWrapper
*
pWrapper
;
const
char
*
path
;
S
QWorkerAll
queryWorker
;
S
QWorkerAll
fetchWorker
;
S
SingleWorker
queryWorker
;
S
SingleWorker
fetchWorker
;
}
SQnodeMgmt
;
// qmInt.c
...
...
source/dnode/mgmt/qnode/src/qmWorker.c
浏览文件 @
2af212f4
...
...
@@ -49,7 +49,7 @@ static void qmProcessFetchQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) {
taosFreeQitem
(
pMsg
);
}
static
int32_t
qmPutMsgToWorker
(
S
QWorkerAll
*
pWorker
,
SNodeMsg
*
pMsg
)
{
static
int32_t
qmPutMsgToWorker
(
S
SingleWorker
*
pWorker
,
SNodeMsg
*
pMsg
)
{
dTrace
(
"msg:%p, put into worker %s"
,
pMsg
,
pWorker
->
name
);
return
taosWriteQitem
(
pWorker
->
queue
,
pMsg
);
}
...
...
@@ -58,7 +58,7 @@ int32_t qmProcessQueryMsg(SQnodeMgmt *pMgmt, SNodeMsg *pMsg) { return qmPutMsgTo
int32_t
qmProcessFetchMsg
(
SQnodeMgmt
*
pMgmt
,
SNodeMsg
*
pMsg
)
{
return
qmPutMsgToWorker
(
&
pMgmt
->
fetchWorker
,
pMsg
);
}
static
int32_t
qmPutRpcMsgToWorker
(
SQnodeMgmt
*
pMgmt
,
S
QWorkerAll
*
pWorker
,
SRpcMsg
*
pRpc
)
{
static
int32_t
qmPutRpcMsgToWorker
(
SQnodeMgmt
*
pMgmt
,
S
SingleWorker
*
pWorker
,
SRpcMsg
*
pRpc
)
{
SNodeMsg
*
pMsg
=
taosAllocateQitem
(
sizeof
(
SNodeMsg
));
if
(
pMsg
==
NULL
)
{
return
-
1
;
...
...
@@ -110,24 +110,24 @@ int32_t qmStartWorker(SQnodeMgmt *pMgmt) {
int32_t
minQueryThreads
=
TMAX
((
int32_t
)(
tsNumOfCores
*
tsRatioOfQueryCores
),
1
);
int32_t
maxQueryThreads
=
minQueryThreads
;
S
QWorkerAll
Cfg
queryCfg
=
{.
minNum
=
minQueryThreads
,
.
maxNum
=
maxQueryThreads
,
.
name
=
"qnode-query"
,
.
fp
=
(
FItem
)
qmProcessQueryQueue
,
.
param
=
pMgmt
};
S
SingleWorker
Cfg
queryCfg
=
{.
minNum
=
minQueryThreads
,
.
maxNum
=
maxQueryThreads
,
.
name
=
"qnode-query"
,
.
fp
=
(
FItem
)
qmProcessQueryQueue
,
.
param
=
pMgmt
};
if
(
t
QWorkerAll
Init
(
&
pMgmt
->
queryWorker
,
&
queryCfg
)
!=
0
)
{
if
(
t
SingleWorker
Init
(
&
pMgmt
->
queryWorker
,
&
queryCfg
)
!=
0
)
{
dError
(
"failed to start qnode-query worker since %s"
,
terrstr
());
return
-
1
;
}
S
QWorkerAll
Cfg
fetchCfg
=
{.
minNum
=
minFetchThreads
,
.
maxNum
=
maxFetchThreads
,
.
name
=
"qnode-fetch"
,
.
fp
=
(
FItem
)
qmProcessFetchQueue
,
.
param
=
pMgmt
};
S
SingleWorker
Cfg
fetchCfg
=
{.
minNum
=
minFetchThreads
,
.
maxNum
=
maxFetchThreads
,
.
name
=
"qnode-fetch"
,
.
fp
=
(
FItem
)
qmProcessFetchQueue
,
.
param
=
pMgmt
};
if
(
t
QWorkerAll
Init
(
&
pMgmt
->
fetchWorker
,
&
fetchCfg
)
!=
0
)
{
if
(
t
SingleWorker
Init
(
&
pMgmt
->
fetchWorker
,
&
fetchCfg
)
!=
0
)
{
dError
(
"failed to start qnode-fetch worker since %s"
,
terrstr
());
return
-
1
;
}
...
...
@@ -136,6 +136,6 @@ int32_t qmStartWorker(SQnodeMgmt *pMgmt) {
}
void
qmStopWorker
(
SQnodeMgmt
*
pMgmt
)
{
t
QWorkerAll
Cleanup
(
&
pMgmt
->
queryWorker
);
t
QWorkerAll
Cleanup
(
&
pMgmt
->
fetchWorker
);
t
SingleWorker
Cleanup
(
&
pMgmt
->
queryWorker
);
t
SingleWorker
Cleanup
(
&
pMgmt
->
fetchWorker
);
}
source/dnode/mgmt/snode/inc/smInt.h
浏览文件 @
2af212f4
...
...
@@ -30,8 +30,8 @@ typedef struct SSnodeMgmt {
const
char
*
path
;
SRWLatch
latch
;
int8_t
uniqueWorkerInUse
;
SArray
*
uniqueWorkers
;
// SArray<S
WWorkerAll
*>
S
QWorkerAll
sharedWorker
;
SArray
*
uniqueWorkers
;
// SArray<S
MultiWorker
*>
S
SingleWorker
sharedWorker
;
}
SSnodeMgmt
;
// smInt.c
...
...
source/dnode/mgmt/snode/src/smWorker.c
浏览文件 @
2af212f4
...
...
@@ -44,22 +44,22 @@ static void smProcessSharedQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) {
}
int32_t
smStartWorker
(
SSnodeMgmt
*
pMgmt
)
{
pMgmt
->
uniqueWorkers
=
taosArrayInit
(
0
,
sizeof
(
S
WWorkerAll
*
));
pMgmt
->
uniqueWorkers
=
taosArrayInit
(
0
,
sizeof
(
S
MultiWorker
*
));
if
(
pMgmt
->
uniqueWorkers
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
for
(
int32_t
i
=
0
;
i
<
SND_UNIQUE_THREAD_NUM
;
i
++
)
{
S
WWorkerAll
*
pUniqueWorker
=
malloc
(
sizeof
(
SWWorkerAll
));
S
MultiWorker
*
pUniqueWorker
=
malloc
(
sizeof
(
SMultiWorker
));
if
(
pUniqueWorker
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
S
WWorkerAll
Cfg
cfg
=
{.
maxNum
=
1
,
.
name
=
"snode-unique"
,
.
fp
=
smProcessUniqueQueue
,
.
param
=
pMgmt
};
S
MultiWorker
Cfg
cfg
=
{.
maxNum
=
1
,
.
name
=
"snode-unique"
,
.
fp
=
smProcessUniqueQueue
,
.
param
=
pMgmt
};
if
(
t
WWorkerAll
Init
(
pUniqueWorker
,
&
cfg
)
!=
0
)
{
if
(
t
MultiWorker
Init
(
pUniqueWorker
,
&
cfg
)
!=
0
)
{
dError
(
"failed to start snode-unique worker since %s"
,
terrstr
());
return
-
1
;
}
...
...
@@ -69,13 +69,13 @@ int32_t smStartWorker(SSnodeMgmt *pMgmt) {
}
}
S
QWorkerAll
Cfg
cfg
=
{.
minNum
=
SND_SHARED_THREAD_NUM
,
.
maxNum
=
SND_SHARED_THREAD_NUM
,
.
name
=
"snode-shared"
,
.
fp
=
(
FItem
)
smProcessSharedQueue
,
.
param
=
pMgmt
};
S
SingleWorker
Cfg
cfg
=
{.
minNum
=
SND_SHARED_THREAD_NUM
,
.
maxNum
=
SND_SHARED_THREAD_NUM
,
.
name
=
"snode-shared"
,
.
fp
=
(
FItem
)
smProcessSharedQueue
,
.
param
=
pMgmt
};
if
(
t
QWorkerAll
Init
(
&
pMgmt
->
sharedWorker
,
&
cfg
))
{
if
(
t
SingleWorker
Init
(
&
pMgmt
->
sharedWorker
,
&
cfg
))
{
dError
(
"failed to start snode shared-worker since %s"
,
terrstr
());
return
-
1
;
}
...
...
@@ -85,11 +85,11 @@ int32_t smStartWorker(SSnodeMgmt *pMgmt) {
void
smStopWorker
(
SSnodeMgmt
*
pMgmt
)
{
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pMgmt
->
uniqueWorkers
);
i
++
)
{
S
WWorkerAll
*
pWorker
=
taosArrayGetP
(
pMgmt
->
uniqueWorkers
,
i
);
t
WWorkerAll
Cleanup
(
pWorker
);
S
MultiWorker
*
pWorker
=
taosArrayGetP
(
pMgmt
->
uniqueWorkers
,
i
);
t
MultiWorker
Cleanup
(
pWorker
);
}
taosArrayDestroy
(
pMgmt
->
uniqueWorkers
);
t
QWorkerAll
Cleanup
(
&
pMgmt
->
sharedWorker
);
t
SingleWorker
Cleanup
(
&
pMgmt
->
sharedWorker
);
}
static
FORCE_INLINE
int32_t
smGetSWIdFromMsg
(
SRpcMsg
*
pMsg
)
{
...
...
@@ -105,7 +105,7 @@ static FORCE_INLINE int32_t smGetSWTypeFromMsg(SRpcMsg *pMsg) {
}
int32_t
smProcessMgmtMsg
(
SSnodeMgmt
*
pMgmt
,
SNodeMsg
*
pMsg
)
{
S
WWorkerAll
*
pWorker
=
taosArrayGetP
(
pMgmt
->
uniqueWorkers
,
0
);
S
MultiWorker
*
pWorker
=
taosArrayGetP
(
pMgmt
->
uniqueWorkers
,
0
);
if
(
pWorker
==
NULL
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
return
-
1
;
...
...
@@ -116,8 +116,8 @@ int32_t smProcessMgmtMsg(SSnodeMgmt *pMgmt, SNodeMsg *pMsg) {
}
int32_t
smProcessUniqueMsg
(
SSnodeMgmt
*
pMgmt
,
SNodeMsg
*
pMsg
)
{
int32_t
index
=
smGetSWIdFromMsg
(
&
pMsg
->
rpcMsg
);
S
WWorkerAll
*
pWorker
=
taosArrayGetP
(
pMgmt
->
uniqueWorkers
,
index
);
int32_t
index
=
smGetSWIdFromMsg
(
&
pMsg
->
rpcMsg
);
S
MultiWorker
*
pWorker
=
taosArrayGetP
(
pMgmt
->
uniqueWorkers
,
index
);
if
(
pWorker
==
NULL
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
return
-
1
;
...
...
@@ -128,7 +128,7 @@ int32_t smProcessUniqueMsg(SSnodeMgmt *pMgmt, SNodeMsg *pMsg) {
}
int32_t
smProcessSharedMsg
(
SSnodeMgmt
*
pMgmt
,
SNodeMsg
*
pMsg
)
{
S
QWorkerAll
*
pWorker
=
&
pMgmt
->
sharedWorker
;
S
SingleWorker
*
pWorker
=
&
pMgmt
->
sharedWorker
;
dTrace
(
"msg:%p, put into worker:%s"
,
pMsg
,
pWorker
->
name
);
return
taosWriteQitem
(
pWorker
->
queue
,
pMsg
);
...
...
source/dnode/mgmt/vnode/inc/vmInt.h
浏览文件 @
2af212f4
...
...
@@ -36,7 +36,7 @@ typedef struct SVnodesMgmt {
const
char
*
path
;
SDnode
*
pDnode
;
SMgmtWrapper
*
pWrapper
;
S
QWorkerAll
mgmtWorker
;
S
SingleWorker
mgmtWorker
;
}
SVnodesMgmt
;
typedef
struct
{
...
...
source/dnode/mgmt/vnode/src/vmWorker.c
浏览文件 @
2af212f4
...
...
@@ -200,24 +200,16 @@ static int32_t vmPutNodeMsgToQueue(SVnodesMgmt *pMgmt, SNodeMsg *pMsg, EQueueTyp
return
code
;
}
int32_t
vmProcessSyncMsg
(
SVnodesMgmt
*
pMgmt
,
SNodeMsg
*
pMsg
)
{
return
vmPutNodeMsgToQueue
(
pMgmt
,
pMsg
,
SYNC_QUEUE
);
}
int32_t
vmProcessSyncMsg
(
SVnodesMgmt
*
pMgmt
,
SNodeMsg
*
pMsg
)
{
return
vmPutNodeMsgToQueue
(
pMgmt
,
pMsg
,
SYNC_QUEUE
);
}
int32_t
vmProcessWriteMsg
(
SVnodesMgmt
*
pMgmt
,
SNodeMsg
*
pMsg
)
{
return
vmPutNodeMsgToQueue
(
pMgmt
,
pMsg
,
WRITE_QUEUE
);
}
int32_t
vmProcessWriteMsg
(
SVnodesMgmt
*
pMgmt
,
SNodeMsg
*
pMsg
)
{
return
vmPutNodeMsgToQueue
(
pMgmt
,
pMsg
,
WRITE_QUEUE
);
}
int32_t
vmProcessQueryMsg
(
SVnodesMgmt
*
pMgmt
,
SNodeMsg
*
pMsg
)
{
return
vmPutNodeMsgToQueue
(
pMgmt
,
pMsg
,
QUERY_QUEUE
);
}
int32_t
vmProcessQueryMsg
(
SVnodesMgmt
*
pMgmt
,
SNodeMsg
*
pMsg
)
{
return
vmPutNodeMsgToQueue
(
pMgmt
,
pMsg
,
QUERY_QUEUE
);
}
int32_t
vmProcessFetchMsg
(
SVnodesMgmt
*
pMgmt
,
SNodeMsg
*
pMsg
)
{
return
vmPutNodeMsgToQueue
(
pMgmt
,
pMsg
,
FETCH_QUEUE
);
}
int32_t
vmProcessFetchMsg
(
SVnodesMgmt
*
pMgmt
,
SNodeMsg
*
pMsg
)
{
return
vmPutNodeMsgToQueue
(
pMgmt
,
pMsg
,
FETCH_QUEUE
);
}
int32_t
vmProcessMgmtMsg
(
SVnodesMgmt
*
pMgmt
,
SNodeMsg
*
pMsg
)
{
S
QWorkerAll
*
pWorker
=
&
pMgmt
->
mgmtWorker
;
S
SingleWorker
*
pWorker
=
&
pMgmt
->
mgmtWorker
;
dTrace
(
"msg:%p, will be written to vnode-mgmt queue, worker:%s"
,
pMsg
,
pWorker
->
name
);
return
taosWriteQitem
(
pWorker
->
queue
,
pMsg
);
}
...
...
@@ -357,9 +349,9 @@ int32_t vmStartWorker(SVnodesMgmt *pMgmt) {
pWPool
->
max
=
maxSyncThreads
;
if
(
tWWorkerInit
(
pWPool
)
!=
0
)
return
-
1
;
S
QWorkerAll
Cfg
cfg
=
{
S
SingleWorker
Cfg
cfg
=
{
.
minNum
=
1
,
.
maxNum
=
1
,
.
name
=
"vnode-mgmt"
,
.
fp
=
(
FItem
)
vmProcessMgmtQueue
,
.
param
=
pMgmt
};
if
(
t
QWorkerAll
Init
(
&
pMgmt
->
mgmtWorker
,
&
cfg
)
!=
0
)
{
if
(
t
SingleWorker
Init
(
&
pMgmt
->
mgmtWorker
,
&
cfg
)
!=
0
)
{
dError
(
"failed to start vnode-mgmt worker since %s"
,
terrstr
());
return
-
1
;
}
...
...
@@ -369,7 +361,7 @@ int32_t vmStartWorker(SVnodesMgmt *pMgmt) {
}
void
vmStopWorker
(
SVnodesMgmt
*
pMgmt
)
{
t
QWorkerAll
Cleanup
(
&
pMgmt
->
mgmtWorker
);
t
SingleWorker
Cleanup
(
&
pMgmt
->
mgmtWorker
);
tQWorkerCleanup
(
&
pMgmt
->
fetchPool
);
tQWorkerCleanup
(
&
pMgmt
->
queryPool
);
tWWorkerCleanup
(
&
pMgmt
->
writePool
);
...
...
source/util/src/tworker.c
浏览文件 @
2af212f4
...
...
@@ -284,7 +284,7 @@ void tWWorkerFreeQueue(SWWorkerPool *pool, STaosQueue *queue) {
uDebug
(
"worker:%s, queue:%p is freed"
,
pool
->
name
,
queue
);
}
int32_t
t
QWorkerAllInit
(
SQWorkerAll
*
pWorker
,
const
SQWorkerAll
Cfg
*
pCfg
)
{
int32_t
t
SingleWorkerInit
(
SSingleWorker
*
pWorker
,
const
SSingleWorker
Cfg
*
pCfg
)
{
SQWorkerPool
*
pPool
=
&
pWorker
->
pool
;
pPool
->
name
=
pCfg
->
name
;
pPool
->
min
=
pCfg
->
minNum
;
...
...
@@ -302,7 +302,7 @@ int32_t tQWorkerAllInit(SQWorkerAll *pWorker, const SQWorkerAllCfg *pCfg) {
return
0
;
}
void
t
QWorkerAllCleanup
(
SQWorkerAll
*
pWorker
)
{
void
t
SingleWorkerCleanup
(
SSingleWorker
*
pWorker
)
{
if
(
pWorker
->
queue
==
NULL
)
return
;
while
(
!
taosQueueEmpty
(
pWorker
->
queue
))
{
...
...
@@ -313,7 +313,7 @@ void tQWorkerAllCleanup(SQWorkerAll *pWorker) {
tQWorkerFreeQueue
(
&
pWorker
->
pool
,
pWorker
->
queue
);
}
int32_t
t
WWorkerAllInit
(
SWWorkerAll
*
pWorker
,
const
SWWorkerAll
Cfg
*
pCfg
)
{
int32_t
t
MultiWorkerInit
(
SMultiWorker
*
pWorker
,
const
SMultiWorker
Cfg
*
pCfg
)
{
SWWorkerPool
*
pPool
=
&
pWorker
->
pool
;
pPool
->
name
=
pCfg
->
name
;
pPool
->
max
=
pCfg
->
maxNum
;
...
...
@@ -330,7 +330,7 @@ int32_t tWWorkerAllInit(SWWorkerAll *pWorker, const SWWorkerAllCfg *pCfg) {
return
0
;
}
void
t
WWorkerAllCleanup
(
SWWorkerAll
*
pWorker
)
{
void
t
MultiWorkerCleanup
(
SMultiWorker
*
pWorker
)
{
if
(
pWorker
->
queue
==
NULL
)
return
;
while
(
!
taosQueueEmpty
(
pWorker
->
queue
))
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录