Parse alter dataDir config.
This commit is contained in:
parent
2e2897fbdd
commit
c202b41861
|
@ -2381,6 +2381,10 @@ static int32_t taosCfgDynamicOptionsForServer(SConfig *pCfg, const char *name) {
|
||||||
code = TSDB_CODE_SUCCESS;
|
code = TSDB_CODE_SUCCESS;
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
if (strcasecmp(name, "dataDir") == 0) {
|
||||||
|
code = TSDB_CODE_SUCCESS;
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
|
|
||||||
{ // 'bool/int32_t/int64_t/float/double' variables with general modification function
|
{ // 'bool/int32_t/int64_t/float/double' variables with general modification function
|
||||||
static OptionNameAndVar debugOptions[] = {
|
static OptionNameAndVar debugOptions[] = {
|
||||||
|
|
|
@ -432,6 +432,56 @@ _err:
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t cfgUpdateTfsItemDisable(SConfigItem *pItem, const char *value) {
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t len = strlen(value) + 1;
|
||||||
|
int8_t disable = 0;
|
||||||
|
char *dataDirStr = taosMemoryMalloc(PATH_MAX);
|
||||||
|
char *disableStr = taosMemoryMalloc(1 + 1);
|
||||||
|
const char *p = value;
|
||||||
|
while (*p) {
|
||||||
|
if (*p == ' ') {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t optLen = p - value;
|
||||||
|
tstrncpy(dataDirStr, value, PATH_MAX);
|
||||||
|
dataDirStr[optLen] = 0;
|
||||||
|
|
||||||
|
if (' ' == value[optLen] && strlen(value) > optLen + 1) {
|
||||||
|
disableStr[0] = value[optLen + 1];
|
||||||
|
disableStr[1] = 0;
|
||||||
|
if ((taosStr2int8(dataDirStr, &disable)) < 0) {
|
||||||
|
code = TSDB_CODE_INVALID_CFG_VALUE;
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
code = TSDB_CODE_INVALID_CFG_VALUE;
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t sz = taosArrayGetSize(pItem->array);
|
||||||
|
for (int32_t i = 0; i < sz; ++i) {
|
||||||
|
SDiskCfg *cfg = taosArrayGet(pItem->array, i);
|
||||||
|
if (strcmp(cfg->dir, dataDirStr) == 0) {
|
||||||
|
cfg->disable = disable;
|
||||||
|
break;
|
||||||
|
uInfo("update tfs item:%s disable:%d", cfg->dir, cfg->disable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
code = TSDB_CODE_INVALID_CFG_VALUE;
|
||||||
|
|
||||||
|
_exit:
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
uError("failed to update tfs item:%s disable:%d", dataDirStr, disable);
|
||||||
|
}
|
||||||
|
taosMemoryFree(dataDirStr);
|
||||||
|
taosMemoryFree(disableStr);
|
||||||
|
TAOS_RETURN(code);
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t cfgUpdateDebugFlagItem(SConfig *pCfg, const char *name, bool resetArray) {
|
static int32_t cfgUpdateDebugFlagItem(SConfig *pCfg, const char *name, bool resetArray) {
|
||||||
SConfigItem *pDebugFlagItem = cfgGetItem(pCfg, "debugFlag");
|
SConfigItem *pDebugFlagItem = cfgGetItem(pCfg, "debugFlag");
|
||||||
if (resetArray) {
|
if (resetArray) {
|
||||||
|
@ -501,11 +551,18 @@ int32_t cfgGetAndSetItem(SConfig *pCfg, SConfigItem **pItem, const char *name, c
|
||||||
|
|
||||||
*pItem = cfgGetItem(pCfg, name);
|
*pItem = cfgGetItem(pCfg, name);
|
||||||
if (*pItem == NULL) {
|
if (*pItem == NULL) {
|
||||||
(void)taosThreadMutexUnlock(&pCfg->lock);
|
code = TSDB_CODE_CFG_NOT_FOUND;
|
||||||
TAOS_RETURN(TSDB_CODE_CFG_NOT_FOUND);
|
goto _exit;
|
||||||
}
|
}
|
||||||
TAOS_CHECK_RETURN(cfgSetItemVal(*pItem, name, value, stype));
|
|
||||||
|
|
||||||
|
if (strcasecmp(name, "dataDir") == 0) {
|
||||||
|
code = cfgUpdateTfsItemDisable(*pItem, value);
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
TAOS_CHECK_GOTO(cfgSetItemVal(*pItem, name, value, stype), NULL, _exit);
|
||||||
|
|
||||||
|
_exit:
|
||||||
if (lock) {
|
if (lock) {
|
||||||
(void)taosThreadMutexUnlock(&pCfg->lock);
|
(void)taosThreadMutexUnlock(&pCfg->lock);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue