Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
36fe62fb
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看板
提交
36fe62fb
编写于
5月 16, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: make more object global
上级
ddf55f25
变更
21
显示空白变更内容
内联
并排
Showing
21 changed file
with
116 addition
and
115 deletion
+116
-115
include/common/tmsgcb.h
include/common/tmsgcb.h
+18
-20
include/libs/transport/trpc.h
include/libs/transport/trpc.h
+1
-1
source/common/src/tmsgcb.c
source/common/src/tmsgcb.c
+13
-26
source/dnode/mgmt/mgmt_bnode/src/bmInt.c
source/dnode/mgmt/mgmt_bnode/src/bmInt.c
+1
-1
source/dnode/mgmt/mgmt_mnode/src/mmInt.c
source/dnode/mgmt/mgmt_mnode/src/mmInt.c
+1
-1
source/dnode/mgmt/mgmt_qnode/src/qmInt.c
source/dnode/mgmt/mgmt_qnode/src/qmInt.c
+1
-1
source/dnode/mgmt/mgmt_snode/src/smInt.c
source/dnode/mgmt/mgmt_snode/src/smInt.c
+1
-1
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
+1
-1
source/dnode/mgmt/node_mgmt/inc/dmMgmt.h
source/dnode/mgmt/node_mgmt/inc/dmMgmt.h
+6
-3
source/dnode/mgmt/node_mgmt/src/dmEnv.c
source/dnode/mgmt/node_mgmt/src/dmEnv.c
+12
-2
source/dnode/mgmt/node_mgmt/src/dmMgmt.c
source/dnode/mgmt/node_mgmt/src/dmMgmt.c
+3
-3
source/dnode/mgmt/node_mgmt/src/dmNodes.c
source/dnode/mgmt/node_mgmt/src/dmNodes.c
+3
-1
source/dnode/mgmt/node_mgmt/src/dmTransport.c
source/dnode/mgmt/node_mgmt/src/dmTransport.c
+33
-32
source/dnode/mnode/impl/src/mndDnode.c
source/dnode/mnode/impl/src/mndDnode.c
+1
-1
source/dnode/mnode/impl/src/mndTrans.c
source/dnode/mnode/impl/src/mndTrans.c
+1
-1
source/dnode/mnode/impl/test/trans/trans2.cpp
source/dnode/mnode/impl/test/trans/trans2.cpp
+1
-1
source/dnode/vnode/src/vnd/vnodeSync.c
source/dnode/vnode/src/vnd/vnodeSync.c
+1
-1
source/libs/qworker/src/qworker.c
source/libs/qworker/src/qworker.c
+5
-5
source/libs/qworker/src/qworkerMsg.c
source/libs/qworker/src/qworkerMsg.c
+2
-2
source/libs/qworker/test/qworkerTests.cpp
source/libs/qworker/test/qworkerTests.cpp
+8
-8
source/libs/stream/src/tstream.c
source/libs/stream/src/tstream.c
+3
-3
未找到文件。
include/common/tmsgcb.h
浏览文件 @
36fe62fb
...
...
@@ -25,6 +25,7 @@ extern "C" {
typedef
struct
SRpcMsg
SRpcMsg
;
typedef
struct
SEpSet
SEpSet
;
typedef
struct
SMgmtWrapper
SMgmtWrapper
;
typedef
struct
SRpcHandleInfo
SRpcHandleInfo
;
typedef
enum
{
QUERY_QUEUE
,
...
...
@@ -37,19 +38,17 @@ typedef enum {
QUEUE_MAX
,
}
EQueueType
;
typedef
int32_t
(
*
PutToQueueFp
)(
void
*
pMgmt
,
SRpcMsg
*
pReq
);
typedef
int32_t
(
*
GetQueueSizeFp
)(
void
*
pMgmt
,
int32_t
vgId
,
EQueueType
qtype
);
typedef
int32_t
(
*
SendReqFp
)(
SMgmtWrapper
*
pWrapper
,
const
SEpSet
*
epSet
,
SRpcMsg
*
pReq
);
typedef
int32_t
(
*
SendMnodeReqFp
)(
SMgmtWrapper
*
pWrapper
,
SRpcMsg
*
pReq
);
typedef
void
(
*
SendRspFp
)(
const
SRpcMsg
*
pRsp
);
typedef
void
(
*
SendRedirectRspFp
)(
const
SRpcMsg
*
pRsp
,
const
SEpSet
*
pNewEpSet
);
typedef
void
(
*
RegisterBrokenLinkArgFp
)(
SMgmtWrapper
*
pWrapper
,
SRpcMsg
*
pMsg
);
typedef
void
(
*
ReleaseHandleFp
)(
SMgmtWrapper
*
pWrapper
,
void
*
handle
,
int8_t
type
);
typedef
int32_t
(
*
PutToQueueFp
)(
void
*
pMgmt
,
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
)(
const
SRpcMsg
*
pMsg
);
typedef
void
(
*
SendRedirectRspFp
)(
const
SRpcMsg
*
pMsg
,
const
SEpSet
*
pNewEpSet
);
typedef
void
(
*
RegisterBrokenLinkArgFp
)(
SRpcMsg
*
pMsg
);
typedef
void
(
*
ReleaseHandleFp
)(
SRpcHandleInfo
*
pHandle
,
int8_t
type
);
typedef
void
(
*
ReportStartup
)(
const
char
*
name
,
const
char
*
desc
);
typedef
struct
{
SMgmtWrapper
*
pWrapper
;
void
*
pMgmt
;
void
*
mgmt
;
void
*
clientRpc
;
PutToQueueFp
queueFps
[
QUEUE_MAX
];
GetQueueSizeFp
qsizeFp
;
...
...
@@ -62,14 +61,13 @@ typedef struct {
}
SMsgCb
;
void
tmsgSetDefaultMsgCb
(
const
SMsgCb
*
pMsgCb
);
int32_t
tmsgPutToQueue
(
const
SMsgCb
*
pMsgCb
,
EQueueType
qtype
,
SRpcMsg
*
p
Req
);
int32_t
tmsgPutToQueue
(
const
SMsgCb
*
pMsgCb
,
EQueueType
qtype
,
SRpcMsg
*
p
Msg
);
int32_t
tmsgGetQueueSize
(
const
SMsgCb
*
pMsgCb
,
int32_t
vgId
,
EQueueType
qtype
);
int32_t
tmsgSendReq
(
const
SMsgCb
*
pMsgCb
,
const
SEpSet
*
epSet
,
SRpcMsg
*
pReq
);
void
tmsgSendRsp
(
SRpcMsg
*
pRsp
);
void
tmsgSendMnodeRecv
(
SRpcMsg
*
pReq
,
SRpcMsg
*
pRsp
);
void
tmsgSendRedirectRsp
(
SRpcMsg
*
pRsp
,
const
SEpSet
*
pNewEpSet
);
void
tmsgRegisterBrokenLinkArg
(
const
SMsgCb
*
pMsgCb
,
SRpcMsg
*
pMsg
);
void
tmsgReleaseHandle
(
void
*
handle
,
int8_t
type
);
int32_t
tmsgSendReq
(
const
SEpSet
*
epSet
,
SRpcMsg
*
pMsg
);
void
tmsgSendRsp
(
const
SRpcMsg
*
pMsg
);
void
tmsgSendRedirectRsp
(
const
SRpcMsg
*
pMsg
,
const
SEpSet
*
pNewEpSet
);
void
tmsgRegisterBrokenLinkArg
(
SRpcMsg
*
pMsg
);
void
tmsgReleaseHandle
(
SRpcHandleInfo
*
pHandle
,
int8_t
type
);
void
tmsgReportStartup
(
const
char
*
name
,
const
char
*
desc
);
#ifdef __cplusplus
...
...
include/libs/transport/trpc.h
浏览文件 @
36fe62fb
...
...
@@ -36,7 +36,7 @@ typedef struct {
char
user
[
TSDB_USER_LEN
];
}
SRpcConnInfo
;
typedef
struct
{
typedef
struct
SRpcHandleInfo
{
// rpc info
void
*
handle
;
// rpc handle returned to app
int64_t
refId
;
// refid, used by server
...
...
source/common/src/tmsgcb.c
浏览文件 @
36fe62fb
...
...
@@ -22,51 +22,38 @@ static SMsgCb tsDefaultMsgCb;
void
tmsgSetDefaultMsgCb
(
const
SMsgCb
*
pMsgCb
)
{
tsDefaultMsgCb
=
*
pMsgCb
;
}
int32_t
tmsgPutToQueue
(
const
SMsgCb
*
pMsgCb
,
EQueueType
qtype
,
SRpcMsg
*
pReq
)
{
// cannot be empty, but not checked for faster detect
PutToQueueFp
fp
=
pMsgCb
->
queueFps
[
qtype
];
return
(
*
fp
)(
pMsgCb
->
pM
gmt
,
pReq
);
return
(
*
fp
)(
pMsgCb
->
m
gmt
,
pReq
);
}
int32_t
tmsgGetQueueSize
(
const
SMsgCb
*
pMsgCb
,
int32_t
vgId
,
EQueueType
qtype
)
{
// cannot be empty, but not checked for faster detect
GetQueueSizeFp
fp
=
pMsgCb
->
qsizeFp
;
return
(
*
fp
)(
pMsgCb
->
pM
gmt
,
vgId
,
qtype
);
return
(
*
fp
)(
pMsgCb
->
m
gmt
,
vgId
,
qtype
);
}
int32_t
tmsgSendReq
(
const
SMsgCb
*
pMsgCb
,
const
SEpSet
*
epSet
,
SRpcMsg
*
pReq
)
{
// cannot be empty, but not checked for faster detect
SendReqFp
fp
=
pMsgCb
->
sendReqFp
;
return
(
*
fp
)(
pMsgCb
->
pWrapper
,
epSet
,
pReq
);
int32_t
tmsgSendReq
(
const
SEpSet
*
epSet
,
SRpcMsg
*
pReq
)
{
SendReqFp
fp
=
tsDefaultMsgCb
.
sendReqFp
;
return
(
*
fp
)(
epSet
,
pReq
);
}
void
tmsgSendRsp
(
SRpcMsg
*
pMsg
)
{
// cannot be empty, but not checked for faster detect
void
tmsgSendRsp
(
const
SRpcMsg
*
pMsg
)
{
SendRspFp
fp
=
tsDefaultMsgCb
.
sendRspFp
;
return
(
*
fp
)(
pMsg
);
}
void
tmsgSendRedirectRsp
(
SRpcMsg
*
pRsp
,
const
SEpSet
*
pNewEpSet
)
{
// cannot be empty, but not checked for faster detect
void
tmsgSendRedirectRsp
(
const
SRpcMsg
*
pMsg
,
const
SEpSet
*
pNewEpSet
)
{
SendRedirectRspFp
fp
=
tsDefaultMsgCb
.
sendRedirectRspFp
;
(
*
fp
)(
p
Rsp
,
pNewEpSet
);
(
*
fp
)(
p
Msg
,
pNewEpSet
);
}
void
tmsgRegisterBrokenLinkArg
(
const
SMsgCb
*
pMsgCb
,
SRpcMsg
*
pMsg
)
{
RegisterBrokenLinkArgFp
fp
=
pMsgCb
->
registerBrokenLinkArgFp
;
if
(
fp
!=
NULL
)
{
(
*
fp
)(
pMsgCb
->
pWrapper
,
pMsg
);
}
else
{
terrno
=
TSDB_CODE_INVALID_PTR
;
}
void
tmsgRegisterBrokenLinkArg
(
SRpcMsg
*
pMsg
)
{
RegisterBrokenLinkArgFp
fp
=
tsDefaultMsgCb
.
registerBrokenLinkArgFp
;
(
*
fp
)(
pMsg
);
}
void
tmsgReleaseHandle
(
void
*
h
andle
,
int8_t
type
)
{
void
tmsgReleaseHandle
(
SRpcHandleInfo
*
pH
andle
,
int8_t
type
)
{
ReleaseHandleFp
fp
=
tsDefaultMsgCb
.
releaseHandleFp
;
if
(
fp
!=
NULL
)
{
(
*
fp
)(
tsDefaultMsgCb
.
pWrapper
,
handle
,
type
);
}
else
{
terrno
=
TSDB_CODE_INVALID_PTR
;
}
(
*
fp
)(
pHandle
,
type
);
}
void
tmsgReportStartup
(
const
char
*
name
,
const
char
*
desc
)
{
...
...
source/dnode/mgmt/mgmt_bnode/src/bmInt.c
浏览文件 @
36fe62fb
...
...
@@ -43,7 +43,7 @@ int32_t bmOpen(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) {
pMgmt
->
path
=
pInput
->
path
;
pMgmt
->
name
=
pInput
->
name
;
pMgmt
->
msgCb
=
pInput
->
msgCb
;
pMgmt
->
msgCb
.
pM
gmt
=
pMgmt
;
pMgmt
->
msgCb
.
m
gmt
=
pMgmt
;
SBnodeOpt
option
=
{
0
};
bmInitOption
(
pMgmt
,
&
option
);
...
...
source/dnode/mgmt/mgmt_mnode/src/mmInt.c
浏览文件 @
36fe62fb
...
...
@@ -136,7 +136,7 @@ static int32_t mmOpen(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) {
pMgmt
->
msgCb
.
queueFps
[
READ_QUEUE
]
=
(
PutToQueueFp
)
mmPutRpcMsgToReadQueue
;
pMgmt
->
msgCb
.
queueFps
[
WRITE_QUEUE
]
=
(
PutToQueueFp
)
mmPutRpcMsgToWriteQueue
;
pMgmt
->
msgCb
.
queueFps
[
SYNC_QUEUE
]
=
(
PutToQueueFp
)
mmPutRpcMsgToWriteQueue
;
pMgmt
->
msgCb
.
pM
gmt
=
pMgmt
;
pMgmt
->
msgCb
.
m
gmt
=
pMgmt
;
bool
deployed
=
false
;
if
(
mmReadFile
(
pMgmt
,
&
deployed
)
!=
0
)
{
...
...
source/dnode/mgmt/mgmt_qnode/src/qmInt.c
浏览文件 @
36fe62fb
...
...
@@ -46,7 +46,7 @@ static int32_t qmOpen(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) {
pMgmt
->
msgCb
.
queueFps
[
QUERY_QUEUE
]
=
(
PutToQueueFp
)
qmPutRpcMsgToQueryQueue
;
pMgmt
->
msgCb
.
queueFps
[
FETCH_QUEUE
]
=
(
PutToQueueFp
)
qmPutRpcMsgToFetchQueue
;
pMgmt
->
msgCb
.
qsizeFp
=
(
GetQueueSizeFp
)
qmGetQueueSize
;
pMgmt
->
msgCb
.
pM
gmt
=
pMgmt
;
pMgmt
->
msgCb
.
m
gmt
=
pMgmt
;
SQnodeOpt
option
=
{
0
};
qmInitOption
(
pMgmt
,
&
option
);
...
...
source/dnode/mgmt/mgmt_snode/src/smInt.c
浏览文件 @
36fe62fb
...
...
@@ -44,7 +44,7 @@ int32_t smOpen(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) {
pMgmt
->
path
=
pInput
->
path
;
pMgmt
->
name
=
pInput
->
name
;
pMgmt
->
msgCb
=
pInput
->
msgCb
;
pMgmt
->
msgCb
.
pM
gmt
=
pMgmt
;
pMgmt
->
msgCb
.
m
gmt
=
pMgmt
;
SSnodeOpt
option
=
{
0
};
smInitOption
(
pMgmt
,
&
option
);
...
...
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
浏览文件 @
36fe62fb
...
...
@@ -258,7 +258,7 @@ static int32_t vmInit(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) {
pMgmt
->
msgCb
.
queueFps
[
FETCH_QUEUE
]
=
(
PutToQueueFp
)
vmPutRpcMsgToFetchQueue
;
pMgmt
->
msgCb
.
queueFps
[
MERGE_QUEUE
]
=
(
PutToQueueFp
)
vmPutRpcMsgToMergeQueue
;
pMgmt
->
msgCb
.
qsizeFp
=
(
GetQueueSizeFp
)
vmGetQueueSize
;
pMgmt
->
msgCb
.
pM
gmt
=
pMgmt
;
pMgmt
->
msgCb
.
m
gmt
=
pMgmt
;
taosInitRWLatch
(
&
pMgmt
->
latch
);
SDiskCfg
dCfg
=
{
0
};
...
...
source/dnode/mgmt/node_mgmt/inc/dmMgmt.h
浏览文件 @
36fe62fb
...
...
@@ -65,7 +65,6 @@ typedef struct {
}
SProc
;
typedef
struct
SMgmtWrapper
{
struct
SDnode
*
pDnode
;
SMgmtFunc
func
;
void
*
pMgmt
;
const
char
*
name
;
...
...
@@ -124,8 +123,12 @@ typedef struct SDnode {
SMgmtWrapper
wrappers
[
NODE_END
];
}
SDnode
;
// dmEmv.c
// dmEnv.c
SDnode
*
dmInstance
();
bool
dmNotRunning
();
void
dmReportStartup
(
const
char
*
pName
,
const
char
*
pDesc
);
void
*
dmGetClientRpc
();
void
dmGetMnodeEpSetGlobal
(
SEpSet
*
pEpSet
);
// dmMgmt.c
int32_t
dmInitDnode
(
SDnode
*
pDnode
,
EDndNodeType
rtype
);
...
...
source/dnode/mgmt/node_mgmt/src/dmEnv.c
浏览文件 @
36fe62fb
...
...
@@ -16,7 +16,7 @@
#define _DEFAULT_SOURCE
#include "dmMgmt.h"
static
SDnode
global
=
{
0
};
SDnode
global
=
{
0
};
static
int32_t
dmCheckRepeatInit
(
SDnode
*
pDnode
)
{
if
(
atomic_val_compare_exchange_8
(
&
pDnode
->
once
,
DND_ENV_INIT
,
DND_ENV_READY
)
!=
DND_ENV_INIT
)
{
...
...
@@ -166,10 +166,12 @@ static bool dmIsNodeRequired(EDndNodeType ntype) {
}
SMgmtInputOpt
dmBuildMgmtInputOpt
(
SMgmtWrapper
*
pWrapper
)
{
SDnode
*
pDnode
=
dmInstance
();
SMgmtInputOpt
opt
=
{
.
path
=
pWrapper
->
path
,
.
name
=
pWrapper
->
name
,
.
pData
=
&
p
Wrapper
->
p
Dnode
->
data
,
.
pData
=
&
pDnode
->
data
,
.
processCreateNodeFp
=
dmProcessCreateNodeReq
,
.
processDropNodeFp
=
dmProcessDropNodeReq
,
.
isNodeRequiredFp
=
dmIsNodeRequired
,
...
...
@@ -185,3 +187,11 @@ void dmReportStartup(const char *pName, const char *pDesc) {
tstrncpy
(
pStartup
->
desc
,
pDesc
,
TSDB_STEP_DESC_LEN
);
dDebug
(
"step:%s, %s"
,
pStartup
->
name
,
pStartup
->
desc
);
}
SDnode
*
dmInstance
()
{
return
&
global
;
}
bool
dmNotRunning
()
{
return
global
.
status
!=
DND_STAT_RUNNING
;
}
void
*
dmGetClientRpc
()
{
return
global
.
trans
.
clientRpc
;
}
void
dmGetMnodeEpSetGlobal
(
SEpSet
*
pEpSet
)
{
dmGetMnodeEpSet
(
&
global
.
data
,
pEpSet
);
}
\ No newline at end of file
source/dnode/mgmt/node_mgmt/src/dmMgmt.c
浏览文件 @
36fe62fb
...
...
@@ -16,7 +16,7 @@
#define _DEFAULT_SOURCE
#include "dmMgmt.h"
static
bool
dmRequireNode
(
SMgmtWrapper
*
pWrapper
)
{
static
bool
dmRequireNode
(
S
Dnode
*
pDnode
,
S
MgmtWrapper
*
pWrapper
)
{
SMgmtInputOpt
input
=
dmBuildMgmtInputOpt
(
pWrapper
);
bool
required
=
false
;
...
...
@@ -25,7 +25,7 @@ static bool dmRequireNode(SMgmtWrapper *pWrapper) {
dDebug
(
"node:%s, does not require startup"
,
pWrapper
->
name
);
}
if
(
pWrapper
->
ntype
==
DNODE
&&
p
Wrapper
->
pDnode
->
rtype
!=
DNODE
&&
pWrapper
->
pDnode
->
rtype
!=
NODE_END
)
{
if
(
pWrapper
->
ntype
==
DNODE
&&
p
Dnode
->
rtype
!=
DNODE
&&
pDnode
->
rtype
!=
NODE_END
)
{
required
=
false
;
dDebug
(
"node:%s, does not require startup in child process"
,
pWrapper
->
name
);
}
...
...
@@ -150,7 +150,7 @@ int32_t dmInitDnode(SDnode *pDnode, EDndNodeType rtype) {
goto
_OVER
;
}
pWrapper
->
required
=
dmRequireNode
(
pWrapper
);
pWrapper
->
required
=
dmRequireNode
(
p
Dnode
,
p
Wrapper
);
if
(
ntype
!=
DNODE
&&
dmReadShmFile
(
pWrapper
->
path
,
pWrapper
->
name
,
pDnode
->
rtype
,
&
pWrapper
->
proc
.
shm
)
!=
0
)
{
dError
(
"node:%s, failed to read shm file since %s"
,
pWrapper
->
name
,
terrstr
());
...
...
source/dnode/mgmt/node_mgmt/src/dmNodes.c
浏览文件 @
36fe62fb
...
...
@@ -64,6 +64,8 @@ static int32_t dmNewProc(SMgmtWrapper *pWrapper, EDndNodeType ntype) {
}
int32_t
dmOpenNode
(
SMgmtWrapper
*
pWrapper
)
{
SDnode
*
pDnode
=
dmInstance
();
if
(
taosMkDir
(
pWrapper
->
path
)
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
dError
(
"node:%s, failed to create dir:%s since %s"
,
pWrapper
->
name
,
pWrapper
->
path
,
terrstr
());
...
...
@@ -101,7 +103,7 @@ int32_t dmOpenNode(SMgmtWrapper *pWrapper) {
dError
(
"node:%s, failed to init proc since %s"
,
pWrapper
->
name
,
terrstr
());
return
-
1
;
}
if
(
p
Wrapper
->
p
Dnode
->
rtype
==
NODE_END
)
{
if
(
pDnode
->
rtype
==
NODE_END
)
{
dInfo
(
"node:%s, should be started manually in child process"
,
pWrapper
->
name
);
}
else
{
if
(
dmNewProc
(
pWrapper
,
pWrapper
->
ntype
)
!=
0
)
{
...
...
source/dnode/mgmt/node_mgmt/src/dmTransport.c
浏览文件 @
36fe62fb
...
...
@@ -194,9 +194,9 @@ int32_t dmInitMsgHandle(SDnode *pDnode) {
return
0
;
}
static
void
dmSendRpcRedirectRsp
(
SDnode
*
pDnode
,
const
SRpcMsg
*
pReq
)
{
static
void
dmSendRpcRedirectRsp
(
const
SRpcMsg
*
pReq
)
{
SEpSet
epSet
=
{
0
};
dmGetMnodeEpSet
(
&
pDnode
->
data
,
&
epSet
);
dmGetMnodeEpSet
Global
(
&
epSet
);
dDebug
(
"RPC %p, req is redirected, num:%d use:%d"
,
pReq
->
info
.
handle
,
epSet
.
numOfEps
,
epSet
.
inUse
);
for
(
int32_t
i
=
0
;
i
<
epSet
.
numOfEps
;
++
i
)
{
...
...
@@ -221,15 +221,8 @@ static void dmSendRpcRedirectRsp(SDnode *pDnode, const SRpcMsg *pReq) {
rpcSendResponse
(
&
rsp
);
}
static
inline
void
dmSendRpcRsp
(
SDnode
*
pDnode
,
const
SRpcMsg
*
pRsp
)
{
if
(
pRsp
->
code
==
TSDB_CODE_NODE_REDIRECT
)
{
dmSendRpcRedirectRsp
(
pDnode
,
pRsp
);
}
else
{
rpcSendResponse
(
pRsp
);
}
}
static
inline
void
dmSendRecv
(
SDnode
*
pDnode
,
SEpSet
*
pEpSet
,
SRpcMsg
*
pReq
,
SRpcMsg
*
pRsp
)
{
static
inline
void
dmSendRecv
(
SEpSet
*
pEpSet
,
SRpcMsg
*
pReq
,
SRpcMsg
*
pRsp
)
{
SDnode
*
pDnode
=
dmInstance
();
if
(
pDnode
->
status
!=
DND_STAT_RUNNING
)
{
pRsp
->
code
=
TSDB_CODE_NODE_OFFLINE
;
rpcFreeCont
(
pReq
->
pCont
);
...
...
@@ -239,18 +232,18 @@ static inline void dmSendRecv(SDnode *pDnode, SEpSet *pEpSet, SRpcMsg *pReq, SRp
}
}
static
inline
int32_t
dmSendReq
(
SMgmtWrapper
*
pWrapper
,
const
SEpSet
*
pEpSet
,
SRpcMsg
*
pReq
)
{
SDnode
*
pDnode
=
pWrapper
->
pDnode
;
if
(
pDnode
->
status
!=
DND_STAT_RUNNING
||
pDnode
->
trans
.
clientRpc
==
NULL
)
{
static
inline
int32_t
dmSendReq
(
const
SEpSet
*
pEpSet
,
SRpcMsg
*
pReq
)
{
SDnode
*
pDnode
=
dmInstance
()
;
if
(
pDnode
->
status
!=
DND_STAT_RUNNING
)
{
rpcFreeCont
(
pReq
->
pCont
);
pReq
->
pCont
=
NULL
;
terrno
=
TSDB_CODE_NODE_OFFLINE
;
dError
(
"failed to send rpc msg since %s, handle:%p"
,
terrstr
(),
pReq
->
info
.
handle
);
return
-
1
;
}
}
else
{
rpcSendRequest
(
pDnode
->
trans
.
clientRpc
,
pEpSet
,
pReq
,
NULL
);
return
0
;
}
}
static
inline
void
dmSendRsp
(
const
SRpcMsg
*
pMsg
)
{
...
...
@@ -258,7 +251,11 @@ static inline void dmSendRsp(const SRpcMsg *pMsg) {
if
(
InChildProc
(
pWrapper
->
proc
.
ptype
))
{
dmPutToProcPQueue
(
&
pWrapper
->
proc
,
pMsg
,
sizeof
(
SRpcMsg
),
pMsg
->
pCont
,
pMsg
->
contLen
,
DND_FUNC_RSP
);
}
else
{
dmSendRpcRsp
(
pWrapper
->
pDnode
,
pMsg
);
if
(
pMsg
->
code
==
TSDB_CODE_NODE_REDIRECT
)
{
dmSendRpcRedirectRsp
(
pMsg
);
}
else
{
rpcSendResponse
(
pMsg
);
}
}
}
...
...
@@ -280,7 +277,9 @@ static inline void dmSendRedirectRsp(const SRpcMsg *pRsp, const SEpSet *pNewEpSe
}
}
static
inline
void
dmRegisterBrokenLinkArg
(
SMgmtWrapper
*
pWrapper
,
SRpcMsg
*
pMsg
)
{
static
inline
void
dmRegisterBrokenLinkArg
(
SRpcMsg
*
pMsg
)
{
SMgmtWrapper
*
pWrapper
=
pMsg
->
info
.
wrapper
;
if
(
InChildProc
(
pWrapper
->
proc
.
ptype
))
{
dmPutToProcPQueue
(
&
pWrapper
->
proc
,
pMsg
,
sizeof
(
SRpcMsg
),
pMsg
->
pCont
,
pMsg
->
contLen
,
DND_FUNC_REGIST
);
}
else
{
...
...
@@ -288,12 +287,14 @@ static inline void dmRegisterBrokenLinkArg(SMgmtWrapper *pWrapper, SRpcMsg *pMsg
}
}
static
inline
void
dmReleaseHandle
(
SMgmtWrapper
*
pWrapper
,
void
*
handle
,
int8_t
type
)
{
static
inline
void
dmReleaseHandle
(
SRpcHandleInfo
*
pHandle
,
int8_t
type
)
{
SMgmtWrapper
*
pWrapper
=
pHandle
->
wrapper
;
if
(
InChildProc
(
pWrapper
->
proc
.
ptype
))
{
SRpcMsg
msg
=
{.
info
.
handle
=
h
andle
,
.
code
=
type
};
SRpcMsg
msg
=
{.
info
=
*
pH
andle
,
.
code
=
type
};
dmPutToProcPQueue
(
&
pWrapper
->
proc
,
&
msg
,
sizeof
(
SRpcMsg
),
NULL
,
0
,
DND_FUNC_RELEASE
);
}
else
{
rpcReleaseHandle
(
handle
,
type
);
rpcReleaseHandle
(
pHandle
->
handle
,
type
);
}
}
...
...
@@ -385,7 +386,7 @@ static inline int32_t dmRetrieveUserAuthInfo(SDnode *pDnode, char *user, char *s
SEpSet
epSet
=
{
0
};
dTrace
(
"user:%s, send user auth req to other mnodes, spi:%d encrypt:%d"
,
user
,
authReq
.
spi
,
authReq
.
encrypt
);
dmGetMnodeEpSet
(
&
pDnode
->
data
,
&
epSet
);
dmSendRecv
(
pDnode
,
&
epSet
,
&
rpcMsg
,
&
rpcRsp
);
dmSendRecv
(
&
epSet
,
&
rpcMsg
,
&
rpcRsp
);
if
(
rpcRsp
.
code
!=
0
)
{
terrno
=
rpcRsp
.
code
;
...
...
@@ -441,9 +442,9 @@ void dmCleanupServer(SDnode *pDnode) {
}
SMsgCb
dmGetMsgcb
(
SMgmtWrapper
*
pWrapper
)
{
SDnode
*
pDnode
=
dmInstance
();
SMsgCb
msgCb
=
{
.
pWrapper
=
pWrapper
,
.
clientRpc
=
pWrapper
->
pDnode
->
trans
.
clientRpc
,
.
clientRpc
=
dmInstance
()
->
trans
.
clientRpc
,
.
sendReqFp
=
dmSendReq
,
.
sendRspFp
=
dmSendRsp
,
.
sendRedirectRspFp
=
dmSendRedirectRsp
,
...
...
source/dnode/mnode/impl/src/mndDnode.c
浏览文件 @
36fe62fb
...
...
@@ -625,7 +625,7 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) {
SRpcMsg
rpcMsg
=
{.
msgType
=
TDMT_DND_CONFIG_DNODE
,
.
pCont
=
pBuf
,
.
contLen
=
bufLen
,
.
info
=
pReq
->
info
};
mInfo
(
"dnode:%d, app:%p config:%s req send to dnode"
,
cfgReq
.
dnodeId
,
rpcMsg
.
info
.
ahandle
,
cfgReq
.
config
);
tmsgSendReq
(
&
pMnode
->
msgCb
,
&
epSet
,
&
rpcMsg
);
tmsgSendReq
(
&
epSet
,
&
rpcMsg
);
return
0
;
}
...
...
source/dnode/mnode/impl/src/mndTrans.c
浏览文件 @
36fe62fb
...
...
@@ -985,7 +985,7 @@ static int32_t mndTransSendActionMsg(SMnode *pMnode, STrans *pTrans, SArray *pAr
}
memcpy
(
rpcMsg
.
pCont
,
pAction
->
pCont
,
pAction
->
contLen
);
if
(
tmsgSendReq
(
&
p
Mnode
->
msgCb
,
&
p
Action
->
epSet
,
&
rpcMsg
)
==
0
)
{
if
(
tmsgSendReq
(
&
pAction
->
epSet
,
&
rpcMsg
)
==
0
)
{
mDebug
(
"trans:%d, action:%d is sent"
,
pTrans
->
id
,
action
);
pAction
->
msgSent
=
1
;
pAction
->
msgReceived
=
0
;
...
...
source/dnode/mnode/impl/test/trans/trans2.cpp
浏览文件 @
36fe62fb
...
...
@@ -47,7 +47,7 @@ class MndTestTrans2 : public ::testing::Test {
static
void
InitMnode
()
{
static
SMsgCb
msgCb
=
{
0
};
msgCb
.
reportStartupFp
=
reportStartup
;
msgCb
.
pWrapper
=
(
SMgmtWrapper
*
)(
&
msgCb
);
// hack
msgCb
.
mgmt
=
(
SMgmtWrapper
*
)(
&
msgCb
);
// hack
tmsgSetDefaultMsgCb
(
&
msgCb
);
SMnodeOpt
opt
=
{
0
};
...
...
source/dnode/vnode/src/vnd/vnodeSync.c
浏览文件 @
36fe62fb
...
...
@@ -73,7 +73,7 @@ int32_t vnodeSendMsg(void *rpcHandle, const SEpSet *pEpSet, SRpcMsg *pMsg) {
SMsgCb
*
pMsgCb
=
rpcHandle
;
if
(
pMsgCb
->
queueFps
[
SYNC_QUEUE
]
!=
NULL
)
{
pMsg
->
info
.
noResp
=
1
;
tmsgSendReq
(
rpcHandle
,
pEpSet
,
pMsg
);
tmsgSendReq
(
pEpSet
,
pMsg
);
}
else
{
vError
(
"vnodeSendMsg queue is NULL, SYNC_QUEUE:%d"
,
SYNC_QUEUE
);
}
...
...
source/libs/qworker/src/qworker.c
浏览文件 @
36fe62fb
...
...
@@ -412,7 +412,7 @@ int32_t qwKillTaskHandle(QW_FPARAMS_DEF, SQWTaskCtx *ctx) {
}
void
qwFreeTask
(
QW_FPARAMS_DEF
,
SQWTaskCtx
*
ctx
)
{
tmsgReleaseHandle
(
ctx
->
ctrlConnInfo
.
handle
,
TAOS_CONN_SERVER
);
tmsgReleaseHandle
(
&
ctx
->
ctrlConnInfo
,
TAOS_CONN_SERVER
);
ctx
->
ctrlConnInfo
.
handle
=
NULL
;
ctx
->
ctrlConnInfo
.
refId
=
-
1
;
...
...
@@ -1278,7 +1278,7 @@ int32_t qwProcessHbLinkBroken(SQWorker *mgmt, SQWMsg *qwMsg, SSchedulerHbReq *re
QW_LOCK
(
QW_WRITE
,
&
sch
->
hbConnLock
);
if
(
qwMsg
->
connInfo
.
handle
==
sch
->
hbConnInfo
.
handle
)
{
tmsgReleaseHandle
(
sch
->
hbConnInfo
.
handle
,
TAOS_CONN_SERVER
);
tmsgReleaseHandle
(
&
sch
->
hbConnInfo
,
TAOS_CONN_SERVER
);
sch
->
hbConnInfo
.
handle
=
NULL
;
sch
->
hbConnInfo
.
ahandle
=
NULL
;
...
...
@@ -1310,7 +1310,7 @@ int32_t qwProcessHb(SQWorker *mgmt, SQWMsg *qwMsg, SSchedulerHbReq *req) {
QW_LOCK
(
QW_WRITE
,
&
sch
->
hbConnLock
);
if
(
sch
->
hbConnInfo
.
handle
)
{
tmsgReleaseHandle
(
sch
->
hbConnInfo
.
handle
,
TAOS_CONN_SERVER
);
tmsgReleaseHandle
(
&
sch
->
hbConnInfo
,
TAOS_CONN_SERVER
);
}
memcpy
(
&
sch
->
hbConnInfo
,
&
qwMsg
->
connInfo
,
sizeof
(
qwMsg
->
connInfo
));
...
...
@@ -1330,7 +1330,7 @@ _return:
qwBuildAndSendHbRsp
(
&
qwMsg
->
connInfo
,
&
rsp
,
code
);
if
(
code
)
{
tmsgReleaseHandle
(
qwMsg
->
connInfo
.
handle
,
TAOS_CONN_SERVER
);
tmsgReleaseHandle
(
&
qwMsg
->
connInfo
,
TAOS_CONN_SERVER
);
}
QW_DLOG
(
"hb rsp send, handle:%p, code:%x - %s"
,
qwMsg
->
connInfo
.
handle
,
code
,
tstrerror
(
code
));
...
...
@@ -1498,7 +1498,7 @@ void qwSetHbParam(int64_t refId, SQWHbParam **pParam) {
}
int32_t
qWorkerInit
(
int8_t
nodeType
,
int32_t
nodeId
,
SQWorkerCfg
*
cfg
,
void
**
qWorkerMgmt
,
const
SMsgCb
*
pMsgCb
)
{
if
(
NULL
==
qWorkerMgmt
||
pMsgCb
->
pWrapper
==
NULL
)
{
if
(
NULL
==
qWorkerMgmt
||
pMsgCb
->
mgmt
==
NULL
)
{
qError
(
"invalid param to init qworker"
);
QW_RET
(
TSDB_CODE_QRY_INVALID_INPUT
);
}
...
...
source/libs/qworker/src/qworkerMsg.c
浏览文件 @
36fe62fb
...
...
@@ -294,7 +294,7 @@ int32_t qwRegisterQueryBrokenLinkArg(QW_FPARAMS_DEF, SRpcHandleInfo *pConn) {
.
info
=
*
pConn
,
};
tmsgRegisterBrokenLinkArg
(
&
mgmt
->
msgCb
,
&
pMsg
);
tmsgRegisterBrokenLinkArg
(
&
pMsg
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -328,7 +328,7 @@ int32_t qwRegisterHbBrokenLinkArg(SQWorker *mgmt, uint64_t sId, SRpcHandleInfo *
.
info
=
*
pConn
,
};
tmsgRegisterBrokenLinkArg
(
&
mgmt
->
msgCb
,
&
pMsg
);
tmsgRegisterBrokenLinkArg
(
&
pMsg
);
return
TSDB_CODE_SUCCESS
;
}
...
...
source/libs/qworker/test/qworkerTests.cpp
浏览文件 @
36fe62fb
...
...
@@ -959,7 +959,7 @@ TEST(seqTest, normalCase) {
stubSetGetDataBlock
();
SMsgCb
msgCb
=
{
0
};
msgCb
.
pWrapper
=
(
struct
SMgmtWrapper
*
)
mockPointer
;
msgCb
.
mgmt
=
(
void
*
)
mockPointer
;
msgCb
.
queueFps
[
QUERY_QUEUE
]
=
(
PutToQueueFp
)
qwtPutReqToQueue
;
code
=
qWorkerInit
(
NODE_TYPE_VNODE
,
1
,
NULL
,
&
mgmt
,
&
msgCb
);
ASSERT_EQ
(
code
,
0
);
...
...
@@ -1001,7 +1001,7 @@ TEST(seqTest, cancelFirst) {
stubSetRpcSendResponse
();
SMsgCb
msgCb
=
{
0
};
msgCb
.
pWrapper
=
(
struct
SMgmtWrapper
*
)
mockPointer
;
msgCb
.
mgmt
=
(
void
*
)
mockPointer
;
msgCb
.
queueFps
[
QUERY_QUEUE
]
=
(
PutToQueueFp
)
qwtPutReqToQueue
;
code
=
qWorkerInit
(
NODE_TYPE_VNODE
,
1
,
NULL
,
&
mgmt
,
&
msgCb
);
ASSERT_EQ
(
code
,
0
);
...
...
@@ -1050,7 +1050,7 @@ TEST(seqTest, randCase) {
taosSeedRand
(
taosGetTimestampSec
());
SMsgCb
msgCb
=
{
0
};
msgCb
.
pWrapper
=
(
struct
SMgmtWrapper
*
)
mockPointer
;
msgCb
.
mgmt
=
(
void
*
)
mockPointer
;
msgCb
.
queueFps
[
QUERY_QUEUE
]
=
(
PutToQueueFp
)
qwtPutReqToQueue
;
code
=
qWorkerInit
(
NODE_TYPE_VNODE
,
1
,
NULL
,
&
mgmt
,
&
msgCb
);
ASSERT_EQ
(
code
,
0
);
...
...
@@ -1124,7 +1124,7 @@ TEST(seqTest, multithreadRand) {
taosSeedRand
(
taosGetTimestampSec
());
SMsgCb
msgCb
=
{
0
};
msgCb
.
pWrapper
=
(
struct
SMgmtWrapper
*
)
mockPointer
;
msgCb
.
mgmt
=
(
void
*
)
mockPointer
;
msgCb
.
queueFps
[
QUERY_QUEUE
]
=
(
PutToQueueFp
)
qwtPutReqToQueue
;
code
=
qWorkerInit
(
NODE_TYPE_VNODE
,
1
,
NULL
,
&
mgmt
,
&
msgCb
);
ASSERT_EQ
(
code
,
0
);
...
...
@@ -1188,7 +1188,7 @@ TEST(rcTest, shortExecshortDelay) {
qwtTestQuitThreadNum
=
0
;
SMsgCb
msgCb
=
{
0
};
msgCb
.
pWrapper
=
(
struct
SMgmtWrapper
*
)
mockPointer
;
msgCb
.
mgmt
=
(
void
*
)
mockPointer
;
msgCb
.
queueFps
[
QUERY_QUEUE
]
=
(
PutToQueueFp
)
qwtPutReqToQueue
;
code
=
qWorkerInit
(
NODE_TYPE_VNODE
,
1
,
NULL
,
&
mgmt
,
&
msgCb
);
ASSERT_EQ
(
code
,
0
);
...
...
@@ -1272,7 +1272,7 @@ TEST(rcTest, longExecshortDelay) {
qwtTestQuitThreadNum
=
0
;
SMsgCb
msgCb
=
{
0
};
msgCb
.
pWrapper
=
(
struct
SMgmtWrapper
*
)
mockPointer
;
msgCb
.
mgmt
=
(
void
*
)
mockPointer
;
msgCb
.
queueFps
[
QUERY_QUEUE
]
=
(
PutToQueueFp
)
qwtPutReqToQueue
;
code
=
qWorkerInit
(
NODE_TYPE_VNODE
,
1
,
NULL
,
&
mgmt
,
&
msgCb
);
ASSERT_EQ
(
code
,
0
);
...
...
@@ -1358,7 +1358,7 @@ TEST(rcTest, shortExeclongDelay) {
qwtTestQuitThreadNum
=
0
;
SMsgCb
msgCb
=
{
0
};
msgCb
.
pWrapper
=
(
struct
SMgmtWrapper
*
)
mockPointer
;
msgCb
.
mgmt
=
(
void
*
)
mockPointer
;
msgCb
.
queueFps
[
QUERY_QUEUE
]
=
(
PutToQueueFp
)
qwtPutReqToQueue
;
code
=
qWorkerInit
(
NODE_TYPE_VNODE
,
1
,
NULL
,
&
mgmt
,
&
msgCb
);
ASSERT_EQ
(
code
,
0
);
...
...
@@ -1442,7 +1442,7 @@ TEST(rcTest, dropTest) {
taosSeedRand
(
taosGetTimestampSec
());
SMsgCb
msgCb
=
{
0
};
msgCb
.
pWrapper
=
(
struct
SMgmtWrapper
*
)
mockPointer
;
msgCb
.
mgmt
=
(
void
*
)
mockPointer
;
msgCb
.
queueFps
[
QUERY_QUEUE
]
=
(
PutToQueueFp
)
qwtPutReqToQueue
;
code
=
qWorkerInit
(
NODE_TYPE_VNODE
,
1
,
NULL
,
&
mgmt
,
&
msgCb
);
ASSERT_EQ
(
code
,
0
);
...
...
source/libs/stream/src/tstream.c
浏览文件 @
36fe62fb
...
...
@@ -111,7 +111,7 @@ static int32_t streamShuffleDispatch(SStreamTask* pTask, SMsgCb* pMsgCb, SHashOb
ASSERT
(
0
);
return
-
1
;
}
tmsgSendReq
(
p
MsgCb
,
p
EpSet
,
&
dispatchMsg
);
tmsgSendReq
(
pEpSet
,
&
dispatchMsg
);
}
return
0
;
}
...
...
@@ -371,7 +371,7 @@ int32_t streamTaskProcessInputReq(SStreamTask* pTask, SMsgCb* pMsgCb, SStreamDat
return
-
1
;
}
tmsgSendReq
(
p
MsgCb
,
p
EpSet
,
&
dispatchMsg
);
tmsgSendReq
(
pEpSet
,
&
dispatchMsg
);
}
else
if
(
pTask
->
dispatchType
==
TASK_DISPATCH__SHUFFLE
)
{
SHashObj
*
pShuffleRes
=
taosHashInit
(
64
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
false
,
HASH_NO_LOCK
);
...
...
@@ -571,7 +571,7 @@ int32_t streamExecTask(SStreamTask* pTask, SMsgCb* pMsgCb, const void* input, in
return
-
1
;
}
tmsgSendReq
(
p
MsgCb
,
p
EpSet
,
&
dispatchMsg
);
tmsgSendReq
(
pEpSet
,
&
dispatchMsg
);
}
else
if
(
pTask
->
dispatchType
==
TASK_DISPATCH__SHUFFLE
)
{
SHashObj
*
pShuffleRes
=
taosHashInit
(
64
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
false
,
HASH_NO_LOCK
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录