提交 cefb07bc 编写于 作者: S Shengliang Guan

config for client

上级 0a0dfd5f
...@@ -24,11 +24,6 @@ extern "C" { ...@@ -24,11 +24,6 @@ extern "C" {
#include "tcfg.h" #include "tcfg.h"
// cluster // cluster
extern char tsFirst[];
extern char tsSecond[];
extern char tsLocalFqdn[];
extern char tsLocalEp[];
extern uint16_t tsServerPort;
extern int32_t tsStatusInterval; extern int32_t tsStatusInterval;
extern int8_t tsEnableTelemetryReporting; extern int8_t tsEnableTelemetryReporting;
extern int32_t tsNumOfSupportVnodes; extern int32_t tsNumOfSupportVnodes;
......
...@@ -8,7 +8,7 @@ target_include_directories( ...@@ -8,7 +8,7 @@ target_include_directories(
target_link_libraries( target_link_libraries(
taos taos
INTERFACE api 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}) if(${BUILD_TEST})
......
...@@ -32,6 +32,8 @@ extern "C" { ...@@ -32,6 +32,8 @@ extern "C" {
#include "query.h" #include "query.h"
#include "parser.h" #include "parser.h"
#include "config.h"
#define CHECK_CODE_GOTO(expr, label) \ #define CHECK_CODE_GOTO(expr, label) \
do { \ do { \
int32_t code = expr; \ int32_t code = expr; \
...@@ -253,6 +255,11 @@ int hbAddConnInfo(SAppHbMgr* pAppHbMgr, SClientHbKey connKey, void* key, void* v ...@@ -253,6 +255,11 @@ int hbAddConnInfo(SAppHbMgr* pAppHbMgr, SClientHbKey connKey, void* key, void* v
// --- mq // --- mq
void hbMgrInitMqHbRspHandle(); 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 #ifdef __cplusplus
} }
......
/*
* 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
...@@ -72,22 +72,6 @@ static void deregisterRequest(SRequestObj* pRequest) { ...@@ -72,22 +72,6 @@ static void deregisterRequest(SRequestObj* pRequest) {
taosReleaseRef(clientConnRefPool, pTscObj->id); 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 // todo close the transporter properly
void closeTransporter(STscObj* pTscObj) { void closeTransporter(STscObj* pTscObj) {
if (pTscObj == NULL || pTscObj->pAppInfo->pTransporter == NULL) { if (pTscObj == NULL || pTscObj->pAppInfo->pTransporter == NULL) {
...@@ -224,11 +208,17 @@ void taos_init_imp(void) { ...@@ -224,11 +208,17 @@ void taos_init_imp(void) {
srand(taosGetTimestampSec()); srand(taosGetTimestampSec());
deltaToUtcInitOnce(); deltaToUtcInitOnce();
#if 0
taosInitGlobalCfg(); if (tscInitLog(configDir, NULL, NULL) != 0) {
taosReadCfgFromFile(); tscInitRes = -1;
#endif return;
tscInitLogFile(); }
if (tscInitCfg(configDir, NULL, NULL) != 0) {
tscInitRes = -1;
return;
}
if (taosCheckAndPrintCfg()) { if (taosCheckAndPrintCfg()) {
tscInitRes = -1; tscInitRes = -1;
return; return;
...@@ -245,7 +235,7 @@ void taos_init_imp(void) { ...@@ -245,7 +235,7 @@ void taos_init_imp(void) {
SSchedulerCfg scfg = {.maxJobNum = 100}; SSchedulerCfg scfg = {.maxJobNum = 100};
schedulerInit(&scfg); schedulerInit(&scfg);
tscDebug("starting to initialize TAOS driver, local ep: %s", tsLocalEp); tscDebug("starting to initialize TAOS driver");
taosSetCoreDump(true); taosSetCoreDump(true);
......
...@@ -90,7 +90,9 @@ TAOS* taos_connect_internal(const char* ip, const char* user, const char* pass, ...@@ -90,7 +90,9 @@ TAOS* taos_connect_internal(const char* ip, const char* user, const char* pass,
epSet.epSet.eps[0].port = port; epSet.epSet.eps[0].port = port;
} }
} else { } 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; return NULL;
} }
} }
......
...@@ -56,7 +56,7 @@ void taos_cleanup(void) { ...@@ -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) { 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); tscDebug("try to connect to %s:%u, user:%s db:%s", ip, p, user, db);
if (user == NULL) { if (user == NULL) {
......
...@@ -8,13 +8,13 @@ AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST) ...@@ -8,13 +8,13 @@ AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST)
ADD_EXECUTABLE(clientTest clientTests.cpp) ADD_EXECUTABLE(clientTest clientTests.cpp)
TARGET_LINK_LIBRARIES( TARGET_LINK_LIBRARIES(
clientTest 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) ADD_EXECUTABLE(tmqTest tmqTest.cpp)
TARGET_LINK_LIBRARIES( TARGET_LINK_LIBRARIES(
tmqTest 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( TARGET_INCLUDE_DIRECTORIES(
......
...@@ -14,10 +14,12 @@ int taosGetFqdnPortFromEp(const char *ep, SEp* pEp) { ...@@ -14,10 +14,12 @@ int taosGetFqdnPortFromEp(const char *ep, SEp* pEp) {
pEp->port = atoi(temp+1); pEp->port = atoi(temp+1);
} }
#if 0
if (pEp->port == 0) { if (pEp->port == 0) {
pEp->port = tsServerPort; pEp->port = tsServerPort;
return -1; return -1;
} }
#endif
return 0; return 0;
} }
......
...@@ -28,11 +28,6 @@ ...@@ -28,11 +28,6 @@
#include "ulog.h" #include "ulog.h"
// cluster // 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 int32_t tsStatusInterval = 1; // second
int8_t tsEnableTelemetryReporting = 0; int8_t tsEnableTelemetryReporting = 0;
char tsEmail[TSDB_FQDN_LEN] = {0}; char tsEmail[TSDB_FQDN_LEN] = {0};
...@@ -293,38 +288,6 @@ static void doInitGlobalConfig(void) { ...@@ -293,38 +288,6 @@ static void doInitGlobalConfig(void) {
#if 0 #if 0
SGlobalCfg cfg = {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.option = "scriptDir";
cfg.ptr = tsScriptDir; cfg.ptr = tsScriptDir;
cfg.valType = TAOS_CFG_VTYPE_DIRECTORY; cfg.valType = TAOS_CFG_VTYPE_DIRECTORY;
...@@ -723,26 +686,6 @@ int32_t taosCheckAndPrintCfg() { ...@@ -723,26 +686,6 @@ int32_t taosCheckAndPrintCfg() {
taosSetAllDebugFlag(); 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(); taosCheckDataDirCfg();
......
...@@ -16,14 +16,35 @@ ...@@ -16,14 +16,35 @@
#define _DEFAULT_SOURCE #define _DEFAULT_SOURCE
#include "dmnInt.h" #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) { static int32_t dmnAddDnodeCfg(SConfig *pCfg) {
if (dmnAddEpCfg(pCfg) != 0) return -1;
if (cfgAddString(pCfg, "buildinfo", buildinfo) != 0) return -1; if (cfgAddString(pCfg, "buildinfo", buildinfo) != 0) return -1;
if (cfgAddString(pCfg, "gitinfo", gitinfo) != 0) return -1; if (cfgAddString(pCfg, "gitinfo", gitinfo) != 0) return -1;
if (cfgAddString(pCfg, "version", version) != 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 (cfgAddDir(pCfg, "dataDir", tsDataDir) != 0) return -1;
if (cfgAddTimezone(pCfg, "timezone", "") != 0) return -1; if (cfgAddTimezone(pCfg, "timezone", "") != 0) return -1;
if (cfgAddLocale(pCfg, "locale", "") != 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 ...@@ -55,7 +76,7 @@ SConfig *dmnReadCfg(const char *cfgDir, const char *envFile, const char *apolloU
if (pCfg == NULL) return NULL; if (pCfg == NULL) return NULL;
if (dmnAddLogCfg(pCfg) != 0) { 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); cfgCleanup(pCfg);
return NULL; return NULL;
} }
......
...@@ -570,86 +570,82 @@ void cfgDumpCfg(SConfig *pCfg) { ...@@ -570,86 +570,82 @@ void cfgDumpCfg(SConfig *pCfg) {
uInfo("=================================="); uInfo("==================================");
} }
#if 0
int32_t cfgCheck(SConfig *pCfg) { // int32_t cfgCheck(SConfig *pCfg) {
SConfigItem *pItem = NULL; // SConfigItem *pItem = NULL;
pItem = cfgGetItem(pCfg, "localFqdn"); // pItem = cfgGetItem(pCfg, "serverPort");
if (pItem != NULL) { // if (pItem != NULL) {
tstrncpy(tsLocalFqdn, pItem->str, TSDB_FQDN_LEN); // tsServerPort = (uint16_t)pItem->i32;
} // }
pItem = cfgGetItem(pCfg, "serverPort"); // pItem = cfgGetItem(pCfg, "firstEp");
if (pItem != NULL) { // if (pItem != NULL) {
tsServerPort = (uint16_t)pItem->i32; // tstrncpy(tsFirst, pItem->str, TSDB_EP_LEN);
} // }
pItem = cfgGetItem(pCfg, "firstEp"); // snprintf(tsLocalEp, TSDB_EP_LEN, "%s:%u", tsLocalFqdn, tsServerPort);
if (pItem != NULL) { // uInfo("localEp is: %s", tsLocalEp);
tstrncpy(tsFirst, pItem->str, TSDB_EP_LEN);
} // SEp ep = {0};
// if (tsFirst[0] == 0) {
snprintf(tsLocalEp, TSDB_EP_LEN, "%s:%u", tsLocalFqdn, tsServerPort); // strcpy(tsFirst, tsLocalEp);
uInfo("localEp is: %s", tsLocalEp); // } else {
// taosGetFqdnPortFromEp(tsFirst, &ep);
SEp ep = {0}; // snprintf(tsFirst, TSDB_EP_LEN, "%s:%u", ep.fqdn, ep.port);
if (tsFirst[0] == 0) { // }
strcpy(tsFirst, tsLocalEp);
} else { // pItem = cfgGetItem(pCfg, "secondEp");
taosGetFqdnPortFromEp(tsFirst, &ep); // if (pItem != NULL) {
snprintf(tsFirst, TSDB_EP_LEN, "%s:%u", ep.fqdn, ep.port); // tstrncpy(tsSecond, pItem->str, TSDB_EP_LEN);
} // }
pItem = cfgGetItem(pCfg, "secondEp"); // if (tsSecond[0] == 0) {
if (pItem != NULL) { // strcpy(tsSecond, tsLocalEp);
tstrncpy(tsSecond, pItem->str, TSDB_EP_LEN); // } else {
} // taosGetFqdnPortFromEp(tsSecond, &ep);
// snprintf(tsSecond, TSDB_EP_LEN, "%s:%u", ep.fqdn, ep.port);
if (tsSecond[0] == 0) { // }
strcpy(tsSecond, tsLocalEp);
} else { // pItem = cfgGetItem(pCfg, "dataDir");
taosGetFqdnPortFromEp(tsSecond, &ep); // if (pItem != NULL) {
snprintf(tsSecond, TSDB_EP_LEN, "%s:%u", ep.fqdn, ep.port); // tstrncpy(tsDataDir, pItem->str, PATH_MAX);
} // }
pItem = cfgGetItem(pCfg, "dataDir"); // if (tsDiskCfgNum <= 0) {
if (pItem != NULL) { // taosAddDataDir(0, tsDataDir, 0, 1);
tstrncpy(tsDataDir, pItem->str, PATH_MAX); // tsDiskCfgNum = 1;
} // uTrace("dataDir:%s, level:0 primary:1 is configured by default", tsDataDir);
// }
if (tsDiskCfgNum <= 0) {
taosAddDataDir(0, tsDataDir, 0, 1); // if (taosDirExist(tsTempDir) != 0) {
tsDiskCfgNum = 1; // return -1;
uTrace("dataDir:%s, level:0 primary:1 is configured by default", tsDataDir); // }
}
// taosGetSystemInfo();
if (taosDirExist(tsTempDir) != 0) {
return -1; // tsSetLocale();
}
// // SGlobalCfg *cfg_timezone = taosGetConfigOption("timezone");
taosGetSystemInfo(); // // if (cfg_timezone && cfg_timezone->cfgStatus == TAOS_CFG_CSTATUS_FILE) {
// tsSetTimeZone();
tsSetLocale(); // // }
// SGlobalCfg *cfg_timezone = taosGetConfigOption("timezone"); // pItem = cfgGetItem(pCfg, "numOfCores");
// if (cfg_timezone && cfg_timezone->cfgStatus == TAOS_CFG_CSTATUS_FILE) { // if (pItem != NULL) {
tsSetTimeZone(); // tsNumOfCores = pItem->i32;
// } // }
pItem = cfgGetItem(pCfg, "numOfCores"); // if (tsNumOfCores <= 0) {
if (pItem != NULL) { // tsNumOfCores = 1;
tsNumOfCores = pItem->i32; // }
}
// if (tsQueryBufferSize >= 0) {
if (tsNumOfCores <= 0) { // tsQueryBufferSizeBytes = tsQueryBufferSize * 1048576UL;
tsNumOfCores = 1; // }
}
// cfgPrintCfg(pCfg);
if (tsQueryBufferSize >= 0) {
tsQueryBufferSizeBytes = tsQueryBufferSize * 1048576UL; // return 0;
} // }
#endif
cfgPrintCfg(pCfg); \ No newline at end of file
return 0;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册