Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
285c396b
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1193
Star
22018
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看板
提交
285c396b
编写于
5月 07, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: adjust cluster mgmt code
上级
f54cdb02
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
35 addition
and
33 deletion
+35
-33
source/dnode/mnode/impl/src/mndCluster.c
source/dnode/mnode/impl/src/mndCluster.c
+35
-33
未找到文件。
source/dnode/mnode/impl/src/mndCluster.c
浏览文件 @
285c396b
...
...
@@ -17,8 +17,8 @@
#include "mndCluster.h"
#include "mndShow.h"
#define
TSDB_
CLUSTER_VER_NUMBE 1
#define
TSDB_
CLUSTER_RESERVE_SIZE 64
#define CLUSTER_VER_NUMBE 1
#define CLUSTER_RESERVE_SIZE 64
static
SSdbRaw
*
mndClusterActionEncode
(
SClusterObj
*
pCluster
);
static
SSdbRow
*
mndClusterActionDecode
(
SSdbRaw
*
pRaw
);
...
...
@@ -30,14 +30,16 @@ static int32_t mndRetrieveClusters(SNodeMsg *pMsg, SShowObj *pShow, SSDataBlock
static
void
mndCancelGetNextCluster
(
SMnode
*
pMnode
,
void
*
pIter
);
int32_t
mndInitCluster
(
SMnode
*
pMnode
)
{
SSdbTable
table
=
{.
sdbType
=
SDB_CLUSTER
,
.
keyType
=
SDB_KEY_INT64
,
.
deployFp
=
(
SdbDeployFp
)
mndCreateDefaultCluster
,
.
encodeFp
=
(
SdbEncodeFp
)
mndClusterActionEncode
,
.
decodeFp
=
(
SdbDecodeFp
)
mndClusterActionDecode
,
.
insertFp
=
(
SdbInsertFp
)
mndClusterActionInsert
,
.
updateFp
=
(
SdbUpdateFp
)
mndClusterActionUpdate
,
.
deleteFp
=
(
SdbDeleteFp
)
mndClusterActionDelete
};
SSdbTable
table
=
{
.
sdbType
=
SDB_CLUSTER
,
.
keyType
=
SDB_KEY_INT64
,
.
deployFp
=
(
SdbDeployFp
)
mndCreateDefaultCluster
,
.
encodeFp
=
(
SdbEncodeFp
)
mndClusterActionEncode
,
.
decodeFp
=
(
SdbDecodeFp
)
mndClusterActionDecode
,
.
insertFp
=
(
SdbInsertFp
)
mndClusterActionInsert
,
.
updateFp
=
(
SdbUpdateFp
)
mndClusterActionUpdate
,
.
deleteFp
=
(
SdbDeleteFp
)
mndClusterActionDelete
,
};
mndAddShowRetrieveHandle
(
pMnode
,
TSDB_MGMT_TABLE_CLUSTER
,
mndRetrieveClusters
);
mndAddShowFreeIterHandle
(
pMnode
,
TSDB_MGMT_TABLE_CLUSTER
,
mndCancelGetNextCluster
);
...
...
@@ -79,19 +81,19 @@ int64_t mndGetClusterId(SMnode *pMnode) {
static
SSdbRaw
*
mndClusterActionEncode
(
SClusterObj
*
pCluster
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
SSdbRaw
*
pRaw
=
sdbAllocRaw
(
SDB_CLUSTER
,
TSDB_CLUSTER_VER_NUMBE
,
sizeof
(
SClusterObj
)
+
TSDB_
CLUSTER_RESERVE_SIZE
);
if
(
pRaw
==
NULL
)
goto
CLUSTER_ENCODE
_OVER
;
SSdbRaw
*
pRaw
=
sdbAllocRaw
(
SDB_CLUSTER
,
CLUSTER_VER_NUMBE
,
sizeof
(
SClusterObj
)
+
CLUSTER_RESERVE_SIZE
);
if
(
pRaw
==
NULL
)
goto
_OVER
;
int32_t
dataPos
=
0
;
SDB_SET_INT64
(
pRaw
,
dataPos
,
pCluster
->
id
,
CLUSTER_ENCODE
_OVER
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pCluster
->
createdTime
,
CLUSTER_ENCODE
_OVER
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pCluster
->
updateTime
,
CLUSTER_ENCODE
_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pCluster
->
name
,
TSDB_CLUSTER_ID_LEN
,
CLUSTER_ENCODE
_OVER
)
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
TSDB_CLUSTER_RESERVE_SIZE
,
CLUSTER_ENCODE
_OVER
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pCluster
->
id
,
_OVER
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pCluster
->
createdTime
,
_OVER
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pCluster
->
updateTime
,
_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pCluster
->
name
,
TSDB_CLUSTER_ID_LEN
,
_OVER
)
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
CLUSTER_RESERVE_SIZE
,
_OVER
)
terrno
=
0
;
CLUSTER_ENCODE
_OVER:
_OVER:
if
(
terrno
!=
0
)
{
mError
(
"cluster:%"
PRId64
", failed to encode to raw:%p since %s"
,
pCluster
->
id
,
pRaw
,
terrstr
());
sdbFreeRaw
(
pRaw
);
...
...
@@ -106,29 +108,29 @@ static SSdbRow *mndClusterActionDecode(SSdbRaw *pRaw) {
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
int8_t
sver
=
0
;
if
(
sdbGetRawSoftVer
(
pRaw
,
&
sver
)
!=
0
)
goto
CLUSTER_DECODE
_OVER
;
if
(
sdbGetRawSoftVer
(
pRaw
,
&
sver
)
!=
0
)
goto
_OVER
;
if
(
sver
!=
TSDB_
CLUSTER_VER_NUMBE
)
{
if
(
sver
!=
CLUSTER_VER_NUMBE
)
{
terrno
=
TSDB_CODE_SDB_INVALID_DATA_VER
;
goto
CLUSTER_DECODE
_OVER
;
goto
_OVER
;
}
SSdbRow
*
pRow
=
sdbAllocRow
(
sizeof
(
SClusterObj
));
if
(
pRow
==
NULL
)
goto
CLUSTER_DECODE
_OVER
;
if
(
pRow
==
NULL
)
goto
_OVER
;
SClusterObj
*
pCluster
=
sdbGetRowObj
(
pRow
);
if
(
pCluster
==
NULL
)
goto
CLUSTER_DECODE
_OVER
;
if
(
pCluster
==
NULL
)
goto
_OVER
;
int32_t
dataPos
=
0
;
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pCluster
->
id
,
CLUSTER_DECODE
_OVER
)
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pCluster
->
createdTime
,
CLUSTER_DECODE
_OVER
)
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pCluster
->
updateTime
,
CLUSTER_DECODE
_OVER
)
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pCluster
->
name
,
TSDB_CLUSTER_ID_LEN
,
CLUSTER_DECODE
_OVER
)
SDB_GET_RESERVE
(
pRaw
,
dataPos
,
TSDB_CLUSTER_RESERVE_SIZE
,
CLUSTER_DECODE
_OVER
)
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pCluster
->
id
,
_OVER
)
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pCluster
->
createdTime
,
_OVER
)
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pCluster
->
updateTime
,
_OVER
)
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pCluster
->
name
,
TSDB_CLUSTER_ID_LEN
,
_OVER
)
SDB_GET_RESERVE
(
pRaw
,
dataPos
,
CLUSTER_RESERVE_SIZE
,
_OVER
)
terrno
=
0
;
CLUSTER_DECODE
_OVER:
_OVER:
if
(
terrno
!=
0
)
{
mError
(
"cluster:%"
PRId64
", failed to decode from raw:%p since %s"
,
pCluster
->
id
,
pRaw
,
terrstr
());
taosMemoryFreeClear
(
pRow
);
...
...
@@ -161,7 +163,7 @@ static int32_t mndCreateDefaultCluster(SMnode *pMnode) {
int32_t
code
=
taosGetSystemUUID
(
clusterObj
.
name
,
TSDB_CLUSTER_ID_LEN
);
if
(
code
!=
0
)
{
strcpy
(
clusterObj
.
name
,
"tdengine
2
.0"
);
strcpy
(
clusterObj
.
name
,
"tdengine
3
.0"
);
mError
(
"failed to get name from system, set to default val %s"
,
clusterObj
.
name
);
}
...
...
@@ -190,8 +192,8 @@ static int32_t mndRetrieveClusters(SNodeMsg *pMsg, SShowObj *pShow, SSDataBlock
if
(
pShow
->
pIter
==
NULL
)
break
;
cols
=
0
;
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pCluster
->
id
,
false
);
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pCluster
->
id
,
false
);
char
buf
[
tListLen
(
pCluster
->
name
)
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
buf
,
pCluster
->
name
,
pShow
->
pMeta
->
pSchemas
[
cols
].
bytes
);
...
...
@@ -200,7 +202,7 @@ static int32_t mndRetrieveClusters(SNodeMsg *pMsg, SShowObj *pShow, SSDataBlock
colDataAppend
(
pColInfo
,
numOfRows
,
buf
,
false
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pCluster
->
createdTime
,
false
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pCluster
->
createdTime
,
false
);
sdbRelease
(
pSdb
,
pCluster
);
numOfRows
++
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录