Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a9b32dc3
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看板
提交
a9b32dc3
编写于
6月 02, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: adjust vnode queue
上级
a682999c
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
93 addition
and
159 deletion
+93
-159
include/common/tmsgcb.h
include/common/tmsgcb.h
+2
-2
source/common/src/tmsgcb.c
source/common/src/tmsgcb.c
+8
-28
source/dnode/mgmt/mgmt_mnode/inc/mmInt.h
source/dnode/mgmt/mgmt_mnode/inc/mmInt.h
+1
-4
source/dnode/mgmt/mgmt_mnode/src/mmInt.c
source/dnode/mgmt/mgmt_mnode/src/mmInt.c
+1
-4
source/dnode/mgmt/mgmt_mnode/src/mmWorker.c
source/dnode/mgmt/mgmt_mnode/src/mmWorker.c
+27
-29
source/dnode/mgmt/mgmt_qnode/inc/qmInt.h
source/dnode/mgmt/mgmt_qnode/inc/qmInt.h
+1
-2
source/dnode/mgmt/mgmt_qnode/src/qmInt.c
source/dnode/mgmt/mgmt_qnode/src/qmInt.c
+1
-2
source/dnode/mgmt/mgmt_qnode/src/qmWorker.c
source/dnode/mgmt/mgmt_qnode/src/qmWorker.c
+14
-12
source/dnode/mgmt/mgmt_vnode/inc/vmInt.h
source/dnode/mgmt/mgmt_vnode/inc/vmInt.h
+18
-23
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
+2
-7
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
+2
-29
source/libs/qworker/test/qworkerTests.cpp
source/libs/qworker/test/qworkerTests.cpp
+16
-17
未找到文件。
include/common/tmsgcb.h
浏览文件 @
a9b32dc3
...
...
@@ -38,7 +38,7 @@ typedef enum {
QUEUE_MAX
,
}
EQueueType
;
typedef
int32_t
(
*
PutToQueueFp
)(
void
*
pMgmt
,
SRpcMsg
*
pMsg
);
typedef
int32_t
(
*
PutToQueueFp
)(
void
*
pMgmt
,
EQueueType
qtype
,
SRpcMsg
*
pMsg
);
typedef
int32_t
(
*
GetQueueSizeFp
)(
void
*
pMgmt
,
int32_t
vgId
,
EQueueType
qtype
);
typedef
int32_t
(
*
SendReqFp
)(
const
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
);
typedef
void
(
*
SendRspFp
)(
SRpcMsg
*
pMsg
);
...
...
@@ -50,7 +50,7 @@ typedef void (*ReportStartup)(const char* name, const char* desc);
typedef
struct
{
void
*
mgmt
;
void
*
clientRpc
;
PutToQueueFp
queueFps
[
QUEUE_MAX
]
;
PutToQueueFp
putToQueueFp
;
GetQueueSizeFp
qsizeFp
;
SendReqFp
sendReqFp
;
SendRspFp
sendRspFp
;
...
...
source/common/src/tmsgcb.c
浏览文件 @
a9b32dc3
...
...
@@ -22,41 +22,21 @@ static SMsgCb defaultMsgCb;
void
tmsgSetDefault
(
const
SMsgCb
*
msgcb
)
{
defaultMsgCb
=
*
msgcb
;
}
int32_t
tmsgPutToQueue
(
const
SMsgCb
*
msgcb
,
EQueueType
qtype
,
SRpcMsg
*
pMsg
)
{
PutToQueueFp
fp
=
msgcb
->
queueFps
[
qtype
];
return
(
*
fp
)(
msgcb
->
mgmt
,
pMsg
);
return
(
*
msgcb
->
putToQueueFp
)(
msgcb
->
mgmt
,
qtype
,
pMsg
);
}
int32_t
tmsgGetQueueSize
(
const
SMsgCb
*
msgcb
,
int32_t
vgId
,
EQueueType
qtype
)
{
GetQueueSizeFp
fp
=
msgcb
->
qsizeFp
;
return
(
*
fp
)(
msgcb
->
mgmt
,
vgId
,
qtype
);
return
(
*
msgcb
->
qsizeFp
)(
msgcb
->
mgmt
,
vgId
,
qtype
);
}
int32_t
tmsgSendReq
(
const
SEpSet
*
epSet
,
SRpcMsg
*
pMsg
)
{
SendReqFp
fp
=
defaultMsgCb
.
sendReqFp
;
return
(
*
fp
)(
epSet
,
pMsg
);
}
int32_t
tmsgSendReq
(
const
SEpSet
*
epSet
,
SRpcMsg
*
pMsg
)
{
return
(
*
defaultMsgCb
.
sendReqFp
)(
epSet
,
pMsg
);
}
void
tmsgSendRsp
(
SRpcMsg
*
pMsg
)
{
SendRspFp
fp
=
defaultMsgCb
.
sendRspFp
;
return
(
*
fp
)(
pMsg
);
}
void
tmsgSendRsp
(
SRpcMsg
*
pMsg
)
{
return
(
*
defaultMsgCb
.
sendRspFp
)(
pMsg
);
}
void
tmsgSendRedirectRsp
(
SRpcMsg
*
pMsg
,
const
SEpSet
*
pNewEpSet
)
{
SendRedirectRspFp
fp
=
defaultMsgCb
.
sendRedirectRspFp
;
(
*
fp
)(
pMsg
,
pNewEpSet
);
}
void
tmsgSendRedirectRsp
(
SRpcMsg
*
pMsg
,
const
SEpSet
*
pNewEpSet
)
{
(
*
defaultMsgCb
.
sendRedirectRspFp
)(
pMsg
,
pNewEpSet
);
}
void
tmsgRegisterBrokenLinkArg
(
SRpcMsg
*
pMsg
)
{
RegisterBrokenLinkArgFp
fp
=
defaultMsgCb
.
registerBrokenLinkArgFp
;
(
*
fp
)(
pMsg
);
}
void
tmsgRegisterBrokenLinkArg
(
SRpcMsg
*
pMsg
)
{
(
*
defaultMsgCb
.
registerBrokenLinkArgFp
)(
pMsg
);
}
void
tmsgReleaseHandle
(
SRpcHandleInfo
*
pHandle
,
int8_t
type
)
{
ReleaseHandleFp
fp
=
defaultMsgCb
.
releaseHandleFp
;
(
*
fp
)(
pHandle
,
type
);
}
void
tmsgReleaseHandle
(
SRpcHandleInfo
*
pHandle
,
int8_t
type
)
{
(
*
defaultMsgCb
.
releaseHandleFp
)(
pHandle
,
type
);
}
void
tmsgReportStartup
(
const
char
*
name
,
const
char
*
desc
)
{
ReportStartup
fp
=
defaultMsgCb
.
reportStartupFp
;
(
*
fp
)(
name
,
desc
);
}
\ No newline at end of file
void
tmsgReportStartup
(
const
char
*
name
,
const
char
*
desc
)
{
(
*
defaultMsgCb
.
reportStartupFp
)(
name
,
desc
);
}
\ No newline at end of file
source/dnode/mgmt/mgmt_mnode/inc/mmInt.h
浏览文件 @
a9b32dc3
...
...
@@ -65,10 +65,7 @@ int32_t mmPutNodeMsgToSyncQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg);
int32_t
mmPutNodeMsgToReadQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPutNodeMsgToQueryQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPutNodeMsgToMonitorQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPutRpcMsgToQueryQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPutRpcMsgToReadQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPutRpcMsgToWriteQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPutRpcMsgToSyncQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPutRpcMsgToQueue
(
SMnodeMgmt
*
pMgmt
,
EQueueType
qtype
,
SRpcMsg
*
pRpc
);
#ifdef __cplusplus
}
...
...
source/dnode/mgmt/mgmt_mnode/src/mmInt.c
浏览文件 @
a9b32dc3
...
...
@@ -105,10 +105,7 @@ static int32_t mmOpen(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) {
pMgmt
->
path
=
pInput
->
path
;
pMgmt
->
name
=
pInput
->
name
;
pMgmt
->
msgCb
=
pInput
->
msgCb
;
pMgmt
->
msgCb
.
queueFps
[
QUERY_QUEUE
]
=
(
PutToQueueFp
)
mmPutRpcMsgToQueryQueue
;
pMgmt
->
msgCb
.
queueFps
[
READ_QUEUE
]
=
(
PutToQueueFp
)
mmPutRpcMsgToReadQueue
;
pMgmt
->
msgCb
.
queueFps
[
WRITE_QUEUE
]
=
(
PutToQueueFp
)
mmPutRpcMsgToWriteQueue
;
pMgmt
->
msgCb
.
queueFps
[
SYNC_QUEUE
]
=
(
PutToQueueFp
)
mmPutRpcMsgToSyncQueue
;
pMgmt
->
msgCb
.
putToQueueFp
=
(
PutToQueueFp
)
mmPutRpcMsgToQueue
;
pMgmt
->
msgCb
.
mgmt
=
pMgmt
;
taosThreadRwlockInit
(
&
pMgmt
->
lock
,
NULL
);
...
...
source/dnode/mgmt/mgmt_mnode/src/mmWorker.c
浏览文件 @
a9b32dc3
...
...
@@ -96,40 +96,38 @@ int32_t mmPutNodeMsgToMonitorQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
return
mmPutNodeMsgToWorker
(
&
pMgmt
->
monitorWorker
,
pMsg
);
}
static
inline
int32_t
mmPutRpcMsgToWorker
(
SSingleWorker
*
pWorker
,
SRpcMsg
*
pRpc
)
{
int32_t
mmPutRpcMsgToQueue
(
SMnodeMgmt
*
pMgmt
,
EQueueType
qtype
,
SRpcMsg
*
pRpc
)
{
SRpcMsg
*
pMsg
=
taosAllocateQitem
(
sizeof
(
SRpcMsg
),
RPC_QITEM
);
if
(
pMsg
==
NULL
)
return
-
1
;
dTrace
(
"msg:%p, create and put into worker:%s, type:%s"
,
pMsg
,
pWorker
->
name
,
TMSG_INFO
(
pRpc
->
msgType
));
memcpy
(
pMsg
,
pRpc
,
sizeof
(
SRpcMsg
));
taosWriteQitem
(
pWorker
->
queue
,
pMsg
);
return
0
;
}
int32_t
mmPutRpcMsgToQueryQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
return
mmPutRpcMsgToWorker
(
&
pMgmt
->
queryWorker
,
pMsg
);
}
int32_t
mmPutRpcMsgToWriteQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
return
mmPutRpcMsgToWorker
(
&
pMgmt
->
writeWorker
,
pMsg
);
}
int32_t
mmPutRpcMsgToReadQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
return
mmPutRpcMsgToWorker
(
&
pMgmt
->
readWorker
,
pMsg
);
}
int32_t
mmPutRpcMsgToSyncQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
int32_t
code
=
-
1
;
if
(
mmAcquire
(
pMgmt
)
==
0
)
{
code
=
mmPutRpcMsgToWorker
(
&
pMgmt
->
syncWorker
,
pMsg
);
mmRelease
(
pMgmt
);
}
if
(
code
!=
0
)
{
rpcFreeCont
(
pMsg
->
pCont
);
pMsg
->
pCont
=
NULL
;
switch
(
qtype
)
{
case
WRITE_QUEUE
:
dTrace
(
"msg:%p, is created and will put into vnode-write queue"
,
pMsg
);
taosWriteQitem
(
pMgmt
->
writeWorker
.
queue
,
pMsg
);
return
0
;
case
QUERY_QUEUE
:
dTrace
(
"msg:%p, is created and will put into vnode-query queue"
,
pMsg
);
taosWriteQitem
(
pMgmt
->
queryWorker
.
queue
,
pMsg
);
return
0
;
case
READ_QUEUE
:
dTrace
(
"msg:%p, is created and will put into vnode-read queue"
,
pMsg
);
taosWriteQitem
(
pMgmt
->
readWorker
.
queue
,
pMsg
);
return
0
;
case
SYNC_QUEUE
:
if
(
mmAcquire
(
pMgmt
)
==
0
)
{
dTrace
(
"msg:%p, is created and will put into vnode-sync queue"
,
pMsg
);
taosWriteQitem
(
pMgmt
->
syncWorker
.
queue
,
pMsg
);
mmRelease
(
pMgmt
);
return
0
;
}
else
{
return
-
1
;
}
default:
terrno
=
TSDB_CODE_INVALID_PARA
;
return
-
1
;
}
return
code
;
}
int32_t
mmStartWorker
(
SMnodeMgmt
*
pMgmt
)
{
...
...
source/dnode/mgmt/mgmt_qnode/inc/qmInt.h
浏览文件 @
a9b32dc3
...
...
@@ -42,8 +42,7 @@ int32_t qmProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg);
int32_t
qmProcessGetMonitorInfoReq
(
SQnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
// qmWorker.c
int32_t
qmPutRpcMsgToQueryQueue
(
SQnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
qmPutRpcMsgToFetchQueue
(
SQnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
qmPutRpcMsgToQueue
(
SQnodeMgmt
*
pMgmt
,
EQueueType
qtype
,
SRpcMsg
*
pMsg
);
int32_t
qmGetQueueSize
(
SQnodeMgmt
*
pMgmt
,
int32_t
vgId
,
EQueueType
qtype
);
int32_t
qmStartWorker
(
SQnodeMgmt
*
pMgmt
);
...
...
source/dnode/mgmt/mgmt_qnode/src/qmInt.c
浏览文件 @
a9b32dc3
...
...
@@ -43,8 +43,7 @@ static int32_t qmOpen(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) {
pMgmt
->
path
=
pInput
->
path
;
pMgmt
->
name
=
pInput
->
name
;
pMgmt
->
msgCb
=
pInput
->
msgCb
;
pMgmt
->
msgCb
.
queueFps
[
QUERY_QUEUE
]
=
(
PutToQueueFp
)
qmPutRpcMsgToQueryQueue
;
pMgmt
->
msgCb
.
queueFps
[
FETCH_QUEUE
]
=
(
PutToQueueFp
)
qmPutRpcMsgToFetchQueue
;
pMgmt
->
msgCb
.
putToQueueFp
=
(
PutToQueueFp
)
qmPutRpcMsgToQueue
;
pMgmt
->
msgCb
.
qsizeFp
=
(
GetQueueSizeFp
)
qmGetQueueSize
;
pMgmt
->
msgCb
.
mgmt
=
pMgmt
;
...
...
source/dnode/mgmt/mgmt_qnode/src/qmWorker.c
浏览文件 @
a9b32dc3
...
...
@@ -68,22 +68,24 @@ int32_t qmPutNodeMsgToMonitorQueue(SQnodeMgmt *pMgmt, SRpcMsg *pMsg) {
return
qmPutNodeMsgToWorker
(
&
pMgmt
->
monitorWorker
,
pMsg
);
}
static
int32_t
qmPutRpcMsgToWorker
(
SQnodeMgmt
*
pMgmt
,
SSingleWorker
*
pWorker
,
SRpcMsg
*
pRpc
)
{
int32_t
qmPutRpcMsgToQueue
(
SQnodeMgmt
*
pMgmt
,
EQueueType
qtype
,
SRpcMsg
*
pRpc
)
{
SRpcMsg
*
pMsg
=
taosAllocateQitem
(
sizeof
(
SRpcMsg
),
RPC_QITEM
);
if
(
pMsg
==
NULL
)
return
-
1
;
dTrace
(
"msg:%p, create and put into worker:%s, type:%s"
,
pMsg
,
pWorker
->
name
,
TMSG_INFO
(
pRpc
->
msgType
));
memcpy
(
pMsg
,
pRpc
,
sizeof
(
SRpcMsg
));
taosWriteQitem
(
pWorker
->
queue
,
pMsg
);
return
0
;
}
int32_t
qmPutRpcMsgToQueryQueue
(
SQnodeMgmt
*
pMgmt
,
SRpcMsg
*
pRpc
)
{
return
qmPutRpcMsgToWorker
(
pMgmt
,
&
pMgmt
->
queryWorker
,
pRpc
);
}
int32_t
qmPutRpcMsgToFetchQueue
(
SQnodeMgmt
*
pMgmt
,
SRpcMsg
*
pRpc
)
{
return
qmPutRpcMsgToWorker
(
pMgmt
,
&
pMgmt
->
fetchWorker
,
pRpc
);
switch
(
qtype
)
{
case
QUERY_QUEUE
:
dTrace
(
"msg:%p, is created and will put into qnode-query queue"
,
pMsg
);
taosWriteQitem
(
pMgmt
->
queryWorker
.
queue
,
pMsg
);
return
0
;
case
READ_QUEUE
:
dTrace
(
"msg:%p, is created and will put into qnode-fetch queue"
,
pMsg
);
taosWriteQitem
(
pMgmt
->
fetchWorker
.
queue
,
pMsg
);
return
0
;
default:
terrno
=
TSDB_CODE_INVALID_PARA
;
return
-
1
;
}
}
int32_t
qmGetQueueSize
(
SQnodeMgmt
*
pMgmt
,
int32_t
vgId
,
EQueueType
qtype
)
{
...
...
source/dnode/mgmt/mgmt_vnode/inc/vmInt.h
浏览文件 @
a9b32dc3
...
...
@@ -44,26 +44,26 @@ typedef struct SVnodeMgmt {
}
SVnodeMgmt
;
typedef
struct
{
int32_t
vgId
;
int32_t
vgVersion
;
int8_t
dropped
;
char
path
[
PATH_MAX
+
20
];
int32_t
vgId
;
int32_t
vgVersion
;
int8_t
dropped
;
char
path
[
PATH_MAX
+
20
];
}
SWrapperCfg
;
typedef
struct
{
int32_t
vgId
;
int32_t
refCount
;
int32_t
vgVersion
;
int8_t
dropped
;
int8_t
accessState
;
char
*
path
;
SVnode
*
pImpl
;
STaosQueue
*
pWriteQ
;
STaosQueue
*
pSyncQ
;
STaosQueue
*
pApplyQ
;
STaosQueue
*
pQueryQ
;
STaosQueue
*
pFetchQ
;
STaosQueue
*
pMergeQ
;
int32_t
vgId
;
int32_t
refCount
;
int32_t
vgVersion
;
int8_t
dropped
;
int8_t
accessState
;
char
*
path
;
SVnode
*
pImpl
;
STaosQueue
*
pWriteQ
;
STaosQueue
*
pSyncQ
;
STaosQueue
*
pApplyQ
;
STaosQueue
*
pQueryQ
;
STaosQueue
*
pFetchQ
;
STaosQueue
*
pMergeQ
;
}
SVnodeObj
;
typedef
struct
{
...
...
@@ -100,13 +100,8 @@ void vmStopWorker(SVnodeMgmt *pMgmt);
int32_t
vmAllocQueue
(
SVnodeMgmt
*
pMgmt
,
SVnodeObj
*
pVnode
);
void
vmFreeQueue
(
SVnodeMgmt
*
pMgmt
,
SVnodeObj
*
pVnode
);
int32_t
vmPutRpcMsgToWriteQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmPutRpcMsgToSyncQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmPutRpcMsgToApplyQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmPutRpcMsgToQueryQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmPutRpcMsgToFetchQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmPutRpcMsgToMergeQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmGetQueueSize
(
SVnodeMgmt
*
pMgmt
,
int32_t
vgId
,
EQueueType
qtype
);
int32_t
vmPutRpcMsgToQueue
(
SVnodeMgmt
*
pMgmt
,
EQueueType
qtype
,
SRpcMsg
*
pRpc
);
int32_t
vmPutMsgToWriteQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmPutMsgToSyncQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
...
...
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
浏览文件 @
a9b32dc3
...
...
@@ -156,7 +156,7 @@ static int32_t vmOpenVnodes(SVnodeMgmt *pMgmt) {
pMgmt
->
state
.
totalVnodes
=
numOfVnodes
;
int32_t
threadNum
=
tsNumOfCores
;
int32_t
threadNum
=
1
;
int32_t
vnodesPerThread
=
numOfVnodes
/
threadNum
+
1
;
SVnodeThread
*
threads
=
taosMemoryCalloc
(
threadNum
,
sizeof
(
SVnodeThread
));
...
...
@@ -249,12 +249,7 @@ static int32_t vmInit(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) {
pMgmt
->
path
=
pInput
->
path
;
pMgmt
->
name
=
pInput
->
name
;
pMgmt
->
msgCb
=
pInput
->
msgCb
;
pMgmt
->
msgCb
.
queueFps
[
WRITE_QUEUE
]
=
(
PutToQueueFp
)
vmPutRpcMsgToWriteQueue
;
pMgmt
->
msgCb
.
queueFps
[
SYNC_QUEUE
]
=
(
PutToQueueFp
)
vmPutRpcMsgToSyncQueue
;
pMgmt
->
msgCb
.
queueFps
[
APPLY_QUEUE
]
=
(
PutToQueueFp
)
vmPutRpcMsgToApplyQueue
;
pMgmt
->
msgCb
.
queueFps
[
QUERY_QUEUE
]
=
(
PutToQueueFp
)
vmPutRpcMsgToQueryQueue
;
pMgmt
->
msgCb
.
queueFps
[
FETCH_QUEUE
]
=
(
PutToQueueFp
)
vmPutRpcMsgToFetchQueue
;
pMgmt
->
msgCb
.
queueFps
[
MERGE_QUEUE
]
=
(
PutToQueueFp
)
vmPutRpcMsgToMergeQueue
;
pMgmt
->
msgCb
.
putToQueueFp
=
(
PutToQueueFp
)
vmPutRpcMsgToQueue
;
pMgmt
->
msgCb
.
qsizeFp
=
(
GetQueueSizeFp
)
vmGetQueueSize
;
pMgmt
->
msgCb
.
mgmt
=
pMgmt
;
taosThreadRwlockInit
(
&
pMgmt
->
lock
,
NULL
);
...
...
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
浏览文件 @
a9b32dc3
...
...
@@ -304,14 +304,9 @@ int32_t vmPutMsgToMonitorQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
return
0
;
}
static
int32_t
vmPutRpcMsgToQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pRpc
,
EQueueType
qtype
)
{
int32_t
vmPutRpcMsgToQueue
(
SVnodeMgmt
*
pMgmt
,
EQueueType
qtype
,
SRpcMsg
*
pRpc
)
{
SRpcMsg
*
pMsg
=
taosAllocateQitem
(
sizeof
(
SRpcMsg
),
RPC_QITEM
);
if
(
pMsg
==
NULL
)
{
rpcFreeCont
(
pRpc
->
pCont
);
pRpc
->
pCont
=
NULL
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
if
(
pMsg
==
NULL
)
return
-
1
;
SMsgHead
*
pHead
=
pRpc
->
pCont
;
pHead
->
contLen
=
htonl
(
pHead
->
contLen
);
...
...
@@ -322,28 +317,6 @@ static int32_t vmPutRpcMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pRpc, EQueueType q
return
vmPutMsgToQueue
(
pMgmt
,
pMsg
,
qtype
);
}
int32_t
vmPutRpcMsgToWriteQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pRpc
)
{
return
vmPutRpcMsgToQueue
(
pMgmt
,
pRpc
,
WRITE_QUEUE
);
}
int32_t
vmPutRpcMsgToSyncQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pRpc
)
{
return
vmPutRpcMsgToQueue
(
pMgmt
,
pRpc
,
SYNC_QUEUE
);
}
int32_t
vmPutRpcMsgToApplyQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pRpc
)
{
return
vmPutRpcMsgToQueue
(
pMgmt
,
pRpc
,
APPLY_QUEUE
);
}
int32_t
vmPutRpcMsgToQueryQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pRpc
)
{
return
vmPutRpcMsgToQueue
(
pMgmt
,
pRpc
,
QUERY_QUEUE
);
}
int32_t
vmPutRpcMsgToFetchQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pRpc
)
{
return
vmPutRpcMsgToQueue
(
pMgmt
,
pRpc
,
FETCH_QUEUE
);
}
int32_t
vmPutRpcMsgToMergeQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pRpc
)
{
return
vmPutRpcMsgToQueue
(
pMgmt
,
pRpc
,
MERGE_QUEUE
);
}
int32_t
vmGetQueueSize
(
SVnodeMgmt
*
pMgmt
,
int32_t
vgId
,
EQueueType
qtype
)
{
int32_t
size
=
-
1
;
SVnodeObj
*
pVnode
=
vmAcquireVnode
(
pMgmt
,
vgId
);
...
...
source/libs/qworker/test/qworkerTests.cpp
浏览文件 @
a9b32dc3
...
...
@@ -172,8 +172,7 @@ int32_t qwtPutReqToFetchQueue(void *node, struct SRpcMsg *pMsg) {
return
0
;
}
int32_t
qwtPutReqToQueue
(
void
*
node
,
struct
SRpcMsg
*
pMsg
)
{
int32_t
qwtPutReqToQueue
(
void
*
node
,
EQueueType
qtype
,
struct
SRpcMsg
*
pMsg
)
{
taosWLockLatch
(
&
qwtTestQueryQueueLock
);
struct
SRpcMsg
*
newMsg
=
(
struct
SRpcMsg
*
)
taosMemoryCalloc
(
1
,
sizeof
(
struct
SRpcMsg
));
memcpy
(
newMsg
,
pMsg
,
sizeof
(
struct
SRpcMsg
));
...
...
@@ -181,7 +180,7 @@ int32_t qwtPutReqToQueue(void *node, struct SRpcMsg *pMsg) {
if
(
qwtTestQueryQueueWIdx
>=
qwtTestQueryQueueSize
)
{
qwtTestQueryQueueWIdx
=
0
;
}
qwtTestQueryQueueNum
++
;
if
(
qwtTestQueryQueueWIdx
==
qwtTestQueryQueueRIdx
)
{
...
...
@@ -702,9 +701,9 @@ void *qwtclientThread(void *param) {
while
(
!
qwtTestStop
)
{
qwtTestCaseFinished
=
false
;
qwtBuildQueryReqMsg
(
&
queryRpc
);
qwtPutReqToQueue
((
void
*
)
0x1
,
&
queryRpc
);
qwtPutReqToQueue
((
void
*
)
0x1
,
QUERY_QUEUE
,
&
queryRpc
);
while
(
!
qwtTestCaseFinished
)
{
taosUsleep
(
1
);
...
...
@@ -874,7 +873,7 @@ TEST(seqTest, normalCase) {
SMsgCb
msgCb
=
{
0
};
msgCb
.
mgmt
=
(
void
*
)
mockPointer
;
msgCb
.
queueFps
[
QUERY_QUEUE
]
=
(
PutToQueueFp
)
qwtPutReqToQueue
;
msgCb
.
putToQueueFp
=
(
PutToQueueFp
)
qwtPutReqToQueue
;
code
=
qWorkerInit
(
NODE_TYPE_VNODE
,
1
,
NULL
,
&
mgmt
,
&
msgCb
);
ASSERT_EQ
(
code
,
0
);
...
...
@@ -907,10 +906,10 @@ TEST(seqTest, cancelFirst) {
stubSetStringToPlan
();
stubSetRpcSendResponse
();
SMsgCb
msgCb
=
{
0
};
msgCb
.
mgmt
=
(
void
*
)
mockPointer
;
msgCb
.
queueFps
[
QUERY_QUEUE
]
=
(
PutToQueueFp
)
qwtPutReqToQueue
;
msgCb
.
putToQueueFp
=
(
PutToQueueFp
)
qwtPutReqToQueue
;
code
=
qWorkerInit
(
NODE_TYPE_VNODE
,
1
,
NULL
,
&
mgmt
,
&
msgCb
);
ASSERT_EQ
(
code
,
0
);
...
...
@@ -944,10 +943,10 @@ TEST(seqTest, randCase) {
stubSetCreateExecTask
();
taosSeedRand
(
taosGetTimestampSec
());
SMsgCb
msgCb
=
{
0
};
msgCb
.
mgmt
=
(
void
*
)
mockPointer
;
msgCb
.
queueFps
[
QUERY_QUEUE
]
=
(
PutToQueueFp
)
qwtPutReqToQueue
;
msgCb
.
putToQueueFp
=
(
PutToQueueFp
)
qwtPutReqToQueue
;
code
=
qWorkerInit
(
NODE_TYPE_VNODE
,
1
,
NULL
,
&
mgmt
,
&
msgCb
);
ASSERT_EQ
(
code
,
0
);
...
...
@@ -1015,10 +1014,10 @@ TEST(seqTest, multithreadRand) {
stubSetGetDataBlock
();
taosSeedRand
(
taosGetTimestampSec
());
SMsgCb
msgCb
=
{
0
};
msgCb
.
mgmt
=
(
void
*
)
mockPointer
;
msgCb
.
queueFps
[
QUERY_QUEUE
]
=
(
PutToQueueFp
)
qwtPutReqToQueue
;
msgCb
.
putToQueueFp
=
(
PutToQueueFp
)
qwtPutReqToQueue
;
code
=
qWorkerInit
(
NODE_TYPE_VNODE
,
1
,
NULL
,
&
mgmt
,
&
msgCb
);
ASSERT_EQ
(
code
,
0
);
...
...
@@ -1081,7 +1080,7 @@ TEST(rcTest, shortExecshortDelay) {
SMsgCb
msgCb
=
{
0
};
msgCb
.
mgmt
=
(
void
*
)
mockPointer
;
msgCb
.
queueFps
[
QUERY_QUEUE
]
=
(
PutToQueueFp
)
qwtPutReqToQueue
;
msgCb
.
putToQueueFp
=
(
PutToQueueFp
)
qwtPutReqToQueue
;
code
=
qWorkerInit
(
NODE_TYPE_VNODE
,
1
,
NULL
,
&
mgmt
,
&
msgCb
);
ASSERT_EQ
(
code
,
0
);
...
...
@@ -1165,7 +1164,7 @@ TEST(rcTest, longExecshortDelay) {
SMsgCb
msgCb
=
{
0
};
msgCb
.
mgmt
=
(
void
*
)
mockPointer
;
msgCb
.
queueFps
[
QUERY_QUEUE
]
=
(
PutToQueueFp
)
qwtPutReqToQueue
;
msgCb
.
putToQueueFp
=
(
PutToQueueFp
)
qwtPutReqToQueue
;
code
=
qWorkerInit
(
NODE_TYPE_VNODE
,
1
,
NULL
,
&
mgmt
,
&
msgCb
);
ASSERT_EQ
(
code
,
0
);
...
...
@@ -1251,7 +1250,7 @@ TEST(rcTest, shortExeclongDelay) {
SMsgCb
msgCb
=
{
0
};
msgCb
.
mgmt
=
(
void
*
)
mockPointer
;
msgCb
.
queueFps
[
QUERY_QUEUE
]
=
(
PutToQueueFp
)
qwtPutReqToQueue
;
msgCb
.
putToQueueFp
=
(
PutToQueueFp
)
qwtPutReqToQueue
;
code
=
qWorkerInit
(
NODE_TYPE_VNODE
,
1
,
NULL
,
&
mgmt
,
&
msgCb
);
ASSERT_EQ
(
code
,
0
);
...
...
@@ -1332,10 +1331,10 @@ TEST(rcTest, dropTest) {
stubSetGetDataBlock
();
taosSeedRand
(
taosGetTimestampSec
());
SMsgCb
msgCb
=
{
0
};
msgCb
.
mgmt
=
(
void
*
)
mockPointer
;
msgCb
.
queueFps
[
QUERY_QUEUE
]
=
(
PutToQueueFp
)
qwtPutReqToQueue
;
msgCb
.
putToQueueFp
=
(
PutToQueueFp
)
qwtPutReqToQueue
;
code
=
qWorkerInit
(
NODE_TYPE_VNODE
,
1
,
NULL
,
&
mgmt
,
&
msgCb
);
ASSERT_EQ
(
code
,
0
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录