Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5ae72c15
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看板
提交
5ae72c15
编写于
5月 21, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: rpc msg handler
上级
d5fabd53
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
56 addition
and
66 deletion
+56
-66
source/dnode/mgmt/mgmt_qnode/src/qmWorker.c
source/dnode/mgmt/mgmt_qnode/src/qmWorker.c
+21
-50
source/dnode/qnode/src/qnode.c
source/dnode/qnode/src/qnode.c
+35
-16
未找到文件。
source/dnode/mgmt/mgmt_qnode/src/qmWorker.c
浏览文件 @
5ae72c15
...
...
@@ -19,70 +19,43 @@
static
inline
void
qmSendRsp
(
SRpcMsg
*
pMsg
,
int32_t
code
)
{
SRpcMsg
rsp
=
{
.
code
=
code
,
.
info
=
pMsg
->
info
,
.
pCont
=
pMsg
->
info
.
rsp
,
.
contLen
=
pMsg
->
info
.
rspLen
,
.
info
=
pMsg
->
info
,
};
tmsgSendRsp
(
&
rsp
);
}
static
void
qmProcess
Monitor
Queue
(
SQueueInfo
*
pInfo
,
SRpcMsg
*
pMsg
)
{
static
void
qmProcessQueue
(
SQueueInfo
*
pInfo
,
SRpcMsg
*
pMsg
)
{
SQnodeMgmt
*
pMgmt
=
pInfo
->
ahandle
;
int32_t
code
=
-
1
;
dTrace
(
"msg:%p, get from qnode queue"
,
pMsg
);
dTrace
(
"msg:%p, get from qnode-monitor queue"
,
pMsg
);
SRpcMsg
*
pRpc
=
pMsg
;
int32_t
code
=
-
1
;
if
(
pMsg
->
msgType
==
TDMT_MON_QM_INFO
)
{
code
=
qmProcessGetMonitorInfoReq
(
pMgmt
,
pMsg
);
}
else
{
terrno
=
TSDB_CODE_MSG_NOT_PROCESSED
;
switch
(
pMsg
->
msgType
)
{
case
TDMT_MON_QM_INFO
:
code
=
qmProcessGetMonitorInfoReq
(
pMgmt
,
pMsg
);
break
;
case
TDMT_VND_QUERY
:
case
TDMT_VND_QUERY_CONTINUE
:
code
=
qndProcessQueryMsg
(
pMgmt
->
pQnode
,
pMsg
);
break
;
default:
code
=
qndProcessFetchMsg
(
pMgmt
->
pQnode
,
pMsg
);
break
;
}
if
(
pRpc
->
msgType
&
1U
)
{
if
(
IsReq
(
pMsg
)
&&
code
!=
TSDB_CODE_ACTION_IN_PROGRESS
)
{
if
(
code
!=
0
&&
terrno
!=
0
)
code
=
terrno
;
qmSendRsp
(
pMsg
,
code
);
}
dTrace
(
"msg:%p, is freed, code:0x%x"
,
pMsg
,
code
);
rpcFreeCont
(
pRpc
->
pCont
);
taosFreeQitem
(
pMsg
);
}
static
void
qmProcessQueryQueue
(
SQueueInfo
*
pInfo
,
SRpcMsg
*
pMsg
)
{
SQnodeMgmt
*
pMgmt
=
pInfo
->
ahandle
;
dTrace
(
"msg:%p, get from qnode-query queue"
,
pMsg
);
SRpcMsg
*
pRpc
=
pMsg
;
int32_t
code
=
qndProcessQueryMsg
(
pMgmt
->
pQnode
,
pRpc
);
if
(
pRpc
->
msgType
&
1U
&&
code
!=
0
)
{
qmSendRsp
(
pMsg
,
code
);
}
dTrace
(
"msg:%p, is freed, code:0x%x"
,
pMsg
,
code
);
rpcFreeCont
(
pMsg
->
pCont
);
taosFreeQitem
(
pMsg
);
}
static
void
qmProcessFetchQueue
(
SQueueInfo
*
pInfo
,
SRpcMsg
*
pMsg
)
{
SQnodeMgmt
*
pMgmt
=
pInfo
->
ahandle
;
dTrace
(
"msg:%p, get from qnode-fetch queue"
,
pMsg
);
SRpcMsg
*
pRpc
=
pMsg
;
int32_t
code
=
qndProcessFetchMsg
(
pMgmt
->
pQnode
,
pRpc
);
if
(
pRpc
->
msgType
&
1U
&&
code
!=
0
)
{
qmSendRsp
(
pMsg
,
code
);
}
dTrace
(
"msg:%p, is freed, code:0x%x"
,
pMsg
,
code
);
rpcFreeCont
(
pMsg
->
pCont
);
taosFreeQitem
(
pMsg
);
}
static
int32_t
qmPutNodeMsgToWorker
(
SSingleWorker
*
pWorker
,
SRpcMsg
*
pMsg
)
{
dTrace
(
"msg:%p, put into worker %s
"
,
pMsg
,
pWorker
->
name
);
dTrace
(
"msg:%p, put into worker %s
, type:%s"
,
pMsg
,
pWorker
->
name
,
TMSG_INFO
(
pMsg
->
msgType
)
);
taosWriteQitem
(
pWorker
->
queue
,
pMsg
);
return
0
;
}
...
...
@@ -101,9 +74,7 @@ int32_t qmPutNodeMsgToMonitorQueue(SQnodeMgmt *pMgmt, SRpcMsg *pMsg) {
static
int32_t
qmPutRpcMsgToWorker
(
SQnodeMgmt
*
pMgmt
,
SSingleWorker
*
pWorker
,
SRpcMsg
*
pRpc
)
{
SRpcMsg
*
pMsg
=
taosAllocateQitem
(
sizeof
(
SRpcMsg
),
RPC_QITEM
);
if
(
pMsg
==
NULL
)
{
return
-
1
;
}
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
));
...
...
@@ -141,7 +112,7 @@ int32_t qmStartWorker(SQnodeMgmt *pMgmt) {
.
min
=
tsNumOfVnodeQueryThreads
,
.
max
=
tsNumOfVnodeQueryThreads
,
.
name
=
"qnode-query"
,
.
fp
=
(
FItem
)
qmProcessQue
ryQue
ue
,
.
fp
=
(
FItem
)
qmProcessQueue
,
.
param
=
pMgmt
,
};
...
...
@@ -154,7 +125,7 @@ int32_t qmStartWorker(SQnodeMgmt *pMgmt) {
.
min
=
tsNumOfQnodeFetchThreads
,
.
max
=
tsNumOfQnodeFetchThreads
,
.
name
=
"qnode-fetch"
,
.
fp
=
(
FItem
)
qmProcess
Fetch
Queue
,
.
fp
=
(
FItem
)
qmProcessQueue
,
.
param
=
pMgmt
,
};
...
...
@@ -167,7 +138,7 @@ int32_t qmStartWorker(SQnodeMgmt *pMgmt) {
.
min
=
1
,
.
max
=
1
,
.
name
=
"qnode-monitor"
,
.
fp
=
(
FItem
)
qmProcess
Monitor
Queue
,
.
fp
=
(
FItem
)
qmProcessQueue
,
.
param
=
pMgmt
,
};
if
(
tSingleWorkerInit
(
&
pMgmt
->
monitorWorker
,
&
mCfg
)
!=
0
)
{
...
...
source/dnode/qnode/src/qnode.c
浏览文件 @
5ae72c15
...
...
@@ -43,44 +43,63 @@ void qndClose(SQnode *pQnode) {
int32_t
qndGetLoad
(
SQnode
*
pQnode
,
SQnodeLoad
*
pLoad
)
{
return
0
;
}
int32_t
qndProcessQueryMsg
(
SQnode
*
pQnode
,
SRpcMsg
*
pMsg
)
{
qTrace
(
"message in qnode query queue is processing"
)
;
int32_t
code
=
-
1
;
SReadHandle
handle
=
{.
pMsgCb
=
&
pQnode
->
msgCb
};
qTrace
(
"message in qnode query queue is processing"
);
switch
(
pMsg
->
msgType
)
{
case
TDMT_VND_QUERY
:
{
return
qWorkerProcessQueryMsg
(
&
handle
,
pQnode
->
pQuery
,
pMsg
);
}
case
TDMT_VND_QUERY
:
code
=
qWorkerProcessQueryMsg
(
&
handle
,
pQnode
->
pQuery
,
pMsg
);
break
;
case
TDMT_VND_QUERY_CONTINUE
:
return
qWorkerProcessCQueryMsg
(
&
handle
,
pQnode
->
pQuery
,
pMsg
);
code
=
qWorkerProcessCQueryMsg
(
&
handle
,
pQnode
->
pQuery
,
pMsg
);
break
;
default:
qError
(
"unknown msg type:%d in query queue"
,
pMsg
->
msgType
);
return
TSDB_CODE_VND_APP_ERROR
;
terrno
=
TSDB_CODE_VND_APP_ERROR
;
}
if
(
code
==
0
)
return
TSDB_CODE_ACTION_IN_PROGRESS
;
return
code
;
}
int32_t
qndProcessFetchMsg
(
SQnode
*
pQnode
,
SRpcMsg
*
pMsg
)
{
int32_t
code
=
-
1
;
qTrace
(
"message in fetch queue is processing"
);
switch
(
pMsg
->
msgType
)
{
case
TDMT_VND_FETCH
:
return
qWorkerProcessFetchMsg
(
pQnode
,
pQnode
->
pQuery
,
pMsg
);
code
=
qWorkerProcessFetchMsg
(
pQnode
,
pQnode
->
pQuery
,
pMsg
);
break
;
case
TDMT_VND_FETCH_RSP
:
return
qWorkerProcessFetchRsp
(
pQnode
,
pQnode
->
pQuery
,
pMsg
);
code
=
qWorkerProcessFetchRsp
(
pQnode
,
pQnode
->
pQuery
,
pMsg
);
break
;
case
TDMT_VND_RES_READY
:
return
qWorkerProcessReadyMsg
(
pQnode
,
pQnode
->
pQuery
,
pMsg
);
code
=
qWorkerProcessReadyMsg
(
pQnode
,
pQnode
->
pQuery
,
pMsg
);
break
;
case
TDMT_VND_TASKS_STATUS
:
return
qWorkerProcessStatusMsg
(
pQnode
,
pQnode
->
pQuery
,
pMsg
);
code
=
qWorkerProcessStatusMsg
(
pQnode
,
pQnode
->
pQuery
,
pMsg
);
break
;
case
TDMT_VND_CANCEL_TASK
:
return
qWorkerProcessCancelMsg
(
pQnode
,
pQnode
->
pQuery
,
pMsg
);
code
=
qWorkerProcessCancelMsg
(
pQnode
,
pQnode
->
pQuery
,
pMsg
);
break
;
case
TDMT_VND_DROP_TASK
:
return
qWorkerProcessDropMsg
(
pQnode
,
pQnode
->
pQuery
,
pMsg
);
code
=
qWorkerProcessDropMsg
(
pQnode
,
pQnode
->
pQuery
,
pMsg
);
break
;
case
TDMT_VND_TABLE_META
:
// return vnodeGetTableMeta(pQnode, pMsg);
// code = vnodeGetTableMeta(pQnode, pMsg);
// break;
case
TDMT_VND_CONSUME
:
// return tqProcessConsumeReq(pQnode->pTq, pMsg);
// code = tqProcessConsumeReq(pQnode->pTq, pMsg);
// break;
case
TDMT_VND_QUERY_HEARTBEAT
:
return
qWorkerProcessHbMsg
(
pQnode
,
pQnode
->
pQuery
,
pMsg
);
code
=
qWorkerProcessHbMsg
(
pQnode
,
pQnode
->
pQuery
,
pMsg
);
break
;
default:
qError
(
"unknown msg type:%d in fetch queue"
,
pMsg
->
msgType
);
return
TSDB_CODE_VND_APP_ERROR
;
terrno
=
TSDB_CODE_VND_APP_ERROR
;
}
if
(
code
==
0
)
return
TSDB_CODE_ACTION_IN_PROGRESS
;
return
code
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录