Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
cd289b99
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
cd289b99
编写于
5月 20, 2020
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-374] Set mnodeInfo as a static variable to speed up the query
上级
45257d71
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
59 addition
and
26 deletion
+59
-26
src/mnode/inc/mgmtMnode.h
src/mnode/inc/mgmtMnode.h
+1
-1
src/mnode/src/mgmtMnode.c
src/mnode/src/mgmtMnode.c
+56
-25
src/mnode/src/mgmtSdb.c
src/mnode/src/mgmtSdb.c
+2
-0
未找到文件。
src/mnode/inc/mgmtMnode.h
浏览文件 @
cd289b99
...
...
@@ -44,7 +44,7 @@ void mgmtDecMnodeRef(struct SMnodeObj *pMnode);
char
*
mgmtGetMnodeRoleStr
();
void
mgmtGetMnodeIpSet
(
SRpcIpSet
*
ipSet
);
void
mgmtGetMnodeInfos
(
void
*
mnodes
);
void
mgmtUpdateMnodeIpSet
();
#ifdef __cplusplus
}
...
...
src/mnode/src/mgmtMnode.c
浏览文件 @
cd289b99
...
...
@@ -36,6 +36,25 @@ static int32_t tsMnodeUpdateSize = 0;
static
int32_t
mgmtGetMnodeMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mgmtRetrieveMnodes
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
SRpcIpSet
tsMnodeRpcIpSet
;
static
SDMMnodeInfos
tsMnodeInfos
;
#if defined(LINUX)
static
pthread_rwlock_t
tsMnodeLock
;
#define mgmtMnodeWrLock() pthread_rwlock_wrlock(&tsMnodeLock)
#define mgmtMnodeRdLock() pthread_rwlock_rdlock(&tsMnodeLock)
#define mgmtMnodeUnLock() pthread_rwlock_unlock(&tsMnodeLock)
#define mgmtMnodeInitLock() pthread_rwlock_init(&tsMnodeLock, NULL)
#define mgmtMnodeDestroyLock() pthread_rwlock_destroy(&tsMnodeLock)
#else
static
pthread_mutex_t
tsMnodeLock
;
#define mgmtMnodeWrLock() pthread_mutex_lock(&tsMnodeLock)
#define mgmtMnodeRdLock() pthread_mutex_lock(&tsMnodeLock)
#define mgmtMnodeUnLock() pthread_mutex_unlock(&tsMnodeLock)
#define mgmtMnodeInitLock() pthread_mutex_init(&tsMnodeLock, NULL)
#define mgmtMnodeDestroyLock() pthread_mutex_destroy(&tsMnodeLock)
#endif
static
int32_t
mgmtMnodeActionDestroy
(
SSdbOper
*
pOper
)
{
tfree
(
pOper
->
pObj
);
return
TSDB_CODE_SUCCESS
;
...
...
@@ -106,6 +125,8 @@ static int32_t mgmtMnodeActionRestored() {
}
int32_t
mgmtInitMnodes
()
{
mgmtMnodeInitLock
();
SMnodeObj
tObj
;
tsMnodeUpdateSize
=
(
int8_t
*
)
tObj
.
updateEnd
-
(
int8_t
*
)
&
tObj
;
...
...
@@ -140,6 +161,7 @@ int32_t mgmtInitMnodes() {
void
mgmtCleanupMnodes
()
{
sdbCloseTable
(
tsMnodeSdb
);
mgmtMnodeDestroyLock
();
}
int32_t
mgmtGetMnodesNum
()
{
...
...
@@ -177,50 +199,52 @@ char *mgmtGetMnodeRoleStr(int32_t role) {
}
}
void
mgmtGetMnodeIpSet
(
SRpcIpSet
*
ipSet
)
{
void
*
pIter
=
NULL
;
while
(
1
)
{
SMnodeObj
*
pMnode
=
NULL
;
pIter
=
mgmtGetNextMnode
(
pIter
,
&
pMnode
);
if
(
pMnode
==
NULL
)
break
;
strcpy
(
ipSet
->
fqdn
[
ipSet
->
numOfIps
],
pMnode
->
pDnode
->
dnodeFqdn
);
ipSet
->
port
[
ipSet
->
numOfIps
]
=
htons
(
pMnode
->
pDnode
->
dnodePort
);
if
(
pMnode
->
role
==
TAOS_SYNC_ROLE_MASTER
)
{
ipSet
->
inUse
=
ipSet
->
numOfIps
;
}
void
mgmtUpdateMnodeIpSet
()
{
SRpcIpSet
*
ipSet
=
&
tsMnodeRpcIpSet
;
SDMMnodeInfos
*
mnodes
=
&
tsMnodeInfos
;
ipSet
->
numOfIps
++
;
mgmtDecMnodeRef
(
pMnode
);
}
sdbFreeIter
(
pIter
);
}
mgmtMnodeWrLock
();
void
mgmtGetMnodeInfos
(
void
*
param
)
{
SDMMnodeInfos
*
mnodes
=
param
;
mnodes
->
inUse
=
0
;
int32_t
index
=
0
;
void
*
pIter
=
NULL
;
void
*
pIter
=
NULL
;
while
(
1
)
{
SMnodeObj
*
pMnode
=
NULL
;
pIter
=
mgmtGetNextMnode
(
pIter
,
&
pMnode
);
if
(
pMnode
==
NULL
)
break
;
strcpy
(
ipSet
->
fqdn
[
ipSet
->
numOfIps
],
pMnode
->
pDnode
->
dnodeFqdn
);
ipSet
->
port
[
ipSet
->
numOfIps
]
=
htons
(
pMnode
->
pDnode
->
dnodePort
);
mnodes
->
nodeInfos
[
index
].
nodeId
=
htonl
(
pMnode
->
mnodeId
);
strcpy
(
mnodes
->
nodeInfos
[
index
].
nodeEp
,
pMnode
->
pDnode
->
dnodeEp
);
if
(
pMnode
->
role
==
TAOS_SYNC_ROLE_MASTER
)
{
ipSet
->
inUse
=
ipSet
->
numOfIps
;
mnodes
->
inUse
=
index
;
}
ipSet
->
numOfIps
++
;
index
++
;
mgmtDecMnodeRef
(
pMnode
);
}
sdbFreeIter
(
pIter
);
mnodes
->
nodeNum
=
index
;
sdbFreeIter
(
pIter
);
mgmtMnodeUnLock
();
}
void
mgmtGetMnodeIpSet
(
SRpcIpSet
*
ipSet
)
{
mgmtMnodeRdLock
();
*
ipSet
=
tsMnodeRpcIpSet
;
mgmtMnodeUnLock
();
}
void
mgmtGetMnodeInfos
(
void
*
mnodeInfos
)
{
mgmtMnodeRdLock
();
*
(
SDMMnodeInfos
*
)
mnodeInfos
=
tsMnodeInfos
;
mgmtMnodeUnLock
();
}
int32_t
mgmtAddMnode
(
int32_t
dnodeId
)
{
...
...
@@ -240,6 +264,8 @@ int32_t mgmtAddMnode(int32_t dnodeId) {
code
=
TSDB_CODE_SDB_ERROR
;
}
mgmtUpdateMnodeIpSet
();
return
code
;
}
...
...
@@ -250,6 +276,8 @@ void mgmtDropMnodeLocal(int32_t dnodeId) {
sdbDeleteRow
(
&
oper
);
mgmtDecMnodeRef
(
pMnode
);
}
mgmtUpdateMnodeIpSet
();
}
int32_t
mgmtDropMnode
(
int32_t
dnodeId
)
{
...
...
@@ -270,6 +298,9 @@ int32_t mgmtDropMnode(int32_t dnodeId) {
}
sdbDecRef
(
tsMnodeSdb
,
pMnode
);
mgmtUpdateMnodeIpSet
();
return
code
;
}
...
...
src/mnode/src/mgmtSdb.c
浏览文件 @
cd289b99
...
...
@@ -196,6 +196,8 @@ void sdbUpdateMnodeRoles() {
mgmtDecMnodeRef
(
pMnode
);
}
}
mgmtUpdateMnodeIpSet
();
}
static
uint32_t
sdbGetFileInfo
(
void
*
ahandle
,
char
*
name
,
uint32_t
*
index
,
int32_t
*
size
,
uint64_t
*
fversion
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录