Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
fe8b9e03
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看板
提交
fe8b9e03
编写于
6月 09, 2020
作者:
T
Tao Liu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-553] add usage statistics function
上级
b1f66073
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
53 addition
and
11 deletion
+53
-11
src/common/inc/tdataformat.h
src/common/inc/tdataformat.h
+5
-2
src/common/src/tdataformat.c
src/common/src/tdataformat.c
+9
-1
src/inc/tsdb.h
src/inc/tsdb.h
+16
-0
src/tsdb/inc/tsdbMain.h
src/tsdb/inc/tsdbMain.h
+2
-0
src/tsdb/src/tsdbMain.c
src/tsdb/src/tsdbMain.c
+15
-1
src/vnode/inc/vnodeInt.h
src/vnode/inc/vnodeInt.h
+0
-3
src/vnode/src/vnodeMain.c
src/vnode/src/vnodeMain.c
+6
-4
未找到文件。
src/common/inc/tdataformat.h
浏览文件 @
fe8b9e03
...
...
@@ -69,7 +69,8 @@ typedef struct {
int
version
;
// version
int
numOfCols
;
// Number of columns appended
int
tlen
;
// maximum length of a SDataRow without the header part
int
flen
;
// First part length in a SDataRow after the header part
int16_t
flen
;
// First part length in a SDataRow after the header part
int16_t
vlen
;
// pure value part length, excluded the overhead
STColumn
columns
[];
}
STSchema
;
...
...
@@ -77,6 +78,7 @@ typedef struct {
#define schemaVersion(s) ((s)->version)
#define schemaTLen(s) ((s)->tlen)
#define schemaFLen(s) ((s)->flen)
#define schemaVLen(s) ((s)->vlen)
#define schemaColAt(s, i) ((s)->columns + i)
#define tdFreeSchema(s) tfree((s))
...
...
@@ -105,7 +107,8 @@ typedef struct {
int
tCols
;
int
nCols
;
int
tlen
;
int
flen
;
int16_t
flen
;
int16_t
vlen
;
int
version
;
STColumn
*
columns
;
}
STSchemaBuilder
;
...
...
src/common/src/tdataformat.c
浏览文件 @
fe8b9e03
...
...
@@ -37,6 +37,7 @@ void *tdEncodeSchema(void *dst, STSchema *pSchema) {
T_APPEND_MEMBER
(
dst
,
pSchema
,
STSchema
,
version
);
T_APPEND_MEMBER
(
dst
,
pSchema
,
STSchema
,
numOfCols
);
T_APPEND_MEMBER
(
dst
,
pSchema
,
STSchema
,
vlen
);
for
(
int
i
=
0
;
i
<
schemaNCols
(
pSchema
);
i
++
)
{
STColumn
*
pCol
=
schemaColAt
(
pSchema
,
i
);
T_APPEND_MEMBER
(
dst
,
pCol
,
STColumn
,
type
);
...
...
@@ -53,10 +54,12 @@ void *tdEncodeSchema(void *dst, STSchema *pSchema) {
STSchema
*
tdDecodeSchema
(
void
**
psrc
)
{
int
totalCols
=
0
;
int
version
=
0
;
int16_t
vlen
=
0
;
STSchemaBuilder
schemaBuilder
=
{
0
};
T_READ_MEMBER
(
*
psrc
,
int
,
version
);
T_READ_MEMBER
(
*
psrc
,
int
,
totalCols
);
T_READ_MEMBER
(
*
psrc
,
int16_t
,
vlen
);
if
(
tdInitTSchemaBuilder
(
&
schemaBuilder
,
version
)
<
0
)
return
NULL
;
...
...
@@ -75,6 +78,7 @@ STSchema *tdDecodeSchema(void **psrc) {
}
STSchema
*
pSchema
=
tdGetSchemaFromBuilder
(
&
schemaBuilder
);
pSchema
->
vlen
=
vlen
;
tdDestroyTSchemaBuilder
(
&
schemaBuilder
);
return
pSchema
;
}
...
...
@@ -100,6 +104,7 @@ void tdResetTSchemaBuilder(STSchemaBuilder *pBuilder, int32_t version) {
pBuilder
->
nCols
=
0
;
pBuilder
->
tlen
=
0
;
pBuilder
->
flen
=
0
;
pBuilder
->
vlen
=
0
;
pBuilder
->
version
=
version
;
}
...
...
@@ -124,10 +129,12 @@ int tdAddColToSchema(STSchemaBuilder *pBuilder, int8_t type, int16_t colId, int3
if
(
IS_VAR_DATA_TYPE
(
type
))
{
colSetBytes
(
pCol
,
bytes
);
pBuilder
->
tlen
+=
(
TYPE_BYTES
[
type
]
+
sizeof
(
VarDataLenT
)
+
bytes
);
pBuilder
->
tlen
+=
(
TYPE_BYTES
[
type
]
+
bytes
);
pBuilder
->
vlen
+=
bytes
-
sizeof
(
VarDataLenT
);
}
else
{
colSetBytes
(
pCol
,
TYPE_BYTES
[
type
]);
pBuilder
->
tlen
+=
TYPE_BYTES
[
type
];
pBuilder
->
vlen
+=
TYPE_BYTES
[
type
];
}
pBuilder
->
nCols
++
;
...
...
@@ -150,6 +157,7 @@ STSchema *tdGetSchemaFromBuilder(STSchemaBuilder *pBuilder) {
schemaNCols
(
pSchema
)
=
pBuilder
->
nCols
;
schemaTLen
(
pSchema
)
=
pBuilder
->
tlen
;
schemaFLen
(
pSchema
)
=
pBuilder
->
flen
;
schemaVLen
(
pSchema
)
=
pBuilder
->
vlen
;
memcpy
(
schemaColAt
(
pSchema
,
0
),
pBuilder
->
columns
,
sizeof
(
STColumn
)
*
pBuilder
->
nCols
);
...
...
src/inc/tsdb.h
浏览文件 @
fe8b9e03
...
...
@@ -65,6 +65,13 @@ typedef struct {
int8_t
compression
;
}
STsdbCfg
;
// --------- TSDB REPOSITORY USAGE STATISTICS
typedef
struct
{
int64_t
totalStorage
;
//total bytes occupie
int64_t
compStorage
;
int64_t
pointsWritten
;
//total data points written
}
STsdbStat
;
typedef
void
TsdbRepoT
;
// use void to hide implementation details from outside
void
tsdbSetDefaultCfg
(
STsdbCfg
*
pCfg
);
...
...
@@ -306,6 +313,15 @@ int32_t tsdbGetOneTableGroup(TsdbRepoT *tsdb, uint64_t uid, STableGroupInfo *pGr
*/
void
tsdbCleanupQueryHandle
(
TsdbQueryHandleT
queryHandle
);
/**
* get the statistics of repo usage
* @param repo. point to the tsdbrepo
* @param totalPoints. total data point written
* @param totalStorage. total bytes took by the tsdb
* @param compStorage. total bytes took by the tsdb after compressed
*/
void
tsdbReportStat
(
void
*
repo
,
int64_t
*
totalPoints
,
int64_t
*
totalStorage
,
int64_t
*
compStorage
);
#ifdef __cplusplus
}
#endif
...
...
src/tsdb/inc/tsdbMain.h
浏览文件 @
fe8b9e03
...
...
@@ -357,6 +357,8 @@ typedef struct STsdbRepo {
STsdbAppH
appH
;
STsdbStat
stat
;
// The meter meta handle of this TSDB repository
STsdbMeta
*
tsdbMeta
;
...
...
src/tsdb/src/tsdbMain.c
浏览文件 @
fe8b9e03
...
...
@@ -953,6 +953,7 @@ static int32_t tdInsertRowToTable(STsdbRepo *pRepo, SDataRow row, STable *pTable
static
int32_t
tsdbInsertDataToTable
(
TsdbRepoT
*
repo
,
SSubmitBlk
*
pBlock
,
TSKEY
now
,
int32_t
*
affectedrows
)
{
STsdbRepo
*
pRepo
=
(
STsdbRepo
*
)
repo
;
STsdbMeta
*
pMeta
=
pRepo
->
tsdbMeta
;
int64_t
points
=
0
;
STableId
tableId
=
{.
uid
=
pBlock
->
uid
,
.
tid
=
pBlock
->
tid
};
STable
*
pTable
=
tsdbIsValidTableToInsert
(
pRepo
->
tsdbMeta
,
tableId
);
...
...
@@ -964,7 +965,9 @@ static int32_t tsdbInsertDataToTable(TsdbRepoT *repo, SSubmitBlk *pBlock, TSKEY
// Check schema version
int32_t
tversion
=
pBlock
->
sversion
;
int16_t
nversion
=
schemaVersion
(
tsdbGetTableSchema
(
pMeta
,
pTable
));
STSchema
*
pSchema
=
tsdbGetTableSchema
(
pMeta
,
pTable
);
ASSERT
(
pSchema
!=
NULL
);
int16_t
nversion
=
schemaVersion
(
pSchema
);
if
(
tversion
>
nversion
)
{
tsdbTrace
(
"vgId:%d table:%s tid:%d server schema version %d is older than clien version %d, try to config."
,
pRepo
->
config
.
tsdbId
,
varDataVal
(
pTable
->
name
),
pTable
->
tableId
.
tid
,
nversion
,
tversion
);
...
...
@@ -1014,7 +1017,10 @@ static int32_t tsdbInsertDataToTable(TsdbRepoT *repo, SSubmitBlk *pBlock, TSKEY
return
-
1
;
}
(
*
affectedrows
)
++
;
points
++
;
}
atomic_fetch_add_64
(
&
(
pRepo
->
stat
.
pointsWritten
),
points
*
(
pSchema
->
numOfCols
));
atomic_fetch_add_64
(
&
(
pRepo
->
stat
.
totalStorage
),
points
*
pSchema
->
vlen
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -1381,3 +1387,11 @@ uint32_t tsdbGetFileInfo(TsdbRepoT *repo, char *name, uint32_t *index, uint32_t
return
magic
;
}
void
tsdbReportStat
(
void
*
repo
,
int64_t
*
totalPoints
,
int64_t
*
totalStorage
,
int64_t
*
compStorage
){
ASSERT
(
repo
!=
NULL
);
STsdbRepo
*
pRepo
=
repo
;
*
totalPoints
=
pRepo
->
stat
.
pointsWritten
;
*
totalStorage
=
pRepo
->
stat
.
totalStorage
;
*
compStorage
=
pRepo
->
stat
.
compStorage
;
}
\ No newline at end of file
src/vnode/inc/vnodeInt.h
浏览文件 @
fe8b9e03
...
...
@@ -39,9 +39,6 @@ typedef struct {
int8_t
role
;
int64_t
version
;
// current version
int64_t
fversion
;
// version on saved data file
int64_t
totalStorage
;
//total bytes occupie
int64_t
compStorage
;
int64_t
pointsWritten
;
//total data points written
void
*
wqueue
;
void
*
rqueue
;
void
*
wal
;
...
...
src/vnode/src/vnodeMain.c
浏览文件 @
fe8b9e03
...
...
@@ -371,16 +371,18 @@ void *vnodeGetWal(void *pVnode) {
static
void
vnodeBuildVloadMsg
(
SVnodeObj
*
pVnode
,
SDMStatusMsg
*
pStatus
)
{
if
(
pVnode
->
status
==
TAOS_VN_STATUS_DELETING
)
return
;
if
(
pStatus
->
openVnodes
>=
TSDB_MAX_VNODES
)
return
;
int64_t
totalStorage
,
compStorage
,
pointsWritten
=
0
;
tsdbReportStat
(
pVnode
->
tsdb
,
&
pointsWritten
,
&
totalStorage
,
&
compStorage
);
SVnodeLoad
*
pLoad
=
&
pStatus
->
load
[
pStatus
->
openVnodes
++
];
pLoad
->
vgId
=
htonl
(
pVnode
->
vgId
);
pLoad
->
cfgVersion
=
htonl
(
pVnode
->
cfgVersion
);
pLoad
->
totalStorage
=
htobe64
(
pLoad
->
totalStorage
);
pLoad
->
compStorage
=
htobe64
(
pLoad
->
compStorage
);
pLoad
->
pointsWritten
=
htobe64
(
p
Load
->
p
ointsWritten
);
pLoad
->
totalStorage
=
htobe64
(
totalStorage
);
pLoad
->
compStorage
=
htobe64
(
compStorage
);
pLoad
->
pointsWritten
=
htobe64
(
pointsWritten
);
pLoad
->
status
=
pVnode
->
status
;
pLoad
->
role
=
pVnode
->
role
;
pLoad
->
replica
=
pVnode
->
syncCfg
.
replica
;
pLoad
->
replica
=
pVnode
->
syncCfg
.
replica
;
}
void
vnodeBuildStatusMsg
(
void
*
param
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录