config integrate with taosd
This commit is contained in:
parent
22cb2ada73
commit
06a7ba7b80
|
@ -29,8 +29,9 @@ typedef struct SDnode SDnode;
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t sver;
|
int32_t sver;
|
||||||
int32_t numOfCores;
|
int32_t numOfCores;
|
||||||
int16_t numOfCommitThreads;
|
uint16_t numOfCommitThreads;
|
||||||
int8_t enableTelem;
|
bool enableTelem;
|
||||||
|
bool printAuth;
|
||||||
char timezone[TSDB_TIMEZONE_LEN];
|
char timezone[TSDB_TIMEZONE_LEN];
|
||||||
char locale[TSDB_LOCALE_LEN];
|
char locale[TSDB_LOCALE_LEN];
|
||||||
char charset[TSDB_LOCALE_LEN];
|
char charset[TSDB_LOCALE_LEN];
|
||||||
|
@ -65,6 +66,7 @@ typedef struct {
|
||||||
char localEp[TSDB_EP_LEN];
|
char localEp[TSDB_EP_LEN];
|
||||||
char localFqdn[TSDB_FQDN_LEN];
|
char localFqdn[TSDB_FQDN_LEN];
|
||||||
char firstEp[TSDB_EP_LEN];
|
char firstEp[TSDB_EP_LEN];
|
||||||
|
char secondEp[TSDB_EP_LEN];
|
||||||
} SDnodeObjCfg;
|
} SDnodeObjCfg;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -46,7 +46,8 @@ typedef struct SMnodeLoad {
|
||||||
|
|
||||||
typedef struct SMnodeCfg {
|
typedef struct SMnodeCfg {
|
||||||
int32_t sver;
|
int32_t sver;
|
||||||
int8_t enableTelem;
|
bool enableTelem;
|
||||||
|
bool printAuth;
|
||||||
int32_t statusInterval;
|
int32_t statusInterval;
|
||||||
int32_t shellActivityTimer;
|
int32_t shellActivityTimer;
|
||||||
char *timezone;
|
char *timezone;
|
||||||
|
|
|
@ -38,8 +38,6 @@ typedef enum {
|
||||||
typedef enum {
|
typedef enum {
|
||||||
CFG_DTYPE_NONE,
|
CFG_DTYPE_NONE,
|
||||||
CFG_DTYPE_BOOL,
|
CFG_DTYPE_BOOL,
|
||||||
CFG_DTYPE_INT8,
|
|
||||||
CFG_DTYPE_UINT16,
|
|
||||||
CFG_DTYPE_INT32,
|
CFG_DTYPE_INT32,
|
||||||
CFG_DTYPE_INT64,
|
CFG_DTYPE_INT64,
|
||||||
CFG_DTYPE_FLOAT,
|
CFG_DTYPE_FLOAT,
|
||||||
|
@ -51,37 +49,24 @@ typedef enum {
|
||||||
CFG_DTYPE_TIMEZONE
|
CFG_DTYPE_TIMEZONE
|
||||||
} ECfgDataType;
|
} ECfgDataType;
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
CFG_UTYPE_NONE,
|
|
||||||
CFG_UTYPE_GB,
|
|
||||||
CFG_UTYPE_MB,
|
|
||||||
CFG_UTYPE_BYTE,
|
|
||||||
CFG_UTYPE_SECOND,
|
|
||||||
CFG_UTYPE_MS,
|
|
||||||
CFG_UTYPE_PERCENT
|
|
||||||
} ECfgUnitType;
|
|
||||||
|
|
||||||
typedef struct SConfigItem {
|
typedef struct SConfigItem {
|
||||||
ECfgSrcType stype;
|
ECfgSrcType stype;
|
||||||
ECfgUnitType utype;
|
|
||||||
ECfgDataType dtype;
|
ECfgDataType dtype;
|
||||||
char *name;
|
char *name;
|
||||||
union {
|
union {
|
||||||
bool boolVal;
|
bool bval;
|
||||||
int8_t int8Val;
|
float fval;
|
||||||
uint16_t uint16Val;
|
int32_t i32;
|
||||||
int32_t int32Val;
|
int64_t i64;
|
||||||
int64_t int64Val;
|
char *str;
|
||||||
float floatVal;
|
|
||||||
char *strVal;
|
|
||||||
};
|
};
|
||||||
union {
|
union {
|
||||||
int64_t minIntVal;
|
int64_t imin;
|
||||||
double minFloatVal;
|
double fmin;
|
||||||
};
|
};
|
||||||
union {
|
union {
|
||||||
int64_t maxIntVal;
|
int64_t imax;
|
||||||
double maxFloatVal;
|
double fmax;
|
||||||
};
|
};
|
||||||
} SConfigItem;
|
} SConfigItem;
|
||||||
|
|
||||||
|
@ -96,27 +81,19 @@ SConfigItem *cfgIterate(SConfig *pConfig, SConfigItem *pIter);
|
||||||
void cfgCancelIterate(SConfig *pConfig, SConfigItem *pIter);
|
void cfgCancelIterate(SConfig *pConfig, SConfigItem *pIter);
|
||||||
SConfigItem *cfgGetItem(SConfig *pConfig, const char *name);
|
SConfigItem *cfgGetItem(SConfig *pConfig, const char *name);
|
||||||
|
|
||||||
int32_t cfgAddBool(SConfig *pConfig, const char *name, bool defaultVal, ECfgUnitType utype);
|
int32_t cfgAddBool(SConfig *pConfig, const char *name, bool defaultVal);
|
||||||
int32_t cfgAddInt8(SConfig *pConfig, const char *name, int8_t defaultVal, int64_t minval, int64_t maxval,
|
int32_t cfgAddInt32(SConfig *pConfig, const char *name, int32_t defaultVal, int64_t minval, int64_t maxval);
|
||||||
ECfgUnitType utype);
|
int32_t cfgAddInt64(SConfig *pConfig, const char *name, int64_t defaultVal, int64_t minval, int64_t maxval);
|
||||||
int32_t cfgAddUInt16(SConfig *pConfig, const char *name, uint16_t defaultVal, int64_t minval, int64_t maxval,
|
int32_t cfgAddFloat(SConfig *pConfig, const char *name, float defaultVal, double minval, double maxval);
|
||||||
ECfgUnitType utype);
|
int32_t cfgAddString(SConfig *pConfig, const char *name, const char *defaultVal);
|
||||||
int32_t cfgAddInt32(SConfig *pConfig, const char *name, int32_t defaultVal, int64_t minval, int64_t maxval,
|
int32_t cfgAddIpStr(SConfig *pConfig, const char *name, const char *defaultVa);
|
||||||
ECfgUnitType utype);
|
int32_t cfgAddDir(SConfig *pConfig, const char *name, const char *defaultVal);
|
||||||
int32_t cfgAddInt64(SConfig *pConfig, const char *name, int64_t defaultVal, int64_t minval, int64_t maxval,
|
int32_t cfgAddLocale(SConfig *pConfig, const char *name, const char *defaultVal);
|
||||||
ECfgUnitType utype);
|
int32_t cfgAddCharset(SConfig *pConfig, const char *name, const char *defaultVal);
|
||||||
int32_t cfgAddFloat(SConfig *pConfig, const char *name, float defaultVal, double minval, double maxval,
|
int32_t cfgAddTimezone(SConfig *pConfig, const char *name, const char *defaultVal);
|
||||||
ECfgUnitType utype);
|
|
||||||
int32_t cfgAddString(SConfig *pConfig, const char *name, const char *defaultVal, ECfgUnitType utype);
|
|
||||||
int32_t cfgAddIpStr(SConfig *pConfig, const char *name, const char *defaultVal, ECfgUnitType utype);
|
|
||||||
int32_t cfgAddDir(SConfig *pConfig, const char *name, const char *defaultVal, ECfgUnitType utype);
|
|
||||||
int32_t cfgAddLocale(SConfig *pConfig, const char *name, const char *defaultVal, ECfgUnitType utype);
|
|
||||||
int32_t cfgAddCharset(SConfig *pConfig, const char *name, const char *defaultVal, ECfgUnitType utype);
|
|
||||||
int32_t cfgAddTimezone(SConfig *pConfig, const char *name, const char *defaultVal, ECfgUnitType utype);
|
|
||||||
|
|
||||||
const char *cfgStypeStr(ECfgSrcType type);
|
const char *cfgStypeStr(ECfgSrcType type);
|
||||||
const char *cfgDtypeStr(ECfgDataType type);
|
const char *cfgDtypeStr(ECfgDataType type);
|
||||||
const char *cfgUtypeStr(ECfgUnitType type);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,6 +74,9 @@ void taosPrintLongString(const char *flags, int32_t dflag, const char *format, .
|
||||||
|
|
||||||
void taosDumpData(unsigned char *msg, int32_t len);
|
void taosDumpData(unsigned char *msg, int32_t len);
|
||||||
|
|
||||||
|
|
||||||
|
void taosSetDebugFlag(int32_t flag);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -73,6 +73,7 @@ static void deregisterRequest(SRequestObj* pRequest) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tscInitLogFile() {
|
static void tscInitLogFile() {
|
||||||
|
#if 0
|
||||||
taosReadGlobalLogCfg();
|
taosReadGlobalLogCfg();
|
||||||
if (mkdir(tsLogDir, 0755) != 0 && errno != EEXIST) {
|
if (mkdir(tsLogDir, 0755) != 0 && errno != EEXIST) {
|
||||||
printf("failed to create log dir:%s\n", tsLogDir);
|
printf("failed to create log dir:%s\n", tsLogDir);
|
||||||
|
@ -86,6 +87,7 @@ static void tscInitLogFile() {
|
||||||
if (taosInitLog(temp, tsNumOfLogLines, maxLogFileNum) < 0) {
|
if (taosInitLog(temp, tsNumOfLogLines, maxLogFileNum) < 0) {
|
||||||
printf("failed to open log file in directory:%s\n", tsLogDir);
|
printf("failed to open log file in directory:%s\n", tsLogDir);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo close the transporter properly
|
// todo close the transporter properly
|
||||||
|
@ -224,9 +226,10 @@ void taos_init_imp(void) {
|
||||||
srand(taosGetTimestampSec());
|
srand(taosGetTimestampSec());
|
||||||
|
|
||||||
deltaToUtcInitOnce();
|
deltaToUtcInitOnce();
|
||||||
|
#if 0
|
||||||
taosInitGlobalCfg();
|
taosInitGlobalCfg();
|
||||||
taosReadCfgFromFile();
|
taosReadCfgFromFile();
|
||||||
|
#endif
|
||||||
tscInitLogFile();
|
tscInitLogFile();
|
||||||
if (taosCheckAndPrintCfg()) {
|
if (taosCheckAndPrintCfg()) {
|
||||||
tscInitRes = -1;
|
tscInitRes = -1;
|
||||||
|
@ -268,6 +271,7 @@ int taos_init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int taos_options_imp(TSDB_OPTION option, const char *str) {
|
int taos_options_imp(TSDB_OPTION option, const char *str) {
|
||||||
|
#if 0
|
||||||
SGlobalCfg *cfg = NULL;
|
SGlobalCfg *cfg = NULL;
|
||||||
|
|
||||||
switch (option) {
|
switch (option) {
|
||||||
|
@ -418,7 +422,7 @@ int taos_options_imp(TSDB_OPTION option, const char *str) {
|
||||||
tscError("Invalid option %d", option);
|
tscError("Invalid option %d", option);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -340,47 +340,6 @@ static void doInitGlobalConfig(void) {
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
||||||
taosAddConfigOption(cfg);
|
taosAddConfigOption(cfg);
|
||||||
|
|
||||||
// port
|
|
||||||
cfg.option = "serverPort";
|
|
||||||
cfg.ptr = &tsServerPort;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_UINT16;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT;
|
|
||||||
cfg.minValue = 1;
|
|
||||||
cfg.maxValue = 65056;
|
|
||||||
cfg.ptrLength = 0;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "supportVnodes";
|
|
||||||
cfg.ptr = &tsNumOfSupportVnodes;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_INT32;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT;
|
|
||||||
cfg.minValue = 0;
|
|
||||||
cfg.maxValue = 65536;
|
|
||||||
cfg.ptrLength = 0;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
// directory
|
|
||||||
cfg.option = "configDir";
|
|
||||||
cfg.ptr = configDir;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_DIRECTORY;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT;
|
|
||||||
cfg.minValue = 0;
|
|
||||||
cfg.maxValue = 0;
|
|
||||||
cfg.ptrLength = TSDB_FILENAME_LEN;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "logDir";
|
|
||||||
cfg.ptr = tsLogDir;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_DIRECTORY;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT | TSDB_CFG_CTYPE_B_LOG;
|
|
||||||
cfg.minValue = 0;
|
|
||||||
cfg.maxValue = 0;
|
|
||||||
cfg.ptrLength = TSDB_FILENAME_LEN;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "scriptDir";
|
cfg.option = "scriptDir";
|
||||||
cfg.ptr = tsScriptDir;
|
cfg.ptr = tsScriptDir;
|
||||||
|
@ -402,36 +361,6 @@ static void doInitGlobalConfig(void) {
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
||||||
taosAddConfigOption(cfg);
|
taosAddConfigOption(cfg);
|
||||||
|
|
||||||
// dnode configs
|
|
||||||
cfg.option = "numOfThreadsPerCore";
|
|
||||||
cfg.ptr = &tsNumOfThreadsPerCore;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_FLOAT;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT;
|
|
||||||
cfg.minValue = 0;
|
|
||||||
cfg.maxValue = 10;
|
|
||||||
cfg.ptrLength = 0;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "numOfCommitThreads";
|
|
||||||
cfg.ptr = &tsNumOfCommitThreads;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_INT32;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
|
|
||||||
cfg.minValue = 1;
|
|
||||||
cfg.maxValue = 100;
|
|
||||||
cfg.ptrLength = 0;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "ratioOfQueryCores";
|
|
||||||
cfg.ptr = &tsRatioOfQueryCores;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_FLOAT;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
|
|
||||||
cfg.minValue = 0.0f;
|
|
||||||
cfg.maxValue = 2.0f;
|
|
||||||
cfg.ptrLength = 0;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "maxNumOfDistinctRes";
|
cfg.option = "maxNumOfDistinctRes";
|
||||||
cfg.ptr = &tsMaxNumOfDistinctResults;
|
cfg.ptr = &tsMaxNumOfDistinctResults;
|
||||||
|
@ -494,25 +423,6 @@ static void doInitGlobalConfig(void) {
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_SECOND;
|
cfg.unitType = TAOS_CFG_UTYPE_SECOND;
|
||||||
taosAddConfigOption(cfg);
|
taosAddConfigOption(cfg);
|
||||||
|
|
||||||
cfg.option = "statusInterval";
|
|
||||||
cfg.ptr = &tsStatusInterval;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_INT32;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
|
|
||||||
cfg.minValue = 1;
|
|
||||||
cfg.maxValue = 10;
|
|
||||||
cfg.ptrLength = 0;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_SECOND;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "shellActivityTimer";
|
|
||||||
cfg.ptr = &tsShellActivityTimer;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_INT32;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT;
|
|
||||||
cfg.minValue = 1;
|
|
||||||
cfg.maxValue = 120;
|
|
||||||
cfg.ptrLength = 0;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_SECOND;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "minSlidingTime";
|
cfg.option = "minSlidingTime";
|
||||||
cfg.ptr = &tsMinSlidingTime;
|
cfg.ptr = &tsMinSlidingTime;
|
||||||
|
@ -654,47 +564,6 @@ static void doInitGlobalConfig(void) {
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
||||||
taosAddConfigOption(cfg);
|
taosAddConfigOption(cfg);
|
||||||
|
|
||||||
// locale & charset
|
|
||||||
cfg.option = "timezone";
|
|
||||||
cfg.ptr = tsTimezone;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_STRING;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT;
|
|
||||||
cfg.minValue = 0;
|
|
||||||
cfg.maxValue = 0;
|
|
||||||
cfg.ptrLength = TSDB_TIMEZONE_LEN;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "locale";
|
|
||||||
cfg.ptr = tsLocale;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_STRING;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT;
|
|
||||||
cfg.minValue = 0;
|
|
||||||
cfg.maxValue = 0;
|
|
||||||
cfg.ptrLength = TSDB_LOCALE_LEN;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "charset";
|
|
||||||
cfg.ptr = tsCharset;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_STRING;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT;
|
|
||||||
cfg.minValue = 0;
|
|
||||||
cfg.maxValue = 0;
|
|
||||||
cfg.ptrLength = TSDB_LOCALE_LEN;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
// connect configs
|
|
||||||
cfg.option = "maxShellConns";
|
|
||||||
cfg.ptr = &tsMaxShellConns;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_INT32;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
|
|
||||||
cfg.minValue = 10;
|
|
||||||
cfg.maxValue = 50000000;
|
|
||||||
cfg.ptrLength = 0;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "maxConnections";
|
cfg.option = "maxConnections";
|
||||||
cfg.ptr = &tsMaxConnections;
|
cfg.ptr = &tsMaxConnections;
|
||||||
|
@ -746,176 +615,7 @@ static void doInitGlobalConfig(void) {
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
||||||
taosAddConfigOption(cfg);
|
taosAddConfigOption(cfg);
|
||||||
|
|
||||||
// debug flag
|
|
||||||
cfg.option = "numOfLogLines";
|
|
||||||
cfg.ptr = &tsNumOfLogLines;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_INT32;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG | TSDB_CFG_CTYPE_B_CLIENT;
|
|
||||||
cfg.minValue = 1000;
|
|
||||||
cfg.maxValue = 2000000000;
|
|
||||||
cfg.ptrLength = 0;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "logKeepDays";
|
|
||||||
cfg.ptr = &tsLogKeepDays;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_INT32;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG | TSDB_CFG_CTYPE_B_CLIENT;
|
|
||||||
cfg.minValue = -365000;
|
|
||||||
cfg.maxValue = 365000;
|
|
||||||
cfg.ptrLength = 0;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "asyncLog";
|
|
||||||
cfg.ptr = &tsAsyncLog;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_INT8;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG | TSDB_CFG_CTYPE_B_CLIENT;
|
|
||||||
cfg.minValue = 0;
|
|
||||||
cfg.maxValue = 1;
|
|
||||||
cfg.ptrLength = 0;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "debugFlag";
|
|
||||||
cfg.ptr = &debugFlag;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_INT32;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG | TSDB_CFG_CTYPE_B_CLIENT;
|
|
||||||
cfg.minValue = 0;
|
|
||||||
cfg.maxValue = 255;
|
|
||||||
cfg.ptrLength = 0;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "mDebugFlag";
|
|
||||||
cfg.ptr = &mDebugFlag;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_INT32;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG;
|
|
||||||
cfg.minValue = 0;
|
|
||||||
cfg.maxValue = 255;
|
|
||||||
cfg.ptrLength = 0;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "dDebugFlag";
|
|
||||||
cfg.ptr = &dDebugFlag;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_INT32;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG;
|
|
||||||
cfg.minValue = 0;
|
|
||||||
cfg.maxValue = 255;
|
|
||||||
cfg.ptrLength = 0;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "sDebugFlag";
|
|
||||||
cfg.ptr = &sDebugFlag;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_INT32;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG;
|
|
||||||
cfg.minValue = 0;
|
|
||||||
cfg.maxValue = 255;
|
|
||||||
cfg.ptrLength = 0;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "wDebugFlag";
|
|
||||||
cfg.ptr = &wDebugFlag;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_INT32;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG;
|
|
||||||
cfg.minValue = 0;
|
|
||||||
cfg.maxValue = 255;
|
|
||||||
cfg.ptrLength = 0;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "rpcDebugFlag";
|
|
||||||
cfg.ptr = &rpcDebugFlag;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_INT32;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG | TSDB_CFG_CTYPE_B_CLIENT;
|
|
||||||
cfg.minValue = 0;
|
|
||||||
cfg.maxValue = 255;
|
|
||||||
cfg.ptrLength = 0;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "tmrDebugFlag";
|
|
||||||
cfg.ptr = &tmrDebugFlag;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_INT32;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG | TSDB_CFG_CTYPE_B_CLIENT;
|
|
||||||
cfg.minValue = 0;
|
|
||||||
cfg.maxValue = 255;
|
|
||||||
cfg.ptrLength = 0;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "cDebugFlag";
|
|
||||||
cfg.ptr = &cDebugFlag;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_INT32;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG | TSDB_CFG_CTYPE_B_CLIENT;
|
|
||||||
cfg.minValue = 0;
|
|
||||||
cfg.maxValue = 255;
|
|
||||||
cfg.ptrLength = 0;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "jniDebugFlag";
|
|
||||||
cfg.ptr = &jniDebugFlag;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_INT32;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG | TSDB_CFG_CTYPE_B_CLIENT;
|
|
||||||
cfg.minValue = 0;
|
|
||||||
cfg.maxValue = 255;
|
|
||||||
cfg.ptrLength = 0;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "uDebugFlag";
|
|
||||||
cfg.ptr = &uDebugFlag;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_INT32;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG | TSDB_CFG_CTYPE_B_CLIENT;
|
|
||||||
cfg.minValue = 0;
|
|
||||||
cfg.maxValue = 255;
|
|
||||||
cfg.ptrLength = 0;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "qDebugFlag";
|
|
||||||
cfg.ptr = &qDebugFlag;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_INT32;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG | TSDB_CFG_CTYPE_B_CLIENT;
|
|
||||||
cfg.minValue = 0;
|
|
||||||
cfg.maxValue = 255;
|
|
||||||
cfg.ptrLength = 0;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "vDebugFlag";
|
|
||||||
cfg.ptr = &vDebugFlag;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_INT32;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG;
|
|
||||||
cfg.minValue = 0;
|
|
||||||
cfg.maxValue = 255;
|
|
||||||
cfg.ptrLength = 0;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "tsdbDebugFlag";
|
|
||||||
cfg.ptr = &tsdbDebugFlag;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_INT32;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG;
|
|
||||||
cfg.minValue = 0;
|
|
||||||
cfg.maxValue = 255;
|
|
||||||
cfg.ptrLength = 0;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "cqDebugFlag";
|
|
||||||
cfg.ptr = &cqDebugFlag;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_INT32;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG;
|
|
||||||
cfg.minValue = 0;
|
|
||||||
cfg.maxValue = 255;
|
|
||||||
cfg.ptrLength = 0;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "enableRecordSql";
|
cfg.option = "enableRecordSql";
|
||||||
cfg.ptr = &tsTscEnableRecordSql;
|
cfg.ptr = &tsTscEnableRecordSql;
|
||||||
|
@ -937,46 +637,6 @@ static void doInitGlobalConfig(void) {
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
||||||
taosAddConfigOption(cfg);
|
taosAddConfigOption(cfg);
|
||||||
|
|
||||||
// version info
|
|
||||||
cfg.option = "gitinfo";
|
|
||||||
cfg.ptr = gitinfo;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_STRING;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT;
|
|
||||||
cfg.minValue = 0;
|
|
||||||
cfg.maxValue = 0;
|
|
||||||
cfg.ptrLength = 0;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "gitinfoOfInternal";
|
|
||||||
cfg.ptr = gitinfoOfInternal;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_STRING;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT;
|
|
||||||
cfg.minValue = 0;
|
|
||||||
cfg.maxValue = 0;
|
|
||||||
cfg.ptrLength = 0;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "buildinfo";
|
|
||||||
cfg.ptr = buildinfo;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_STRING;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT;
|
|
||||||
cfg.minValue = 0;
|
|
||||||
cfg.maxValue = 0;
|
|
||||||
cfg.ptrLength = 0;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "version";
|
|
||||||
cfg.ptr = version;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_STRING;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT;
|
|
||||||
cfg.minValue = 0;
|
|
||||||
cfg.maxValue = 0;
|
|
||||||
cfg.ptrLength = 0;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "maxBinaryDisplayWidth";
|
cfg.option = "maxBinaryDisplayWidth";
|
||||||
cfg.ptr = &tsMaxBinaryDisplayWidth;
|
cfg.ptr = &tsMaxBinaryDisplayWidth;
|
||||||
|
|
|
@ -20,15 +20,25 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "dnode.h"
|
#include "dnode.h"
|
||||||
#include "tglobal.h"
|
#include "tglobal.h"
|
||||||
#include "tnote.h"
|
|
||||||
#include "ulog.h"
|
#include "ulog.h"
|
||||||
|
#include "taoserror.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int32_t dnmInitCfg(SDnodeEnvCfg *pEnvCfg, SDnodeObjCfg *pObjCfg, const char *configFile, const char *envFile,
|
int32_t dmnInitLogCfg(SConfig *pCfg);
|
||||||
const char *apolloUrl);
|
int32_t dmnInitLog(const char *cfgDir, const char *envFile, const char *apolloUrl);
|
||||||
|
|
||||||
|
int32_t dmnLoadCfg(SConfig *pConfig, const char *inputCfgDir, const char *envFile, const char *apolloUrl);
|
||||||
|
SConfig *dmnReadCfg(const char *cfgDir, const char *envFile, const char *apolloUrl);
|
||||||
|
|
||||||
|
SDnodeEnvCfg dmnGetEnvCfg(SConfig *pCfg);
|
||||||
|
SDnodeObjCfg dmnGetObjCfg(SConfig *pCfg);
|
||||||
|
|
||||||
|
void dmnDumpCfg(SConfig *pCfg);
|
||||||
|
void dmnPrintVersion(SConfig *pCfg);
|
||||||
|
void dmnGenerateGrant();
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "dnode.h"
|
|
||||||
#include "dmnInt.h"
|
#include "dmnInt.h"
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
|
@ -24,14 +23,16 @@ static struct {
|
||||||
bool printAuth;
|
bool printAuth;
|
||||||
bool printVersion;
|
bool printVersion;
|
||||||
char configDir[PATH_MAX];
|
char configDir[PATH_MAX];
|
||||||
|
char envFile[PATH_MAX];
|
||||||
|
char apolloUrl[PATH_MAX];
|
||||||
} dmn = {0};
|
} dmn = {0};
|
||||||
|
|
||||||
void dmnSigintHandle(int signum, void *info, void *ctx) {
|
static void dmnSigintHandle(int signum, void *info, void *ctx) {
|
||||||
uInfo("singal:%d is received", signum);
|
uInfo("singal:%d is received", signum);
|
||||||
dmn.stop = true;
|
dmn.stop = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dmnSetSignalHandle() {
|
static void dmnSetSignalHandle() {
|
||||||
taosSetSignal(SIGTERM, dmnSigintHandle);
|
taosSetSignal(SIGTERM, dmnSigintHandle);
|
||||||
taosSetSignal(SIGHUP, dmnSigintHandle);
|
taosSetSignal(SIGHUP, dmnSigintHandle);
|
||||||
taosSetSignal(SIGINT, dmnSigintHandle);
|
taosSetSignal(SIGINT, dmnSigintHandle);
|
||||||
|
@ -39,10 +40,17 @@ void dmnSetSignalHandle() {
|
||||||
taosSetSignal(SIGBREAK, dmnSigintHandle);
|
taosSetSignal(SIGBREAK, dmnSigintHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
int dmnParseOption(int argc, char const *argv[]) {
|
static void dmnWaitSignal() {
|
||||||
|
dmnSetSignalHandle();
|
||||||
|
while (!dmn.stop) {
|
||||||
|
taosMsleep(100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t dmnParseOption(int32_t argc, char const *argv[]) {
|
||||||
tstrncpy(dmn.configDir, "/etc/taos", PATH_MAX);
|
tstrncpy(dmn.configDir, "/etc/taos", PATH_MAX);
|
||||||
|
|
||||||
for (int i = 1; i < argc; ++i) {
|
for (int32_t i = 1; i < argc; ++i) {
|
||||||
if (strcmp(argv[i], "-c") == 0) {
|
if (strcmp(argv[i], "-c") == 0) {
|
||||||
if (i < argc - 1) {
|
if (i < argc - 1) {
|
||||||
if (strlen(argv[++i]) >= PATH_MAX) {
|
if (strlen(argv[++i]) >= PATH_MAX) {
|
||||||
|
@ -58,8 +66,6 @@ int dmnParseOption(int argc, char const *argv[]) {
|
||||||
dmn.dumpConfig = true;
|
dmn.dumpConfig = true;
|
||||||
} else if (strcmp(argv[i], "-k") == 0) {
|
} else if (strcmp(argv[i], "-k") == 0) {
|
||||||
dmn.generateGrant = true;
|
dmn.generateGrant = true;
|
||||||
} else if (strcmp(argv[i], "-A") == 0) {
|
|
||||||
dmn.printAuth = true;
|
|
||||||
} else if (strcmp(argv[i], "-V") == 0) {
|
} else if (strcmp(argv[i], "-V") == 0) {
|
||||||
dmn.printVersion = true;
|
dmn.printVersion = true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -69,86 +75,17 @@ int dmnParseOption(int argc, char const *argv[]) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dmnGenerateGrant() {
|
int32_t dmnRunDnode(SConfig *pCfg) {
|
||||||
#if 0
|
SDnodeEnvCfg envCfg = dmnGetEnvCfg(pCfg);
|
||||||
grantParseParameter();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void dmnPrintVersion() {
|
|
||||||
#ifdef TD_ENTERPRISE
|
|
||||||
char *releaseName = "enterprise";
|
|
||||||
#else
|
|
||||||
char *releaseName = "community";
|
|
||||||
#endif
|
|
||||||
printf("%s version: %s compatible_version: %s\n", releaseName, version, compatible_version);
|
|
||||||
printf("gitinfo: %s\n", gitinfo);
|
|
||||||
printf("gitinfoI: %s\n", gitinfoOfInternal);
|
|
||||||
printf("builuInfo: %s\n", buildinfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
int dmnReadConfig(const char *path) {
|
|
||||||
tstrncpy(configDir, dmn.configDir, PATH_MAX);
|
|
||||||
taosInitGlobalCfg();
|
|
||||||
taosReadGlobalLogCfg();
|
|
||||||
|
|
||||||
if (taosMkDir(tsLogDir) != 0) {
|
|
||||||
printf("failed to create dir: %s, reason: %s\n", tsLogDir, strerror(errno));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
char temp[PATH_MAX];
|
|
||||||
snprintf(temp, PATH_MAX, "%s/taosdlog", tsLogDir);
|
|
||||||
if (taosInitLog(temp, tsNumOfLogLines, 1) != 0) {
|
|
||||||
printf("failed to init log file\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (taosInitNotes() != 0) {
|
|
||||||
printf("failed to init log file\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (taosReadCfgFromFile() != 0) {
|
|
||||||
uError("failed to read config");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (taosCheckAndPrintCfg() != 0) {
|
|
||||||
uError("failed to check config");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
taosSetCoreDump(tsEnableCoreFile);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void dmnDumpConfig() { taosDumpGlobalCfg(); }
|
|
||||||
|
|
||||||
void dmnWaitSignal() {
|
|
||||||
dmnSetSignalHandle();
|
|
||||||
while (!dmn.stop) {
|
|
||||||
taosMsleep(100);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int dmnRunDnode() {
|
|
||||||
SDnodeEnvCfg envCfg = {0};
|
|
||||||
SDnodeObjCfg objCfg = {0};
|
|
||||||
|
|
||||||
if (dnmInitCfg(&envCfg, &objCfg, "", "", "") != 0) {
|
|
||||||
uInfo("Failed to start TDengine since load config error");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dndInit(&envCfg) != 0) {
|
if (dndInit(&envCfg) != 0) {
|
||||||
uInfo("Failed to start TDengine, please check the log at %s", tsLogDir);
|
uInfo("Failed to start TDengine, please check the log");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDnodeObjCfg objCfg = dmnGetObjCfg(pCfg);
|
||||||
SDnode *pDnode = dndCreate(&objCfg);
|
SDnode *pDnode = dndCreate(&objCfg);
|
||||||
if (pDnode == NULL) {
|
if (pDnode == NULL) {
|
||||||
uInfo("Failed to start TDengine, please check the log at %s", tsLogDir);
|
uInfo("Failed to start TDengine, please check the log");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,19 +109,29 @@ int main(int argc, char const *argv[]) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dmn.printVersion) {
|
if (dmnInitLog(dmn.configDir, dmn.envFile, dmn.apolloUrl) != 0) {
|
||||||
dmnPrintVersion();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dmnReadConfig(dmn.configDir) != 0) {
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dmn.dumpConfig) {
|
SConfig *pCfg = dmnReadCfg(dmn.configDir, dmn.envFile, dmn.apolloUrl);
|
||||||
dmnDumpConfig();
|
if (pCfg == NULL) {
|
||||||
|
uInfo("Failed to start TDengine since read config error");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dmn.printVersion) {
|
||||||
|
dmnPrintVersion(pCfg);
|
||||||
|
cfgCleanup(pCfg);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return dmnRunDnode();
|
if (dmn.dumpConfig) {
|
||||||
|
dmnDumpCfg(pCfg);
|
||||||
|
cfgCleanup(pCfg);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t code = dmnRunDnode(pCfg);
|
||||||
|
cfgCleanup(pCfg);
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,205 +16,157 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "dmnInt.h"
|
#include "dmnInt.h"
|
||||||
|
|
||||||
static void dmnInitEnvCfg(SDnodeEnvCfg *pCfg) {
|
static int32_t dmnInitDnodeCfg(SConfig *pConfig) {
|
||||||
pCfg->sver = 30000000; // 3.0.0.0
|
if (cfgAddString(pConfig, "version", version) != 0) return -1;
|
||||||
pCfg->numOfCores = tsNumOfCores;
|
if (cfgAddString(pConfig, "buildinfo", buildinfo) != 0) return -1;
|
||||||
pCfg->numOfCommitThreads = tsNumOfCommitThreads;
|
if (cfgAddString(pConfig, "gitinfo", gitinfo) != 0) return -1;
|
||||||
pCfg->enableTelem = 0;
|
if (cfgAddTimezone(pConfig, "timezone", "") != 0) return -1;
|
||||||
tstrncpy(pCfg->timezone, tsTimezone, TSDB_TIMEZONE_LEN);
|
if (cfgAddLocale(pConfig, "locale", "") != 0) return -1;
|
||||||
tstrncpy(pCfg->locale, tsLocale, TSDB_LOCALE_LEN);
|
if (cfgAddCharset(pConfig, "charset", "") != 0) return -1;
|
||||||
tstrncpy(pCfg->charset, tsCharset, TSDB_LOCALE_LEN);
|
if (cfgAddInt32(pConfig, "numOfCores", 1, 1, 100000) != 0) return -1;
|
||||||
tstrncpy(pCfg->buildinfo, buildinfo, 64);
|
if (cfgAddInt32(pConfig, "numOfCommitThreads", 4, 1, 1000) != 0) return -1;
|
||||||
tstrncpy(pCfg->gitinfo, gitinfo, 48);
|
if (cfgAddBool(pConfig, "telemetryReporting", 0) != 0) return -1;
|
||||||
}
|
if (cfgAddBool(pConfig, "enableCoreFile", 0) != 0) return -1;
|
||||||
|
if (cfgAddInt32(pConfig, "supportVnodes", 256, 0, 65536) != 0) return -1;
|
||||||
static void dmnInitObjCfg(SDnodeObjCfg *pCfg) {
|
if (cfgAddInt32(pConfig, "statusInterval", 1, 1, 30) != 0) return -1;
|
||||||
pCfg->numOfSupportVnodes = tsNumOfSupportVnodes;
|
if (cfgAddFloat(pConfig, "numOfThreadsPerCore", 1, 0, 10) != 0) return -1;
|
||||||
pCfg->statusInterval = tsStatusInterval;
|
if (cfgAddFloat(pConfig, "ratioOfQueryCores", 1, 0, 5) != 0) return -1;
|
||||||
pCfg->numOfThreadsPerCore = tsNumOfThreadsPerCore;
|
if (cfgAddInt32(pConfig, "maxShellConns", 50000, 10, 50000000) != 0) return -1;
|
||||||
pCfg->ratioOfQueryCores = tsRatioOfQueryCores;
|
if (cfgAddInt32(pConfig, "shellActivityTimer", 3, 1, 120) != 0) return -1;
|
||||||
pCfg->maxShellConns = tsMaxShellConns;
|
if (cfgAddInt32(pConfig, "serverPort", 6030, 1, 65056) != 0) return -1;
|
||||||
pCfg->shellActivityTimer = tsShellActivityTimer;
|
|
||||||
pCfg->serverPort = tsServerPort;
|
|
||||||
tstrncpy(pCfg->dataDir, tsDataDir, TSDB_FILENAME_LEN);
|
|
||||||
tstrncpy(pCfg->localEp, tsLocalEp, TSDB_EP_LEN);
|
|
||||||
tstrncpy(pCfg->localFqdn, tsLocalFqdn, TSDB_FQDN_LEN);
|
|
||||||
tstrncpy(pCfg->firstEp, tsFirst, TSDB_EP_LEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
void taosReadGlobalLogCfg() {
|
|
||||||
FILE * fp;
|
|
||||||
char * line, *option, *value;
|
|
||||||
int olen, vlen;
|
|
||||||
char fileName[PATH_MAX] = {0};
|
|
||||||
|
|
||||||
taosExpandDir(configDir, configDir, PATH_MAX);
|
|
||||||
taosReadLogOption("logDir", tsLogDir);
|
|
||||||
|
|
||||||
sprintf(fileName, "%s/taos.cfg", configDir);
|
|
||||||
fp = fopen(fileName, "r");
|
|
||||||
if (fp == NULL) {
|
|
||||||
printf("\nconfig file:%s not found, all variables are set to default\n", fileName);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ssize_t _bytes = 0;
|
|
||||||
size_t len = 1024;
|
|
||||||
line = calloc(1, len);
|
|
||||||
|
|
||||||
while (!feof(fp)) {
|
|
||||||
memset(line, 0, len);
|
|
||||||
|
|
||||||
option = value = NULL;
|
|
||||||
olen = vlen = 0;
|
|
||||||
|
|
||||||
_bytes = tgetline(&line, &len, fp);
|
|
||||||
if (_bytes < 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
line[len - 1] = 0;
|
|
||||||
|
|
||||||
paGetToken(line, &option, &olen);
|
|
||||||
if (olen == 0) continue;
|
|
||||||
option[olen] = 0;
|
|
||||||
|
|
||||||
paGetToken(option + olen + 1, &value, &vlen);
|
|
||||||
if (vlen == 0) continue;
|
|
||||||
value[vlen] = 0;
|
|
||||||
|
|
||||||
taosReadLogOption(option, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
tfree(line);
|
|
||||||
fclose(fp);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void taosPrintCfg() {
|
|
||||||
uInfo(" taos config & system info:");
|
|
||||||
uInfo("==================================");
|
|
||||||
|
|
||||||
for (int i = 0; i < tsGlobalConfigNum; ++i) {
|
|
||||||
SGlobalCfg *cfg = tsGlobalConfig + i;
|
|
||||||
if (tscEmbeddedInUtil == 0 && !(cfg->cfgType & TSDB_CFG_CTYPE_B_CLIENT)) continue;
|
|
||||||
if (cfg->cfgType & TSDB_CFG_CTYPE_B_NOT_PRINT) continue;
|
|
||||||
|
|
||||||
int optionLen = (int)strlen(cfg->option);
|
|
||||||
int blankLen = TSDB_CFG_PRINT_LEN - optionLen;
|
|
||||||
blankLen = blankLen < 0 ? 0 : blankLen;
|
|
||||||
|
|
||||||
char blank[TSDB_CFG_PRINT_LEN];
|
|
||||||
memset(blank, ' ', TSDB_CFG_PRINT_LEN);
|
|
||||||
blank[blankLen] = 0;
|
|
||||||
|
|
||||||
switch (cfg->valType) {
|
|
||||||
case TAOS_CFG_VTYPE_INT8:
|
|
||||||
uInfo(" %s:%s%d%s", cfg->option, blank, *((int8_t *)cfg->ptr), tsGlobalUnit[cfg->unitType]);
|
|
||||||
break;
|
|
||||||
case TAOS_CFG_VTYPE_INT16:
|
|
||||||
uInfo(" %s:%s%d%s", cfg->option, blank, *((int16_t *)cfg->ptr), tsGlobalUnit[cfg->unitType]);
|
|
||||||
break;
|
|
||||||
case TAOS_CFG_VTYPE_INT32:
|
|
||||||
uInfo(" %s:%s%d%s", cfg->option, blank, *((int32_t *)cfg->ptr), tsGlobalUnit[cfg->unitType]);
|
|
||||||
break;
|
|
||||||
case TAOS_CFG_VTYPE_UINT16:
|
|
||||||
uInfo(" %s:%s%d%s", cfg->option, blank, *((uint16_t *)cfg->ptr), tsGlobalUnit[cfg->unitType]);
|
|
||||||
break;
|
|
||||||
case TAOS_CFG_VTYPE_FLOAT:
|
|
||||||
uInfo(" %s:%s%f%s", cfg->option, blank, *((float *)cfg->ptr), tsGlobalUnit[cfg->unitType]);
|
|
||||||
break;
|
|
||||||
case TAOS_CFG_VTYPE_DOUBLE:
|
|
||||||
uInfo(" %s:%s%f%s", cfg->option, blank, *((double *)cfg->ptr), tsGlobalUnit[cfg->unitType]);
|
|
||||||
break;
|
|
||||||
case TAOS_CFG_VTYPE_STRING:
|
|
||||||
case TAOS_CFG_VTYPE_IPSTR:
|
|
||||||
case TAOS_CFG_VTYPE_DIRECTORY:
|
|
||||||
uInfo(" %s:%s%s%s", cfg->option, blank, (char *)cfg->ptr, tsGlobalUnit[cfg->unitType]);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
taosPrintOsInfo();
|
|
||||||
uInfo("==================================");
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
static void taosDumpCfg(SGlobalCfg *cfg) {
|
|
||||||
int optionLen = (int)strlen(cfg->option);
|
|
||||||
int blankLen = TSDB_CFG_PRINT_LEN - optionLen;
|
|
||||||
blankLen = blankLen < 0 ? 0 : blankLen;
|
|
||||||
|
|
||||||
char blank[TSDB_CFG_PRINT_LEN];
|
|
||||||
memset(blank, ' ', TSDB_CFG_PRINT_LEN);
|
|
||||||
blank[blankLen] = 0;
|
|
||||||
|
|
||||||
switch (cfg->valType) {
|
|
||||||
case TAOS_CFG_VTYPE_INT8:
|
|
||||||
printf(" %s:%s%d%s\n", cfg->option, blank, *((int8_t *)cfg->ptr), tsGlobalUnit[cfg->unitType]);
|
|
||||||
break;
|
|
||||||
case TAOS_CFG_VTYPE_INT16:
|
|
||||||
printf(" %s:%s%d%s\n", cfg->option, blank, *((int16_t *)cfg->ptr), tsGlobalUnit[cfg->unitType]);
|
|
||||||
break;
|
|
||||||
case TAOS_CFG_VTYPE_INT32:
|
|
||||||
printf(" %s:%s%d%s\n", cfg->option, blank, *((int32_t *)cfg->ptr), tsGlobalUnit[cfg->unitType]);
|
|
||||||
break;
|
|
||||||
case TAOS_CFG_VTYPE_UINT16:
|
|
||||||
printf(" %s:%s%d%s\n", cfg->option, blank, *((uint16_t *)cfg->ptr), tsGlobalUnit[cfg->unitType]);
|
|
||||||
break;
|
|
||||||
case TAOS_CFG_VTYPE_FLOAT:
|
|
||||||
printf(" %s:%s%f%s\n", cfg->option, blank, *((float *)cfg->ptr), tsGlobalUnit[cfg->unitType]);
|
|
||||||
break;
|
|
||||||
case TAOS_CFG_VTYPE_STRING:
|
|
||||||
case TAOS_CFG_VTYPE_IPSTR:
|
|
||||||
case TAOS_CFG_VTYPE_DIRECTORY:
|
|
||||||
printf(" %s:%s%s%s\n", cfg->option, blank, (char *)cfg->ptr, tsGlobalUnit[cfg->unitType]);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void taosDumpGlobalCfg() {
|
|
||||||
printf("taos global config:\n");
|
|
||||||
printf("==================================\n");
|
|
||||||
for (int i = 0; i < tsGlobalConfigNum; ++i) {
|
|
||||||
SGlobalCfg *cfg = tsGlobalConfig + i;
|
|
||||||
if (tscEmbeddedInUtil == 0 && !(cfg->cfgType & TSDB_CFG_CTYPE_B_CLIENT)) continue;
|
|
||||||
if (cfg->cfgType & TSDB_CFG_CTYPE_B_NOT_PRINT) continue;
|
|
||||||
if (!(cfg->cfgType & TSDB_CFG_CTYPE_B_SHOW)) continue;
|
|
||||||
|
|
||||||
taosDumpCfg(cfg);
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("\ntaos local config:\n");
|
|
||||||
printf("==================================\n");
|
|
||||||
|
|
||||||
for (int i = 0; i < tsGlobalConfigNum; ++i) {
|
|
||||||
SGlobalCfg *cfg = tsGlobalConfig + i;
|
|
||||||
if (tscEmbeddedInUtil == 0 && !(cfg->cfgType & TSDB_CFG_CTYPE_B_CLIENT)) continue;
|
|
||||||
if (cfg->cfgType & TSDB_CFG_CTYPE_B_NOT_PRINT) continue;
|
|
||||||
if (cfg->cfgType & TSDB_CFG_CTYPE_B_SHOW) continue;
|
|
||||||
|
|
||||||
taosDumpCfg(cfg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static int32_t dmnInitLog() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t dnmInitCfg(SDnodeEnvCfg *pEnvCfg, SDnodeObjCfg *pObjCfg, const char *configFile, const char *envFile,
|
|
||||||
const char *apolloUrl) {
|
|
||||||
dmnInitEnvCfg(pEnvCfg);
|
|
||||||
dmnInitObjCfg(pObjCfg);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t dmnLoadCfg(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;
|
||||||
|
}
|
||||||
|
|
||||||
|
SConfig *dmnReadCfg(const char *cfgDir, const char *envFile, const char *apolloUrl) {
|
||||||
|
SConfig *pConfig = cfgInit();
|
||||||
|
if (pConfig == NULL) return NULL;
|
||||||
|
|
||||||
|
if (dmnInitLogCfg(pConfig) != 0) {
|
||||||
|
uError("failed to init log cfg since %s", terrstr());
|
||||||
|
cfgCleanup(pConfig);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dmnInitDnodeCfg(pConfig) != 0) {
|
||||||
|
uError("failed to init dnode cfg since %s", terrstr());
|
||||||
|
cfgCleanup(pConfig);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dmnLoadCfg(pConfig, cfgDir, envFile, apolloUrl) != 0) {
|
||||||
|
uError("failed to load cfg since %s", terrstr());
|
||||||
|
cfgCleanup(pConfig);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool enableCore = cfgGetItem(pConfig, "enableCoreFile")->bval;
|
||||||
|
taosSetCoreDump(enableCore);
|
||||||
|
|
||||||
|
if (taosCheckAndPrintCfg() != 0) {
|
||||||
|
uError("failed to check config");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return pConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dmnDumpCfg(SConfig *pCfg) {
|
||||||
|
printf("taos global config:\n");
|
||||||
|
printf("==================================\n");
|
||||||
|
|
||||||
|
SConfigItem *pItem = cfgIterate(pCfg, NULL);
|
||||||
|
while (pItem != NULL) {
|
||||||
|
switch (pItem->dtype) {
|
||||||
|
case CFG_DTYPE_BOOL:
|
||||||
|
printf("cfg:%s, value:%u src:%s\n", pItem->name, pItem->bval, cfgStypeStr(pItem->stype));
|
||||||
|
break;
|
||||||
|
case CFG_DTYPE_INT32:
|
||||||
|
printf("cfg:%s, value:%d src:%s\n", pItem->name, pItem->i32, cfgStypeStr(pItem->stype));
|
||||||
|
break;
|
||||||
|
case CFG_DTYPE_INT64:
|
||||||
|
printf("cfg:%s, value:%" PRId64 " src:%s\n", pItem->name, pItem->i64, cfgStypeStr(pItem->stype));
|
||||||
|
break;
|
||||||
|
case CFG_DTYPE_FLOAT:
|
||||||
|
printf("cfg:%s, value:%f src:%s\n", pItem->name, pItem->fval, cfgStypeStr(pItem->stype));
|
||||||
|
break;
|
||||||
|
case CFG_DTYPE_STRING:
|
||||||
|
case CFG_DTYPE_IPSTR:
|
||||||
|
case CFG_DTYPE_DIR:
|
||||||
|
case CFG_DTYPE_LOCALE:
|
||||||
|
case CFG_DTYPE_CHARSET:
|
||||||
|
case CFG_DTYPE_TIMEZONE:
|
||||||
|
printf("cfg:%s, value:%s src:%s\n", pItem->name, pItem->str, cfgStypeStr(pItem->stype));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
pItem = cfgIterate(pCfg, pItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SDnodeEnvCfg dmnGetEnvCfg(SConfig *pCfg) {
|
||||||
|
SDnodeEnvCfg envCfg = {0};
|
||||||
|
|
||||||
|
const char *vstr = cfgGetItem(pCfg, "version")->str;
|
||||||
|
envCfg.sver = 30000000;
|
||||||
|
tstrncpy(envCfg.buildinfo, cfgGetItem(pCfg, "buildinfo")->str, sizeof(envCfg.buildinfo));
|
||||||
|
tstrncpy(envCfg.gitinfo, cfgGetItem(pCfg, "gitinfo")->str, sizeof(envCfg.gitinfo));
|
||||||
|
tstrncpy(envCfg.timezone, cfgGetItem(pCfg, "timezone")->str, sizeof(envCfg.timezone));
|
||||||
|
tstrncpy(envCfg.locale, cfgGetItem(pCfg, "locale")->str, sizeof(envCfg.locale));
|
||||||
|
tstrncpy(envCfg.charset, cfgGetItem(pCfg, "charset")->str, sizeof(envCfg.charset));
|
||||||
|
envCfg.numOfCores = cfgGetItem(pCfg, "numOfCores")->i32;
|
||||||
|
envCfg.numOfCommitThreads = (uint16_t) cfgGetItem(pCfg, "numOfCommitThreads")->i32;
|
||||||
|
envCfg.enableTelem = cfgGetItem(pCfg, "telemetryReporting")->bval;
|
||||||
|
|
||||||
|
return envCfg;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDnodeObjCfg dmnGetObjCfg(SConfig *pCfg) {
|
||||||
|
SDnodeObjCfg objCfg = {0};
|
||||||
|
|
||||||
|
objCfg.numOfSupportVnodes = cfgGetItem(pCfg, "supportVnodes")->i32;
|
||||||
|
objCfg.statusInterval = cfgGetItem(pCfg, "statusInterval")->i32;
|
||||||
|
objCfg.numOfThreadsPerCore = cfgGetItem(pCfg, "numOfThreadsPerCore")->fval;
|
||||||
|
objCfg.ratioOfQueryCores = cfgGetItem(pCfg, "ratioOfQueryCores")->fval;
|
||||||
|
objCfg.maxShellConns = cfgGetItem(pCfg, "maxShellConns")->i32;
|
||||||
|
objCfg.shellActivityTimer = cfgGetItem(pCfg, "shellActivityTimer")->i32;
|
||||||
|
objCfg.serverPort = (uint16_t)cfgGetItem(pCfg, "serverPort")->i32;
|
||||||
|
tstrncpy(objCfg.dataDir, cfgGetItem(pCfg, "dataDir")->str, sizeof(objCfg.dataDir));
|
||||||
|
tstrncpy(objCfg.localEp, cfgGetItem(pCfg, "localEp")->str, sizeof(objCfg.localEp));
|
||||||
|
tstrncpy(objCfg.localFqdn, cfgGetItem(pCfg, "localFqdn")->str, sizeof(objCfg.localFqdn, cfgGetItem));
|
||||||
|
tstrncpy(objCfg.firstEp, cfgGetItem(pCfg, "firstEp")->str, sizeof(objCfg.firstEp));
|
||||||
|
tstrncpy(objCfg.secondEp, cfgGetItem(pCfg, "secondEp")->str, sizeof(objCfg.firstEp));
|
||||||
|
|
||||||
|
return objCfg;
|
||||||
|
}
|
|
@ -0,0 +1,67 @@
|
||||||
|
/*
|
||||||
|
* 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 "dmnInt.h"
|
||||||
|
|
||||||
|
int32_t dmnInitLogCfg(SConfig *pCfg) {
|
||||||
|
if (cfgAddDir(pCfg, "logDir", "/var/log/taos") != 0) return -1;
|
||||||
|
if (cfgAddInt32(pCfg, "numOfLogLines", 10000000, 1000, 2000000000) != 0) return -1;
|
||||||
|
if (cfgAddInt32(pCfg, "logKeepDays", 0, -365000, 365000) != 0) return -1;
|
||||||
|
if (cfgAddBool(pCfg, "asyncLog", 1) != 0) return -1;
|
||||||
|
if (cfgAddInt32(pCfg, "debugFlag", 0, 0, 255) != 0) return -1;
|
||||||
|
if (cfgAddInt32(pCfg, "mDebugFlag", 0, 0, 255) != 0) return -1;
|
||||||
|
if (cfgAddInt32(pCfg, "dDebugFlag", 0, 0, 255) != 0) return -1;
|
||||||
|
if (cfgAddInt32(pCfg, "sDebugFlag", 0, 0, 255) != 0) return -1;
|
||||||
|
if (cfgAddInt32(pCfg, "wDebugFlag", 0, 0, 255) != 0) return -1;
|
||||||
|
if (cfgAddInt32(pCfg, "rpcDebugFlag", 0, 0, 255) != 0) return -1;
|
||||||
|
if (cfgAddInt32(pCfg, "tmrDebugFlag", 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, "uDebugFlag", 0, 0, 255) != 0) return -1;
|
||||||
|
if (cfgAddInt32(pCfg, "qDebugFlag", 0, 0, 255) != 0) return -1;
|
||||||
|
if (cfgAddInt32(pCfg, "vDebugFlag", 0, 0, 255) != 0) return -1;
|
||||||
|
if (cfgAddInt32(pCfg, "tsdbDebugFlag", 0, 0, 255) != 0) return -1;
|
||||||
|
if (cfgAddInt32(pCfg, "cqDebugFlag", 0, 0, 255) != 0) return -1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t dmnInitLog(const char *cfgDir, const char *envFile, const char *apolloUrl) {
|
||||||
|
SConfig *pCfg = cfgInit();
|
||||||
|
if (pCfg == NULL) return -1;
|
||||||
|
|
||||||
|
if (dmnInitLogCfg(pCfg) != 0) {
|
||||||
|
uError("failed to init log cfg since %s\n", terrstr());
|
||||||
|
cfgCleanup(pCfg);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dmnLoadCfg(pCfg, cfgDir, envFile, apolloUrl) != 0) {
|
||||||
|
uError("failed to load log cfg since %s\n", terrstr());
|
||||||
|
cfgCleanup(pCfg);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
char temp[PATH_MAX] = {0};
|
||||||
|
snprintf(temp, PATH_MAX, "%s" TD_DIRSEP "taosdlog", cfgGetItem(pCfg, "logDir")->str);
|
||||||
|
if (taosInitLog(temp, cfgGetItem(pCfg, "numOfLogLines")->i32, 1) != 0) {
|
||||||
|
uError("failed to init log file since %s\n", terrstr());
|
||||||
|
cfgCleanup(pCfg);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
cfgCleanup(pCfg);
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* 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 "dmnInt.h"
|
||||||
|
|
||||||
|
void dmnGenerateGrant() {
|
||||||
|
#if 0
|
||||||
|
grantParseParameter();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void dmnPrintVersion(SConfig *pCfg) {
|
||||||
|
#ifdef TD_ENTERPRISE
|
||||||
|
char *releaseName = "enterprise";
|
||||||
|
#else
|
||||||
|
char *releaseName = "community";
|
||||||
|
#endif
|
||||||
|
printf("%s version: %s compatible_version: %s\n", releaseName, version, compatible_version);
|
||||||
|
printf("gitinfo: %s\n", gitinfo);
|
||||||
|
printf("gitinfoI: %s\n", gitinfoOfInternal);
|
||||||
|
printf("builuInfo: %s\n", buildinfo);
|
||||||
|
}
|
|
@ -56,7 +56,7 @@ typedef struct {
|
||||||
} SProfileMgmt;
|
} SProfileMgmt;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int8_t enable;
|
bool enable;
|
||||||
SRWLatch lock;
|
SRWLatch lock;
|
||||||
char email[TSDB_FQDN_LEN];
|
char email[TSDB_FQDN_LEN];
|
||||||
} STelemMgmt;
|
} STelemMgmt;
|
||||||
|
|
|
@ -6,7 +6,7 @@ target_include_directories(
|
||||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(config os util)
|
target_link_libraries(config os util common)
|
||||||
|
|
||||||
if(${BUILD_TEST})
|
if(${BUILD_TEST})
|
||||||
ADD_SUBDIRECTORY(test)
|
ADD_SUBDIRECTORY(test)
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "thash.h"
|
#include "thash.h"
|
||||||
#include "tutil.h"
|
#include "tutil.h"
|
||||||
#include "ulog.h"
|
#include "ulog.h"
|
||||||
|
#include "tglobal.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
|
@ -15,6 +15,10 @@
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "cfgInt.h"
|
#include "cfgInt.h"
|
||||||
|
#include "tmsg.h"
|
||||||
|
#include "tep.h"
|
||||||
|
#include "tlocale.h"
|
||||||
|
#include "ttimezone.h"
|
||||||
|
|
||||||
SConfig *cfgInit() {
|
SConfig *cfgInit() {
|
||||||
SConfig *pConfig = calloc(1, sizeof(SConfig));
|
SConfig *pConfig = calloc(1, sizeof(SConfig));
|
||||||
|
@ -23,7 +27,7 @@ SConfig *cfgInit() {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pConfig->hash = taosHashInit(64, MurmurHash3_32, false, HASH_NO_LOCK);
|
pConfig->hash = taosHashInit(16, MurmurHash3_32, false, HASH_NO_LOCK);
|
||||||
if (pConfig->hash == NULL) {
|
if (pConfig->hash == NULL) {
|
||||||
free(pConfig);
|
free(pConfig);
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -64,6 +68,85 @@ SConfigItem *cfgIterate(SConfig *pConfig, SConfigItem *pIter) { return taosHashI
|
||||||
|
|
||||||
void cfgCancelIterate(SConfig *pConfig, SConfigItem *pIter) { return taosHashCancelIterate(pConfig->hash, pIter); }
|
void cfgCancelIterate(SConfig *pConfig, SConfigItem *pIter) { return taosHashCancelIterate(pConfig->hash, pIter); }
|
||||||
|
|
||||||
|
static int32_t cfgCheckAndSetTimezone(SConfigItem *pItem, const char *timezone) {
|
||||||
|
tfree(pItem->str);
|
||||||
|
pItem->str = strdup(timezone);
|
||||||
|
if (pItem->str == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t cfgCheckAndSetCharset(SConfigItem *pItem, const char *charset) {
|
||||||
|
tfree(pItem->str);
|
||||||
|
pItem->str = strdup(charset);
|
||||||
|
if (pItem->str == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t cfgCheckAndSetLocale(SConfigItem *pItem, const char *locale) {
|
||||||
|
tfree(pItem->str);
|
||||||
|
pItem->str = strdup(locale);
|
||||||
|
if (pItem->str == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t cfgCheckAndSetDir(SConfigItem *pItem, const char *inputDir) {
|
||||||
|
char fullDir[PATH_MAX] = {0};
|
||||||
|
if (taosExpandDir(inputDir, fullDir, PATH_MAX) != 0) {
|
||||||
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
uError("failed to expand dir:%s since %s", inputDir, terrstr());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (taosRealPath(fullDir, PATH_MAX) != 0) {
|
||||||
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
uError("failed to get realpath of dir:%s since %s", inputDir, terrstr());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (taosMkDir(fullDir) != 0) {
|
||||||
|
uError("failed to create dir:%s realpath:%s since %s", inputDir, fullDir, terrstr());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
tfree(pItem->str);
|
||||||
|
pItem->str = strdup(fullDir);
|
||||||
|
if (pItem->str == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t cfgCheckAndSetIpStr(SConfigItem *pItem, const char *ip) {
|
||||||
|
uint32_t value = taosInetAddr(ip);
|
||||||
|
if (value == INADDR_NONE) {
|
||||||
|
uError("ip:%s is not a valid ip address", ip);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
tfree(pItem->str);
|
||||||
|
pItem->str = strdup(ip);
|
||||||
|
if (pItem->str == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t cfgSetBool(SConfigItem *pItem, const char *value, ECfgSrcType stype) {
|
static int32_t cfgSetBool(SConfigItem *pItem, const char *value, ECfgSrcType stype) {
|
||||||
bool tmp = false;
|
bool tmp = false;
|
||||||
if (strcasecmp(value, "true") == 0) {
|
if (strcasecmp(value, "true") == 0) {
|
||||||
|
@ -73,83 +156,53 @@ static int32_t cfgSetBool(SConfigItem *pItem, const char *value, ECfgSrcType sty
|
||||||
tmp = true;
|
tmp = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
pItem->boolVal = tmp;
|
pItem->bval = tmp;
|
||||||
pItem->stype = stype;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t cfgSetInt8(SConfigItem *pItem, const char *value, ECfgSrcType stype) {
|
|
||||||
int8_t ival = (int8_t)atoi(value);
|
|
||||||
if (ival < pItem->minIntVal || ival > pItem->maxIntVal) {
|
|
||||||
uError("cfg:%s, type:%s src:%s value:%d out of range[%" PRId64 ", %" PRId64 "], use last src:%s value:%d",
|
|
||||||
pItem->name, cfgDtypeStr(pItem->dtype), cfgStypeStr(stype), ival, pItem->minIntVal, pItem->maxIntVal,
|
|
||||||
cfgStypeStr(pItem->stype), pItem->int8Val);
|
|
||||||
terrno = TSDB_CODE_OUT_OF_RANGE;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
pItem->int8Val = ival;
|
|
||||||
pItem->stype = stype;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t cfgSetUInt16(SConfigItem *pItem, const char *value, ECfgSrcType stype) {
|
|
||||||
uint16_t ival = (uint16_t)atoi(value);
|
|
||||||
if (ival < pItem->minIntVal || ival > pItem->maxIntVal) {
|
|
||||||
uError("cfg:%s, type:%s src:%s value:%d out of range[%" PRId64 ", %" PRId64 "], use last src:%s value:%d",
|
|
||||||
pItem->name, cfgDtypeStr(pItem->dtype), cfgStypeStr(stype), ival, pItem->minIntVal, pItem->maxIntVal,
|
|
||||||
cfgStypeStr(pItem->stype), pItem->uint16Val);
|
|
||||||
terrno = TSDB_CODE_OUT_OF_RANGE;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
pItem->uint16Val = ival;
|
|
||||||
pItem->stype = stype;
|
pItem->stype = stype;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t cfgSetInt32(SConfigItem *pItem, const char *value, ECfgSrcType stype) {
|
static int32_t cfgSetInt32(SConfigItem *pItem, const char *value, ECfgSrcType stype) {
|
||||||
int32_t ival = (int32_t)atoi(value);
|
int32_t ival = (int32_t)atoi(value);
|
||||||
if (ival < pItem->minIntVal || ival > pItem->maxIntVal) {
|
if (ival < pItem->imin || ival > pItem->imax) {
|
||||||
uError("cfg:%s, type:%s src:%s value:%d out of range[%" PRId64 ", %" PRId64 "], use last src:%s value:%d",
|
uError("cfg:%s, type:%s src:%s value:%d out of range[%" PRId64 ", %" PRId64 "], use last src:%s value:%d",
|
||||||
pItem->name, cfgDtypeStr(pItem->dtype), cfgStypeStr(stype), ival, pItem->minIntVal, pItem->maxIntVal,
|
pItem->name, cfgDtypeStr(pItem->dtype), cfgStypeStr(stype), ival, pItem->imin, pItem->imax,
|
||||||
cfgStypeStr(pItem->stype), pItem->int32Val);
|
cfgStypeStr(pItem->stype), pItem->i32);
|
||||||
terrno = TSDB_CODE_OUT_OF_RANGE;
|
terrno = TSDB_CODE_OUT_OF_RANGE;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
pItem->int32Val = ival;
|
pItem->i32 = ival;
|
||||||
pItem->stype = stype;
|
pItem->stype = stype;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t cfgSetInt64(SConfigItem *pItem, const char *value, ECfgSrcType stype) {
|
static int32_t cfgSetInt64(SConfigItem *pItem, const char *value, ECfgSrcType stype) {
|
||||||
int64_t ival = (int64_t)atoi(value);
|
int64_t ival = (int64_t)atoi(value);
|
||||||
if (ival < pItem->minIntVal || ival > pItem->maxIntVal) {
|
if (ival < pItem->imin || ival > pItem->imax) {
|
||||||
uError("cfg:%s, type:%s src:%s value:%" PRId64 " out of range[%" PRId64 ", %" PRId64
|
uError("cfg:%s, type:%s src:%s value:%" PRId64 " out of range[%" PRId64 ", %" PRId64
|
||||||
"], use last src:%s value:%" PRId64,
|
"], use last src:%s value:%" PRId64,
|
||||||
pItem->name, cfgDtypeStr(pItem->dtype), cfgStypeStr(stype), ival, pItem->minIntVal, pItem->maxIntVal,
|
pItem->name, cfgDtypeStr(pItem->dtype), cfgStypeStr(stype), ival, pItem->imin, pItem->imax,
|
||||||
cfgStypeStr(pItem->stype), pItem->int64Val);
|
cfgStypeStr(pItem->stype), pItem->i64);
|
||||||
terrno = TSDB_CODE_OUT_OF_RANGE;
|
terrno = TSDB_CODE_OUT_OF_RANGE;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
pItem->int64Val = ival;
|
pItem->i64 = ival;
|
||||||
pItem->stype = stype;
|
pItem->stype = stype;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t cfgSetFloat(SConfigItem *pItem, const char *value, ECfgSrcType stype) {
|
static int32_t cfgSetFloat(SConfigItem *pItem, const char *value, ECfgSrcType stype) {
|
||||||
float fval = (float)atof(value);
|
float fval = (float)atof(value);
|
||||||
if (fval < pItem->minFloatVal || fval > pItem->maxFloatVal) {
|
if (fval < pItem->fmin || fval > pItem->fmax) {
|
||||||
uError("cfg:%s, type:%s src:%s value:%f out of range[%f, %f], use last src:%s value:%f", pItem->name,
|
uError("cfg:%s, type:%s src:%s value:%f out of range[%f, %f], use last src:%s value:%f", pItem->name,
|
||||||
cfgDtypeStr(pItem->dtype), cfgStypeStr(stype), fval, pItem->minFloatVal, pItem->maxFloatVal,
|
cfgDtypeStr(pItem->dtype), cfgStypeStr(stype), fval, pItem->fmin, pItem->fmax, cfgStypeStr(pItem->stype),
|
||||||
cfgStypeStr(pItem->stype), pItem->floatVal);
|
pItem->fval);
|
||||||
terrno = TSDB_CODE_OUT_OF_RANGE;
|
terrno = TSDB_CODE_OUT_OF_RANGE;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
pItem->floatVal = fval;
|
pItem->fval = fval;
|
||||||
pItem->stype = stype;
|
pItem->stype = stype;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -159,42 +212,82 @@ static int32_t cfgSetString(SConfigItem *pItem, const char *value, ECfgSrcType s
|
||||||
if (tmp == NULL) {
|
if (tmp == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
uError("cfg:%s, type:%s src:%s value:%s failed to dup since %s, use last src:%s value:%s", pItem->name,
|
uError("cfg:%s, type:%s src:%s value:%s failed to dup since %s, use last src:%s value:%s", pItem->name,
|
||||||
cfgDtypeStr(pItem->dtype), cfgStypeStr(stype), value, terrstr(), cfgStypeStr(pItem->stype), pItem->strVal);
|
cfgDtypeStr(pItem->dtype), cfgStypeStr(stype), value, terrstr(), cfgStypeStr(pItem->stype), pItem->str);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(pItem->strVal);
|
free(pItem->str);
|
||||||
pItem->strVal = tmp;
|
pItem->str = tmp;
|
||||||
pItem->stype = stype;
|
pItem->stype = stype;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t cfgSetIpStr(SConfigItem *pItem, const char *value, ECfgSrcType stype) {
|
static int32_t cfgSetIpStr(SConfigItem *pItem, const char *value, ECfgSrcType stype) {
|
||||||
char *tmp = strdup(value);
|
char *tmp = strdup(value);
|
||||||
if (tmp == NULL) {
|
if (tmp == NULL || cfgCheckAndSetIpStr(pItem, value) != 0) {
|
||||||
|
free(tmp);
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
uError("cfg:%s, type:%s src:%s value:%s failed to dup since %s, use last src:%s value:%s", pItem->name,
|
uError("cfg:%s, type:%s src:%s value:%s failed to dup since %s, use last src:%s value:%s", pItem->name,
|
||||||
cfgDtypeStr(pItem->dtype), cfgStypeStr(stype), value, terrstr(), cfgStypeStr(pItem->stype), pItem->strVal);
|
cfgDtypeStr(pItem->dtype), cfgStypeStr(stype), value, terrstr(), cfgStypeStr(pItem->stype), pItem->str);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(pItem->strVal);
|
|
||||||
pItem->strVal = tmp;
|
|
||||||
pItem->stype = stype;
|
pItem->stype = stype;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t cfgSetDir(SConfigItem *pItem, const char *value, ECfgSrcType stype) {
|
static int32_t cfgSetDir(SConfigItem *pItem, const char *value, ECfgSrcType stype) {
|
||||||
char *tmp = strdup(value);
|
char *tmp = strdup(value);
|
||||||
if (tmp == NULL) {
|
if (tmp == NULL || cfgCheckAndSetDir(pItem, value) != 0) {
|
||||||
|
free(tmp);
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
uError("cfg:%s, type:%s src:%s value:%s failed to dup since %s, use last src:%s value:%s", pItem->name,
|
uError("cfg:%s, type:%s src:%s value:%s failed to dup since %s, use last src:%s value:%s", pItem->name,
|
||||||
cfgDtypeStr(pItem->dtype), cfgStypeStr(stype), value, terrstr(), cfgStypeStr(pItem->stype), pItem->strVal);
|
cfgDtypeStr(pItem->dtype), cfgStypeStr(stype), value, terrstr(), cfgStypeStr(pItem->stype), pItem->str);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
pItem->stype = stype;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t cfgSetLocale(SConfigItem *pItem, const char *value, ECfgSrcType stype) {
|
||||||
|
char *tmp = strdup(value);
|
||||||
|
if (tmp == NULL || cfgCheckAndSetLocale(pItem, value) != 0) {
|
||||||
|
free(tmp);
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
uError("cfg:%s, type:%s src:%s value:%s failed to dup since %s, use last src:%s value:%s", pItem->name,
|
||||||
|
cfgDtypeStr(pItem->dtype), cfgStypeStr(stype), value, terrstr(), cfgStypeStr(pItem->stype), pItem->str);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
pItem->stype = stype;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t cfgSetCharset(SConfigItem *pItem, const char *value, ECfgSrcType stype) {
|
||||||
|
char *tmp = strdup(value);
|
||||||
|
if (tmp == NULL || cfgCheckAndSetCharset(pItem, value) != 0) {
|
||||||
|
free(tmp);
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
uError("cfg:%s, type:%s src:%s value:%s failed to dup since %s, use last src:%s value:%s", pItem->name,
|
||||||
|
cfgDtypeStr(pItem->dtype), cfgStypeStr(stype), value, terrstr(), cfgStypeStr(pItem->stype), pItem->str);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
pItem->stype = stype;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t cfgSetTimezone(SConfigItem *pItem, const char *value, ECfgSrcType stype) {
|
||||||
|
char *tmp = strdup(value);
|
||||||
|
if (tmp == NULL || cfgCheckAndSetTimezone(pItem, value) != 0) {
|
||||||
|
free(tmp);
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
uError("cfg:%s, type:%s src:%s value:%s failed to dup since %s, use last src:%s value:%s", pItem->name,
|
||||||
|
cfgDtypeStr(pItem->dtype), cfgStypeStr(stype), value, terrstr(), cfgStypeStr(pItem->stype), pItem->str);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(pItem->strVal);
|
|
||||||
pItem->strVal = tmp;
|
|
||||||
pItem->stype = stype;
|
pItem->stype = stype;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -208,10 +301,6 @@ int32_t cfgSetItem(SConfig *pConfig, const char *name, const char *value, ECfgSr
|
||||||
switch (pItem->dtype) {
|
switch (pItem->dtype) {
|
||||||
case CFG_DTYPE_BOOL:
|
case CFG_DTYPE_BOOL:
|
||||||
return cfgSetBool(pItem, value, stype);
|
return cfgSetBool(pItem, value, stype);
|
||||||
case CFG_DTYPE_INT8:
|
|
||||||
return cfgSetInt8(pItem, value, stype);
|
|
||||||
case CFG_DTYPE_UINT16:
|
|
||||||
return cfgSetUInt16(pItem, value, stype);
|
|
||||||
case CFG_DTYPE_INT32:
|
case CFG_DTYPE_INT32:
|
||||||
return cfgSetInt32(pItem, value, stype);
|
return cfgSetInt32(pItem, value, stype);
|
||||||
case CFG_DTYPE_INT64:
|
case CFG_DTYPE_INT64:
|
||||||
|
@ -224,6 +313,12 @@ int32_t cfgSetItem(SConfig *pConfig, const char *name, const char *value, ECfgSr
|
||||||
return cfgSetIpStr(pItem, value, stype);
|
return cfgSetIpStr(pItem, value, stype);
|
||||||
case CFG_DTYPE_DIR:
|
case CFG_DTYPE_DIR:
|
||||||
return cfgSetDir(pItem, value, stype);
|
return cfgSetDir(pItem, value, stype);
|
||||||
|
case CFG_DTYPE_TIMEZONE:
|
||||||
|
return cfgSetTimezone(pItem, value, stype);
|
||||||
|
case CFG_DTYPE_CHARSET:
|
||||||
|
return cfgSetCharset(pItem, value, stype);
|
||||||
|
case CFG_DTYPE_LOCALE:
|
||||||
|
return cfgSetLocale(pItem, value, stype);
|
||||||
case CFG_DTYPE_NONE:
|
case CFG_DTYPE_NONE:
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -246,9 +341,8 @@ SConfigItem *cfgGetItem(SConfig *pConfig, const char *name) {
|
||||||
return pItem;
|
return pItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t cfgAddItem(SConfig *pConfig, SConfigItem *pItem, const char *name, ECfgUnitType utype) {
|
static int32_t cfgAddItem(SConfig *pConfig, SConfigItem *pItem, const char *name) {
|
||||||
pItem->stype = CFG_STYPE_DEFAULT;
|
pItem->stype = CFG_STYPE_DEFAULT;
|
||||||
pItem->utype = utype;
|
|
||||||
pItem->name = strdup(name);
|
pItem->name = strdup(name);
|
||||||
if (pItem->name == NULL) {
|
if (pItem->name == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -261,7 +355,7 @@ static int32_t cfgAddItem(SConfig *pConfig, SConfigItem *pItem, const char *name
|
||||||
|
|
||||||
if (taosHashPut(pConfig->hash, lowcaseName, strlen(lowcaseName) + 1, pItem, sizeof(SConfigItem)) != 0) {
|
if (taosHashPut(pConfig->hash, lowcaseName, strlen(lowcaseName) + 1, pItem, sizeof(SConfigItem)) != 0) {
|
||||||
if (pItem->dtype == CFG_DTYPE_STRING) {
|
if (pItem->dtype == CFG_DTYPE_STRING) {
|
||||||
free(pItem->strVal);
|
free(pItem->str);
|
||||||
}
|
}
|
||||||
free(pItem->name);
|
free(pItem->name);
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -271,202 +365,94 @@ static int32_t cfgAddItem(SConfig *pConfig, SConfigItem *pItem, const char *name
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t cfgAddBool(SConfig *pConfig, const char *name, bool defaultVal, ECfgUnitType utype) {
|
int32_t cfgAddBool(SConfig *pConfig, const char *name, bool defaultVal) {
|
||||||
SConfigItem item = {.dtype = CFG_DTYPE_BOOL, .boolVal = defaultVal};
|
SConfigItem item = {.dtype = CFG_DTYPE_BOOL, .bval = defaultVal};
|
||||||
return cfgAddItem(pConfig, &item, name, utype);
|
return cfgAddItem(pConfig, &item, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t cfgAddInt8(SConfig *pConfig, const char *name, int8_t defaultVal, int64_t minval, int64_t maxval,
|
int32_t cfgAddInt32(SConfig *pConfig, const char *name, int32_t defaultVal, int64_t minval, int64_t maxval) {
|
||||||
ECfgUnitType utype) {
|
|
||||||
if (defaultVal < minval || defaultVal > maxval) {
|
if (defaultVal < minval || defaultVal > maxval) {
|
||||||
terrno = TSDB_CODE_OUT_OF_RANGE;
|
terrno = TSDB_CODE_OUT_OF_RANGE;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SConfigItem item = {.dtype = CFG_DTYPE_INT8, .int8Val = defaultVal, .minIntVal = minval, .maxIntVal = maxval};
|
SConfigItem item = {.dtype = CFG_DTYPE_INT32, .i32 = defaultVal, .imin = minval, .imax = maxval};
|
||||||
return cfgAddItem(pConfig, &item, name, utype);
|
return cfgAddItem(pConfig, &item, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t cfgAddUInt16(SConfig *pConfig, const char *name, uint16_t defaultVal, int64_t minval, int64_t maxval,
|
int32_t cfgAddInt64(SConfig *pConfig, const char *name, int64_t defaultVal, int64_t minval, int64_t maxval) {
|
||||||
ECfgUnitType utype) {
|
|
||||||
if (defaultVal < minval || defaultVal > maxval) {
|
if (defaultVal < minval || defaultVal > maxval) {
|
||||||
terrno = TSDB_CODE_OUT_OF_RANGE;
|
terrno = TSDB_CODE_OUT_OF_RANGE;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SConfigItem item = {.dtype = CFG_DTYPE_UINT16, .uint16Val = defaultVal, .minIntVal = minval, .maxIntVal = maxval};
|
SConfigItem item = {.dtype = CFG_DTYPE_INT64, .i64 = defaultVal, .imin = minval, .imax = maxval};
|
||||||
return cfgAddItem(pConfig, &item, name, utype);
|
return cfgAddItem(pConfig, &item, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t cfgAddInt32(SConfig *pConfig, const char *name, int32_t defaultVal, int64_t minval, int64_t maxval,
|
int32_t cfgAddFloat(SConfig *pConfig, const char *name, float defaultVal, double minval, double maxval) {
|
||||||
ECfgUnitType utype) {
|
|
||||||
if (defaultVal < minval || defaultVal > maxval) {
|
if (defaultVal < minval || defaultVal > maxval) {
|
||||||
terrno = TSDB_CODE_OUT_OF_RANGE;
|
terrno = TSDB_CODE_OUT_OF_RANGE;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SConfigItem item = {.dtype = CFG_DTYPE_INT32, .int32Val = defaultVal, .minIntVal = minval, .maxIntVal = maxval};
|
SConfigItem item = {.dtype = CFG_DTYPE_FLOAT, .fval = defaultVal, .fmin = minval, .fmax = maxval};
|
||||||
return cfgAddItem(pConfig, &item, name, utype);
|
return cfgAddItem(pConfig, &item, name);
|
||||||
}
|
|
||||||
|
|
||||||
int32_t cfgAddInt64(SConfig *pConfig, const char *name, int64_t defaultVal, int64_t minval, int64_t maxval,
|
|
||||||
ECfgUnitType utype) {
|
|
||||||
if (defaultVal < minval || defaultVal > maxval) {
|
|
||||||
terrno = TSDB_CODE_OUT_OF_RANGE;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
SConfigItem item = {.dtype = CFG_DTYPE_INT64, .int64Val = defaultVal, .minIntVal = minval, .maxIntVal = maxval};
|
|
||||||
return cfgAddItem(pConfig, &item, name, utype);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t cfgAddFloat(SConfig *pConfig, const char *name, float defaultVal, double minval, double maxval,
|
|
||||||
ECfgUnitType utype) {
|
|
||||||
if (defaultVal < minval || defaultVal > maxval) {
|
|
||||||
terrno = TSDB_CODE_OUT_OF_RANGE;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
SConfigItem item = {.dtype = CFG_DTYPE_FLOAT, .floatVal = defaultVal, .minFloatVal = minval, .maxFloatVal = maxval};
|
|
||||||
return cfgAddItem(pConfig, &item, name, utype);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t cfgAddString(SConfig *pConfig, const char *name, const char *defaultVal, ECfgUnitType utype) {
|
|
||||||
if (defaultVal == NULL) {
|
|
||||||
terrno = TSDB_CODE_OUT_OF_RANGE;
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t cfgAddString(SConfig *pConfig, const char *name, const char *defaultVal) {
|
||||||
SConfigItem item = {.dtype = CFG_DTYPE_STRING};
|
SConfigItem item = {.dtype = CFG_DTYPE_STRING};
|
||||||
item.strVal = strdup(defaultVal);
|
item.str = strdup(defaultVal);
|
||||||
if (item.strVal == NULL) {
|
if (item.str == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return cfgAddItem(pConfig, &item, name, utype);
|
return cfgAddItem(pConfig, &item, name);
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t cfgCheckIpStr(const char *ip) {
|
|
||||||
uint32_t value = taosInetAddr(ip);
|
|
||||||
if (value == INADDR_NONE) {
|
|
||||||
uError("ip:%s is not a valid ip address", ip);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t cfgAddIpStr(SConfig *pConfig, const char *name, const char *defaultVal, ECfgUnitType utype) {
|
|
||||||
if (cfgCheckIpStr(defaultVal) != 0) {
|
|
||||||
terrno = TSDB_CODE_OUT_OF_RANGE;
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t cfgAddIpStr(SConfig *pConfig, const char *name, const char *defaultVal) {
|
||||||
SConfigItem item = {.dtype = CFG_DTYPE_IPSTR};
|
SConfigItem item = {.dtype = CFG_DTYPE_IPSTR};
|
||||||
item.strVal = strdup(defaultVal);
|
if (cfgCheckAndSetIpStr(&item, defaultVal) != 0) {
|
||||||
if (item.strVal == NULL) {
|
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return cfgAddItem(pConfig, &item, name, utype);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t cfgCheckAndSetDir(SConfigItem *pItem, const char *inputDir) {
|
|
||||||
char fullDir[PATH_MAX] = {0};
|
|
||||||
if (taosExpandDir(inputDir, fullDir, PATH_MAX) != 0) {
|
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
|
||||||
uError("failed to expand dir:%s since %s", inputDir, terrstr());
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosRealPath(fullDir, PATH_MAX) != 0) {
|
return cfgAddItem(pConfig, &item, name);
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
|
||||||
uError("failed to get realpath of dir:%s since %s", inputDir, terrstr());
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosMkDir(fullDir) != 0) {
|
int32_t cfgAddDir(SConfig *pConfig, const char *name, const char *defaultVal) {
|
||||||
uError("failed to create dir:%s realpath:%s since %s", inputDir, fullDir, terrstr());
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
tfree(pItem->strVal);
|
|
||||||
pItem->strVal = strdup(fullDir);
|
|
||||||
if (pItem->strVal == NULL) {
|
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t cfgAddDir(SConfig *pConfig, const char *name, const char *defaultVal, ECfgUnitType utype) {
|
|
||||||
SConfigItem item = {.dtype = CFG_DTYPE_DIR};
|
SConfigItem item = {.dtype = CFG_DTYPE_DIR};
|
||||||
if (cfgCheckAndSetDir(&item, defaultVal) != 0) {
|
if (cfgCheckAndSetDir(&item, defaultVal) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return cfgAddItem(pConfig, &item, name, utype);
|
return cfgAddItem(pConfig, &item, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t cfgCheckAndSetLocale(SConfigItem *pItem, const char *locale) {
|
int32_t cfgAddLocale(SConfig *pConfig, const char *name, const char *defaultVal) {
|
||||||
tfree(pItem->strVal);
|
|
||||||
pItem->strVal = strdup(locale);
|
|
||||||
if (pItem->strVal == NULL) {
|
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t cfgAddLocale(SConfig *pConfig, const char *name, const char *defaultVal, ECfgUnitType utype) {
|
|
||||||
SConfigItem item = {.dtype = CFG_DTYPE_LOCALE};
|
SConfigItem item = {.dtype = CFG_DTYPE_LOCALE};
|
||||||
if (cfgCheckAndSetLocale(&item, defaultVal) != 0) {
|
if (cfgCheckAndSetLocale(&item, defaultVal) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return cfgAddItem(pConfig, &item, name, utype);
|
return cfgAddItem(pConfig, &item, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t cfgCheckAndSetCharset(SConfigItem *pItem, const char *charset) {
|
int32_t cfgAddCharset(SConfig *pConfig, const char *name, const char *defaultVal) {
|
||||||
tfree(pItem->strVal);
|
|
||||||
pItem->strVal = strdup(charset);
|
|
||||||
if (pItem->strVal == NULL) {
|
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t cfgAddCharset(SConfig *pConfig, const char *name, const char *defaultVal, ECfgUnitType utype) {
|
|
||||||
SConfigItem item = {.dtype = CFG_DTYPE_CHARSET};
|
SConfigItem item = {.dtype = CFG_DTYPE_CHARSET};
|
||||||
if (cfgCheckAndSetCharset(&item, defaultVal) != 0) {
|
if (cfgCheckAndSetCharset(&item, defaultVal) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return cfgAddItem(pConfig, &item, name, utype);
|
return cfgAddItem(pConfig, &item, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t cfgCheckAndSetTimezone(SConfigItem *pItem, const char *timezone) {
|
int32_t cfgAddTimezone(SConfig *pConfig, const char *name, const char *defaultVal) {
|
||||||
tfree(pItem->strVal);
|
|
||||||
pItem->strVal = strdup(timezone);
|
|
||||||
if (pItem->strVal == NULL) {
|
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t cfgAddTimezone(SConfig *pConfig, const char *name, const char *defaultVal, ECfgUnitType utype) {
|
|
||||||
SConfigItem item = {.dtype = CFG_DTYPE_TIMEZONE};
|
SConfigItem item = {.dtype = CFG_DTYPE_TIMEZONE};
|
||||||
if (cfgCheckAndSetTimezone(&item, defaultVal) != 0) {
|
if (cfgCheckAndSetTimezone(&item, defaultVal) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return cfgAddItem(pConfig, &item, name, utype);
|
return cfgAddItem(pConfig, &item, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *cfgStypeStr(ECfgSrcType type) {
|
const char *cfgStypeStr(ECfgSrcType type) {
|
||||||
|
@ -496,10 +482,6 @@ const char *cfgDtypeStr(ECfgDataType type) {
|
||||||
return "none";
|
return "none";
|
||||||
case CFG_DTYPE_BOOL:
|
case CFG_DTYPE_BOOL:
|
||||||
return "bool";
|
return "bool";
|
||||||
case CFG_DTYPE_INT8:
|
|
||||||
return "int8";
|
|
||||||
case CFG_DTYPE_UINT16:
|
|
||||||
return "uint16";
|
|
||||||
case CFG_DTYPE_INT32:
|
case CFG_DTYPE_INT32:
|
||||||
return "int32";
|
return "int32";
|
||||||
case CFG_DTYPE_INT64:
|
case CFG_DTYPE_INT64:
|
||||||
|
@ -523,23 +505,120 @@ const char *cfgDtypeStr(ECfgDataType type) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *cfgUtypeStr(ECfgUnitType type) {
|
void cfgPrintCfg(SConfig *pCfg) {
|
||||||
switch (type) {
|
uInfo("taos global config");
|
||||||
case CFG_UTYPE_NONE:
|
uInfo("==================================");
|
||||||
return "";
|
|
||||||
case CFG_UTYPE_PERCENT:
|
SConfigItem *pItem = cfgIterate(pCfg, NULL);
|
||||||
return "(%)";
|
while (pItem != NULL) {
|
||||||
case CFG_UTYPE_GB:
|
switch (pItem->dtype) {
|
||||||
return "(GB)";
|
case CFG_DTYPE_BOOL:
|
||||||
case CFG_UTYPE_MB:
|
uInfo("cfg:%s, value:%u src:%s", pItem->name, pItem->bval, cfgStypeStr(pItem->stype));
|
||||||
return "(Mb)";
|
break;
|
||||||
case CFG_UTYPE_BYTE:
|
case CFG_DTYPE_INT32:
|
||||||
return "(byte)";
|
uInfo("cfg:%s, value:%d src:%s", pItem->name, pItem->i32, cfgStypeStr(pItem->stype));
|
||||||
case CFG_UTYPE_SECOND:
|
break;
|
||||||
return "(s)";
|
case CFG_DTYPE_INT64:
|
||||||
case CFG_UTYPE_MS:
|
uInfo("cfg:%s, value:%" PRId64 " src:%s", pItem->name, pItem->i64, cfgStypeStr(pItem->stype));
|
||||||
return "(ms)";
|
break;
|
||||||
default:
|
case CFG_DTYPE_FLOAT:
|
||||||
return "invalid";
|
uInfo("cfg:%s, value:%f src:%s", pItem->name, pItem->fval, cfgStypeStr(pItem->stype));
|
||||||
|
break;
|
||||||
|
case CFG_DTYPE_STRING:
|
||||||
|
case CFG_DTYPE_IPSTR:
|
||||||
|
case CFG_DTYPE_DIR:
|
||||||
|
case CFG_DTYPE_LOCALE:
|
||||||
|
case CFG_DTYPE_CHARSET:
|
||||||
|
case CFG_DTYPE_TIMEZONE:
|
||||||
|
uInfo("cfg:%s, value:%s src:%s", pItem->name, pItem->str, cfgStypeStr(pItem->stype));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
pItem = cfgIterate(pCfg, pItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t cfgCheck(SConfig *pConfig) {
|
||||||
|
SConfigItem *pItem = cfgGetItem(pConfig, "debugFlag");
|
||||||
|
if (pItem != NULL) {
|
||||||
|
taosSetDebugFlag(pItem->i32);
|
||||||
|
}
|
||||||
|
|
||||||
|
pItem = cfgGetItem(pConfig, "localFqdn");
|
||||||
|
if (pItem != NULL) {
|
||||||
|
tstrncpy(tsLocalFqdn, pItem->str, TSDB_FQDN_LEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
pItem = cfgGetItem(pConfig, "serverPort");
|
||||||
|
if (pItem != NULL) {
|
||||||
|
tsServerPort = (uint16_t)pItem->i32;
|
||||||
|
}
|
||||||
|
|
||||||
|
pItem = cfgGetItem(pConfig, "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(pConfig, "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(pConfig, "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(pConfig, "numOfCores");
|
||||||
|
if (pItem != NULL) {
|
||||||
|
tsNumOfCores = pItem->i32;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tsNumOfCores <= 0) {
|
||||||
|
tsNumOfCores = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tsQueryBufferSize >= 0) {
|
||||||
|
tsQueryBufferSizeBytes = tsQueryBufferSize * 1048576UL;
|
||||||
|
}
|
||||||
|
|
||||||
|
cfgPrintCfg(pConfig);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -20,15 +20,14 @@ class CfgTest : public ::testing::Test {
|
||||||
public:
|
public:
|
||||||
void SetUp() override {}
|
void SetUp() override {}
|
||||||
void TearDown() override {}
|
void TearDown() override {}
|
||||||
|
void InitCfg(SConfig *pConfig);
|
||||||
void InitializeConfig(SConfig *pConfig);
|
|
||||||
|
|
||||||
static const char *pConfig;
|
static const char *pConfig;
|
||||||
};
|
};
|
||||||
|
|
||||||
const char *CfgTest::pConfig;
|
const char *CfgTest::pConfig;
|
||||||
|
|
||||||
TEST_F(CfgTest, 02_Str) {
|
TEST_F(CfgTest, 01_Str) {
|
||||||
EXPECT_STREQ(cfgStypeStr(CFG_STYPE_DEFAULT), "default");
|
EXPECT_STREQ(cfgStypeStr(CFG_STYPE_DEFAULT), "default");
|
||||||
EXPECT_STREQ(cfgStypeStr(CFG_STYPE_CFG_FILE), "cfg_file");
|
EXPECT_STREQ(cfgStypeStr(CFG_STYPE_CFG_FILE), "cfg_file");
|
||||||
EXPECT_STREQ(cfgStypeStr(CFG_STYPE_ENV_FILE), "env_file");
|
EXPECT_STREQ(cfgStypeStr(CFG_STYPE_ENV_FILE), "env_file");
|
||||||
|
@ -40,72 +39,56 @@ TEST_F(CfgTest, 02_Str) {
|
||||||
|
|
||||||
EXPECT_STREQ(cfgDtypeStr(CFG_DTYPE_NONE), "none");
|
EXPECT_STREQ(cfgDtypeStr(CFG_DTYPE_NONE), "none");
|
||||||
EXPECT_STREQ(cfgDtypeStr(CFG_DTYPE_BOOL), "bool");
|
EXPECT_STREQ(cfgDtypeStr(CFG_DTYPE_BOOL), "bool");
|
||||||
EXPECT_STREQ(cfgDtypeStr(CFG_DTYPE_INT8), "int8");
|
|
||||||
EXPECT_STREQ(cfgDtypeStr(CFG_DTYPE_UINT16), "uint16");
|
|
||||||
EXPECT_STREQ(cfgDtypeStr(CFG_DTYPE_INT32), "int32");
|
EXPECT_STREQ(cfgDtypeStr(CFG_DTYPE_INT32), "int32");
|
||||||
EXPECT_STREQ(cfgDtypeStr(CFG_DTYPE_INT64), "int64");
|
EXPECT_STREQ(cfgDtypeStr(CFG_DTYPE_INT64), "int64");
|
||||||
EXPECT_STREQ(cfgDtypeStr(CFG_DTYPE_FLOAT), "float");
|
EXPECT_STREQ(cfgDtypeStr(CFG_DTYPE_FLOAT), "float");
|
||||||
EXPECT_STREQ(cfgDtypeStr(CFG_DTYPE_STRING), "string");
|
EXPECT_STREQ(cfgDtypeStr(CFG_DTYPE_STRING), "string");
|
||||||
EXPECT_STREQ(cfgDtypeStr(CFG_DTYPE_IPSTR), "ipstr");
|
EXPECT_STREQ(cfgDtypeStr(CFG_DTYPE_IPSTR), "ipstr");
|
||||||
EXPECT_STREQ(cfgDtypeStr(CFG_DTYPE_DIR), "dir");
|
EXPECT_STREQ(cfgDtypeStr(CFG_DTYPE_DIR), "dir");
|
||||||
|
EXPECT_STREQ(cfgDtypeStr(CFG_DTYPE_DIR), "dir");
|
||||||
|
EXPECT_STREQ(cfgDtypeStr(CFG_DTYPE_DIR), "dir");
|
||||||
|
EXPECT_STREQ(cfgDtypeStr(CFG_DTYPE_DIR), "dir");
|
||||||
EXPECT_STREQ(cfgDtypeStr(ECfgDataType(1024)), "invalid");
|
EXPECT_STREQ(cfgDtypeStr(ECfgDataType(1024)), "invalid");
|
||||||
|
|
||||||
EXPECT_STREQ(cfgUtypeStr(CFG_UTYPE_NONE), "");
|
|
||||||
EXPECT_STREQ(cfgUtypeStr(CFG_UTYPE_GB), "(GB)");
|
|
||||||
EXPECT_STREQ(cfgUtypeStr(CFG_UTYPE_MB), "(Mb)");
|
|
||||||
EXPECT_STREQ(cfgUtypeStr(CFG_UTYPE_BYTE), "(byte)");
|
|
||||||
EXPECT_STREQ(cfgUtypeStr(CFG_UTYPE_SECOND), "(s)");
|
|
||||||
EXPECT_STREQ(cfgUtypeStr(CFG_UTYPE_MS), "(ms)");
|
|
||||||
EXPECT_STREQ(cfgUtypeStr(CFG_UTYPE_PERCENT), "(%)");
|
|
||||||
EXPECT_STREQ(cfgUtypeStr(ECfgUnitType(1024)), "invalid");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(CfgTest, 02_Basic) {
|
TEST_F(CfgTest, 02_Basic) {
|
||||||
SConfig *pConfig = cfgInit();
|
SConfig *pConfig = cfgInit();
|
||||||
ASSERT_NE(pConfig, nullptr);
|
ASSERT_NE(pConfig, nullptr);
|
||||||
|
|
||||||
EXPECT_EQ(cfgAddBool(pConfig, "test_bool", 0, CFG_UTYPE_NONE), 0);
|
EXPECT_EQ(cfgAddBool(pConfig, "test_bool", 0), 0);
|
||||||
EXPECT_EQ(cfgAddInt8(pConfig, "test_int8", 1, 0, 16, CFG_UTYPE_GB), 0);
|
EXPECT_EQ(cfgAddInt32(pConfig, "test_int32", 1, 0, 16), 0);
|
||||||
EXPECT_EQ(cfgAddUInt16(pConfig, "test_uint16", 2, 0, 16, CFG_UTYPE_MB), 0);
|
EXPECT_EQ(cfgAddInt64(pConfig, "test_int64", 2, 0, 16), 0);
|
||||||
EXPECT_EQ(cfgAddInt32(pConfig, "test_int32", 3, 0, 16, CFG_UTYPE_BYTE), 0);
|
EXPECT_EQ(cfgAddFloat(pConfig, "test_float", 3, 0, 16), 0);
|
||||||
EXPECT_EQ(cfgAddInt64(pConfig, "test_int64", 4, 0, 16, CFG_UTYPE_SECOND), 0);
|
EXPECT_EQ(cfgAddString(pConfig, "test_string", "4"), 0);
|
||||||
EXPECT_EQ(cfgAddFloat(pConfig, "test_float", 5, 0, 16, CFG_UTYPE_MS), 0);
|
EXPECT_EQ(cfgAddIpStr(pConfig, "test_ipstr", "192.168.0.1"), 0);
|
||||||
EXPECT_EQ(cfgAddString(pConfig, "test_string", "6", CFG_UTYPE_NONE), 0);
|
EXPECT_EQ(cfgAddDir(pConfig, "test_dir", "/tmp"), 0);
|
||||||
EXPECT_EQ(cfgAddIpStr(pConfig, "test_ipstr", "192.168.0.1", CFG_UTYPE_NONE), 0);
|
|
||||||
EXPECT_EQ(cfgAddDir(pConfig, "test_dir", "/tmp", CFG_UTYPE_NONE), 0);
|
|
||||||
|
|
||||||
EXPECT_EQ(cfgGetSize(pConfig), 9);
|
EXPECT_EQ(cfgGetSize(pConfig), 7);
|
||||||
|
|
||||||
int32_t size = 0;
|
int32_t size = 0;
|
||||||
SConfigItem *pItem = cfgIterate(pConfig, NULL);
|
SConfigItem *pItem = cfgIterate(pConfig, NULL);
|
||||||
while (pItem != NULL) {
|
while (pItem != NULL) {
|
||||||
switch (pItem->dtype) {
|
switch (pItem->dtype) {
|
||||||
case CFG_DTYPE_BOOL:
|
case CFG_DTYPE_BOOL:
|
||||||
printf("index:%d, cfg:%s value:%d\n", size, pItem->name, pItem->boolVal);
|
printf("index:%d, cfg:%s value:%d\n", size, pItem->name, pItem->bval);
|
||||||
break;
|
|
||||||
case CFG_DTYPE_INT8:
|
|
||||||
printf("index:%d, cfg:%s value:%d\n", size, pItem->name, pItem->int8Val);
|
|
||||||
break;
|
|
||||||
case CFG_DTYPE_UINT16:
|
|
||||||
printf("index:%d, cfg:%s value:%d\n", size, pItem->name, pItem->uint16Val);
|
|
||||||
break;
|
break;
|
||||||
case CFG_DTYPE_INT32:
|
case CFG_DTYPE_INT32:
|
||||||
printf("index:%d, cfg:%s value:%d\n", size, pItem->name, pItem->int32Val);
|
printf("index:%d, cfg:%s value:%d\n", size, pItem->name, pItem->i32);
|
||||||
break;
|
break;
|
||||||
case CFG_DTYPE_INT64:
|
case CFG_DTYPE_INT64:
|
||||||
printf("index:%d, cfg:%s value:%" PRId64 "\n", size, pItem->name, pItem->int64Val);
|
printf("index:%d, cfg:%s value:%" PRId64 "\n", size, pItem->name, pItem->i64);
|
||||||
break;
|
break;
|
||||||
case CFG_DTYPE_FLOAT:
|
case CFG_DTYPE_FLOAT:
|
||||||
printf("index:%d, cfg:%s value:%f\n", size, pItem->name, pItem->floatVal);
|
printf("index:%d, cfg:%s value:%f\n", size, pItem->name, pItem->fval);
|
||||||
break;
|
break;
|
||||||
case CFG_DTYPE_STRING:
|
case CFG_DTYPE_STRING:
|
||||||
printf("index:%d, cfg:%s value:%s\n", size, pItem->name, pItem->strVal);
|
printf("index:%d, cfg:%s value:%s\n", size, pItem->name, pItem->str);
|
||||||
break;
|
break;
|
||||||
case CFG_DTYPE_IPSTR:
|
case CFG_DTYPE_IPSTR:
|
||||||
printf("index:%d, cfg:%s value:%s\n", size, pItem->name, pItem->strVal);
|
printf("index:%d, cfg:%s value:%s\n", size, pItem->name, pItem->str);
|
||||||
break;
|
break;
|
||||||
case CFG_DTYPE_DIR:
|
case CFG_DTYPE_DIR:
|
||||||
printf("index:%d, cfg:%s value:%s\n", size, pItem->name, pItem->strVal);
|
printf("index:%d, cfg:%s value:%s\n", size, pItem->name, pItem->str);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printf("index:%d, cfg:%s invalid cfg dtype:%d\n", size, pItem->name, pItem->dtype);
|
printf("index:%d, cfg:%s invalid cfg dtype:%d\n", size, pItem->name, pItem->dtype);
|
||||||
|
@ -116,70 +99,49 @@ TEST_F(CfgTest, 02_Basic) {
|
||||||
}
|
}
|
||||||
cfgCancelIterate(pConfig, pItem);
|
cfgCancelIterate(pConfig, pItem);
|
||||||
|
|
||||||
EXPECT_EQ(cfgGetSize(pConfig), 9);
|
EXPECT_EQ(cfgGetSize(pConfig), 7);
|
||||||
|
|
||||||
pItem = cfgGetItem(pConfig, "test_bool");
|
pItem = cfgGetItem(pConfig, "test_bool");
|
||||||
EXPECT_EQ(pItem->stype, CFG_STYPE_DEFAULT);
|
EXPECT_EQ(pItem->stype, CFG_STYPE_DEFAULT);
|
||||||
EXPECT_EQ(pItem->utype, CFG_UTYPE_NONE);
|
|
||||||
EXPECT_EQ(pItem->dtype, CFG_DTYPE_BOOL);
|
EXPECT_EQ(pItem->dtype, CFG_DTYPE_BOOL);
|
||||||
EXPECT_STREQ(pItem->name, "test_bool");
|
EXPECT_STREQ(pItem->name, "test_bool");
|
||||||
EXPECT_EQ(pItem->boolVal, 0);
|
EXPECT_EQ(pItem->bval, 0);
|
||||||
|
|
||||||
pItem = cfgGetItem(pConfig, "test_int8");
|
|
||||||
EXPECT_EQ(pItem->stype, CFG_STYPE_DEFAULT);
|
|
||||||
EXPECT_EQ(pItem->utype, CFG_UTYPE_GB);
|
|
||||||
EXPECT_EQ(pItem->dtype, CFG_DTYPE_INT8);
|
|
||||||
EXPECT_STREQ(pItem->name, "test_int8");
|
|
||||||
EXPECT_EQ(pItem->int8Val, 1);
|
|
||||||
|
|
||||||
pItem = cfgGetItem(pConfig, "test_uint16");
|
|
||||||
EXPECT_EQ(pItem->stype, CFG_STYPE_DEFAULT);
|
|
||||||
EXPECT_EQ(pItem->utype, CFG_UTYPE_MB);
|
|
||||||
EXPECT_EQ(pItem->dtype, CFG_DTYPE_UINT16);
|
|
||||||
EXPECT_STREQ(pItem->name, "test_uint16");
|
|
||||||
EXPECT_EQ(pItem->uint16Val, 2);
|
|
||||||
|
|
||||||
pItem = cfgGetItem(pConfig, "test_int32");
|
pItem = cfgGetItem(pConfig, "test_int32");
|
||||||
EXPECT_EQ(pItem->stype, CFG_STYPE_DEFAULT);
|
EXPECT_EQ(pItem->stype, CFG_STYPE_DEFAULT);
|
||||||
EXPECT_EQ(pItem->utype, CFG_UTYPE_BYTE);
|
|
||||||
EXPECT_EQ(pItem->dtype, CFG_DTYPE_INT32);
|
EXPECT_EQ(pItem->dtype, CFG_DTYPE_INT32);
|
||||||
EXPECT_STREQ(pItem->name, "test_int32");
|
EXPECT_STREQ(pItem->name, "test_int32");
|
||||||
EXPECT_EQ(pItem->int32Val, 3);
|
EXPECT_EQ(pItem->i32, 1);
|
||||||
|
|
||||||
pItem = cfgGetItem(pConfig, "test_int64");
|
pItem = cfgGetItem(pConfig, "test_int64");
|
||||||
EXPECT_EQ(pItem->stype, CFG_STYPE_DEFAULT);
|
EXPECT_EQ(pItem->stype, CFG_STYPE_DEFAULT);
|
||||||
EXPECT_EQ(pItem->utype, CFG_UTYPE_SECOND);
|
|
||||||
EXPECT_EQ(pItem->dtype, CFG_DTYPE_INT64);
|
EXPECT_EQ(pItem->dtype, CFG_DTYPE_INT64);
|
||||||
EXPECT_STREQ(pItem->name, "test_int64");
|
EXPECT_STREQ(pItem->name, "test_int64");
|
||||||
EXPECT_EQ(pItem->int64Val, 4);
|
EXPECT_EQ(pItem->i64, 2);
|
||||||
|
|
||||||
pItem = cfgGetItem(pConfig, "test_float");
|
pItem = cfgGetItem(pConfig, "test_float");
|
||||||
EXPECT_EQ(pItem->stype, CFG_STYPE_DEFAULT);
|
EXPECT_EQ(pItem->stype, CFG_STYPE_DEFAULT);
|
||||||
EXPECT_EQ(pItem->utype, CFG_UTYPE_MS);
|
|
||||||
EXPECT_EQ(pItem->dtype, CFG_DTYPE_FLOAT);
|
EXPECT_EQ(pItem->dtype, CFG_DTYPE_FLOAT);
|
||||||
EXPECT_STREQ(pItem->name, "test_float");
|
EXPECT_STREQ(pItem->name, "test_float");
|
||||||
EXPECT_EQ(pItem->floatVal, 5);
|
EXPECT_EQ(pItem->fval, 3);
|
||||||
|
|
||||||
pItem = cfgGetItem(pConfig, "test_string");
|
pItem = cfgGetItem(pConfig, "test_string");
|
||||||
EXPECT_EQ(pItem->stype, CFG_STYPE_DEFAULT);
|
EXPECT_EQ(pItem->stype, CFG_STYPE_DEFAULT);
|
||||||
EXPECT_EQ(pItem->utype, CFG_UTYPE_NONE);
|
|
||||||
EXPECT_EQ(pItem->dtype, CFG_DTYPE_STRING);
|
EXPECT_EQ(pItem->dtype, CFG_DTYPE_STRING);
|
||||||
EXPECT_STREQ(pItem->name, "test_string");
|
EXPECT_STREQ(pItem->name, "test_string");
|
||||||
EXPECT_STREQ(pItem->strVal, "6");
|
EXPECT_STREQ(pItem->str, "4");
|
||||||
|
|
||||||
pItem = cfgGetItem(pConfig, "test_ipstr");
|
pItem = cfgGetItem(pConfig, "test_ipstr");
|
||||||
EXPECT_EQ(pItem->stype, CFG_STYPE_DEFAULT);
|
EXPECT_EQ(pItem->stype, CFG_STYPE_DEFAULT);
|
||||||
EXPECT_EQ(pItem->utype, CFG_UTYPE_NONE);
|
|
||||||
EXPECT_EQ(pItem->dtype, CFG_DTYPE_IPSTR);
|
EXPECT_EQ(pItem->dtype, CFG_DTYPE_IPSTR);
|
||||||
EXPECT_STREQ(pItem->name, "test_ipstr");
|
EXPECT_STREQ(pItem->name, "test_ipstr");
|
||||||
EXPECT_STREQ(pItem->strVal, "192.168.0.1");
|
EXPECT_STREQ(pItem->str, "192.168.0.1");
|
||||||
|
|
||||||
pItem = cfgGetItem(pConfig, "test_dir");
|
pItem = cfgGetItem(pConfig, "test_dir");
|
||||||
EXPECT_EQ(pItem->stype, CFG_STYPE_DEFAULT);
|
EXPECT_EQ(pItem->stype, CFG_STYPE_DEFAULT);
|
||||||
EXPECT_EQ(pItem->utype, CFG_UTYPE_NONE);
|
|
||||||
EXPECT_EQ(pItem->dtype, CFG_DTYPE_DIR);
|
EXPECT_EQ(pItem->dtype, CFG_DTYPE_DIR);
|
||||||
EXPECT_STREQ(pItem->name, "test_dir");
|
EXPECT_STREQ(pItem->name, "test_dir");
|
||||||
EXPECT_STREQ(pItem->strVal, "/tmp");
|
EXPECT_STREQ(pItem->str, "/tmp");
|
||||||
|
|
||||||
cfgCleanup(pConfig);
|
cfgCleanup(pConfig);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,12 +15,13 @@
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "ulog.h"
|
// #include "ulog.h"
|
||||||
#include "tglobal.h"
|
// #include "tglobal.h"
|
||||||
#include "tutil.h"
|
// #include "tutil.h"
|
||||||
|
|
||||||
// TODO refactor to set the tz value through parameter
|
// TODO refactor to set the tz value through parameter
|
||||||
void tsSetTimeZone() {
|
void tsSetTimeZone() {
|
||||||
|
#if 0
|
||||||
SGlobalCfg *cfg_timezone = taosGetConfigOption("timezone");
|
SGlobalCfg *cfg_timezone = taosGetConfigOption("timezone");
|
||||||
if (cfg_timezone != NULL) {
|
if (cfg_timezone != NULL) {
|
||||||
uInfo("timezone is set to %s by %s", tsTimezone, tsCfgStatusStr[cfg_timezone->cfgStatus]);
|
uInfo("timezone is set to %s by %s", tsTimezone, tsCfgStatusStr[cfg_timezone->cfgStatus]);
|
||||||
|
@ -63,4 +64,6 @@ void tsSetTimeZone() {
|
||||||
tsDaylight = daylight;
|
tsDaylight = daylight;
|
||||||
|
|
||||||
uInfo("timezone format changed to %s", tsTimezone);
|
uInfo("timezone format changed to %s", tsTimezone);
|
||||||
|
|
||||||
|
#endif
|
||||||
}
|
}
|
|
@ -773,3 +773,12 @@ void taosPrintOsInfo() {
|
||||||
uInfo(" os version: %s", info.version);
|
uInfo(" os version: %s", info.version);
|
||||||
uInfo(" os machine: %s", info.machine);
|
uInfo(" os machine: %s", info.machine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void taosSetDebugFlag(int32_t flag) {
|
||||||
|
if (!(debugFlag & DEBUG_TRACE || debugFlag & DEBUG_DEBUG || debugFlag & DEBUG_DUMP)) return;
|
||||||
|
|
||||||
|
debugFlag = flag;
|
||||||
|
mDebugFlag = flag;
|
||||||
|
dDebugFlag = flag;
|
||||||
|
cDebugFlag = flag;
|
||||||
|
}
|
Loading…
Reference in New Issue