Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
46d566d3
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看板
提交
46d566d3
编写于
5月 16, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: make more object global
上级
36fe62fb
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
34 addition
and
53 deletion
+34
-53
source/dnode/mgmt/node_mgmt/inc/dmMgmt.h
source/dnode/mgmt/node_mgmt/inc/dmMgmt.h
+2
-4
source/dnode/mgmt/node_mgmt/src/dmEnv.c
source/dnode/mgmt/node_mgmt/src/dmEnv.c
+14
-22
source/dnode/mgmt/node_mgmt/src/dmMgmt.c
source/dnode/mgmt/node_mgmt/src/dmMgmt.c
+1
-0
source/dnode/mgmt/node_mgmt/src/dmNodes.c
source/dnode/mgmt/node_mgmt/src/dmNodes.c
+1
-1
source/dnode/mgmt/node_mgmt/src/dmTransport.c
source/dnode/mgmt/node_mgmt/src/dmTransport.c
+16
-26
未找到文件。
source/dnode/mgmt/node_mgmt/inc/dmMgmt.h
浏览文件 @
46d566d3
...
...
@@ -66,6 +66,7 @@ typedef struct {
typedef
struct
SMgmtWrapper
{
SMgmtFunc
func
;
struct
SDnode
*
pDnode
;
void
*
pMgmt
;
const
char
*
name
;
char
*
path
;
...
...
@@ -125,10 +126,7 @@ typedef struct SDnode {
// 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
);
...
...
@@ -164,7 +162,7 @@ int32_t dmInitServer(SDnode *pDnode);
void
dmCleanupServer
(
SDnode
*
pDnode
);
int32_t
dmInitClient
(
SDnode
*
pDnode
);
void
dmCleanupClient
(
SDnode
*
pDnode
);
SMsgCb
dmGetMsgcb
(
S
MgmtWrapper
*
pWrapper
);
SMsgCb
dmGetMsgcb
(
S
Dnode
*
pDnode
);
int32_t
dmInitMsgHandle
(
SDnode
*
pDnode
);
int32_t
dmProcessNodeMsg
(
SMgmtWrapper
*
pWrapper
,
SRpcMsg
*
pMsg
);
...
...
source/dnode/mgmt/node_mgmt/src/dmEnv.c
浏览文件 @
46d566d3
...
...
@@ -16,7 +16,9 @@
#define _DEFAULT_SOURCE
#include "dmMgmt.h"
SDnode
global
=
{
0
};
static
SDnode
global
=
{
0
};
SDnode
*
dmInstance
()
{
return
&
global
;
}
static
int32_t
dmCheckRepeatInit
(
SDnode
*
pDnode
)
{
if
(
atomic_val_compare_exchange_8
(
&
pDnode
->
once
,
DND_ENV_INIT
,
DND_ENV_READY
)
!=
DND_ENV_INIT
)
{
...
...
@@ -49,10 +51,10 @@ static int32_t dmInitMonitor() {
int32_t
dmInit
(
int8_t
rtype
)
{
dInfo
(
"start to init env"
);
if
(
dmCheckRepeatInit
(
&
global
)
!=
0
)
return
-
1
;
if
(
dmCheckRepeatInit
(
dmInstance
()
)
!=
0
)
return
-
1
;
if
(
dmInitSystem
()
!=
0
)
return
-
1
;
if
(
dmInitMonitor
()
!=
0
)
return
-
1
;
if
(
dmInitDnode
(
&
global
,
rtype
)
!=
0
)
return
-
1
;
if
(
dmInitDnode
(
dmInstance
()
,
rtype
)
!=
0
)
return
-
1
;
dInfo
(
"env is initialized"
);
return
0
;
...
...
@@ -69,7 +71,7 @@ static int32_t dmCheckRepeatCleanup(SDnode *pDnode) {
void
dmCleanup
()
{
dDebug
(
"start to cleanup env"
);
if
(
dmCheckRepeatCleanup
!=
0
)
return
;
dmCleanupDnode
(
&
global
);
dmCleanupDnode
(
dmInstance
()
);
monCleanup
();
syncCleanUp
();
walCleanUp
();
...
...
@@ -83,17 +85,17 @@ void dmCleanup() {
}
void
dmStop
()
{
SDnode
*
pDnode
=
&
global
;
SDnode
*
pDnode
=
dmInstance
()
;
pDnode
->
stop
=
true
;
}
int32_t
dmRun
()
{
SDnode
*
pDnode
=
&
global
;
SDnode
*
pDnode
=
dmInstance
()
;
return
dmRunDnode
(
pDnode
);
}
static
int32_t
dmProcessCreateNodeReq
(
EDndNodeType
ntype
,
SRpcMsg
*
pMsg
)
{
SDnode
*
pDnode
=
&
global
;
SDnode
*
pDnode
=
dmInstance
()
;
SMgmtWrapper
*
pWrapper
=
dmAcquireWrapper
(
pDnode
,
ntype
);
if
(
pWrapper
!=
NULL
)
{
...
...
@@ -130,7 +132,7 @@ static int32_t dmProcessCreateNodeReq(EDndNodeType ntype, SRpcMsg *pMsg) {
}
static
int32_t
dmProcessDropNodeReq
(
EDndNodeType
ntype
,
SRpcMsg
*
pMsg
)
{
SDnode
*
pDnode
=
&
global
;
SDnode
*
pDnode
=
dmInstance
()
;
SMgmtWrapper
*
pWrapper
=
dmAcquireWrapper
(
pDnode
,
ntype
);
if
(
pWrapper
==
NULL
)
{
...
...
@@ -161,37 +163,27 @@ static int32_t dmProcessDropNodeReq(EDndNodeType ntype, SRpcMsg *pMsg) {
}
static
bool
dmIsNodeRequired
(
EDndNodeType
ntype
)
{
SDnode
*
pDnode
=
&
global
;
SDnode
*
pDnode
=
dmInstance
()
;
return
pDnode
->
wrappers
[
ntype
].
required
;
}
SMgmtInputOpt
dmBuildMgmtInputOpt
(
SMgmtWrapper
*
pWrapper
)
{
SDnode
*
pDnode
=
dmInstance
();
SMgmtInputOpt
opt
=
{
.
path
=
pWrapper
->
path
,
.
name
=
pWrapper
->
name
,
.
pData
=
&
pDnode
->
data
,
.
pData
=
&
p
Wrapper
->
p
Dnode
->
data
,
.
processCreateNodeFp
=
dmProcessCreateNodeReq
,
.
processDropNodeFp
=
dmProcessDropNodeReq
,
.
isNodeRequiredFp
=
dmIsNodeRequired
,
};
opt
.
msgCb
=
dmGetMsgcb
(
pWrapper
);
opt
.
msgCb
=
dmGetMsgcb
(
pWrapper
->
pDnode
);
return
opt
;
}
void
dmReportStartup
(
const
char
*
pName
,
const
char
*
pDesc
)
{
SStartupInfo
*
pStartup
=
&
global
.
startup
;
SStartupInfo
*
pStartup
=
&
(
dmInstance
()
->
startup
)
;
tstrncpy
(
pStartup
->
name
,
pName
,
TSDB_STEP_NAME_LEN
);
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
浏览文件 @
46d566d3
...
...
@@ -132,6 +132,7 @@ int32_t dmInitDnode(SDnode *pDnode, EDndNodeType rtype) {
for
(
EDndNodeType
ntype
=
DNODE
;
ntype
<
NODE_END
;
++
ntype
)
{
SMgmtWrapper
*
pWrapper
=
&
pDnode
->
wrappers
[
ntype
];
pWrapper
->
pDnode
=
pDnode
;
pWrapper
->
name
=
dmNodeName
(
ntype
);
pWrapper
->
ntype
=
ntype
;
pWrapper
->
proc
.
wrapper
=
pWrapper
;
...
...
source/dnode/mgmt/node_mgmt/src/dmNodes.c
浏览文件 @
46d566d3
...
...
@@ -64,7 +64,7 @@ static int32_t dmNewProc(SMgmtWrapper *pWrapper, EDndNodeType ntype) {
}
int32_t
dmOpenNode
(
SMgmtWrapper
*
pWrapper
)
{
SDnode
*
pDnode
=
dmInstance
()
;
SDnode
*
pDnode
=
pWrapper
->
pDnode
;
if
(
taosMkDir
(
pWrapper
->
path
)
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
...
...
source/dnode/mgmt/node_mgmt/src/dmTransport.c
浏览文件 @
46d566d3
...
...
@@ -195,8 +195,9 @@ int32_t dmInitMsgHandle(SDnode *pDnode) {
}
static
void
dmSendRpcRedirectRsp
(
const
SRpcMsg
*
pReq
)
{
SEpSet
epSet
=
{
0
};
dmGetMnodeEpSetGlobal
(
&
epSet
);
SDnode
*
pDnode
=
dmInstance
();
SEpSet
epSet
=
{
0
};
dmGetMnodeEpSet
(
&
pDnode
->
data
,
&
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
)
{
...
...
@@ -279,7 +280,6 @@ static inline void dmSendRedirectRsp(const SRpcMsg *pRsp, const SEpSet *pNewEpSe
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
{
...
...
@@ -289,22 +289,15 @@ static inline void dmRegisterBrokenLinkArg(SRpcMsg *pMsg) {
static
inline
void
dmReleaseHandle
(
SRpcHandleInfo
*
pHandle
,
int8_t
type
)
{
SMgmtWrapper
*
pWrapper
=
pHandle
->
wrapper
;
if
(
InChildProc
(
pWrapper
->
proc
.
ptype
))
{
SRpcMsg
msg
=
{.
info
=
*
pHandle
,
.
code
=
typ
e
};
SRpcMsg
msg
=
{.
code
=
type
,
.
info
=
*
pHandl
e
};
dmPutToProcPQueue
(
&
pWrapper
->
proc
,
&
msg
,
sizeof
(
SRpcMsg
),
NULL
,
0
,
DND_FUNC_RELEASE
);
}
else
{
rpcReleaseHandle
(
pHandle
->
handle
,
type
);
}
}
static
bool
rpcRfp
(
int32_t
code
)
{
if
(
code
==
TSDB_CODE_RPC_REDIRECT
)
{
return
true
;
}
else
{
return
false
;
}
}
static
bool
rpcRfp
(
int32_t
code
)
{
return
code
==
TSDB_CODE_RPC_REDIRECT
;
}
int32_t
dmInitClient
(
SDnode
*
pDnode
)
{
SDnodeTrans
*
pTrans
=
&
pDnode
->
trans
;
...
...
@@ -345,8 +338,7 @@ void dmCleanupClient(SDnode *pDnode) {
}
}
static
inline
int32_t
dmGetHideUserAuth
(
SDnode
*
pDnode
,
char
*
user
,
char
*
spi
,
char
*
encrypt
,
char
*
secret
,
char
*
ckey
)
{
static
inline
int32_t
dmGetHideUserAuth
(
char
*
user
,
char
*
spi
,
char
*
encrypt
,
char
*
secret
,
char
*
ckey
)
{
int32_t
code
=
0
;
char
pass
[
TSDB_PASSWORD_LEN
+
1
]
=
{
0
};
...
...
@@ -370,7 +362,7 @@ static inline int32_t dmGetHideUserAuth(SDnode *pDnode, char *user, char *spi, c
static
inline
int32_t
dmRetrieveUserAuthInfo
(
SDnode
*
pDnode
,
char
*
user
,
char
*
spi
,
char
*
encrypt
,
char
*
secret
,
char
*
ckey
)
{
if
(
dmGetHideUserAuth
(
pDnode
,
user
,
spi
,
encrypt
,
secret
,
ckey
)
==
0
)
{
if
(
dmGetHideUserAuth
(
user
,
spi
,
encrypt
,
secret
,
ckey
)
==
0
)
{
dTrace
(
"user:%s, get auth from mnode, spi:%d encrypt:%d"
,
user
,
*
spi
,
*
encrypt
);
return
0
;
}
...
...
@@ -410,7 +402,6 @@ int32_t dmInitServer(SDnode *pDnode) {
SDnodeTrans
*
pTrans
=
&
pDnode
->
trans
;
SRpcInit
rpcInit
=
{
0
};
strncpy
(
rpcInit
.
localFqdn
,
tsLocalFqdn
,
strlen
(
tsLocalFqdn
));
rpcInit
.
localPort
=
tsServerPort
;
rpcInit
.
label
=
"DND"
;
...
...
@@ -441,16 +432,15 @@ void dmCleanupServer(SDnode *pDnode) {
}
}
SMsgCb
dmGetMsgcb
(
SMgmtWrapper
*
pWrapper
)
{
SDnode
*
pDnode
=
dmInstance
();
SMsgCb
msgCb
=
{
.
clientRpc
=
dmInstance
()
->
trans
.
clientRpc
,
.
sendReqFp
=
dmSendReq
,
.
sendRspFp
=
dmSendRsp
,
.
sendRedirectRspFp
=
dmSendRedirectRsp
,
.
registerBrokenLinkArgFp
=
dmRegisterBrokenLinkArg
,
.
releaseHandleFp
=
dmReleaseHandle
,
.
reportStartupFp
=
dmReportStartup
,
SMsgCb
dmGetMsgcb
(
SDnode
*
pDnode
)
{
SMsgCb
msgCb
=
{
.
clientRpc
=
pDnode
->
trans
.
clientRpc
,
.
sendReqFp
=
dmSendReq
,
.
sendRspFp
=
dmSendRsp
,
.
sendRedirectRspFp
=
dmSendRedirectRsp
,
.
registerBrokenLinkArgFp
=
dmRegisterBrokenLinkArg
,
.
releaseHandleFp
=
dmReleaseHandle
,
.
reportStartupFp
=
dmReportStartup
,
};
return
msgCb
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录