Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
cefb07bc
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,发现更多精彩内容 >>
提交
cefb07bc
编写于
2月 23, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
config for client
上级
0a0dfd5f
变更
12
显示空白变更内容
内联
并排
Showing
12 changed file
with
343 addition
and
177 deletion
+343
-177
include/common/tglobal.h
include/common/tglobal.h
+0
-5
source/client/CMakeLists.txt
source/client/CMakeLists.txt
+1
-1
source/client/inc/clientInt.h
source/client/inc/clientInt.h
+7
-0
source/client/src/clientCfg.c
source/client/src/clientCfg.c
+210
-0
source/client/src/clientEnv.c
source/client/src/clientEnv.c
+12
-22
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+3
-1
source/client/src/clientMain.c
source/client/src/clientMain.c
+1
-1
source/client/test/CMakeLists.txt
source/client/test/CMakeLists.txt
+2
-2
source/common/src/tep.c
source/common/src/tep.c
+2
-0
source/common/src/tglobal.c
source/common/src/tglobal.c
+0
-57
source/dnode/mgmt/daemon/src/dmnCfg.c
source/dnode/mgmt/daemon/src/dmnCfg.c
+26
-5
source/libs/config/src/config.c
source/libs/config/src/config.c
+79
-83
未找到文件。
include/common/tglobal.h
浏览文件 @
cefb07bc
...
...
@@ -24,11 +24,6 @@ extern "C" {
#include "tcfg.h"
// cluster
extern
char
tsFirst
[];
extern
char
tsSecond
[];
extern
char
tsLocalFqdn
[];
extern
char
tsLocalEp
[];
extern
uint16_t
tsServerPort
;
extern
int32_t
tsStatusInterval
;
extern
int8_t
tsEnableTelemetryReporting
;
extern
int32_t
tsNumOfSupportVnodes
;
...
...
source/client/CMakeLists.txt
浏览文件 @
cefb07bc
...
...
@@ -8,7 +8,7 @@ target_include_directories(
target_link_libraries
(
taos
INTERFACE api
PRIVATE os util common transport parser planner catalog scheduler function qcom
PRIVATE os util common transport parser planner catalog scheduler function qcom
config
)
if
(
${
BUILD_TEST
}
)
...
...
source/client/inc/clientInt.h
浏览文件 @
cefb07bc
...
...
@@ -32,6 +32,8 @@ extern "C" {
#include "query.h"
#include "parser.h"
#include "config.h"
#define CHECK_CODE_GOTO(expr, label) \
do { \
int32_t code = expr; \
...
...
@@ -253,6 +255,11 @@ int hbAddConnInfo(SAppHbMgr* pAppHbMgr, SClientHbKey connKey, void* key, void* v
// --- mq
void
hbMgrInitMqHbRspHandle
();
// config
int32_t
tscInitLog
(
const
char
*
cfgDir
,
const
char
*
envFile
,
const
char
*
apolloUrl
);
int32_t
tscInitCfg
(
const
char
*
cfgDir
,
const
char
*
envFile
,
const
char
*
apolloUrl
);
extern
SConfig
*
tscCfg
;
#ifdef __cplusplus
}
...
...
source/client/src/clientCfg.c
0 → 100644
浏览文件 @
cefb07bc
/*
* 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/>.
*/
#define _DEFAULT_SOURCE
#include "clientInt.h"
#include "ulog.h"
// todo refact
SConfig
*
tscCfg
;
static
int32_t
tscLoadCfg
(
SConfig
*
pConfig
,
const
char
*
inputCfgDir
,
const
char
*
envFile
,
const
char
*
apolloUrl
)
{
char
configDir
[
PATH_MAX
]
=
{
0
};
char
configFile
[
PATH_MAX
+
100
]
=
{
0
};
taosExpandDir
(
inputCfgDir
,
configDir
,
PATH_MAX
);
snprintf
(
configFile
,
sizeof
(
configFile
),
"%s"
TD_DIRSEP
"taos.cfg"
,
configDir
);
if
(
cfgLoad
(
pConfig
,
CFG_STYPE_APOLLO_URL
,
apolloUrl
)
!=
0
)
{
uError
(
"failed to load from apollo url:%s since %s
\n
"
,
apolloUrl
,
terrstr
());
return
-
1
;
}
if
(
cfgLoad
(
pConfig
,
CFG_STYPE_CFG_FILE
,
configFile
)
!=
0
)
{
if
(
cfgLoad
(
pConfig
,
CFG_STYPE_CFG_FILE
,
configDir
)
!=
0
)
{
uError
(
"failed to load from config file:%s since %s
\n
"
,
configFile
,
terrstr
());
return
-
1
;
}
}
if
(
cfgLoad
(
pConfig
,
CFG_STYPE_ENV_FILE
,
envFile
)
!=
0
)
{
uError
(
"failed to load from env file:%s since %s
\n
"
,
envFile
,
terrstr
());
return
-
1
;
}
if
(
cfgLoad
(
pConfig
,
CFG_STYPE_ENV_VAR
,
NULL
)
!=
0
)
{
uError
(
"failed to load from global env variables since %s
\n
"
,
terrstr
());
return
-
1
;
}
return
0
;
}
static
int32_t
tscAddLogCfg
(
SConfig
*
pCfg
)
{
if
(
cfgAddDir
(
pCfg
,
"logDir"
,
"/var/log/taos"
)
!=
0
)
return
-
1
;
if
(
cfgAddBool
(
pCfg
,
"asyncLog"
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"numOfLogLines"
,
10000000
,
1000
,
2000000000
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"logKeepDays"
,
0
,
-
365000
,
365000
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"debugFlag"
,
0
,
0
,
255
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"cDebugFlag"
,
0
,
0
,
255
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"jniDebugFlag"
,
0
,
0
,
255
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"tmrDebugFlag"
,
0
,
0
,
255
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"uDebugFlag"
,
0
,
0
,
255
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"rpcDebugFlag"
,
0
,
0
,
255
)
!=
0
)
return
-
1
;
return
0
;
}
static
int32_t
tscSetLogCfg
(
SConfig
*
pCfg
)
{
tstrncpy
(
tsLogDir
,
cfgGetItem
(
pCfg
,
"logDir"
)
->
str
,
PATH_MAX
);
tsAsyncLog
=
cfgGetItem
(
pCfg
,
"asyncLog"
)
->
bval
;
tsNumOfLogLines
=
cfgGetItem
(
pCfg
,
"numOfLogLines"
)
->
i32
;
tsLogKeepDays
=
cfgGetItem
(
pCfg
,
"logKeepDays"
)
->
i32
;
cDebugFlag
=
cfgGetItem
(
pCfg
,
"cDebugFlag"
)
->
i32
;
jniDebugFlag
=
cfgGetItem
(
pCfg
,
"jniDebugFlag"
)
->
i32
;
tmrDebugFlag
=
cfgGetItem
(
pCfg
,
"tmrDebugFlag"
)
->
i32
;
uDebugFlag
=
cfgGetItem
(
pCfg
,
"uDebugFlag"
)
->
i32
;
rpcDebugFlag
=
cfgGetItem
(
pCfg
,
"rpcDebugFlag"
)
->
i32
;
int32_t
debugFlag
=
cfgGetItem
(
pCfg
,
"debugFlag"
)
->
i32
;
taosSetAllDebugFlag
(
debugFlag
);
return
0
;
}
int32_t
tscInitLog
(
const
char
*
cfgDir
,
const
char
*
envFile
,
const
char
*
apolloUrl
)
{
SConfig
*
pCfg
=
cfgInit
();
if
(
pCfg
==
NULL
)
return
-
1
;
if
(
tscAddLogCfg
(
pCfg
)
!=
0
)
{
printf
(
"failed to add log cfg since %s
\n
"
,
terrstr
());
cfgCleanup
(
pCfg
);
return
-
1
;
}
if
(
tscLoadCfg
(
pCfg
,
cfgDir
,
envFile
,
apolloUrl
)
!=
0
)
{
printf
(
"failed to load log cfg since %s
\n
"
,
terrstr
());
cfgCleanup
(
pCfg
);
return
-
1
;
}
if
(
tscSetLogCfg
(
pCfg
)
!=
0
)
{
printf
(
"failed to set log cfg since %s
\n
"
,
terrstr
());
cfgCleanup
(
pCfg
);
return
-
1
;
}
const
int32_t
maxLogFileNum
=
10
;
if
(
taosInitLog
(
"taoslog"
,
maxLogFileNum
)
!=
0
)
{
printf
(
"failed to init log file since %s
\n
"
,
terrstr
());
cfgCleanup
(
pCfg
);
return
-
1
;
}
cfgCleanup
(
pCfg
);
return
0
;
}
static
int32_t
tscAddEpCfg
(
SConfig
*
pCfg
)
{
char
defaultFqdn
[
TSDB_FQDN_LEN
]
=
{
0
};
if
(
taosGetFqdn
(
defaultFqdn
)
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
}
if
(
cfgAddString
(
pCfg
,
"fqdn"
,
defaultFqdn
)
!=
0
)
return
-
1
;
int32_t
defaultServerPort
=
6030
;
if
(
cfgAddInt32
(
pCfg
,
"serverPort"
,
defaultServerPort
,
1
,
65056
)
!=
0
)
return
-
1
;
char
defaultFirstEp
[
TSDB_EP_LEN
]
=
{
0
};
char
defaultSecondEp
[
TSDB_EP_LEN
]
=
{
0
};
snprintf
(
defaultFirstEp
,
TSDB_EP_LEN
,
"%s:%d"
,
defaultFqdn
,
defaultServerPort
);
snprintf
(
defaultSecondEp
,
TSDB_EP_LEN
,
"%s:%d"
,
defaultFqdn
,
defaultServerPort
);
if
(
cfgAddString
(
pCfg
,
"firstEp"
,
defaultFirstEp
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"secondEp"
,
defaultSecondEp
)
!=
0
)
return
-
1
;
return
0
;
}
static
int32_t
tscAddCfg
(
SConfig
*
pCfg
)
{
if
(
tscAddEpCfg
(
pCfg
)
!=
0
)
return
-
1
;
// if (cfgAddString(pCfg, "buildinfo", buildinfo) != 0) return -1;
// if (cfgAddString(pCfg, "gitinfo", gitinfo) != 0) return -1;
// if (cfgAddString(pCfg, "version", version) != 0) return -1;
// if (cfgAddDir(pCfg, "dataDir", tsDataDir) != 0) return -1;
if
(
cfgAddTimezone
(
pCfg
,
"timezone"
,
""
)
!=
0
)
return
-
1
;
if
(
cfgAddLocale
(
pCfg
,
"locale"
,
""
)
!=
0
)
return
-
1
;
if
(
cfgAddCharset
(
pCfg
,
"charset"
,
""
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"numOfCores"
,
1
,
1
,
100000
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"numOfCommitThreads"
,
4
,
1
,
1000
)
!=
0
)
return
-
1
;
// if (cfgAddBool(pCfg, "telemetryReporting", 0) != 0) return -1;
// if (cfgAddBool(pCfg, "enableCoreFile", 0) != 0) return -1;
// if (cfgAddInt32(pCfg, "supportVnodes", 256, 0, 65536) != 0) return -1;
if
(
cfgAddInt32
(
pCfg
,
"statusInterval"
,
1
,
1
,
30
)
!=
0
)
return
-
1
;
if
(
cfgAddFloat
(
pCfg
,
"numOfThreadsPerCore"
,
1
,
0
,
10
)
!=
0
)
return
-
1
;
if
(
cfgAddFloat
(
pCfg
,
"ratioOfQueryCores"
,
1
,
0
,
5
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"maxShellConns"
,
50000
,
10
,
50000000
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"shellActivityTimer"
,
3
,
1
,
120
)
!=
0
)
return
-
1
;
return
0
;
}
int32_t
tscCheckCfg
(
SConfig
*
pCfg
)
{
bool
enableCore
=
cfgGetItem
(
pCfg
,
"enableCoreFile"
)
->
bval
;
taosSetCoreDump
(
enableCore
);
return
0
;
}
SConfig
*
tscInitCfgImp
(
const
char
*
cfgDir
,
const
char
*
envFile
,
const
char
*
apolloUrl
)
{
SConfig
*
pCfg
=
cfgInit
();
if
(
pCfg
==
NULL
)
return
NULL
;
if
(
tscAddLogCfg
(
pCfg
)
!=
0
)
{
uError
(
"failed to add log cfg since %s"
,
terrstr
());
cfgCleanup
(
pCfg
);
return
NULL
;
}
if
(
tscAddCfg
(
pCfg
)
!=
0
)
{
uError
(
"failed to init tsc cfg since %s"
,
terrstr
());
cfgCleanup
(
pCfg
);
return
NULL
;
}
if
(
tscLoadCfg
(
pCfg
,
cfgDir
,
envFile
,
apolloUrl
)
!=
0
)
{
printf
(
"failed to load tsc cfg since %s
\n
"
,
terrstr
());
cfgCleanup
(
pCfg
);
return
NULL
;
}
if
(
tscCheckCfg
(
pCfg
)
!=
0
)
{
uError
(
"failed to check cfg since %s"
,
terrstr
());
cfgCleanup
(
pCfg
);
return
NULL
;
}
cfgDumpCfg
(
pCfg
);
return
pCfg
;
}
int32_t
tscInitCfg
(
const
char
*
cfgDir
,
const
char
*
envFile
,
const
char
*
apolloUrl
)
{
tscCfg
=
tscInitCfgImp
(
cfgDir
,
envFile
,
apolloUrl
);
if
(
tscCfg
==
NULL
)
return
-
1
;
return
0
;
}
\ No newline at end of file
source/client/src/clientEnv.c
浏览文件 @
cefb07bc
...
...
@@ -72,22 +72,6 @@ static void deregisterRequest(SRequestObj* pRequest) {
taosReleaseRef
(
clientConnRefPool
,
pTscObj
->
id
);
}
static
void
tscInitLogFile
()
{
#if 0
taosReadGlobalLogCfg();
if (mkdir(tsLogDir, 0755) != 0 && errno != EEXIST) {
printf("failed to create log dir:%s\n", tsLogDir);
}
const char *defaultLogFileNamePrefix = "taoslog";
const int32_t maxLogFileNum = 10;
if (taosInitLog(defaultLogFileNamePrefix, maxLogFileNum) < 0) {
printf("failed to open log file in directory:%s\n", tsLogDir);
}
#endif
}
// todo close the transporter properly
void
closeTransporter
(
STscObj
*
pTscObj
)
{
if
(
pTscObj
==
NULL
||
pTscObj
->
pAppInfo
->
pTransporter
==
NULL
)
{
...
...
@@ -224,11 +208,17 @@ void taos_init_imp(void) {
srand
(
taosGetTimestampSec
());
deltaToUtcInitOnce
();
#if 0
taosInitGlobalCfg();
taosReadCfgFromFile();
#endif
tscInitLogFile
();
if
(
tscInitLog
(
configDir
,
NULL
,
NULL
)
!=
0
)
{
tscInitRes
=
-
1
;
return
;
}
if
(
tscInitCfg
(
configDir
,
NULL
,
NULL
)
!=
0
)
{
tscInitRes
=
-
1
;
return
;
}
if
(
taosCheckAndPrintCfg
())
{
tscInitRes
=
-
1
;
return
;
...
...
@@ -245,7 +235,7 @@ void taos_init_imp(void) {
SSchedulerCfg
scfg
=
{.
maxJobNum
=
100
};
schedulerInit
(
&
scfg
);
tscDebug
(
"starting to initialize TAOS driver
, local ep: %s"
,
tsLocalEp
);
tscDebug
(
"starting to initialize TAOS driver
"
);
taosSetCoreDump
(
true
);
...
...
source/client/src/clientImpl.c
浏览文件 @
cefb07bc
...
...
@@ -90,7 +90,9 @@ TAOS* taos_connect_internal(const char* ip, const char* user, const char* pass,
epSet
.
epSet
.
eps
[
0
].
port
=
port
;
}
}
else
{
if
(
initEpSetFromCfg
(
tsFirst
,
tsSecond
,
&
epSet
)
<
0
)
{
SConfigItem
*
pFirst
=
cfgGetItem
(
tscCfg
,
"firstEp"
);
SConfigItem
*
pSecond
=
cfgGetItem
(
tscCfg
,
"secondEp"
);
if
(
initEpSetFromCfg
(
pFirst
->
str
,
pSecond
->
str
,
&
epSet
)
<
0
)
{
return
NULL
;
}
}
...
...
source/client/src/clientMain.c
浏览文件 @
cefb07bc
...
...
@@ -56,7 +56,7 @@ void taos_cleanup(void) {
}
TAOS
*
taos_connect
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
pass
,
const
char
*
db
,
uint16_t
port
)
{
int32_t
p
=
(
port
!=
0
)
?
port
:
tsServerPort
;
int32_t
p
=
(
port
!=
0
)
?
port
:
cfgGetItem
(
tscCfg
,
"serverPort"
)
->
i32
;
tscDebug
(
"try to connect to %s:%u, user:%s db:%s"
,
ip
,
p
,
user
,
db
);
if
(
user
==
NULL
)
{
...
...
source/client/test/CMakeLists.txt
浏览文件 @
cefb07bc
...
...
@@ -8,13 +8,13 @@ AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST)
ADD_EXECUTABLE
(
clientTest clientTests.cpp
)
TARGET_LINK_LIBRARIES
(
clientTest
PUBLIC os util common transport parser catalog scheduler function gtest taos qcom
PUBLIC os util common transport parser catalog scheduler function gtest taos qcom
config
)
ADD_EXECUTABLE
(
tmqTest tmqTest.cpp
)
TARGET_LINK_LIBRARIES
(
tmqTest
PUBLIC os util common transport parser catalog scheduler function gtest taos qcom
PUBLIC os util common transport parser catalog scheduler function gtest taos qcom
config
)
TARGET_INCLUDE_DIRECTORIES
(
...
...
source/common/src/tep.c
浏览文件 @
cefb07bc
...
...
@@ -14,10 +14,12 @@ int taosGetFqdnPortFromEp(const char *ep, SEp* pEp) {
pEp
->
port
=
atoi
(
temp
+
1
);
}
#if 0
if (pEp->port == 0) {
pEp->port = tsServerPort;
return -1;
}
#endif
return
0
;
}
...
...
source/common/src/tglobal.c
浏览文件 @
cefb07bc
...
...
@@ -28,11 +28,6 @@
#include "ulog.h"
// cluster
char
tsFirst
[
TSDB_EP_LEN
]
=
{
0
};
char
tsSecond
[
TSDB_EP_LEN
]
=
{
0
};
char
tsLocalFqdn
[
TSDB_FQDN_LEN
]
=
{
0
};
char
tsLocalEp
[
TSDB_EP_LEN
]
=
{
0
};
// Local End Point, hostname:port
uint16_t
tsServerPort
=
6030
;
int32_t
tsStatusInterval
=
1
;
// second
int8_t
tsEnableTelemetryReporting
=
0
;
char
tsEmail
[
TSDB_FQDN_LEN
]
=
{
0
};
...
...
@@ -293,38 +288,6 @@ static void doInitGlobalConfig(void) {
#if 0
SGlobalCfg cfg = {0};
// ip address
cfg.option = "firstEp";
cfg.ptr = tsFirst;
cfg.valType = TAOS_CFG_VTYPE_STRING;
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT;
cfg.minValue = 0;
cfg.maxValue = 0;
cfg.ptrLength = TSDB_EP_LEN;
cfg.unitType = TAOS_CFG_UTYPE_NONE;
taosAddConfigOption(cfg);
cfg.option = "secondEp";
cfg.ptr = tsSecond;
cfg.valType = TAOS_CFG_VTYPE_STRING;
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT;
cfg.minValue = 0;
cfg.maxValue = 0;
cfg.ptrLength = TSDB_EP_LEN;
cfg.unitType = TAOS_CFG_UTYPE_NONE;
taosAddConfigOption(cfg);
cfg.option = "fqdn";
cfg.ptr = tsLocalFqdn;
cfg.valType = TAOS_CFG_VTYPE_STRING;
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT;
cfg.minValue = 0;
cfg.maxValue = 0;
cfg.ptrLength = TSDB_FQDN_LEN;
cfg.unitType = TAOS_CFG_UTYPE_NONE;
taosAddConfigOption(cfg);
cfg.option = "scriptDir";
cfg.ptr = tsScriptDir;
cfg.valType = TAOS_CFG_VTYPE_DIRECTORY;
...
...
@@ -723,26 +686,6 @@ int32_t taosCheckAndPrintCfg() {
taosSetAllDebugFlag();
}
if (tsLocalFqdn[0] == 0) {
taosGetFqdn(tsLocalFqdn);
}
snprintf(tsLocalEp, sizeof(tsLocalEp), "%s:%u", tsLocalFqdn, tsServerPort);
uInfo("localEp is: %s", tsLocalEp);
if (tsFirst[0] == 0) {
strcpy(tsFirst, tsLocalEp);
} else {
taosGetFqdnPortFromEp(tsFirst, &ep);
snprintf(tsFirst, sizeof(tsFirst), "%s:%u", ep.fqdn, ep.port);
}
if (tsSecond[0] == 0) {
strcpy(tsSecond, tsLocalEp);
} else {
taosGetFqdnPortFromEp(tsSecond, &ep);
snprintf(tsSecond, sizeof(tsSecond), "%s:%u", ep.fqdn, ep.port);
}
taosCheckDataDirCfg();
...
...
source/dnode/mgmt/daemon/src/dmnCfg.c
浏览文件 @
cefb07bc
...
...
@@ -16,14 +16,35 @@
#define _DEFAULT_SOURCE
#include "dmnInt.h"
static
int32_t
dmnAddEpCfg
(
SConfig
*
pCfg
)
{
char
defaultFqdn
[
TSDB_FQDN_LEN
]
=
{
0
};
if
(
taosGetFqdn
(
defaultFqdn
)
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
}
if
(
cfgAddString
(
pCfg
,
"fqdn"
,
defaultFqdn
)
!=
0
)
return
-
1
;
int32_t
defaultServerPort
=
6030
;
if
(
cfgAddInt32
(
pCfg
,
"serverPort"
,
defaultServerPort
,
1
,
65056
)
!=
0
)
return
-
1
;
char
defaultFirstEp
[
TSDB_EP_LEN
]
=
{
0
};
char
defaultSecondEp
[
TSDB_EP_LEN
]
=
{
0
};
snprintf
(
defaultFirstEp
,
TSDB_EP_LEN
,
"%s:%d"
,
defaultFqdn
,
defaultServerPort
);
snprintf
(
defaultSecondEp
,
TSDB_EP_LEN
,
"%s:%d"
,
defaultFqdn
,
defaultServerPort
);
if
(
cfgAddString
(
pCfg
,
"firstEp"
,
defaultFirstEp
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"secondEp"
,
defaultSecondEp
)
!=
0
)
return
-
1
;
return
0
;
}
static
int32_t
dmnAddDnodeCfg
(
SConfig
*
pCfg
)
{
if
(
dmnAddEpCfg
(
pCfg
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"buildinfo"
,
buildinfo
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"gitinfo"
,
gitinfo
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"version"
,
version
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"firstEp"
,
""
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"secondEp"
,
""
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"fqdn"
,
""
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"serverPort"
,
6030
,
1
,
65056
)
!=
0
)
return
-
1
;
if
(
cfgAddDir
(
pCfg
,
"dataDir"
,
tsDataDir
)
!=
0
)
return
-
1
;
if
(
cfgAddTimezone
(
pCfg
,
"timezone"
,
""
)
!=
0
)
return
-
1
;
if
(
cfgAddLocale
(
pCfg
,
"locale"
,
""
)
!=
0
)
return
-
1
;
...
...
@@ -55,7 +76,7 @@ SConfig *dmnReadCfg(const char *cfgDir, const char *envFile, const char *apolloU
if
(
pCfg
==
NULL
)
return
NULL
;
if
(
dmnAddLogCfg
(
pCfg
)
!=
0
)
{
printf
(
"failed to add log cfg since %s
\n
"
,
terrstr
());
uError
(
"failed to add log cfg since %s
"
,
terrstr
());
cfgCleanup
(
pCfg
);
return
NULL
;
}
...
...
source/libs/config/src/config.c
浏览文件 @
cefb07bc
...
...
@@ -570,86 +570,82 @@ void cfgDumpCfg(SConfig *pCfg) {
uInfo
(
"=================================="
);
}
int32_t
cfgCheck
(
SConfig
*
pCfg
)
{
SConfigItem
*
pItem
=
NULL
;
pItem
=
cfgGetItem
(
pCfg
,
"localFqdn"
);
if
(
pItem
!=
NULL
)
{
tstrncpy
(
tsLocalFqdn
,
pItem
->
str
,
TSDB_FQDN_LEN
);
}
pItem
=
cfgGetItem
(
pCfg
,
"serverPort"
);
if
(
pItem
!=
NULL
)
{
tsServerPort
=
(
uint16_t
)
pItem
->
i32
;
}
pItem
=
cfgGetItem
(
pCfg
,
"firstEp"
);
if
(
pItem
!=
NULL
)
{
tstrncpy
(
tsFirst
,
pItem
->
str
,
TSDB_EP_LEN
);
}
snprintf
(
tsLocalEp
,
TSDB_EP_LEN
,
"%s:%u"
,
tsLocalFqdn
,
tsServerPort
);
uInfo
(
"localEp is: %s"
,
tsLocalEp
);
SEp
ep
=
{
0
};
if
(
tsFirst
[
0
]
==
0
)
{
strcpy
(
tsFirst
,
tsLocalEp
);
}
else
{
taosGetFqdnPortFromEp
(
tsFirst
,
&
ep
);
snprintf
(
tsFirst
,
TSDB_EP_LEN
,
"%s:%u"
,
ep
.
fqdn
,
ep
.
port
);
}
pItem
=
cfgGetItem
(
pCfg
,
"secondEp"
);
if
(
pItem
!=
NULL
)
{
tstrncpy
(
tsSecond
,
pItem
->
str
,
TSDB_EP_LEN
);
}
if
(
tsSecond
[
0
]
==
0
)
{
strcpy
(
tsSecond
,
tsLocalEp
);
}
else
{
taosGetFqdnPortFromEp
(
tsSecond
,
&
ep
);
snprintf
(
tsSecond
,
TSDB_EP_LEN
,
"%s:%u"
,
ep
.
fqdn
,
ep
.
port
);
}
pItem
=
cfgGetItem
(
pCfg
,
"dataDir"
);
if
(
pItem
!=
NULL
)
{
tstrncpy
(
tsDataDir
,
pItem
->
str
,
PATH_MAX
);
}
if
(
tsDiskCfgNum
<=
0
)
{
taosAddDataDir
(
0
,
tsDataDir
,
0
,
1
);
tsDiskCfgNum
=
1
;
uTrace
(
"dataDir:%s, level:0 primary:1 is configured by default"
,
tsDataDir
);
}
if
(
taosDirExist
(
tsTempDir
)
!=
0
)
{
return
-
1
;
}
taosGetSystemInfo
();
tsSetLocale
();
// SGlobalCfg *cfg_timezone = taosGetConfigOption("timezone");
// if (cfg_timezone && cfg_timezone->cfgStatus == TAOS_CFG_CSTATUS_FILE) {
tsSetTimeZone
();
// }
pItem
=
cfgGetItem
(
pCfg
,
"numOfCores"
);
if
(
pItem
!=
NULL
)
{
tsNumOfCores
=
pItem
->
i32
;
}
if
(
tsNumOfCores
<=
0
)
{
tsNumOfCores
=
1
;
}
if
(
tsQueryBufferSize
>=
0
)
{
tsQueryBufferSizeBytes
=
tsQueryBufferSize
*
1048576UL
;
}
cfgPrintCfg
(
pCfg
);
return
0
;
}
#if 0
// int32_t cfgCheck(SConfig *pCfg) {
// SConfigItem *pItem = NULL;
// pItem = cfgGetItem(pCfg, "serverPort");
// if (pItem != NULL) {
// tsServerPort = (uint16_t)pItem->i32;
// }
// pItem = cfgGetItem(pCfg, "firstEp");
// if (pItem != NULL) {
// tstrncpy(tsFirst, pItem->str, TSDB_EP_LEN);
// }
// snprintf(tsLocalEp, TSDB_EP_LEN, "%s:%u", tsLocalFqdn, tsServerPort);
// uInfo("localEp is: %s", tsLocalEp);
// SEp ep = {0};
// if (tsFirst[0] == 0) {
// strcpy(tsFirst, tsLocalEp);
// } else {
// taosGetFqdnPortFromEp(tsFirst, &ep);
// snprintf(tsFirst, TSDB_EP_LEN, "%s:%u", ep.fqdn, ep.port);
// }
// pItem = cfgGetItem(pCfg, "secondEp");
// if (pItem != NULL) {
// tstrncpy(tsSecond, pItem->str, TSDB_EP_LEN);
// }
// if (tsSecond[0] == 0) {
// strcpy(tsSecond, tsLocalEp);
// } else {
// taosGetFqdnPortFromEp(tsSecond, &ep);
// snprintf(tsSecond, TSDB_EP_LEN, "%s:%u", ep.fqdn, ep.port);
// }
// pItem = cfgGetItem(pCfg, "dataDir");
// if (pItem != NULL) {
// tstrncpy(tsDataDir, pItem->str, PATH_MAX);
// }
// if (tsDiskCfgNum <= 0) {
// taosAddDataDir(0, tsDataDir, 0, 1);
// tsDiskCfgNum = 1;
// uTrace("dataDir:%s, level:0 primary:1 is configured by default", tsDataDir);
// }
// if (taosDirExist(tsTempDir) != 0) {
// return -1;
// }
// taosGetSystemInfo();
// tsSetLocale();
// // SGlobalCfg *cfg_timezone = taosGetConfigOption("timezone");
// // if (cfg_timezone && cfg_timezone->cfgStatus == TAOS_CFG_CSTATUS_FILE) {
// tsSetTimeZone();
// // }
// pItem = cfgGetItem(pCfg, "numOfCores");
// if (pItem != NULL) {
// tsNumOfCores = pItem->i32;
// }
// if (tsNumOfCores <= 0) {
// tsNumOfCores = 1;
// }
// if (tsQueryBufferSize >= 0) {
// tsQueryBufferSizeBytes = tsQueryBufferSize * 1048576UL;
// }
// cfgPrintCfg(pCfg);
// return 0;
// }
#endif
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录