Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
e5021e77
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
e5021e77
编写于
10月 20, 2020
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more code
上级
7e61fc12
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
105 addition
and
28 deletion
+105
-28
src/common/inc/tglobal.h
src/common/inc/tglobal.h
+5
-0
src/common/inc/tpath.h
src/common/inc/tpath.h
+53
-0
src/dnode/src/dnodeMain.c
src/dnode/src/dnodeMain.c
+26
-19
src/vnode/src/vnodeMain.c
src/vnode/src/vnodeMain.c
+21
-9
未找到文件。
src/common/inc/tglobal.h
浏览文件 @
e5021e77
...
...
@@ -20,6 +20,8 @@
extern
"C"
{
#endif
struct
SDnodeTier
;
// cluster
extern
char
tsFirst
[];
extern
char
tsSecond
[];
...
...
@@ -156,6 +158,9 @@ extern char gitinfo[];
extern
char
gitinfoOfInternal
[];
extern
char
buildinfo
[];
// dnode
extern
struct
SDnodeTier
*
pDnodeTier
;
// log
extern
int32_t
tsAsyncLog
;
extern
int32_t
tsNumOfLogLines
;
...
...
src/common/inc/tpath.h
0 → 100644
浏览文件 @
e5021e77
/*
* 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_TPATH_H_
#define _TD_TPATH_H_
#include <stdio.h>
#include "taosdef.h"
#ifdef __cplusplus
extern
"C"
{
#endif
static
FORCE_INLINE
void
tdGetMnodeRootDir
(
char
*
rootDir
,
char
*
dirName
)
{
snprintf
(
dirName
,
TSDB_FILENAME_LEN
,
"%s/mnode"
,
rootDir
);
}
static
FORCE_INLINE
void
tdGetDnodeRootDir
(
char
*
rootDir
,
char
*
dirName
)
{
snprintf
(
dirName
,
TSDB_FILENAME_LEN
,
"%s/dnode"
,
rootDir
);
}
static
FORCE_INLINE
void
tdGetVnodeRootDir
(
char
*
rootDir
,
char
*
dirName
)
{
snprintf
(
dirName
,
TSDB_FILENAME_LEN
,
"%s/vnode"
,
rootDir
);
}
static
FORCE_INLINE
void
tdGetVnodeBackRootDir
(
char
*
rootDir
,
char
*
dirName
)
{
snprintf
(
dirName
,
TSDB_FILENAME_LEN
,
"%s/vnode_bak"
,
rootDir
);
}
static
FORCE_INLINE
void
tdGetVnodeDir
(
char
*
rootDir
,
int
vid
,
char
*
dirName
)
{
snprintf
(
dirName
,
TSDB_FILENAME_LEN
,
"%s/vnode/vnode%d"
,
rootDir
,
vid
);
}
static
FORCE_INLINE
void
tdGetVnodeBackDir
(
char
*
rootDir
,
int
vid
,
char
*
dirName
)
{
snprintf
(
dirName
,
TSDB_FILENAME_LEN
,
"%s/vnode_bak/vnode%d"
,
rootDir
,
vid
);
}
#ifdef __cplusplus
}
#endif
#endif // _TD_TPATH_H_
\ No newline at end of file
src/dnode/src/dnodeMain.c
浏览文件 @
e5021e77
...
...
@@ -32,8 +32,9 @@
#include "dnodeMPeer.h"
#include "dnodeShell.h"
#include "dnodeTelemetry.h"
#include "tpath.h"
SDnodeTier
*
pDnodeTier
=
NULL
;
struct
SDnodeTier
*
pDnodeTier
=
NULL
;
static
int32_t
dnodeInitStorage
();
static
void
dnodeCleanupStorage
();
...
...
@@ -181,32 +182,38 @@ static int32_t dnodeInitStorage() {
return
-
1
;
}
if
(
dnodeCreateDir
(
tsDataDir
)
<
0
)
{
dError
(
"failed to create dir: %s, reason: %s"
,
tsDataDir
,
strerror
(
errno
));
return
-
1
;
}
sprintf
(
tsMnodeDir
,
"%s/mnode"
,
tsDataDir
);
sprintf
(
tsVnodeDir
,
"%s/vnode"
,
tsDataDir
);
sprintf
(
tsDnodeDir
,
"%s/dnode"
,
tsDataDir
);
sprintf
(
tsVnodeBakDir
,
"%s/vnode_bak"
,
tsDataDir
);
//TODO(dengyihao): no need to init here
tdGetMnodeRootDir
(
DNODE_PRIMARY_DISK
(
pDnodeTier
)
->
dir
,
tsMnodeDir
);
if
(
dnodeCreateDir
(
tsMnodeDir
)
<
0
)
{
dError
(
"failed to create dir: %s, reason: %s"
,
tsMnodeDir
,
strerror
(
errno
));
return
-
1
;
}
//TODO(dengyihao): no need to init here
if
(
dnodeCreateDir
(
tsVnodeDir
)
<
0
)
{
dError
(
"failed to create dir: %s, reason: %s"
,
tsVnodeDir
,
strerror
(
errno
));
return
-
1
;
}
tdGetDnodeRootDir
(
DNODE_PRIMARY_DISK
(
pDnodeTier
)
->
dir
,
tsDnodeDir
);
if
(
dnodeCreateDir
(
tsDnodeDir
)
<
0
)
{
dError
(
"failed to create dir: %s, reason: %s"
,
tsDnodeDir
,
strerror
(
errno
));
return
-
1
;
}
if
(
dnodeCreateDir
(
tsVnodeBakDir
)
<
0
)
{
dError
(
"failed to create dir: %s, reason: %s"
,
tsVnodeBakDir
,
strerror
(
errno
));
return
-
1
;
}
for
(
int
i
=
0
;
i
<
pDnodeTier
->
nTiers
;
i
++
)
{
char
dirName
[
TSDB_FILENAME_LEN
];
STier
*
pTier
=
pDnodeTier
->
tiers
+
i
;
for
(
int
j
=
0
;
j
<
pTier
->
nDisks
;
j
++
)
{
SDisk
*
pDisk
=
dnodeGetDisk
(
pDnodeTier
,
i
,
j
);
tdGetVnodeRootDir
(
dirName
,
pDisk
->
dir
);
if
(
dnodeCreateDir
(
dirName
)
<
0
)
{
dError
(
"failed to create dir: %s, reason: %s"
,
dirName
,
strerror
(
errno
));
return
-
1
;
}
tdGetVnodeBackRootDir
(
dirName
,
pDisk
->
dir
);
if
(
dnodeCreateDir
(
dirName
)
<
0
)
{
dError
(
"failed to create dir: %s, reason: %s"
,
dirName
,
strerror
(
errno
));
return
-
1
;
}
}
}
dnodeCheckDataDirOpenned
(
tsDnodeDir
);
...
...
src/vnode/src/vnodeMain.c
浏览文件 @
e5021e77
...
...
@@ -31,6 +31,7 @@
#include "vnodeInt.h"
#include "query.h"
#include "dnode.h"
#include "tpath.h"
#define TSDB_VNODE_VERSION_CONTENT_LEN 31
...
...
@@ -395,17 +396,28 @@ void vnodeRelease(void *pVnodeRaw) {
if
(
pVnode
->
dropped
)
{
char
rootDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
newDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
sprintf
(
rootDir
,
"%s/vnode%d"
,
tsVnodeDir
,
vgId
);
sprintf
(
newDir
,
"%s/vnode%d"
,
tsVnodeBakDir
,
vgId
);
if
(
0
==
tsEnableVnodeBak
)
{
vInfo
(
"vgId:%d, vnode backup not enabled"
,
pVnode
->
vgId
);
}
else
{
taosRemoveDir
(
newDir
);
taosRename
(
rootDir
,
newDir
);
}
for
(
int
i
=
0
;
i
<
pDnodeTier
->
nTiers
;
i
++
)
{
STier
*
pTier
=
pDnodeTier
->
tiers
+
i
;
for
(
int
j
=
0
;
j
<
pTier
->
nDisks
;
j
++
)
{
SDisk
*
pDisk
=
pTier
->
disks
[
j
];
tdGetVnodeDir
(
pDisk
->
dir
,
vgId
,
rootDir
);
tdGetVnodeBackDir
(
pDisk
->
dir
,
vgId
,
newDir
);
taosRemoveDir
(
rootDir
);
if
(
access
(
rootDir
,
F_OK
)
==
0
)
{
if
(
0
==
tsEnableVnodeBak
)
{
vInfo
(
"vgId:%d, vnode backup not enabled"
,
pVnode
->
vgId
);
}
else
{
taosRemoveDir
(
newDir
);
taosRename
(
rootDir
,
newDir
);
}
taosRemoveDir
(
rootDir
);
}
}
}
dnodeSendStatusMsgToMnode
();
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录