提交 7c9ef176 编写于 作者: H Hongze Cheng

Merge branch 'feature/TD-1413' of https://github.com/taosdata/TDengine into feature/TD-1413

...@@ -321,22 +321,27 @@ void taosAddDataDir(int index, char *v1, int level, int primary) { ...@@ -321,22 +321,27 @@ 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) {
taosAddDataDir(0, tsDataDir, 0, 1); if (tsDiskCfgNum == 1) {
tstrncpy(tsDiskCfg[0].dir, tsDataDir, TSDB_FILENAME_LEN); SDiskCfg *cfg = &tsDiskCfg[0];
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;
} }
#endif
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 level:%d primary:%d", cfg->dir, cfg->level, cfg->primary); uInfo(" dataDir: %s", cfg->dir);
} }
} }
#endif
static void taosCheckDataDirCfg() { static void taosCheckDataDirCfg() {
if (tsDiskCfgNum <= 0) { if (tsDiskCfgNum <= 0) {
taosAddDataDir(0, tsDataDir, 0, 1); taosAddDataDir(0, tsDataDir, 0, 1);
tsDiskCfgNum = 1; tsDiskCfgNum = 1;
uTrace("dataDir:%s, level:0 primary:1 is configured by default", tsDataDir);
} }
} }
......
...@@ -104,7 +104,7 @@ int32_t dnodeInitSystem() { ...@@ -104,7 +104,7 @@ int32_t dnodeInitSystem() {
signal(SIGPIPE, SIG_IGN); signal(SIGPIPE, SIG_IGN);
if (dnodeCreateDir(tsLogDir) < 0) { if (dnodeCreateDir(tsLogDir) < 0) {
printf("failed to create dir: %s, reason: %s\n", tsLogDir, strerror(errno)); printf("failed to create log dir: %s, reason: %s\n", tsLogDir, strerror(errno));
return -1; return -1;
} }
...@@ -186,13 +186,13 @@ static int32_t dnodeInitStorage() { ...@@ -186,13 +186,13 @@ static int32_t dnodeInitStorage() {
//TODO(dengyihao): no need to init here //TODO(dengyihao): no need to init here
tdGetMnodeRootDir(tsDataDir, tsMnodeDir); tdGetMnodeRootDir(tsDataDir, tsMnodeDir);
if (dnodeCreateDir(tsMnodeDir) < 0) { if (dnodeCreateDir(tsMnodeDir) < 0) {
dError("failed to create dir: %s, reason: %s", tsMnodeDir, strerror(errno)); dError("failed to create mnode dir: %s, reason: %s", tsMnodeDir, strerror(errno));
return -1; return -1;
} }
tdGetDnodeRootDir(tsDataDir, tsDnodeDir); tdGetDnodeRootDir(tsDataDir, tsDnodeDir);
if (dnodeCreateDir(tsDnodeDir) < 0) { if (dnodeCreateDir(tsDnodeDir) < 0) {
dError("failed to create dir: %s, reason: %s", tsDnodeDir, strerror(errno)); dError("failed to create dnode dir: %s, reason: %s", tsDnodeDir, strerror(errno));
return -1; return -1;
} }
...@@ -205,13 +205,13 @@ static int32_t dnodeInitStorage() { ...@@ -205,13 +205,13 @@ static int32_t dnodeInitStorage() {
tdGetVnodeRootDir(dirName, pDisk->dir); tdGetVnodeRootDir(dirName, pDisk->dir);
if (dnodeCreateDir(dirName) < 0) { if (dnodeCreateDir(dirName) < 0) {
dError("failed to create dir: %s, reason: %s", dirName, strerror(errno)); dError("failed to create vnode dir: %s, reason: %s", dirName, strerror(errno));
return -1; return -1;
} }
tdGetVnodeBackRootDir(dirName, pDisk->dir); tdGetVnodeBackRootDir(dirName, pDisk->dir);
if (dnodeCreateDir(dirName) < 0) { if (dnodeCreateDir(dirName) < 0) {
dError("failed to create dir: %s, reason: %s", dirName, strerror(errno)); dError("failed to create vnode back dir: %s, reason: %s", dirName, strerror(errno));
return -1; return -1;
} }
} }
......
...@@ -97,19 +97,20 @@ static void taosReadInt16Config(SGlobalCfg *cfg, char *input_value) { ...@@ -97,19 +97,20 @@ static void taosReadInt16Config(SGlobalCfg *cfg, char *input_value) {
} }
} }
static void taosReadDirectoryConfig(SGlobalCfg *cfg, char *input_value) { static bool taosReadDirectoryConfig(SGlobalCfg *cfg, char *input_value) {
int length = (int)strlen(input_value); int length = (int)strlen(input_value);
char *option = (char *)cfg->ptr; char *option = (char *)cfg->ptr;
if (length <= 0 || length > cfg->ptrLength) { if (length <= 0 || length > cfg->ptrLength) {
uError("config option:%s, input value:%s, length out of range[0, %d], use default value:%s", uError("config option:%s, input value:%s, length out of range[0, %d], use default value:%s", cfg->option,
cfg->option, input_value, cfg->ptrLength, option); input_value, cfg->ptrLength, option);
return false;
} else { } else {
if (cfg->cfgStatus <= TAOS_CFG_CSTATUS_FILE) { if (cfg->cfgStatus <= TAOS_CFG_CSTATUS_FILE) {
wordexp_t full_path; wordexp_t full_path;
if (0 != wordexp(input_value, &full_path, 0)) { if (0 != wordexp(input_value, &full_path, 0)) {
printf("\nconfig dir: %s wordexp fail! reason:%s\n", input_value, strerror(errno)); printf("\nconfig dir: %s wordexp fail! reason:%s\n", input_value, strerror(errno));
wordfree(&full_path); wordfree(&full_path);
return; return false;
} }
if (full_path.we_wordv != NULL && full_path.we_wordv[0] != NULL) { if (full_path.we_wordv != NULL && full_path.we_wordv[0] != NULL) {
...@@ -121,8 +122,9 @@ static void taosReadDirectoryConfig(SGlobalCfg *cfg, char *input_value) { ...@@ -121,8 +122,9 @@ static void taosReadDirectoryConfig(SGlobalCfg *cfg, char *input_value) {
int code = taosMkDir(option, 0755); int code = taosMkDir(option, 0755);
if (code != 0) { if (code != 0) {
terrno = TAOS_SYSTEM_ERROR(errno); terrno = TAOS_SYSTEM_ERROR(errno);
uError("config option:%s, input value:%s, directory not exist, create fail:%s", uError("config option:%s, input value:%s, directory not exist, create fail:%s", cfg->option, input_value,
cfg->option, input_value, strerror(errno)); strerror(errno));
return false;
} }
cfg->cfgStatus = TAOS_CFG_CSTATUS_FILE; cfg->cfgStatus = TAOS_CFG_CSTATUS_FILE;
} else { } else {
...@@ -130,6 +132,8 @@ static void taosReadDirectoryConfig(SGlobalCfg *cfg, char *input_value) { ...@@ -130,6 +132,8 @@ static void taosReadDirectoryConfig(SGlobalCfg *cfg, char *input_value) {
tsCfgStatusStr[cfg->cfgStatus], option); tsCfgStatusStr[cfg->cfgStatus], option);
} }
} }
return true;
} }
static void taosReadIpStrConfig(SGlobalCfg *cfg, char *input_value) { static void taosReadIpStrConfig(SGlobalCfg *cfg, char *input_value) {
...@@ -225,8 +229,10 @@ static void taosReadConfigOption(const char *option, char *value, char *value2, ...@@ -225,8 +229,10 @@ static void taosReadConfigOption(const char *option, char *value, char *value2,
taosReadDirectoryConfig(cfg, value); taosReadDirectoryConfig(cfg, value);
break; break;
case TAOS_CFG_VTYPE_DATA_DIRCTORY: case TAOS_CFG_VTYPE_DATA_DIRCTORY:
taosReadDirectoryConfig(cfg, value); if (taosReadDirectoryConfig(cfg, value)) {
taosReadDataDirCfg(value, value2, value3); taosReadDataDirCfg(value, value2, value3);
}
break;
default: default:
uError("config option:%s, input value:%s, can't be recognized", option, value); uError("config option:%s, input value:%s, can't be recognized", option, value);
break; break;
...@@ -349,10 +355,11 @@ bool taosReadGlobalCfg() { ...@@ -349,10 +355,11 @@ bool taosReadGlobalCfg() {
value[vlen] = 0; value[vlen] = 0;
paGetToken(value + vlen + 1, &value2, &vlen2); paGetToken(value + vlen + 1, &value2, &vlen2);
if (vlen2 != 0) value2[vlen2] = 0; if (vlen2 != 0) {
value2[vlen2] = 0;
paGetToken(value + vlen2 + 1, &value3, &vlen3); paGetToken(value2 + vlen2 + 1, &value3, &vlen3);
if (vlen3 != 0) value3[vlen3] = 0; if (vlen3 != 0) value3[vlen3] = 0;
}
taosReadConfigOption(option, value, value2, value3); taosReadConfigOption(option, value, value2, value3);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册