os env
This commit is contained in:
parent
1383e53d4f
commit
612dd71918
|
@ -22,33 +22,31 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct SOsEnv SOsEnv;
|
extern char tsOsName[];
|
||||||
|
extern char tsTimezone[];
|
||||||
|
extern char tsCharset[];
|
||||||
|
extern char tsLocale[];
|
||||||
|
extern int8_t tsDaylight;
|
||||||
|
extern bool tsEnableCoreFile;
|
||||||
|
extern int64_t tsPageSize;
|
||||||
|
extern int64_t tsOpenMax;
|
||||||
|
extern int64_t tsStreamMax;
|
||||||
|
extern int32_t tsNumOfCores;
|
||||||
|
extern int32_t tsTotalMemoryMB;
|
||||||
|
|
||||||
extern char configDir[];
|
extern char configDir[];
|
||||||
|
extern char tsDataDir[];
|
||||||
|
extern char tsLogDir[];
|
||||||
|
extern char tsTempDir[];
|
||||||
|
|
||||||
|
extern SDiskSpace tsDataSpace;
|
||||||
|
extern SDiskSpace tsLogSpace;
|
||||||
|
extern SDiskSpace tsTempSpace;
|
||||||
|
|
||||||
void osInit();
|
void osInit();
|
||||||
void osUpdate();
|
void osUpdate();
|
||||||
|
|
||||||
bool osLogSpaceAvailable();
|
bool osLogSpaceAvailable();
|
||||||
int8_t osDaylight();
|
|
||||||
|
|
||||||
const char *osLogDir();
|
|
||||||
const char *osTempDir();
|
|
||||||
const char *osDataDir();
|
|
||||||
const char *osName();
|
|
||||||
const char *osTimezone();
|
|
||||||
const char *osLocale();
|
|
||||||
const char *osCharset();
|
|
||||||
|
|
||||||
void osSetLogDir(const char *logDir);
|
|
||||||
void osSetTempDir(const char *tempDir);
|
|
||||||
void osSetDataDir(const char *dataDir);
|
|
||||||
void osSetLogReservedSpace(float sizeInGB);
|
|
||||||
void osSetTempReservedSpace(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
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,14 +37,6 @@ typedef struct SDiskSpace {
|
||||||
SDiskSize size;
|
SDiskSize size;
|
||||||
} SDiskSpace;
|
} SDiskSpace;
|
||||||
|
|
||||||
extern int64_t tsPageSize;
|
|
||||||
extern int64_t tsOpenMax;
|
|
||||||
extern int64_t tsStreamMax;
|
|
||||||
extern int32_t tsNumOfCores;
|
|
||||||
extern int32_t tsTotalMemoryMB;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int32_t taosGetDiskSize(char *dataDir, SDiskSize *diskSize);
|
int32_t taosGetDiskSize(char *dataDir, SDiskSize *diskSize);
|
||||||
int32_t taosGetCpuCores();
|
int32_t taosGetCpuCores();
|
||||||
void taosGetSystemInfo();
|
void taosGetSystemInfo();
|
||||||
|
|
|
@ -207,7 +207,7 @@ static int32_t taosLoadCfg(SConfig *pCfg, const char *inputCfgDir, const char *e
|
||||||
}
|
}
|
||||||
|
|
||||||
static void taosAddClientLogCfg(SConfig *pCfg) {
|
static void taosAddClientLogCfg(SConfig *pCfg) {
|
||||||
cfgAddDir(pCfg, "logDir", osLogDir(), 1);
|
cfgAddDir(pCfg, "logDir", tsLogDir, 1);
|
||||||
cfgAddFloat(pCfg, "minimalLogDirGB", 1.0f, 0.001f, 10000000, 1);
|
cfgAddFloat(pCfg, "minimalLogDirGB", 1.0f, 0.001f, 10000000, 1);
|
||||||
cfgAddInt32(pCfg, "numOfLogLines", tsNumOfLogLines, 1000, 2000000000, 1);
|
cfgAddInt32(pCfg, "numOfLogLines", tsNumOfLogLines, 1000, 2000000000, 1);
|
||||||
cfgAddBool(pCfg, "asyncLog", tsAsyncLog, 1);
|
cfgAddBool(pCfg, "asyncLog", tsAsyncLog, 1);
|
||||||
|
@ -248,7 +248,7 @@ static void taosAddClientCfg(SConfig *pCfg) {
|
||||||
cfgAddString(pCfg, "secondEp", defaultSecondEp, 1);
|
cfgAddString(pCfg, "secondEp", defaultSecondEp, 1);
|
||||||
cfgAddString(pCfg, "fqdn", defaultFqdn, 1);
|
cfgAddString(pCfg, "fqdn", defaultFqdn, 1);
|
||||||
cfgAddInt32(pCfg, "serverPort", defaultServerPort, 1, 65056, 1);
|
cfgAddInt32(pCfg, "serverPort", defaultServerPort, 1, 65056, 1);
|
||||||
cfgAddDir(pCfg, "tempDir", osTempDir(), 1);
|
cfgAddDir(pCfg, "tempDir", tsTempDir, 1);
|
||||||
cfgAddFloat(pCfg, "minimalTempDirGB", 1.0f, 0.001f, 10000000, 1);
|
cfgAddFloat(pCfg, "minimalTempDirGB", 1.0f, 0.001f, 10000000, 1);
|
||||||
cfgAddFloat(pCfg, "numOfThreadsPerCore", tsNumOfThreadsPerCore, 0, 10, 1);
|
cfgAddFloat(pCfg, "numOfThreadsPerCore", tsNumOfThreadsPerCore, 0, 10, 1);
|
||||||
cfgAddInt32(pCfg, "maxTmrCtrl", tsMaxTmrCtrl, 8, 2048, 1);
|
cfgAddInt32(pCfg, "maxTmrCtrl", tsMaxTmrCtrl, 8, 2048, 1);
|
||||||
|
@ -263,11 +263,12 @@ static void taosAddClientCfg(SConfig *pCfg) {
|
||||||
cfgAddInt32(pCfg, "maxNumOfOrderedRes", tsMaxNumOfOrderedResults, 128, TSDB_MAX_ALLOWED_SQL_LEN, 1);
|
cfgAddInt32(pCfg, "maxNumOfOrderedRes", tsMaxNumOfOrderedResults, 128, TSDB_MAX_ALLOWED_SQL_LEN, 1);
|
||||||
cfgAddBool(pCfg, "keepColumnName", tsKeepOriginalColumnName, 1);
|
cfgAddBool(pCfg, "keepColumnName", tsKeepOriginalColumnName, 1);
|
||||||
cfgAddInt32(pCfg, "maxBinaryDisplayWidth", tsMaxBinaryDisplayWidth, 1, 65536, 1);
|
cfgAddInt32(pCfg, "maxBinaryDisplayWidth", tsMaxBinaryDisplayWidth, 1, 65536, 1);
|
||||||
cfgAddTimezone(pCfg, "timezone", osTimezone());
|
cfgAddTimezone(pCfg, "timezone", tsTimezone);
|
||||||
cfgAddLocale(pCfg, "locale", osLocale());
|
cfgAddLocale(pCfg, "locale", tsLocale);
|
||||||
cfgAddCharset(pCfg, "charset", osCharset());
|
cfgAddCharset(pCfg, "charset", tsCharset);
|
||||||
cfgAddBool(pCfg, "enableCoreFile", 0, 1);
|
cfgAddBool(pCfg, "enableCoreFile", 0, 1);
|
||||||
cfgAddInt32(pCfg, "numOfCores", tsNumOfCores, 1, 100000, 1);
|
cfgAddInt32(pCfg, "numOfCores", tsNumOfCores, 1, 100000, 1);
|
||||||
|
|
||||||
cfgAddString(pCfg, "version", version, 1);
|
cfgAddString(pCfg, "version", version, 1);
|
||||||
cfgAddString(pCfg, "compatible_version", compatible_version, 1);
|
cfgAddString(pCfg, "compatible_version", compatible_version, 1);
|
||||||
cfgAddString(pCfg, "gitinfo", gitinfo, 1);
|
cfgAddString(pCfg, "gitinfo", gitinfo, 1);
|
||||||
|
@ -277,7 +278,7 @@ static void taosAddClientCfg(SConfig *pCfg) {
|
||||||
|
|
||||||
static void taosAddServerCfg(SConfig *pCfg) {
|
static void taosAddServerCfg(SConfig *pCfg) {
|
||||||
cfgAddInt32(pCfg, "supportVnodes", 256, 0, 65536, 0);
|
cfgAddInt32(pCfg, "supportVnodes", 256, 0, 65536, 0);
|
||||||
cfgAddDir(pCfg, "dataDir", osDataDir(), 0);
|
cfgAddDir(pCfg, "dataDir", tsDataDir, 0);
|
||||||
cfgAddFloat(pCfg, "minimalDataDirGB", 2.0f, 0.001f, 10000000, 0);
|
cfgAddFloat(pCfg, "minimalDataDirGB", 2.0f, 0.001f, 10000000, 0);
|
||||||
cfgAddInt32(pCfg, "numOfCommitThreads", tsNumOfCommitThreads, 1, 100, 0);
|
cfgAddInt32(pCfg, "numOfCommitThreads", tsNumOfCommitThreads, 1, 100, 0);
|
||||||
cfgAddFloat(pCfg, "ratioOfQueryCores", tsRatioOfQueryCores, 0, 2, 0);
|
cfgAddFloat(pCfg, "ratioOfQueryCores", tsRatioOfQueryCores, 0, 2, 0);
|
||||||
|
@ -301,8 +302,8 @@ static void taosAddServerCfg(SConfig *pCfg) {
|
||||||
|
|
||||||
static void taosSetClientLogCfg(SConfig *pCfg) {
|
static void taosSetClientLogCfg(SConfig *pCfg) {
|
||||||
SConfigItem *pItem = cfgGetItem(pCfg, "logDir");
|
SConfigItem *pItem = cfgGetItem(pCfg, "logDir");
|
||||||
osSetLogDir(cfgGetItem(pCfg, "logDir")->str);
|
tstrncpy(tsLogDir, cfgGetItem(pCfg, "logDir")->str, PATH_MAX);
|
||||||
osSetDataReservedSpace(cfgGetItem(pCfg, "minimalLogDirGB")->fval);
|
tsLogSpace.reserved = cfgGetItem(pCfg, "minimalLogDirGB")->fval;
|
||||||
tsNumOfLogLines = cfgGetItem(pCfg, "numOfLogLines")->i32;
|
tsNumOfLogLines = cfgGetItem(pCfg, "numOfLogLines")->i32;
|
||||||
tsAsyncLog = cfgGetItem(pCfg, "asyncLog")->bval;
|
tsAsyncLog = cfgGetItem(pCfg, "asyncLog")->bval;
|
||||||
tsLogKeepDays = cfgGetItem(pCfg, "logKeepDays")->i32;
|
tsLogKeepDays = cfgGetItem(pCfg, "logKeepDays")->i32;
|
||||||
|
@ -331,8 +332,8 @@ static void taosSetClientCfg(SConfig *pCfg) {
|
||||||
tstrncpy(tsLocalFqdn, cfgGetItem(pCfg, "fqdn")->str, TSDB_EP_LEN);
|
tstrncpy(tsLocalFqdn, cfgGetItem(pCfg, "fqdn")->str, TSDB_EP_LEN);
|
||||||
tsServerPort = (uint16_t)cfgGetItem(pCfg, "serverPort")->i32;
|
tsServerPort = (uint16_t)cfgGetItem(pCfg, "serverPort")->i32;
|
||||||
snprintf(tsLocalEp, sizeof(tsLocalEp), "%s:%u", tsLocalFqdn, tsServerPort);
|
snprintf(tsLocalEp, sizeof(tsLocalEp), "%s:%u", tsLocalFqdn, tsServerPort);
|
||||||
osSetTempDir(cfgGetItem(pCfg, "tempDir")->str);
|
tstrncpy(tsLogDir, cfgGetItem(pCfg, "tempDir")->str, PATH_MAX);
|
||||||
osSetDataReservedSpace(cfgGetItem(pCfg, "minimalTempDirGB")->fval);
|
tsTempSpace.reserved = cfgGetItem(pCfg, "minimalTempDirGB")->fval;
|
||||||
|
|
||||||
tsNumOfThreadsPerCore = cfgGetItem(pCfg, "maxTmrCtrl")->fval;
|
tsNumOfThreadsPerCore = cfgGetItem(pCfg, "maxTmrCtrl")->fval;
|
||||||
tsMaxTmrCtrl = cfgGetItem(pCfg, "maxTmrCtrl")->i32;
|
tsMaxTmrCtrl = cfgGetItem(pCfg, "maxTmrCtrl")->i32;
|
||||||
|
@ -350,28 +351,27 @@ static void taosSetClientCfg(SConfig *pCfg) {
|
||||||
|
|
||||||
SConfigItem *pItem = cfgGetItem(pCfg, "timezone");
|
SConfigItem *pItem = cfgGetItem(pCfg, "timezone");
|
||||||
osSetTimezone(pItem->str);
|
osSetTimezone(pItem->str);
|
||||||
uDebug("timezone format changed from %s to %s", pItem->str, osTimezone());
|
uDebug("timezone format changed from %s to %s", pItem->str, tsTimezone);
|
||||||
cfgSetItem(pCfg, "timezone", osTimezone(), pItem->stype);
|
cfgSetItem(pCfg, "timezone", tsTimezone, pItem->stype);
|
||||||
|
|
||||||
const char *locale = cfgGetItem(pCfg, "locale")->str;
|
const char *locale = cfgGetItem(pCfg, "locale")->str;
|
||||||
const char *charset = cfgGetItem(pCfg, "charset")->str;
|
const char *charset = cfgGetItem(pCfg, "charset")->str;
|
||||||
osSetLocale(locale, charset);
|
taosSetSystemLocale(locale, charset);
|
||||||
|
|
||||||
if (tsNumOfCores <= 1) {
|
if (tsNumOfCores <= 1) {
|
||||||
tsNumOfCores = 2;
|
tsNumOfCores = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool enableCore = cfgGetItem(pCfg, "enableCoreFile")->bval;
|
bool enableCore = cfgGetItem(pCfg, "enableCoreFile")->bval;
|
||||||
taosSetCoreDump(enableCore);
|
taosSetConsoleEcho(enableCore);
|
||||||
|
|
||||||
// todo
|
// todo
|
||||||
tsVersion = 30000000;
|
tsVersion = 30000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void taosSetServerCfg(SConfig *pCfg) {
|
static void taosSetServerCfg(SConfig *pCfg) {
|
||||||
osSetDataDir(cfgGetItem(pCfg, "dataDir")->str);
|
tstrncpy(tsDataDir, cfgGetItem(pCfg, "dataDir")->str, PATH_MAX);
|
||||||
osSetTempReservedSpace(cfgGetItem(pCfg, "minimalDataDirGB")->fval);
|
tsTempSpace.reserved = cfgGetItem(pCfg, "minimalDataDirGB")->fval;
|
||||||
|
|
||||||
tsNumOfCommitThreads = cfgGetItem(pCfg, "numOfCommitThreads")->i32;
|
tsNumOfCommitThreads = cfgGetItem(pCfg, "numOfCommitThreads")->i32;
|
||||||
tsRatioOfQueryCores = cfgGetItem(pCfg, "ratioOfQueryCores")->fval;
|
tsRatioOfQueryCores = cfgGetItem(pCfg, "ratioOfQueryCores")->fval;
|
||||||
tsMaxNumOfDistinctResults = cfgGetItem(pCfg, "maxNumOfDistinctRes")->i32;
|
tsMaxNumOfDistinctResults = cfgGetItem(pCfg, "maxNumOfDistinctRes")->i32;
|
||||||
|
|
|
@ -23,7 +23,7 @@ STSBuf* tsBufCreate(bool autoDelete, int32_t order) {
|
||||||
|
|
||||||
pTSBuf->autoDelete = autoDelete;
|
pTSBuf->autoDelete = autoDelete;
|
||||||
|
|
||||||
taosGetTmpfilePath(osTempDir(), "join", pTSBuf->path);
|
taosGetTmpfilePath(tsTempDir, "join", pTSBuf->path);
|
||||||
pTSBuf->f = fopen(pTSBuf->path, "wb+");
|
pTSBuf->f = fopen(pTSBuf->path, "wb+");
|
||||||
if (pTSBuf->f == NULL) {
|
if (pTSBuf->f == NULL) {
|
||||||
free(pTSBuf);
|
free(pTSBuf);
|
||||||
|
|
|
@ -371,9 +371,9 @@ void dndSendStatusReq(SDnode *pDnode) {
|
||||||
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, osTimezone(), TD_TIMEZONE_LEN);
|
memcpy(req.clusterCfg.timezone, tsTimezone, TD_TIMEZONE_LEN);
|
||||||
memcpy(req.clusterCfg.locale, osLocale(), TD_LOCALE_LEN);
|
memcpy(req.clusterCfg.locale, tsLocale, TD_LOCALE_LEN);
|
||||||
memcpy(req.clusterCfg.charset, osCharset(), TD_LOCALE_LEN);
|
memcpy(req.clusterCfg.charset, tsCharset, 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));
|
||||||
|
|
|
@ -33,7 +33,7 @@ void Testbase::InitLog(const char* path) {
|
||||||
|
|
||||||
taosRemoveDir(path);
|
taosRemoveDir(path);
|
||||||
taosMkDir(path);
|
taosMkDir(path);
|
||||||
osSetLogDir(path);
|
tstrncpy(tsLogDir, path, PATH_MAX);
|
||||||
if (taosInitLog("taosdlog", 1) != 0) {
|
if (taosInitLog("taosdlog", 1) != 0) {
|
||||||
printf("failed to init log file\n");
|
printf("failed to init log file\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -277,19 +277,19 @@ static int32_t mndCheckClusterCfgPara(SMnode *pMnode, const SClusterCfg *pCfg) {
|
||||||
return DND_REASON_STATUS_INTERVAL_NOT_MATCH;
|
return DND_REASON_STATUS_INTERVAL_NOT_MATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((0 != strcasecmp(pCfg->timezone, osTimezone())) && (pMnode->checkTime != pCfg->checkTime)) {
|
if ((0 != strcasecmp(pCfg->timezone, tsTimezone)) && (pMnode->checkTime != pCfg->checkTime)) {
|
||||||
mError("timezone [%s - %s] [%" PRId64 " - %" PRId64 "] cfg inconsistent", pCfg->timezone, osTimezone(),
|
mError("timezone [%s - %s] [%" PRId64 " - %" PRId64 "] cfg inconsistent", pCfg->timezone, tsTimezone,
|
||||||
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, osLocale())) {
|
if (0 != strcasecmp(pCfg->locale, tsLocale)) {
|
||||||
mError("locale [%s - %s] cfg inconsistent", pCfg->locale, osLocale());
|
mError("locale [%s - %s] cfg inconsistent", pCfg->locale, tsLocale);
|
||||||
return DND_REASON_LOCALE_NOT_MATCH;
|
return DND_REASON_LOCALE_NOT_MATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 != strcasecmp(pCfg->charset, osCharset())) {
|
if (0 != strcasecmp(pCfg->charset, tsCharset)) {
|
||||||
mError("charset [%s - %s] cfg inconsistent.", pCfg->charset, osCharset());
|
mError("charset [%s - %s] cfg inconsistent.", pCfg->charset, tsCharset);
|
||||||
return DND_REASON_CHARSET_NOT_MATCH;
|
return DND_REASON_CHARSET_NOT_MATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -669,15 +669,15 @@ static int32_t mndRetrieveConfigs(SMnodeMsg *pReq, SShowObj *pShow, char *data,
|
||||||
numOfRows++;
|
numOfRows++;
|
||||||
|
|
||||||
cfgOpts[numOfRows] = "timezone";
|
cfgOpts[numOfRows] = "timezone";
|
||||||
snprintf(cfgVals[numOfRows], TSDB_CONIIG_VALUE_LEN, "%s", osTimezone());
|
snprintf(cfgVals[numOfRows], TSDB_CONIIG_VALUE_LEN, "%s", tsTimezone);
|
||||||
numOfRows++;
|
numOfRows++;
|
||||||
|
|
||||||
cfgOpts[numOfRows] = "locale";
|
cfgOpts[numOfRows] = "locale";
|
||||||
snprintf(cfgVals[numOfRows], TSDB_CONIIG_VALUE_LEN, "%s", osLocale());
|
snprintf(cfgVals[numOfRows], TSDB_CONIIG_VALUE_LEN, "%s", tsLocale);
|
||||||
numOfRows++;
|
numOfRows++;
|
||||||
|
|
||||||
cfgOpts[numOfRows] = "charset";
|
cfgOpts[numOfRows] = "charset";
|
||||||
snprintf(cfgVals[numOfRows], TSDB_CONIIG_VALUE_LEN, "%s", osCharset());
|
snprintf(cfgVals[numOfRows], TSDB_CONIIG_VALUE_LEN, "%s", tsCharset);
|
||||||
numOfRows++;
|
numOfRows++;
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfRows; i++) {
|
for (int32_t i = 0; i < numOfRows; i++) {
|
||||||
|
|
|
@ -132,7 +132,7 @@ void ctgTestInitLogFile() {
|
||||||
ctgDbgEnableDebug("api");
|
ctgDbgEnableDebug("api");
|
||||||
|
|
||||||
if (taosInitLog(defaultLogFileNamePrefix, maxLogFileNum) < 0) {
|
if (taosInitLog(defaultLogFileNamePrefix, maxLogFileNum) < 0) {
|
||||||
printf("failed to open log file in directory:%s\n", osLogDir());
|
printf("failed to open log file in directory:%s\n", tsLogDir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4628,7 +4628,7 @@ int32_t doInitQInfo(SQInfo* pQInfo, STSBuf* pTsBuf, void* tsdb, void* sourceOptr
|
||||||
getIntermediateBufInfo(pRuntimeEnv, &ps, &pQueryAttr->intermediateResultRowSize);
|
getIntermediateBufInfo(pRuntimeEnv, &ps, &pQueryAttr->intermediateResultRowSize);
|
||||||
|
|
||||||
int32_t TENMB = 1024*1024*10;
|
int32_t TENMB = 1024*1024*10;
|
||||||
int32_t code = createDiskbasedBuffer(&pRuntimeEnv->pResultBuf, ps, TENMB, pQInfo->qId, osTempDir());
|
int32_t code = createDiskbasedBuffer(&pRuntimeEnv->pResultBuf, ps, TENMB, pQInfo->qId, tsTempDir);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -254,7 +254,7 @@ tMemBucket *tMemBucketCreate(int16_t nElemSize, int16_t dataType, double minval,
|
||||||
|
|
||||||
resetSlotInfo(pBucket);
|
resetSlotInfo(pBucket);
|
||||||
|
|
||||||
int32_t ret = createDiskbasedBuffer(&pBucket->pBuffer, pBucket->bufPageSize, pBucket->bufPageSize * 512, 1, osTempDir());
|
int32_t ret = createDiskbasedBuffer(&pBucket->pBuffer, pBucket->bufPageSize, pBucket->bufPageSize * 512, 1, tsTempDir);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
tMemBucketDestroy(pBucket);
|
tMemBucketDestroy(pBucket);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -55,7 +55,7 @@ int32_t initUdfInfo(SUdfInfo* pUdfInfo) {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
char path[PATH_MAX] = {0};
|
char path[PATH_MAX] = {0};
|
||||||
taosGetTmpfilePath("script", path, osTempDir());
|
taosGetTmpfilePath("script", path, tsTempDir);
|
||||||
|
|
||||||
FILE* file = fopen(path, "w+");
|
FILE* file = fopen(path, "w+");
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ static void EnvInit() {
|
||||||
taosRemoveDir(path.c_str());
|
taosRemoveDir(path.c_str());
|
||||||
taosMkDir(path.c_str());
|
taosMkDir(path.c_str());
|
||||||
// init log file
|
// init log file
|
||||||
osSetLogDir( path.c_str());
|
tstrncpy(tsLogDir, path.c_str(), PATH_MAX);
|
||||||
if (taosInitLog("tindex.idx", 1) != 0) {
|
if (taosInitLog("tindex.idx", 1) != 0) {
|
||||||
printf("failed to init log");
|
printf("failed to init log");
|
||||||
}
|
}
|
||||||
|
|
|
@ -204,7 +204,7 @@ static int parseTime(char **end, SToken *pToken, int16_t timePrec, int64_t *time
|
||||||
bool isSigned = false;
|
bool isSigned = false;
|
||||||
toInteger(pToken->z, pToken->n, 10, &ts, &isSigned);
|
toInteger(pToken->z, pToken->n, 10, &ts, &isSigned);
|
||||||
} else { // parse the RFC-3339/ISO-8601 timestamp format string
|
} else { // parse the RFC-3339/ISO-8601 timestamp format string
|
||||||
if (taosParseTime(pToken->z, time, pToken->n, timePrec, osDaylight()) != TSDB_CODE_SUCCESS) {
|
if (taosParseTime(pToken->z, time, pToken->n, timePrec, tsDaylight) != TSDB_CODE_SUCCESS) {
|
||||||
return buildSyntaxErrMsg(pMsgBuf, "invalid timestamp format", pToken->z);
|
return buildSyntaxErrMsg(pMsgBuf, "invalid timestamp format", pToken->z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -578,7 +578,7 @@ static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) {
|
||||||
return DEAL_RES_ERROR;
|
return DEAL_RES_ERROR;
|
||||||
}
|
}
|
||||||
int32_t len = trimStringCopy(pVal->literal, n, tmp);
|
int32_t len = trimStringCopy(pVal->literal, n, tmp);
|
||||||
if (taosParseTime(tmp, &pVal->datum.i, len, pVal->node.resType.precision, osDaylight()) != TSDB_CODE_SUCCESS) {
|
if (taosParseTime(tmp, &pVal->datum.i, len, pVal->node.resType.precision, tsDaylight) != TSDB_CODE_SUCCESS) {
|
||||||
tfree(tmp);
|
tfree(tmp);
|
||||||
generateSyntaxErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pVal->literal);
|
generateSyntaxErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pVal->literal);
|
||||||
return DEAL_RES_ERROR;
|
return DEAL_RES_ERROR;
|
||||||
|
|
|
@ -1639,7 +1639,7 @@ static int parseTime(char **end, SToken *pToken, int16_t timePrec, int64_t *time
|
||||||
bool isSigned = false;
|
bool isSigned = false;
|
||||||
toInteger(pToken->z, pToken->n, 10, &ts, &isSigned);
|
toInteger(pToken->z, pToken->n, 10, &ts, &isSigned);
|
||||||
} else { // parse the RFC-3339/ISO-8601 timestamp format string
|
} else { // parse the RFC-3339/ISO-8601 timestamp format string
|
||||||
if (taosParseTime(pToken->z, time, pToken->n, timePrec, osDaylight()) != TSDB_CODE_SUCCESS) {
|
if (taosParseTime(pToken->z, time, pToken->n, timePrec, tsDaylight) != TSDB_CODE_SUCCESS) {
|
||||||
return buildSyntaxErrMsg(pMsgBuf, "invalid timestamp format", pToken->z);
|
return buildSyntaxErrMsg(pMsgBuf, "invalid timestamp format", pToken->z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,7 @@ void qwtInitLogFile() {
|
||||||
qDebugFlag = 159;
|
qDebugFlag = 159;
|
||||||
|
|
||||||
if (taosInitLog(defaultLogFileNamePrefix, maxLogFileNum) < 0) {
|
if (taosInitLog(defaultLogFileNamePrefix, maxLogFileNum) < 0) {
|
||||||
printf("failed to open log file in directory:%s\n", osLogDir());
|
printf("failed to open log file in directory:%s\n", tsLogDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ void flttInitLogFile() {
|
||||||
qDebugFlag = 159;
|
qDebugFlag = 159;
|
||||||
|
|
||||||
if (taosInitLog(defaultLogFileNamePrefix, maxLogFileNum) < 0) {
|
if (taosInitLog(defaultLogFileNamePrefix, maxLogFileNum) < 0) {
|
||||||
printf("failed to open log file in directory:%s\n", osLogDir());
|
printf("failed to open log file in directory:%s\n", tsLogDir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ void scltInitLogFile() {
|
||||||
qDebugFlag = 159;
|
qDebugFlag = 159;
|
||||||
|
|
||||||
if (taosInitLog(defaultLogFileNamePrefix, maxLogFileNum) < 0) {
|
if (taosInitLog(defaultLogFileNamePrefix, maxLogFileNum) < 0) {
|
||||||
printf("failed to open log file in directory:%s\n", osLogDir());
|
printf("failed to open log file in directory:%s\n", tsLogDir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ void schtInitLogFile() {
|
||||||
qDebugFlag = 159;
|
qDebugFlag = 159;
|
||||||
|
|
||||||
if (taosInitLog(defaultLogFileNamePrefix, maxLogFileNum) < 0) {
|
if (taosInitLog(defaultLogFileNamePrefix, maxLogFileNum) < 0) {
|
||||||
printf("failed to open log file in directory:%s\n", osLogDir());
|
printf("failed to open log file in directory:%s\n", tsLogDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,7 +155,7 @@ class TransObj {
|
||||||
taosRemoveDir(path.c_str());
|
taosRemoveDir(path.c_str());
|
||||||
taosMkDir(path.c_str());
|
taosMkDir(path.c_str());
|
||||||
|
|
||||||
osSetLogDir(path.c_str());
|
tstrncpy(tsLogDir, path.c_str(), PATH_MAX);
|
||||||
if (taosInitLog("taosdlog", 1) != 0) {
|
if (taosInitLog("taosdlog", 1) != 0) {
|
||||||
printf("failed to init log file\n");
|
printf("failed to init log file\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,68 +17,31 @@
|
||||||
#include "osEnv.h"
|
#include "osEnv.h"
|
||||||
|
|
||||||
extern void taosWinSocketInit();
|
extern void taosWinSocketInit();
|
||||||
|
|
||||||
char configDir[PATH_MAX] = {0};
|
char configDir[PATH_MAX] = {0};
|
||||||
|
char tsDataDir[PATH_MAX];
|
||||||
typedef struct SOsEnv {
|
char tsLogDir[PATH_MAX];
|
||||||
char dataDir[PATH_MAX];
|
char tsTempDir[PATH_MAX];
|
||||||
char logDir[PATH_MAX];
|
SDiskSpace tsDataSpace;
|
||||||
char tempDir[PATH_MAX];
|
SDiskSpace tsLogSpace;
|
||||||
SDiskSpace dataSpace;
|
SDiskSpace tsTempSpace;
|
||||||
SDiskSpace logSpace;
|
char tsOsName[16];
|
||||||
SDiskSpace tempSpace;
|
char tsTimezone[TD_TIMEZONE_LEN];
|
||||||
char osName[16];
|
char tsLocale[TD_LOCALE_LEN];
|
||||||
char timezone[TD_TIMEZONE_LEN];
|
char tsCharset[TD_CHARSET_LEN];
|
||||||
char locale[TD_LOCALE_LEN];
|
int8_t tsDaylight;
|
||||||
char charset[TD_CHARSET_LEN];
|
bool tsEnableCoreFile;
|
||||||
int8_t daylight;
|
int64_t tsPageSize;
|
||||||
bool enableCoreFile;
|
int64_t tsOpenMax;
|
||||||
} SOsEnv;
|
int64_t tsStreamMax;
|
||||||
|
int32_t tsNumOfCores;
|
||||||
static SOsEnv env = {0};
|
int32_t tsTotalMemoryMB;
|
||||||
|
|
||||||
SOsEnv *osEnv() { return &env; }
|
|
||||||
|
|
||||||
void osInitImp() {
|
|
||||||
taosGetSystemLocale(env.locale, env.charset);
|
|
||||||
taosGetSystemTimezone(env.timezone);
|
|
||||||
osSetTimezone(env.timezone);
|
|
||||||
}
|
|
||||||
|
|
||||||
void osUpdate() {
|
|
||||||
if (env.logDir[0] != 0) {
|
|
||||||
taosGetDiskSize(env.logDir, &env.logSpace.size);
|
|
||||||
}
|
|
||||||
if (env.dataDir[0] != 0) {
|
|
||||||
taosGetDiskSize(env.dataDir, &env.dataSpace.size);
|
|
||||||
}
|
|
||||||
if (env.tempDir[0] != 0) {
|
|
||||||
taosGetDiskSize(env.tempDir, &env.tempSpace.size);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool osLogSpaceAvailable() { return env.logSpace.reserved <= env.logSpace.size.avail; }
|
|
||||||
int8_t osDaylight() { return env.daylight; }
|
|
||||||
|
|
||||||
const char *osLogDir() { return env.logDir; }
|
|
||||||
const char *osTempDir() { return env.tempDir; }
|
|
||||||
const char *osDataDir() { return env.dataDir; }
|
|
||||||
const char *osName() { return env.osName; }
|
|
||||||
const char *osTimezone() { return env.timezone; }
|
|
||||||
const char *osLocale() { return env.locale; }
|
|
||||||
const char *osCharset() { return env.charset; }
|
|
||||||
|
|
||||||
void osSetLogDir(const char *logDir) { tstrncpy(env.logDir, logDir, PATH_MAX); }
|
|
||||||
void osSetTempDir(const char *tempDir) { tstrncpy(env.tempDir, tempDir, PATH_MAX); }
|
|
||||||
void osSetDataDir(const char *dataDir) { tstrncpy(env.dataDir, dataDir, PATH_MAX); }
|
|
||||||
void osSetLogReservedSpace(float sizeInGB) { env.logSpace.reserved = sizeInGB; }
|
|
||||||
void osSetTempReservedSpace(float sizeInGB) { env.tempSpace.reserved = sizeInGB; }
|
|
||||||
void osSetDataReservedSpace(float sizeInGB) { env.dataSpace.reserved = sizeInGB; }
|
|
||||||
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());
|
||||||
|
taosGetSystemLocale(tsLocale, tsCharset);
|
||||||
|
taosGetSystemTimezone(tsTimezone);
|
||||||
|
taosSetSystemTimezone(tsTimezone, tsTimezone, &tsDaylight);
|
||||||
taosGetSystemInfo();
|
taosGetSystemInfo();
|
||||||
|
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
||||||
|
@ -89,34 +52,50 @@ void osInit() {
|
||||||
tmpDir = getenv("temp");
|
tmpDir = getenv("temp");
|
||||||
}
|
}
|
||||||
if (tmpDir != NULL) {
|
if (tmpDir != NULL) {
|
||||||
strcpy(env.tempDir, tmpDir);
|
strcpy(tsTempDir, tmpDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (configDir[0] == 0) {
|
if (configDir[0] == 0) {
|
||||||
strcpy(configDir, "C:\\TDengine\\cfg");
|
strcpy(configDir, "C:\\TDengine\\cfg");
|
||||||
}
|
}
|
||||||
strcpy(env.dataDir, "C:\\TDengine\\data");
|
strcpy(tsDataDir, "C:\\TDengine\\data");
|
||||||
strcpy(env.logDir, "C:\\TDengine\\log");
|
strcpy(tsLogDir, "C:\\TDengine\\log");
|
||||||
strcpy(env.tempDir, "C:\\Windows\\Temp");
|
strcpy(tsTempDir, "C:\\Windows\\Temp");
|
||||||
strcpy(env.osName, "Windows");
|
strcpy(tsOsName, "Windows");
|
||||||
|
|
||||||
#elif defined(_TD_DARWIN_64)
|
#elif defined(_TD_DARWIN_64)
|
||||||
if (configDir[0] == 0) {
|
if (configDir[0] == 0) {
|
||||||
strcpy(configDir, "/tmp/taosd");
|
strcpy(configDir, "/tmp/taosd");
|
||||||
}
|
}
|
||||||
strcpy(env.dataDir, "/usr/local/var/lib/taos");
|
strcpy(tsDataDir, "/usr/local/var/lib/taos");
|
||||||
strcpy(env.logDir, "/usr/local/var/log/taos");
|
strcpy(tsLogDir, "/usr/local/var/log/taos");
|
||||||
strcpy(env.tempDir, "/usr/local/etc/taos");
|
strcpy(tsTempDir, "/usr/local/etc/taos");
|
||||||
strcpy(env.osName, "Darwin");
|
strcpy(tsOsName, "Darwin");
|
||||||
|
|
||||||
#else
|
#else
|
||||||
if (configDir[0] == 0) {
|
if (configDir[0] == 0) {
|
||||||
strcpy(configDir, "/etc/taos");
|
strcpy(configDir, "/etc/taos");
|
||||||
}
|
}
|
||||||
strcpy(env.dataDir, "/var/lib/taos");
|
strcpy(tsDataDir, "/var/lib/taos");
|
||||||
strcpy(env.logDir, "/var/log/taos");
|
strcpy(tsLogDir, "/var/log/taos");
|
||||||
strcpy(env.tempDir, "/tmp");
|
strcpy(tsTempDir, "/tmp");
|
||||||
strcpy(env.osName, "Linux");
|
strcpy(tsOsName, "Linux");
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void osUpdate() {
|
||||||
|
if (tsLogDir[0] != 0) {
|
||||||
|
taosGetDiskSize(tsLogDir, &tsLogSpace.size);
|
||||||
|
}
|
||||||
|
if (tsDataDir[0] != 0) {
|
||||||
|
taosGetDiskSize(tsDataDir, &tsDataSpace.size);
|
||||||
|
}
|
||||||
|
if (tsTempDir[0] != 0) {
|
||||||
|
taosGetDiskSize(tsTempDir, &tsTempSpace.size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool osLogSpaceAvailable() { return tsLogSpace.reserved <= tsLogSpace.size.avail; }
|
||||||
|
|
||||||
|
void osSetTimezone(const char *timezone) { taosSetSystemTimezone(tsTimezone, tsTimezone, &tsDaylight); }
|
||||||
|
|
|
@ -111,7 +111,7 @@ int32_t taosGetDiskSize(char *dataDir, SDiskSize *diskSize) {
|
||||||
diskSize->used = (int64_t)(i64TotalBytes - i64FreeBytes);
|
diskSize->used = (int64_t)(i64TotalBytes - i64FreeBytes);
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
//printf("failed to get disk size, dataDir:%s errno:%s", osDataDir(), strerror(errno));
|
//printf("failed to get disk size, dataDir:%s errno:%s", tsDataDir, strerror(errno));
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -316,7 +316,7 @@ void taosSetCoreDump() {}
|
||||||
int32_t taosGetDiskSize(char *dataDir, SDiskSize *diskSize) {
|
int32_t taosGetDiskSize(char *dataDir, SDiskSize *diskSize) {
|
||||||
struct statvfs info;
|
struct statvfs info;
|
||||||
if (statvfs(dataDir, &info)) {
|
if (statvfs(dataDir, &info)) {
|
||||||
//printf("failed to get disk size, dataDir:%s errno:%s", osDataDir(), strerror(errno));
|
//printf("failed to get disk size, dataDir:%s errno:%s", tsDataDir, strerror(errno));
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -121,7 +121,7 @@ int32_t taosInitLog(const char *logName, int maxFiles) {
|
||||||
osUpdate();
|
osUpdate();
|
||||||
|
|
||||||
char fullName[PATH_MAX] = {0};
|
char fullName[PATH_MAX] = {0};
|
||||||
snprintf(fullName, PATH_MAX, "%s" TD_DIRSEP "%s", osLogDir(), logName);
|
snprintf(fullName, PATH_MAX, "%s" TD_DIRSEP "%s", tsLogDir, logName);
|
||||||
|
|
||||||
tsLogObj.logHandle = taosLogBuffNew(TSDB_DEFAULT_LOG_BUF_SIZE);
|
tsLogObj.logHandle = taosLogBuffNew(TSDB_DEFAULT_LOG_BUF_SIZE);
|
||||||
if (tsLogObj.logHandle == NULL) return -1;
|
if (tsLogObj.logHandle == NULL) return -1;
|
||||||
|
@ -187,7 +187,7 @@ static void taosKeepOldLog(char *oldName) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
taosRemoveOldFiles(osLogDir(), TABS(tsLogKeepDays));
|
taosRemoveOldFiles(tsLogDir, TABS(tsLogKeepDays));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *taosThreadToOpenNewFile(void *param) {
|
static void *taosThreadToOpenNewFile(void *param) {
|
||||||
|
|
|
@ -68,11 +68,11 @@ TAOS *shellInit(SShellArguments *_args) {
|
||||||
printf("\n");
|
printf("\n");
|
||||||
if (!_args->is_use_passwd) {
|
if (!_args->is_use_passwd) {
|
||||||
#ifdef TD_WINDOWS
|
#ifdef TD_WINDOWS
|
||||||
strcpy(osName(), "Windows");
|
strcpy(tsOsName, "Windows");
|
||||||
#elif defined(TD_DARWIN)
|
#elif defined(TD_DARWIN)
|
||||||
strcpy(osName(), "Darwin");
|
strcpy(tsOsName, "Darwin");
|
||||||
#endif
|
#endif
|
||||||
printf(CLIENT_VERSION, osName(), taos_get_client_info());
|
printf(CLIENT_VERSION, tsOsName, taos_get_client_info());
|
||||||
}
|
}
|
||||||
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
|
@ -184,7 +184,7 @@ static void parse_args(
|
||||||
for (int i = 1; i < argc; i++) {
|
for (int i = 1; i < argc; i++) {
|
||||||
if ((strncmp(argv[i], "-p", 2) == 0)
|
if ((strncmp(argv[i], "-p", 2) == 0)
|
||||||
|| (strncmp(argv[i], "--password", 10) == 0)) {
|
|| (strncmp(argv[i], "--password", 10) == 0)) {
|
||||||
printf(LINUXCLIENT_VERSION, osName(), taos_get_client_info());
|
printf(LINUXCLIENT_VERSION, tsOsName, taos_get_client_info());
|
||||||
if ((strlen(argv[i]) == 2)
|
if ((strlen(argv[i]) == 2)
|
||||||
|| (strncmp(argv[i], "--password", 10) == 0)) {
|
|| (strncmp(argv[i], "--password", 10) == 0)) {
|
||||||
printf("Enter password: ");
|
printf("Enter password: ");
|
||||||
|
|
Loading…
Reference in New Issue