sim config
This commit is contained in:
parent
d9bc65e5be
commit
42c100df2d
|
@ -23,7 +23,7 @@ typedef struct SBlockOrderInfo {
|
||||||
// bool hasNull;
|
// bool hasNull;
|
||||||
} SBlockOrderInfo;
|
} SBlockOrderInfo;
|
||||||
|
|
||||||
int taosGetFqdnPortFromEp(const char *ep, SEp *pEp);
|
int taosGetFqdnPortFromEp(const char *ep, uint16_t defaultPort, 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);
|
||||||
|
|
|
@ -100,13 +100,10 @@ extern uint32_t tsMaxRange;
|
||||||
extern uint32_t tsCurRange;
|
extern uint32_t tsCurRange;
|
||||||
extern char tsCompressor[];
|
extern char tsCompressor[];
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
void taosInitGlobalCfg();
|
void taosInitGlobalCfg();
|
||||||
int32_t taosCheckAndPrintCfg();
|
|
||||||
int32_t taosCfgDynamicOptions(char *msg);
|
int32_t taosCfgDynamicOptions(char *msg);
|
||||||
bool taosCheckBalanceCfgOptions(const char *option, int32_t *vnodeId, int32_t *dnodeId);
|
bool taosCheckBalanceCfgOptions(const char *option, int32_t *vnodeId, int32_t *dnodeId);
|
||||||
void taosAddDataDir(int index, char *v1, int level, int primary);
|
void taosAddDataDir(int index, char *v1, int level, int primary);
|
||||||
|
|
|
@ -21,20 +21,20 @@
|
||||||
SConfig *tscCfg;
|
SConfig *tscCfg;
|
||||||
|
|
||||||
static int32_t tscLoadCfg(SConfig *pConfig, const char *inputCfgDir, const char *envFile, const char *apolloUrl) {
|
static int32_t tscLoadCfg(SConfig *pConfig, const char *inputCfgDir, const char *envFile, const char *apolloUrl) {
|
||||||
char configDir[PATH_MAX] = {0};
|
char cfgDir[PATH_MAX] = {0};
|
||||||
char configFile[PATH_MAX + 100] = {0};
|
char cfgFile[PATH_MAX + 100] = {0};
|
||||||
|
|
||||||
taosExpandDir(inputCfgDir, configDir, PATH_MAX);
|
taosExpandDir(inputCfgDir, cfgDir, PATH_MAX);
|
||||||
snprintf(configFile, sizeof(configFile), "%s" TD_DIRSEP "taos.cfg", configDir);
|
snprintf(cfgFile, sizeof(cfgFile), "%s" TD_DIRSEP "taos.cfg", cfgDir);
|
||||||
|
|
||||||
if (cfgLoad(pConfig, CFG_STYPE_APOLLO_URL, apolloUrl) != 0) {
|
if (cfgLoad(pConfig, CFG_STYPE_APOLLO_URL, apolloUrl) != 0) {
|
||||||
uError("failed to load from apollo url:%s since %s\n", apolloUrl, terrstr());
|
uError("failed to load from apollo url:%s since %s\n", apolloUrl, terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cfgLoad(pConfig, CFG_STYPE_CFG_FILE, configFile) != 0) {
|
if (cfgLoad(pConfig, CFG_STYPE_CFG_FILE, cfgFile) != 0) {
|
||||||
if (cfgLoad(pConfig, CFG_STYPE_CFG_FILE, configDir) != 0) {
|
if (cfgLoad(pConfig, CFG_STYPE_CFG_FILE, cfgDir) != 0) {
|
||||||
uError("failed to load from config file:%s since %s\n", configFile, terrstr());
|
uError("failed to load from config file:%s since %s\n", cfgFile, terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
#include "tpagedbuf.h"
|
#include "tpagedbuf.h"
|
||||||
#include "tref.h"
|
#include "tref.h"
|
||||||
|
|
||||||
static int32_t initEpSetFromCfg(const char* firstEp, const char* secondEp, SCorEpSet* pEpSet);
|
static int32_t initEpSetFromCfg(const char* ip, uint16_t port, 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);
|
||||||
|
@ -81,21 +81,7 @@ TAOS* taos_connect_internal(const char* ip, const char* user, const char* pass,
|
||||||
}
|
}
|
||||||
|
|
||||||
SCorEpSet epSet = {0};
|
SCorEpSet epSet = {0};
|
||||||
if (ip) {
|
initEpSetFromCfg(ip, port, &epSet);
|
||||||
if (initEpSetFromCfg(ip, NULL, &epSet) < 0) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (port) {
|
|
||||||
epSet.epSet.eps[0].port = port;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
SConfigItem* pFirst = cfgGetItem(tscCfg, "firstEp");
|
|
||||||
SConfigItem* pSecond = cfgGetItem(tscCfg, "secondEp");
|
|
||||||
if (initEpSetFromCfg(pFirst->str, pSecond->str, &epSet) < 0) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
char* key = getClusterKey(user, secretEncrypt, ip, port);
|
char* key = getClusterKey(user, secretEncrypt, ip, port);
|
||||||
SAppInstInfo** pInst = NULL;
|
SAppInstInfo** pInst = NULL;
|
||||||
|
@ -284,32 +270,40 @@ _return:
|
||||||
return pRequest;
|
return pRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
int initEpSetFromCfg(const char* firstEp, const char* secondEp, SCorEpSet* pEpSet) {
|
int initEpSetFromCfg(const char* ip, uint16_t port, SCorEpSet* pEpSet) {
|
||||||
pEpSet->version = 0;
|
SConfigItem* pFirst = cfgGetItem(tscCfg, "firstEp");
|
||||||
|
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 (firstEp && firstEp[0] != 0) {
|
if (ip != NULL) {
|
||||||
if (strlen(firstEp) >= TSDB_EP_LEN) {
|
taosGetFqdnPortFromEp(ip, (uint16_t)pPort->i32, &mgmtEpSet->eps[0]);
|
||||||
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) {
|
}
|
||||||
if (strlen(secondEp) >= TSDB_EP_LEN) {
|
} else {
|
||||||
terrno = TSDB_CODE_TSC_INVALID_FQDN;
|
if (pFirst->str[0] != 0) {
|
||||||
return -1;
|
if (strlen(pFirst->str) >= TSDB_EP_LEN) {
|
||||||
|
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) {
|
||||||
|
|
|
@ -56,9 +56,7 @@ void taos_cleanup(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, uint16_t port) {
|
TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, uint16_t port) {
|
||||||
int32_t p = (port != 0) ? port : cfgGetItem(tscCfg, "serverPort")->i32;
|
tscDebug("try to connect to %s:%u, user:%s db:%s", ip, port, user, db);
|
||||||
|
|
||||||
tscDebug("try to connect to %s:%u, user:%s db:%s", ip, p, user, db);
|
|
||||||
if (user == NULL) {
|
if (user == NULL) {
|
||||||
user = TSDB_DEFAULT_USER;
|
user = TSDB_DEFAULT_USER;
|
||||||
}
|
}
|
||||||
|
@ -67,7 +65,7 @@ TAOS *taos_connect(const char *ip, const char *user, const char *pass, const cha
|
||||||
pass = TSDB_DEFAULT_PASS;
|
pass = TSDB_DEFAULT_PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
return taos_connect_internal(ip, user, pass, NULL, db, p);
|
return taos_connect_internal(ip, user, pass, NULL, db, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
void taos_close(TAOS* taos) {
|
void taos_close(TAOS* taos) {
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "tglobal.h"
|
#include "tglobal.h"
|
||||||
#include "tlockfree.h"
|
#include "tlockfree.h"
|
||||||
|
|
||||||
int taosGetFqdnPortFromEp(const char *ep, SEp* pEp) {
|
int taosGetFqdnPortFromEp(const char *ep, uint16_t defaultPort, SEp* pEp) {
|
||||||
pEp->port = 0;
|
pEp->port = 0;
|
||||||
strcpy(pEp->fqdn, ep);
|
strcpy(pEp->fqdn, ep);
|
||||||
|
|
||||||
|
@ -14,12 +14,10 @@ int taosGetFqdnPortFromEp(const char *ep, SEp* pEp) {
|
||||||
pEp->port = atoi(temp+1);
|
pEp->port = atoi(temp+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (pEp->port == 0) {
|
if (pEp->port == 0) {
|
||||||
pEp->port = tsServerPort;
|
pEp->port = defaultPort;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,8 +125,6 @@ int8_t tsDeadLockKillQuery = 0;
|
||||||
// For backward compatibility
|
// For backward compatibility
|
||||||
bool tsdbForceKeepFile = false;
|
bool tsdbForceKeepFile = false;
|
||||||
|
|
||||||
int32_t tsDiskCfgNum = 0;
|
|
||||||
|
|
||||||
#ifndef _STORAGE
|
#ifndef _STORAGE
|
||||||
SDiskCfg tsDiskCfg[1];
|
SDiskCfg tsDiskCfg[1];
|
||||||
#else
|
#else
|
||||||
|
@ -257,21 +255,21 @@ void taosAddDataDir(int index, char *v1, int level, int primary) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef _STORAGE
|
#ifndef _STORAGE
|
||||||
void taosReadDataDirCfg(char *v1, char *v2, char *v3) {
|
// void taosReadDataDirCfg(char *v1, char *v2, char *v3) {
|
||||||
if (tsDiskCfgNum == 1) {
|
// if (tsDiskCfgNum == 1) {
|
||||||
SDiskCfg *cfg = &tsDiskCfg[0];
|
// SDiskCfg *cfg = &tsDiskCfg[0];
|
||||||
uInfo("dataDir:%s, level:%d primary:%d is replaced by %s", cfg->dir, cfg->level, cfg->primary, v1);
|
// uInfo("dataDir:%s, level:%d primary:%d is replaced by %s", cfg->dir, cfg->level, cfg->primary, v1);
|
||||||
}
|
// }
|
||||||
taosAddDataDir(0, v1, 0, 1);
|
// taosAddDataDir(0, v1, 0, 1);
|
||||||
tsDiskCfgNum = 1;
|
// tsDiskCfgNum = 1;
|
||||||
}
|
// }
|
||||||
|
|
||||||
void taosPrintDataDirCfg() {
|
// void taosPrintDataDirCfg() {
|
||||||
for (int i = 0; i < tsDiskCfgNum; ++i) {
|
// for (int i = 0; i < tsDiskCfgNum; ++i) {
|
||||||
SDiskCfg *cfg = &tsDiskCfg[i];
|
// SDiskCfg *cfg = &tsDiskCfg[i];
|
||||||
uInfo(" dataDir: %s", cfg->dir);
|
// uInfo(" dataDir: %s", cfg->dir);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -47,13 +47,6 @@ static int32_t dmnAddDirCfg(SConfig *pCfg) {
|
||||||
static int32_t dmnCheckDirCfg(SConfig *pCfg) {
|
static int32_t dmnCheckDirCfg(SConfig *pCfg) {
|
||||||
SConfigItem *pItem = NULL;
|
SConfigItem *pItem = NULL;
|
||||||
|
|
||||||
pItem = cfgGetItem(pCfg, "dataDir");
|
|
||||||
if (tsDiskCfgNum <= 0) {
|
|
||||||
taosAddDataDir(0, pItem->str, 0, 1);
|
|
||||||
tsDiskCfgNum = 1;
|
|
||||||
uTrace("dataDir:%s, level:0 primary:1 is configured by default", pItem->str);
|
|
||||||
}
|
|
||||||
|
|
||||||
pItem = cfgGetItem(pCfg, "tmpDir");
|
pItem = cfgGetItem(pCfg, "tmpDir");
|
||||||
if (taosDirExist(pItem->str) != 0) {
|
if (taosDirExist(pItem->str) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -204,12 +197,12 @@ SDnodeObjCfg dmnGetObjCfg(SConfig *pCfg) {
|
||||||
objCfg.ratioOfQueryCores = cfgGetItem(pCfg, "ratioOfQueryCores")->fval;
|
objCfg.ratioOfQueryCores = cfgGetItem(pCfg, "ratioOfQueryCores")->fval;
|
||||||
objCfg.maxShellConns = cfgGetItem(pCfg, "maxShellConns")->i32;
|
objCfg.maxShellConns = cfgGetItem(pCfg, "maxShellConns")->i32;
|
||||||
objCfg.shellActivityTimer = cfgGetItem(pCfg, "shellActivityTimer")->i32;
|
objCfg.shellActivityTimer = cfgGetItem(pCfg, "shellActivityTimer")->i32;
|
||||||
objCfg.serverPort = (uint16_t)cfgGetItem(pCfg, "serverPort")->i32;
|
|
||||||
tstrncpy(objCfg.dataDir, cfgGetItem(pCfg, "dataDir")->str, sizeof(objCfg.dataDir));
|
tstrncpy(objCfg.dataDir, cfgGetItem(pCfg, "dataDir")->str, sizeof(objCfg.dataDir));
|
||||||
tstrncpy(objCfg.localEp, cfgGetItem(pCfg, "localEp")->str, sizeof(objCfg.localEp));
|
|
||||||
tstrncpy(objCfg.localFqdn, cfgGetItem(pCfg, "localFqdn")->str, sizeof(objCfg.localFqdn, cfgGetItem));
|
|
||||||
tstrncpy(objCfg.firstEp, cfgGetItem(pCfg, "firstEp")->str, sizeof(objCfg.firstEp));
|
tstrncpy(objCfg.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;
|
||||||
|
tstrncpy(objCfg.localFqdn, cfgGetItem(pCfg, "fqdn")->str, sizeof(objCfg.localFqdn, cfgGetItem));
|
||||||
|
snprintf(objCfg.localEp, sizeof(objCfg.localEp), "%s:%u", objCfg.localFqdn, objCfg.serverPort);
|
||||||
return objCfg;
|
return objCfg;
|
||||||
}
|
}
|
|
@ -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, &dnodeEp.ep);
|
taosGetFqdnPortFromEp(pDnode->cfg.firstEp, pDnode->cfg.serverPort, &dnodeEp.ep);
|
||||||
taosArrayPush(pMgmt->pDnodeEps, &dnodeEp);
|
taosArrayPush(pMgmt->pDnodeEps, &dnodeEp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,6 +71,7 @@ int8_t tscEmbeddedInUtil = 0;
|
||||||
|
|
||||||
int32_t tsLogKeepDays = 0;
|
int32_t tsLogKeepDays = 0;
|
||||||
bool tsAsyncLog = true;
|
bool tsAsyncLog = true;
|
||||||
|
bool tsLogInited = false;
|
||||||
float tsTotalLogDirGB = 0;
|
float tsTotalLogDirGB = 0;
|
||||||
float tsAvailLogDirGB = 0;
|
float tsAvailLogDirGB = 0;
|
||||||
float tsMinimalLogDirGB = 1.0f;
|
float tsMinimalLogDirGB = 1.0f;
|
||||||
|
@ -120,6 +121,8 @@ static int32_t taosStartLog() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t taosInitLog(const char *logName, int maxFiles) {
|
int32_t taosInitLog(const char *logName, int maxFiles) {
|
||||||
|
if (tsLogInited) return 0;
|
||||||
|
|
||||||
char fullName[PATH_MAX] = {0};
|
char fullName[PATH_MAX] = {0};
|
||||||
snprintf(fullName, PATH_MAX, "%s" TD_DIRSEP "%s", tsLogDir, logName);
|
snprintf(fullName, PATH_MAX, "%s" TD_DIRSEP "%s", tsLogDir, logName);
|
||||||
|
|
||||||
|
@ -127,6 +130,7 @@ int32_t taosInitLog(const char *logName, int maxFiles) {
|
||||||
if (tsLogObj.logHandle == NULL) return -1;
|
if (tsLogObj.logHandle == NULL) return -1;
|
||||||
if (taosOpenLogFile(fullName, tsNumOfLogLines, maxFiles) < 0) return -1;
|
if (taosOpenLogFile(fullName, tsNumOfLogLines, maxFiles) < 0) return -1;
|
||||||
if (taosStartLog() < 0) return -1;
|
if (taosStartLog() < 0) return -1;
|
||||||
|
tsLogInited = true;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue