Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
63a68154
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看板
提交
63a68154
编写于
1月 07, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more refact
上级
73254132
变更
9
展开全部
隐藏空白更改
内联
并排
Showing
9 changed file
with
54 addition
and
944 deletion
+54
-944
include/dnode/vnode/tsdb2/tsdb.h
include/dnode/vnode/tsdb2/tsdb.h
+14
-12
source/dnode/vnode/tsdb2/inc/tsdbCompact.h
source/dnode/vnode/tsdb2/inc/tsdbCompact.h
+10
-10
source/dnode/vnode/tsdb2/inc/tsdbHealth.h
source/dnode/vnode/tsdb2/inc/tsdbHealth.h
+0
-28
source/dnode/vnode/tsdb2/src/tsdbCompact.c
source/dnode/vnode/tsdb2/src/tsdbCompact.c
+3
-0
source/dnode/vnode/tsdb2/src/tsdbFile.c
source/dnode/vnode/tsdb2/src/tsdbFile.c
+3
-3
source/dnode/vnode/tsdb2/src/tsdbHealth.c
source/dnode/vnode/tsdb2/src/tsdbHealth.c
+0
-102
source/dnode/vnode/tsdb2/src/tsdbMain.c
source/dnode/vnode/tsdb2/src/tsdbMain.c
+24
-24
source/dnode/vnode/tsdb2/src/tsdbScan.c
source/dnode/vnode/tsdb2/src/tsdbScan.c
+0
-38
source/dnode/vnode/tsdb2/src/tsdbSync.c
source/dnode/vnode/tsdb2/src/tsdbSync.c
+0
-727
未找到文件。
include/dnode/vnode/tsdb2/tsdb.h
浏览文件 @
63a68154
...
...
@@ -102,8 +102,8 @@ typedef struct STsdb STsdb;
STsdbCfg
*
tsdbGetCfg
(
const
STsdb
*
repo
);
// --------- TSDB REPOSITORY DEFINITION
int32_t
tsdbCreateRepo
(
int
repoid
);
int32_t
tsdbDropRepo
(
int
repoid
);
//
int32_t tsdbCreateRepo(int repoid);
//
int32_t tsdbDropRepo(int repoid);
STsdb
*
tsdbOpen
(
STsdbCfg
*
pCfg
,
STsdbAppH
*
pAppH
);
int
tsdbClose
(
STsdb
*
repo
,
int
toCommit
);
int32_t
tsdbConfigRepo
(
STsdb
*
repo
,
STsdbCfg
*
pCfg
);
...
...
@@ -221,6 +221,7 @@ typedef struct SMemRef {
SMemSnapshot
snapshot
;
}
SMemRef
;
#if 0
typedef struct SFileBlockInfo {
int32_t numBlocksOfStep;
} SFileBlockInfo;
...
...
@@ -418,20 +419,21 @@ void tsdbSwitchTable(TsdbQueryHandleT pQueryHandle);
int tsdbSyncSend(void *pRepo, SOCKET socketFd);
int tsdbSyncRecv(void *pRepo, SOCKET socketFd);
// For TSDB Compact
int
tsdbCompact
(
STsdb
*
pRepo
);
//
//
For TSDB Compact
//
int tsdbCompact(STsdb *pRepo);
// For TSDB Health Monitor
// no problem return true
bool
tsdbNoProblem
(
STsdb
*
pRepo
);
// unit of walSize: MB
int
tsdbCheckWal
(
STsdb
*
pRepo
,
uint32_t
walSize
);
//
//
no problem return true
//
bool tsdbNoProblem(STsdb *pRepo);
//
//
unit of walSize: MB
//
int tsdbCheckWal(STsdb *pRepo, uint32_t walSize);
// for json tag
void
*
getJsonTagValueElment
(
void
*
data
,
char
*
key
,
int32_t
keyLen
,
char
*
out
,
int16_t
bytes
);
void
getJsonTagValueAll
(
void
*
data
,
void
*
dst
,
int16_t
bytes
);
char
*
parseTagDatatoJson
(
void
*
p
);
// // for json tag
// void *getJsonTagValueElment(void *data, char *key, int32_t keyLen, char *out, int16_t bytes);
// void getJsonTagValueAll(void *data, void *dst, int16_t bytes);
// char *parseTagDatatoJson(void *p);
#endif
#ifdef __cplusplus
}
...
...
source/dnode/vnode/tsdb2/inc/tsdbCompact.h
浏览文件 @
63a68154
...
...
@@ -12,17 +12,17 @@
* 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_TSDB_COMPACT_H_
#define _TD_TSDB_COMPACT_H_
//
#ifndef _TD_TSDB_COMPACT_H_
//
#define _TD_TSDB_COMPACT_H_
#ifdef __cplusplus
extern
"C"
{
#endif
//
#ifdef __cplusplus
//
extern "C" {
//
#endif
void
*
tsdbCompactImpl
(
STsdb
*
pRepo
);
//
void *tsdbCompactImpl(STsdb *pRepo);
#ifdef __cplusplus
}
#endif
//
#ifdef __cplusplus
//
}
//
#endif
#endif
/* _TD_TSDB_COMPACT_H_ */
\ No newline at end of file
// #endif /* _TD_TSDB_COMPACT_H_ */
\ No newline at end of file
source/dnode/vnode/tsdb2/inc/tsdbHealth.h
已删除
100644 → 0
浏览文件 @
73254132
/*
* 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_TSDB_HEALTH_H_
// #define _TD_TSDB_HEALTH_H_
// #include "os.h"
// #include "tsdb.h"
// bool tsdbUrgeQueryFree(STsdbRepo* pRepo);
// int32_t tsdbInsertNewBlock(STsdbRepo* pRepo);
// bool tsdbIdleMemEnough();
// bool tsdbAllowNewBlock(STsdbRepo* pRepo);
// #endif /* _TD_TSDB_BUFFER_H_ */
source/dnode/vnode/tsdb2/src/tsdbCompact.c
浏览文件 @
63a68154
...
...
@@ -12,6 +12,8 @@
* 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/>.
*/
#if 0
#include "tsdbint.h"
typedef struct {
...
...
@@ -538,3 +540,4 @@ static int tsdbCompactMeta(STsdb *pRepo) {
return 0;
}
#endif
\ No newline at end of file
source/dnode/vnode/tsdb2/src/tsdbFile.c
浏览文件 @
63a68154
...
...
@@ -217,7 +217,7 @@ int tsdbScanAndTryFixMFile(STsdb *pRepo) {
return
-
1
;
}
if
(
taosFtruncate
(
mf
.
fd
,
mf
.
info
.
size
)
<
0
)
{
if
(
taosFtruncate
File
(
mf
.
fd
,
mf
.
info
.
size
)
<
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
tsdbCloseMFile
(
&
mf
);
return
-
1
;
...
...
@@ -276,7 +276,7 @@ static int tsdbRollBackMFile(SMFile *pMFile) {
return
-
1
;
}
if
(
taosFtruncate
(
TSDB_FILE_FD
(
&
mf
),
pMFile
->
info
.
size
)
<
0
)
{
if
(
taosFtruncate
File
(
TSDB_FILE_FD
(
&
mf
),
pMFile
->
info
.
size
)
<
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
tsdbCloseMFile
(
&
mf
);
return
-
1
;
...
...
@@ -459,7 +459,7 @@ static int tsdbScanAndTryFixDFile(STsdb *pRepo, SDFile *pDFile) {
return
-
1
;
}
if
(
taosFtruncate
(
df
.
fd
,
df
.
info
.
size
)
<
0
)
{
if
(
taosFtruncate
File
(
df
.
fd
,
df
.
info
.
size
)
<
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
tsdbCloseDFile
(
&
df
);
return
-
1
;
...
...
source/dnode/vnode/tsdb2/src/tsdbHealth.c
已删除
100644 → 0
浏览文件 @
73254132
/*
* 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/>.
*/
#if 0
#include "tsdbHealth.h"
#include "os.h"
#include "query.h"
#include "tarray.h"
#include "tglobal.h"
#include "tlist.h"
#include "tmsg.h"
#include "tsdbBuffer.h"
#include "tsdbLog.h"
#include "tsdbint.h"
#include "tthread.h"
#include "ttimer.h"
// return malloc new block count
int32_t tsdbInsertNewBlock(STsdbRepo* pRepo) {
STsdbBufPool* pPool = pRepo->pPool;
int32_t cnt = 0;
if (tsdbAllowNewBlock(pRepo)) {
STsdbBufBlock* pBufBlock = tsdbNewBufBlock(pPool->bufBlockSize);
if (pBufBlock) {
if (tdListAppend(pPool->bufBlockList, (void*)(&pBufBlock)) < 0) {
// append error
tsdbFreeBufBlock(pBufBlock);
} else {
pPool->nElasticBlocks++;
cnt++;
}
}
}
return cnt;
}
// switch anther thread to run
void* cbKillQueryFree(void* param) {
STsdbRepo* pRepo = (STsdbRepo*)param;
// vnode
if (pRepo->appH.notifyStatus) {
pRepo->appH.notifyStatus(pRepo->appH.appH, TSDB_STATUS_COMMIT_NOBLOCK, TSDB_CODE_SUCCESS);
}
// free
if (pRepo->pthread) {
void* p = pRepo->pthread;
pRepo->pthread = NULL;
free(p);
}
return NULL;
}
// return true do free , false do nothing
bool tsdbUrgeQueryFree(STsdbRepo* pRepo) {
// check previous running
if (pRepo->pthread && taosThreadRunning(pRepo->pthread)) {
tsdbWarn("vgId:%d pre urge thread is runing. nBlocks=%d nElasticBlocks=%d", REPO_ID(pRepo),
pRepo->pPool->nBufBlocks, pRepo->pPool->nElasticBlocks);
return false;
}
// create new
pRepo->pthread = taosCreateThread(cbKillQueryFree, pRepo);
if (pRepo->pthread == NULL) {
tsdbError("vgId:%d create urge thread error.", REPO_ID(pRepo));
return false;
}
return true;
}
bool tsdbAllowNewBlock(STsdbRepo* pRepo) {
int32_t nMaxElastic = pRepo->config.totalBlocks / 3;
STsdbBufPool* pPool = pRepo->pPool;
if (pPool->nElasticBlocks >= nMaxElastic) {
tsdbWarn("vgId:%d tsdbAllowNewBlock return fasle. nElasticBlock(%d) >= MaxElasticBlocks(%d)", REPO_ID(pRepo),
pPool->nElasticBlocks, nMaxElastic);
return false;
}
return true;
}
bool tsdbNoProblem(STsdbRepo* pRepo) {
if (listNEles(pRepo->pPool->bufBlockList) == 0) return false;
return true;
}
#endif
\ No newline at end of file
source/dnode/vnode/tsdb2/src/tsdbMain.c
浏览文件 @
63a68154
...
...
@@ -32,36 +32,36 @@ static void tsdbStopStream(STsdb *pRepo);
static
int
tsdbRestoreLastColumns
(
STsdb
*
pRepo
,
STable
*
pTable
,
SReadH
*
pReadh
);
static
int
tsdbRestoreLastRow
(
STsdb
*
pRepo
,
STable
*
pTable
,
SReadH
*
pReadh
,
SBlockIdx
*
pIdx
);
// Function declaration
int32_t
tsdbCreateRepo
(
int
repoid
)
{
char
tsdbDir
[
TSDB_FILENAME_LEN
]
=
"
\0
"
;
char
dataDir
[
TSDB_FILENAME_LEN
]
=
"
\0
"
;
tsdbGetRootDir
(
repoid
,
tsdbDir
);
if
(
tfsMkdir
(
tsdbDir
)
<
0
)
{
goto
_err
;
}
//
//
Function declaration
//
int32_t tsdbCreateRepo(int repoid) {
//
char tsdbDir[TSDB_FILENAME_LEN] = "\0";
//
char dataDir[TSDB_FILENAME_LEN] = "\0";
//
tsdbGetRootDir(repoid, tsdbDir);
//
if (tfsMkdir(tsdbDir) < 0) {
//
goto _err;
//
}
tsdbGetDataDir
(
repoid
,
dataDir
);
if
(
tfsMkdir
(
dataDir
)
<
0
)
{
goto
_err
;
}
//
tsdbGetDataDir(repoid, dataDir);
//
if (tfsMkdir(dataDir) < 0) {
//
goto _err;
//
}
// TODO: need to create current file with nothing in
//
// TODO: need to create current file with nothing in
return
0
;
//
return 0;
_err:
tsdbError
(
"vgId:%d failed to create TSDB repository since %s"
,
repoid
,
tstrerror
(
terrno
));
return
-
1
;
}
//
_err:
//
tsdbError("vgId:%d failed to create TSDB repository since %s", repoid, tstrerror(terrno));
//
return -1;
//
}
int32_t
tsdbDropRepo
(
int
repoid
)
{
char
tsdbDir
[
TSDB_FILENAME_LEN
]
=
"
\0
"
;
//
int32_t tsdbDropRepo(int repoid) {
//
char tsdbDir[TSDB_FILENAME_LEN] = "\0";
tsdbGetRootDir
(
repoid
,
tsdbDir
);
return
tfsRmdir
(
tsdbDir
);
}
//
tsdbGetRootDir(repoid, tsdbDir);
//
return tfsRmdir(tsdbDir);
//
}
STsdb
*
tsdbOpen
(
STsdbCfg
*
pCfg
,
STsdbAppH
*
pAppH
)
{
STsdb
*
pRepo
;
...
...
source/dnode/vnode/tsdb2/src/tsdbScan.c
已删除
100644 → 0
浏览文件 @
73254132
/*
* 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/>.
*/
#include "tsdbint.h"
#if 0
#ifndef _TSDB_PLUGINS
int tsdbScanFGroup(STsdbScanHandle* pScanHandle, char* rootDir, int fid) { return 0; }
STsdbScanHandle* tsdbNewScanHandle() { return NULL; }
void tsdbSetScanLogStream(STsdbScanHandle* pScanHandle, FILE* fLogStream) {}
int tsdbSetAndOpenScanFile(STsdbScanHandle* pScanHandle, char* rootDir, int fid) { return 0; }
int tsdbScanSBlockIdx(STsdbScanHandle* pScanHandle) { return 0; }
int tsdbScanSBlock(STsdbScanHandle* pScanHandle, int idx) { return 0; }
int tsdbCloseScanFile(STsdbScanHandle* pScanHandle) { return 0; }
void tsdbFreeScanHandle(STsdbScanHandle* pScanHandle) {}
#endif
#endif
\ No newline at end of file
source/dnode/vnode/tsdb2/src/tsdbSync.c
已删除
100644 → 0
浏览文件 @
73254132
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录