Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c3a25985
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看板
提交
c3a25985
编写于
11月 27, 2021
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change lock type in dndDnode
上级
c049678a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
46 addition
and
42 deletion
+46
-42
source/dnode/mgmt/impl/src/dndDnode.c
source/dnode/mgmt/impl/src/dndDnode.c
+42
-39
source/dnode/mgmt/impl/src/dndTransport.c
source/dnode/mgmt/impl/src/dndTransport.c
+2
-0
source/dnode/mgmt/impl/src/dnode.c
source/dnode/mgmt/impl/src/dnode.c
+2
-3
未找到文件。
source/dnode/mgmt/impl/src/dndDnode.c
浏览文件 @
c3a25985
...
...
@@ -18,32 +18,27 @@
#include "dndTransport.h"
#include "dndVnodes.h"
static
inline
void
dndRLockDnode
(
SDnode
*
pDnode
)
{
taosRLockLatch
(
&
pDnode
->
dmgmt
.
latch
);
}
static
inline
void
dndRUnLockDnode
(
SDnode
*
pDnode
)
{
taosRUnLockLatch
(
&
pDnode
->
dmgmt
.
latch
);
}
static
inline
void
dndWLockDnode
(
SDnode
*
pDnode
)
{
taosWLockLatch
(
&
pDnode
->
dmgmt
.
latch
);
}
static
inline
void
dndWUnLockDnode
(
SDnode
*
pDnode
)
{
taosWUnLockLatch
(
&
pDnode
->
dmgmt
.
latch
);
}
int32_t
dndGetDnodeId
(
SDnode
*
pDnode
)
{
dndRLockDnode
(
pDnode
);
int32_t
dnodeId
=
pDnode
->
dmgmt
.
dnodeId
;
dndRUnLockDnode
(
pDnode
);
SDnodeMgmt
*
pMgmt
=
&
pDnode
->
dmgmt
;
taosRLockLatch
(
&
pMgmt
->
latch
);
int32_t
dnodeId
=
pMgmt
->
dnodeId
;
taosRUnLockLatch
(
&
pMgmt
->
latch
);
return
dnodeId
;
}
int64_t
dndGetClusterId
(
SDnode
*
pDnode
)
{
dndRLockDnode
(
pDnode
);
int64_t
clusterId
=
pDnode
->
dmgmt
.
clusterId
;
dndRUnLockDnode
(
pDnode
);
SDnodeMgmt
*
pMgmt
=
&
pDnode
->
dmgmt
;
taosRLockLatch
(
&
pMgmt
->
latch
);
int64_t
clusterId
=
pMgmt
->
clusterId
;
taosRUnLockLatch
(
&
pMgmt
->
latch
);
return
clusterId
;
}
void
dndGetDnodeEp
(
SDnode
*
pDnode
,
int32_t
dnodeId
,
char
*
pEp
,
char
*
pFqdn
,
uint16_t
*
pPort
)
{
dndRLockDnode
(
pDnode
);
SDnodeMgmt
*
pMgmt
=
&
pDnode
->
dmgmt
;
taosRLockLatch
(
&
pMgmt
->
latch
);
SDnodeEp
*
pDnodeEp
=
taosHashGet
(
p
Dnode
->
dmgmt
.
dnodeHash
,
&
dnodeId
,
sizeof
(
int32_t
));
SDnodeEp
*
pDnodeEp
=
taosHashGet
(
p
Mgmt
->
dnodeHash
,
&
dnodeId
,
sizeof
(
int32_t
));
if
(
pDnodeEp
!=
NULL
)
{
if
(
pPort
!=
NULL
)
{
*
pPort
=
pDnodeEp
->
port
;
...
...
@@ -56,13 +51,14 @@ void dndGetDnodeEp(SDnode *pDnode, int32_t dnodeId, char *pEp, char *pFqdn, uint
}
}
dndRUnLockDnode
(
pDnode
);
taosRUnLockLatch
(
&
pMgmt
->
latch
);
}
void
dndGetMnodeEpSet
(
SDnode
*
pDnode
,
SEpSet
*
pEpSet
)
{
dndRLockDnode
(
pDnode
);
*
pEpSet
=
pDnode
->
dmgmt
.
mnodeEpSet
;
dndRUnLockDnode
(
pDnode
);
SDnodeMgmt
*
pMgmt
=
&
pDnode
->
dmgmt
;
taosRLockLatch
(
&
pMgmt
->
latch
);
*
pEpSet
=
pMgmt
->
mnodeEpSet
;
taosRUnLockLatch
(
&
pMgmt
->
latch
);
}
void
dndSendRedirectMsg
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
)
{
...
...
@@ -87,14 +83,15 @@ void dndSendRedirectMsg(SDnode *pDnode, SRpcMsg *pMsg) {
static
void
dndUpdateMnodeEpSet
(
SDnode
*
pDnode
,
SEpSet
*
pEpSet
)
{
dInfo
(
"mnode is changed, num:%d inUse:%d"
,
pEpSet
->
numOfEps
,
pEpSet
->
inUse
);
dndWLockDnode
(
pDnode
);
SDnodeMgmt
*
pMgmt
=
&
pDnode
->
dmgmt
;
taosWLockLatch
(
&
pMgmt
->
latch
);
p
Dnode
->
dmgmt
.
mnodeEpSet
=
*
pEpSet
;
p
Mgmt
->
mnodeEpSet
=
*
pEpSet
;
for
(
int32_t
i
=
0
;
i
<
pEpSet
->
numOfEps
;
++
i
)
{
dInfo
(
"mnode index:%d %s:%u"
,
i
,
pEpSet
->
fqdn
[
i
],
pEpSet
->
port
[
i
]);
}
dndWUnLockDnode
(
pDnode
);
taosWUnLockLatch
(
&
pMgmt
->
latch
);
}
static
void
dndPrintDnodes
(
SDnode
*
pDnode
)
{
...
...
@@ -145,16 +142,18 @@ static void dndResetDnodes(SDnode *pDnode, SDnodeEps *pDnodeEps) {
static
bool
dndIsEpChanged
(
SDnode
*
pDnode
,
int32_t
dnodeId
,
char
*
pEp
)
{
bool
changed
=
false
;
dndRLockDnode
(
pDnode
);
SDnodeEp
*
pDnodeEp
=
taosHashGet
(
pDnode
->
dmgmt
.
dnodeHash
,
&
dnodeId
,
sizeof
(
int32_t
));
SDnodeMgmt
*
pMgmt
=
&
pDnode
->
dmgmt
;
taosRLockLatch
(
&
pMgmt
->
latch
);
SDnodeEp
*
pDnodeEp
=
taosHashGet
(
pMgmt
->
dnodeHash
,
&
dnodeId
,
sizeof
(
int32_t
));
if
(
pDnodeEp
!=
NULL
)
{
char
epstr
[
TSDB_EP_LEN
+
1
];
snprintf
(
epstr
,
TSDB_EP_LEN
,
"%s:%u"
,
pDnodeEp
->
fqdn
,
pDnodeEp
->
port
);
changed
=
strcmp
(
pEp
,
epstr
)
!=
0
;
}
dndRUnLockDnode
(
pDnode
);
taosRUnLockLatch
(
&
pMgmt
->
latch
);
return
changed
;
}
...
...
@@ -342,11 +341,14 @@ static void dndSendStatusMsg(SDnode *pDnode) {
return
;
}
dndRLockDnode
(
pDnode
);
bool
changed
=
false
;
SDnodeMgmt
*
pMgmt
=
&
pDnode
->
dmgmt
;
taosRLockLatch
(
&
pMgmt
->
latch
);
pStatus
->
sversion
=
htonl
(
pDnode
->
opt
.
sver
);
pStatus
->
dnodeId
=
htonl
(
p
Dnode
->
dmgmt
.
dnodeId
);
pStatus
->
clusterId
=
htobe64
(
p
Dnode
->
dmgmt
.
clusterId
);
pStatus
->
rebootTime
=
htonl
(
p
Dnode
->
dmgmt
.
rebootTime
);
pStatus
->
dnodeId
=
htonl
(
p
Mgmt
->
dnodeId
);
pStatus
->
clusterId
=
htobe64
(
p
Mgmt
->
clusterId
);
pStatus
->
rebootTime
=
htonl
(
p
Mgmt
->
rebootTime
);
pStatus
->
numOfCores
=
htonl
(
pDnode
->
opt
.
numOfCores
);
tstrncpy
(
pStatus
->
dnodeEp
,
pDnode
->
opt
.
localEp
,
TSDB_EP_LEN
);
pStatus
->
clusterCfg
.
statusInterval
=
htonl
(
pDnode
->
opt
.
statusInterval
);
...
...
@@ -356,7 +358,7 @@ static void dndSendStatusMsg(SDnode *pDnode) {
pStatus
->
clusterCfg
.
checkTime
=
0
;
char
timestr
[
32
]
=
"1970-01-01 00:00:00.00"
;
(
void
)
taosParseTime
(
timestr
,
&
pStatus
->
clusterCfg
.
checkTime
,
(
int32_t
)
strlen
(
timestr
),
TSDB_TIME_PRECISION_MILLI
,
0
);
dndRUnLockDnode
(
pDnode
);
taosRUnLockLatch
(
&
pMgmt
->
latch
);
dndGetVnodeLoads
(
pDnode
,
&
pStatus
->
vnodeLoads
);
contLen
=
sizeof
(
SStatusMsg
)
+
pStatus
->
vnodeLoads
.
num
*
sizeof
(
SVnodeLoad
);
...
...
@@ -370,32 +372,33 @@ static void dndUpdateDnodeCfg(SDnode *pDnode, SDnodeCfg *pCfg) {
if
(
pMgmt
->
dnodeId
==
0
||
pMgmt
->
dropped
!=
pCfg
->
dropped
)
{
dInfo
(
"set dnodeId:%d clusterId:%"
PRId64
" dropped:%d"
,
pCfg
->
dnodeId
,
pCfg
->
clusterId
,
pCfg
->
dropped
);
dndWLockDnode
(
pDnode
);
taosWLockLatch
(
&
pMgmt
->
latch
);
pMgmt
->
dnodeId
=
pCfg
->
dnodeId
;
pMgmt
->
clusterId
=
pCfg
->
clusterId
;
pMgmt
->
dropped
=
pCfg
->
dropped
;
(
void
)
dndWriteDnodes
(
pDnode
);
dndWUnLockDnode
(
pDnode
);
taosWUnLockLatch
(
&
pMgmt
->
latch
);
}
}
static
void
dndUpdateDnodeEps
(
SDnode
*
pDnode
,
SDnodeEps
*
pDnodeEps
)
{
if
(
pDnodeEps
==
NULL
||
pDnodeEps
->
num
<=
0
)
return
;
dndWLockDnode
(
pDnode
);
SDnodeMgmt
*
pMgmt
=
&
pDnode
->
dmgmt
;
taosWLockLatch
(
&
pMgmt
->
latch
);
if
(
pDnodeEps
->
num
!=
p
Dnode
->
dmgmt
.
dnodeEps
->
num
)
{
if
(
pDnodeEps
->
num
!=
p
Mgmt
->
dnodeEps
->
num
)
{
dndResetDnodes
(
pDnode
,
pDnodeEps
);
dndWriteDnodes
(
pDnode
);
}
else
{
int32_t
size
=
pDnodeEps
->
num
*
sizeof
(
SDnodeEp
)
+
sizeof
(
SDnodeEps
);
if
(
memcmp
(
p
Dnode
->
dmgmt
.
dnodeEps
,
pDnodeEps
,
size
)
!=
0
)
{
if
(
memcmp
(
p
Mgmt
->
dnodeEps
,
pDnodeEps
,
size
)
!=
0
)
{
dndResetDnodes
(
pDnode
,
pDnodeEps
);
dndWriteDnodes
(
pDnode
);
}
}
dndWUnLockDnode
(
pDnode
);
taosWUnLockLatch
(
&
pMgmt
->
latch
);
}
static
void
dndProcessStatusRsp
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
)
{
...
...
@@ -512,7 +515,7 @@ void dndCleanupDnode(SDnode *pDnode) {
pMgmt
->
threadId
=
NULL
;
}
dndWLockDnode
(
pDnode
);
taosWLockLatch
(
&
pMgmt
->
latch
);
if
(
pMgmt
->
dnodeEps
!=
NULL
)
{
free
(
pMgmt
->
dnodeEps
);
...
...
@@ -529,7 +532,7 @@ void dndCleanupDnode(SDnode *pDnode) {
pMgmt
->
file
=
NULL
;
}
dndWUnLockDnode
(
pDnode
);
taosWUnLockLatch
(
&
pMgmt
->
latch
);
dInfo
(
"dnode-dnode is cleaned up"
);
}
...
...
source/dnode/mgmt/impl/src/dndTransport.c
浏览文件 @
c3a25985
...
...
@@ -187,6 +187,7 @@ static void dndProcessRequest(void *param, SRpcMsg *pMsg, SEpSet *pEpSet) {
int32_t
msgType
=
pMsg
->
msgType
;
if
(
msgType
==
TSDB_MSG_TYPE_NETWORK_TEST
)
{
dTrace
(
"RPC %p, network test req will be processed"
,
pMsg
->
handle
);
dndProcessDnodeReq
(
pDnode
,
pMsg
,
pEpSet
);
return
;
}
...
...
@@ -206,6 +207,7 @@ static void dndProcessRequest(void *param, SRpcMsg *pMsg, SEpSet *pEpSet) {
}
if
(
pMsg
->
pCont
==
NULL
)
{
dTrace
(
"RPC %p, req:%s not processed since content is null"
,
pMsg
->
handle
,
taosMsg
[
msgType
]);
SRpcMsg
rspMsg
=
{.
handle
=
pMsg
->
handle
,
.
code
=
TSDB_CODE_DND_INVALID_MSG_LEN
};
rpcSendResponse
(
&
rspMsg
);
return
;
...
...
source/dnode/mgmt/impl/src/dnode.c
浏览文件 @
c3a25985
...
...
@@ -26,7 +26,7 @@
EStat
dndGetStat
(
SDnode
*
pDnode
)
{
return
pDnode
->
stat
;
}
void
dndSetStat
(
SDnode
*
pDnode
,
EStat
stat
)
{
dDebug
(
"dnode stat set from %s to %s"
,
dndStatStr
(
pDnode
->
stat
),
dndStatStr
(
stat
));
dDebug
(
"dnode stat
us
set from %s to %s"
,
dndStatStr
(
pDnode
->
stat
),
dndStatStr
(
stat
));
pDnode
->
stat
=
stat
;
}
...
...
@@ -214,8 +214,7 @@ void dndCleanup(SDnode *pDnode) {
dndCleanupDnode
(
pDnode
);
walCleanUp
();
rpcCleanup
();
dInfo
(
"TDengine is cleaned up successfully"
);
dndCleanupEnv
(
pDnode
);
free
(
pDnode
);
dInfo
(
"TDengine is cleaned up successfully"
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录