Merge branch 'feature/config' into feature/3.0_liaohj
This commit is contained in:
commit
5d07ef4e43
|
@ -20,7 +20,7 @@ typedef struct SBlockOrderInfo {
|
||||||
SColumnInfoData *pColData;
|
SColumnInfoData *pColData;
|
||||||
} SBlockOrderInfo;
|
} SBlockOrderInfo;
|
||||||
|
|
||||||
int taosGetFqdnPortFromEp(const char *ep, uint16_t defaultPort, SEp *pEp);
|
int taosGetFqdnPortFromEp(const char *ep, SEp *pEp);
|
||||||
void addEpIntoEpSet(SEpSet *pEpSet, const char *fqdn, uint16_t port);
|
void addEpIntoEpSet(SEpSet *pEpSet, const char *fqdn, uint16_t port);
|
||||||
|
|
||||||
bool isEpsetEqual(const SEpSet *s1, const SEpSet *s2);
|
bool isEpsetEqual(const SEpSet *s1, const SEpSet *s2);
|
||||||
|
|
|
@ -20,24 +20,44 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "tcfg.h"
|
||||||
#include "tdef.h"
|
#include "tdef.h"
|
||||||
|
|
||||||
|
// cluster
|
||||||
|
extern char tsFirst[];
|
||||||
|
extern char tsSecond[];
|
||||||
|
extern char tsLocalFqdn[];
|
||||||
|
extern char tsLocalEp[];
|
||||||
|
extern uint16_t tsServerPort;
|
||||||
|
extern int32_t tsVersion;
|
||||||
|
extern int32_t tsStatusInterval;
|
||||||
|
extern bool tsEnableTelemetryReporting;
|
||||||
|
|
||||||
// common
|
// common
|
||||||
extern int32_t tsCompressMsgSize;
|
extern int32_t tsRpcTimer;
|
||||||
extern int32_t tsCompressColData;
|
extern int32_t tsRpcMaxTime;
|
||||||
extern int32_t tsMaxNumOfDistinctResults;
|
extern bool tsRpcForceTcp; // all commands go to tcp protocol if this is enabled
|
||||||
extern int tsCompatibleModel; // 2.0 compatible model
|
extern int32_t tsMaxConnections;
|
||||||
extern int8_t tsEnableSlaveQuery;
|
extern int32_t tsMaxShellConns;
|
||||||
extern int8_t tsEnableAdjustMaster;
|
extern int32_t tsShellActivityTimer;
|
||||||
extern int8_t tsPrintAuth;
|
extern int32_t tsMaxTmrCtrl;
|
||||||
extern int64_t tsTickPerDay[3];
|
extern float tsNumOfThreadsPerCore;
|
||||||
|
extern int32_t tsNumOfCommitThreads;
|
||||||
|
extern float tsRatioOfQueryCores;
|
||||||
|
extern int32_t tsCompressMsgSize;
|
||||||
|
extern int32_t tsCompressColData;
|
||||||
|
extern int32_t tsMaxNumOfDistinctResults;
|
||||||
|
extern int32_t tsCompatibleModel;
|
||||||
|
extern bool tsEnableSlaveQuery;
|
||||||
|
extern bool tsPrintAuth;
|
||||||
|
extern int64_t tsTickPerDay[3];
|
||||||
|
|
||||||
// query buffer management
|
// query buffer management
|
||||||
extern int32_t tsQueryBufferSize; // maximum allowed usage buffer size in MB for each data node during query processing
|
extern int32_t tsQueryBufferSize; // maximum allowed usage buffer size in MB for each data node during query processing
|
||||||
extern int64_t tsQueryBufferSizeBytes; // maximum allowed usage buffer size in byte for each data node
|
extern int64_t tsQueryBufferSizeBytes; // maximum allowed usage buffer size in byte for each data node
|
||||||
extern int32_t tsRetrieveBlockingModel; // retrieve threads will be blocked
|
extern bool tsRetrieveBlockingModel; // retrieve threads will be blocked
|
||||||
extern int8_t tsKeepOriginalColumnName;
|
extern bool tsKeepOriginalColumnName;
|
||||||
extern int8_t tsDeadLockKillQuery;
|
extern bool tsDeadLockKillQuery;
|
||||||
|
|
||||||
// client
|
// client
|
||||||
extern int32_t tsMaxWildCardsLen;
|
extern int32_t tsMaxWildCardsLen;
|
||||||
|
@ -52,13 +72,34 @@ extern float tsStreamComputDelayRatio; // the delayed computing ration of the
|
||||||
extern int32_t tsProjectExecInterval;
|
extern int32_t tsProjectExecInterval;
|
||||||
extern int64_t tsMaxRetentWindow;
|
extern int64_t tsMaxRetentWindow;
|
||||||
|
|
||||||
|
// build info
|
||||||
|
extern char version[];
|
||||||
|
extern char compatible_version[];
|
||||||
|
extern char gitinfo[];
|
||||||
|
extern char gitinfoOfInternal[];
|
||||||
|
extern char buildinfo[];
|
||||||
|
|
||||||
|
// lossy
|
||||||
|
extern char tsLossyColumns[];
|
||||||
|
extern double tsFPrecision;
|
||||||
|
extern double tsDPrecision;
|
||||||
|
extern uint32_t tsMaxRange;
|
||||||
|
extern uint32_t tsCurRange;
|
||||||
|
extern char tsCompressor[];
|
||||||
|
|
||||||
|
// tfs
|
||||||
|
extern int32_t tsDiskCfgNum;
|
||||||
|
extern SDiskCfg tsDiskCfg[];
|
||||||
|
|
||||||
#define NEEDTO_COMPRESSS_MSG(size) (tsCompressMsgSize != -1 && (size) > tsCompressMsgSize)
|
#define NEEDTO_COMPRESSS_MSG(size) (tsCompressMsgSize != -1 && (size) > tsCompressMsgSize)
|
||||||
|
|
||||||
int32_t taosCfgDynamicOptions(char *msg);
|
int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDir, const char *envFile,
|
||||||
bool taosCheckBalanceCfgOptions(const char *option, int32_t *vnodeId, int32_t *dnodeId);
|
const char *apolloUrl, bool tsc);
|
||||||
void taosAddDataDir(int index, char *v1, int level, int primary);
|
int32_t taosInitCfg(const char *cfgDir, const char *envFile, const char *apolloUrl, bool tsc);
|
||||||
void taosReadDataDirCfg(char *v1, char *v2, char *v3);
|
void taosCleanupCfg();
|
||||||
void taosPrintDataDirCfg();
|
void taosCfgDynamicOptions(const char *option, const char *value);
|
||||||
|
|
||||||
|
struct SConfig *taosGetCfg();
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,29 +25,12 @@ extern "C" {
|
||||||
/* ------------------------ TYPES EXPOSED ---------------- */
|
/* ------------------------ TYPES EXPOSED ---------------- */
|
||||||
typedef struct SDnode SDnode;
|
typedef struct SDnode SDnode;
|
||||||
|
|
||||||
/* ------------------------ Environment ------------------ */
|
|
||||||
typedef struct {
|
|
||||||
int32_t sver;
|
|
||||||
int32_t numOfCores;
|
|
||||||
uint16_t numOfCommitThreads;
|
|
||||||
bool enableTelem;
|
|
||||||
bool printAuth;
|
|
||||||
int32_t rpcTimer;
|
|
||||||
int32_t rpcMaxTime;
|
|
||||||
char timezone[TD_TIMEZONE_LEN];
|
|
||||||
char locale[TD_LOCALE_LEN];
|
|
||||||
char charset[TD_LOCALE_LEN];
|
|
||||||
char buildinfo[64];
|
|
||||||
char gitinfo[48];
|
|
||||||
} SDnodeEnvCfg;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Initialize the environment
|
* @brief Initialize the environment
|
||||||
*
|
*
|
||||||
* @param pOption Option of the environment
|
|
||||||
* @return int32_t 0 for success and -1 for failure
|
* @return int32_t 0 for success and -1 for failure
|
||||||
*/
|
*/
|
||||||
int32_t dndInit(const SDnodeEnvCfg *pCfg);
|
int32_t dndInit();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief clear the environment
|
* @brief clear the environment
|
||||||
|
@ -58,11 +41,6 @@ void dndCleanup();
|
||||||
/* ------------------------ SDnode ----------------------- */
|
/* ------------------------ SDnode ----------------------- */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t numOfSupportVnodes;
|
int32_t numOfSupportVnodes;
|
||||||
int32_t statusInterval;
|
|
||||||
float numOfThreadsPerCore;
|
|
||||||
float ratioOfQueryCores;
|
|
||||||
int32_t maxShellConns;
|
|
||||||
int32_t shellActivityTimer;
|
|
||||||
uint16_t serverPort;
|
uint16_t serverPort;
|
||||||
char dataDir[TSDB_FILENAME_LEN];
|
char dataDir[TSDB_FILENAME_LEN];
|
||||||
char localEp[TSDB_EP_LEN];
|
char localEp[TSDB_EP_LEN];
|
||||||
|
|
|
@ -44,26 +44,12 @@ typedef struct SMnodeLoad {
|
||||||
int64_t compStorage;
|
int64_t compStorage;
|
||||||
} SMnodeLoad;
|
} SMnodeLoad;
|
||||||
|
|
||||||
typedef struct SMnodeCfg {
|
|
||||||
int32_t sver;
|
|
||||||
bool enableTelem;
|
|
||||||
bool printAuth;
|
|
||||||
int32_t statusInterval;
|
|
||||||
int32_t shellActivityTimer;
|
|
||||||
char *timezone;
|
|
||||||
char *locale;
|
|
||||||
char *charset;
|
|
||||||
char *buildinfo;
|
|
||||||
char *gitinfo;
|
|
||||||
} SMnodeCfg;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t dnodeId;
|
int32_t dnodeId;
|
||||||
int64_t clusterId;
|
int64_t clusterId;
|
||||||
int8_t replica;
|
int8_t replica;
|
||||||
int8_t selfIndex;
|
int8_t selfIndex;
|
||||||
SReplica replicas[TSDB_MAX_REPLICA];
|
SReplica replicas[TSDB_MAX_REPLICA];
|
||||||
SMnodeCfg cfg;
|
|
||||||
SDnode *pDnode;
|
SDnode *pDnode;
|
||||||
PutReqToMWriteQFp putReqToMWriteQFp;
|
PutReqToMWriteQFp putReqToMWriteQFp;
|
||||||
PutReqToMReadQFp putReqToMReadQFp;
|
PutReqToMReadQFp putReqToMReadQFp;
|
||||||
|
|
|
@ -84,13 +84,7 @@ typedef struct SRpcInit {
|
||||||
void *parent;
|
void *parent;
|
||||||
} SRpcInit;
|
} SRpcInit;
|
||||||
|
|
||||||
typedef struct {
|
int32_t rpcInit();
|
||||||
int32_t rpcTimer;
|
|
||||||
int32_t rpcMaxTime;
|
|
||||||
int32_t sver;
|
|
||||||
} SRpcCfg;
|
|
||||||
|
|
||||||
int32_t rpcInit(SRpcCfg *pCfg);
|
|
||||||
void rpcCleanup();
|
void rpcCleanup();
|
||||||
void *rpcOpen(const SRpcInit *pRpc);
|
void *rpcOpen(const SRpcInit *pRpc);
|
||||||
void rpcClose(void *);
|
void rpcClose(void *);
|
||||||
|
|
|
@ -47,6 +47,8 @@ void osSetLogReservedSpace(float sizeInGB);
|
||||||
void osSetTempReservedSpace(float sizeInGB);
|
void osSetTempReservedSpace(float sizeInGB);
|
||||||
void osSetDataReservedSpace(float sizeInGB);
|
void osSetDataReservedSpace(float sizeInGB);
|
||||||
void osSetTimezone(const char *timezone);
|
void osSetTimezone(const char *timezone);
|
||||||
|
void osSetLocale(const char *locale, const char *charset);
|
||||||
|
bool osSetEnableCore(bool enable);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,6 @@ typedef enum {
|
||||||
CFG_DTYPE_INT64,
|
CFG_DTYPE_INT64,
|
||||||
CFG_DTYPE_FLOAT,
|
CFG_DTYPE_FLOAT,
|
||||||
CFG_DTYPE_STRING,
|
CFG_DTYPE_STRING,
|
||||||
CFG_DTYPE_IPSTR,
|
|
||||||
CFG_DTYPE_DIR,
|
CFG_DTYPE_DIR,
|
||||||
CFG_DTYPE_LOCALE,
|
CFG_DTYPE_LOCALE,
|
||||||
CFG_DTYPE_CHARSET,
|
CFG_DTYPE_CHARSET,
|
||||||
|
@ -52,6 +51,7 @@ typedef enum {
|
||||||
typedef struct SConfigItem {
|
typedef struct SConfigItem {
|
||||||
ECfgSrcType stype;
|
ECfgSrcType stype;
|
||||||
ECfgDataType dtype;
|
ECfgDataType dtype;
|
||||||
|
bool tsc;
|
||||||
char *name;
|
char *name;
|
||||||
union {
|
union {
|
||||||
bool bval;
|
bool bval;
|
||||||
|
@ -82,13 +82,12 @@ void cfgCancelIterate(SConfig *pCfg, SConfigItem *pIter);
|
||||||
SConfigItem *cfgGetItem(SConfig *pCfg, const char *name);
|
SConfigItem *cfgGetItem(SConfig *pCfg, const char *name);
|
||||||
int32_t cfgSetItem(SConfig *pCfg, const char *name, const char *value, ECfgSrcType stype);
|
int32_t cfgSetItem(SConfig *pCfg, const char *name, const char *value, ECfgSrcType stype);
|
||||||
|
|
||||||
int32_t cfgAddBool(SConfig *pCfg, const char *name, bool defaultVal);
|
int32_t cfgAddBool(SConfig *pCfg, const char *name, bool defaultVal, bool tsc);
|
||||||
int32_t cfgAddInt32(SConfig *pCfg, const char *name, int32_t defaultVal, int64_t minval, int64_t maxval);
|
int32_t cfgAddInt32(SConfig *pCfg, const char *name, int32_t defaultVal, int64_t minval, int64_t maxval, bool tsc);
|
||||||
int32_t cfgAddInt64(SConfig *pCfg, const char *name, int64_t defaultVal, int64_t minval, int64_t maxval);
|
int32_t cfgAddInt64(SConfig *pCfg, const char *name, int64_t defaultVal, int64_t minval, int64_t maxval, bool tsc);
|
||||||
int32_t cfgAddFloat(SConfig *pCfg, const char *name, float defaultVal, double minval, double maxval);
|
int32_t cfgAddFloat(SConfig *pCfg, const char *name, float defaultVal, double minval, double maxval, bool tsc);
|
||||||
int32_t cfgAddString(SConfig *pCfg, const char *name, const char *defaultVal);
|
int32_t cfgAddString(SConfig *pCfg, const char *name, const char *defaultVal, bool tsc);
|
||||||
int32_t cfgAddIpStr(SConfig *pCfg, const char *name, const char *defaultVa);
|
int32_t cfgAddDir(SConfig *pCfg, const char *name, const char *defaultVal, bool tsc);
|
||||||
int32_t cfgAddDir(SConfig *pCfg, const char *name, const char *defaultVal);
|
|
||||||
int32_t cfgAddLocale(SConfig *pCfg, const char *name, const char *defaultVal);
|
int32_t cfgAddLocale(SConfig *pCfg, const char *name, const char *defaultVal);
|
||||||
int32_t cfgAddCharset(SConfig *pCfg, const char *name, const char *defaultVal);
|
int32_t cfgAddCharset(SConfig *pCfg, const char *name, const char *defaultVal);
|
||||||
int32_t cfgAddTimezone(SConfig *pCfg, const char *name, const char *defaultVal);
|
int32_t cfgAddTimezone(SConfig *pCfg, const char *name, const char *defaultVal);
|
||||||
|
@ -96,7 +95,7 @@ int32_t cfgAddTimezone(SConfig *pCfg, const char *name, const char *defaultVal);
|
||||||
const char *cfgStypeStr(ECfgSrcType type);
|
const char *cfgStypeStr(ECfgSrcType type);
|
||||||
const char *cfgDtypeStr(ECfgDataType type);
|
const char *cfgDtypeStr(ECfgDataType type);
|
||||||
|
|
||||||
void cfgDumpCfg(SConfig *pCfg);
|
void cfgDumpCfg(SConfig *pCfg, bool tsc, bool dump);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
|
@ -8,7 +8,7 @@ target_include_directories(
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
taos
|
taos
|
||||||
INTERFACE api
|
INTERFACE api
|
||||||
PRIVATE os util common transport parser planner catalog scheduler function qcom config
|
PRIVATE os util common transport parser planner catalog scheduler function qcom
|
||||||
)
|
)
|
||||||
|
|
||||||
if(${BUILD_TEST})
|
if(${BUILD_TEST})
|
||||||
|
|
|
@ -32,7 +32,7 @@ extern "C" {
|
||||||
#include "tmsgtype.h"
|
#include "tmsgtype.h"
|
||||||
#include "trpc.h"
|
#include "trpc.h"
|
||||||
|
|
||||||
#include "config.h"
|
#include "tconfig.h"
|
||||||
|
|
||||||
#define CHECK_CODE_GOTO(expr, label) \
|
#define CHECK_CODE_GOTO(expr, label) \
|
||||||
do { \
|
do { \
|
||||||
|
@ -253,13 +253,6 @@ int hbAddConnInfo(SAppHbMgr* pAppHbMgr, SClientHbKey connKey, void* key, void* v
|
||||||
// --- mq
|
// --- mq
|
||||||
void hbMgrInitMqHbRspHandle();
|
void hbMgrInitMqHbRspHandle();
|
||||||
|
|
||||||
|
|
||||||
// config
|
|
||||||
int32_t tscInitLog(const char *cfgDir, const char *envFile, const char *apolloUrl);
|
|
||||||
int32_t tscInitCfg(const char *cfgDir, const char *envFile, const char *apolloUrl);
|
|
||||||
|
|
||||||
extern SConfig *tscCfg;
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,206 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
|
||||||
*
|
|
||||||
* This program is free software: you can use, redistribute, and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License, version 3
|
|
||||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
|
||||||
#include "clientInt.h"
|
|
||||||
#include "ulog.h"
|
|
||||||
|
|
||||||
// todo refact
|
|
||||||
SConfig *tscCfg;
|
|
||||||
|
|
||||||
static int32_t tscLoadCfg(SConfig *pConfig, const char *inputCfgDir, const char *envFile, const char *apolloUrl) {
|
|
||||||
char cfgDir[PATH_MAX] = {0};
|
|
||||||
char cfgFile[PATH_MAX + 100] = {0};
|
|
||||||
|
|
||||||
taosExpandDir(inputCfgDir, cfgDir, PATH_MAX);
|
|
||||||
snprintf(cfgFile, sizeof(cfgFile), "%s" TD_DIRSEP "taos.cfg", cfgDir);
|
|
||||||
|
|
||||||
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, cfgFile) != 0) {
|
|
||||||
if (cfgLoad(pConfig, CFG_STYPE_CFG_FILE, cfgDir) != 0) {
|
|
||||||
uError("failed to load from config file:%s since %s\n", cfgFile, terrstr());
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cfgLoad(pConfig, CFG_STYPE_ENV_FILE, envFile) != 0) {
|
|
||||||
uError("failed to load from env file:%s since %s\n", envFile, terrstr());
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cfgLoad(pConfig, CFG_STYPE_ENV_VAR, NULL) != 0) {
|
|
||||||
uError("failed to load from global env variables since %s\n", terrstr());
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t tscAddLogCfg(SConfig *pCfg) {
|
|
||||||
if (cfgAddDir(pCfg, "logDir", "/var/log/taos") != 0) return -1;
|
|
||||||
if (cfgAddBool(pCfg, "asyncLog", 1) != 0) return -1;
|
|
||||||
if (cfgAddInt32(pCfg, "numOfLogLines", 10000000, 1000, 2000000000) != 0) return -1;
|
|
||||||
if (cfgAddInt32(pCfg, "logKeepDays", 0, -365000, 365000) != 0) return -1;
|
|
||||||
if (cfgAddInt32(pCfg, "debugFlag", 0, 0, 255) != 0) return -1;
|
|
||||||
if (cfgAddInt32(pCfg, "cDebugFlag", 0, 0, 255) != 0) return -1;
|
|
||||||
if (cfgAddInt32(pCfg, "jniDebugFlag", 0, 0, 255) != 0) return -1;
|
|
||||||
if (cfgAddInt32(pCfg, "tmrDebugFlag", 0, 0, 255) != 0) return -1;
|
|
||||||
if (cfgAddInt32(pCfg, "uDebugFlag", 0, 0, 255) != 0) return -1;
|
|
||||||
if (cfgAddInt32(pCfg, "rpcDebugFlag", 0, 0, 255) != 0) return -1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t tscSetLogCfg(SConfig *pCfg) {
|
|
||||||
osSetLogDir(cfgGetItem(pCfg, "logDir")->str);
|
|
||||||
tsAsyncLog = cfgGetItem(pCfg, "asyncLog")->bval;
|
|
||||||
tsNumOfLogLines = cfgGetItem(pCfg, "numOfLogLines")->i32;
|
|
||||||
tsLogKeepDays = cfgGetItem(pCfg, "logKeepDays")->i32;
|
|
||||||
cDebugFlag = cfgGetItem(pCfg, "cDebugFlag")->i32;
|
|
||||||
jniDebugFlag = cfgGetItem(pCfg, "jniDebugFlag")->i32;
|
|
||||||
tmrDebugFlag = cfgGetItem(pCfg, "tmrDebugFlag")->i32;
|
|
||||||
uDebugFlag = cfgGetItem(pCfg, "uDebugFlag")->i32;
|
|
||||||
rpcDebugFlag = cfgGetItem(pCfg, "rpcDebugFlag")->i32;
|
|
||||||
|
|
||||||
int32_t debugFlag = cfgGetItem(pCfg, "debugFlag")->i32;
|
|
||||||
taosSetAllDebugFlag(debugFlag);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t tscInitLog(const char *cfgDir, const char *envFile, const char *apolloUrl) {
|
|
||||||
if (tsLogInited) return 0;
|
|
||||||
|
|
||||||
SConfig *pCfg = cfgInit();
|
|
||||||
if (pCfg == NULL) return -1;
|
|
||||||
|
|
||||||
if (tscAddLogCfg(pCfg) != 0) {
|
|
||||||
printf("failed to add log cfg since %s\n", terrstr());
|
|
||||||
cfgCleanup(pCfg);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tscLoadCfg(pCfg, cfgDir, envFile, apolloUrl) != 0) {
|
|
||||||
printf("failed to load log cfg since %s\n", terrstr());
|
|
||||||
cfgCleanup(pCfg);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tscSetLogCfg(pCfg) != 0) {
|
|
||||||
printf("failed to set log cfg since %s\n", terrstr());
|
|
||||||
cfgCleanup(pCfg);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
const int32_t maxLogFileNum = 10;
|
|
||||||
if (taosInitLog("taoslog", maxLogFileNum) != 0) {
|
|
||||||
printf("failed to init log file since %s\n", terrstr());
|
|
||||||
cfgCleanup(pCfg);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
cfgDumpCfg(pCfg);
|
|
||||||
cfgCleanup(pCfg);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t tscAddEpCfg(SConfig *pCfg) {
|
|
||||||
char defaultFqdn[TSDB_FQDN_LEN] = {0};
|
|
||||||
if (taosGetFqdn(defaultFqdn) != 0) {
|
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (cfgAddString(pCfg, "fqdn", defaultFqdn) != 0) return -1;
|
|
||||||
|
|
||||||
int32_t defaultServerPort = 6030;
|
|
||||||
if (cfgAddInt32(pCfg, "serverPort", defaultServerPort, 1, 65056) != 0) return -1;
|
|
||||||
|
|
||||||
char defaultFirstEp[TSDB_EP_LEN] = {0};
|
|
||||||
char defaultSecondEp[TSDB_EP_LEN] = {0};
|
|
||||||
snprintf(defaultFirstEp, TSDB_EP_LEN, "%s:%d", defaultFqdn, defaultServerPort);
|
|
||||||
snprintf(defaultSecondEp, TSDB_EP_LEN, "%s:%d", defaultFqdn, defaultServerPort);
|
|
||||||
if (cfgAddString(pCfg, "firstEp", defaultFirstEp) != 0) return -1;
|
|
||||||
if (cfgAddString(pCfg, "secondEp", defaultSecondEp) != 0) return -1;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t tscAddCfg(SConfig *pCfg) {
|
|
||||||
if (tscAddEpCfg(pCfg) != 0) return -1;
|
|
||||||
|
|
||||||
// if (cfgAddString(pCfg, "buildinfo", buildinfo) != 0) return -1;
|
|
||||||
// if (cfgAddString(pCfg, "gitinfo", gitinfo) != 0) return -1;
|
|
||||||
// if (cfgAddString(pCfg, "version", version) != 0) return -1;
|
|
||||||
|
|
||||||
// if (cfgAddDir(pCfg, "dataDir", osDataDir()) != 0) return -1;
|
|
||||||
if (cfgAddTimezone(pCfg, "timezone", "") != 0) return -1;
|
|
||||||
if (cfgAddLocale(pCfg, "locale", "") != 0) return -1;
|
|
||||||
if (cfgAddCharset(pCfg, "charset", "") != 0) return -1;
|
|
||||||
if (cfgAddInt32(pCfg, "numOfCores", 1, 1, 100000) != 0) return -1;
|
|
||||||
if (cfgAddInt32(pCfg, "numOfCommitThreads", 4, 1, 1000) != 0) return -1;
|
|
||||||
// if (cfgAddBool(pCfg, "telemetryReporting", 0) != 0) return -1;
|
|
||||||
if (cfgAddBool(pCfg, "enableCoreFile", 0) != 0) return -1;
|
|
||||||
// if (cfgAddInt32(pCfg, "supportVnodes", 256, 0, 65536) != 0) return -1;
|
|
||||||
if (cfgAddInt32(pCfg, "statusInterval", 1, 1, 30) != 0) return -1;
|
|
||||||
if (cfgAddFloat(pCfg, "numOfThreadsPerCore", 1, 0, 10) != 0) return -1;
|
|
||||||
if (cfgAddFloat(pCfg, "ratioOfQueryCores", 1, 0, 5) != 0) return -1;
|
|
||||||
if (cfgAddInt32(pCfg, "shellActivityTimer", 3, 1, 120) != 0) return -1;
|
|
||||||
if (cfgAddInt32(pCfg, "rpcTimer", 300, 100, 3000) != 0) return -1;
|
|
||||||
if (cfgAddInt32(pCfg, "rpcMaxTime", 600, 100, 7200) != 0) return -1;
|
|
||||||
if (cfgAddInt32(pCfg, "maxConnections", 50000, 1, 100000) != 0) return -1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t tscCheckCfg(SConfig *pCfg) {
|
|
||||||
bool enableCore = cfgGetItem(pCfg, "enableCoreFile")->bval;
|
|
||||||
taosSetCoreDump(enableCore);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
SConfig *tscInitCfgImp(const char *cfgDir, const char *envFile, const char *apolloUrl) {
|
|
||||||
SConfig *pCfg = cfgInit();
|
|
||||||
if (pCfg == NULL) return NULL;
|
|
||||||
|
|
||||||
if (tscAddCfg(pCfg) != 0) {
|
|
||||||
uError("failed to init tsc cfg since %s", terrstr());
|
|
||||||
cfgCleanup(pCfg);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tscLoadCfg(pCfg, cfgDir, envFile, apolloUrl) != 0) {
|
|
||||||
printf("failed to load tsc cfg since %s\n", terrstr());
|
|
||||||
cfgCleanup(pCfg);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tscCheckCfg(pCfg) != 0) {
|
|
||||||
uError("failed to check cfg since %s", terrstr());
|
|
||||||
cfgCleanup(pCfg);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
cfgDumpCfg(pCfg);
|
|
||||||
return pCfg;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t tscInitCfg(const char *cfgDir, const char *envFile, const char *apolloUrl) {
|
|
||||||
tscCfg = tscInitCfgImp(cfgDir, envFile, apolloUrl);
|
|
||||||
if (tscCfg == NULL) return -1;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -93,10 +93,10 @@ void *openTransporter(const char *user, const char *auth, int32_t numOfThread) {
|
||||||
rpcInit.numOfThreads = numOfThread;
|
rpcInit.numOfThreads = numOfThread;
|
||||||
rpcInit.cfp = processMsgFromServer;
|
rpcInit.cfp = processMsgFromServer;
|
||||||
rpcInit.pfp = persistConnForSpecificMsg;
|
rpcInit.pfp = persistConnForSpecificMsg;
|
||||||
rpcInit.sessions = cfgGetItem(tscCfg, "maxConnections")->i32;
|
rpcInit.sessions = tsMaxConnections;
|
||||||
rpcInit.connType = TAOS_CONN_CLIENT;
|
rpcInit.connType = TAOS_CONN_CLIENT;
|
||||||
rpcInit.user = (char *)user;
|
rpcInit.user = (char *)user;
|
||||||
rpcInit.idleTime = cfgGetItem(tscCfg, "shellActivityTimer")->i32 * 1000;
|
rpcInit.idleTime = tsShellActivityTimer * 1000;
|
||||||
rpcInit.ckey = "key";
|
rpcInit.ckey = "key";
|
||||||
rpcInit.spi = 1;
|
rpcInit.spi = 1;
|
||||||
rpcInit.secret = (char *)auth;
|
rpcInit.secret = (char *)auth;
|
||||||
|
@ -212,12 +212,12 @@ void taos_init_imp(void) {
|
||||||
|
|
||||||
deltaToUtcInitOnce();
|
deltaToUtcInitOnce();
|
||||||
|
|
||||||
if (tscInitLog(configDir, NULL, NULL) != 0) {
|
if (taosCreateLog("taoslog", 10, configDir, NULL, NULL, 1) != 0) {
|
||||||
tscInitRes = -1;
|
tscInitRes = -1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tscInitCfg(configDir, NULL, NULL) != 0) {
|
if (taosInitCfg(configDir, NULL, NULL, 1) != 0) {
|
||||||
tscInitRes = -1;
|
tscInitRes = -1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -225,11 +225,7 @@ void taos_init_imp(void) {
|
||||||
initMsgHandleFp();
|
initMsgHandleFp();
|
||||||
initQueryModuleMsgHandle();
|
initQueryModuleMsgHandle();
|
||||||
|
|
||||||
SRpcCfg rpcCfg = {0};
|
rpcInit();
|
||||||
rpcCfg.rpcTimer = cfgGetItem(tscCfg, "rpcTimer")->i32;
|
|
||||||
rpcCfg.rpcMaxTime = cfgGetItem(tscCfg, "rpcMaxTime")->i32;
|
|
||||||
rpcCfg.sver = 30000000;
|
|
||||||
rpcInit(&rpcCfg);
|
|
||||||
|
|
||||||
SCatalogCfg cfg = {.maxDBCacheNum = 100, .maxTblCacheNum = 100};
|
SCatalogCfg cfg = {.maxDBCacheNum = 100, .maxTblCacheNum = 100};
|
||||||
catalogInit(&cfg);
|
catalogInit(&cfg);
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
#include "tpagedbuf.h"
|
#include "tpagedbuf.h"
|
||||||
#include "tref.h"
|
#include "tref.h"
|
||||||
|
|
||||||
static int32_t initEpSetFromCfg(const char* ip, uint16_t port, SCorEpSet* pEpSet);
|
static int32_t initEpSetFromCfg(const char* firstEp, const char* secondEp, SCorEpSet* pEpSet);
|
||||||
static SMsgSendInfo* buildConnectMsg(SRequestObj* pRequest);
|
static SMsgSendInfo* buildConnectMsg(SRequestObj* pRequest);
|
||||||
static void destroySendMsgInfo(SMsgSendInfo* pMsgBody);
|
static void destroySendMsgInfo(SMsgSendInfo* pMsgBody);
|
||||||
static void setQueryResultFromRsp(SReqResultInfo* pResultInfo, const SRetrieveTableRsp* pRsp);
|
static void setQueryResultFromRsp(SReqResultInfo* pResultInfo, const SRetrieveTableRsp* pRsp);
|
||||||
|
@ -80,7 +80,19 @@ TAOS* taos_connect_internal(const char* ip, const char* user, const char* pass,
|
||||||
}
|
}
|
||||||
|
|
||||||
SCorEpSet epSet = {0};
|
SCorEpSet epSet = {0};
|
||||||
initEpSetFromCfg(ip, port, &epSet);
|
if (ip) {
|
||||||
|
if (initEpSetFromCfg(ip, NULL, &epSet) < 0) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (port) {
|
||||||
|
epSet.epSet.eps[0].port = port;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (initEpSetFromCfg(tsFirst, tsSecond, &epSet) < 0) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
char* key = getClusterKey(user, secretEncrypt, ip, port);
|
char* key = getClusterKey(user, secretEncrypt, ip, port);
|
||||||
SAppInstInfo** pInst = NULL;
|
SAppInstInfo** pInst = NULL;
|
||||||
|
@ -267,40 +279,32 @@ _return:
|
||||||
return pRequest;
|
return pRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
int initEpSetFromCfg(const char* ip, uint16_t port, SCorEpSet* pEpSet) {
|
int initEpSetFromCfg(const char* firstEp, const char* secondEp, SCorEpSet* pEpSet) {
|
||||||
SConfigItem* pFirst = cfgGetItem(tscCfg, "firstEp");
|
pEpSet->version = 0;
|
||||||
SConfigItem* pSecond = cfgGetItem(tscCfg, "secondEp");
|
|
||||||
SConfigItem* pPort = cfgGetItem(tscCfg, "serverPort");
|
|
||||||
|
|
||||||
// init mnode ip set
|
// init mnode ip set
|
||||||
SEpSet* mgmtEpSet = &(pEpSet->epSet);
|
SEpSet* mgmtEpSet = &(pEpSet->epSet);
|
||||||
mgmtEpSet->numOfEps = 0;
|
mgmtEpSet->numOfEps = 0;
|
||||||
mgmtEpSet->inUse = 0;
|
mgmtEpSet->inUse = 0;
|
||||||
pEpSet->version = 0;
|
|
||||||
|
|
||||||
if (ip != NULL) {
|
if (firstEp && firstEp[0] != 0) {
|
||||||
taosGetFqdnPortFromEp(ip, (uint16_t)pPort->i32, &mgmtEpSet->eps[0]);
|
if (strlen(firstEp) >= TSDB_EP_LEN) {
|
||||||
|
terrno = TSDB_CODE_TSC_INVALID_FQDN;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
taosGetFqdnPortFromEp(firstEp, &mgmtEpSet->eps[0]);
|
||||||
mgmtEpSet->numOfEps++;
|
mgmtEpSet->numOfEps++;
|
||||||
if (port) {
|
}
|
||||||
mgmtEpSet->eps[0].port = port;
|
|
||||||
}
|
if (secondEp && secondEp[0] != 0) {
|
||||||
} else {
|
if (strlen(secondEp) >= TSDB_EP_LEN) {
|
||||||
if (pFirst->str[0] != 0) {
|
terrno = TSDB_CODE_TSC_INVALID_FQDN;
|
||||||
if (strlen(pFirst->str) >= TSDB_EP_LEN) {
|
return -1;
|
||||||
terrno = TSDB_CODE_TSC_INVALID_FQDN;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
taosGetFqdnPortFromEp(pFirst->str, (uint16_t)pPort->i32, &mgmtEpSet->eps[0]);
|
|
||||||
mgmtEpSet->numOfEps++;
|
|
||||||
}
|
|
||||||
if (pSecond->str[0] != 0) {
|
|
||||||
if (strlen(pSecond->str) >= TSDB_EP_LEN) {
|
|
||||||
terrno = TSDB_CODE_TSC_INVALID_FQDN;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
taosGetFqdnPortFromEp(pSecond->str, (uint16_t)pPort->i32, &mgmtEpSet->eps[1]);
|
|
||||||
mgmtEpSet->numOfEps++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
taosGetFqdnPortFromEp(secondEp, &mgmtEpSet->eps[mgmtEpSet->numOfEps]);
|
||||||
|
mgmtEpSet->numOfEps++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mgmtEpSet->numOfEps == 0) {
|
if (mgmtEpSet->numOfEps == 0) {
|
||||||
|
|
|
@ -8,13 +8,13 @@ AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST)
|
||||||
ADD_EXECUTABLE(clientTest clientTests.cpp)
|
ADD_EXECUTABLE(clientTest clientTests.cpp)
|
||||||
TARGET_LINK_LIBRARIES(
|
TARGET_LINK_LIBRARIES(
|
||||||
clientTest
|
clientTest
|
||||||
PUBLIC os util common transport parser catalog scheduler function gtest taos qcom config
|
PUBLIC os util common transport parser catalog scheduler function gtest taos qcom
|
||||||
)
|
)
|
||||||
|
|
||||||
ADD_EXECUTABLE(tmqTest tmqTest.cpp)
|
ADD_EXECUTABLE(tmqTest tmqTest.cpp)
|
||||||
TARGET_LINK_LIBRARIES(
|
TARGET_LINK_LIBRARIES(
|
||||||
tmqTest
|
tmqTest
|
||||||
PUBLIC os util common transport parser catalog scheduler function gtest taos qcom config
|
PUBLIC os util common transport parser catalog scheduler function gtest taos qcom
|
||||||
)
|
)
|
||||||
|
|
||||||
TARGET_INCLUDE_DIRECTORIES(
|
TARGET_INCLUDE_DIRECTORIES(
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "tglobal.h"
|
#include "tglobal.h"
|
||||||
#include "tlockfree.h"
|
#include "tlockfree.h"
|
||||||
|
|
||||||
int taosGetFqdnPortFromEp(const char *ep, uint16_t defaultPort, SEp* pEp) {
|
int taosGetFqdnPortFromEp(const char *ep, SEp* pEp) {
|
||||||
pEp->port = 0;
|
pEp->port = 0;
|
||||||
strcpy(pEp->fqdn, ep);
|
strcpy(pEp->fqdn, ep);
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ int taosGetFqdnPortFromEp(const char *ep, uint16_t defaultPort, SEp* pEp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pEp->port == 0) {
|
if (pEp->port == 0) {
|
||||||
pEp->port = defaultPort;
|
pEp->port = tsServerPort;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,18 +19,39 @@
|
||||||
#include "taosdef.h"
|
#include "taosdef.h"
|
||||||
#include "taoserror.h"
|
#include "taoserror.h"
|
||||||
#include "tcompare.h"
|
#include "tcompare.h"
|
||||||
|
#include "tconfig.h"
|
||||||
#include "tep.h"
|
#include "tep.h"
|
||||||
#include "tglobal.h"
|
#include "tglobal.h"
|
||||||
#include "tlog.h"
|
#include "tlog.h"
|
||||||
#include "tutil.h"
|
#include "tutil.h"
|
||||||
#include "ulog.h"
|
#include "ulog.h"
|
||||||
|
|
||||||
|
SConfig *tsCfg = NULL;
|
||||||
|
|
||||||
|
// cluster
|
||||||
|
char tsFirst[TSDB_EP_LEN] = {0};
|
||||||
|
char tsSecond[TSDB_EP_LEN] = {0};
|
||||||
|
char tsLocalFqdn[TSDB_FQDN_LEN] = {0};
|
||||||
|
char tsLocalEp[TSDB_EP_LEN] = {0}; // Local End Point, hostname:port
|
||||||
|
uint16_t tsServerPort = 6030;
|
||||||
|
int32_t tsVersion = 30000000;
|
||||||
|
int32_t tsStatusInterval = 1; // second
|
||||||
|
bool tsEnableTelemetryReporting = 0;
|
||||||
|
|
||||||
// common
|
// common
|
||||||
|
int32_t tsRpcTimer = 300;
|
||||||
|
int32_t tsRpcMaxTime = 600; // seconds;
|
||||||
|
bool tsRpcForceTcp = 1; // disable this, means query, show command use udp protocol as default
|
||||||
|
int32_t tsMaxShellConns = 50000;
|
||||||
|
int32_t tsMaxConnections = 50000;
|
||||||
|
int32_t tsShellActivityTimer = 3; // second
|
||||||
|
float tsNumOfThreadsPerCore = 1.0f;
|
||||||
|
int32_t tsNumOfCommitThreads = 4;
|
||||||
|
float tsRatioOfQueryCores = 1.0f;
|
||||||
int32_t tsMaxBinaryDisplayWidth = 30;
|
int32_t tsMaxBinaryDisplayWidth = 30;
|
||||||
int8_t tsEnableSlaveQuery = 1;
|
bool tsEnableSlaveQuery = 1;
|
||||||
int8_t tsEnableAdjustMaster = 1;
|
bool tsPrintAuth = 0;
|
||||||
int8_t tsPrintAuth = 0;
|
|
||||||
/*
|
/*
|
||||||
* denote if the server needs to compress response message at the application layer to client, including query rsp,
|
* denote if the server needs to compress response message at the application layer to client, including query rsp,
|
||||||
* metricmeta rsp, and multi-meter query rsp message body. The client compress the submit message to server.
|
* metricmeta rsp, and multi-meter query rsp message body. The client compress the submit message to server.
|
||||||
|
@ -93,18 +114,21 @@ int32_t tsQueryBufferSize = -1;
|
||||||
int64_t tsQueryBufferSizeBytes = -1;
|
int64_t tsQueryBufferSizeBytes = -1;
|
||||||
|
|
||||||
// in retrieve blocking model, the retrieve threads will wait for the completion of the query processing.
|
// in retrieve blocking model, the retrieve threads will wait for the completion of the query processing.
|
||||||
int32_t tsRetrieveBlockingModel = 0;
|
bool tsRetrieveBlockingModel = 0;
|
||||||
|
|
||||||
// last_row(*), first(*), last_row(ts, col1, col2) query, the result fields will be the original column name
|
// last_row(*), first(*), last_row(ts, col1, col2) query, the result fields will be the original column name
|
||||||
int8_t tsKeepOriginalColumnName = 0;
|
bool tsKeepOriginalColumnName = 0;
|
||||||
|
|
||||||
// long query death-lock
|
// long query death-lock
|
||||||
int8_t tsDeadLockKillQuery = 0;
|
bool tsDeadLockKillQuery = 0;
|
||||||
|
|
||||||
// tsdb config
|
// tsdb config
|
||||||
// For backward compatibility
|
// For backward compatibility
|
||||||
bool tsdbForceKeepFile = false;
|
bool tsdbForceKeepFile = false;
|
||||||
|
|
||||||
|
int32_t tsDiskCfgNum = 0;
|
||||||
|
SDiskCfg tsDiskCfg[TFS_MAX_DISKS] = {0};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* minimum scale for whole system, millisecond by default
|
* minimum scale for whole system, millisecond by default
|
||||||
* for TSDB_TIME_PRECISION_MILLI: 86400000L
|
* for TSDB_TIME_PRECISION_MILLI: 86400000L
|
||||||
|
@ -113,414 +137,351 @@ bool tsdbForceKeepFile = false;
|
||||||
*/
|
*/
|
||||||
int64_t tsTickPerDay[] = {86400000L, 86400000000L, 86400000000000L};
|
int64_t tsTickPerDay[] = {86400000L, 86400000000L, 86400000000000L};
|
||||||
|
|
||||||
int32_t (*monStartSystemFp)() = NULL;
|
// lossy compress 6
|
||||||
void (*monStopSystemFp)() = NULL;
|
char tsLossyColumns[32] = ""; // "float|double" means all float and double columns can be lossy compressed. set empty
|
||||||
void (*monExecuteSQLFp)(char *sql) = NULL;
|
// can close lossy compress.
|
||||||
|
// below option can take effect when tsLossyColumns not empty
|
||||||
|
double tsFPrecision = 1E-8; // float column precision
|
||||||
|
double tsDPrecision = 1E-16; // double column precision
|
||||||
|
uint32_t tsMaxRange = 500; // max range
|
||||||
|
uint32_t tsCurRange = 100; // range
|
||||||
|
char tsCompressor[32] = "ZSTD_COMPRESSOR"; // ZSTD_COMPRESSOR or GZIP_COMPRESSOR
|
||||||
|
|
||||||
char *qtypeStr[] = {"rpc", "fwd", "wal", "cq", "query"};
|
static void taosAddDataDir(int32_t index, char *v1, int32_t level, int32_t primary) {
|
||||||
|
tstrncpy(tsDiskCfg[index].dir, v1, TSDB_FILENAME_LEN);
|
||||||
static pthread_once_t tsInitGlobalCfgOnce = PTHREAD_ONCE_INIT;
|
tsDiskCfg[index].level = level;
|
||||||
|
tsDiskCfg[index].primary = primary;
|
||||||
|
uTrace("dataDir:%s, level:%d primary:%d is configured", v1, level, primary);
|
||||||
int32_t taosCfgDynamicOptions(char *msg) {
|
|
||||||
#if 0
|
|
||||||
char *option, *value;
|
|
||||||
int32_t olen, vlen;
|
|
||||||
int32_t vint = 0;
|
|
||||||
|
|
||||||
paGetToken(msg, &option, &olen);
|
|
||||||
if (olen == 0) return -1;
|
|
||||||
|
|
||||||
paGetToken(option + olen + 1, &value, &vlen);
|
|
||||||
if (vlen == 0)
|
|
||||||
vint = 135;
|
|
||||||
else {
|
|
||||||
vint = atoi(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
uInfo("change dynamic option: %s, value: %d", option, vint);
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < tsGlobalConfigNum; ++i) {
|
|
||||||
SGlobalCfg *cfg = tsGlobalConfig + i;
|
|
||||||
// if (!(cfg->cfgType & TSDB_CFG_CTYPE_B_LOG)) continue;
|
|
||||||
if (cfg->valType != TAOS_CFG_VTYPE_INT32 && cfg->valType != TAOS_CFG_VTYPE_INT8) continue;
|
|
||||||
|
|
||||||
int32_t cfgLen = (int32_t)strlen(cfg->option);
|
|
||||||
if (cfgLen != olen) continue;
|
|
||||||
if (strncasecmp(option, cfg->option, olen) != 0) continue;
|
|
||||||
if (cfg->valType == TAOS_CFG_VTYPE_INT32) {
|
|
||||||
*((int32_t *)cfg->ptr) = vint;
|
|
||||||
} else {
|
|
||||||
*((int8_t *)cfg->ptr) = (int8_t)vint;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strncasecmp(cfg->option, "monitor", olen) == 0) {
|
|
||||||
if (1 == vint) {
|
|
||||||
if (monStartSystemFp) {
|
|
||||||
(*monStartSystemFp)();
|
|
||||||
uInfo("monitor is enabled");
|
|
||||||
} else {
|
|
||||||
uError("monitor can't be updated, for monitor not initialized");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (monStopSystemFp) {
|
|
||||||
(*monStopSystemFp)();
|
|
||||||
uInfo("monitor is disabled");
|
|
||||||
} else {
|
|
||||||
uError("monitor can't be updated, for monitor not initialized");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (strncasecmp(cfg->option, "debugFlag", olen) == 0) {
|
|
||||||
taosSetAllDebugFlag();
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strncasecmp(option, "resetlog", 8) == 0) {
|
|
||||||
taosResetLog();
|
|
||||||
taosPrintCfg();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strncasecmp(option, "resetQueryCache", 15) == 0) {
|
|
||||||
if (monExecuteSQLFp) {
|
|
||||||
(*monExecuteSQLFp)("resetQueryCache");
|
|
||||||
uInfo("resetquerycache is executed");
|
|
||||||
} else {
|
|
||||||
uError("resetquerycache can't be executed, for monitor not started");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// void taosAddDataDir(int index, char *v1, int level, int primary) {
|
static void taosReadDataDirCfg(char *v1, char *v2, char *v3) {
|
||||||
// tstrncpy(tsDiskCfg[index].dir, v1, TSDB_FILENAME_LEN);
|
if (tsDiskCfgNum == 1) {
|
||||||
// tsDiskCfg[index].level = level;
|
SDiskCfg *cfg = &tsDiskCfg[0];
|
||||||
// tsDiskCfg[index].primary = primary;
|
uInfo("dataDir:%s, level:%d primary:%d is replaced by %s", cfg->dir, cfg->level, cfg->primary, v1);
|
||||||
// uTrace("dataDir:%s, level:%d primary:%d is configured", v1, level, primary);
|
}
|
||||||
// }
|
taosAddDataDir(0, v1, 0, 1);
|
||||||
|
tsDiskCfgNum = 1;
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef _STORAGE
|
static void taosPrintDataDirCfg() {
|
||||||
// void taosReadDataDirCfg(char *v1, char *v2, char *v3) {
|
for (int32_t i = 0; i < tsDiskCfgNum; ++i) {
|
||||||
// if (tsDiskCfgNum == 1) {
|
SDiskCfg *cfg = &tsDiskCfg[i];
|
||||||
// SDiskCfg *cfg = &tsDiskCfg[0];
|
uInfo(" dataDir: %s", cfg->dir);
|
||||||
// uInfo("dataDir:%s, level:%d primary:%d is replaced by %s", cfg->dir, cfg->level, cfg->primary, v1);
|
}
|
||||||
// }
|
}
|
||||||
// taosAddDataDir(0, v1, 0, 1);
|
|
||||||
// tsDiskCfgNum = 1;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// void taosPrintDataDirCfg() {
|
struct SConfig *taosGetCfg() {
|
||||||
// for (int i = 0; i < tsDiskCfgNum; ++i) {
|
return tsCfg;
|
||||||
// SDiskCfg *cfg = &tsDiskCfg[i];
|
}
|
||||||
// uInfo(" dataDir: %s", cfg->dir);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
static int32_t taosLoadCfg(SConfig *pCfg, const char *inputCfgDir, const char *envFile, const char *apolloUrl) {
|
||||||
|
char cfgDir[PATH_MAX] = {0};
|
||||||
|
char cfgFile[PATH_MAX + 100] = {0};
|
||||||
|
|
||||||
|
taosExpandDir(inputCfgDir, cfgDir, PATH_MAX);
|
||||||
|
snprintf(cfgFile, sizeof(cfgFile), "%s" TD_DIRSEP "taos.cfg", cfgDir);
|
||||||
|
|
||||||
static void doInitGlobalConfig(void) {
|
if (cfgLoad(pCfg, CFG_STYPE_APOLLO_URL, apolloUrl) != 0) {
|
||||||
|
uError("failed to load from apollo url:%s since %s\n", apolloUrl, terrstr());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cfgLoad(pCfg, CFG_STYPE_CFG_FILE, cfgFile) != 0) {
|
||||||
|
if (cfgLoad(pCfg, CFG_STYPE_CFG_FILE, cfgDir) != 0) {
|
||||||
|
uError("failed to load from config file:%s since %s\n", cfgFile, terrstr());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cfgLoad(pCfg, CFG_STYPE_ENV_FILE, envFile) != 0) {
|
||||||
|
uError("failed to load from env file:%s since %s\n", envFile, terrstr());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cfgLoad(pCfg, CFG_STYPE_ENV_VAR, NULL) != 0) {
|
||||||
|
uError("failed to load from global env variables since %s\n", terrstr());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void taosAddClientLogCfg(SConfig *pCfg) {
|
||||||
|
cfgAddDir(pCfg, "logDir", osLogDir(), 1);
|
||||||
|
cfgAddFloat(pCfg, "minimalLogDirGB", 1.0f, 0.001f, 10000000, 1);
|
||||||
|
cfgAddInt32(pCfg, "numOfLogLines", tsNumOfLogLines, 1000, 2000000000, 1);
|
||||||
|
cfgAddBool(pCfg, "asyncLog", tsAsyncLog, 1);
|
||||||
|
cfgAddInt32(pCfg, "logKeepDays", 0, -365000, 365000, 1);
|
||||||
|
cfgAddInt32(pCfg, "cDebugFlag", cDebugFlag, 0, 255, 1);
|
||||||
|
cfgAddInt32(pCfg, "uDebugFlag", uDebugFlag, 0, 255, 1);
|
||||||
|
cfgAddInt32(pCfg, "rpcDebugFlag", rpcDebugFlag, 0, 255, 1);
|
||||||
|
cfgAddInt32(pCfg, "tmrDebugFlag", tmrDebugFlag, 0, 255, 1);
|
||||||
|
cfgAddInt32(pCfg, "jniDebugFlag", jniDebugFlag, 0, 255, 1);
|
||||||
|
cfgAddInt32(pCfg, "simDebugFlag", 143, 0, 255, 1);
|
||||||
|
cfgAddDir(pCfg, "configDir", configDir, 1);
|
||||||
|
cfgAddDir(pCfg, "scriptDir", configDir, 1);
|
||||||
|
cfgAddInt32(pCfg, "debugFlag", 0, 0, 255, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void taosAddServerLogCfg(SConfig *pCfg) {
|
||||||
|
cfgAddInt32(pCfg, "dDebugFlag", dDebugFlag, 0, 255, 0);
|
||||||
|
cfgAddInt32(pCfg, "vDebugFlag", vDebugFlag, 0, 255, 0);
|
||||||
|
cfgAddInt32(pCfg, "mDebugFlag", mDebugFlag, 0, 255, 0);
|
||||||
|
cfgAddInt32(pCfg, "qDebugFlag", qDebugFlag, 0, 255, 0);
|
||||||
|
cfgAddInt32(pCfg, "wDebugFlag", wDebugFlag, 0, 255, 0);
|
||||||
|
cfgAddInt32(pCfg, "sDebugFlag", sDebugFlag, 0, 255, 0);
|
||||||
|
cfgAddInt32(pCfg, "tsdbDebugFlag", tsdbDebugFlag, 0, 255, 0);
|
||||||
|
cfgAddInt32(pCfg, "tqDebugFlag", tqDebugFlag, 0, 255, 0);
|
||||||
|
cfgAddInt32(pCfg, "fsDebugFlag", fsDebugFlag, 0, 255, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void taosAddClientCfg(SConfig *pCfg) {
|
||||||
|
char defaultFqdn[TSDB_FQDN_LEN] = {0};
|
||||||
|
int32_t defaultServerPort = 6030;
|
||||||
|
char defaultFirstEp[TSDB_EP_LEN] = {0};
|
||||||
|
char defaultSecondEp[TSDB_EP_LEN] = {0};
|
||||||
|
taosGetFqdn(defaultFqdn);
|
||||||
|
snprintf(defaultFirstEp, TSDB_EP_LEN, "%s:%d", defaultFqdn, defaultServerPort);
|
||||||
|
snprintf(defaultSecondEp, TSDB_EP_LEN, "%s:%d", defaultFqdn, defaultServerPort);
|
||||||
|
|
||||||
|
cfgAddString(pCfg, "firstEp", defaultFirstEp, 1);
|
||||||
|
cfgAddString(pCfg, "secondEp", defaultSecondEp, 1);
|
||||||
|
cfgAddString(pCfg, "fqdn", defaultFqdn, 1);
|
||||||
|
cfgAddInt32(pCfg, "serverPort", defaultServerPort, 1, 65056, 1);
|
||||||
|
cfgAddDir(pCfg, "tempDir", osTempDir(), 1);
|
||||||
|
cfgAddFloat(pCfg, "minimalTempDirGB", 1.0f, 0.001f, 10000000, 1);
|
||||||
|
cfgAddFloat(pCfg, "numOfThreadsPerCore", tsNumOfThreadsPerCore, 0, 10, 1);
|
||||||
|
cfgAddInt32(pCfg, "maxTmrCtrl", tsMaxTmrCtrl, 8, 2048, 1);
|
||||||
|
cfgAddInt32(pCfg, "rpcTimer", tsRpcTimer, 100, 3000, 1);
|
||||||
|
cfgAddInt32(pCfg, "rpcMaxTime", tsRpcMaxTime, 100, 7200, 1);
|
||||||
|
cfgAddBool(pCfg, "rpcForceTcp", tsRpcForceTcp, 1);
|
||||||
|
cfgAddInt32(pCfg, "shellActivityTimer", tsShellActivityTimer, 1, 120, 1);
|
||||||
|
cfgAddInt32(pCfg, "compressMsgSize", tsCompressMsgSize, -1, 100000000, 1);
|
||||||
|
cfgAddInt32(pCfg, "compressColData", tsCompressColData, -1, 100000000, 1);
|
||||||
|
cfgAddInt32(pCfg, "maxWildCardsLength", tsMaxWildCardsLen, 0, TSDB_MAX_FIELD_LEN, 1);
|
||||||
|
cfgAddInt32(pCfg, "maxRegexStringLen", tsMaxRegexStringLen, 0, TSDB_MAX_FIELD_LEN, 1);
|
||||||
|
cfgAddInt32(pCfg, "maxNumOfOrderedRes", tsMaxNumOfOrderedResults, 128, TSDB_MAX_ALLOWED_SQL_LEN, 1);
|
||||||
|
cfgAddBool(pCfg, "keepColumnName", tsKeepOriginalColumnName, 1);
|
||||||
|
cfgAddInt32(pCfg, "maxBinaryDisplayWidth", tsMaxBinaryDisplayWidth, 1, 65536, 1);
|
||||||
|
cfgAddTimezone(pCfg, "timezone", osTimezone());
|
||||||
|
cfgAddLocale(pCfg, "locale", osLocale());
|
||||||
|
cfgAddCharset(pCfg, "charset", osCharset());
|
||||||
|
cfgAddBool(pCfg, "enableCoreFile", 0, 1);
|
||||||
|
cfgAddInt32(pCfg, "numOfCores", tsNumOfCores, 1, 100000, 1);
|
||||||
|
cfgAddString(pCfg, "version", version, 1);
|
||||||
|
cfgAddString(pCfg, "compatible_version", compatible_version, 1);
|
||||||
|
cfgAddString(pCfg, "gitinfo", gitinfo, 1);
|
||||||
|
cfgAddString(pCfg, "gitinfoOfInternal", gitinfoOfInternal, 1);
|
||||||
|
cfgAddString(pCfg, "buildinfo", buildinfo, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void taosAddServerCfg(SConfig *pCfg) {
|
||||||
|
cfgAddInt32(pCfg, "supportVnodes", 256, 0, 65536, 0);
|
||||||
|
cfgAddDir(pCfg, "dataDir", osDataDir(), 0);
|
||||||
|
cfgAddFloat(pCfg, "minimalDataDirGB", 2.0f, 0.001f, 10000000, 0);
|
||||||
|
cfgAddInt32(pCfg, "numOfCommitThreads", tsNumOfCommitThreads, 1, 100, 0);
|
||||||
|
cfgAddFloat(pCfg, "ratioOfQueryCores", tsRatioOfQueryCores, 0, 2, 0);
|
||||||
|
cfgAddInt32(pCfg, "maxNumOfDistinctRes", tsMaxNumOfDistinctResults, 10 * 10000, 10000 * 10000, 0);
|
||||||
|
cfgAddBool(pCfg, "telemetryReporting", tsEnableTelemetryReporting, 0);
|
||||||
|
cfgAddInt32(pCfg, "maxConnections", tsMaxConnections, 1, 100000, 0);
|
||||||
|
cfgAddInt32(pCfg, "maxShellConns", tsMaxShellConns, 10, 50000000, 0);
|
||||||
|
cfgAddInt32(pCfg, "statusInterval", tsStatusInterval, 1, 30, 0);
|
||||||
|
cfgAddInt32(pCfg, "minSlidingTime", tsMinSlidingTime, 10, 1000000, 0);
|
||||||
|
cfgAddInt32(pCfg, "minIntervalTime", tsMinIntervalTime, 1, 1000000, 0);
|
||||||
|
cfgAddInt32(pCfg, "maxStreamCompDelay", tsMaxStreamComputDelay, 10, 1000000000, 0);
|
||||||
|
cfgAddInt32(pCfg, "maxFirstStreamCompDelay", tsStreamCompStartDelay, 1000, 1000000000, 0);
|
||||||
|
cfgAddInt32(pCfg, "retryStreamCompDelay", tsRetryStreamCompDelay, 10, 1000000000, 0);
|
||||||
|
cfgAddFloat(pCfg, "streamCompDelayRatio", tsStreamComputDelayRatio, 0.1, 0.9, 0);
|
||||||
|
cfgAddInt32(pCfg, "queryBufferSize", tsQueryBufferSize, -1, 500000000000, 0);
|
||||||
|
cfgAddBool(pCfg, "retrieveBlockingModel", tsRetrieveBlockingModel, 0);
|
||||||
|
cfgAddBool(pCfg, "printAuth", tsPrintAuth, 0);
|
||||||
|
cfgAddBool(pCfg, "slaveQuery", tsEnableSlaveQuery, 0);
|
||||||
|
cfgAddBool(pCfg, "deadLockKillQuery", tsDeadLockKillQuery, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void taosSetClientLogCfg(SConfig *pCfg) {
|
||||||
|
SConfigItem *pItem = cfgGetItem(pCfg, "logDir");
|
||||||
|
osSetLogDir(cfgGetItem(pCfg, "logDir")->str);
|
||||||
|
osSetDataReservedSpace(cfgGetItem(pCfg, "minimalLogDirGB")->fval);
|
||||||
|
tsNumOfLogLines = cfgGetItem(pCfg, "numOfLogLines")->i32;
|
||||||
|
tsAsyncLog = cfgGetItem(pCfg, "asyncLog")->bval;
|
||||||
|
tsLogKeepDays = cfgGetItem(pCfg, "logKeepDays")->i32;
|
||||||
|
cDebugFlag = cfgGetItem(pCfg, "cDebugFlag")->i32;
|
||||||
|
uDebugFlag = cfgGetItem(pCfg, "uDebugFlag")->i32;
|
||||||
|
rpcDebugFlag = cfgGetItem(pCfg, "rpcDebugFlag")->i32;
|
||||||
|
tmrDebugFlag = cfgGetItem(pCfg, "tmrDebugFlag")->i32;
|
||||||
|
jniDebugFlag = cfgGetItem(pCfg, "jniDebugFlag")->i32;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void taosSetServerLogCfg(SConfig *pCfg) {
|
||||||
|
dDebugFlag = cfgGetItem(pCfg, "dDebugFlag")->i32;
|
||||||
|
vDebugFlag = cfgGetItem(pCfg, "vDebugFlag")->i32;
|
||||||
|
mDebugFlag = cfgGetItem(pCfg, "mDebugFlag")->i32;
|
||||||
|
qDebugFlag = cfgGetItem(pCfg, "qDebugFlag")->i32;
|
||||||
|
wDebugFlag = cfgGetItem(pCfg, "wDebugFlag")->i32;
|
||||||
|
sDebugFlag = cfgGetItem(pCfg, "sDebugFlag")->i32;
|
||||||
|
tsdbDebugFlag = cfgGetItem(pCfg, "tsdbDebugFlag")->i32;
|
||||||
|
tqDebugFlag = cfgGetItem(pCfg, "tqDebugFlag")->i32;
|
||||||
|
fsDebugFlag = cfgGetItem(pCfg, "fsDebugFlag")->i32;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void taosSetClientCfg(SConfig *pCfg) {
|
||||||
|
tstrncpy(tsFirst, cfgGetItem(pCfg, "firstEp")->str, TSDB_EP_LEN);
|
||||||
|
tstrncpy(tsSecond, cfgGetItem(pCfg, "secondEp")->str, TSDB_EP_LEN);
|
||||||
|
tstrncpy(tsLocalFqdn, cfgGetItem(pCfg, "fqdn")->str, TSDB_EP_LEN);
|
||||||
|
tsServerPort = (uint16_t)cfgGetItem(pCfg, "serverPort")->i32;
|
||||||
|
snprintf(tsLocalEp, sizeof(tsLocalEp), "%s:%u", tsLocalFqdn, tsServerPort);
|
||||||
|
osSetTempDir(cfgGetItem(pCfg, "tempDir")->str);
|
||||||
|
osSetDataReservedSpace(cfgGetItem(pCfg, "minimalTempDirGB")->fval);
|
||||||
|
|
||||||
|
tsNumOfThreadsPerCore = cfgGetItem(pCfg, "maxTmrCtrl")->fval;
|
||||||
|
tsMaxTmrCtrl = cfgGetItem(pCfg, "maxTmrCtrl")->i32;
|
||||||
|
tsRpcTimer = cfgGetItem(pCfg, "rpcTimer")->i32;
|
||||||
|
tsRpcMaxTime = cfgGetItem(pCfg, "rpcMaxTime")->i32;
|
||||||
|
tsRpcForceTcp = cfgGetItem(pCfg, "rpcForceTcp")->i32;
|
||||||
|
tsShellActivityTimer = cfgGetItem(pCfg, "shellActivityTimer")->bval;
|
||||||
|
tsCompressMsgSize = cfgGetItem(pCfg, "compressMsgSize")->i32;
|
||||||
|
tsCompressColData = cfgGetItem(pCfg, "compressColData")->i32;
|
||||||
|
tsMaxWildCardsLen = cfgGetItem(pCfg, "maxWildCardsLength")->i32;
|
||||||
|
tsMaxRegexStringLen = cfgGetItem(pCfg, "maxRegexStringLen")->i32;
|
||||||
|
tsMaxNumOfOrderedResults = cfgGetItem(pCfg, "maxNumOfOrderedRes")->i32;
|
||||||
|
tsKeepOriginalColumnName = cfgGetItem(pCfg, "keepColumnName")->bval;
|
||||||
|
tsMaxBinaryDisplayWidth = cfgGetItem(pCfg, "maxBinaryDisplayWidth")->i32;
|
||||||
|
|
||||||
|
SConfigItem *pItem = cfgGetItem(pCfg, "timezone");
|
||||||
|
osSetTimezone(pItem->str);
|
||||||
|
uDebug("timezone format changed from %s to %s", pItem->str, osTimezone());
|
||||||
|
cfgSetItem(pCfg, "timezone", osTimezone(), pItem->stype);
|
||||||
|
|
||||||
|
const char *locale = cfgGetItem(pCfg, "locale")->str;
|
||||||
|
const char *charset = cfgGetItem(pCfg, "charset")->str;
|
||||||
|
osSetLocale(locale, charset);
|
||||||
|
|
||||||
|
if (tsNumOfCores <= 1) {
|
||||||
|
tsNumOfCores = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool enableCore = cfgGetItem(pCfg, "enableCoreFile")->bval;
|
||||||
|
taosSetCoreDump(enableCore);
|
||||||
|
|
||||||
|
// todo
|
||||||
|
tsVersion = 30000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void taosSetServerCfg(SConfig *pCfg) {
|
||||||
|
osSetDataDir(cfgGetItem(pCfg, "dataDir")->str);
|
||||||
|
osSetTempReservedSpace(cfgGetItem(pCfg, "minimalDataDirGB")->fval);
|
||||||
|
|
||||||
|
tsNumOfCommitThreads = cfgGetItem(pCfg, "numOfCommitThreads")->i32;
|
||||||
|
tsRatioOfQueryCores = cfgGetItem(pCfg, "ratioOfQueryCores")->fval;
|
||||||
|
tsMaxNumOfDistinctResults = cfgGetItem(pCfg, "maxNumOfDistinctRes")->i32;
|
||||||
|
tsEnableTelemetryReporting = cfgGetItem(pCfg, "telemetryReporting")->bval;
|
||||||
|
tsMaxConnections = cfgGetItem(pCfg, "maxConnections")->i32;
|
||||||
|
tsMaxShellConns = cfgGetItem(pCfg, "maxShellConns")->i32;
|
||||||
|
tsStatusInterval = cfgGetItem(pCfg, "statusInterval")->i32;
|
||||||
|
tsMinSlidingTime = cfgGetItem(pCfg, "minSlidingTime")->i32;
|
||||||
|
tsMinIntervalTime = cfgGetItem(pCfg, "minIntervalTime")->i32;
|
||||||
|
tsMaxStreamComputDelay = cfgGetItem(pCfg, "maxStreamCompDelay")->i32;
|
||||||
|
tsStreamCompStartDelay = cfgGetItem(pCfg, "maxFirstStreamCompDelay")->i32;
|
||||||
|
tsRetryStreamCompDelay = cfgGetItem(pCfg, "retryStreamCompDelay")->i32;
|
||||||
|
tsStreamComputDelayRatio = cfgGetItem(pCfg, "streamCompDelayRatio")->fval;
|
||||||
|
tsQueryBufferSize = cfgGetItem(pCfg, "queryBufferSize")->i32;
|
||||||
|
tsRetrieveBlockingModel = cfgGetItem(pCfg, "retrieveBlockingModel")->bval;
|
||||||
|
tsPrintAuth = cfgGetItem(pCfg, "printAuth")->bval;
|
||||||
|
tsEnableSlaveQuery = cfgGetItem(pCfg, "slaveQuery")->bval;
|
||||||
|
tsDeadLockKillQuery = cfgGetItem(pCfg, "deadLockKillQuery")->bval;
|
||||||
|
|
||||||
|
if (tsQueryBufferSize >= 0) {
|
||||||
|
tsQueryBufferSizeBytes = tsQueryBufferSize * 1048576UL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDir, const char *envFile,
|
||||||
|
const char *apolloUrl, bool tsc) {
|
||||||
osInit();
|
osInit();
|
||||||
srand(taosSafeRand());
|
|
||||||
#if 0
|
|
||||||
SGlobalCfg cfg = {0};
|
|
||||||
|
|
||||||
|
SConfig *pCfg = cfgInit();
|
||||||
|
if (pCfg == NULL) return -1;
|
||||||
|
|
||||||
cfg.option = "dataDir";
|
if (tsc) {
|
||||||
cfg.ptr = osDataDir();
|
taosAddClientLogCfg(pCfg);
|
||||||
cfg.valType = TAOS_CFG_VTYPE_DATA_DIRCTORY;
|
} else {
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
|
taosAddClientLogCfg(pCfg);
|
||||||
cfg.minValue = 0;
|
taosAddServerLogCfg(pCfg);
|
||||||
cfg.maxValue = 0;
|
}
|
||||||
cfg.ptrLength = TSDB_FILENAME_LEN;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
|
if (taosLoadCfg(pCfg, cfgDir, envFile, apolloUrl) != 0) {
|
||||||
|
uError("failed to load cfg since %s", terrstr());
|
||||||
|
cfgCleanup(pCfg);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
cfg.option = "maxNumOfDistinctRes";
|
if (tsc) {
|
||||||
cfg.ptr = &tsMaxNumOfDistinctResults;
|
taosSetClientLogCfg(pCfg);
|
||||||
cfg.valType = TAOS_CFG_VTYPE_INT32;
|
taosSetAllDebugFlag(cfgGetItem(pCfg, "debugFlag")->i32);
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT;
|
} else {
|
||||||
cfg.minValue = 10 * 10000;
|
taosSetClientLogCfg(pCfg);
|
||||||
cfg.maxValue = 10000 * 10000;
|
taosSetServerLogCfg(pCfg);
|
||||||
cfg.ptrLength = 0;
|
taosSetAllDebugFlag(cfgGetItem(pCfg, "debugFlag")->i32);
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
}
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "minSlidingTime";
|
if (taosInitLog(logname, logFileNum) != 0) {
|
||||||
cfg.ptr = &tsMinSlidingTime;
|
printf("failed to init log file since %s\n", terrstr());
|
||||||
cfg.valType = TAOS_CFG_VTYPE_INT32;
|
cfgCleanup(pCfg);
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
|
return -1;
|
||||||
cfg.minValue = 10;
|
}
|
||||||
cfg.maxValue = 1000000;
|
|
||||||
cfg.ptrLength = 0;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_MS;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "minIntervalTime";
|
cfgCleanup(pCfg);
|
||||||
cfg.ptr = &tsMinIntervalTime;
|
return 0;
|
||||||
cfg.valType = TAOS_CFG_VTYPE_INT32;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
|
|
||||||
cfg.minValue = 1;
|
|
||||||
cfg.maxValue = 1000000;
|
|
||||||
cfg.ptrLength = 0;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_MS;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "maxStreamCompDelay";
|
|
||||||
cfg.ptr = &tsMaxStreamComputDelay;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_INT32;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
|
|
||||||
cfg.minValue = 10;
|
|
||||||
cfg.maxValue = 1000000000;
|
|
||||||
cfg.ptrLength = 0;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_MS;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "maxFirstStreamCompDelay";
|
|
||||||
cfg.ptr = &tsStreamCompStartDelay;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_INT32;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
|
|
||||||
cfg.minValue = 1000;
|
|
||||||
cfg.maxValue = 1000000000;
|
|
||||||
cfg.ptrLength = 0;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_MS;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "retryStreamCompDelay";
|
|
||||||
cfg.ptr = &tsRetryStreamCompDelay;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_INT32;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
|
|
||||||
cfg.minValue = 10;
|
|
||||||
cfg.maxValue = 1000000000;
|
|
||||||
cfg.ptrLength = 0;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_MS;
|
|
||||||
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
cfg.option = "streamCompDelayRatio";
|
|
||||||
cfg.ptr = &tsStreamComputDelayRatio;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_FLOAT;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
|
|
||||||
cfg.minValue = 0.1f;
|
|
||||||
cfg.maxValue = 0.9f;
|
|
||||||
cfg.ptrLength = 0;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "compressMsgSize";
|
|
||||||
cfg.ptr = &tsCompressMsgSize;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_INT32;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT | TSDB_CFG_CTYPE_B_SHOW;
|
|
||||||
cfg.minValue = -1;
|
|
||||||
cfg.maxValue = 100000000.0f;
|
|
||||||
cfg.ptrLength = 0;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "compressColData";
|
|
||||||
cfg.ptr = &tsCompressColData;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_INT32;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT | TSDB_CFG_CTYPE_B_SHOW;
|
|
||||||
cfg.minValue = -1;
|
|
||||||
cfg.maxValue = 100000000.0f;
|
|
||||||
cfg.ptrLength = 0;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "maxWildCardsLength";
|
|
||||||
cfg.ptr = &tsMaxWildCardsLen;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_INT32;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT | TSDB_CFG_CTYPE_B_SHOW;
|
|
||||||
cfg.minValue = 0;
|
|
||||||
cfg.maxValue = TSDB_MAX_FIELD_LEN;
|
|
||||||
cfg.ptrLength = 0;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_BYTE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "maxRegexStringLen";
|
|
||||||
cfg.ptr = &tsMaxRegexStringLen;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_INT32;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT | TSDB_CFG_CTYPE_B_SHOW;
|
|
||||||
cfg.minValue = 0;
|
|
||||||
cfg.maxValue = TSDB_MAX_FIELD_LEN;
|
|
||||||
cfg.ptrLength = 0;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_BYTE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "maxNumOfOrderedRes";
|
|
||||||
cfg.ptr = &tsMaxNumOfOrderedResults;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_INT32;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT | TSDB_CFG_CTYPE_B_SHOW;
|
|
||||||
cfg.minValue = TSDB_MAX_SQL_LEN;
|
|
||||||
cfg.maxValue = TSDB_MAX_ALLOWED_SQL_LEN;
|
|
||||||
cfg.ptrLength = 0;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "queryBufferSize";
|
|
||||||
cfg.ptr = &tsQueryBufferSize;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_INT32;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
|
|
||||||
cfg.minValue = -1;
|
|
||||||
cfg.maxValue = 500000000000.0f;
|
|
||||||
cfg.ptrLength = 0;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_BYTE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "retrieveBlockingModel";
|
|
||||||
cfg.ptr = &tsRetrieveBlockingModel;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_INT32;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
|
|
||||||
cfg.minValue = 0;
|
|
||||||
cfg.maxValue = 1;
|
|
||||||
cfg.ptrLength = 1;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "keepColumnName";
|
|
||||||
cfg.ptr = &tsKeepOriginalColumnName;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_INT8;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT;
|
|
||||||
cfg.minValue = 0;
|
|
||||||
cfg.maxValue = 1;
|
|
||||||
cfg.ptrLength = 1;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cfg.option = "slaveQuery";
|
|
||||||
cfg.ptr = &tsEnableSlaveQuery;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_INT8;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
|
|
||||||
cfg.minValue = 0;
|
|
||||||
cfg.maxValue = 1;
|
|
||||||
cfg.ptrLength = 0;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
|
|
||||||
cfg.option = "maxBinaryDisplayWidth";
|
|
||||||
cfg.ptr = &tsMaxBinaryDisplayWidth;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_INT32;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT;
|
|
||||||
cfg.minValue = 1;
|
|
||||||
cfg.maxValue = 65536;
|
|
||||||
cfg.ptrLength = 0;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "tempDir";
|
|
||||||
cfg.ptr = osTempDir();
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_STRING;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT;
|
|
||||||
cfg.minValue = 0;
|
|
||||||
cfg.maxValue = 0;
|
|
||||||
cfg.ptrLength = PATH_MAX;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
// enable kill long query
|
|
||||||
cfg.option = "deadLockKillQuery";
|
|
||||||
cfg.ptr = &tsDeadLockKillQuery;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_INT8;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
|
|
||||||
cfg.minValue = 0;
|
|
||||||
cfg.maxValue = 1;
|
|
||||||
cfg.ptrLength = 1;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
#ifdef TD_TSZ
|
|
||||||
// lossy compress
|
|
||||||
cfg.option = "lossyColumns";
|
|
||||||
cfg.ptr = lossyColumns;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_STRING;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
|
|
||||||
cfg.minValue = 0;
|
|
||||||
cfg.maxValue = 0;
|
|
||||||
cfg.ptrLength = tListLen(lossyColumns);
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "fPrecision";
|
|
||||||
cfg.ptr = &fPrecision;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_DOUBLE;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
|
|
||||||
cfg.minValue = MIN_FLOAT;
|
|
||||||
cfg.maxValue = 100000;
|
|
||||||
cfg.ptrLength = 0;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "dPrecision";
|
|
||||||
cfg.ptr = &dPrecision;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_DOUBLE;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
|
|
||||||
cfg.minValue = 100000;
|
|
||||||
cfg.maxValue = 0;
|
|
||||||
cfg.ptrLength = 0;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "maxRange";
|
|
||||||
cfg.ptr = &maxRange;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_INT32;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
|
|
||||||
cfg.minValue = 0;
|
|
||||||
cfg.maxValue = 65536;
|
|
||||||
cfg.ptrLength = 0;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "range";
|
|
||||||
cfg.ptr = &curRange;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_INT32;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
|
|
||||||
cfg.minValue = 0;
|
|
||||||
cfg.maxValue = 65536;
|
|
||||||
cfg.ptrLength = 0;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
assert(tsGlobalConfigNum == TSDB_CFG_MAX_NUM);
|
|
||||||
#else
|
|
||||||
// assert(tsGlobalConfigNum == TSDB_CFG_MAX_NUM - 5);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
int32_t taosInitCfg(const char *cfgDir, const char *envFile, const char *apolloUrl, bool tsc) {
|
||||||
* alter dnode 1 balance "vnode:1-dnode:2"
|
if (tsCfg != NULL) return 0;
|
||||||
*/
|
tsCfg = cfgInit();
|
||||||
|
|
||||||
bool taosCheckBalanceCfgOptions(const char *option, int32_t *vnodeId, int32_t *dnodeId) {
|
if (tsc) {
|
||||||
int len = (int)strlen(option);
|
taosAddClientLogCfg(tsCfg);
|
||||||
if (strncasecmp(option, "vnode:", 6) != 0) {
|
taosAddClientCfg(tsCfg);
|
||||||
return false;
|
} else {
|
||||||
|
taosAddClientLogCfg(tsCfg);
|
||||||
|
taosAddServerLogCfg(tsCfg);
|
||||||
|
taosAddClientCfg(tsCfg);
|
||||||
|
taosAddServerCfg(tsCfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
int pos = 0;
|
if (taosLoadCfg(tsCfg, cfgDir, envFile, apolloUrl) != 0) {
|
||||||
for (; pos < len; ++pos) {
|
uError("failed to load cfg since %s", terrstr());
|
||||||
if (option[pos] == '-') break;
|
cfgCleanup(tsCfg);
|
||||||
|
tsCfg = NULL;
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (++pos >= len) return false;
|
if (tsc) {
|
||||||
if (strncasecmp(option + pos, "dnode:", 6) != 0) {
|
taosSetClientCfg(tsCfg);
|
||||||
return false;
|
} else {
|
||||||
|
taosSetClientCfg(tsCfg);
|
||||||
|
taosSetServerCfg(tsCfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
*vnodeId = strtol(option + 6, NULL, 10);
|
cfgDumpCfg(tsCfg, tsc, false);
|
||||||
*dnodeId = strtol(option + pos + 6, NULL, 10);
|
return 0;
|
||||||
if (*vnodeId <= 1 || *dnodeId <= 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void taosCleanupCfg() {
|
||||||
|
if (tsCfg) {
|
||||||
|
cfgCleanup(tsCfg);
|
||||||
|
tsCfg = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void taosCfgDynamicOptions(const char *option, const char *value) {
|
||||||
|
if (strcasecmp(option, "debugFlag") == 0) {
|
||||||
|
int32_t debugFlag = atoi(value);
|
||||||
|
taosSetAllDebugFlag(debugFlag);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcasecmp(option, "resetlog") == 0) {
|
||||||
|
taosResetLog();
|
||||||
|
cfgDumpCfg(tsCfg, 1, false);
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,4 +6,4 @@ target_include_directories(
|
||||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(taosd dnode config util os)
|
target_link_libraries(taosd dnode util os)
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#ifndef _TD_DMN_INT_H_
|
#ifndef _TD_DMN_INT_H_
|
||||||
#define _TD_DMN_INT_H_
|
#define _TD_DMN_INT_H_
|
||||||
|
|
||||||
#include "config.h"
|
#include "tconfig.h"
|
||||||
#include "dnode.h"
|
#include "dnode.h"
|
||||||
#include "taoserror.h"
|
#include "taoserror.h"
|
||||||
#include "tglobal.h"
|
#include "tglobal.h"
|
||||||
|
@ -28,15 +28,9 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int32_t dmnAddLogCfg(SConfig *pCfg);
|
SDnodeObjCfg dmnGetObjCfg();
|
||||||
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);
|
void dmnDumpCfg();
|
||||||
SDnodeEnvCfg dmnGetEnvCfg(SConfig *pCfg);
|
|
||||||
SDnodeObjCfg dmnGetObjCfg(SConfig *pCfg);
|
|
||||||
|
|
||||||
void dmnDumpCfg(SConfig *pCfg);
|
|
||||||
void dmnPrintVersion();
|
void dmnPrintVersion();
|
||||||
void dmnGenerateGrant();
|
void dmnGenerateGrant();
|
||||||
|
|
||||||
|
|
|
@ -15,204 +15,23 @@
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "dmnInt.h"
|
#include "dmnInt.h"
|
||||||
|
#include "tconfig.h"
|
||||||
|
|
||||||
static int32_t dmnAddEpCfg(SConfig *pCfg) {
|
SDnodeObjCfg dmnGetObjCfg() {
|
||||||
char defaultFqdn[TSDB_FQDN_LEN] = {0};
|
SConfig *pCfg = taosGetCfg();
|
||||||
if (taosGetFqdn(defaultFqdn) != 0) {
|
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (cfgAddString(pCfg, "fqdn", defaultFqdn) != 0) return -1;
|
|
||||||
|
|
||||||
int32_t defaultServerPort = 6030;
|
|
||||||
if (cfgAddInt32(pCfg, "serverPort", defaultServerPort, 1, 65056) != 0) return -1;
|
|
||||||
|
|
||||||
char defaultFirstEp[TSDB_EP_LEN] = {0};
|
|
||||||
char defaultSecondEp[TSDB_EP_LEN] = {0};
|
|
||||||
snprintf(defaultFirstEp, TSDB_EP_LEN, "%s:%d", defaultFqdn, defaultServerPort);
|
|
||||||
snprintf(defaultSecondEp, TSDB_EP_LEN, "%s:%d", defaultFqdn, defaultServerPort);
|
|
||||||
if (cfgAddString(pCfg, "firstEp", defaultFirstEp) != 0) return -1;
|
|
||||||
if (cfgAddString(pCfg, "secondEp", defaultSecondEp) != 0) return -1;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t dmnAddDirCfg(SConfig *pCfg) {
|
|
||||||
if (cfgAddDir(pCfg, "dataDir", osDataDir()) != 0) return -1;
|
|
||||||
if (cfgAddDir(pCfg, "tempDir", osTempDir()) != 0) return -1;
|
|
||||||
if (cfgAddFloat(pCfg, "minimalDataDirGB", 2.0f, 0.001f, 10000000) != 0) return -1;
|
|
||||||
if (cfgAddFloat(pCfg, "minimalTempDirGB", 1.0f, 0.001f, 10000000) != 0) return -1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t dmnCheckDirCfg(SConfig *pCfg) {
|
|
||||||
osSetDataDir(cfgGetItem(pCfg, "dataDir")->str);
|
|
||||||
osSetTempDir(cfgGetItem(pCfg, "tempDir")->str);
|
|
||||||
osSetTempReservedSpace(cfgGetItem(pCfg, "minimalDataDirGB")->fval);
|
|
||||||
osSetDataReservedSpace(cfgGetItem(pCfg, "minimalTempDirGB")->fval);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t dmnAddVersionCfg(SConfig *pCfg) {
|
|
||||||
if (cfgAddString(pCfg, "buildinfo", buildinfo) != 0) return -1;
|
|
||||||
if (cfgAddString(pCfg, "gitinfo", gitinfo) != 0) return -1;
|
|
||||||
if (cfgAddString(pCfg, "version", version) != 0) return -1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t dmnAddDnodeCfg(SConfig *pCfg) {
|
|
||||||
if (dmnAddEpCfg(pCfg) != 0) return -1;
|
|
||||||
if (dmnAddDirCfg(pCfg) != 0) return -1;
|
|
||||||
if (dmnAddVersionCfg(pCfg) != 0) return -1;
|
|
||||||
|
|
||||||
if (cfgAddTimezone(pCfg, "timezone", "") != 0) return -1;
|
|
||||||
if (cfgAddLocale(pCfg, "locale", "") != 0) return -1;
|
|
||||||
if (cfgAddCharset(pCfg, "charset", "") != 0) return -1;
|
|
||||||
if (cfgAddInt32(pCfg, "numOfCores", 2, 1, 100000) != 0) return -1;
|
|
||||||
if (cfgAddInt32(pCfg, "numOfCommitThreads", 4, 1, 1000) != 0) return -1;
|
|
||||||
if (cfgAddBool(pCfg, "telemetryReporting", 0) != 0) return -1;
|
|
||||||
if (cfgAddBool(pCfg, "enableCoreFile", 0) != 0) return -1;
|
|
||||||
if (cfgAddInt32(pCfg, "supportVnodes", 256, 0, 65536) != 0) return -1;
|
|
||||||
if (cfgAddInt32(pCfg, "statusInterval", 1, 1, 30) != 0) return -1;
|
|
||||||
if (cfgAddFloat(pCfg, "numOfThreadsPerCore", 1, 0, 10) != 0) return -1;
|
|
||||||
if (cfgAddFloat(pCfg, "ratioOfQueryCores", 1, 0, 5) != 0) return -1;
|
|
||||||
if (cfgAddInt32(pCfg, "maxShellConns", 50000, 10, 50000000) != 0) return -1;
|
|
||||||
if (cfgAddInt32(pCfg, "shellActivityTimer", 3, 1, 120) != 0) return -1;
|
|
||||||
if (cfgAddInt32(pCfg, "rpcTimer", 300, 100, 3000) != 0) return -1;
|
|
||||||
if (cfgAddInt32(pCfg, "rpcMaxTime", 600, 100, 7200) != 0) return -1;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void dmnSetDnodeCfg(SConfig *pCfg) {
|
|
||||||
SConfigItem *pItem = cfgGetItem(pCfg, "timezone");
|
|
||||||
osSetTimezone(pItem->str);
|
|
||||||
uDebug("timezone format changed from %s to %s", pItem->str, osTimezone());
|
|
||||||
cfgSetItem(pCfg, "timezone", osTimezone(), pItem->stype);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t dmnCheckCfg(SConfig *pCfg) {
|
|
||||||
bool enableCore = cfgGetItem(pCfg, "enableCoreFile")->bval;
|
|
||||||
taosSetCoreDump(enableCore);
|
|
||||||
|
|
||||||
dmnSetDnodeCfg(pCfg);
|
|
||||||
|
|
||||||
if (dmnCheckDirCfg(pCfg) != 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
taosGetSystemInfo();
|
|
||||||
|
|
||||||
|
|
||||||
if (tsNumOfCores <= 0) {
|
|
||||||
tsNumOfCores = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tsQueryBufferSize >= 0) {
|
|
||||||
tsQueryBufferSizeBytes = tsQueryBufferSize * 1048576UL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
SConfig *dmnReadCfg(const char *cfgDir, const char *envFile, const char *apolloUrl) {
|
|
||||||
SConfig *pCfg = cfgInit();
|
|
||||||
if (pCfg == NULL) return NULL;
|
|
||||||
|
|
||||||
if (dmnAddLogCfg(pCfg) != 0) {
|
|
||||||
uError("failed to add log cfg since %s", terrstr());
|
|
||||||
cfgCleanup(pCfg);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dmnAddDnodeCfg(pCfg) != 0) {
|
|
||||||
uError("failed to init dnode cfg since %s", terrstr());
|
|
||||||
cfgCleanup(pCfg);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dmnLoadCfg(pCfg, cfgDir, envFile, apolloUrl) != 0) {
|
|
||||||
uError("failed to load cfg since %s", terrstr());
|
|
||||||
cfgCleanup(pCfg);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dmnCheckCfg(pCfg) != 0) {
|
|
||||||
uError("failed to check cfg since %s", terrstr());
|
|
||||||
cfgCleanup(pCfg);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
cfgDumpCfg(pCfg);
|
|
||||||
return pCfg;
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
envCfg.rpcMaxTime = cfgGetItem(pCfg, "rpcMaxTime")->i32;
|
|
||||||
envCfg.rpcTimer = cfgGetItem(pCfg, "rpcTimer")->i32;
|
|
||||||
|
|
||||||
return envCfg;
|
|
||||||
}
|
|
||||||
|
|
||||||
SDnodeObjCfg dmnGetObjCfg(SConfig *pCfg) {
|
|
||||||
SDnodeObjCfg objCfg = {0};
|
SDnodeObjCfg objCfg = {0};
|
||||||
|
|
||||||
objCfg.numOfSupportVnodes = cfgGetItem(pCfg, "supportVnodes")->i32;
|
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;
|
|
||||||
tstrncpy(objCfg.dataDir, cfgGetItem(pCfg, "dataDir")->str, sizeof(objCfg.dataDir));
|
tstrncpy(objCfg.dataDir, cfgGetItem(pCfg, "dataDir")->str, sizeof(objCfg.dataDir));
|
||||||
|
|
||||||
tstrncpy(objCfg.firstEp, cfgGetItem(pCfg, "firstEp")->str, sizeof(objCfg.firstEp));
|
tstrncpy(objCfg.firstEp, cfgGetItem(pCfg, "firstEp")->str, sizeof(objCfg.firstEp));
|
||||||
tstrncpy(objCfg.secondEp, cfgGetItem(pCfg, "secondEp")->str, sizeof(objCfg.firstEp));
|
tstrncpy(objCfg.secondEp, cfgGetItem(pCfg, "secondEp")->str, sizeof(objCfg.firstEp));
|
||||||
objCfg.serverPort = (uint16_t)cfgGetItem(pCfg, "serverPort")->i32;
|
objCfg.serverPort = (uint16_t)cfgGetItem(pCfg, "serverPort")->i32;
|
||||||
tstrncpy(objCfg.localFqdn, cfgGetItem(pCfg, "fqdn")->str, sizeof(objCfg.localFqdn));
|
tstrncpy(objCfg.localFqdn, cfgGetItem(pCfg, "fqdn")->str, sizeof(objCfg.localFqdn));
|
||||||
snprintf(objCfg.localEp, sizeof(objCfg.localEp), "%s:%u", objCfg.localFqdn, objCfg.serverPort);
|
snprintf(objCfg.localEp, sizeof(objCfg.localEp), "%s:%u", objCfg.localFqdn, objCfg.serverPort);
|
||||||
return objCfg;
|
return objCfg;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dmnDumpCfg() {
|
||||||
|
SConfig *pCfg = taosGetCfg();
|
||||||
|
cfgDumpCfg(pCfg, 0, 1);
|
||||||
}
|
}
|
|
@ -1,132 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 dmnAddLogCfg(SConfig *pCfg) {
|
|
||||||
if (cfgAddDir(pCfg, "logDir", osLogDir()) != 0) return -1;
|
|
||||||
if (cfgAddFloat(pCfg, "minimalLogDirGB", 1.0f, 0.001f, 10000000) != 0) return -1;
|
|
||||||
if (cfgAddBool(pCfg, "asyncLog", 1) != 0) return -1;
|
|
||||||
if (cfgAddInt32(pCfg, "numOfLogLines", 10000000, 1000, 2000000000) != 0) return -1;
|
|
||||||
if (cfgAddInt32(pCfg, "logKeepDays", 0, -365000, 365000) != 0) return -1;
|
|
||||||
if (cfgAddInt32(pCfg, "debugFlag", 0, 0, 255) != 0) return -1;
|
|
||||||
if (cfgAddInt32(pCfg, "dDebugFlag", 0, 0, 255) != 0) return -1;
|
|
||||||
if (cfgAddInt32(pCfg, "vDebugFlag", 0, 0, 255) != 0) return -1;
|
|
||||||
if (cfgAddInt32(pCfg, "mDebugFlag", 0, 0, 255) != 0) return -1;
|
|
||||||
if (cfgAddInt32(pCfg, "cDebugFlag", 0, 0, 255) != 0) return -1;
|
|
||||||
if (cfgAddInt32(pCfg, "jniDebugFlag", 0, 0, 255) != 0) return -1;
|
|
||||||
if (cfgAddInt32(pCfg, "tmrDebugFlag", 0, 0, 255) != 0) return -1;
|
|
||||||
if (cfgAddInt32(pCfg, "uDebugFlag", 0, 0, 255) != 0) return -1;
|
|
||||||
if (cfgAddInt32(pCfg, "rpcDebugFlag", 0, 0, 255) != 0) return -1;
|
|
||||||
if (cfgAddInt32(pCfg, "qDebugFlag", 0, 0, 255) != 0) return -1;
|
|
||||||
if (cfgAddInt32(pCfg, "wDebugFlag", 0, 0, 255) != 0) return -1;
|
|
||||||
if (cfgAddInt32(pCfg, "sDebugFlag", 0, 0, 255) != 0) return -1;
|
|
||||||
if (cfgAddInt32(pCfg, "tsdbDebugFlag", 0, 0, 255) != 0) return -1;
|
|
||||||
if (cfgAddInt32(pCfg, "tqDebugFlag", 0, 0, 255) != 0) return -1;
|
|
||||||
if (cfgAddInt32(pCfg, "fsDebugFlag", 0, 0, 255) != 0) return -1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t dmnSetLogCfg(SConfig *pCfg) {
|
|
||||||
osSetLogDir(cfgGetItem(pCfg, "logDir")->str);
|
|
||||||
osSetLogReservedSpace(cfgGetItem(pCfg, "minimalLogDirGB")->fval);
|
|
||||||
tsAsyncLog = cfgGetItem(pCfg, "asyncLog")->bval;
|
|
||||||
tsNumOfLogLines = cfgGetItem(pCfg, "numOfLogLines")->i32;
|
|
||||||
tsLogKeepDays = cfgGetItem(pCfg, "logKeepDays")->i32;
|
|
||||||
dDebugFlag = cfgGetItem(pCfg, "dDebugFlag")->i32;
|
|
||||||
vDebugFlag = cfgGetItem(pCfg, "vDebugFlag")->i32;
|
|
||||||
mDebugFlag = cfgGetItem(pCfg, "mDebugFlag")->i32;
|
|
||||||
cDebugFlag = cfgGetItem(pCfg, "cDebugFlag")->i32;
|
|
||||||
jniDebugFlag = cfgGetItem(pCfg, "jniDebugFlag")->i32;
|
|
||||||
tmrDebugFlag = cfgGetItem(pCfg, "tmrDebugFlag")->i32;
|
|
||||||
uDebugFlag = cfgGetItem(pCfg, "uDebugFlag")->i32;
|
|
||||||
rpcDebugFlag = cfgGetItem(pCfg, "rpcDebugFlag")->i32;
|
|
||||||
qDebugFlag = cfgGetItem(pCfg, "qDebugFlag")->i32;
|
|
||||||
wDebugFlag = cfgGetItem(pCfg, "wDebugFlag")->i32;
|
|
||||||
sDebugFlag = cfgGetItem(pCfg, "sDebugFlag")->i32;
|
|
||||||
tsdbDebugFlag = cfgGetItem(pCfg, "tsdbDebugFlag")->i32;
|
|
||||||
tqDebugFlag = cfgGetItem(pCfg, "tqDebugFlag")->i32;
|
|
||||||
fsDebugFlag = cfgGetItem(pCfg, "fsDebugFlag")->i32;
|
|
||||||
|
|
||||||
int32_t debugFlag = cfgGetItem(pCfg, "debugFlag")->i32;
|
|
||||||
taosSetAllDebugFlag(debugFlag);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t dmnInitLog(const char *cfgDir, const char *envFile, const char *apolloUrl) {
|
|
||||||
SConfig *pCfg = cfgInit();
|
|
||||||
if (pCfg == NULL) return -1;
|
|
||||||
|
|
||||||
if (dmnAddLogCfg(pCfg) != 0) {
|
|
||||||
printf("failed to add log cfg since %s\n", terrstr());
|
|
||||||
cfgCleanup(pCfg);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dmnLoadCfg(pCfg, cfgDir, envFile, apolloUrl) != 0) {
|
|
||||||
printf("failed to load log cfg since %s\n", terrstr());
|
|
||||||
cfgCleanup(pCfg);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dmnSetLogCfg(pCfg) != 0) {
|
|
||||||
printf("failed to set log cfg since %s\n", terrstr());
|
|
||||||
cfgCleanup(pCfg);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (taosInitLog("taosdlog", 1) != 0) {
|
|
||||||
printf("failed to init log file since %s\n", terrstr());
|
|
||||||
cfgCleanup(pCfg);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
cfgCleanup(pCfg);
|
|
||||||
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;
|
|
||||||
}
|
|
|
@ -72,15 +72,14 @@ static int32_t dmnParseOption(int32_t argc, char const *argv[]) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t dmnRunDnode(SConfig *pCfg) {
|
int32_t dmnRunDnode() {
|
||||||
SDnodeEnvCfg envCfg = dmnGetEnvCfg(pCfg);
|
if (dndInit() != 0) {
|
||||||
if (dndInit(&envCfg) != 0) {
|
|
||||||
uInfo("Failed to start TDengine, please check the log");
|
uInfo("Failed to start TDengine, please check the log");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDnodeObjCfg objCfg = dmnGetObjCfg(pCfg);
|
SDnodeObjCfg objCfg = dmnGetObjCfg();
|
||||||
SDnode *pDnode = dndCreate(&objCfg);
|
SDnode *pDnode = dndCreate(&objCfg);
|
||||||
if (pDnode == NULL) {
|
if (pDnode == NULL) {
|
||||||
uInfo("Failed to start TDengine, please check the log");
|
uInfo("Failed to start TDengine, please check the log");
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -93,12 +92,11 @@ int32_t dmnRunDnode(SConfig *pCfg) {
|
||||||
dndClose(pDnode);
|
dndClose(pDnode);
|
||||||
dndCleanup();
|
dndCleanup();
|
||||||
taosCloseLog();
|
taosCloseLog();
|
||||||
|
taosCleanupCfg();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char const *argv[]) {
|
int main(int argc, char const *argv[]) {
|
||||||
osInit();
|
|
||||||
|
|
||||||
if (dmnParseOption(argc, argv) != 0) {
|
if (dmnParseOption(argc, argv) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -113,23 +111,21 @@ int main(int argc, char const *argv[]) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dmnInitLog(configDir, dmn.envFile, dmn.apolloUrl) != 0) {
|
if (taosCreateLog("taosdlog", 1, configDir, dmn.envFile, dmn.apolloUrl, 0) != 0) {
|
||||||
|
uInfo("Failed to start TDengine since read config error");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SConfig *pCfg = dmnReadCfg(configDir, dmn.envFile, dmn.apolloUrl);
|
if (taosInitCfg(configDir, dmn.envFile, dmn.apolloUrl, 0) != 0) {
|
||||||
if (pCfg == NULL) {
|
|
||||||
uInfo("Failed to start TDengine since read config error");
|
uInfo("Failed to start TDengine since read config error");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dmn.dumpConfig) {
|
if (dmn.dumpConfig) {
|
||||||
dmnDumpCfg(pCfg);
|
dmnDumpCfg();
|
||||||
cfgCleanup(pCfg);
|
taosCleanupCfg();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t code = dmnRunDnode(pCfg);
|
return dmnRunDnode();
|
||||||
cfgCleanup(pCfg);
|
|
||||||
return code;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,7 +124,6 @@ typedef struct {
|
||||||
typedef struct SDnode {
|
typedef struct SDnode {
|
||||||
EStat stat;
|
EStat stat;
|
||||||
SDnodeObjCfg cfg;
|
SDnodeObjCfg cfg;
|
||||||
SDnodeEnvCfg env;
|
|
||||||
SDnodeDir dir;
|
SDnodeDir dir;
|
||||||
FileFd lockFd;
|
FileFd lockFd;
|
||||||
SDnodeMgmt dmgmt;
|
SDnodeMgmt dmgmt;
|
||||||
|
@ -138,11 +137,6 @@ typedef struct SDnode {
|
||||||
SStartupReq startup;
|
SStartupReq startup;
|
||||||
} SDnode;
|
} SDnode;
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int8_t once;
|
|
||||||
SDnodeEnvCfg cfg;
|
|
||||||
} SDnodeEnv;
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -35,6 +35,7 @@ extern "C" {
|
||||||
#include "tthread.h"
|
#include "tthread.h"
|
||||||
#include "ttime.h"
|
#include "ttime.h"
|
||||||
#include "tworker.h"
|
#include "tworker.h"
|
||||||
|
#include "tglobal.h"
|
||||||
|
|
||||||
#include "dnode.h"
|
#include "dnode.h"
|
||||||
|
|
||||||
|
|
|
@ -179,7 +179,7 @@ static void dndBuildBnodeOption(SDnode *pDnode, SBnodeOpt *pOption) {
|
||||||
pOption->sendRedirectRspFp = dndSendRedirectRsp;
|
pOption->sendRedirectRspFp = dndSendRedirectRsp;
|
||||||
pOption->dnodeId = dndGetDnodeId(pDnode);
|
pOption->dnodeId = dndGetDnodeId(pDnode);
|
||||||
pOption->clusterId = dndGetClusterId(pDnode);
|
pOption->clusterId = dndGetClusterId(pDnode);
|
||||||
pOption->sver = pDnode->env.sver;
|
pOption->sver = tsVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t dndOpenBnode(SDnode *pDnode) {
|
static int32_t dndOpenBnode(SDnode *pDnode) {
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#include "tfs.h"
|
#include "tfs.h"
|
||||||
#include "wal.h"
|
#include "wal.h"
|
||||||
|
|
||||||
static SDnodeEnv dndEnv = {0};
|
static int8_t once = DND_ENV_INIT;
|
||||||
|
|
||||||
EStat dndGetStat(SDnode *pDnode) { return pDnode->stat; }
|
EStat dndGetStat(SDnode *pDnode) { return pDnode->stat; }
|
||||||
|
|
||||||
|
@ -137,7 +137,6 @@ static int32_t dndCreateImp(SDnode *pDnode, SDnodeObjCfg *pCfg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(&pDnode->cfg, pCfg, sizeof(SDnodeObjCfg));
|
memcpy(&pDnode->cfg, pCfg, sizeof(SDnodeObjCfg));
|
||||||
memcpy(&pDnode->env, &dndEnv.cfg, sizeof(SDnodeEnvCfg));
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,8 +258,8 @@ void dndClose(SDnode *pDnode) {
|
||||||
dInfo("dnode object is closed, data:%p", pDnode);
|
dInfo("dnode object is closed, data:%p", pDnode);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t dndInit(const SDnodeEnvCfg *pCfg) {
|
int32_t dndInit() {
|
||||||
if (atomic_val_compare_exchange_8(&dndEnv.once, DND_ENV_INIT, DND_ENV_READY) != DND_ENV_INIT) {
|
if (atomic_val_compare_exchange_8(&once, DND_ENV_INIT, DND_ENV_READY) != DND_ENV_INIT) {
|
||||||
terrno = TSDB_CODE_REPEAT_INIT;
|
terrno = TSDB_CODE_REPEAT_INIT;
|
||||||
dError("failed to init dnode env since %s", terrstr());
|
dError("failed to init dnode env since %s", terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -270,8 +269,7 @@ int32_t dndInit(const SDnodeEnvCfg *pCfg) {
|
||||||
taosBlockSIGPIPE();
|
taosBlockSIGPIPE();
|
||||||
taosResolveCRC();
|
taosResolveCRC();
|
||||||
|
|
||||||
SRpcCfg rpcCfg = {.rpcTimer = pCfg->rpcTimer, .rpcMaxTime = pCfg->rpcMaxTime, .sver = pCfg->sver};
|
if (rpcInit() != 0) {
|
||||||
if (rpcInit(&rpcCfg) != 0) {
|
|
||||||
dError("failed to init rpc since %s", terrstr());
|
dError("failed to init rpc since %s", terrstr());
|
||||||
dndCleanup();
|
dndCleanup();
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -284,11 +282,8 @@ int32_t dndInit(const SDnodeEnvCfg *pCfg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SVnodeOpt vnodeOpt = {
|
SVnodeOpt vnodeOpt = {
|
||||||
.sver = pCfg->sver,
|
.sver = tsVersion,
|
||||||
.timezone = pCfg->timezone,
|
.nthreads = tsNumOfCommitThreads,
|
||||||
.locale = pCfg->locale,
|
|
||||||
.charset = pCfg->charset,
|
|
||||||
.nthreads = pCfg->numOfCommitThreads,
|
|
||||||
.putReqToVQueryQFp = dndPutReqToVQueryQ,
|
.putReqToVQueryQFp = dndPutReqToVQueryQ,
|
||||||
.sendReqToDnodeFp = dndSendReqToDnode
|
.sendReqToDnodeFp = dndSendReqToDnode
|
||||||
};
|
};
|
||||||
|
@ -299,13 +294,12 @@ int32_t dndInit(const SDnodeEnvCfg *pCfg) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(&dndEnv.cfg, pCfg, sizeof(SDnodeEnvCfg));
|
|
||||||
dInfo("dnode env is initialized");
|
dInfo("dnode env is initialized");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dndCleanup() {
|
void dndCleanup() {
|
||||||
if (atomic_val_compare_exchange_8(&dndEnv.once, DND_ENV_READY, DND_ENV_CLEANUP) != DND_ENV_READY) {
|
if (atomic_val_compare_exchange_8(&once, DND_ENV_READY, DND_ENV_CLEANUP) != DND_ENV_READY) {
|
||||||
dError("dnode env is already cleaned up");
|
dError("dnode env is already cleaned up");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -296,7 +296,7 @@ PRASE_DNODE_OVER:
|
||||||
if (taosArrayGetSize(pMgmt->pDnodeEps) == 0) {
|
if (taosArrayGetSize(pMgmt->pDnodeEps) == 0) {
|
||||||
SDnodeEp dnodeEp = {0};
|
SDnodeEp dnodeEp = {0};
|
||||||
dnodeEp.isMnode = 1;
|
dnodeEp.isMnode = 1;
|
||||||
taosGetFqdnPortFromEp(pDnode->cfg.firstEp, pDnode->cfg.serverPort, &dnodeEp.ep);
|
taosGetFqdnPortFromEp(pDnode->cfg.firstEp, &dnodeEp.ep);
|
||||||
taosArrayPush(pMgmt->pDnodeEps, &dnodeEp);
|
taosArrayPush(pMgmt->pDnodeEps, &dnodeEp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -357,23 +357,23 @@ void dndSendStatusReq(SDnode *pDnode) {
|
||||||
|
|
||||||
SDnodeMgmt *pMgmt = &pDnode->dmgmt;
|
SDnodeMgmt *pMgmt = &pDnode->dmgmt;
|
||||||
taosRLockLatch(&pMgmt->latch);
|
taosRLockLatch(&pMgmt->latch);
|
||||||
req.sver = pDnode->env.sver;
|
req.sver = tsVersion;
|
||||||
req.dver = pMgmt->dver;
|
req.dver = pMgmt->dver;
|
||||||
req.dnodeId = pMgmt->dnodeId;
|
req.dnodeId = pMgmt->dnodeId;
|
||||||
req.clusterId = pMgmt->clusterId;
|
req.clusterId = pMgmt->clusterId;
|
||||||
req.rebootTime = pMgmt->rebootTime;
|
req.rebootTime = pMgmt->rebootTime;
|
||||||
req.updateTime = pMgmt->updateTime;
|
req.updateTime = pMgmt->updateTime;
|
||||||
req.numOfCores = pDnode->env.numOfCores;
|
req.numOfCores = tsNumOfCores;
|
||||||
req.numOfSupportVnodes = pDnode->cfg.numOfSupportVnodes;
|
req.numOfSupportVnodes = pDnode->cfg.numOfSupportVnodes;
|
||||||
memcpy(req.dnodeEp, pDnode->cfg.localEp, TSDB_EP_LEN);
|
memcpy(req.dnodeEp, pDnode->cfg.localEp, TSDB_EP_LEN);
|
||||||
|
|
||||||
req.clusterCfg.statusInterval = pDnode->cfg.statusInterval;
|
req.clusterCfg.statusInterval = tsStatusInterval;
|
||||||
req.clusterCfg.checkTime = 0;
|
req.clusterCfg.checkTime = 0;
|
||||||
char timestr[32] = "1970-01-01 00:00:00.00";
|
char timestr[32] = "1970-01-01 00:00:00.00";
|
||||||
(void)taosParseTime(timestr, &req.clusterCfg.checkTime, (int32_t)strlen(timestr), TSDB_TIME_PRECISION_MILLI, 0);
|
(void)taosParseTime(timestr, &req.clusterCfg.checkTime, (int32_t)strlen(timestr), TSDB_TIME_PRECISION_MILLI, 0);
|
||||||
memcpy(req.clusterCfg.timezone, pDnode->env.timezone, TD_TIMEZONE_LEN);
|
memcpy(req.clusterCfg.timezone, osTimezone(), TD_TIMEZONE_LEN);
|
||||||
memcpy(req.clusterCfg.locale, pDnode->env.locale, TD_LOCALE_LEN);
|
memcpy(req.clusterCfg.locale, osLocale(), TD_LOCALE_LEN);
|
||||||
memcpy(req.clusterCfg.charset, pDnode->env.charset, TD_LOCALE_LEN);
|
memcpy(req.clusterCfg.charset, osCharset(), TD_LOCALE_LEN);
|
||||||
taosRUnLockLatch(&pMgmt->latch);
|
taosRUnLockLatch(&pMgmt->latch);
|
||||||
|
|
||||||
req.pVloads = taosArrayInit(TSDB_MAX_VNODES, sizeof(SVnodeLoad));
|
req.pVloads = taosArrayInit(TSDB_MAX_VNODES, sizeof(SVnodeLoad));
|
||||||
|
@ -475,7 +475,7 @@ void dndProcessStartupReq(SDnode *pDnode, SRpcMsg *pReq) {
|
||||||
static void *dnodeThreadRoutine(void *param) {
|
static void *dnodeThreadRoutine(void *param) {
|
||||||
SDnode *pDnode = param;
|
SDnode *pDnode = param;
|
||||||
SDnodeMgmt *pMgmt = &pDnode->dmgmt;
|
SDnodeMgmt *pMgmt = &pDnode->dmgmt;
|
||||||
int32_t ms = pDnode->cfg.statusInterval * 1000;
|
int32_t ms = tsStatusInterval * 1000;
|
||||||
|
|
||||||
setThreadName("dnode-hb");
|
setThreadName("dnode-hb");
|
||||||
|
|
||||||
|
|
|
@ -273,15 +273,6 @@ static void dndInitMnodeOption(SDnode *pDnode, SMnodeOpt *pOption) {
|
||||||
pOption->putReqToMReadQFp = dndPutMsgToMReadQ;
|
pOption->putReqToMReadQFp = dndPutMsgToMReadQ;
|
||||||
pOption->dnodeId = dndGetDnodeId(pDnode);
|
pOption->dnodeId = dndGetDnodeId(pDnode);
|
||||||
pOption->clusterId = dndGetClusterId(pDnode);
|
pOption->clusterId = dndGetClusterId(pDnode);
|
||||||
pOption->cfg.sver = pDnode->env.sver;
|
|
||||||
pOption->cfg.enableTelem = pDnode->env.enableTelem;
|
|
||||||
pOption->cfg.statusInterval = pDnode->cfg.statusInterval;
|
|
||||||
pOption->cfg.shellActivityTimer = pDnode->cfg.shellActivityTimer;
|
|
||||||
pOption->cfg.timezone = pDnode->env.timezone;
|
|
||||||
pOption->cfg.charset = pDnode->env.charset;
|
|
||||||
pOption->cfg.locale = pDnode->env.locale;
|
|
||||||
pOption->cfg.gitinfo = pDnode->env.gitinfo;
|
|
||||||
pOption->cfg.buildinfo = pDnode->env.buildinfo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dndBuildMnodeDeployOption(SDnode *pDnode, SMnodeOpt *pOption) {
|
static void dndBuildMnodeDeployOption(SDnode *pDnode, SMnodeOpt *pOption) {
|
||||||
|
|
|
@ -185,7 +185,7 @@ static void dndBuildQnodeOption(SDnode *pDnode, SQnodeOpt *pOption) {
|
||||||
pOption->sendRedirectRspFp = dndSendRedirectRsp;
|
pOption->sendRedirectRspFp = dndSendRedirectRsp;
|
||||||
pOption->dnodeId = dndGetDnodeId(pDnode);
|
pOption->dnodeId = dndGetDnodeId(pDnode);
|
||||||
pOption->clusterId = dndGetClusterId(pDnode);
|
pOption->clusterId = dndGetClusterId(pDnode);
|
||||||
pOption->sver = pDnode->env.sver;
|
pOption->sver = tsVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t dndOpenQnode(SDnode *pDnode) {
|
static int32_t dndOpenQnode(SDnode *pDnode) {
|
||||||
|
|
|
@ -179,7 +179,7 @@ static void dndBuildSnodeOption(SDnode *pDnode, SSnodeOpt *pOption) {
|
||||||
pOption->sendRedirectRspFp = dndSendRedirectRsp;
|
pOption->sendRedirectRspFp = dndSendRedirectRsp;
|
||||||
pOption->dnodeId = dndGetDnodeId(pDnode);
|
pOption->dnodeId = dndGetDnodeId(pDnode);
|
||||||
pOption->clusterId = dndGetClusterId(pDnode);
|
pOption->clusterId = dndGetClusterId(pDnode);
|
||||||
pOption->sver = pDnode->env.sver;
|
pOption->sver = tsVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t dndOpenSnode(SDnode *pDnode) {
|
static int32_t dndOpenSnode(SDnode *pDnode) {
|
||||||
|
|
|
@ -189,7 +189,7 @@ static int32_t dndInitClient(SDnode *pDnode) {
|
||||||
rpcInit.cfp = dndProcessResponse;
|
rpcInit.cfp = dndProcessResponse;
|
||||||
rpcInit.sessions = 1024;
|
rpcInit.sessions = 1024;
|
||||||
rpcInit.connType = TAOS_CONN_CLIENT;
|
rpcInit.connType = TAOS_CONN_CLIENT;
|
||||||
rpcInit.idleTime = pDnode->cfg.shellActivityTimer * 1000;
|
rpcInit.idleTime = tsShellActivityTimer * 1000;
|
||||||
rpcInit.user = INTERNAL_USER;
|
rpcInit.user = INTERNAL_USER;
|
||||||
rpcInit.ckey = INTERNAL_CKEY;
|
rpcInit.ckey = INTERNAL_CKEY;
|
||||||
rpcInit.spi = 1;
|
rpcInit.spi = 1;
|
||||||
|
@ -344,7 +344,7 @@ static int32_t dndInitServer(SDnode *pDnode) {
|
||||||
STransMgmt *pMgmt = &pDnode->tmgmt;
|
STransMgmt *pMgmt = &pDnode->tmgmt;
|
||||||
dndInitMsgFp(pMgmt);
|
dndInitMsgFp(pMgmt);
|
||||||
|
|
||||||
int32_t numOfThreads = (int32_t)((pDnode->env.numOfCores * pDnode->cfg.numOfThreadsPerCore) / 2.0);
|
int32_t numOfThreads = (int32_t)((tsNumOfCores * tsNumOfThreadsPerCore) / 2.0);
|
||||||
if (numOfThreads < 1) {
|
if (numOfThreads < 1) {
|
||||||
numOfThreads = 1;
|
numOfThreads = 1;
|
||||||
}
|
}
|
||||||
|
@ -355,9 +355,9 @@ static int32_t dndInitServer(SDnode *pDnode) {
|
||||||
rpcInit.label = "D-S";
|
rpcInit.label = "D-S";
|
||||||
rpcInit.numOfThreads = numOfThreads;
|
rpcInit.numOfThreads = numOfThreads;
|
||||||
rpcInit.cfp = dndProcessRequest;
|
rpcInit.cfp = dndProcessRequest;
|
||||||
rpcInit.sessions = pDnode->cfg.maxShellConns;
|
rpcInit.sessions = tsMaxShellConns;
|
||||||
rpcInit.connType = TAOS_CONN_SERVER;
|
rpcInit.connType = TAOS_CONN_SERVER;
|
||||||
rpcInit.idleTime = pDnode->cfg.shellActivityTimer * 1000;
|
rpcInit.idleTime = tsShellActivityTimer * 1000;
|
||||||
rpcInit.afp = dndRetrieveUserAuthInfo;
|
rpcInit.afp = dndRetrieveUserAuthInfo;
|
||||||
rpcInit.parent = pDnode;
|
rpcInit.parent = pDnode;
|
||||||
|
|
||||||
|
|
|
@ -421,7 +421,7 @@ static int32_t dndOpenVnodes(SDnode *pDnode) {
|
||||||
|
|
||||||
pMgmt->totalVnodes = numOfVnodes;
|
pMgmt->totalVnodes = numOfVnodes;
|
||||||
|
|
||||||
int32_t threadNum = pDnode->env.numOfCores;
|
int32_t threadNum = tsNumOfCores;
|
||||||
#if 1
|
#if 1
|
||||||
threadNum = 1;
|
threadNum = 1;
|
||||||
#endif
|
#endif
|
||||||
|
@ -874,11 +874,11 @@ static int32_t dndInitVnodeWorkers(SDnode *pDnode) {
|
||||||
SVnodesMgmt *pMgmt = &pDnode->vmgmt;
|
SVnodesMgmt *pMgmt = &pDnode->vmgmt;
|
||||||
|
|
||||||
int32_t maxFetchThreads = 4;
|
int32_t maxFetchThreads = 4;
|
||||||
int32_t minFetchThreads = TMIN(maxFetchThreads, pDnode->env.numOfCores);
|
int32_t minFetchThreads = TMIN(maxFetchThreads, tsNumOfCores);
|
||||||
int32_t minQueryThreads = TMAX((int32_t)(pDnode->env.numOfCores * pDnode->cfg.ratioOfQueryCores), 1);
|
int32_t minQueryThreads = TMAX((int32_t)(tsNumOfCores * tsRatioOfQueryCores), 1);
|
||||||
int32_t maxQueryThreads = minQueryThreads;
|
int32_t maxQueryThreads = minQueryThreads;
|
||||||
int32_t maxWriteThreads = TMAX(pDnode->env.numOfCores, 1);
|
int32_t maxWriteThreads = TMAX(tsNumOfCores, 1);
|
||||||
int32_t maxSyncThreads = TMAX(pDnode->env.numOfCores / 2, 1);
|
int32_t maxSyncThreads = TMAX(tsNumOfCores / 2, 1);
|
||||||
|
|
||||||
SQWorkerPool *pQPool = &pMgmt->queryPool;
|
SQWorkerPool *pQPool = &pMgmt->queryPool;
|
||||||
pQPool->name = "vnode-query";
|
pQPool->name = "vnode-query";
|
||||||
|
|
|
@ -25,11 +25,6 @@ void* serverLoop(void* param) {
|
||||||
SDnodeObjCfg TestServer::BuildOption(const char* path, const char* fqdn, uint16_t port, const char* firstEp) {
|
SDnodeObjCfg TestServer::BuildOption(const char* path, const char* fqdn, uint16_t port, const char* firstEp) {
|
||||||
SDnodeObjCfg cfg = {0};
|
SDnodeObjCfg cfg = {0};
|
||||||
cfg.numOfSupportVnodes = 16;
|
cfg.numOfSupportVnodes = 16;
|
||||||
cfg.statusInterval = 1;
|
|
||||||
cfg.numOfThreadsPerCore = 1;
|
|
||||||
cfg.ratioOfQueryCores = 1;
|
|
||||||
cfg.maxShellConns = 1000;
|
|
||||||
cfg.shellActivityTimer = 30;
|
|
||||||
cfg.serverPort = port;
|
cfg.serverPort = port;
|
||||||
strcpy(cfg.dataDir, path);
|
strcpy(cfg.dataDir, path);
|
||||||
snprintf(cfg.localEp, TSDB_EP_LEN, "%s:%u", fqdn, port);
|
snprintf(cfg.localEp, TSDB_EP_LEN, "%s:%u", fqdn, port);
|
||||||
|
|
|
@ -40,12 +40,7 @@ void Testbase::InitLog(const char* path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Testbase::Init(const char* path, int16_t port) {
|
void Testbase::Init(const char* path, int16_t port) {
|
||||||
SDnodeEnvCfg cfg = {0};
|
dndInit();
|
||||||
cfg.numOfCommitThreads = 1;
|
|
||||||
cfg.numOfCores = 1;
|
|
||||||
cfg.rpcMaxTime = 600;
|
|
||||||
cfg.rpcTimer = 300;
|
|
||||||
dndInit(&cfg);
|
|
||||||
|
|
||||||
char fqdn[] = "localhost";
|
char fqdn[] = "localhost";
|
||||||
char firstEp[TSDB_EP_LEN] = {0};
|
char firstEp[TSDB_EP_LEN] = {0};
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
#include "tqueue.h"
|
#include "tqueue.h"
|
||||||
#include "ttime.h"
|
#include "ttime.h"
|
||||||
#include "wal.h"
|
#include "wal.h"
|
||||||
|
#include "version.h"
|
||||||
|
#include "tglobal.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -80,7 +82,6 @@ typedef struct SMnode {
|
||||||
tmr_h mqTimer;
|
tmr_h mqTimer;
|
||||||
tmr_h telemTimer;
|
tmr_h telemTimer;
|
||||||
char *path;
|
char *path;
|
||||||
SMnodeCfg cfg;
|
|
||||||
int64_t checkTime;
|
int64_t checkTime;
|
||||||
SSdb *pSdb;
|
SSdb *pSdb;
|
||||||
SDnode *pDnode;
|
SDnode *pDnode;
|
||||||
|
|
|
@ -237,7 +237,7 @@ int32_t mndGetDnodeSize(SMnode *pMnode) {
|
||||||
|
|
||||||
bool mndIsDnodeOnline(SMnode *pMnode, SDnodeObj *pDnode, int64_t curMs) {
|
bool mndIsDnodeOnline(SMnode *pMnode, SDnodeObj *pDnode, int64_t curMs) {
|
||||||
int64_t interval = TABS(pDnode->lastAccessTime - curMs);
|
int64_t interval = TABS(pDnode->lastAccessTime - curMs);
|
||||||
if (interval > 3500 * pMnode->cfg.statusInterval) {
|
if (interval > 3500 * tsStatusInterval) {
|
||||||
if (pDnode->rebootTime > 0) {
|
if (pDnode->rebootTime > 0) {
|
||||||
pDnode->offlineReason = DND_REASON_STATUS_MSG_TIMEOUT;
|
pDnode->offlineReason = DND_REASON_STATUS_MSG_TIMEOUT;
|
||||||
}
|
}
|
||||||
|
@ -272,24 +272,24 @@ static void mndGetDnodeData(SMnode *pMnode, SArray *pDnodeEps) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndCheckClusterCfgPara(SMnode *pMnode, const SClusterCfg *pCfg) {
|
static int32_t mndCheckClusterCfgPara(SMnode *pMnode, const SClusterCfg *pCfg) {
|
||||||
if (pCfg->statusInterval != pMnode->cfg.statusInterval) {
|
if (pCfg->statusInterval != tsStatusInterval) {
|
||||||
mError("statusInterval [%d - %d] cfg inconsistent", pCfg->statusInterval, pMnode->cfg.statusInterval);
|
mError("statusInterval [%d - %d] cfg inconsistent", pCfg->statusInterval, tsStatusInterval);
|
||||||
return DND_REASON_STATUS_INTERVAL_NOT_MATCH;
|
return DND_REASON_STATUS_INTERVAL_NOT_MATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((0 != strcasecmp(pCfg->timezone, pMnode->cfg.timezone)) && (pMnode->checkTime != pCfg->checkTime)) {
|
if ((0 != strcasecmp(pCfg->timezone, osTimezone())) && (pMnode->checkTime != pCfg->checkTime)) {
|
||||||
mError("timezone [%s - %s] [%" PRId64 " - %" PRId64 "] cfg inconsistent", pCfg->timezone, pMnode->cfg.timezone,
|
mError("timezone [%s - %s] [%" PRId64 " - %" PRId64 "] cfg inconsistent", pCfg->timezone, osTimezone(),
|
||||||
pCfg->checkTime, pMnode->checkTime);
|
pCfg->checkTime, pMnode->checkTime);
|
||||||
return DND_REASON_TIME_ZONE_NOT_MATCH;
|
return DND_REASON_TIME_ZONE_NOT_MATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 != strcasecmp(pCfg->locale, pMnode->cfg.locale)) {
|
if (0 != strcasecmp(pCfg->locale, osLocale())) {
|
||||||
mError("locale [%s - %s] cfg inconsistent", pCfg->locale, pMnode->cfg.locale);
|
mError("locale [%s - %s] cfg inconsistent", pCfg->locale, osLocale());
|
||||||
return DND_REASON_LOCALE_NOT_MATCH;
|
return DND_REASON_LOCALE_NOT_MATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 != strcasecmp(pCfg->charset, pMnode->cfg.charset)) {
|
if (0 != strcasecmp(pCfg->charset, osCharset())) {
|
||||||
mError("charset [%s - %s] cfg inconsistent.", pCfg->charset, pMnode->cfg.charset);
|
mError("charset [%s - %s] cfg inconsistent.", pCfg->charset, osCharset());
|
||||||
return DND_REASON_CHARSET_NOT_MATCH;
|
return DND_REASON_CHARSET_NOT_MATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -355,12 +355,11 @@ static int32_t mndProcessStatusReq(SMnodeMsg *pReq) {
|
||||||
bool needCheck = !online || dnodeChanged || reboot;
|
bool needCheck = !online || dnodeChanged || reboot;
|
||||||
|
|
||||||
if (needCheck) {
|
if (needCheck) {
|
||||||
if (statusReq.sver != pMnode->cfg.sver) {
|
if (statusReq.sver != tsVersion) {
|
||||||
if (pDnode != NULL) {
|
if (pDnode != NULL) {
|
||||||
pDnode->offlineReason = DND_REASON_VERSION_NOT_MATCH;
|
pDnode->offlineReason = DND_REASON_VERSION_NOT_MATCH;
|
||||||
}
|
}
|
||||||
mError("dnode:%d, status msg version:%d not match cluster:%d", statusReq.dnodeId, statusReq.sver,
|
mError("dnode:%d, status msg version:%d not match cluster:%d", statusReq.dnodeId, statusReq.sver, tsVersion);
|
||||||
pMnode->cfg.sver);
|
|
||||||
terrno = TSDB_CODE_MND_INVALID_MSG_VERSION;
|
terrno = TSDB_CODE_MND_INVALID_MSG_VERSION;
|
||||||
goto PROCESS_STATUS_MSG_OVER;
|
goto PROCESS_STATUS_MSG_OVER;
|
||||||
}
|
}
|
||||||
|
@ -666,19 +665,19 @@ static int32_t mndRetrieveConfigs(SMnodeMsg *pReq, SShowObj *pShow, char *data,
|
||||||
int32_t cols = 0;
|
int32_t cols = 0;
|
||||||
|
|
||||||
cfgOpts[numOfRows] = "statusInterval";
|
cfgOpts[numOfRows] = "statusInterval";
|
||||||
snprintf(cfgVals[numOfRows], TSDB_CONIIG_VALUE_LEN, "%d", pMnode->cfg.statusInterval);
|
snprintf(cfgVals[numOfRows], TSDB_CONIIG_VALUE_LEN, "%d", tsStatusInterval);
|
||||||
numOfRows++;
|
numOfRows++;
|
||||||
|
|
||||||
cfgOpts[numOfRows] = "timezone";
|
cfgOpts[numOfRows] = "timezone";
|
||||||
snprintf(cfgVals[numOfRows], TSDB_CONIIG_VALUE_LEN, "%s", pMnode->cfg.timezone);
|
snprintf(cfgVals[numOfRows], TSDB_CONIIG_VALUE_LEN, "%s", osTimezone());
|
||||||
numOfRows++;
|
numOfRows++;
|
||||||
|
|
||||||
cfgOpts[numOfRows] = "locale";
|
cfgOpts[numOfRows] = "locale";
|
||||||
snprintf(cfgVals[numOfRows], TSDB_CONIIG_VALUE_LEN, "%s", pMnode->cfg.locale);
|
snprintf(cfgVals[numOfRows], TSDB_CONIIG_VALUE_LEN, "%s", osLocale());
|
||||||
numOfRows++;
|
numOfRows++;
|
||||||
|
|
||||||
cfgOpts[numOfRows] = "charset";
|
cfgOpts[numOfRows] = "charset";
|
||||||
snprintf(cfgVals[numOfRows], TSDB_CONIIG_VALUE_LEN, "%s", pMnode->cfg.charset);
|
snprintf(cfgVals[numOfRows], TSDB_CONIIG_VALUE_LEN, "%s", osCharset());
|
||||||
numOfRows++;
|
numOfRows++;
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfRows; i++) {
|
for (int32_t i = 0; i < numOfRows; i++) {
|
||||||
|
|
|
@ -63,7 +63,7 @@ static void mndCancelGetNextQuery(SMnode *pMnode, void *pIter);
|
||||||
int32_t mndInitProfile(SMnode *pMnode) {
|
int32_t mndInitProfile(SMnode *pMnode) {
|
||||||
SProfileMgmt *pMgmt = &pMnode->profileMgmt;
|
SProfileMgmt *pMgmt = &pMnode->profileMgmt;
|
||||||
|
|
||||||
int32_t connCheckTime = pMnode->cfg.shellActivityTimer * 2;
|
int32_t connCheckTime = tsShellActivityTimer * 2;
|
||||||
pMgmt->cache = taosCacheInit(TSDB_DATA_TYPE_INT, connCheckTime, true, (__cache_free_fn_t)mndFreeConn, "conn");
|
pMgmt->cache = taosCacheInit(TSDB_DATA_TYPE_INT, connCheckTime, true, (__cache_free_fn_t)mndFreeConn, "conn");
|
||||||
if (pMgmt->cache == NULL) {
|
if (pMgmt->cache == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -117,7 +117,7 @@ static SConnObj *mndCreateConn(SMnode *pMnode, SRpcConnInfo *pInfo, int32_t pid,
|
||||||
tstrncpy(connObj.user, pInfo->user, TSDB_USER_LEN);
|
tstrncpy(connObj.user, pInfo->user, TSDB_USER_LEN);
|
||||||
tstrncpy(connObj.app, app, TSDB_APP_NAME_LEN);
|
tstrncpy(connObj.app, app, TSDB_APP_NAME_LEN);
|
||||||
|
|
||||||
int32_t keepTime = pMnode->cfg.shellActivityTimer * 3;
|
int32_t keepTime = tsShellActivityTimer * 3;
|
||||||
SConnObj *pConn = taosCachePut(pMgmt->cache, &connId, sizeof(int32_t), &connObj, sizeof(connObj), keepTime * 1000);
|
SConnObj *pConn = taosCachePut(pMgmt->cache, &connId, sizeof(int32_t), &connObj, sizeof(connObj), keepTime * 1000);
|
||||||
if (pConn == NULL) {
|
if (pConn == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -143,7 +143,7 @@ static SConnObj *mndAcquireConn(SMnode *pMnode, int32_t connId) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t keepTime = pMnode->cfg.shellActivityTimer * 3;
|
int32_t keepTime = tsShellActivityTimer * 3;
|
||||||
pConn->lastAccessTimeMs = keepTime * 1000 + (uint64_t)taosGetTimestampMs();
|
pConn->lastAccessTimeMs = keepTime * 1000 + (uint64_t)taosGetTimestampMs();
|
||||||
|
|
||||||
mTrace("conn:%d, acquired from cache, data:%p", pConn->id, pConn);
|
mTrace("conn:%d, acquired from cache, data:%p", pConn->id, pConn);
|
||||||
|
|
|
@ -64,7 +64,7 @@ static SShowObj *mndCreateShowObj(SMnode *pMnode, SShowReq *pReq) {
|
||||||
memcpy(showObj.db, pReq->db, TSDB_DB_FNAME_LEN);
|
memcpy(showObj.db, pReq->db, TSDB_DB_FNAME_LEN);
|
||||||
memcpy(showObj.payload, pReq->payload, pReq->payloadLen);
|
memcpy(showObj.payload, pReq->payload, pReq->payloadLen);
|
||||||
|
|
||||||
int32_t keepTime = pMnode->cfg.shellActivityTimer * 6 * 1000;
|
int32_t keepTime = tsShellActivityTimer * 6 * 1000;
|
||||||
SShowObj *pShow = taosCachePut(pMgmt->cache, &showId, sizeof(int64_t), &showObj, size, keepTime);
|
SShowObj *pShow = taosCachePut(pMgmt->cache, &showId, sizeof(int64_t), &showObj, size, keepTime);
|
||||||
if (pShow == NULL) {
|
if (pShow == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
|
|
@ -138,13 +138,9 @@ static void mndAddMemoryInfo(SMnode* pMnode, SBufferWriter* bw) {
|
||||||
|
|
||||||
static void mndAddVersionInfo(SMnode* pMnode, SBufferWriter* bw) {
|
static void mndAddVersionInfo(SMnode* pMnode, SBufferWriter* bw) {
|
||||||
STelemMgmt* pMgmt = &pMnode->telemMgmt;
|
STelemMgmt* pMgmt = &pMnode->telemMgmt;
|
||||||
|
mndAddStringField(bw, "version", version);
|
||||||
char vstr[32] = {0};
|
mndAddStringField(bw, "buildInfo", buildinfo);
|
||||||
taosVersionIntToStr(pMnode->cfg.sver, vstr, 32);
|
mndAddStringField(bw, "gitInfo", gitinfo);
|
||||||
|
|
||||||
mndAddStringField(bw, "version", vstr);
|
|
||||||
mndAddStringField(bw, "buildInfo", pMnode->cfg.buildinfo);
|
|
||||||
mndAddStringField(bw, "gitInfo", pMnode->cfg.gitinfo);
|
|
||||||
mndAddStringField(bw, "email", pMgmt->email);
|
mndAddStringField(bw, "email", pMgmt->email);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,7 +266,7 @@ static void mndGetEmail(SMnode* pMnode, char* filepath) {
|
||||||
|
|
||||||
int32_t mndInitTelem(SMnode* pMnode) {
|
int32_t mndInitTelem(SMnode* pMnode) {
|
||||||
STelemMgmt* pMgmt = &pMnode->telemMgmt;
|
STelemMgmt* pMgmt = &pMnode->telemMgmt;
|
||||||
pMgmt->enable = pMnode->cfg.enableTelem;
|
pMgmt->enable = tsEnableTelemetryReporting;
|
||||||
taosInitRWLatch(&pMgmt->lock);
|
taosInitRWLatch(&pMgmt->lock);
|
||||||
mndGetEmail(pMnode, "/usr/local/taos/email");
|
mndGetEmail(pMnode, "/usr/local/taos/email");
|
||||||
|
|
||||||
|
|
|
@ -290,28 +290,13 @@ static int32_t mndSetOptions(SMnode *pMnode, const SMnodeOpt *pOption) {
|
||||||
pMnode->sendReqToDnodeFp = pOption->sendReqToDnodeFp;
|
pMnode->sendReqToDnodeFp = pOption->sendReqToDnodeFp;
|
||||||
pMnode->sendReqToMnodeFp = pOption->sendReqToMnodeFp;
|
pMnode->sendReqToMnodeFp = pOption->sendReqToMnodeFp;
|
||||||
pMnode->sendRedirectRspFp = pOption->sendRedirectRspFp;
|
pMnode->sendRedirectRspFp = pOption->sendRedirectRspFp;
|
||||||
pMnode->cfg.sver = pOption->cfg.sver;
|
|
||||||
pMnode->cfg.enableTelem = pOption->cfg.enableTelem;
|
|
||||||
pMnode->cfg.statusInterval = pOption->cfg.statusInterval;
|
|
||||||
pMnode->cfg.shellActivityTimer = pOption->cfg.shellActivityTimer;
|
|
||||||
pMnode->cfg.timezone = strdup(pOption->cfg.timezone);
|
|
||||||
pMnode->cfg.locale = strdup(pOption->cfg.locale);
|
|
||||||
pMnode->cfg.charset = strdup(pOption->cfg.charset);
|
|
||||||
pMnode->cfg.gitinfo = strdup(pOption->cfg.gitinfo);
|
|
||||||
pMnode->cfg.buildinfo = strdup(pOption->cfg.buildinfo);
|
|
||||||
|
|
||||||
if (pMnode->sendReqToDnodeFp == NULL || pMnode->sendReqToMnodeFp == NULL || pMnode->sendRedirectRspFp == NULL ||
|
if (pMnode->sendReqToDnodeFp == NULL || pMnode->sendReqToMnodeFp == NULL || pMnode->sendRedirectRspFp == NULL ||
|
||||||
pMnode->putReqToMWriteQFp == NULL || pMnode->dnodeId < 0 || pMnode->clusterId < 0 ||
|
pMnode->putReqToMWriteQFp == NULL || pMnode->dnodeId < 0 || pMnode->clusterId < 0) {
|
||||||
pMnode->cfg.statusInterval < 1) {
|
|
||||||
terrno = TSDB_CODE_MND_INVALID_OPTIONS;
|
terrno = TSDB_CODE_MND_INVALID_OPTIONS;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pMnode->cfg.timezone == NULL || pMnode->cfg.locale == NULL || pMnode->cfg.charset == NULL) {
|
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -381,11 +366,6 @@ void mndClose(SMnode *pMnode) {
|
||||||
mDebug("start to close mnode");
|
mDebug("start to close mnode");
|
||||||
mndCleanupSteps(pMnode, -1);
|
mndCleanupSteps(pMnode, -1);
|
||||||
tfree(pMnode->path);
|
tfree(pMnode->path);
|
||||||
tfree(pMnode->cfg.charset);
|
|
||||||
tfree(pMnode->cfg.locale);
|
|
||||||
tfree(pMnode->cfg.timezone);
|
|
||||||
tfree(pMnode->cfg.gitinfo);
|
|
||||||
tfree(pMnode->cfg.buildinfo);
|
|
||||||
tfree(pMnode);
|
tfree(pMnode);
|
||||||
mDebug("mnode is closed");
|
mDebug("mnode is closed");
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,5 +14,4 @@ add_subdirectory(qcom)
|
||||||
add_subdirectory(qworker)
|
add_subdirectory(qworker)
|
||||||
add_subdirectory(tfs)
|
add_subdirectory(tfs)
|
||||||
add_subdirectory(nodes)
|
add_subdirectory(nodes)
|
||||||
add_subdirectory(config)
|
|
||||||
add_subdirectory(scalar)
|
add_subdirectory(scalar)
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
aux_source_directory(src CONFIG_SRC)
|
|
||||||
add_library(config STATIC ${CONFIG_SRC})
|
|
||||||
target_include_directories(
|
|
||||||
config
|
|
||||||
PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/config"
|
|
||||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
|
||||||
)
|
|
||||||
|
|
||||||
target_link_libraries(config os util common)
|
|
||||||
|
|
||||||
if(${BUILD_TEST})
|
|
||||||
ADD_SUBDIRECTORY(test)
|
|
||||||
endif(${BUILD_TEST})
|
|
|
@ -1,47 +0,0 @@
|
||||||
|
|
||||||
/*
|
|
||||||
* 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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _TD_CFG_INT_H_
|
|
||||||
#define _TD_CFG_INT_H_
|
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
#include "taoserror.h"
|
|
||||||
#include "thash.h"
|
|
||||||
#include "tutil.h"
|
|
||||||
#include "ulog.h"
|
|
||||||
#include "tglobal.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct SConfig {
|
|
||||||
ECfgSrcType stype;
|
|
||||||
SHashObj *hash;
|
|
||||||
} SConfig;
|
|
||||||
|
|
||||||
int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath);
|
|
||||||
int32_t cfgLoadFromEnvFile(SConfig *pConfig, const char *filepath);
|
|
||||||
int32_t cfgLoadFromEnvVar(SConfig *pConfig);
|
|
||||||
int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url);
|
|
||||||
|
|
||||||
int32_t cfgSetItem(SConfig *pConfig, const char *name, const char *value, ECfgSrcType stype);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /*_TD_CFG_INT_H_*/
|
|
|
@ -1,22 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 "cfgInt.h"
|
|
||||||
|
|
||||||
int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) {
|
|
||||||
uInfo("load from apoll url %s", url);
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -1,70 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 "cfgInt.h"
|
|
||||||
|
|
||||||
int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) {
|
|
||||||
char *line, *name, *value, *value2, *value3;
|
|
||||||
int olen, vlen, vlen2, vlen3;
|
|
||||||
ssize_t _bytes = 0;
|
|
||||||
size_t len = 1024;
|
|
||||||
|
|
||||||
FILE *fp = fopen(filepath, "r");
|
|
||||||
if (fp == NULL) {
|
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
line = malloc(len);
|
|
||||||
|
|
||||||
while (!feof(fp)) {
|
|
||||||
memset(line, 0, len);
|
|
||||||
|
|
||||||
name = value = value2 = value3 = NULL;
|
|
||||||
olen = vlen = vlen2 = vlen3 = 0;
|
|
||||||
|
|
||||||
_bytes = tgetline(&line, &len, fp);
|
|
||||||
if (_bytes < 0) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
line[len - 1] = 0;
|
|
||||||
|
|
||||||
paGetToken(line, &name, &olen);
|
|
||||||
if (olen == 0) continue;
|
|
||||||
name[olen] = 0;
|
|
||||||
|
|
||||||
paGetToken(name + olen + 1, &value, &vlen);
|
|
||||||
if (vlen == 0) continue;
|
|
||||||
value[vlen] = 0;
|
|
||||||
|
|
||||||
paGetToken(value + vlen + 1, &value2, &vlen2);
|
|
||||||
if (vlen2 != 0) {
|
|
||||||
value2[vlen2] = 0;
|
|
||||||
paGetToken(value2 + vlen2 + 1, &value3, &vlen3);
|
|
||||||
if (vlen3 != 0) value3[vlen3] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
cfgSetItem(pConfig, name, value, CFG_STYPE_CFG_FILE);
|
|
||||||
// taosReadConfigOption(name, value, value2, value3);
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(fp);
|
|
||||||
tfree(line);
|
|
||||||
|
|
||||||
uInfo("load from cfg file %s success", filepath);
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -1,22 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 "cfgInt.h"
|
|
||||||
|
|
||||||
int32_t cfgLoadFromEnvFile(SConfig *pConfig, const char *filepath) {
|
|
||||||
uInfo("load from env file %s", filepath);
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -1,22 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 "cfgInt.h"
|
|
||||||
|
|
||||||
int32_t cfgLoadFromEnvVar(SConfig *pConfig) {
|
|
||||||
uInfo("load from global env variables");
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
enable_testing()
|
|
||||||
|
|
||||||
aux_source_directory(. CFG_TEST_SRC)
|
|
||||||
add_executable(cfg_test ${CFG_TEST_SRC})
|
|
||||||
target_link_libraries(
|
|
||||||
cfg_test
|
|
||||||
PUBLIC config
|
|
||||||
PUBLIC gtest_main
|
|
||||||
)
|
|
||||||
|
|
||||||
add_test(
|
|
||||||
NAME cfg_test
|
|
||||||
COMMAND cfg_test
|
|
||||||
)
|
|
|
@ -133,8 +133,7 @@ do { \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
int32_t getMaximumIdleDurationSec() {
|
int32_t getMaximumIdleDurationSec() {
|
||||||
// todo
|
return tsShellActivityTimer * 2;
|
||||||
return 6; //tsShellActivityTimer * 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t getExprFunctionId(SExprInfo *pExprInfo) {
|
static int32_t getExprFunctionId(SExprInfo *pExprInfo) {
|
||||||
|
@ -5293,12 +5292,10 @@ SOperatorInfo* createExchangeOperatorInfo(const SArray* pSources, const SArray*
|
||||||
rpcInit.label = "EX";
|
rpcInit.label = "EX";
|
||||||
rpcInit.numOfThreads = 1;
|
rpcInit.numOfThreads = 1;
|
||||||
rpcInit.cfp = qProcessFetchRsp;
|
rpcInit.cfp = qProcessFetchRsp;
|
||||||
// todo
|
rpcInit.sessions = tsMaxConnections;
|
||||||
rpcInit.sessions = 50000; //tsMaxConnections;
|
|
||||||
rpcInit.connType = TAOS_CONN_CLIENT;
|
rpcInit.connType = TAOS_CONN_CLIENT;
|
||||||
rpcInit.user = (char *)"root";
|
rpcInit.user = (char *)"root";
|
||||||
// todo
|
rpcInit.idleTime = tsShellActivityTimer * 1000;
|
||||||
rpcInit.idleTime = 6; //tsShellActivityTimer * 1000;
|
|
||||||
rpcInit.ckey = "key";
|
rpcInit.ckey = "key";
|
||||||
rpcInit.spi = 1;
|
rpcInit.spi = 1;
|
||||||
rpcInit.secret = (char *)"dcc5bed04851fec854c035b2e40263b6";
|
rpcInit.secret = (char *)"dcc5bed04851fec854c035b2e40263b6";
|
||||||
|
|
|
@ -85,11 +85,10 @@ static void* pTaskQueue = NULL;
|
||||||
|
|
||||||
int32_t initTaskQueue() {
|
int32_t initTaskQueue() {
|
||||||
double factor = 4.0;
|
double factor = 4.0;
|
||||||
// todo
|
|
||||||
// int32_t numOfThreads = TMAX((int)(tsNumOfCores * tsNumOfThreadsPerCore / factor), 2);
|
|
||||||
int32_t numOfThreads = TMAX((int)(tsNumOfCores * 1.0f / factor), 2);
|
|
||||||
|
|
||||||
int32_t queueSize = 25000; //tsMaxConnections * 2;
|
int32_t numOfThreads = TMAX((int)(tsNumOfCores * tsNumOfThreadsPerCore / factor), 2);
|
||||||
|
|
||||||
|
int32_t queueSize = tsMaxConnections * 2;
|
||||||
pTaskQueue = taosInitScheduler(queueSize, numOfThreads, "tsc");
|
pTaskQueue = taosInitScheduler(queueSize, numOfThreads, "tsc");
|
||||||
if (NULL == pTaskQueue) {
|
if (NULL == pTaskQueue) {
|
||||||
qError("failed to init task queue");
|
qError("failed to init task queue");
|
||||||
|
|
|
@ -42,8 +42,6 @@ int tsRpcMaxRetry;
|
||||||
int tsRpcHeadSize;
|
int tsRpcHeadSize;
|
||||||
int tsRpcOverhead;
|
int tsRpcOverhead;
|
||||||
|
|
||||||
int32_t tsRpcForceTcp = 1; // disable this, means query, show command use udp protocol as default
|
|
||||||
|
|
||||||
SHashObj *tsFqdnHash;
|
SHashObj *tsFqdnHash;
|
||||||
|
|
||||||
#ifndef USE_UV
|
#ifndef USE_UV
|
||||||
|
@ -146,10 +144,6 @@ typedef struct SRpcConn {
|
||||||
static int tsRpcRefId = -1;
|
static int tsRpcRefId = -1;
|
||||||
static int32_t tsRpcNum = 0;
|
static int32_t tsRpcNum = 0;
|
||||||
|
|
||||||
int32_t tsRpcTimer = 300;
|
|
||||||
int32_t tsRpcMaxTime = 600; // seconds;
|
|
||||||
uint32_t tsVersion = 0;
|
|
||||||
|
|
||||||
// static pthread_once_t tsRpcInit = PTHREAD_ONCE_INIT;
|
// static pthread_once_t tsRpcInit = PTHREAD_ONCE_INIT;
|
||||||
|
|
||||||
// server:0 client:1 tcp:2 udp:0
|
// server:0 client:1 tcp:2 udp:0
|
||||||
|
@ -229,9 +223,7 @@ static void rpcInitImp(void) {
|
||||||
tsFqdnHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK);
|
tsFqdnHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t rpcInit(SRpcCfg *pCfg) {
|
int32_t rpcInit() {
|
||||||
tsRpcTimer = pCfg->rpcTimer;
|
|
||||||
tsRpcMaxTime = pCfg->rpcMaxTime;
|
|
||||||
pthread_once(&tsRpcInitOnce, rpcInitImp);
|
pthread_once(&tsRpcInitOnce, rpcInitImp);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,7 +112,7 @@ void rpcSendRedirectRsp(void* thandle, const SEpSet* pEpSet) {
|
||||||
int rpcReportProgress(void* pConn, char* pCont, int contLen) { return -1; }
|
int rpcReportProgress(void* pConn, char* pCont, int contLen) { return -1; }
|
||||||
void rpcCancelRequest(int64_t rid) { return; }
|
void rpcCancelRequest(int64_t rid) { return; }
|
||||||
|
|
||||||
int32_t rpcInit(SRpcCfg* pCfg) {
|
int32_t rpcInit() {
|
||||||
// impl later
|
// impl later
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ typedef struct SOsEnv {
|
||||||
char locale[TD_LOCALE_LEN];
|
char locale[TD_LOCALE_LEN];
|
||||||
char charset[TD_CHARSET_LEN];
|
char charset[TD_CHARSET_LEN];
|
||||||
int8_t daylight;
|
int8_t daylight;
|
||||||
|
bool enableCoreFile;
|
||||||
} SOsEnv;
|
} SOsEnv;
|
||||||
|
|
||||||
static SOsEnv env = {0};
|
static SOsEnv env = {0};
|
||||||
|
@ -73,9 +74,12 @@ void osSetLogReservedSpace(float sizeInGB) { env.logSpace.reserved = sizeInGB; }
|
||||||
void osSetTempReservedSpace(float sizeInGB) { env.tempSpace.reserved = sizeInGB; }
|
void osSetTempReservedSpace(float sizeInGB) { env.tempSpace.reserved = sizeInGB; }
|
||||||
void osSetDataReservedSpace(float sizeInGB) { env.dataSpace.reserved = sizeInGB; }
|
void osSetDataReservedSpace(float sizeInGB) { env.dataSpace.reserved = sizeInGB; }
|
||||||
void osSetTimezone(const char *timezone) { taosSetSystemTimezone(timezone, env.timezone, &env.daylight); }
|
void osSetTimezone(const char *timezone) { taosSetSystemTimezone(timezone, env.timezone, &env.daylight); }
|
||||||
|
void osSetLocale(const char *locale, const char *charset) { taosSetSystemLocale(locale, charset); }
|
||||||
|
bool osSetEnableCore(bool enable) { env.enableCoreFile = enable; }
|
||||||
|
|
||||||
void osInit() {
|
void osInit() {
|
||||||
srand(taosSafeRand());
|
srand(taosSafeRand());
|
||||||
|
taosGetSystemInfo();
|
||||||
|
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
||||||
taosWinSocketInit();
|
taosWinSocketInit();
|
||||||
|
@ -88,21 +92,27 @@ void osInit() {
|
||||||
strcpy(env.tempDir, tmpDir);
|
strcpy(env.tempDir, tmpDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(configDir, "C:\\TDengine\\cfg");
|
if (configDir[0] == 0) {
|
||||||
|
strcpy(configDir, "C:\\TDengine\\cfg");
|
||||||
|
}
|
||||||
strcpy(env.dataDir, "C:\\TDengine\\data");
|
strcpy(env.dataDir, "C:\\TDengine\\data");
|
||||||
strcpy(env.logDir, "C:\\TDengine\\log");
|
strcpy(env.logDir, "C:\\TDengine\\log");
|
||||||
strcpy(env.tempDir, "C:\\Windows\\Temp");
|
strcpy(env.tempDir, "C:\\Windows\\Temp");
|
||||||
strcpy(env.osName, "Windows");
|
strcpy(env.osName, "Windows");
|
||||||
|
|
||||||
#elif defined(_TD_DARWIN_64)
|
#elif defined(_TD_DARWIN_64)
|
||||||
strcpy(configDir, "/tmp/taosd");
|
if (configDir[0] == 0) {
|
||||||
|
strcpy(configDir, "/tmp/taosd");
|
||||||
|
}
|
||||||
strcpy(env.dataDir, "/usr/local/var/lib/taos");
|
strcpy(env.dataDir, "/usr/local/var/lib/taos");
|
||||||
strcpy(env.logDir, "/usr/local/var/log/taos");
|
strcpy(env.logDir, "/usr/local/var/log/taos");
|
||||||
strcpy(env.tempDir, "/usr/local/etc/taos");
|
strcpy(env.tempDir, "/usr/local/etc/taos");
|
||||||
strcpy(env.osName, "Darwin");
|
strcpy(env.osName, "Darwin");
|
||||||
|
|
||||||
#else
|
#else
|
||||||
strcpy(configDir, "/etc/taos");
|
if (configDir[0] == 0) {
|
||||||
|
strcpy(configDir, "/etc/taos");
|
||||||
|
}
|
||||||
strcpy(env.dataDir, "/var/lib/taos");
|
strcpy(env.dataDir, "/var/lib/taos");
|
||||||
strcpy(env.logDir, "/var/log/taos");
|
strcpy(env.logDir, "/var/log/taos");
|
||||||
strcpy(env.tempDir, "/tmp");
|
strcpy(env.tempDir, "/tmp");
|
||||||
|
|
|
@ -75,13 +75,8 @@ void taosSetSystemLocale(const char *inLocale, const char *inCharSet) {
|
||||||
char *locale = setlocale(LC_CTYPE, inLocale);
|
char *locale = setlocale(LC_CTYPE, inLocale);
|
||||||
|
|
||||||
// default locale or user specified locale is not valid, abort launch
|
// default locale or user specified locale is not valid, abort launch
|
||||||
if (inLocale == NULL) {
|
if (inLocale == NULL || strlen(inLocale) == 0) {
|
||||||
printf("Invalid locale:%s, please set the valid locale in config file\n", inLocale);
|
//printf("Invalid locale:%s, please set the valid locale in config file\n", inLocale);
|
||||||
}
|
|
||||||
|
|
||||||
if (strlen(inCharSet) == 0) {
|
|
||||||
printf("failed to get charset, please set the valid charset in config file\n");
|
|
||||||
exit(-1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!taosValidateEncodec(inCharSet)) {
|
if (!taosValidateEncodec(inCharSet)) {
|
||||||
|
|
|
@ -20,7 +20,7 @@ int32_t tsTotalMemoryMB = 0;
|
||||||
int64_t tsPageSize = 0;
|
int64_t tsPageSize = 0;
|
||||||
int64_t tsOpenMax = 0;
|
int64_t tsOpenMax = 0;
|
||||||
int64_t tsStreamMax = 0;
|
int64_t tsStreamMax = 0;
|
||||||
int32_t tsNumOfCores = 1;
|
int32_t tsNumOfCores = 2;
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -14,12 +14,25 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "cfgInt.h"
|
#include "tconfig.h"
|
||||||
#include "tep.h"
|
#include "taoserror.h"
|
||||||
#include "tmsg.h"
|
#include "thash.h"
|
||||||
|
#include "tutil.h"
|
||||||
|
#include "ulog.h"
|
||||||
|
|
||||||
#define CFG_NAME_PRINT_LEN 22
|
#define CFG_NAME_PRINT_LEN 24
|
||||||
#define CFG_SRC_PRINT_LEN 12
|
#define CFG_SRC_PRINT_LEN 12
|
||||||
|
|
||||||
|
typedef struct SConfig {
|
||||||
|
ECfgSrcType stype;
|
||||||
|
SHashObj *hash;
|
||||||
|
} SConfig;
|
||||||
|
|
||||||
|
int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath);
|
||||||
|
int32_t cfgLoadFromEnvFile(SConfig *pConfig, const char *filepath);
|
||||||
|
int32_t cfgLoadFromEnvVar(SConfig *pConfig);
|
||||||
|
int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url);
|
||||||
|
int32_t cfgSetItem(SConfig *pConfig, const char *name, const char *value, ECfgSrcType stype);
|
||||||
|
|
||||||
SConfig *cfgInit() {
|
SConfig *cfgInit() {
|
||||||
SConfig *pCfg = calloc(1, sizeof(SConfig));
|
SConfig *pCfg = calloc(1, sizeof(SConfig));
|
||||||
|
@ -131,23 +144,6 @@ static int32_t cfgCheckAndSetDir(SConfigItem *pItem, const char *inputDir) {
|
||||||
return 0;
|
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) {
|
||||||
|
@ -223,20 +219,6 @@ static int32_t cfgSetString(SConfigItem *pItem, const char *value, ECfgSrcType s
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t cfgSetIpStr(SConfigItem *pItem, const char *value, ECfgSrcType stype) {
|
|
||||||
char *tmp = strdup(value);
|
|
||||||
if (tmp == NULL || cfgCheckAndSetIpStr(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 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 || cfgCheckAndSetDir(pItem, value) != 0) {
|
if (tmp == NULL || cfgCheckAndSetDir(pItem, value) != 0) {
|
||||||
|
@ -310,8 +292,6 @@ int32_t cfgSetItem(SConfig *pCfg, const char *name, const char *value, ECfgSrcTy
|
||||||
return cfgSetFloat(pItem, value, stype);
|
return cfgSetFloat(pItem, value, stype);
|
||||||
case CFG_DTYPE_STRING:
|
case CFG_DTYPE_STRING:
|
||||||
return cfgSetString(pItem, value, stype);
|
return cfgSetString(pItem, value, stype);
|
||||||
case CFG_DTYPE_IPSTR:
|
|
||||||
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:
|
case CFG_DTYPE_TIMEZONE:
|
||||||
|
@ -366,43 +346,43 @@ static int32_t cfgAddItem(SConfig *pCfg, SConfigItem *pItem, const char *name) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t cfgAddBool(SConfig *pCfg, const char *name, bool defaultVal) {
|
int32_t cfgAddBool(SConfig *pCfg, const char *name, bool defaultVal, bool tsc) {
|
||||||
SConfigItem item = {.dtype = CFG_DTYPE_BOOL, .bval = defaultVal};
|
SConfigItem item = {.dtype = CFG_DTYPE_BOOL, .bval = defaultVal, .tsc = tsc};
|
||||||
return cfgAddItem(pCfg, &item, name);
|
return cfgAddItem(pCfg, &item, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t cfgAddInt32(SConfig *pCfg, const char *name, int32_t defaultVal, int64_t minval, int64_t maxval) {
|
int32_t cfgAddInt32(SConfig *pCfg, const char *name, int32_t defaultVal, int64_t minval, int64_t maxval, bool tsc) {
|
||||||
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, .i32 = defaultVal, .imin = minval, .imax = maxval};
|
SConfigItem item = {.dtype = CFG_DTYPE_INT32, .i32 = defaultVal, .imin = minval, .imax = maxval, .tsc = tsc};
|
||||||
return cfgAddItem(pCfg, &item, name);
|
return cfgAddItem(pCfg, &item, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t cfgAddInt64(SConfig *pCfg, const char *name, int64_t defaultVal, int64_t minval, int64_t maxval) {
|
int32_t cfgAddInt64(SConfig *pCfg, const char *name, int64_t defaultVal, int64_t minval, int64_t maxval, bool tsc) {
|
||||||
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_INT64, .i64 = defaultVal, .imin = minval, .imax = maxval};
|
SConfigItem item = {.dtype = CFG_DTYPE_INT64, .i64 = defaultVal, .imin = minval, .imax = maxval, .tsc = tsc};
|
||||||
return cfgAddItem(pCfg, &item, name);
|
return cfgAddItem(pCfg, &item, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t cfgAddFloat(SConfig *pCfg, const char *name, float defaultVal, double minval, double maxval) {
|
int32_t cfgAddFloat(SConfig *pCfg, const char *name, float defaultVal, double minval, double maxval, bool tsc) {
|
||||||
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_FLOAT, .fval = defaultVal, .fmin = minval, .fmax = maxval};
|
SConfigItem item = {.dtype = CFG_DTYPE_FLOAT, .fval = defaultVal, .fmin = minval, .fmax = maxval, .tsc = tsc};
|
||||||
return cfgAddItem(pCfg, &item, name);
|
return cfgAddItem(pCfg, &item, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t cfgAddString(SConfig *pCfg, const char *name, const char *defaultVal) {
|
int32_t cfgAddString(SConfig *pCfg, const char *name, const char *defaultVal, bool tsc) {
|
||||||
SConfigItem item = {.dtype = CFG_DTYPE_STRING};
|
SConfigItem item = {.dtype = CFG_DTYPE_STRING, .tsc = tsc};
|
||||||
item.str = strdup(defaultVal);
|
item.str = strdup(defaultVal);
|
||||||
if (item.str == NULL) {
|
if (item.str == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -411,17 +391,8 @@ int32_t cfgAddString(SConfig *pCfg, const char *name, const char *defaultVal) {
|
||||||
return cfgAddItem(pCfg, &item, name);
|
return cfgAddItem(pCfg, &item, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t cfgAddIpStr(SConfig *pCfg, const char *name, const char *defaultVal) {
|
int32_t cfgAddDir(SConfig *pCfg, const char *name, const char *defaultVal, bool tsc) {
|
||||||
SConfigItem item = {.dtype = CFG_DTYPE_IPSTR};
|
SConfigItem item = {.dtype = CFG_DTYPE_DIR, .tsc = tsc};
|
||||||
if (cfgCheckAndSetIpStr(&item, defaultVal) != 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return cfgAddItem(pCfg, &item, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t cfgAddDir(SConfig *pCfg, const char *name, const char *defaultVal) {
|
|
||||||
SConfigItem item = {.dtype = CFG_DTYPE_DIR};
|
|
||||||
if (cfgCheckAndSetDir(&item, defaultVal) != 0) {
|
if (cfgCheckAndSetDir(&item, defaultVal) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -430,7 +401,7 @@ int32_t cfgAddDir(SConfig *pCfg, const char *name, const char *defaultVal) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t cfgAddLocale(SConfig *pCfg, const char *name, const char *defaultVal) {
|
int32_t cfgAddLocale(SConfig *pCfg, const char *name, const char *defaultVal) {
|
||||||
SConfigItem item = {.dtype = CFG_DTYPE_LOCALE};
|
SConfigItem item = {.dtype = CFG_DTYPE_LOCALE, .tsc = 1};
|
||||||
if (cfgCheckAndSetLocale(&item, defaultVal) != 0) {
|
if (cfgCheckAndSetLocale(&item, defaultVal) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -439,7 +410,7 @@ int32_t cfgAddLocale(SConfig *pCfg, const char *name, const char *defaultVal) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t cfgAddCharset(SConfig *pCfg, const char *name, const char *defaultVal) {
|
int32_t cfgAddCharset(SConfig *pCfg, const char *name, const char *defaultVal) {
|
||||||
SConfigItem item = {.dtype = CFG_DTYPE_CHARSET};
|
SConfigItem item = {.dtype = CFG_DTYPE_CHARSET, .tsc = 1};
|
||||||
if (cfgCheckAndSetCharset(&item, defaultVal) != 0) {
|
if (cfgCheckAndSetCharset(&item, defaultVal) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -448,7 +419,7 @@ int32_t cfgAddCharset(SConfig *pCfg, const char *name, const char *defaultVal) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t cfgAddTimezone(SConfig *pCfg, const char *name, const char *defaultVal) {
|
int32_t cfgAddTimezone(SConfig *pCfg, const char *name, const char *defaultVal) {
|
||||||
SConfigItem item = {.dtype = CFG_DTYPE_TIMEZONE};
|
SConfigItem item = {.dtype = CFG_DTYPE_TIMEZONE, .tsc = 1};
|
||||||
if (cfgCheckAndSetTimezone(&item, defaultVal) != 0) {
|
if (cfgCheckAndSetTimezone(&item, defaultVal) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -491,8 +462,6 @@ const char *cfgDtypeStr(ECfgDataType type) {
|
||||||
return "float";
|
return "float";
|
||||||
case CFG_DTYPE_STRING:
|
case CFG_DTYPE_STRING:
|
||||||
return "string";
|
return "string";
|
||||||
case CFG_DTYPE_IPSTR:
|
|
||||||
return "ipstr";
|
|
||||||
case CFG_DTYPE_DIR:
|
case CFG_DTYPE_DIR:
|
||||||
return "dir";
|
return "dir";
|
||||||
case CFG_DTYPE_LOCALE:
|
case CFG_DTYPE_LOCALE:
|
||||||
|
@ -506,15 +475,23 @@ const char *cfgDtypeStr(ECfgDataType type) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cfgDumpCfg(SConfig *pCfg) {
|
void cfgDumpCfg(SConfig *pCfg, bool tsc, bool dump) {
|
||||||
uInfo(" global config");
|
if (dump) {
|
||||||
uInfo("=================================================================");
|
printf(" global config");
|
||||||
|
printf("\n");
|
||||||
|
printf("=================================================================");
|
||||||
|
printf("\n");
|
||||||
|
} else {
|
||||||
|
uInfo(" global config");
|
||||||
|
uInfo("=================================================================");
|
||||||
|
}
|
||||||
|
|
||||||
char src[CFG_SRC_PRINT_LEN + 1] = {0};
|
char src[CFG_SRC_PRINT_LEN + 1] = {0};
|
||||||
char name[CFG_NAME_PRINT_LEN + 1] = {0};
|
char name[CFG_NAME_PRINT_LEN + 1] = {0};
|
||||||
|
|
||||||
SConfigItem *pItem = cfgIterate(pCfg, NULL);
|
SConfigItem *pItem = cfgIterate(pCfg, NULL);
|
||||||
while (pItem != NULL) {
|
while (pItem != NULL) {
|
||||||
|
if (tsc && !pItem->tsc) continue;
|
||||||
tstrncpy(src, cfgStypeStr(pItem->stype), CFG_SRC_PRINT_LEN);
|
tstrncpy(src, cfgStypeStr(pItem->stype), CFG_SRC_PRINT_LEN);
|
||||||
for (int32_t i = 0; i < CFG_SRC_PRINT_LEN; ++i) {
|
for (int32_t i = 0; i < CFG_SRC_PRINT_LEN; ++i) {
|
||||||
if (src[i] == 0) src[i] = ' ';
|
if (src[i] == 0) src[i] = ' ';
|
||||||
|
@ -527,107 +504,126 @@ void cfgDumpCfg(SConfig *pCfg) {
|
||||||
|
|
||||||
switch (pItem->dtype) {
|
switch (pItem->dtype) {
|
||||||
case CFG_DTYPE_BOOL:
|
case CFG_DTYPE_BOOL:
|
||||||
uInfo("%s %s %u", src, name, pItem->bval);
|
if (dump) {
|
||||||
|
printf("%s %s %u", src, name, pItem->bval);
|
||||||
|
printf("\n");
|
||||||
|
} else {
|
||||||
|
uInfo("%s %s %u", src, name, pItem->bval);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case CFG_DTYPE_INT32:
|
case CFG_DTYPE_INT32:
|
||||||
uInfo("%s %s %d", src, name, pItem->i32);
|
if (dump) {
|
||||||
|
printf("%s %s %d", src, name, pItem->i32);
|
||||||
|
printf("\n");
|
||||||
|
} else {
|
||||||
|
uInfo("%s %s %d", src, name, pItem->i32);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case CFG_DTYPE_INT64:
|
case CFG_DTYPE_INT64:
|
||||||
uInfo("%s %s %" PRId64, src, name, pItem->i64);
|
if (dump) {
|
||||||
|
printf("%s %s %" PRId64, src, name, pItem->i64);
|
||||||
|
printf("\n");
|
||||||
|
} else {
|
||||||
|
uInfo("%s %s %" PRId64, src, name, pItem->i64);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case CFG_DTYPE_FLOAT:
|
case CFG_DTYPE_FLOAT:
|
||||||
uInfo("%s %s %f", src, name, pItem->fval);
|
if (dump) {
|
||||||
|
printf("%s %s %f", src, name, pItem->fval);
|
||||||
|
printf("\n");
|
||||||
|
} else {
|
||||||
|
uInfo("%s %s %f", src, name, pItem->fval);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case CFG_DTYPE_STRING:
|
case CFG_DTYPE_STRING:
|
||||||
case CFG_DTYPE_IPSTR:
|
|
||||||
case CFG_DTYPE_DIR:
|
case CFG_DTYPE_DIR:
|
||||||
case CFG_DTYPE_LOCALE:
|
case CFG_DTYPE_LOCALE:
|
||||||
case CFG_DTYPE_CHARSET:
|
case CFG_DTYPE_CHARSET:
|
||||||
case CFG_DTYPE_TIMEZONE:
|
case CFG_DTYPE_TIMEZONE:
|
||||||
uInfo("%s %s %s", src, name, pItem->str);
|
if (dump) {
|
||||||
|
printf("%s %s %s", src, name, pItem->str);
|
||||||
|
printf("\n");
|
||||||
|
} else {
|
||||||
|
uInfo("%s %s %s", src, name, pItem->str);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pItem = cfgIterate(pCfg, pItem);
|
pItem = cfgIterate(pCfg, pItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
uInfo("=================================================================");
|
if (dump) {
|
||||||
|
printf("=================================================================");
|
||||||
|
printf("\n");
|
||||||
|
} else {
|
||||||
|
uInfo("=================================================================");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#if 0
|
|
||||||
// int32_t cfgCheck(SConfig *pCfg) {
|
|
||||||
// SConfigItem *pItem = NULL;
|
|
||||||
|
|
||||||
// pItem = cfgGetItem(pCfg, "serverPort");
|
int32_t cfgLoadFromEnvVar(SConfig *pConfig) {
|
||||||
// if (pItem != NULL) {
|
uInfo("load from global env variables");
|
||||||
// tsServerPort = (uint16_t)pItem->i32;
|
return 0;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// pItem = cfgGetItem(pCfg, "firstEp");
|
int32_t cfgLoadFromEnvFile(SConfig *pConfig, const char *filepath) {
|
||||||
// if (pItem != NULL) {
|
uInfo("load from env file %s", filepath);
|
||||||
// tstrncpy(tsFirst, pItem->str, TSDB_EP_LEN);
|
return 0;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// snprintf(tsLocalEp, TSDB_EP_LEN, "%s:%u", tsLocalFqdn, tsServerPort);
|
int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) {
|
||||||
// uInfo("localEp is: %s", tsLocalEp);
|
char *line, *name, *value, *value2, *value3;
|
||||||
|
int olen, vlen, vlen2, vlen3;
|
||||||
|
ssize_t _bytes = 0;
|
||||||
|
size_t len = 1024;
|
||||||
|
|
||||||
// SEp ep = {0};
|
FILE *fp = fopen(filepath, "r");
|
||||||
// if (tsFirst[0] == 0) {
|
if (fp == NULL) {
|
||||||
// strcpy(tsFirst, tsLocalEp);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
// } else {
|
return -1;
|
||||||
// taosGetFqdnPortFromEp(tsFirst, &ep);
|
}
|
||||||
// snprintf(tsFirst, TSDB_EP_LEN, "%s:%u", ep.fqdn, ep.port);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// pItem = cfgGetItem(pCfg, "secondEp");
|
line = malloc(len);
|
||||||
// if (pItem != NULL) {
|
|
||||||
// tstrncpy(tsSecond, pItem->str, TSDB_EP_LEN);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (tsSecond[0] == 0) {
|
while (!feof(fp)) {
|
||||||
// strcpy(tsSecond, tsLocalEp);
|
memset(line, 0, len);
|
||||||
// } else {
|
|
||||||
// taosGetFqdnPortFromEp(tsSecond, &ep);
|
|
||||||
// snprintf(tsSecond, TSDB_EP_LEN, "%s:%u", ep.fqdn, ep.port);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// pItem = cfgGetItem(pCfg, "dataDir");
|
name = value = value2 = value3 = NULL;
|
||||||
// if (pItem != NULL) {
|
olen = vlen = vlen2 = vlen3 = 0;
|
||||||
// tstrncpy(osDataDir(), pItem->str, PATH_MAX);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (tsDiskCfgNum <= 0) {
|
_bytes = tgetline(&line, &len, fp);
|
||||||
// taosAddDataDir(0, osDataDir(), 0, 1);
|
if (_bytes < 0) {
|
||||||
// tsDiskCfgNum = 1;
|
break;
|
||||||
// uTrace("dataDir:%s, level:0 primary:1 is configured by default", osDataDir());
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
// if (taosDirExist(osTempDir()) != 0) {
|
line[len - 1] = 0;
|
||||||
// return -1;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// taosGetSystemInfo();
|
paGetToken(line, &name, &olen);
|
||||||
|
if (olen == 0) continue;
|
||||||
|
name[olen] = 0;
|
||||||
|
|
||||||
// tsSetLocale();
|
paGetToken(name + olen + 1, &value, &vlen);
|
||||||
|
if (vlen == 0) continue;
|
||||||
|
value[vlen] = 0;
|
||||||
|
|
||||||
// // SGlobalCfg *cfg_timezone = taosGetConfigOption("timezone");
|
paGetToken(value + vlen + 1, &value2, &vlen2);
|
||||||
// // if (cfg_timezone && cfg_timezone->cfgStatus == TAOS_CFG_CSTATUS_FILE) {
|
if (vlen2 != 0) {
|
||||||
// tsSetTimeZone();
|
value2[vlen2] = 0;
|
||||||
// // }
|
paGetToken(value2 + vlen2 + 1, &value3, &vlen3);
|
||||||
|
if (vlen3 != 0) value3[vlen3] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// pItem = cfgGetItem(pCfg, "numOfCores");
|
cfgSetItem(pConfig, name, value, CFG_STYPE_CFG_FILE);
|
||||||
// if (pItem != NULL) {
|
// taosReadConfigOption(name, value, value2, value3);
|
||||||
// tsNumOfCores = pItem->i32;
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
// if (tsNumOfCores <= 0) {
|
fclose(fp);
|
||||||
// tsNumOfCores = 1;
|
tfree(line);
|
||||||
// }
|
|
||||||
|
|
||||||
// if (tsQueryBufferSize >= 0) {
|
uInfo("load from cfg file %s success", filepath);
|
||||||
// tsQueryBufferSizeBytes = tsQueryBufferSize * 1048576UL;
|
return 0;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// cfgPrintCfg(pCfg);
|
int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) {
|
||||||
|
uInfo("load from apoll url %s", url);
|
||||||
// return 0;
|
return 0;
|
||||||
// }
|
}
|
||||||
#endif
|
|
|
@ -111,7 +111,7 @@ typedef struct time_wheel_t {
|
||||||
tmr_obj_t** slots;
|
tmr_obj_t** slots;
|
||||||
} time_wheel_t;
|
} time_wheel_t;
|
||||||
|
|
||||||
uint32_t tsMaxTmrCtrl = 512;
|
int32_t tsMaxTmrCtrl = 512;
|
||||||
|
|
||||||
static pthread_once_t tmrModuleInit = PTHREAD_ONCE_INIT;
|
static pthread_once_t tmrModuleInit = PTHREAD_ONCE_INIT;
|
||||||
static pthread_mutex_t tmrCtrlMutex;
|
static pthread_mutex_t tmrCtrlMutex;
|
||||||
|
|
|
@ -51,4 +51,12 @@ target_link_libraries(queue_test os util gtest_main)
|
||||||
add_test(
|
add_test(
|
||||||
NAME queue_test
|
NAME queue_test
|
||||||
COMMAND queue_test
|
COMMAND queue_test
|
||||||
|
)
|
||||||
|
|
||||||
|
# cfgTest
|
||||||
|
add_executable(cfgTest "cfgTest.cpp")
|
||||||
|
target_link_libraries(cfgTest os util gtest_main)
|
||||||
|
add_test(
|
||||||
|
NAME cfgTest
|
||||||
|
COMMAND cfgTest
|
||||||
)
|
)
|
|
@ -10,7 +10,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include "config.h"
|
#include "tconfig.h"
|
||||||
|
|
||||||
class CfgTest : public ::testing::Test {
|
class CfgTest : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
|
@ -43,7 +43,6 @@ TEST_F(CfgTest, 01_Str) {
|
||||||
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_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(CFG_DTYPE_DIR), "dir");
|
||||||
|
@ -55,15 +54,14 @@ 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), 0);
|
EXPECT_EQ(cfgAddBool(pConfig, "test_bool", 0, 0), 0);
|
||||||
EXPECT_EQ(cfgAddInt32(pConfig, "test_int32", 1, 0, 16), 0);
|
EXPECT_EQ(cfgAddInt32(pConfig, "test_int32", 1, 0, 16, 0), 0);
|
||||||
EXPECT_EQ(cfgAddInt64(pConfig, "test_int64", 2, 0, 16), 0);
|
EXPECT_EQ(cfgAddInt64(pConfig, "test_int64", 2, 0, 16, 0), 0);
|
||||||
EXPECT_EQ(cfgAddFloat(pConfig, "test_float", 3, 0, 16), 0);
|
EXPECT_EQ(cfgAddFloat(pConfig, "test_float", 3, 0, 16, 0), 0);
|
||||||
EXPECT_EQ(cfgAddString(pConfig, "test_string", "4"), 0);
|
EXPECT_EQ(cfgAddString(pConfig, "test_string", "4", 0), 0);
|
||||||
EXPECT_EQ(cfgAddIpStr(pConfig, "test_ipstr", "192.168.0.1"), 0);
|
EXPECT_EQ(cfgAddDir(pConfig, "test_dir", "/tmp", 0), 0);
|
||||||
EXPECT_EQ(cfgAddDir(pConfig, "test_dir", "/tmp"), 0);
|
|
||||||
|
|
||||||
EXPECT_EQ(cfgGetSize(pConfig), 7);
|
EXPECT_EQ(cfgGetSize(pConfig), 6);
|
||||||
|
|
||||||
int32_t size = 0;
|
int32_t size = 0;
|
||||||
SConfigItem *pItem = cfgIterate(pConfig, NULL);
|
SConfigItem *pItem = cfgIterate(pConfig, NULL);
|
||||||
|
@ -84,9 +82,6 @@ TEST_F(CfgTest, 02_Basic) {
|
||||||
case CFG_DTYPE_STRING:
|
case CFG_DTYPE_STRING:
|
||||||
printf("index:%d, cfg:%s value:%s\n", size, pItem->name, pItem->str);
|
printf("index:%d, cfg:%s value:%s\n", size, pItem->name, pItem->str);
|
||||||
break;
|
break;
|
||||||
case CFG_DTYPE_IPSTR:
|
|
||||||
printf("index:%d, cfg:%s value:%s\n", size, pItem->name, pItem->str);
|
|
||||||
break;
|
|
||||||
case CFG_DTYPE_DIR:
|
case CFG_DTYPE_DIR:
|
||||||
printf("index:%d, cfg:%s value:%s\n", size, pItem->name, pItem->str);
|
printf("index:%d, cfg:%s value:%s\n", size, pItem->name, pItem->str);
|
||||||
break;
|
break;
|
||||||
|
@ -99,7 +94,7 @@ TEST_F(CfgTest, 02_Basic) {
|
||||||
}
|
}
|
||||||
cfgCancelIterate(pConfig, pItem);
|
cfgCancelIterate(pConfig, pItem);
|
||||||
|
|
||||||
EXPECT_EQ(cfgGetSize(pConfig), 7);
|
EXPECT_EQ(cfgGetSize(pConfig), 6);
|
||||||
|
|
||||||
pItem = cfgGetItem(pConfig, "test_bool");
|
pItem = cfgGetItem(pConfig, "test_bool");
|
||||||
EXPECT_EQ(pItem->stype, CFG_STYPE_DEFAULT);
|
EXPECT_EQ(pItem->stype, CFG_STYPE_DEFAULT);
|
||||||
|
@ -131,12 +126,6 @@ TEST_F(CfgTest, 02_Basic) {
|
||||||
EXPECT_STREQ(pItem->name, "test_string");
|
EXPECT_STREQ(pItem->name, "test_string");
|
||||||
EXPECT_STREQ(pItem->str, "4");
|
EXPECT_STREQ(pItem->str, "4");
|
||||||
|
|
||||||
pItem = cfgGetItem(pConfig, "test_ipstr");
|
|
||||||
EXPECT_EQ(pItem->stype, CFG_STYPE_DEFAULT);
|
|
||||||
EXPECT_EQ(pItem->dtype, CFG_DTYPE_IPSTR);
|
|
||||||
EXPECT_STREQ(pItem->name, "test_ipstr");
|
|
||||||
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->dtype, CFG_DTYPE_DIR);
|
EXPECT_EQ(pItem->dtype, CFG_DTYPE_DIR);
|
Loading…
Reference in New Issue