Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
3da2af00
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3da2af00
编写于
11月 23, 2020
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor
上级
072d42e0
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
24 addition
and
22 deletion
+24
-22
src/tfs/src/tfcntl.c
src/tfs/src/tfcntl.c
+3
-3
src/tfs/src/tfs.c
src/tfs/src/tfs.c
+2
-1
src/tsdb/src/tsdbFile.c
src/tsdb/src/tsdbFile.c
+1
-1
src/tsdb/src/tsdbMain.c
src/tsdb/src/tsdbMain.c
+15
-14
src/vnode/src/vnodeMain.c
src/vnode/src/vnodeMain.c
+3
-3
未找到文件。
src/tfs/src/tfcntl.c
浏览文件 @
3da2af00
...
...
@@ -101,13 +101,13 @@ const char *tfsRelName(TFSFILE *pfile) { return pfile->rname; }
void
tfsDirName
(
TFSFILE
*
pfile
,
char
dest
[])
{
char
fname
[
TSDB_FILENAME_LEN
]
=
"
\0
"
;
tfsAbsFname
(
pfile
,
fname
);
strncpy
(
fname
,
tfsAbsName
(
pfile
),
TSDB_FILENAME_LEN
);
strncpy
(
dest
,
dirname
(
fname
),
TSDB_FILENAME_LEN
);
}
void
tfsBaseName
(
TFSFILE
*
pfile
,
char
dest
[])
{
char
fname
[
TSDB_FILENAME_LEN
]
=
"
\0
"
;
memcpy
((
void
*
)
fname
,
(
void
*
)
pfile
->
rname
,
TSDB_FILENAME_LEN
);
strncpy
(
fname
,
tfsAbsName
(
pfile
)
,
TSDB_FILENAME_LEN
);
strncpy
(
dest
,
basename
(
fname
),
TSDB_FILENAME_LEN
);
}
...
...
src/tfs/src/tfs.c
浏览文件 @
3da2af00
...
...
@@ -118,9 +118,10 @@ int tfsCreateDir(char *dirname) {
ASSERT
(
pDisk
!=
NULL
);
snprintf
(
dirName
,
TSDB_FILENAME_LEN
,
"%s/%s"
,
pDisk
->
dir
,
dirname
);
snprintf
(
dirName
,
TSDB_FILENAME_LEN
,
"%s/%s"
,
pDisk
->
name
,
dirname
);
if
(
mkdir
(
dirName
,
0755
)
!=
0
&&
errno
!=
EEXIST
)
{
fError
(
"failed to create directory %s since %s"
,
dirName
,
strerror
(
errno
));
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
}
...
...
src/tsdb/src/tsdbFile.c
浏览文件 @
3da2af00
...
...
@@ -64,7 +64,7 @@ void tsdbFreeFileH(STsdbFileH *pFileH) {
}
}
int
tsdbOpenFileH
(
STsdbRepo
*
pRepo
)
{
int
tsdbOpenFileH
(
STsdbRepo
*
pRepo
)
{
// TODO
ASSERT
(
pRepo
!=
NULL
&&
pRepo
->
tsdbFileH
!=
NULL
);
char
dataDir
[
TSDB_FILENAME_LEN
]
=
"
\0
"
;
...
...
src/tsdb/src/tsdbMain.c
浏览文件 @
3da2af00
...
...
@@ -52,7 +52,10 @@ static void tsdbStopStream(STsdbRepo *pRepo);
// Function declaration
int32_t
tsdbCreateRepo
(
char
*
rootDir
,
STsdbCfg
*
pCfg
)
{
DIR
*
dir
=
opendir
(
rootDir
);
char
tsdbDir
[
TSDB_FILENAME_LEN
]
=
"
\0
"
;
snprintf
(
tsdbDir
,
TSDB_FILENAME_LEN
,
"%s/%s"
,
tfsPrimaryPath
(),
rootDir
);
DIR
*
dir
=
tfs
(
tsdbDir
);
if
(
dir
)
{
tsdbDebug
(
"repository %s already exists"
,
rootDir
);
closedir
(
dir
);
...
...
@@ -65,12 +68,6 @@ int32_t tsdbCreateRepo(char *rootDir, STsdbCfg *pCfg) {
}
}
if
(
mkdir
(
rootDir
,
0755
)
<
0
)
{
tsdbError
(
"vgId:%d failed to create rootDir %s since %s"
,
pCfg
->
tsdbId
,
rootDir
,
strerror
(
errno
));
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
}
if
(
tsdbCheckAndSetDefaultCfg
(
pCfg
)
<
0
)
return
-
1
;
if
(
tsdbSetRepoEnv
(
rootDir
,
pCfg
)
<
0
)
return
-
1
;
...
...
@@ -306,14 +303,14 @@ int tsdbGetState(TSDB_REPO_T *repo) {
// ----------------- INTERNAL FUNCTIONS -----------------
char
*
tsdbGetMetaFileName
(
char
*
rootDir
)
{
int
tlen
=
(
int
)(
strlen
(
rootDir
)
+
strlen
(
TSDB_META_FILE_NAME
)
+
2
);
int
tlen
=
(
int
)(
strlen
(
tfsPrimaryPath
())
+
strlen
(
rootDir
)
+
strlen
(
TSDB_META_FILE_NAME
)
+
2
);
char
*
fname
=
calloc
(
1
,
tlen
);
if
(
fname
==
NULL
)
{
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
return
NULL
;
}
snprintf
(
fname
,
tlen
,
"%s/%s
"
,
rootDir
,
TSDB_META_FILE_NAME
);
snprintf
(
fname
,
tlen
,
"%s/%s
/%s"
,
tfsPrimaryPath
()
,
rootDir
,
TSDB_META_FILE_NAME
);
return
fname
;
}
...
...
@@ -483,6 +480,11 @@ _err:
}
static
int32_t
tsdbSetRepoEnv
(
char
*
rootDir
,
STsdbCfg
*
pCfg
)
{
if
(
tfsCreateDir
(
rootDir
)
<
0
)
{
tsdbError
(
"vgId:%d failed to create rootDir %s since %s"
,
pCfg
->
tsdbId
,
rootDir
,
tstrerror
(
terrno
));
return
-
1
;
}
if
(
tsdbSaveConfig
(
rootDir
,
pCfg
)
<
0
)
{
tsdbError
(
"vgId:%d failed to set TSDB environment since %s"
,
pCfg
->
tsdbId
,
tstrerror
(
terrno
));
return
-
1
;
...
...
@@ -491,9 +493,8 @@ static int32_t tsdbSetRepoEnv(char *rootDir, STsdbCfg *pCfg) {
char
*
dirName
=
tsdbGetDataDirName
(
rootDir
);
if
(
dirName
==
NULL
)
return
-
1
;
if
(
mkdir
(
dirName
,
0755
)
<
0
)
{
if
(
tfsCreateDir
(
dirName
)
<
0
)
{
tsdbError
(
"vgId:%d failed to create directory %s since %s"
,
pCfg
->
tsdbId
,
dirName
,
strerror
(
errno
));
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
free
(
dirName
);
return
-
1
;
}
...
...
@@ -513,7 +514,7 @@ static int32_t tsdbSetRepoEnv(char *rootDir, STsdbCfg *pCfg) {
}
static
int32_t
tsdbUnsetRepoEnv
(
char
*
rootDir
)
{
t
ao
sRemoveDir
(
rootDir
);
t
f
sRemoveDir
(
rootDir
);
tsdbDebug
(
"repository %s is removed"
,
rootDir
);
return
0
;
}
...
...
@@ -609,14 +610,14 @@ _err:
}
static
char
*
tsdbGetCfgFname
(
char
*
rootDir
)
{
int
tlen
=
(
int
)(
strlen
(
rootDir
)
+
strlen
(
TSDB_CFG_FILE_NAME
)
+
2
);
int
tlen
=
(
int
)(
strlen
(
tfsPrimaryPath
())
+
strlen
(
rootDir
)
+
strlen
(
TSDB_CFG_FILE_NAME
)
+
3
);
char
*
fname
=
calloc
(
1
,
tlen
);
if
(
fname
==
NULL
)
{
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
return
NULL
;
}
snprintf
(
fname
,
tlen
,
"%s/%s
"
,
rootDir
,
TSDB_CFG_FILE_NAME
);
snprintf
(
fname
,
tlen
,
"%s/%s
/%s"
,
tfsPrimaryPath
()
,
rootDir
,
TSDB_CFG_FILE_NAME
);
return
fname
;
}
...
...
src/vnode/src/vnodeMain.c
浏览文件 @
3da2af00
...
...
@@ -136,7 +136,7 @@ int32_t vnodeCreate(SCreateVnodeMsg *pVnodeCfg) {
tsdbCfg
.
update
=
pVnodeCfg
->
cfg
.
update
;
char
tsdbDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
sprintf
(
tsdbDir
,
"
%s/vnode%d/tsdb"
,
tsVnodeDir
,
pVnodeCfg
->
cfg
.
vgId
);
sprintf
(
tsdbDir
,
"
vnode/vnode%d/tsdb"
,
pVnodeCfg
->
cfg
.
vgId
);
if
(
tsdbCreateRepo
(
tsdbDir
,
&
tsdbCfg
)
<
0
)
{
vError
(
"vgId:%d, failed to create tsdb in vnode, reason:%s"
,
pVnodeCfg
->
cfg
.
vgId
,
tstrerror
(
terrno
));
return
TSDB_CODE_VND_INIT_FAILED
;
...
...
@@ -274,7 +274,7 @@ int32_t vnodeOpen(int32_t vnode, char *rootDir) {
appH
.
cqH
=
pVnode
->
cq
;
appH
.
cqCreateFunc
=
cqCreate
;
appH
.
cqDropFunc
=
cqDrop
;
sprintf
(
temp
,
"
%s/tsdb"
,
rootDir
);
sprintf
(
temp
,
"
vnode/vnode%d/tsdb"
,
vnode
);
terrno
=
0
;
pVnode
->
tsdb
=
tsdbOpenRepo
(
temp
,
&
appH
);
...
...
@@ -684,7 +684,7 @@ static void vnodeCtrlFlow(int32_t vgId, int32_t mseconds) {
static
int32_t
vnodeResetTsdb
(
SVnodeObj
*
pVnode
)
{
char
rootDir
[
128
]
=
"
\0
"
;
sprintf
(
rootDir
,
"
%s/tsdb"
,
pVnode
->
rootDir
);
sprintf
(
rootDir
,
"
vnode/vnode%d/tsdb"
,
pVnode
->
vgId
);
if
(
pVnode
->
status
!=
TAOS_VN_STATUS_CLOSING
&&
pVnode
->
status
!=
TAOS_VN_STATUS_INIT
)
{
pVnode
->
status
=
TAOS_VN_STATUS_RESET
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录