Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
7a795927
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
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,发现更多精彩内容 >>
未验证
提交
7a795927
编写于
4月 16, 2022
作者:
H
Hongze Cheng
提交者:
GitHub
4月 16, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #11567 from taosdata/feature/vnode_refact1
refactor: vnode
上级
5ac599b3
cb744ab6
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
94 addition
and
164 deletion
+94
-164
source/dnode/vnode/CMakeLists.txt
source/dnode/vnode/CMakeLists.txt
+2
-3
source/dnode/vnode/src/inc/meta.h
source/dnode/vnode/src/inc/meta.h
+16
-30
source/dnode/vnode/src/inc/vnd.h
source/dnode/vnode/src/inc/vnd.h
+6
-6
source/dnode/vnode/src/meta/metaMain.c
source/dnode/vnode/src/meta/metaMain.c
+0
-111
source/dnode/vnode/src/meta/metaOpen.c
source/dnode/vnode/src/meta/metaOpen.c
+66
-0
source/dnode/vnode/src/vnd/vnodeCfg.c
source/dnode/vnode/src/vnd/vnodeCfg.c
+0
-7
source/dnode/vnode/src/vnd/vnodeOpen.c
source/dnode/vnode/src/vnd/vnodeOpen.c
+4
-7
未找到文件。
source/dnode/vnode/CMakeLists.txt
浏览文件 @
7a795927
...
@@ -18,12 +18,11 @@ target_sources(
...
@@ -18,12 +18,11 @@ target_sources(
"src/vnd/vnodeSvr.c"
"src/vnd/vnodeSvr.c"
# meta
# meta
# "src/meta/metaBDBImpl
.c"
"src/meta/metaOpen
.c"
"src/meta/metaIdx.c"
"src/meta/metaIdx.c"
"src/meta/metaMain.c"
"src/meta/metaTable.c"
"src/meta/metaTable.c"
"src/meta/metaTbUid.c"
"src/meta/metaTDBImpl.c"
"src/meta/metaTDBImpl.c"
# "src/meta/metaBDBImpl.c"
# tsdb
# tsdb
"src/tsdb/tsdbTDBImpl.c"
"src/tsdb/tsdbTDBImpl.c"
...
...
source/dnode/vnode/src/inc/meta.h
浏览文件 @
7a795927
...
@@ -20,7 +20,6 @@
...
@@ -20,7 +20,6 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
typedef
struct
SMetaCache
SMetaCache
;
typedef
struct
SMetaIdx
SMetaIdx
;
typedef
struct
SMetaIdx
SMetaIdx
;
typedef
struct
SMetaDB
SMetaDB
;
typedef
struct
SMetaDB
SMetaDB
;
typedef
struct
SMCtbCursor
SMCtbCursor
;
typedef
struct
SMCtbCursor
SMCtbCursor
;
...
@@ -36,13 +35,22 @@ typedef struct SMSmaCursor SMSmaCursor;
...
@@ -36,13 +35,22 @@ typedef struct SMSmaCursor SMSmaCursor;
#define metaTrace(...) do { if (metaDebugFlag & DEBUG_TRACE) { taosPrintLog("META ", DEBUG_TRACE, metaDebugFlag, __VA_ARGS__); }} while(0)
#define metaTrace(...) do { if (metaDebugFlag & DEBUG_TRACE) { taosPrintLog("META ", DEBUG_TRACE, metaDebugFlag, __VA_ARGS__); }} while(0)
// clang-format on
// clang-format on
// metaOpen ==================
int
metaOpen
(
SVnode
*
pVnode
,
SMeta
**
ppMeta
);
int
metaClose
(
SMeta
*
pMeta
);
// metaIdx ==================
int
metaOpenIdx
(
SMeta
*
pMeta
);
void
metaCloseIdx
(
SMeta
*
pMeta
);
int
metaSaveTableToIdx
(
SMeta
*
pMeta
,
const
STbCfg
*
pTbOptions
);
int
metaRemoveTableFromIdx
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
static
FORCE_INLINE
tb_uid_t
metaGenerateUid
(
SMeta
*
pMeta
)
{
return
tGenIdPI64
();
}
#define META_SUPER_TABLE TD_SUPER_TABLE
#define META_SUPER_TABLE TD_SUPER_TABLE
#define META_CHILD_TABLE TD_CHILD_TABLE
#define META_CHILD_TABLE TD_CHILD_TABLE
#define META_NORMAL_TABLE TD_NORMAL_TABLE
#define META_NORMAL_TABLE TD_NORMAL_TABLE
SMeta
*
metaOpen
(
const
char
*
path
,
SMemAllocatorFactory
*
pMAF
);
void
metaClose
(
SMeta
*
pMeta
);
void
metaRemove
(
const
char
*
path
);
int
metaCreateTable
(
SMeta
*
pMeta
,
STbCfg
*
pTbCfg
);
int
metaCreateTable
(
SMeta
*
pMeta
,
STbCfg
*
pTbCfg
);
int
metaDropTable
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
int
metaDropTable
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
int
metaCommit
(
SMeta
*
pMeta
);
int
metaCommit
(
SMeta
*
pMeta
);
...
@@ -71,27 +79,8 @@ int metaRemoveTableFromDb(SMeta* pMeta, tb_uid_t uid);
...
@@ -71,27 +79,8 @@ int metaRemoveTableFromDb(SMeta* pMeta, tb_uid_t uid);
int
metaSaveSmaToDB
(
SMeta
*
pMeta
,
STSma
*
pTbCfg
);
int
metaSaveSmaToDB
(
SMeta
*
pMeta
,
STSma
*
pTbCfg
);
int
metaRemoveSmaFromDb
(
SMeta
*
pMeta
,
int64_t
indexUid
);
int
metaRemoveSmaFromDb
(
SMeta
*
pMeta
,
int64_t
indexUid
);
// SMetaCache
int
metaOpenCache
(
SMeta
*
pMeta
);
void
metaCloseCache
(
SMeta
*
pMeta
);
// SMetaIdx
// SMetaIdx
int
metaOpenIdx
(
SMeta
*
pMeta
);
void
metaCloseIdx
(
SMeta
*
pMeta
);
int
metaSaveTableToIdx
(
SMeta
*
pMeta
,
const
STbCfg
*
pTbOptions
);
int
metaRemoveTableFromIdx
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
// STbUidGnrt
typedef
struct
STbUidGenerator
{
tb_uid_t
nextUid
;
}
STbUidGenerator
;
// STableUidGenerator
int
metaOpenUidGnrt
(
SMeta
*
pMeta
);
void
metaCloseUidGnrt
(
SMeta
*
pMeta
);
// tb_uid_t
#define IVLD_TB_UID 0
tb_uid_t
metaGenerateUid
(
SMeta
*
pMeta
);
tb_uid_t
metaGenerateUid
(
SMeta
*
pMeta
);
struct
SMeta
{
struct
SMeta
{
...
@@ -99,9 +88,6 @@ struct SMeta {
...
@@ -99,9 +88,6 @@ struct SMeta {
SVnode
*
pVnode
;
SVnode
*
pVnode
;
SMetaDB
*
pDB
;
SMetaDB
*
pDB
;
SMetaIdx
*
pIdx
;
SMetaIdx
*
pIdx
;
SMetaCache
*
pCache
;
STbUidGenerator
uidGnrt
;
SMemAllocatorFactory
*
pmaf
;
};
};
#ifdef __cplusplus
#ifdef __cplusplus
...
...
source/dnode/vnode/src/inc/vnd.h
浏览文件 @
7a795927
...
@@ -44,6 +44,11 @@ int vnodeGetTableMeta(SVnode* pVnode, SRpcMsg* pMsg);
...
@@ -44,6 +44,11 @@ int vnodeGetTableMeta(SVnode* pVnode, SRpcMsg* pMsg);
int
vnodeSaveInfo
(
const
char
*
dir
,
const
SVnodeInfo
*
pCfg
);
int
vnodeSaveInfo
(
const
char
*
dir
,
const
SVnodeInfo
*
pCfg
);
int
vnodeCommitInfo
(
const
char
*
dir
,
const
SVnodeInfo
*
pInfo
);
int
vnodeCommitInfo
(
const
char
*
dir
,
const
SVnodeInfo
*
pInfo
);
int
vnodeLoadInfo
(
const
char
*
dir
,
SVnodeInfo
*
pInfo
);
int
vnodeLoadInfo
(
const
char
*
dir
,
SVnodeInfo
*
pInfo
);
int
vnodeBegin
(
SVnode
*
pVnode
,
int
option
);
int
vnodeSyncCommit
(
SVnode
*
pVnode
);
int
vnodeAsyncCommit
(
SVnode
*
pVnode
);
#define vnodeShouldCommit vnodeBufPoolIsFull
#if 1
#if 1
// SVBufPool
// SVBufPool
...
@@ -85,12 +90,7 @@ bool vmaIsFull(SVMemAllocator* pVMA);
...
@@ -85,12 +90,7 @@ bool vmaIsFull(SVMemAllocator* pVMA);
extern
const
SVnodeCfg
vnodeCfgDefault
;
extern
const
SVnodeCfg
vnodeCfgDefault
;
int
vnodeCheckCfg
(
const
SVnodeCfg
*
);
int
vnodeCheckCfg
(
const
SVnodeCfg
*
);
void
vnodeOptionsCopy
(
SVnodeCfg
*
pDest
,
const
SVnodeCfg
*
pSrc
);
// For commit
#define vnodeShouldCommit vnodeBufPoolIsFull
int
vnodeSyncCommit
(
SVnode
*
pVnode
);
int
vnodeAsyncCommit
(
SVnode
*
pVnode
);
#endif
#endif
#ifdef __cplusplus
#ifdef __cplusplus
...
...
source/dnode/vnode/src/meta/metaMain.c
已删除
100644 → 0
浏览文件 @
5ac599b3
/*
* 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 "tcoding.h"
#include "vnodeInt.h"
static
SMeta
*
metaNew
(
const
char
*
path
,
SMemAllocatorFactory
*
pMAF
);
static
void
metaFree
(
SMeta
*
pMeta
);
static
int
metaOpenImpl
(
SMeta
*
pMeta
);
static
void
metaCloseImpl
(
SMeta
*
pMeta
);
SMeta
*
metaOpen
(
const
char
*
path
,
SMemAllocatorFactory
*
pMAF
)
{
SMeta
*
pMeta
=
NULL
;
// Allocate handle
pMeta
=
metaNew
(
path
,
pMAF
);
if
(
pMeta
==
NULL
)
{
// TODO: handle error
return
NULL
;
}
// Create META path (TODO)
taosMkDir
(
path
);
// Open meta
if
(
metaOpenImpl
(
pMeta
)
<
0
)
{
metaFree
(
pMeta
);
return
NULL
;
}
return
pMeta
;
}
void
metaClose
(
SMeta
*
pMeta
)
{
if
(
pMeta
)
{
metaCloseImpl
(
pMeta
);
metaFree
(
pMeta
);
}
}
void
metaRemove
(
const
char
*
path
)
{
taosRemoveDir
(
path
);
}
/* ------------------------ STATIC METHODS ------------------------ */
static
SMeta
*
metaNew
(
const
char
*
path
,
SMemAllocatorFactory
*
pMAF
)
{
SMeta
*
pMeta
;
size_t
psize
=
strlen
(
path
);
pMeta
=
(
SMeta
*
)
taosMemoryCalloc
(
1
,
sizeof
(
*
pMeta
));
if
(
pMeta
==
NULL
)
{
return
NULL
;
}
pMeta
->
path
=
strdup
(
path
);
if
(
pMeta
->
path
==
NULL
)
{
metaFree
(
pMeta
);
return
NULL
;
}
return
pMeta
;
};
static
void
metaFree
(
SMeta
*
pMeta
)
{
if
(
pMeta
)
{
taosMemoryFreeClear
(
pMeta
->
path
);
taosMemoryFree
(
pMeta
);
}
}
static
int
metaOpenImpl
(
SMeta
*
pMeta
)
{
// Open meta db
if
(
metaOpenDB
(
pMeta
)
<
0
)
{
// TODO: handle error
metaCloseImpl
(
pMeta
);
return
-
1
;
}
// Open meta index
if
(
metaOpenIdx
(
pMeta
)
<
0
)
{
// TODO: handle error
metaCloseImpl
(
pMeta
);
return
-
1
;
}
// Open meta table uid generator
if
(
metaOpenUidGnrt
(
pMeta
)
<
0
)
{
// TODO: handle error
metaCloseImpl
(
pMeta
);
return
-
1
;
}
return
0
;
}
static
void
metaCloseImpl
(
SMeta
*
pMeta
)
{
metaCloseUidGnrt
(
pMeta
);
metaCloseIdx
(
pMeta
);
metaCloseDB
(
pMeta
);
}
\ No newline at end of file
source/dnode/vnode/src/meta/meta
TbUid
.c
→
source/dnode/vnode/src/meta/meta
Open
.c
浏览文件 @
7a795927
...
@@ -15,16 +15,52 @@
...
@@ -15,16 +15,52 @@
#include "vnodeInt.h"
#include "vnodeInt.h"
int
metaOpenUidGnrt
(
SMeta
*
pMeta
)
{
int
metaOpen
(
SVnode
*
pVnode
,
SMeta
**
ppMeta
)
{
// Init a generator
SMeta
*
pMeta
=
NULL
;
pMeta
->
uidGnrt
.
nextUid
=
IVLD_TB_UID
;
int
slen
;
*
ppMeta
=
NULL
;
// create handle
slen
=
strlen
(
tfsGetPrimaryPath
(
pVnode
->
pTfs
))
+
strlen
(
pVnode
->
path
)
+
strlen
(
VNODE_META_DIR
)
+
3
;
if
((
pMeta
=
taosMemoryCalloc
(
1
,
sizeof
(
*
pMeta
)
+
slen
))
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
pMeta
->
path
=
(
char
*
)
&
pMeta
[
1
];
sprintf
(
pMeta
->
path
,
"%s%s%s%s%s"
,
tfsGetPrimaryPath
(
pVnode
->
pTfs
),
TD_DIRSEP
,
pVnode
->
path
,
TD_DIRSEP
,
VNODE_META_DIR
);
pMeta
->
pVnode
=
pVnode
;
// create path if not created yet
taosMkDir
(
pMeta
->
path
);
// open meta
if
(
metaOpenDB
(
pMeta
)
<
0
)
{
goto
_err
;
}
if
(
metaOpenIdx
(
pMeta
)
<
0
)
{
goto
_err
;
}
*
ppMeta
=
pMeta
;
return
0
;
return
0
;
}
void
metaCloseUidGnrt
(
SMeta
*
pMeta
)
{
/* TODO */
_err:
if
(
pMeta
->
pIdx
)
metaCloseIdx
(
pMeta
);
if
(
pMeta
->
pDB
)
metaCloseDB
(
pMeta
);
taosMemoryFree
(
pMeta
);
return
-
1
;
}
}
tb_uid_t
metaGenerateUid
(
SMeta
*
pMeta
)
{
int
metaClose
(
SMeta
*
pMeta
)
{
// Generate a new table UID
if
(
pMeta
)
{
return
tGenIdPI64
();
metaCloseIdx
(
pMeta
);
metaCloseDB
(
pMeta
);
taosMemoryFree
(
pMeta
);
}
return
0
;
}
}
\ No newline at end of file
source/dnode/vnode/src/vnd/vnodeCfg.c
浏览文件 @
7a795927
...
@@ -23,11 +23,6 @@ int vnodeCheckCfg(const SVnodeCfg *pCfg) {
...
@@ -23,11 +23,6 @@ int vnodeCheckCfg(const SVnodeCfg *pCfg) {
return
0
;
return
0
;
}
}
#if 1 //======================================================================
void
vnodeOptionsCopy
(
SVnodeCfg
*
pDest
,
const
SVnodeCfg
*
pSrc
)
{
memcpy
((
void
*
)
pDest
,
(
void
*
)
pSrc
,
sizeof
(
SVnodeCfg
));
}
int
vnodeValidateTableHash
(
SVnodeCfg
*
pVnodeOptions
,
char
*
tableFName
)
{
int
vnodeValidateTableHash
(
SVnodeCfg
*
pVnodeOptions
,
char
*
tableFName
)
{
uint32_t
hashValue
=
0
;
uint32_t
hashValue
=
0
;
...
@@ -47,5 +42,3 @@ int vnodeValidateTableHash(SVnodeCfg *pVnodeOptions, char *tableFName) {
...
@@ -47,5 +42,3 @@ int vnodeValidateTableHash(SVnodeCfg *pVnodeOptions, char *tableFName) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
#endif
\ No newline at end of file
source/dnode/vnode/src/vnd/vnodeOpen.c
浏览文件 @
7a795927
...
@@ -65,14 +65,15 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
...
@@ -65,14 +65,15 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
}
}
// create handle
// create handle
pVnode
=
(
SVnode
*
)
taosMemoryCalloc
(
1
,
sizeof
(
*
pVnode
));
pVnode
=
(
SVnode
*
)
taosMemoryCalloc
(
1
,
sizeof
(
*
pVnode
)
+
strlen
(
path
)
+
1
);
if
(
pVnode
==
NULL
)
{
if
(
pVnode
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
vError
(
"vgId: %d failed to open vnode since %s"
,
info
.
config
.
vgId
,
tstrerror
(
terrno
));
vError
(
"vgId: %d failed to open vnode since %s"
,
info
.
config
.
vgId
,
tstrerror
(
terrno
));
return
NULL
;
return
NULL
;
}
}
pVnode
->
path
=
strdup
(
dir
);
pVnode
->
path
=
(
char
*
)
&
pVnode
[
1
];
strcpy
(
pVnode
->
path
,
path
);
pVnode
->
config
=
info
.
config
;
pVnode
->
config
=
info
.
config
;
pVnode
->
state
.
committed
=
info
.
state
.
committed
;
pVnode
->
state
.
committed
=
info
.
state
.
committed
;
pVnode
->
state
.
processed
=
pVnode
->
state
.
applied
=
pVnode
->
state
.
committed
;
pVnode
->
state
.
processed
=
pVnode
->
state
.
applied
=
pVnode
->
state
.
committed
;
...
@@ -88,9 +89,7 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
...
@@ -88,9 +89,7 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
}
}
// open meta
// open meta
sprintf
(
tdir
,
"%s%s%s"
,
dir
,
TD_DIRSEP
,
VNODE_META_DIR
);
if
(
metaOpen
(
pVnode
,
&
pVnode
->
pMeta
)
<
0
)
{
pVnode
->
pMeta
=
metaOpen
(
tdir
,
vBufPoolGetMAF
(
pVnode
));
if
(
pVnode
->
pMeta
==
NULL
)
{
vError
(
"vgId: %d failed to open vnode meta since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
terrno
));
vError
(
"vgId: %d failed to open vnode meta since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
terrno
));
goto
_err
;
goto
_err
;
}
}
...
@@ -141,7 +140,6 @@ _err:
...
@@ -141,7 +140,6 @@ _err:
if
(
pVnode
->
pTsdb
)
tsdbClose
(
pVnode
->
pTsdb
);
if
(
pVnode
->
pTsdb
)
tsdbClose
(
pVnode
->
pTsdb
);
if
(
pVnode
->
pMeta
)
metaClose
(
pVnode
->
pMeta
);
if
(
pVnode
->
pMeta
)
metaClose
(
pVnode
->
pMeta
);
tsem_destroy
(
&
(
pVnode
->
canCommit
));
tsem_destroy
(
&
(
pVnode
->
canCommit
));
taosMemoryFreeClear
(
pVnode
->
path
);
taosMemoryFree
(
pVnode
);
taosMemoryFree
(
pVnode
);
return
NULL
;
return
NULL
;
}
}
...
@@ -159,7 +157,6 @@ void vnodeClose(SVnode *pVnode) {
...
@@ -159,7 +157,6 @@ void vnodeClose(SVnode *pVnode) {
vnodeCloseBufPool
(
pVnode
);
vnodeCloseBufPool
(
pVnode
);
// destroy handle
// destroy handle
tsem_destroy
(
&
(
pVnode
->
canCommit
));
tsem_destroy
(
&
(
pVnode
->
canCommit
));
taosMemoryFreeClear
(
pVnode
->
path
);
taosMemoryFree
(
pVnode
);
taosMemoryFree
(
pVnode
);
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录