Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
44963201
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,发现更多精彩内容 >>
提交
44963201
编写于
10月 22, 2020
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-1767
上级
28e6927d
变更
14
显示空白变更内容
内联
并排
Showing
14 changed file
with
104 addition
and
50 deletion
+104
-50
CMakeLists.txt
CMakeLists.txt
+1
-0
cmake/define.inc
cmake/define.inc
+4
-0
src/common/inc/tglobal.h
src/common/inc/tglobal.h
+12
-6
src/common/src/tglobal.c
src/common/src/tglobal.c
+37
-1
src/dnode/src/dnodeMain.c
src/dnode/src/dnodeMain.c
+10
-10
src/dnode/src/dnodeTier.c
src/dnode/src/dnodeTier.c
+4
-4
src/inc/dnode.h
src/inc/dnode.h
+5
-13
src/inc/taosdef.h
src/inc/taosdef.h
+4
-0
src/os/src/detail/osSysinfo.c
src/os/src/detail/osSysinfo.c
+0
-1
src/tsdb/src/tsdbFile.c
src/tsdb/src/tsdbFile.c
+3
-3
src/util/CMakeLists.txt
src/util/CMakeLists.txt
+4
-0
src/util/inc/tconfig.h
src/util/inc/tconfig.h
+1
-0
src/util/src/tconfig.c
src/util/src/tconfig.c
+17
-10
src/vnode/src/vnodeMain.c
src/vnode/src/vnodeMain.c
+2
-2
未找到文件。
CMakeLists.txt
浏览文件 @
44963201
...
...
@@ -16,6 +16,7 @@ SET(TD_GRANT FALSE)
SET
(
TD_SYNC TRUE
)
SET
(
TD_MQTT TRUE
)
SET
(
TD_TSDB_PLUGINS FALSE
)
SET
(
TD_STORAGE FALSE
)
SET
(
TD_COVER FALSE
)
SET
(
TD_MEM_CHECK FALSE
)
...
...
cmake/define.inc
浏览文件 @
44963201
...
...
@@ -25,6 +25,10 @@ IF (TD_TSDB_PLUGINS)
ADD_DEFINITIONS
(
-
D_TSDB_PLUGINS
)
ENDIF
()
IF
(
TD_STORAGE
)
ADD_DEFINITIONS
(
-
D_STORAGE
)
ENDIF
()
IF
(
TD_GODLL
)
ADD_DEFINITIONS
(
-
D_TD_GO_DLL_
)
ENDIF
()
...
...
src/common/inc/tglobal.h
浏览文件 @
44963201
...
...
@@ -20,8 +20,6 @@
extern
"C"
{
#endif
struct
SDnodeTier
;
// cluster
extern
char
tsFirst
[];
extern
char
tsSecond
[];
...
...
@@ -157,9 +155,6 @@ extern char gitinfo[];
extern
char
gitinfoOfInternal
[];
extern
char
buildinfo
[];
// dnode
extern
struct
SDnodeTier
*
pDnodeTier
;
// log
extern
int32_t
tsAsyncLog
;
extern
int32_t
tsNumOfLogLines
;
...
...
@@ -182,6 +177,14 @@ extern int32_t wDebugFlag;
extern
int32_t
cqDebugFlag
;
extern
int32_t
debugFlag
;
typedef
struct
{
char
dir
[
TSDB_FILENAME_LEN
];
int
level
;
int
primary
;
}
SDiskCfg
;
extern
int32_t
tsDiskCfgNum
;
extern
SDiskCfg
tsDiskCfg
[];
#define NEEDTO_COMPRESSS_MSG(size) (tsCompressMsgSize != -1 && (size) > tsCompressMsgSize)
void
taosInitGlobalCfg
();
...
...
@@ -190,6 +193,9 @@ void taosSetAllDebugFlag();
bool
taosCfgDynamicOptions
(
char
*
msg
);
int
taosGetFqdnPortFromEp
(
const
char
*
ep
,
char
*
fqdn
,
uint16_t
*
port
);
bool
taosCheckBalanceCfgOptions
(
const
char
*
option
,
int32_t
*
vnodeId
,
int32_t
*
dnodeId
);
void
taosAddDataDir
(
int
index
,
char
*
v1
,
int
level
,
int
primary
);
void
taosReadDataDirCfg
(
char
*
v1
,
char
*
v2
,
char
*
v3
);
void
taosPrintDataDirCfg
();
#ifdef __cplusplus
}
...
...
src/common/src/tglobal.c
浏览文件 @
44963201
...
...
@@ -160,6 +160,13 @@ char tsDnodeDir[TSDB_FILENAME_LEN] = {0};
char
tsMnodeDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
tsDataDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
tsScriptDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
int32_t
tsDiskCfgNum
=
0
;
#ifndef _STORAGE
SDiskCfg
tsDiskCfg
[
1
];
#else
SDiskCfg
tsDiskCfg
[
TSDB_MAX_DISKS
];
#endif
/*
* minimum scale for whole system, millisecond by default
...
...
@@ -305,6 +312,34 @@ bool taosCfgDynamicOptions(char *msg) {
return
false
;
}
void
taosAddDataDir
(
int
index
,
char
*
v1
,
int
level
,
int
primary
)
{
tstrncpy
(
tsDiskCfg
[
index
].
dir
,
v1
,
TSDB_FILENAME_LEN
);
tsDiskCfg
[
index
].
level
=
level
;
tsDiskCfg
[
index
].
primary
=
primary
;
uTrace
(
"dataDir:%s, level:%d primary:%d is configured"
,
v1
,
level
,
primary
);
}
#ifndef _STORAGE
void
taosReadDataDirCfg
(
char
*
v1
,
char
*
v2
,
char
*
v3
)
{
taosAddDataDir
(
0
,
tsDataDir
,
0
,
1
);
tstrncpy
(
tsDiskCfg
[
0
].
dir
,
tsDataDir
,
TSDB_FILENAME_LEN
);
}
#endif
void
taosPrintDataDirCfg
()
{
for
(
int
i
=
0
;
i
<
tsDiskCfgNum
;
++
i
)
{
SDiskCfg
*
cfg
=
&
tsDiskCfg
[
i
];
uInfo
(
" dataDir:%s level:%d primary:%d"
,
cfg
->
dir
,
cfg
->
level
,
cfg
->
primary
);
}
}
static
void
taosCheckDataDirCfg
()
{
if
(
tsDiskCfgNum
<=
0
)
{
taosAddDataDir
(
0
,
tsDataDir
,
0
,
1
);
tsDiskCfgNum
=
1
;
}
}
static
void
doInitGlobalConfig
(
void
)
{
osInit
();
srand
(
taosSafeRand
());
...
...
@@ -386,7 +421,7 @@ static void doInitGlobalConfig(void) {
cfg
.
option
=
"dataDir"
;
cfg
.
ptr
=
tsDataDir
;
cfg
.
valType
=
TAOS_CFG_VTYPE_D
IRE
CTORY
;
cfg
.
valType
=
TAOS_CFG_VTYPE_D
ATA_DIR
CTORY
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
;
cfg
.
minValue
=
0
;
cfg
.
maxValue
=
0
;
...
...
@@ -1328,6 +1363,7 @@ bool taosCheckGlobalCfg() {
snprintf
(
tsSecond
,
sizeof
(
tsSecond
),
"%s:%u"
,
fqdn
,
port
);
}
taosCheckDataDirCfg
();
taosGetSystemInfo
();
tsSetLocale
();
...
...
src/dnode/src/dnodeMain.c
浏览文件 @
44963201
...
...
@@ -169,17 +169,17 @@ static void dnodeCheckDataDirOpenned(char *dir) {
}
static
int32_t
dnodeInitStorage
()
{
p
DnodeTier
=
dnodeNewTier
();
if
(
p
DnodeTier
==
NULL
)
{
ts
DnodeTier
=
dnodeNewTier
();
if
(
ts
DnodeTier
==
NULL
)
{
dError
(
"failed to create new dnode tier since %s"
,
tstrerror
(
terrno
));
return
-
1
;
}
if
(
dnodeAddDisks
(
pDnodeTier
,
NULL
,
0
)
<
0
)
{
if
(
dnodeAddDisks
(
tsDnodeTier
,
tsDiskCfg
,
tsDiskCfgNum
)
<
0
)
{
dError
(
"failed to add disks to dnode tier since %s"
,
tstrerror
(
terrno
));
return
-
1
;
}
strncpy
(
tsDataDir
,
DNODE_PRIMARY_DISK
(
p
DnodeTier
)
->
dir
,
TSDB_FILENAME_LEN
);
strncpy
(
tsDataDir
,
DNODE_PRIMARY_DISK
(
ts
DnodeTier
)
->
dir
,
TSDB_FILENAME_LEN
);
tdGetVnodeRootDir
(
tsDataDir
,
tsVnodeDir
);
//TODO(dengyihao): no need to init here
...
...
@@ -195,12 +195,12 @@ static int32_t dnodeInitStorage() {
return
-
1
;
}
for
(
int
i
=
0
;
i
<
p
DnodeTier
->
nTiers
;
i
++
)
{
for
(
int
i
=
0
;
i
<
ts
DnodeTier
->
nTiers
;
i
++
)
{
char
dirName
[
TSDB_FILENAME_LEN
];
STier
*
pTier
=
p
DnodeTier
->
tiers
+
i
;
STier
*
pTier
=
ts
DnodeTier
->
tiers
+
i
;
for
(
int
j
=
0
;
j
<
pTier
->
nDisks
;
j
++
)
{
SDisk
*
pDisk
=
dnodeGetDisk
(
p
DnodeTier
,
i
,
j
);
SDisk
*
pDisk
=
dnodeGetDisk
(
ts
DnodeTier
,
i
,
j
);
tdGetVnodeRootDir
(
dirName
,
pDisk
->
dir
);
if
(
dnodeCreateDir
(
dirName
)
<
0
)
{
...
...
@@ -223,9 +223,9 @@ static int32_t dnodeInitStorage() {
}
static
void
dnodeCleanupStorage
()
{
if
(
p
DnodeTier
)
{
dnodeCloseTier
(
p
DnodeTier
);
p
DnodeTier
=
NULL
;
if
(
ts
DnodeTier
)
{
dnodeCloseTier
(
ts
DnodeTier
);
ts
DnodeTier
=
NULL
;
}
}
...
...
src/dnode/src/dnodeTier.c
浏览文件 @
44963201
...
...
@@ -40,7 +40,7 @@ SDnodeTier *dnodeNewTier() {
return
NULL
;
}
pDnodeTier
->
map
=
taosHashInit
(
DNODE_MAX_TIERS
*
DNODE
_MAX_DISKS_PER_TIER
*
2
,
pDnodeTier
->
map
=
taosHashInit
(
TSDB_MAX_TIERS
*
TSDB
_MAX_DISKS_PER_TIER
*
2
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
false
,
HASH_NO_LOCK
);
if
(
pDnodeTier
->
map
==
NULL
)
{
terrno
=
TSDB_CODE_COM_OUT_OF_MEMORY
;
...
...
@@ -217,7 +217,7 @@ static int dnodeAddDisk(SDnodeTier *pDnodeTier, char *dir, int level, int primar
SDiskID
diskid
=
{
0
};
SDisk
*
pDisk
=
NULL
;
if
(
level
<
0
||
level
>=
DNODE
_MAX_TIERS
)
{
if
(
level
<
0
||
level
>=
TSDB
_MAX_TIERS
)
{
terrno
=
TSDB_CODE_DND_INVALID_DISK_TIER
;
dError
(
"failed to add disk %s to tier %d level since %s"
,
dir
,
level
,
tstrerror
(
terrno
));
return
-
1
;
...
...
@@ -231,7 +231,7 @@ static int dnodeAddDisk(SDnodeTier *pDnodeTier, char *dir, int level, int primar
pTier
=
pDnodeTier
->
tiers
+
level
;
diskid
.
level
=
level
;
if
(
pTier
->
nDisks
>=
DNODE
_MAX_DISKS_PER_TIER
)
{
if
(
pTier
->
nDisks
>=
TSDB
_MAX_DISKS_PER_TIER
)
{
terrno
=
TSDB_CODE_DND_TOO_MANY_DISKS
;
dError
(
"failed to add disk %s to tier %d level since %s"
,
dir
,
level
,
tstrerror
(
terrno
));
return
-
1
;
...
...
@@ -268,7 +268,7 @@ static int dnodeAddDisk(SDnodeTier *pDnodeTier, char *dir, int level, int primar
diskid
.
did
=
pTier
->
nDisks
;
}
else
{
diskid
.
did
=
pTier
->
nDisks
+
1
;
if
(
diskid
.
did
>=
DNODE
_MAX_DISKS_PER_TIER
)
{
if
(
diskid
.
did
>=
TSDB
_MAX_DISKS_PER_TIER
)
{
terrno
=
TSDB_CODE_DND_TOO_MANY_DISKS
;
dError
(
"failed to add disk %s to tier %d level since %s"
,
dir
,
level
,
tstrerror
(
terrno
));
return
-
1
;
...
...
src/inc/dnode.h
浏览文件 @
44963201
...
...
@@ -20,6 +20,8 @@
extern
"C"
{
#endif
#include "taosdef.h"
#include "tglobal.h"
#include "hash.h"
#include "taoserror.h"
#include "trpc.h"
...
...
@@ -71,16 +73,6 @@ void dnodeDelayReprocessMnodeWriteMsg(void *pMsg);
void
dnodeSendStatusMsgToMnode
();
// DNODE TIER
#define DNODE_MAX_TIERS 3
#define DNODE_MAX_DISKS_PER_TIER 16
typedef
struct
{
char
dir
[
TSDB_FILENAME_LEN
];
int
level
;
int
primary
;
}
SDiskCfg
;
typedef
struct
{
int
level
;
int
did
;
...
...
@@ -100,16 +92,17 @@ typedef struct {
typedef
struct
{
int
level
;
int
nDisks
;
SDisk
*
disks
[
DNODE
_MAX_DISKS_PER_TIER
];
SDisk
*
disks
[
TSDB
_MAX_DISKS_PER_TIER
];
}
STier
;
typedef
struct
SDnodeTier
{
pthread_rwlock_t
rwlock
;
int
nTiers
;
STier
tiers
[
DNODE
_MAX_TIERS
];
STier
tiers
[
TSDB
_MAX_TIERS
];
SHashObj
*
map
;
}
SDnodeTier
;
extern
struct
SDnodeTier
*
tsDnodeTier
;
#define DNODE_PRIMARY_DISK(pDnodeTier) (pDnodeTier)->tiers[0].disks[0]
static
FORCE_INLINE
int
dnodeRLockTiers
(
SDnodeTier
*
pDnodeTier
)
{
...
...
@@ -155,7 +148,6 @@ int dnodeCheckTiers(SDnodeTier *pDnodeTier);
SDisk
*
dnodeAssignDisk
(
SDnodeTier
*
pDnodeTier
,
int
level
);
SDisk
*
dnodeGetDiskByName
(
SDnodeTier
*
pDnodeTier
,
char
*
dirName
);
#ifdef __cplusplus
}
#endif
...
...
src/inc/taosdef.h
浏览文件 @
44963201
...
...
@@ -432,6 +432,10 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size, void* buf
#define TAOS_QTYPE_CQ 3
#define TAOS_QTYPE_QUERY 4
#define TSDB_MAX_TIERS 3
#define TSDB_MAX_DISKS_PER_TIER 16
#define TSDB_MAX_DISKS (TSDB_MAX_TIERS * TSDB_MAX_DISKS_PER_TIER)
typedef
enum
{
TSDB_SUPER_TABLE
=
0
,
// super table
TSDB_CHILD_TABLE
=
1
,
// table created from super table
...
...
src/os/src/detail/osSysinfo.c
浏览文件 @
44963201
...
...
@@ -533,7 +533,6 @@ void taosPrintOsInfo() {
uInfo
(
" os release: %s"
,
buf
.
release
);
uInfo
(
" os version: %s"
,
buf
.
version
);
uInfo
(
" os machine: %s"
,
buf
.
machine
);
uInfo
(
"=================================="
);
}
void
taosKillSystem
()
{
...
...
src/tsdb/src/tsdbFile.c
浏览文件 @
44963201
...
...
@@ -26,7 +26,7 @@
#include "dnode.h"
#include "tpath.h"
struct
SDnodeTier
*
p
DnodeTier
=
NULL
;
struct
SDnodeTier
*
ts
DnodeTier
=
NULL
;
const
char
*
tsdbFileSuffix
[]
=
{
".head"
,
".data"
,
".last"
,
".stat"
,
".h"
,
".d"
,
".l"
,
".s"
};
static
void
tsdbDestroyFile
(
SFile
*
pFile
);
...
...
@@ -79,8 +79,8 @@ int tsdbOpenFileH(STsdbRepo *pRepo) {
ASSERT
(
pRepo
!=
NULL
&&
pRepo
->
tsdbFileH
!=
NULL
);
char
dataDir
[
TSDB_FILENAME_LEN
]
=
"
\0
"
;
for
(
int
level
=
0
;
level
<
p
DnodeTier
->
nTiers
;
level
++
)
{
STier
*
pTier
=
p
DnodeTier
->
tiers
+
level
;
for
(
int
level
=
0
;
level
<
ts
DnodeTier
->
nTiers
;
level
++
)
{
STier
*
pTier
=
ts
DnodeTier
->
tiers
+
level
;
for
(
int
did
=
0
;
did
<
pTier
->
nDisks
;
did
++
)
{
SDisk
*
pDisk
=
pTier
->
disks
[
did
];
...
...
src/util/CMakeLists.txt
浏览文件 @
44963201
...
...
@@ -29,3 +29,7 @@ ELSEIF (TD_WINDOWS)
ELSEIF
(
TD_DARWIN
)
TARGET_LINK_LIBRARIES
(
tutil iconv
)
ENDIF
()
IF
(
TD_STORAGE
)
TARGET_LINK_LIBRARIES
(
tutil storage
)
ENDIF
()
\ No newline at end of file
src/util/inc/tconfig.h
浏览文件 @
44963201
...
...
@@ -47,6 +47,7 @@ enum {
TAOS_CFG_VTYPE_STRING
,
TAOS_CFG_VTYPE_IPSTR
,
TAOS_CFG_VTYPE_DIRECTORY
,
TAOS_CFG_VTYPE_DATA_DIRCTORY
,
};
enum
{
...
...
src/util/src/tconfig.c
浏览文件 @
44963201
...
...
@@ -199,7 +199,7 @@ SGlobalCfg *taosGetConfigOption(const char *option) {
return
NULL
;
}
static
void
taosReadConfigOption
(
const
char
*
option
,
char
*
value
)
{
static
void
taosReadConfigOption
(
const
char
*
option
,
char
*
value
,
char
*
value2
,
char
*
value3
)
{
for
(
int
i
=
0
;
i
<
tsGlobalConfigNum
;
++
i
)
{
SGlobalCfg
*
cfg
=
tsGlobalConfig
+
i
;
if
(
!
(
cfg
->
cfgType
&
TSDB_CFG_CTYPE_B_CONFIG
))
continue
;
...
...
@@ -224,6 +224,9 @@ static void taosReadConfigOption(const char *option, char *value) {
case
TAOS_CFG_VTYPE_DIRECTORY
:
taosReadDirectoryConfig
(
cfg
,
value
);
break
;
case
TAOS_CFG_VTYPE_DATA_DIRCTORY
:
taosReadDirectoryConfig
(
cfg
,
value
);
taosReadDataDirCfg
(
value
,
value2
,
value3
);
default:
uError
(
"config option:%s, input value:%s, can't be recognized"
,
option
,
value
);
break
;
...
...
@@ -307,8 +310,8 @@ void taosReadGlobalLogCfg() {
}
bool
taosReadGlobalCfg
()
{
char
*
line
,
*
option
,
*
value
,
*
value
1
;
int
olen
,
vlen
,
vlen
1
;
char
*
line
,
*
option
,
*
value
,
*
value
2
,
*
value3
;
int
olen
,
vlen
,
vlen
2
,
vlen3
;
char
fileName
[
PATH_MAX
]
=
{
0
};
sprintf
(
fileName
,
"%s/taos.cfg"
,
configDir
);
...
...
@@ -331,8 +334,8 @@ bool taosReadGlobalCfg() {
while
(
!
feof
(
fp
))
{
memset
(
line
,
0
,
len
);
option
=
value
=
NULL
;
olen
=
vlen
=
0
;
option
=
value
=
value2
=
value3
=
NULL
;
olen
=
vlen
=
vlen2
=
vlen3
=
0
;
taosGetline
(
&
line
,
&
len
,
fp
);
line
[
len
-
1
]
=
0
;
...
...
@@ -345,11 +348,13 @@ bool taosReadGlobalCfg() {
if
(
vlen
==
0
)
continue
;
value
[
vlen
]
=
0
;
// For dataDir, the format is:
// dataDir /mnt/disk1 0
paGetToken
(
value
+
vlen
+
1
,
&
value1
,
&
vlen1
);
paGetToken
(
value
+
vlen
+
1
,
&
value2
,
&
vlen2
);
if
(
vlen2
!=
0
)
value2
[
vlen2
]
=
0
;
taosReadConfigOption
(
option
,
value
);
paGetToken
(
value
+
vlen2
+
1
,
&
value3
,
&
vlen3
);
if
(
vlen3
!=
0
)
value3
[
vlen3
]
=
0
;
taosReadConfigOption
(
option
,
value
,
value2
,
value3
);
}
fclose
(
fp
);
...
...
@@ -397,4 +402,6 @@ void taosPrintGlobalCfg() {
}
taosPrintOsInfo
();
taosPrintDataDirCfg
();
uInfo
(
"=================================="
);
}
src/vnode/src/vnodeMain.c
浏览文件 @
44963201
...
...
@@ -418,8 +418,8 @@ void vnodeRelease(void *pVnodeRaw) {
char
rootDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
newDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
for
(
int
i
=
0
;
i
<
p
DnodeTier
->
nTiers
;
i
++
)
{
STier
*
pTier
=
p
DnodeTier
->
tiers
+
i
;
for
(
int
i
=
0
;
i
<
ts
DnodeTier
->
nTiers
;
i
++
)
{
STier
*
pTier
=
ts
DnodeTier
->
tiers
+
i
;
for
(
int
j
=
0
;
j
<
pTier
->
nDisks
;
j
++
)
{
SDisk
*
pDisk
=
pTier
->
disks
[
j
];
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录