Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a4ee9d7c
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1185
Star
22015
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,发现更多精彩内容 >>
提交
a4ee9d7c
编写于
3月 02, 2020
作者:
H
hzcheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor
上级
9f0c0151
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
47 addition
and
53 deletion
+47
-53
src/vnode/tsdb/inc/tsdb.h
src/vnode/tsdb/inc/tsdb.h
+1
-3
src/vnode/tsdb/inc/tsdbMeta.h
src/vnode/tsdb/inc/tsdbMeta.h
+2
-2
src/vnode/tsdb/src/tsdbMain.c
src/vnode/tsdb/src/tsdbMain.c
+28
-32
src/vnode/tsdb/src/tsdbMeta.c
src/vnode/tsdb/src/tsdbMeta.c
+16
-16
未找到文件。
src/vnode/tsdb/inc/tsdb.h
浏览文件 @
a4ee9d7c
...
@@ -37,7 +37,6 @@ typedef struct {
...
@@ -37,7 +37,6 @@ typedef struct {
// the TSDB repository configuration
// the TSDB repository configuration
typedef
struct
{
typedef
struct
{
char
*
rootDir
;
// TSDB repository root directory, TODO: need to adjust here
int32_t
tsdbId
;
int32_t
tsdbId
;
int32_t
maxTables
;
// maximum number of tables this repository can have
int32_t
maxTables
;
// maximum number of tables this repository can have
int32_t
daysPerFile
;
// day per file sharding policy
int32_t
daysPerFile
;
// day per file sharding policy
...
@@ -45,7 +44,6 @@ typedef struct {
...
@@ -45,7 +44,6 @@ typedef struct {
int32_t
maxRowsPerFileBlock
;
// maximum rows per file block
int32_t
maxRowsPerFileBlock
;
// maximum rows per file block
int32_t
keep
;
// day of data to keep
int32_t
keep
;
// day of data to keep
int64_t
maxCacheSize
;
// maximum cache size this TSDB can use
int64_t
maxCacheSize
;
// maximum cache size this TSDB can use
void
*
cachePool
;
// the cache pool the repository to use
}
STsdbCfg
;
}
STsdbCfg
;
// the TSDB repository info
// the TSDB repository info
...
@@ -89,7 +87,7 @@ typedef struct {
...
@@ -89,7 +87,7 @@ typedef struct {
*
*
* @return a TSDB repository handle on success, NULL for failure and the error number is set
* @return a TSDB repository handle on success, NULL for failure and the error number is set
*/
*/
tsdb_repo_t
*
tsdbCreateRepo
(
STsdbCfg
*
pCfg
);
tsdb_repo_t
*
tsdbCreateRepo
(
char
*
rootDir
,
STsdbCfg
*
pCfg
,
void
*
limiter
);
/**
/**
* Close and free all resources taken by the repository
* Close and free all resources taken by the repository
...
...
src/vnode/tsdb/inc/tsdbMeta.h
浏览文件 @
a4ee9d7c
...
@@ -62,7 +62,7 @@ typedef struct {
...
@@ -62,7 +62,7 @@ typedef struct {
// A map of tableName->tableId
// A map of tableName->tableId
// TODO: May use hash table
// TODO: May use hash table
void
*
pNameTableMap
;
void
*
pNameTableMap
;
}
S
MetaHandle
;
}
S
TsdbMeta
;
// ---- Operation on STable
// ---- Operation on STable
#define TSDB_TABLE_ID(pTable) ((pTable)->tableId)
#define TSDB_TABLE_ID(pTable) ((pTable)->tableId)
...
@@ -84,7 +84,7 @@ SSchema *tsdbGetTableSchema(STable *pTable);
...
@@ -84,7 +84,7 @@ SSchema *tsdbGetTableSchema(STable *pTable);
#define TSDB_GET_TABLE_OF_NAME(pHandle, name)
/* TODO */
#define TSDB_GET_TABLE_OF_NAME(pHandle, name)
/* TODO */
// Create a new meta handle with configuration
// Create a new meta handle with configuration
SMetaHandle
*
tsdbCreateMeta
Handle
(
int32_t
numOfTables
);
SMetaHandle
*
tsdbCreateMeta
(
int32_t
numOfTables
);
int32_t
tsdbFreeMetaHandle
(
SMetaHandle
*
pMetaHandle
);
int32_t
tsdbFreeMetaHandle
(
SMetaHandle
*
pMetaHandle
);
// Recover the meta handle from the file
// Recover the meta handle from the file
...
...
src/vnode/tsdb/src/tsdbMain.c
浏览文件 @
a4ee9d7c
#include <fcntl.h>
#include <pthread.h>
#include <pthread.h>
#include <stdint.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/types.h>
#include <unistd.h>
// #include "taosdef.h"
// #include "taosdef.h"
// #include "disk.h"
// #include "disk.h"
#include "tsdbFile.h"
#include "tsdb.h"
#include "tsdb.h"
#include "tsdbCache.h"
#include "tsdbCache.h"
#include "tsdbFile.h"
#include "tsdbMeta.h"
#include "tsdbMeta.h"
enum
{
enum
{
TSDB_REPO_STATE_ACTIVE
,
TSDB_REPO_STATE_CLOSED
,
TSDB_REPO_STATE_CONFIGURING
};
TSDB_REPO_STATE_ACTIVE
,
TSDB_REPO_STATE_CLOSED
,
TSDB_REPO_STATE_CONFIGURING
};
typedef
struct
_tsdb_repo
{
typedef
struct
_tsdb_repo
{
// TSDB configuration
// TSDB configuration
STsdbCfg
*
pCf
g
;
STsdbCfg
confi
g
;
// The meter meta handle of this TSDB repository
// The meter meta handle of this TSDB repository
SMetaHandle
*
tsdbMeta
;
SMetaHandle
*
tsdbMeta
;
...
@@ -37,31 +33,40 @@ typedef struct _tsdb_repo {
...
@@ -37,31 +33,40 @@ typedef struct _tsdb_repo {
pthread_mutex_t
tsdbMutex
;
pthread_mutex_t
tsdbMutex
;
// A limiter to monitor the resources used by tsdb
void
*
limiter
;
int8_t
state
;
int8_t
state
;
}
STsdbRepo
;
}
STsdbRepo
;
static
int32_t
tsdbCheckAndSetDefaultCfg
(
STsdbCfg
*
pCfg
);
static
int32_t
tsdbCreateRepoFiles
(
STsdbRepo
*
pRepo
);
#define TSDB_GET_TABLE_BY_ID(pRepo, sid) (((STSDBRepo *)pRepo)->pTableList)[sid]
#define TSDB_GET_TABLE_BY_ID(pRepo, sid) (((STSDBRepo *)pRepo)->pTableList)[sid]
#define TSDB_GET_TABLE_BY_NAME(pRepo, name)
#define TSDB_GET_TABLE_BY_NAME(pRepo, name)
#define TSDB_IS_REPO_ACTIVE(pRepo) ((pRepo)->state == TSDB_REPO_STATE_ACTIVE)
#define TSDB_IS_REPO_ACTIVE(pRepo) ((pRepo)->state == TSDB_REPO_STATE_ACTIVE)
#define TSDB_IS_REPO_CLOSED(pRepo) ((pRepo)->state == TSDB_REPO_STATE_CLOSED)
#define TSDB_IS_REPO_CLOSED(pRepo) ((pRepo)->state == TSDB_REPO_STATE_CLOSED)
tsdb_repo_t
*
tsdbCreateRepo
(
char
*
rootDir
,
STsdbCfg
*
pCfg
,
void
*
limiter
)
{
if
(
rootDir
==
NULL
)
return
NULL
;
tsdb_repo_t
*
tsdbCreateRepo
(
STsdbCfg
*
pCfg
)
{
if
(
access
(
rootDir
,
F_OK
|
R_OK
|
W_OK
)
==
-
1
)
return
NULL
;
// Check the configuration
if
(
tsdbCheckAndSetDefaultCfg
(
pCfg
)
<
0
)
{
if
(
tsdbCheckCfg
(
pCfg
)
<
0
)
{
return
NULL
;
return
NULL
;
}
}
STsdbRepo
*
pRepo
=
(
STsdbRepo
*
)
malloc
(
sizeof
(
STsdbRepo
));
STsdbRepo
*
pRepo
=
(
STsdbRepo
*
)
malloc
(
sizeof
(
STsdbRepo
));
if
(
pRepo
==
NULL
)
{
if
(
pRepo
==
NULL
)
{
// TODO: deal with error
return
NULL
;
return
NULL
;
}
}
// TODO: Initailize pMetahandle
pRepo
->
config
=
*
pCfg
;
pRepo
->
tsdbMeta
=
tsdbCreateMetaHandle
(
pCfg
->
maxTables
);
pRepo
->
limiter
=
limiter
;
pRepo
->
tsdbMeta
=
tsdbCreateMeta
(
pCfg
->
maxTables
);
if
(
pRepo
->
tsdbMeta
==
NULL
)
{
if
(
pRepo
->
tsdbMeta
==
NULL
)
{
// TODO: deal with error
// TODO: deal with error
free
(
pRepo
);
free
(
pRepo
);
...
@@ -77,11 +82,8 @@ tsdb_repo_t *tsdbCreateRepo(STsdbCfg *pCfg) {
...
@@ -77,11 +82,8 @@ tsdb_repo_t *tsdbCreateRepo(STsdbCfg *pCfg) {
return
NULL
;
return
NULL
;
}
}
// Set configuration
pRepo
->
pCfg
=
pCfg
;
// Create the Meta data file and data directory
// Create the Meta data file and data directory
if
(
tsdbCreateFiles
(
pRepo
)
<
0
)
{
if
(
tsdbCreate
Repo
Files
(
pRepo
)
<
0
)
{
// Failed to create and save files
// Failed to create and save files
tsdbFreeMetaHandle
(
pRepo
->
tsdbCache
);
tsdbFreeMetaHandle
(
pRepo
->
tsdbCache
);
free
(
pRepo
);
free
(
pRepo
);
...
@@ -110,8 +112,7 @@ int32_t tsdbDropRepo(tsdb_repo_t *repo) {
...
@@ -110,8 +112,7 @@ int32_t tsdbDropRepo(tsdb_repo_t *repo) {
}
}
tsdb_repo_t
*
tsdbOpenRepo
(
char
*
tsdbDir
)
{
tsdb_repo_t
*
tsdbOpenRepo
(
char
*
tsdbDir
)
{
if
(
access
(
tsdbDir
,
F_OK
|
W_OK
|
R_OK
)
<
0
)
{
if
(
access
(
tsdbDir
,
F_OK
|
W_OK
|
R_OK
)
<
0
)
{
return
NULL
;
return
NULL
;
}
}
...
@@ -159,7 +160,7 @@ int32_t tsdbCloseRepo(tsdb_repo_t *repo) {
...
@@ -159,7 +160,7 @@ int32_t tsdbCloseRepo(tsdb_repo_t *repo) {
int32_t
tsdbConfigRepo
(
tsdb_repo_t
*
repo
,
STsdbCfg
*
pCfg
)
{
int32_t
tsdbConfigRepo
(
tsdb_repo_t
*
repo
,
STsdbCfg
*
pCfg
)
{
STsdbRepo
*
pRepo
=
(
STsdbRepo
*
)
repo
;
STsdbRepo
*
pRepo
=
(
STsdbRepo
*
)
repo
;
pRepo
->
pCf
g
=
pCfg
;
pRepo
->
confi
g
=
pCfg
;
// TODO
// TODO
return
0
;
return
0
;
}
}
...
@@ -185,18 +186,13 @@ int32_t tsdbInsertData(tsdb_repo_t *pRepo, STableId tid, char *pData, int32_t *e
...
@@ -185,18 +186,13 @@ int32_t tsdbInsertData(tsdb_repo_t *pRepo, STableId tid, char *pData, int32_t *e
// TODO
// TODO
}
}
// Check the correctness of the TSDB configuration
// Check the configuration and set default options
static
int32_t
tsdbCheckCfg
(
STsdbCfg
*
pCfg
)
{
static
int32_t
tsdbCheckAndSetDefaultCfg
(
STsdbCfg
*
pCfg
)
{
if
(
pCfg
->
rootDir
==
NULL
)
return
-
1
;
if
(
access
(
pCfg
->
rootDir
,
F_OK
|
R_OK
|
W_OK
)
==
-
1
)
{
return
-
1
;
}
// TODO
// TODO
return
0
;
return
0
;
}
}
static
int32_t
tsdbCreateFiles
(
STsdbRepo
*
pRepo
)
{
static
int32_t
tsdbCreate
Repo
Files
(
STsdbRepo
*
pRepo
)
{
// TODO
// TODO
}
}
...
...
src/vnode/tsdb/src/tsdbMeta.c
浏览文件 @
a4ee9d7c
...
@@ -4,39 +4,39 @@
...
@@ -4,39 +4,39 @@
#include "tsdb.h"
#include "tsdb.h"
#include "tsdbMeta.h"
#include "tsdbMeta.h"
S
MetaHandle
*
tsdbCreateMetaHandle
(
int32_t
n
umOfTables
)
{
S
TsdbMeta
*
tsdbCreateMeta
(
int32_t
maxN
umOfTables
)
{
S
MetaHandle
*
pMetahandle
=
(
SMetaHandle
*
)
malloc
(
sizeof
(
SMetaHandle
));
S
TsdbMeta
*
pMeta
=
(
STsdbMeta
*
)
malloc
(
sizeof
(
STsdbMeta
));
if
(
pMeta
handle
==
NULL
)
{
if
(
pMeta
==
NULL
)
{
return
NULL
;
return
NULL
;
}
}
pMeta
handle
->
numOfTables
=
0
;
pMeta
->
numOfTables
=
0
;
pMeta
handle
->
numOfSuperTables
=
0
;
pMeta
->
numOfSuperTables
=
0
;
pMeta
handle
->
pTables
=
calloc
(
sizeof
(
STable
*
),
numOfTables
);
pMeta
->
pTables
=
calloc
(
sizeof
(
STable
*
),
numOfTables
);
if
(
pMeta
handle
->
pTables
==
NULL
)
{
if
(
pMeta
->
pTables
==
NULL
)
{
free
(
pMeta
handle
);
free
(
pMeta
);
return
NULL
;
return
NULL
;
}
}
// TODO : initialize the map
// TODO : initialize the map
// pMetahandle->pNameTableMap = ;
// pMetahandle->pNameTableMap = ;
if
(
pMeta
handle
->
pNameTableMap
==
NULL
)
{
if
(
pMeta
->
pNameTableMap
==
NULL
)
{
free
(
pMeta
handle
->
pTables
);
free
(
pMeta
->
pTables
);
free
(
pMeta
handle
);
free
(
pMeta
);
return
NULL
;
return
NULL
;
}
}
return
pMeta
handle
;
return
pMeta
;
}
}
int32_t
tsdbFreeMetaHandle
(
S
MetaHandle
*
pMetaHandle
)
{
int32_t
tsdbFreeMetaHandle
(
S
TsdbMeta
*
pMetaHandle
)
{
// TODO
// TODO
}
}
static
int32_t
tsdbCheckTableCfg
(
STableCfg
*
pCfg
)
{
return
0
;
}
static
int32_t
tsdbCheckTableCfg
(
STableCfg
*
pCfg
)
{
return
0
;
}
int32_t
tsdbCreateTableImpl
(
S
MetaHandle
*
pHandle
,
STableCfg
*
pCfg
)
{
int32_t
tsdbCreateTableImpl
(
S
TsdbMeta
*
pHandle
,
STableCfg
*
pCfg
)
{
if
(
tsdbCheckTableCfg
(
pCfg
)
<
0
)
{
if
(
tsdbCheckTableCfg
(
pCfg
)
<
0
)
{
return
-
1
;
return
-
1
;
}
}
...
@@ -53,10 +53,10 @@ int32_t tsdbCreateTableImpl(SMetaHandle *pHandle, STableCfg *pCfg) {
...
@@ -53,10 +53,10 @@ int32_t tsdbCreateTableImpl(SMetaHandle *pHandle, STableCfg *pCfg) {
return
0
;
return
0
;
}
}
S
MetaHandle
*
tsdbOpenMetaHandle
(
char
*
tsdbDir
)
{
S
TsdbMeta
*
tsdbOpenMetaHandle
(
char
*
tsdbDir
)
{
// Open meta file for reading
// Open meta file for reading
S
MetaHandle
*
pHandle
=
(
SMetaHandle
*
)
malloc
(
sizeof
(
SMetaHandle
));
S
TsdbMeta
*
pHandle
=
(
STsdbMeta
*
)
malloc
(
sizeof
(
STsdbMeta
));
if
(
pHandle
==
NULL
)
{
if
(
pHandle
==
NULL
)
{
return
NULL
;
return
NULL
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录