提交 4f353da4 编写于 作者: S Shengliang Guan

global config

上级 76d69529
......@@ -56,16 +56,7 @@ extern int32_t tsProjectExecInterval;
extern int64_t tsMaxRetentWindow;
// system info
extern float tsTotalLogDirGB;
extern float tsTotalTmpDirGB;
extern float tsTotalDataDirGB;
extern float tsAvailLogDirGB;
extern float tsAvailTmpDirectorySpace;
extern float tsAvailDataDirGB;
extern float tsUsedDataDirGB;
extern float tsMinimalLogDirGB;
extern float tsReservedTmpDirectorySpace;
extern float tsMinimalDataDirGB;
extern uint32_t tsVersion;
// build info
......
......@@ -21,9 +21,24 @@ extern "C" {
#endif
extern char tsOsName[];
extern char tsDataDir[];
extern char tsLogDir[];
extern char tsTempDir[];
extern char configDir[];
extern struct SDiskSpace tsLogSpace;
extern struct SDiskSpace tsTempSpace;
extern struct SDiskSpace tsDataSpace;
void taosUpdateLogSpace();
void taosUpdateTempSpace();
void taosUpdateDataSpace();
bool taosLogSpaceAvailable();
bool taosTmpSpaceAvailable();
bool taosDataSpaceAvailable();
void taosUpdateAllSpace();
#ifdef __cplusplus
}
#endif
......
......@@ -25,20 +25,27 @@ extern "C" {
#define TSDB_LOCALE_LEN 64
#define TSDB_TIMEZONE_LEN 96
typedef struct {
int64_t total;
int64_t used;
int64_t avail;
} SDiskSize;
typedef struct SDiskSpace {
int64_t reserved;
SDiskSize size;
} SDiskSpace;
extern int64_t tsPageSize;
extern int64_t tsOpenMax;
extern int64_t tsStreamMax;
extern int32_t tsNumOfCores;
extern int32_t tsTotalMemoryMB;
extern char tsTimezone[];
extern char tsLocale[];
extern char tsCharset[]; // default encode string
extern char tsTimezone[];
extern char tsLocale[];
extern char tsCharset[]; // default encode string
typedef struct {
int64_t total;
int64_t used;
int64_t avail;
} SDiskSize;
int32_t taosGetDiskSize(char *dataDir, SDiskSize *diskSize);
int32_t taosGetCpuCores();
......
......@@ -22,7 +22,6 @@
extern "C" {
#endif
extern char tsLogDir[];
extern bool tsLogInited;
extern bool tsAsyncLog;
extern int32_t tsNumOfLogLines;
......
......@@ -119,13 +119,6 @@ bool tsdbForceKeepFile = false;
int64_t tsTickPerDay[] = {86400000L, 86400000000L, 86400000000000L};
// system info
float tsTotalTmpDirGB = 0;
float tsTotalDataDirGB = 0;
float tsAvailTmpDirectorySpace = 0;
float tsAvailDataDirGB = 0;
float tsUsedDataDirGB = 0;
float tsReservedTmpDirectorySpace = 1.0f;
float tsMinimalDataDirGB = 2.0f;
int32_t tsTotalMemoryMB = 0;
uint32_t tsVersion = 0;
......@@ -422,35 +415,6 @@ static void doInitGlobalConfig(void) {
taosAddConfigOption(cfg);
cfg.option = "minimalLogDirGB";
cfg.ptr = &tsMinimalLogDirGB;
cfg.valType = TAOS_CFG_VTYPE_FLOAT;
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
cfg.minValue = 0.001f;
cfg.maxValue = 10000000;
cfg.ptrLength = 0;
cfg.unitType = TAOS_CFG_UTYPE_GB;
taosAddConfigOption(cfg);
cfg.option = "minimalTmpDirGB";
cfg.ptr = &tsReservedTmpDirectorySpace;
cfg.valType = TAOS_CFG_VTYPE_FLOAT;
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
cfg.minValue = 0.001f;
cfg.maxValue = 10000000;
cfg.ptrLength = 0;
cfg.unitType = TAOS_CFG_UTYPE_GB;
taosAddConfigOption(cfg);
cfg.option = "minimalDataDirGB";
cfg.ptr = &tsMinimalDataDirGB;
cfg.valType = TAOS_CFG_VTYPE_FLOAT;
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
cfg.minValue = 0.001f;
cfg.maxValue = 10000000;
cfg.ptrLength = 0;
cfg.unitType = TAOS_CFG_UTYPE_GB;
taosAddConfigOption(cfg);
cfg.option = "slaveQuery";
cfg.ptr = &tsEnableSlaveQuery;
......
......@@ -41,17 +41,17 @@ static int32_t dmnAddEpCfg(SConfig *pCfg) {
static int32_t dmnAddDirCfg(SConfig *pCfg) {
if (cfgAddDir(pCfg, "dataDir", tsDataDir) != 0) return -1;
if (cfgAddDir(pCfg, "tmpDir", tsTempDir) != 0) return -1;
if (cfgAddDir(pCfg, "tempDir", tsTempDir) != 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) {
SConfigItem *pItem = NULL;
pItem = cfgGetItem(pCfg, "tmpDir");
if (taosDirExist(pItem->str) != 0) {
return -1;
}
static int32_t dmnCheckDirCfg(SConfig *pCfg) {
tstrncpy(tsDataDir, cfgGetItem(pCfg, "dataDir")->str, PATH_MAX);
tstrncpy(tsTempDir, cfgGetItem(pCfg, "tempDir")->str, PATH_MAX);
tsDataSpace.reserved = cfgGetItem(pCfg, "minimalDataDirGB")->fval;
tsTempSpace.reserved = cfgGetItem(pCfg, "minimalTempDirGB")->fval;
return 0;
}
......
......@@ -18,6 +18,7 @@
int32_t dmnAddLogCfg(SConfig *pCfg) {
if (cfgAddDir(pCfg, "logDir", "/var/log/taos") != 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;
......@@ -41,6 +42,7 @@ int32_t dmnAddLogCfg(SConfig *pCfg) {
int32_t dmnSetLogCfg(SConfig *pCfg) {
tstrncpy(tsLogDir, cfgGetItem(pCfg, "logDir")->str, PATH_MAX);
tsLogSpace.reserved = cfgGetItem(pCfg, "minimalLogDirGB")->fval;
tsAsyncLog = cfgGetItem(pCfg, "asyncLog")->bval;
tsNumOfLogLines = cfgGetItem(pCfg, "numOfLogLines")->i32;
tsLogKeepDays = cfgGetItem(pCfg, "logKeepDays")->i32;
......
......@@ -325,18 +325,6 @@ void taosGetDisk() {
SDiskSize diskSize = tfsGetSize(pTfs);
tfsUpdateSize(&fsMeta);
tsTotalDataDirGB = (float)(fsMeta.total / unit);
tsUsedDataDirGB = (float)(fsMeta.used / unit);
tsAvailDataDirGB = (float)(fsMeta.avail / unit);
if (taosGetDiskSize(tsLogDir, &diskSize) == 0) {
tsTotalLogDirGB = (float)(diskSize.total / unit);
tsAvailLogDirGB = (float)(diskSize.avail / unit);
}
if (taosGetDiskSize(tsTempDir, &diskSize) == 0) {
tsTotalTmpDirGB = (float)(diskSize.total / unit);
tsAvailTmpDirectorySpace = (float)(diskSize.avail / unit);
}
#endif
}
\ No newline at end of file
......@@ -16,6 +16,30 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "osEnv.h"
#include "osSysinfo.h"
SDiskSpace tsLogSpace;
SDiskSpace tsTempSpace;
SDiskSpace tsDataSpace;
void taosUpdateLogSpace() { taosGetDiskSize(tsLogDir, &tsLogSpace.size); }
void taosUpdateTempSpace() { taosGetDiskSize(tsTempDir, &tsTempSpace.size); }
void taosUpdateDataSpace() { taosGetDiskSize(tsDataDir, &tsDataSpace.size); }
bool taosLogSpaceAvailable() { return tsDataSpace.reserved > tsDataSpace.size.avail; }
bool taosTempSpaceAvailable() { return tsTempSpace.reserved > tsTempSpace.size.avail; }
bool taosDataSpaceAvailable() { return tsDataSpace.reserved > tsDataSpace.size.avail; }
void taosUpdateAllSpace() {
taosUpdateLogSpace();
taosUpdateTempSpace();
taosUpdateDataSpace();
}
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
......
......@@ -72,9 +72,6 @@ int8_t tscEmbeddedInUtil = 0;
int32_t tsLogKeepDays = 0;
bool tsAsyncLog = true;
bool tsLogInited = false;
float tsTotalLogDirGB = 0;
float tsAvailLogDirGB = 0;
float tsMinimalLogDirGB = 1.0f;
int64_t asyncLogLostLines = 0;
int32_t writeInterval = DEFAULT_LOG_INTERVAL;
......@@ -383,12 +380,7 @@ static int32_t taosOpenLogFile(char *fn, int32_t maxLines, int32_t maxFileNum) {
}
void taosPrintLog(const char *flags, int32_t dflag, const char *format, ...) {
if (tsTotalLogDirGB != 0 && tsAvailLogDirGB < tsMinimalLogDirGB) {
printf("server disk:%s space remain %.3f GB, total %.1f GB, stop print log.\n", tsLogDir, tsAvailLogDirGB,
tsTotalLogDirGB);
fflush(stdout);
return;
}
if (!taosLogSpaceAvailable()) return;
va_list argpointer;
char buffer[MAX_LOGLINE_BUFFER_SIZE] = {0};
......@@ -443,12 +435,7 @@ void taosPrintLog(const char *flags, int32_t dflag, const char *format, ...) {
}
void taosDumpData(unsigned char *msg, int32_t len) {
if (tsTotalLogDirGB != 0 && tsAvailLogDirGB < tsMinimalLogDirGB) {
printf("server disk:%s space remain %.3f GB, total %.1f GB, stop dump log.\n", tsLogDir, tsAvailLogDirGB,
tsTotalLogDirGB);
fflush(stdout);
return;
}
if (!taosLogSpaceAvailable()) return;
char temp[256];
int32_t i, pos = 0, c = 0;
......@@ -471,12 +458,7 @@ void taosDumpData(unsigned char *msg, int32_t len) {
}
void taosPrintLongString(const char *flags, int32_t dflag, const char *format, ...) {
if (tsTotalLogDirGB != 0 && tsAvailLogDirGB < tsMinimalLogDirGB) {
printf("server disk:%s space remain %.3f GB, total %.1f GB, stop write log.\n", tsLogDir, tsAvailLogDirGB,
tsTotalLogDirGB);
fflush(stdout);
return;
}
if (!taosLogSpaceAvailable()) return;
va_list argpointer;
char buffer[MAX_LOGLINE_DUMP_BUFFER_SIZE];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册