Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b0dd5b23
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
未验证
提交
b0dd5b23
编写于
2月 25, 2022
作者:
S
Shengliang Guan
提交者:
GitHub
2月 25, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #10409 from taosdata/feature/config
Feature/config
上级
7e740259
1929e5b6
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
264 addition
and
166 deletion
+264
-166
include/common/tglobal.h
include/common/tglobal.h
+3
-2
include/dnode/mgmt/dnode.h
include/dnode/mgmt/dnode.h
+10
-7
include/util/tconfig.h
include/util/tconfig.h
+8
-1
source/client/src/clientEnv.c
source/client/src/clientEnv.c
+2
-2
source/common/src/tglobal.c
source/common/src/tglobal.c
+138
-117
source/dnode/mgmt/daemon/src/dmnCfg.c
source/dnode/mgmt/daemon/src/dmnCfg.c
+2
-0
source/dnode/mgmt/daemon/src/dmnMain.c
source/dnode/mgmt/daemon/src/dmnMain.c
+2
-2
source/dnode/mgmt/impl/src/dndEnv.c
source/dnode/mgmt/impl/src/dndEnv.c
+10
-3
source/dnode/mnode/impl/src/mndDnode.c
source/dnode/mnode/impl/src/mndDnode.c
+22
-19
source/libs/tfs/src/tfs.c
source/libs/tfs/src/tfs.c
+1
-1
source/util/src/tconfig.c
source/util/src/tconfig.c
+66
-11
source/util/test/cfgTest.cpp
source/util/test/cfgTest.cpp
+0
-1
未找到文件。
include/common/tglobal.h
浏览文件 @
b0dd5b23
...
...
@@ -22,6 +22,7 @@ extern "C" {
#include "tcfg.h"
#include "tdef.h"
#include "tarray.h"
// cluster
extern
char
tsFirst
[];
...
...
@@ -94,8 +95,8 @@ extern SDiskCfg tsDiskCfg[];
#define NEEDTO_COMPRESSS_MSG(size) (tsCompressMsgSize != -1 && (size) > tsCompressMsgSize)
int32_t
taosCreateLog
(
const
char
*
logname
,
int32_t
logFileNum
,
const
char
*
cfgDir
,
const
char
*
envFile
,
const
char
*
apolloUrl
,
bool
tsc
);
int32_t
taosInitCfg
(
const
char
*
cfgDir
,
const
char
*
envFile
,
const
char
*
apolloUrl
,
bool
tsc
);
const
char
*
apolloUrl
,
SArray
*
pArgs
,
bool
tsc
);
int32_t
taosInitCfg
(
const
char
*
cfgDir
,
const
char
*
envFile
,
const
char
*
apolloUrl
,
SArray
*
pArgs
,
bool
tsc
);
void
taosCleanupCfg
();
void
taosCfgDynamicOptions
(
const
char
*
option
,
const
char
*
value
);
...
...
include/dnode/mgmt/dnode.h
浏览文件 @
b0dd5b23
...
...
@@ -17,6 +17,7 @@
#define _TD_DNODE_H_
#include "tdef.h"
#include "tcfg.h"
#ifdef __cplusplus
extern
"C"
{
...
...
@@ -40,13 +41,15 @@ void dndCleanup();
/* ------------------------ SDnode ----------------------- */
typedef
struct
{
int32_t
numOfSupportVnodes
;
uint16_t
serverPort
;
char
dataDir
[
TSDB_FILENAME_LEN
];
char
localEp
[
TSDB_EP_LEN
];
char
localFqdn
[
TSDB_FQDN_LEN
];
char
firstEp
[
TSDB_EP_LEN
];
char
secondEp
[
TSDB_EP_LEN
];
int32_t
numOfSupportVnodes
;
uint16_t
serverPort
;
char
dataDir
[
TSDB_FILENAME_LEN
];
char
localEp
[
TSDB_EP_LEN
];
char
localFqdn
[
TSDB_FQDN_LEN
];
char
firstEp
[
TSDB_EP_LEN
];
char
secondEp
[
TSDB_EP_LEN
];
SDiskCfg
*
pDisks
;
int32_t
numOfDisks
;
}
SDnodeObjCfg
;
/**
...
...
include/util/tconfig.h
浏览文件 @
b0dd5b23
...
...
@@ -18,6 +18,7 @@
#define _TD_CONFIG_H_
#include "os.h"
#include "tarray.h"
#ifdef __cplusplus
extern
"C"
{
...
...
@@ -32,7 +33,6 @@ typedef enum {
CFG_STYPE_ENV_VAR
,
CFG_STYPE_APOLLO_URL
,
CFG_STYPE_ARG_LIST
,
CFG_STYPE_API_OPTION
}
ECfgSrcType
;
typedef
enum
{
...
...
@@ -68,12 +68,19 @@ typedef struct SConfigItem {
int64_t
imax
;
double
fmax
;
};
SArray
*
array
;
// SDiskCfg
}
SConfigItem
;
typedef
struct
{
const
char
*
name
;
const
char
*
value
;
}
SConfigPair
;
typedef
struct
SConfig
SConfig
;
SConfig
*
cfgInit
();
int32_t
cfgLoad
(
SConfig
*
pCfg
,
ECfgSrcType
cfgType
,
const
char
*
sourceStr
);
int32_t
cfgLoadArray
(
SConfig
*
pCfg
,
SArray
*
pArgs
);
// SConfigPair
void
cfgCleanup
(
SConfig
*
pCfg
);
int32_t
cfgGetSize
(
SConfig
*
pCfg
);
...
...
source/client/src/clientEnv.c
浏览文件 @
b0dd5b23
...
...
@@ -212,12 +212,12 @@ void taos_init_imp(void) {
deltaToUtcInitOnce
();
if
(
taosCreateLog
(
"taoslog"
,
10
,
configDir
,
NULL
,
NULL
,
1
)
!=
0
)
{
if
(
taosCreateLog
(
"taoslog"
,
10
,
configDir
,
NULL
,
NULL
,
NULL
,
1
)
!=
0
)
{
tscInitRes
=
-
1
;
return
;
}
if
(
taosInitCfg
(
configDir
,
NULL
,
NULL
,
1
)
!=
0
)
{
if
(
taosInitCfg
(
configDir
,
NULL
,
NULL
,
NULL
,
1
)
!=
0
)
{
tscInitRes
=
-
1
;
return
;
}
...
...
source/common/src/tglobal.c
浏览文件 @
b0dd5b23
...
...
@@ -154,19 +154,20 @@ static void taosAddDataDir(int32_t index, char *v1, int32_t level, int32_t prima
uTrace
(
"dataDir:%s, level:%d primary:%d is configured"
,
v1
,
level
,
primary
);
}
static
void
taosReadDataDirCfg
(
char
*
v1
,
char
*
v2
,
char
*
v3
)
{
if
(
tsDiskCfgNum
==
1
)
{
SDiskCfg
*
cfg
=
&
tsDiskCfg
[
0
];
uInfo
(
"dataDir:%s, level:%d primary:%d is replaced by %s"
,
cfg
->
dir
,
cfg
->
level
,
cfg
->
primary
,
v1
);
}
taosAddDataDir
(
0
,
v1
,
0
,
1
);
tsDiskCfgNum
=
1
;
}
static
void
taosPrintDataDirCfg
()
{
for
(
int32_t
i
=
0
;
i
<
tsDiskCfgNum
;
++
i
)
{
SDiskCfg
*
cfg
=
&
tsDiskCfg
[
i
];
uInfo
(
" dataDir: %s"
,
cfg
->
dir
);
static
void
taosSetTfsCfg
(
SConfig
*
pCfg
)
{
SConfigItem
*
pItem
=
cfgGetItem
(
pCfg
,
"dataDir"
);
if
(
pItem
==
NULL
)
return
;
int32_t
size
=
taosArrayGetSize
(
pItem
->
array
);
if
(
size
<=
0
)
{
tsDiskCfgNum
=
1
;
taosAddDataDir
(
0
,
pItem
->
str
,
0
,
1
);
}
else
{
tsDiskCfgNum
=
size
<
TFS_MAX_DISKS
?
size
:
TFS_MAX_DISKS
;
for
(
int32_t
index
=
0
;
index
<
tsDiskCfgNum
;
++
index
)
{
SDiskCfg
*
pCfg
=
taosArrayGet
(
pItem
->
array
,
index
);
memcpy
(
&
tsDiskCfg
[
index
],
pCfg
,
sizeof
(
SDiskCfg
));
}
}
}
...
...
@@ -206,113 +207,120 @@ static int32_t taosLoadCfg(SConfig *pCfg, const char *inputCfgDir, const char *e
return
0
;
}
static
void
taosAddClientLogCfg
(
SConfig
*
pCfg
)
{
cfgAddDir
(
pCfg
,
"logDir"
,
tsLogDir
,
1
);
cfgAddFloat
(
pCfg
,
"minimalLogDirGB"
,
1
.
0
f
,
0
.
001
f
,
10000000
,
1
);
cfgAddInt32
(
pCfg
,
"numOfLogLines"
,
tsNumOfLogLines
,
1000
,
2000000000
,
1
);
cfgAddBool
(
pCfg
,
"asyncLog"
,
tsAsyncLog
,
1
);
cfgAddInt32
(
pCfg
,
"logKeepDays"
,
0
,
-
365000
,
365000
,
1
);
cfgAddInt32
(
pCfg
,
"cDebugFlag"
,
cDebugFlag
,
0
,
255
,
1
);
cfgAddInt32
(
pCfg
,
"uDebugFlag"
,
uDebugFlag
,
0
,
255
,
1
);
cfgAddInt32
(
pCfg
,
"rpcDebugFlag"
,
rpcDebugFlag
,
0
,
255
,
1
);
cfgAddInt32
(
pCfg
,
"tmrDebugFlag"
,
tmrDebugFlag
,
0
,
255
,
1
);
cfgAddInt32
(
pCfg
,
"jniDebugFlag"
,
jniDebugFlag
,
0
,
255
,
1
);
cfgAddInt32
(
pCfg
,
"simDebugFlag"
,
143
,
0
,
255
,
1
);
cfgAddDir
(
pCfg
,
"configDir"
,
configDir
,
1
);
cfgAddDir
(
pCfg
,
"scriptDir"
,
configDir
,
1
);
cfgAddInt32
(
pCfg
,
"debugFlag"
,
0
,
0
,
255
,
1
);
static
int32_t
taosAddClientLogCfg
(
SConfig
*
pCfg
)
{
if
(
cfgAddDir
(
pCfg
,
"logDir"
,
tsLogDir
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddFloat
(
pCfg
,
"minimalLogDirGB"
,
1
.
0
f
,
0
.
001
f
,
10000000
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"numOfLogLines"
,
tsNumOfLogLines
,
1000
,
2000000000
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddBool
(
pCfg
,
"asyncLog"
,
tsAsyncLog
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"logKeepDays"
,
0
,
-
365000
,
365000
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"cDebugFlag"
,
cDebugFlag
,
0
,
255
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"uDebugFlag"
,
uDebugFlag
,
0
,
255
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"rpcDebugFlag"
,
rpcDebugFlag
,
0
,
255
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"tmrDebugFlag"
,
tmrDebugFlag
,
0
,
255
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"jniDebugFlag"
,
jniDebugFlag
,
0
,
255
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"simDebugFlag"
,
143
,
0
,
255
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddDir
(
pCfg
,
"configDir"
,
configDir
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddDir
(
pCfg
,
"scriptDir"
,
configDir
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"debugFlag"
,
0
,
0
,
255
,
1
)
!=
0
)
return
-
1
;
return
0
;
}
static
void
taosAddServerLogCfg
(
SConfig
*
pCfg
)
{
cfgAddInt32
(
pCfg
,
"dDebugFlag"
,
dDebugFlag
,
0
,
255
,
0
);
cfgAddInt32
(
pCfg
,
"vDebugFlag"
,
vDebugFlag
,
0
,
255
,
0
);
cfgAddInt32
(
pCfg
,
"mDebugFlag"
,
mDebugFlag
,
0
,
255
,
0
);
cfgAddInt32
(
pCfg
,
"qDebugFlag"
,
qDebugFlag
,
0
,
255
,
0
);
cfgAddInt32
(
pCfg
,
"wDebugFlag"
,
wDebugFlag
,
0
,
255
,
0
);
cfgAddInt32
(
pCfg
,
"sDebugFlag"
,
sDebugFlag
,
0
,
255
,
0
);
cfgAddInt32
(
pCfg
,
"tsdbDebugFlag"
,
tsdbDebugFlag
,
0
,
255
,
0
);
cfgAddInt32
(
pCfg
,
"tqDebugFlag"
,
tqDebugFlag
,
0
,
255
,
0
);
cfgAddInt32
(
pCfg
,
"fsDebugFlag"
,
fsDebugFlag
,
0
,
255
,
0
);
static
int32_t
taosAddServerLogCfg
(
SConfig
*
pCfg
)
{
if
(
cfgAddInt32
(
pCfg
,
"dDebugFlag"
,
dDebugFlag
,
0
,
255
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"vDebugFlag"
,
vDebugFlag
,
0
,
255
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"mDebugFlag"
,
mDebugFlag
,
0
,
255
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"qDebugFlag"
,
qDebugFlag
,
0
,
255
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"wDebugFlag"
,
wDebugFlag
,
0
,
255
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"sDebugFlag"
,
sDebugFlag
,
0
,
255
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"tsdbDebugFlag"
,
tsdbDebugFlag
,
0
,
255
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"tqDebugFlag"
,
tqDebugFlag
,
0
,
255
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"fsDebugFlag"
,
fsDebugFlag
,
0
,
255
,
0
)
!=
0
)
return
-
1
;
return
0
;
}
static
void
taosAddClientCfg
(
SConfig
*
pCfg
)
{
static
int32_t
taosAddClientCfg
(
SConfig
*
pCfg
)
{
char
defaultFqdn
[
TSDB_FQDN_LEN
]
=
{
0
};
int32_t
defaultServerPort
=
6030
;
char
defaultFirstEp
[
TSDB_EP_LEN
]
=
{
0
};
char
defaultSecondEp
[
TSDB_EP_LEN
]
=
{
0
};
taosGetFqdn
(
defaultFqdn
);
if
(
taosGetFqdn
(
defaultFqdn
)
!=
0
)
return
-
1
;
snprintf
(
defaultFirstEp
,
TSDB_EP_LEN
,
"%s:%d"
,
defaultFqdn
,
defaultServerPort
);
snprintf
(
defaultSecondEp
,
TSDB_EP_LEN
,
"%s:%d"
,
defaultFqdn
,
defaultServerPort
);
cfgAddString
(
pCfg
,
"firstEp"
,
defaultFirstEp
,
1
);
cfgAddString
(
pCfg
,
"secondEp"
,
defaultSecondEp
,
1
);
cfgAddString
(
pCfg
,
"fqdn"
,
defaultFqdn
,
1
);
cfgAddInt32
(
pCfg
,
"serverPort"
,
defaultServerPort
,
1
,
65056
,
1
);
cfgAddDir
(
pCfg
,
"tempDir"
,
tsTempDir
,
1
);
cfgAddFloat
(
pCfg
,
"minimalTempDirGB"
,
1
.
0
f
,
0
.
001
f
,
10000000
,
1
);
cfgAddFloat
(
pCfg
,
"numOfThreadsPerCore"
,
tsNumOfThreadsPerCore
,
0
,
10
,
1
);
cfgAddInt32
(
pCfg
,
"maxTmrCtrl"
,
tsMaxTmrCtrl
,
8
,
2048
,
1
);
cfgAddInt32
(
pCfg
,
"rpcTimer"
,
tsRpcTimer
,
100
,
3000
,
1
);
cfgAddInt32
(
pCfg
,
"rpcMaxTime"
,
tsRpcMaxTime
,
100
,
7200
,
1
);
cfgAddBool
(
pCfg
,
"rpcForceTcp"
,
tsRpcForceTcp
,
1
);
cfgAddInt32
(
pCfg
,
"shellActivityTimer"
,
tsShellActivityTimer
,
1
,
120
,
1
);
cfgAddInt32
(
pCfg
,
"compressMsgSize"
,
tsCompressMsgSize
,
-
1
,
100000000
,
1
);
cfgAddInt32
(
pCfg
,
"compressColData"
,
tsCompressColData
,
-
1
,
100000000
,
1
);
cfgAddInt32
(
pCfg
,
"maxWildCardsLength"
,
tsMaxWildCardsLen
,
0
,
TSDB_MAX_FIELD_LEN
,
1
);
cfgAddInt32
(
pCfg
,
"maxRegexStringLen"
,
tsMaxRegexStringLen
,
0
,
TSDB_MAX_FIELD_LEN
,
1
);
cfgAddInt32
(
pCfg
,
"maxNumOfOrderedRes"
,
tsMaxNumOfOrderedResults
,
128
,
TSDB_MAX_ALLOWED_SQL_LEN
,
1
);
cfgAddBool
(
pCfg
,
"keepColumnName"
,
tsKeepOriginalColumnName
,
1
);
cfgAddInt32
(
pCfg
,
"maxBinaryDisplayWidth"
,
tsMaxBinaryDisplayWidth
,
1
,
65536
,
1
);
if
(
cfgAddString
(
pCfg
,
"firstEp"
,
defaultFirstEp
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"secondEp"
,
defaultSecondEp
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"fqdn"
,
defaultFqdn
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"serverPort"
,
defaultServerPort
,
1
,
65056
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddDir
(
pCfg
,
"tempDir"
,
tsTempDir
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddFloat
(
pCfg
,
"minimalTempDirGB"
,
1
.
0
f
,
0
.
001
f
,
10000000
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddFloat
(
pCfg
,
"numOfThreadsPerCore"
,
tsNumOfThreadsPerCore
,
0
,
10
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"maxTmrCtrl"
,
tsMaxTmrCtrl
,
8
,
2048
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"rpcTimer"
,
tsRpcTimer
,
100
,
3000
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"rpcMaxTime"
,
tsRpcMaxTime
,
100
,
7200
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddBool
(
pCfg
,
"rpcForceTcp"
,
tsRpcForceTcp
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"shellActivityTimer"
,
tsShellActivityTimer
,
1
,
120
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"compressMsgSize"
,
tsCompressMsgSize
,
-
1
,
100000000
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"compressColData"
,
tsCompressColData
,
-
1
,
100000000
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"maxWildCardsLength"
,
tsMaxWildCardsLen
,
0
,
TSDB_MAX_FIELD_LEN
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"maxRegexStringLen"
,
tsMaxRegexStringLen
,
0
,
TSDB_MAX_FIELD_LEN
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"maxNumOfOrderedRes"
,
tsMaxNumOfOrderedResults
,
128
,
TSDB_MAX_ALLOWED_SQL_LEN
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddBool
(
pCfg
,
"keepColumnName"
,
tsKeepOriginalColumnName
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"maxBinaryDisplayWidth"
,
tsMaxBinaryDisplayWidth
,
1
,
65536
,
1
)
!=
0
)
return
-
1
;
return
0
;
}
static
void
taosAddSystemInfo
(
SConfig
*
pCfg
)
{
static
int32_t
taosAddSystemCfg
(
SConfig
*
pCfg
)
{
SysNameInfo
info
=
taosGetSysNameInfo
();
cfgAddTimezone
(
pCfg
,
"timezone"
,
tsTimezone
);
cfgAddLocale
(
pCfg
,
"locale"
,
tsLocale
);
cfgAddCharset
(
pCfg
,
"charset"
,
tsCharset
);
cfgAddBool
(
pCfg
,
"enableCoreFile"
,
0
,
1
);
cfgAddInt32
(
pCfg
,
"numOfCores"
,
tsNumOfCores
,
1
,
100000
,
1
);
cfgAddInt32
(
pCfg
,
"pageSize(KB)"
,
tsPageSize
,
0
,
INT64_MAX
,
1
);
cfgAddInt64
(
pCfg
,
"openMax"
,
tsOpenMax
,
0
,
INT64_MAX
,
1
);
cfgAddInt64
(
pCfg
,
"streamMax"
,
tsStreamMax
,
0
,
INT64_MAX
,
1
);
cfgAddInt32
(
pCfg
,
"totalMemory(MB)"
,
tsTotalMemoryMB
,
0
,
INT32_MAX
,
1
);
cfgAddString
(
pCfg
,
"os sysname"
,
info
.
sysname
,
1
);
cfgAddString
(
pCfg
,
"os nodename"
,
info
.
nodename
,
1
);
cfgAddString
(
pCfg
,
"os release"
,
info
.
release
,
1
);
cfgAddString
(
pCfg
,
"os version"
,
info
.
version
,
1
);
cfgAddString
(
pCfg
,
"os machine"
,
info
.
machine
,
1
);
cfgAddString
(
pCfg
,
"os sysname"
,
info
.
sysname
,
1
);
cfgAddString
(
pCfg
,
"version"
,
version
,
1
);
cfgAddString
(
pCfg
,
"compatible_version"
,
compatible_version
,
1
);
cfgAddString
(
pCfg
,
"gitinfo"
,
gitinfo
,
1
);
cfgAddString
(
pCfg
,
"gitinfoOfInternal"
,
gitinfoOfInternal
,
1
);
cfgAddString
(
pCfg
,
"buildinfo"
,
buildinfo
,
1
);
if
(
cfgAddTimezone
(
pCfg
,
"timezone"
,
tsTimezone
)
!=
0
)
return
-
1
;
if
(
cfgAddLocale
(
pCfg
,
"locale"
,
tsLocale
)
!=
0
)
return
-
1
;
if
(
cfgAddCharset
(
pCfg
,
"charset"
,
tsCharset
)
!=
0
)
return
-
1
;
if
(
cfgAddBool
(
pCfg
,
"enableCoreFile"
,
0
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"numOfCores"
,
tsNumOfCores
,
1
,
100000
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"pageSize(KB)"
,
tsPageSize
,
0
,
INT64_MAX
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt64
(
pCfg
,
"openMax"
,
tsOpenMax
,
0
,
INT64_MAX
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt64
(
pCfg
,
"streamMax"
,
tsStreamMax
,
0
,
INT64_MAX
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"totalMemory(MB)"
,
tsTotalMemoryMB
,
0
,
INT32_MAX
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"os sysname"
,
info
.
sysname
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"os nodename"
,
info
.
nodename
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"os release"
,
info
.
release
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"os version"
,
info
.
version
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"os machine"
,
info
.
machine
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"os sysname"
,
info
.
sysname
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"version"
,
version
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"compatible_version"
,
compatible_version
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"gitinfo"
,
gitinfo
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"gitinfoOfInternal"
,
gitinfoOfInternal
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"buildinfo"
,
buildinfo
,
1
)
!=
0
)
return
-
1
;
return
0
;
}
static
void
taosAddServerCfg
(
SConfig
*
pCfg
)
{
cfgAddInt32
(
pCfg
,
"supportVnodes"
,
256
,
0
,
65536
,
0
);
cfgAddDir
(
pCfg
,
"dataDir"
,
tsDataDir
,
0
);
cfgAddFloat
(
pCfg
,
"minimalDataDirGB"
,
2
.
0
f
,
0
.
001
f
,
10000000
,
0
);
cfgAddInt32
(
pCfg
,
"numOfCommitThreads"
,
tsNumOfCommitThreads
,
1
,
100
,
0
);
cfgAddFloat
(
pCfg
,
"ratioOfQueryCores"
,
tsRatioOfQueryCores
,
0
,
2
,
0
);
cfgAddInt32
(
pCfg
,
"maxNumOfDistinctRes"
,
tsMaxNumOfDistinctResults
,
10
*
10000
,
10000
*
10000
,
0
);
cfgAddBool
(
pCfg
,
"telemetryReporting"
,
tsEnableTelemetryReporting
,
0
);
cfgAddInt32
(
pCfg
,
"maxConnections"
,
tsMaxConnections
,
1
,
100000
,
0
);
cfgAddInt32
(
pCfg
,
"maxShellConns"
,
tsMaxShellConns
,
10
,
50000000
,
0
);
cfgAddInt32
(
pCfg
,
"statusInterval"
,
tsStatusInterval
,
1
,
30
,
0
);
cfgAddInt32
(
pCfg
,
"minSlidingTime"
,
tsMinSlidingTime
,
10
,
1000000
,
0
);
cfgAddInt32
(
pCfg
,
"minIntervalTime"
,
tsMinIntervalTime
,
1
,
1000000
,
0
);
cfgAddInt32
(
pCfg
,
"maxStreamCompDelay"
,
tsMaxStreamComputDelay
,
10
,
1000000000
,
0
);
cfgAddInt32
(
pCfg
,
"maxFirstStreamCompDelay"
,
tsStreamCompStartDelay
,
1000
,
1000000000
,
0
);
cfgAddInt32
(
pCfg
,
"retryStreamCompDelay"
,
tsRetryStreamCompDelay
,
10
,
1000000000
,
0
);
cfgAddFloat
(
pCfg
,
"streamCompDelayRatio"
,
tsStreamComputDelayRatio
,
0
.
1
,
0
.
9
,
0
);
cfgAddInt32
(
pCfg
,
"queryBufferSize"
,
tsQueryBufferSize
,
-
1
,
500000000000
,
0
);
cfgAddBool
(
pCfg
,
"retrieveBlockingModel"
,
tsRetrieveBlockingModel
,
0
);
cfgAddBool
(
pCfg
,
"printAuth"
,
tsPrintAuth
,
0
);
cfgAddBool
(
pCfg
,
"slaveQuery"
,
tsEnableSlaveQuery
,
0
);
cfgAddBool
(
pCfg
,
"deadLockKillQuery"
,
tsDeadLockKillQuery
,
0
);
static
int32_t
taosAddServerCfg
(
SConfig
*
pCfg
)
{
if
(
cfgAddInt32
(
pCfg
,
"supportVnodes"
,
256
,
0
,
65536
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddDir
(
pCfg
,
"dataDir"
,
tsDataDir
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddFloat
(
pCfg
,
"minimalDataDirGB"
,
2
.
0
f
,
0
.
001
f
,
10000000
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"numOfCommitThreads"
,
tsNumOfCommitThreads
,
1
,
100
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddFloat
(
pCfg
,
"ratioOfQueryCores"
,
tsRatioOfQueryCores
,
0
,
2
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"maxNumOfDistinctRes"
,
tsMaxNumOfDistinctResults
,
10
*
10000
,
10000
*
10000
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddBool
(
pCfg
,
"telemetryReporting"
,
tsEnableTelemetryReporting
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"maxConnections"
,
tsMaxConnections
,
1
,
100000
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"maxShellConns"
,
tsMaxShellConns
,
10
,
50000000
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"statusInterval"
,
tsStatusInterval
,
1
,
30
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"minSlidingTime"
,
tsMinSlidingTime
,
10
,
1000000
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"minIntervalTime"
,
tsMinIntervalTime
,
1
,
1000000
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"maxStreamCompDelay"
,
tsMaxStreamComputDelay
,
10
,
1000000000
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"maxFirstStreamCompDelay"
,
tsStreamCompStartDelay
,
1000
,
1000000000
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"retryStreamCompDelay"
,
tsRetryStreamCompDelay
,
10
,
1000000000
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddFloat
(
pCfg
,
"streamCompDelayRatio"
,
tsStreamComputDelayRatio
,
0
.
1
,
0
.
9
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"queryBufferSize"
,
tsQueryBufferSize
,
-
1
,
500000000000
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddBool
(
pCfg
,
"retrieveBlockingModel"
,
tsRetrieveBlockingModel
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddBool
(
pCfg
,
"printAuth"
,
tsPrintAuth
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddBool
(
pCfg
,
"slaveQuery"
,
tsEnableSlaveQuery
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddBool
(
pCfg
,
"deadLockKillQuery"
,
tsDeadLockKillQuery
,
0
)
!=
0
)
return
-
1
;
return
0
;
}
static
void
taosSetClientLogCfg
(
SConfig
*
pCfg
)
{
...
...
@@ -414,17 +422,17 @@ static void taosSetServerCfg(SConfig *pCfg) {
}
int32_t
taosCreateLog
(
const
char
*
logname
,
int32_t
logFileNum
,
const
char
*
cfgDir
,
const
char
*
envFile
,
const
char
*
apolloUrl
,
bool
tsc
)
{
const
char
*
apolloUrl
,
SArray
*
pArgs
,
bool
tsc
)
{
osInit
();
SConfig
*
pCfg
=
cfgInit
();
if
(
pCfg
==
NULL
)
return
-
1
;
if
(
tsc
)
{
taosAddClientLogCfg
(
pCfg
)
;
if
(
taosAddClientLogCfg
(
pCfg
)
!=
0
)
return
-
1
;
}
else
{
taosAddClientLogCfg
(
pCfg
)
;
taosAddServerLogCfg
(
pCfg
)
;
if
(
taosAddClientLogCfg
(
pCfg
)
!=
0
)
return
-
1
;
if
(
taosAddServerLogCfg
(
pCfg
)
!=
0
)
return
-
1
;
}
if
(
taosLoadCfg
(
pCfg
,
cfgDir
,
envFile
,
apolloUrl
)
!=
0
)
{
...
...
@@ -433,15 +441,21 @@ int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDi
return
-
1
;
}
if
(
cfgLoadArray
(
pCfg
,
pArgs
)
!=
0
)
{
uError
(
"failed to load cfg from array since %s"
,
terrstr
());
cfgCleanup
(
pCfg
);
return
-
1
;
}
if
(
tsc
)
{
taosSetClientLogCfg
(
pCfg
);
taosSetAllDebugFlag
(
cfgGetItem
(
pCfg
,
"debugFlag"
)
->
i32
);
}
else
{
taosSetClientLogCfg
(
pCfg
);
taosSetServerLogCfg
(
pCfg
);
taosSetAllDebugFlag
(
cfgGetItem
(
pCfg
,
"debugFlag"
)
->
i32
);
}
taosSetAllDebugFlag
(
cfgGetItem
(
pCfg
,
"debugFlag"
)
->
i32
);
if
(
taosInitLog
(
logname
,
logFileNum
)
!=
0
)
{
printf
(
"failed to init log file since %s
\n
"
,
terrstr
());
cfgCleanup
(
pCfg
);
...
...
@@ -452,20 +466,20 @@ int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDi
return
0
;
}
int32_t
taosInitCfg
(
const
char
*
cfgDir
,
const
char
*
envFile
,
const
char
*
apolloUrl
,
bool
tsc
)
{
int32_t
taosInitCfg
(
const
char
*
cfgDir
,
const
char
*
envFile
,
const
char
*
apolloUrl
,
SArray
*
pArgs
,
bool
tsc
)
{
if
(
tsCfg
!=
NULL
)
return
0
;
tsCfg
=
cfgInit
();
if
(
tsc
)
{
taosAddClientLogCfg
(
tsCfg
)
;
taosAddClientCfg
(
tsCfg
)
;
if
(
taosAddClientLogCfg
(
tsCfg
)
!=
0
)
return
-
1
;
if
(
taosAddClientCfg
(
tsCfg
)
!=
0
)
return
-
1
;
}
else
{
taosAddClientLogCfg
(
tsCfg
)
;
taosAddServerLogCfg
(
tsCfg
)
;
taosAddClientCfg
(
tsCfg
)
;
taosAddServerCfg
(
tsCfg
)
;
if
(
taosAddClientLogCfg
(
tsCfg
)
!=
0
)
return
-
1
;
if
(
taosAddServerLogCfg
(
tsCfg
)
!=
0
)
return
-
1
;
if
(
taosAddClientCfg
(
tsCfg
)
!=
0
)
return
-
1
;
if
(
taosAddServerCfg
(
tsCfg
)
!=
0
)
return
-
1
;
}
taosAddSystem
Info
(
tsCfg
);
taosAddSystem
Cfg
(
tsCfg
);
if
(
taosLoadCfg
(
tsCfg
,
cfgDir
,
envFile
,
apolloUrl
)
!=
0
)
{
uError
(
"failed to load cfg since %s"
,
terrstr
());
...
...
@@ -474,11 +488,18 @@ int32_t taosInitCfg(const char *cfgDir, const char *envFile, const char *apolloU
return
-
1
;
}
if
(
cfgLoadArray
(
tsCfg
,
pArgs
)
!=
0
)
{
uError
(
"failed to load cfg from array since %s"
,
terrstr
());
cfgCleanup
(
tsCfg
);
return
-
1
;
}
if
(
tsc
)
{
taosSetClientCfg
(
tsCfg
);
}
else
{
taosSetClientCfg
(
tsCfg
);
taosSetServerCfg
(
tsCfg
);
taosSetTfsCfg
(
tsCfg
);
}
taosSetSystemCfg
(
tsCfg
);
...
...
source/dnode/mgmt/daemon/src/dmnCfg.c
浏览文件 @
b0dd5b23
...
...
@@ -28,6 +28,8 @@ SDnodeObjCfg dmnGetObjCfg() {
objCfg
.
serverPort
=
(
uint16_t
)
cfgGetItem
(
pCfg
,
"serverPort"
)
->
i32
;
tstrncpy
(
objCfg
.
localFqdn
,
cfgGetItem
(
pCfg
,
"fqdn"
)
->
str
,
sizeof
(
objCfg
.
localFqdn
));
snprintf
(
objCfg
.
localEp
,
sizeof
(
objCfg
.
localEp
),
"%s:%u"
,
objCfg
.
localFqdn
,
objCfg
.
serverPort
);
objCfg
.
pDisks
=
tsDiskCfg
;
objCfg
.
numOfDisks
=
tsDiskCfgNum
;
return
objCfg
;
}
...
...
source/dnode/mgmt/daemon/src/dmnMain.c
浏览文件 @
b0dd5b23
...
...
@@ -111,12 +111,12 @@ int main(int argc, char const *argv[]) {
return
0
;
}
if
(
taosCreateLog
(
"taosdlog"
,
1
,
configDir
,
dmn
.
envFile
,
dmn
.
apolloUrl
,
0
)
!=
0
)
{
if
(
taosCreateLog
(
"taosdlog"
,
1
,
configDir
,
dmn
.
envFile
,
dmn
.
apolloUrl
,
NULL
,
0
)
!=
0
)
{
uInfo
(
"Failed to start TDengine since read config error"
);
return
-
1
;
}
if
(
taosInitCfg
(
configDir
,
dmn
.
envFile
,
dmn
.
apolloUrl
,
0
)
!=
0
)
{
if
(
taosInitCfg
(
configDir
,
dmn
.
envFile
,
dmn
.
apolloUrl
,
NULL
,
0
)
!=
0
)
{
uInfo
(
"Failed to start TDengine since read config error"
);
return
-
1
;
}
...
...
source/dnode/mgmt/impl/src/dndEnv.c
浏览文件 @
b0dd5b23
...
...
@@ -81,7 +81,7 @@ static TdFilePtr dndCheckRunning(char *dataDir) {
return
pFile
;
}
static
int32_t
dnd
CreateImp
(
SDnode
*
pDnode
,
SDnodeObjCfg
*
pCfg
)
{
static
int32_t
dnd
InitDir
(
SDnode
*
pDnode
,
SDnodeObjCfg
*
pCfg
)
{
pDnode
->
pLockFile
=
dndCheckRunning
(
pCfg
->
dataDir
);
if
(
pDnode
->
pLockFile
==
NULL
)
{
return
-
1
;
...
...
@@ -166,7 +166,7 @@ SDnode *dndCreate(SDnodeObjCfg *pCfg) {
dndSetStat
(
pDnode
,
DND_STAT_INIT
);
if
(
dnd
CreateImp
(
pDnode
,
pCfg
)
!=
0
)
{
if
(
dnd
InitDir
(
pDnode
,
pCfg
)
!=
0
)
{
dError
(
"failed to init dnode dir since %s"
,
terrstr
());
dndClose
(
pDnode
);
return
NULL
;
...
...
@@ -176,7 +176,14 @@ SDnode *dndCreate(SDnodeObjCfg *pCfg) {
tstrncpy
(
dCfg
.
dir
,
pDnode
->
cfg
.
dataDir
,
TSDB_FILENAME_LEN
);
dCfg
.
level
=
0
;
dCfg
.
primary
=
1
;
pDnode
->
pTfs
=
tfsOpen
(
&
dCfg
,
1
);
SDiskCfg
*
pDisks
=
pDnode
->
cfg
.
pDisks
;
int32_t
numOfDisks
=
pDnode
->
cfg
.
numOfDisks
;
if
(
numOfDisks
<=
0
||
pDisks
==
NULL
)
{
pDisks
=
&
dCfg
;
numOfDisks
=
1
;
}
pDnode
->
pTfs
=
tfsOpen
(
pDisks
,
numOfDisks
);
if
(
pDnode
->
pTfs
==
NULL
)
{
dError
(
"failed to init tfs since %s"
,
terrstr
());
dndClose
(
pDnode
);
...
...
source/dnode/mnode/impl/src/mndDnode.c
浏览文件 @
b0dd5b23
...
...
@@ -22,11 +22,11 @@
#include "mndUser.h"
#include "mndVgroup.h"
#define TSDB_DNODE_VER_NUMBER 1
#define TSDB_DNODE_VER_NUMBER
1
#define TSDB_DNODE_RESERVE_SIZE 64
#define TSDB_CONFIG_OPTION_LEN 16
#define TSDB_CONIIG_VALUE_LEN 48
#define TSDB_CONFIG_NUMBER 8
#define TSDB_CONFIG_OPTION_LEN
16
#define TSDB_CONIIG_VALUE_LEN
48
#define TSDB_CONFIG_NUMBER
8
static
const
char
*
offlineReason
[]
=
{
""
,
...
...
@@ -631,13 +631,13 @@ static int32_t mndGetConfigMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaRsp
pShow
->
bytes
[
cols
]
=
TSDB_CONFIG_OPTION_LEN
+
VARSTR_HEADER_SIZE
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
tstrncpy
(
pSchema
[
cols
].
name
,
"name"
,
sizeof
(
pSchema
[
cols
].
name
)
);
strcpy
(
pSchema
[
cols
].
name
,
"name"
);
pSchema
[
cols
].
bytes
=
pShow
->
bytes
[
cols
];
cols
++
;
pShow
->
bytes
[
cols
]
=
TSDB_CONIIG_VALUE_LEN
+
VARSTR_HEADER_SIZE
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
tstrncpy
(
pSchema
[
cols
].
name
,
"value"
,
sizeof
(
pSchema
[
cols
].
name
)
);
strcpy
(
pSchema
[
cols
].
name
,
"value"
);
pSchema
[
cols
].
bytes
=
pShow
->
bytes
[
cols
];
cols
++
;
...
...
@@ -658,29 +658,30 @@ static int32_t mndGetConfigMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaRsp
static
int32_t
mndRetrieveConfigs
(
SMnodeMsg
*
pReq
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
SMnode
*
pMnode
=
pReq
->
pMnode
;
int32_t
totalRows
=
0
;
int32_t
numOfRows
=
0
;
char
*
cfgOpts
[
TSDB_CONFIG_NUMBER
]
=
{
0
};
char
cfgVals
[
TSDB_CONFIG_NUMBER
][
TSDB_CONIIG_VALUE_LEN
+
1
]
=
{
0
};
char
*
pWrite
;
int32_t
cols
=
0
;
cfgOpts
[
numOf
Rows
]
=
"statusInterval"
;
snprintf
(
cfgVals
[
numOf
Rows
],
TSDB_CONIIG_VALUE_LEN
,
"%d"
,
tsStatusInterval
);
numOf
Rows
++
;
cfgOpts
[
total
Rows
]
=
"statusInterval"
;
snprintf
(
cfgVals
[
total
Rows
],
TSDB_CONIIG_VALUE_LEN
,
"%d"
,
tsStatusInterval
);
total
Rows
++
;
cfgOpts
[
numOf
Rows
]
=
"timezone"
;
snprintf
(
cfgVals
[
numOf
Rows
],
TSDB_CONIIG_VALUE_LEN
,
"%s"
,
tsTimezone
);
numOf
Rows
++
;
cfgOpts
[
total
Rows
]
=
"timezone"
;
snprintf
(
cfgVals
[
total
Rows
],
TSDB_CONIIG_VALUE_LEN
,
"%s"
,
tsTimezone
);
total
Rows
++
;
cfgOpts
[
numOf
Rows
]
=
"locale"
;
snprintf
(
cfgVals
[
numOf
Rows
],
TSDB_CONIIG_VALUE_LEN
,
"%s"
,
tsLocale
);
numOf
Rows
++
;
cfgOpts
[
total
Rows
]
=
"locale"
;
snprintf
(
cfgVals
[
total
Rows
],
TSDB_CONIIG_VALUE_LEN
,
"%s"
,
tsLocale
);
total
Rows
++
;
cfgOpts
[
numOf
Rows
]
=
"charset"
;
snprintf
(
cfgVals
[
numOf
Rows
],
TSDB_CONIIG_VALUE_LEN
,
"%s"
,
tsCharset
);
numOf
Rows
++
;
cfgOpts
[
total
Rows
]
=
"charset"
;
snprintf
(
cfgVals
[
total
Rows
],
TSDB_CONIIG_VALUE_LEN
,
"%s"
,
tsCharset
);
total
Rows
++
;
for
(
int32_t
i
=
0
;
i
<
numOf
Rows
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
total
Rows
;
i
++
)
{
cols
=
0
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
...
...
@@ -690,6 +691,8 @@ static int32_t mndRetrieveConfigs(SMnodeMsg *pReq, SShowObj *pShow, char *data,
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
STR_WITH_MAXSIZE_TO_VARSTR
(
pWrite
,
cfgVals
[
i
],
TSDB_CONIIG_VALUE_LEN
);
cols
++
;
numOfRows
++
;
}
mndVacuumResult
(
data
,
pShow
->
numOfColumns
,
numOfRows
,
rows
,
pShow
);
...
...
source/libs/tfs/src/tfs.c
浏览文件 @
b0dd5b23
...
...
@@ -25,7 +25,7 @@ static int32_t tfsOpendirImpl(STfs *pTfs, STfsDir *pDir);
static
STfsDisk
*
tfsNextDisk
(
STfs
*
pTfs
,
SDiskIter
*
pIter
);
STfs
*
tfsOpen
(
SDiskCfg
*
pCfg
,
int32_t
ndisk
)
{
if
(
ndisk
<
0
||
ndisk
>
TFS_MAX_DISKS
)
{
if
(
ndisk
<
=
0
||
ndisk
>
TFS_MAX_DISKS
)
{
terrno
=
TSDB_CODE_INVALID_PARA
;
return
NULL
;
}
...
...
source/util/src/tconfig.c
浏览文件 @
b0dd5b23
...
...
@@ -16,6 +16,7 @@
#define _DEFAULT_SOURCE
#include "tconfig.h"
#include "taoserror.h"
#include "tcfg.h"
#include "thash.h"
#include "tutil.h"
#include "ulog.h"
...
...
@@ -66,9 +67,37 @@ int32_t cfgLoad(SConfig *pCfg, ECfgSrcType cfgType, const char *sourceStr) {
}
}
int32_t
cfgLoadArray
(
SConfig
*
pCfg
,
SArray
*
pArgs
)
{
int32_t
size
=
taosArrayGetSize
(
pArgs
);
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
SConfigPair
*
pPair
=
taosArrayGet
(
pArgs
,
i
);
if
(
cfgSetItem
(
pCfg
,
pPair
->
name
,
pPair
->
value
,
CFG_STYPE_ARG_LIST
)
!=
0
)
{
return
-
1
;
}
}
return
0
;
}
static
void
cfgFreeItem
(
SConfigItem
*
pItem
)
{
if
(
pItem
->
dtype
==
CFG_DTYPE_STRING
||
pItem
->
dtype
==
CFG_DTYPE_DIR
||
pItem
->
dtype
==
CFG_DTYPE_LOCALE
||
pItem
->
dtype
==
CFG_DTYPE_CHARSET
||
pItem
->
dtype
==
CFG_DTYPE_TIMEZONE
)
{
tfree
(
pItem
->
str
);
}
if
(
pItem
->
array
)
{
taosArrayDestroy
(
pItem
->
array
);
pItem
->
array
=
NULL
;
}
}
void
cfgCleanup
(
SConfig
*
pCfg
)
{
if
(
pCfg
!=
NULL
)
{
if
(
pCfg
->
hash
!=
NULL
)
{
SConfigItem
*
pItem
=
taosHashIterate
(
pCfg
->
hash
,
NULL
);
while
(
pItem
!=
NULL
)
{
cfgFreeItem
(
pItem
);
pItem
=
taosHashIterate
(
pCfg
->
hash
,
pItem
);
}
taosHashCleanup
(
pCfg
->
hash
);
pCfg
->
hash
==
NULL
;
}
...
...
@@ -83,7 +112,7 @@ SConfigItem *cfgIterate(SConfig *pCfg, SConfigItem *pIter) { return taosHashIter
void
cfgCancelIterate
(
SConfig
*
pCfg
,
SConfigItem
*
pIter
)
{
return
taosHashCancelIterate
(
pCfg
->
hash
,
pIter
);
}
static
int32_t
cfgCheckAndSetTimezone
(
SConfigItem
*
pItem
,
const
char
*
timezone
)
{
tfree
(
pItem
->
str
);
cfgFreeItem
(
pItem
);
pItem
->
str
=
strdup
(
timezone
);
if
(
pItem
->
str
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
...
...
@@ -94,7 +123,7 @@ static int32_t cfgCheckAndSetTimezone(SConfigItem *pItem, const char *timezone)
}
static
int32_t
cfgCheckAndSetCharset
(
SConfigItem
*
pItem
,
const
char
*
charset
)
{
tfree
(
pItem
->
str
);
cfgFreeItem
(
pItem
);
pItem
->
str
=
strdup
(
charset
);
if
(
pItem
->
str
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
...
...
@@ -105,7 +134,7 @@ static int32_t cfgCheckAndSetCharset(SConfigItem *pItem, const char *charset) {
}
static
int32_t
cfgCheckAndSetLocale
(
SConfigItem
*
pItem
,
const
char
*
locale
)
{
tfree
(
pItem
->
str
);
cfgFreeItem
(
pItem
);
pItem
->
str
=
strdup
(
locale
);
if
(
pItem
->
str
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
...
...
@@ -134,7 +163,7 @@ static int32_t cfgCheckAndSetDir(SConfigItem *pItem, const char *inputDir) {
return
-
1
;
}
tfree
(
pItem
->
str
);
cfgFreeItem
(
pItem
);
pItem
->
str
=
strdup
(
fullDir
);
if
(
pItem
->
str
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
...
...
@@ -275,6 +304,33 @@ static int32_t cfgSetTimezone(SConfigItem *pItem, const char *value, ECfgSrcType
return
0
;
}
static
int32_t
cfgSetTfsItem
(
SConfig
*
pCfg
,
const
char
*
name
,
const
char
*
value
,
const
char
*
level
,
const
char
*
primary
,
ECfgSrcType
stype
)
{
SConfigItem
*
pItem
=
cfgGetItem
(
pCfg
,
name
);
if
(
pItem
==
NULL
)
return
-
1
;
if
(
pItem
->
array
==
NULL
)
{
pItem
->
array
=
taosArrayInit
(
16
,
sizeof
(
SDiskCfg
));
if
(
pItem
->
array
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
}
SDiskCfg
cfg
=
{
0
};
tstrncpy
(
cfg
.
dir
,
value
,
sizeof
(
cfg
.
dir
));
cfg
.
level
=
atoi
(
level
);
cfg
.
primary
=
atoi
(
primary
);
void
*
ret
=
taosArrayPush
(
pItem
->
array
,
&
cfg
);
if
(
ret
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
pItem
->
stype
=
stype
;
return
0
;
}
int32_t
cfgSetItem
(
SConfig
*
pCfg
,
const
char
*
name
,
const
char
*
value
,
ECfgSrcType
stype
)
{
SConfigItem
*
pItem
=
cfgGetItem
(
pCfg
,
name
);
if
(
pItem
==
NULL
)
{
...
...
@@ -441,8 +497,6 @@ const char *cfgStypeStr(ECfgSrcType type) {
return
"apollo_url"
;
case
CFG_STYPE_ARG_LIST
:
return
"arg_list"
;
case
CFG_STYPE_API_OPTION
:
return
"api_option"
;
default:
return
"invalid"
;
}
...
...
@@ -477,12 +531,12 @@ const char *cfgDtypeStr(ECfgDataType type) {
void
cfgDumpCfg
(
SConfig
*
pCfg
,
bool
tsc
,
bool
dump
)
{
if
(
dump
)
{
printf
(
" global config"
);
printf
(
"
global config"
);
printf
(
"
\n
"
);
printf
(
"================================================================="
);
printf
(
"
\n
"
);
}
else
{
uInfo
(
" global config"
);
uInfo
(
"
global config"
);
uInfo
(
"================================================================="
);
}
...
...
@@ -583,7 +637,6 @@ int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) {
}
while
(
!
taosEOFFile
(
pFile
))
{
name
=
value
=
value2
=
value3
=
NULL
;
olen
=
vlen
=
vlen2
=
vlen3
=
0
;
...
...
@@ -610,11 +663,13 @@ int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) {
}
cfgSetItem
(
pConfig
,
name
,
value
,
CFG_STYPE_CFG_FILE
);
// taosReadConfigOption(name, value, value2, value3);
if
(
value2
!=
NULL
&&
value3
!=
NULL
&&
value2
[
0
]
!=
0
&&
value3
[
0
]
!=
0
)
{
cfgSetTfsItem
(
pConfig
,
name
,
value
,
value2
,
value3
,
CFG_STYPE_CFG_FILE
);
}
}
taosCloseFile
(
&
pFile
);
if
(
line
!=
NULL
)
tfree
(
line
);
if
(
line
!=
NULL
)
tfree
(
line
);
uInfo
(
"load from cfg file %s success"
,
filepath
);
return
0
;
...
...
source/util/test/cfgTest.cpp
浏览文件 @
b0dd5b23
...
...
@@ -34,7 +34,6 @@ TEST_F(CfgTest, 01_Str) {
EXPECT_STREQ
(
cfgStypeStr
(
CFG_STYPE_ENV_VAR
),
"env_var"
);
EXPECT_STREQ
(
cfgStypeStr
(
CFG_STYPE_APOLLO_URL
),
"apollo_url"
);
EXPECT_STREQ
(
cfgStypeStr
(
CFG_STYPE_ARG_LIST
),
"arg_list"
);
EXPECT_STREQ
(
cfgStypeStr
(
CFG_STYPE_API_OPTION
),
"api_option"
);
EXPECT_STREQ
(
cfgStypeStr
(
ECfgSrcType
(
1024
)),
"invalid"
);
EXPECT_STREQ
(
cfgDtypeStr
(
CFG_DTYPE_NONE
),
"none"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录