Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5ac599b3
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1181
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,发现更多精彩内容 >>
未验证
提交
5ac599b3
编写于
4月 16, 2022
作者:
H
Hongze Cheng
提交者:
GitHub
4月 16, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #11565 from taosdata/feature/vnode_refact1
refactor: vnode
上级
3f0f31c4
032b30da
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
63 addition
and
58 deletion
+63
-58
source/dnode/vnode/src/inc/vnodeInt.h
source/dnode/vnode/src/inc/vnodeInt.h
+5
-0
source/dnode/vnode/src/vnd/vnodeOpen.c
source/dnode/vnode/src/vnd/vnodeOpen.c
+58
-58
未找到文件。
source/dnode/vnode/src/inc/vnodeInt.h
浏览文件 @
5ac599b3
...
...
@@ -52,6 +52,11 @@ typedef struct SVState SVState;
typedef
struct
SVBufPool
SVBufPool
;
typedef
struct
SQWorkerMgmt
SQHandle
;
#define VNODE_META_DIR "meta"
#define VNODE_TSDB_DIR "tsdb"
#define VNODE_TQ_DIR "tq"
#define VNODE_WAL_DIR "wal"
typedef
struct
{
int8_t
streamType
;
// sma or other
int8_t
dstType
;
...
...
source/dnode/vnode/src/vnd/vnodeOpen.c
浏览文件 @
5ac599b3
...
...
@@ -15,9 +15,6 @@
#include "vnodeInt.h"
static
int
vnodeOpenImpl
(
SVnode
*
pVnode
);
static
void
vnodeCloseImpl
(
SVnode
*
pVnode
);
int
vnodeCreate
(
const
char
*
path
,
SVnodeCfg
*
pCfg
,
STfs
*
pTfs
)
{
SVnodeInfo
info
=
{
0
};
char
dir
[
TSDB_FILENAME_LEN
];
...
...
@@ -55,6 +52,7 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
SVnode
*
pVnode
=
NULL
;
SVnodeInfo
info
=
{
0
};
char
dir
[
TSDB_FILENAME_LEN
];
char
tdir
[
TSDB_FILENAME_LEN
*
2
];
int
ret
;
snprintf
(
dir
,
TSDB_FILENAME_LEN
,
"%s%s%s"
,
tfsGetPrimaryPath
(
pTfs
),
TD_DIRSEP
,
path
);
...
...
@@ -83,83 +81,85 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
tsem_init
(
&
(
pVnode
->
canCommit
),
0
,
1
);
// open the vnode
if
(
vnodeOpenImpl
(
pVnode
)
<
0
)
{
// TODO: handle error
return
NULL
;
}
return
pVnode
;
}
void
vnodeClose
(
SVnode
*
pVnode
)
{
if
(
pVnode
)
{
vnodeCloseImpl
(
pVnode
);
tsem_destroy
(
&
(
pVnode
->
canCommit
));
taosMemoryFreeClear
(
pVnode
->
path
);
taosMemoryFree
(
pVnode
);
}
}
/* ------------------------ STATIC METHODS ------------------------ */
static
int
vnodeOpenImpl
(
SVnode
*
pVnode
)
{
char
dir
[
TSDB_FILENAME_LEN
];
// open buffer pool
if
(
vnodeOpenBufPool
(
pVnode
)
<
0
)
{
// TODO: handle error
return
-
1
;
vError
(
"vgId: %d failed to open vnode buffer pool since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
terrno
));
goto
_err
;
}
//
O
pen meta
sprintf
(
dir
,
"%s/meta"
,
pVnode
->
path
);
pVnode
->
pMeta
=
metaOpen
(
dir
,
vBufPoolGetMAF
(
pVnode
));
//
o
pen meta
sprintf
(
tdir
,
"%s%s%s"
,
dir
,
TD_DIRSEP
,
VNODE_META_DIR
);
pVnode
->
pMeta
=
metaOpen
(
t
dir
,
vBufPoolGetMAF
(
pVnode
));
if
(
pVnode
->
pMeta
==
NULL
)
{
// TODO: handle error
return
-
1
;
vError
(
"vgId: %d failed to open vnode meta since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
terrno
));
goto
_err
;
}
//
O
pen tsdb
sprintf
(
dir
,
"%s/tsdb"
,
pVnode
->
path
);
//
o
pen tsdb
sprintf
(
tdir
,
"%s%s%s"
,
dir
,
TD_DIRSEP
,
VNODE_TSDB_DIR
);
pVnode
->
pTsdb
=
tsdbOpen
(
dir
,
TD_VID
(
pVnode
),
&
(
pVnode
->
config
.
tsdbCfg
),
vBufPoolGetMAF
(
pVnode
),
pVnode
->
pMeta
,
pVnode
->
pTfs
);
tsdbOpen
(
t
dir
,
TD_VID
(
pVnode
),
&
(
pVnode
->
config
.
tsdbCfg
),
vBufPoolGetMAF
(
pVnode
),
pVnode
->
pMeta
,
pVnode
->
pTfs
);
if
(
pVnode
->
pTsdb
==
NULL
)
{
// TODO: handle error
return
-
1
;
vError
(
"vgId: %d failed to open vnode tsdb since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
terrno
));
goto
_err
;
}
//
Open WAL
sprintf
(
dir
,
"%s/wal"
,
pVnode
->
path
);
pVnode
->
pWal
=
walOpen
(
dir
,
&
(
pVnode
->
config
.
walCfg
));
//
open wal
sprintf
(
tdir
,
"%s%s%s"
,
dir
,
TD_DIRSEP
,
VNODE_WAL_DIR
);
pVnode
->
pWal
=
walOpen
(
t
dir
,
&
(
pVnode
->
config
.
walCfg
));
if
(
pVnode
->
pWal
==
NULL
)
{
// TODO: handle error
return
-
1
;
vError
(
"vgId: %d failed to open vnode wal since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
terrno
));
goto
_err
;
}
//
Open TQ
sprintf
(
dir
,
"%s/tq"
,
pVnode
->
path
);
pVnode
->
pTq
=
tqOpen
(
dir
,
pVnode
,
pVnode
->
pWal
,
pVnode
->
pMeta
,
vBufPoolGetMAF
(
pVnode
));
//
open tq
sprintf
(
tdir
,
"%s%s%s"
,
dir
,
TD_DIRSEP
,
VNODE_TQ_DIR
);
pVnode
->
pTq
=
tqOpen
(
t
dir
,
pVnode
,
pVnode
->
pWal
,
pVnode
->
pMeta
,
vBufPoolGetMAF
(
pVnode
));
if
(
pVnode
->
pTq
==
NULL
)
{
// TODO: handle error
return
-
1
;
vError
(
"vgId: %d failed to open vnode tq since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
terrno
));
goto
_err
;
}
//
Open Q
uery
//
open q
uery
if
(
vnodeQueryOpen
(
pVnode
))
{
return
-
1
;
vError
(
"vgId: %d failed to open vnode query since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
terrno
));
goto
_err
;
}
// TODO
return
0
;
#if 0
if (vnodeBegin() < 0) {
goto _err;
}
#endif
return
pVnode
;
_err:
if
(
pVnode
->
pQuery
)
vnodeQueryClose
(
pVnode
);
if
(
pVnode
->
pTq
)
tqClose
(
pVnode
->
pTq
);
if
(
pVnode
->
pWal
)
walClose
(
pVnode
->
pWal
);
if
(
pVnode
->
pTsdb
)
tsdbClose
(
pVnode
->
pTsdb
);
if
(
pVnode
->
pMeta
)
metaClose
(
pVnode
->
pMeta
);
tsem_destroy
(
&
(
pVnode
->
canCommit
));
taosMemoryFreeClear
(
pVnode
->
path
);
taosMemoryFree
(
pVnode
);
return
NULL
;
}
static
void
vnodeCloseImpl
(
SVnode
*
pVnode
)
{
vnodeSyncCommit
(
pVnode
);
void
vnodeClose
(
SVnode
*
pVnode
)
{
if
(
pVnode
)
{
vnodeCloseBufPool
(
pVnode
);
metaClose
(
pVnode
->
pMeta
);
tsdbClose
(
pVnode
->
pTsdb
);
tqClose
(
pVnode
->
pTq
);
walClose
(
pVnode
->
pWal
);
// commit (TODO: use option to control)
vnodeSyncCommit
(
pVnode
);
// close vnode
vnodeQueryClose
(
pVnode
);
walClose
(
pVnode
->
pWal
);
tqClose
(
pVnode
->
pTq
);
tsdbClose
(
pVnode
->
pTsdb
);
metaClose
(
pVnode
->
pMeta
);
vnodeCloseBufPool
(
pVnode
);
// destroy handle
tsem_destroy
(
&
(
pVnode
->
canCommit
));
taosMemoryFreeClear
(
pVnode
->
path
);
taosMemoryFree
(
pVnode
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录