Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
4766deb2
T
TDengine
项目概览
taosdata
/
TDengine
12 个月 前同步成功
通知
1180
Star
22014
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4766deb2
编写于
4月 13, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feature/qnode
上级
c9b43b29
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
219 addition
and
0 deletion
+219
-0
source/dnode/mnode/impl/inc/mndPerfSchema.h
source/dnode/mnode/impl/inc/mndPerfSchema.h
+45
-0
source/dnode/mnode/impl/src/mndPerfSchema.c
source/dnode/mnode/impl/src/mndPerfSchema.c
+174
-0
未找到文件。
source/dnode/mnode/impl/inc/mndPerfSchema.h
0 → 100644
浏览文件 @
4766deb2
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_MND_PERF_SCHEMA_H_
#define _TD_MND_PERF_SCHEMA_H_
#include "mndInt.h"
#ifdef __cplusplus
extern
"C"
{
#endif
typedef
struct
SPerfsTableSchema
{
char
*
name
;
int32_t
type
;
int32_t
bytes
;
}
SPerfsTableSchema
;
typedef
struct
SPerfsTableMeta
{
char
*
name
;
const
SPerfsTableSchema
*
schema
;
int32_t
colNum
;
}
SPerfsTableMeta
;
int32_t
mndBuildPerfsTableSchema
(
SMnode
*
pMnode
,
const
char
*
dbFName
,
const
char
*
tbName
,
STableMetaRsp
*
pRsp
);
int32_t
mndInitPerfs
(
SMnode
*
pMnode
);
void
mndCleanupPerfs
(
SMnode
*
pMnode
);
#ifdef __cplusplus
}
#endif
#endif
/*_TD_MND_PERF_SCHEMA_H_*/
source/dnode/mnode/impl/src/mndPerfSchema.c
0 → 100644
浏览文件 @
4766deb2
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "mndPerfSchema.h"
#include "mndInt.h"
//!!!! Note: only APPEND columns in below tables, NO insert !!!!
static
const
SPerfsTableSchema
connectionsSchema
[]
=
{
{.
name
=
"conn_id"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_UINT
},
{.
name
=
"user"
,
.
bytes
=
TSDB_USER_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_BINARY
},
{.
name
=
"program"
,
.
bytes
=
TSDB_APP_NAME_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_BINARY
},
{.
name
=
"pid"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"end_point"
,
.
bytes
=
TSDB_EP_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_BINARY
},
{.
name
=
"login_time"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
},
{.
name
=
"last_access"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
},
};
static
const
SPerfsTableSchema
queriesSchema
[]
=
{
{.
name
=
"query_id"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_UBIGINT
},
{.
name
=
"sql"
,
.
bytes
=
TSDB_SHOW_SQL_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_BINARY
},
{.
name
=
"user"
,
.
bytes
=
TSDB_USER_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_BINARY
},
{.
name
=
"pid"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"fqdn"
,
.
bytes
=
TSDB_FQDN_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_BINARY
},
{.
name
=
"exec_time"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_BIGINT
},
{.
name
=
"create_time"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
},
{.
name
=
"sub_queries"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"sub_query_info"
,
.
bytes
=
TSDB_SHOW_SUBQUERY_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_BINARY
},
};
static
const
SPerfsTableSchema
topicSchema
[]
=
{
{.
name
=
"topic_name"
,
.
bytes
=
SYSTABLE_SCH_TABLE_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_BINARY
},
{.
name
=
"db_name"
,
.
bytes
=
SYSTABLE_SCH_DB_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_BINARY
},
{.
name
=
"create_time"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
},
{.
name
=
"sql"
,
.
bytes
=
TSDB_SHOW_SQL_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_BINARY
},
{.
name
=
"row_len"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
};
static
const
SPerfsTableSchema
consumerSchema
[]
=
{
{.
name
=
"client_id"
,
.
bytes
=
SYSTABLE_SCH_TABLE_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_BINARY
},
{.
name
=
"group_id"
,
.
bytes
=
SYSTABLE_SCH_TABLE_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_BINARY
},
{.
name
=
"pid"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"status"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
// ep
// up time
// topics
};
static
const
SPerfsTableSchema
subscribeSchema
[]
=
{
{.
name
=
"topic_name"
,
.
bytes
=
SYSTABLE_SCH_TABLE_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_BINARY
},
{.
name
=
"group_id"
,
.
bytes
=
SYSTABLE_SCH_TABLE_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_BINARY
},
{.
name
=
"vgroup_id"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"client_id"
,
.
bytes
=
SYSTABLE_SCH_TABLE_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_BINARY
},
};
static
const
SPerfsTableMeta
perfsMeta
[]
=
{
{
TSDB_PERFS_TABLE_CONNECTIONS
,
connectionsSchema
,
tListLen
(
connectionsSchema
)},
{
TSDB_PERFS_TABLE_QUERIES
,
queriesSchema
,
tListLen
(
queriesSchema
)},
{
TSDB_PERFS_TABLE_TOPICS
,
topicSchema
,
tListLen
(
topicSchema
)},
{
TSDB_PERFS_TABLE_CONSUMERS
,
consumerSchema
,
tListLen
(
consumerSchema
)},
{
TSDB_PERFS_TABLE_SUBSCRIBES
,
subscribeSchema
,
tListLen
(
subscribeSchema
)},
};
// connection/application/
int32_t
mndInitPerfsTableSchema
(
const
SPerfsTableSchema
*
pSrc
,
int32_t
colNum
,
SSchema
**
pDst
)
{
SSchema
*
schema
=
taosMemoryCalloc
(
colNum
,
sizeof
(
SSchema
));
if
(
NULL
==
schema
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
for
(
int32_t
i
=
0
;
i
<
colNum
;
++
i
)
{
strcpy
(
schema
[
i
].
name
,
pSrc
[
i
].
name
);
schema
[
i
].
type
=
pSrc
[
i
].
type
;
schema
[
i
].
colId
=
i
+
1
;
schema
[
i
].
bytes
=
pSrc
[
i
].
bytes
;
}
*
pDst
=
schema
;
return
TSDB_CODE_SUCCESS
;
}
int32_t
mndPerfsInitMeta
(
SHashObj
*
hash
)
{
STableMetaRsp
meta
=
{
0
};
strcpy
(
meta
.
dbFName
,
TSDB_INFORMATION_SCHEMA_DB
);
meta
.
tableType
=
TSDB_SYSTEM_TABLE
;
meta
.
sversion
=
1
;
meta
.
tversion
=
1
;
for
(
int32_t
i
=
0
;
i
<
tListLen
(
perfsMeta
);
++
i
)
{
strcpy
(
meta
.
tbName
,
perfsMeta
[
i
].
name
);
meta
.
numOfColumns
=
perfsMeta
[
i
].
colNum
;
if
(
mndInitPerfsTableSchema
(
perfsMeta
[
i
].
schema
,
perfsMeta
[
i
].
colNum
,
&
meta
.
pSchemas
))
{
return
-
1
;
}
if
(
taosHashPut
(
hash
,
meta
.
tbName
,
strlen
(
meta
.
tbName
),
&
meta
,
sizeof
(
meta
)))
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
}
return
TSDB_CODE_SUCCESS
;
}
int32_t
mndBuildPerfsTableSchema
(
SMnode
*
pMnode
,
const
char
*
dbFName
,
const
char
*
tbName
,
STableMetaRsp
*
pRsp
)
{
if
(
NULL
==
pMnode
->
perfsMeta
)
{
terrno
=
TSDB_CODE_MND_NOT_READY
;
return
-
1
;
}
STableMetaRsp
*
meta
=
(
STableMetaRsp
*
)
taosHashGet
(
pMnode
->
perfsMeta
,
tbName
,
strlen
(
tbName
));
if
(
NULL
==
meta
)
{
mError
(
"invalid performance schema table name:%s"
,
tbName
);
terrno
=
TSDB_CODE_MND_INVALID_INFOS_TBL
;
return
-
1
;
}
*
pRsp
=
*
meta
;
pRsp
->
pSchemas
=
taosMemoryCalloc
(
meta
->
numOfColumns
,
sizeof
(
SSchema
));
if
(
pRsp
->
pSchemas
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
pRsp
->
pSchemas
=
NULL
;
return
-
1
;
}
memcpy
(
pRsp
->
pSchemas
,
meta
->
pSchemas
,
meta
->
numOfColumns
*
sizeof
(
SSchema
));
return
0
;
}
int32_t
mndInitPerfs
(
SMnode
*
pMnode
)
{
pMnode
->
perfsMeta
=
taosHashInit
(
20
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
false
,
HASH_NO_LOCK
);
if
(
pMnode
->
perfsMeta
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
return
mndPerfsInitMeta
(
pMnode
->
perfsMeta
);
}
void
mndCleanupPerfs
(
SMnode
*
pMnode
)
{
if
(
NULL
==
pMnode
->
perfsMeta
)
{
return
;
}
void
*
pIter
=
taosHashIterate
(
pMnode
->
perfsMeta
,
NULL
);
while
(
pIter
)
{
STableMetaRsp
*
meta
=
(
STableMetaRsp
*
)
pIter
;
taosMemoryFreeClear
(
meta
->
pSchemas
);
pIter
=
taosHashIterate
(
pMnode
->
perfsMeta
,
pIter
);
}
taosHashCleanup
(
pMnode
->
perfsMeta
);
pMnode
->
perfsMeta
=
NULL
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录