Feat support alter dataDir disable.
This commit is contained in:
parent
c202b41861
commit
93500cf96e
|
@ -323,6 +323,8 @@ void printConfigNotMatch(SArray *array);
|
||||||
|
|
||||||
int32_t compareSConfigItemArrays(SArray *mArray, const SArray *dArray, SArray *diffArray);
|
int32_t compareSConfigItemArrays(SArray *mArray, const SArray *dArray, SArray *diffArray);
|
||||||
bool isConifgItemLazyMode(SConfigItem *item);
|
bool isConifgItemLazyMode(SConfigItem *item);
|
||||||
|
int32_t taosUpdateTfsItemDisable(SConfig *pCfg, const char *value, void *pTfs);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -319,6 +319,15 @@ bool tfsDiskSpaceAvailable(STfs *pTfs, int32_t level);
|
||||||
*/
|
*/
|
||||||
bool tfsDiskSpaceSufficient(STfs *pTfs, int32_t level, int32_t disk);
|
bool tfsDiskSpaceSufficient(STfs *pTfs, int32_t level, int32_t disk);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Update disk size of tfs.
|
||||||
|
*
|
||||||
|
* @param pTfs The fs object.
|
||||||
|
* @param dir The directory.
|
||||||
|
* @param disable The disable flag.
|
||||||
|
*/
|
||||||
|
int32_t tfsUpdateDiskDisable(STfs *pTfs, const char *dir, int8_t disable);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -390,6 +390,16 @@ int32_t taosSetTfsCfg(SConfig *pCfg) {
|
||||||
int32_t taosSetTfsCfg(SConfig *pCfg);
|
int32_t taosSetTfsCfg(SConfig *pCfg);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef _STORAGE
|
||||||
|
int32_t cfgUpdateTfsItemDisable(SConfig *pCfg, const char *value, void *pTfs) { return TSDB_CODE_INVALID_CFG; }
|
||||||
|
#else
|
||||||
|
int32_t cfgUpdateTfsItemDisable(SConfig *pCfg, const char *value, void *pTfs);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int32_t taosUpdateTfsItemDisable(SConfig *pCfg, const char *value, void *pTfs) {
|
||||||
|
return cfgUpdateTfsItemDisable(pCfg, value, pTfs);
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t taosSplitS3Cfg(SConfig *pCfg, const char *name, char gVarible[TSDB_MAX_EP_NUM][TSDB_FQDN_LEN],
|
static int32_t taosSplitS3Cfg(SConfig *pCfg, const char *name, char gVarible[TSDB_MAX_EP_NUM][TSDB_FQDN_LEN],
|
||||||
int8_t *pNum) {
|
int8_t *pNum) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
|
@ -25,6 +25,7 @@ extern "C" {
|
||||||
typedef struct SDnodeMgmt {
|
typedef struct SDnodeMgmt {
|
||||||
SDnodeData *pData;
|
SDnodeData *pData;
|
||||||
SMsgCb msgCb;
|
SMsgCb msgCb;
|
||||||
|
STfs *pTfs;
|
||||||
const char *path;
|
const char *path;
|
||||||
const char *name;
|
const char *name;
|
||||||
TdThread statusThread;
|
TdThread statusThread;
|
||||||
|
|
|
@ -499,9 +499,15 @@ static int32_t dmAlterMaxCompactTask(const char *value) {
|
||||||
int32_t dmProcessConfigReq(SDnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
int32_t dmProcessConfigReq(SDnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SDCfgDnodeReq cfgReq = {0};
|
SDCfgDnodeReq cfgReq = {0};
|
||||||
|
SConfig *pCfg = taosGetCfg();
|
||||||
|
SConfigItem *pItem = NULL;
|
||||||
|
|
||||||
if (tDeserializeSDCfgDnodeReq(pMsg->pCont, pMsg->contLen, &cfgReq) != 0) {
|
if (tDeserializeSDCfgDnodeReq(pMsg->pCont, pMsg->contLen, &cfgReq) != 0) {
|
||||||
return TSDB_CODE_INVALID_MSG;
|
return TSDB_CODE_INVALID_MSG;
|
||||||
}
|
}
|
||||||
|
if (strcasecmp(cfgReq.config, "dataDir") == 0) {
|
||||||
|
return taosUpdateTfsItemDisable(pCfg, cfgReq.value, pMgmt->pTfs);
|
||||||
|
}
|
||||||
|
|
||||||
if (strncmp(cfgReq.config, tsAlterCompactTaskKeywords, strlen(tsAlterCompactTaskKeywords) + 1) == 0) {
|
if (strncmp(cfgReq.config, tsAlterCompactTaskKeywords, strlen(tsAlterCompactTaskKeywords) + 1) == 0) {
|
||||||
return dmAlterMaxCompactTask(cfgReq.value);
|
return dmAlterMaxCompactTask(cfgReq.value);
|
||||||
|
@ -509,9 +515,6 @@ int32_t dmProcessConfigReq(SDnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||||
|
|
||||||
dInfo("start to config, option:%s, value:%s", cfgReq.config, cfgReq.value);
|
dInfo("start to config, option:%s, value:%s", cfgReq.config, cfgReq.value);
|
||||||
|
|
||||||
SConfig *pCfg = taosGetCfg();
|
|
||||||
SConfigItem *pItem = NULL;
|
|
||||||
|
|
||||||
code = cfgGetAndSetItem(pCfg, &pItem, cfgReq.config, cfgReq.value, CFG_STYPE_ALTER_SERVER_CMD, true);
|
code = cfgGetAndSetItem(pCfg, &pItem, cfgReq.config, cfgReq.value, CFG_STYPE_ALTER_SERVER_CMD, true);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
if (strncasecmp(cfgReq.config, "resetlog", strlen("resetlog")) == 0) {
|
if (strncasecmp(cfgReq.config, "resetlog", strlen("resetlog")) == 0) {
|
||||||
|
|
|
@ -68,6 +68,7 @@ static int32_t dmOpenMgmt(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) {
|
||||||
|
|
||||||
pMgmt->pData = pInput->pData;
|
pMgmt->pData = pInput->pData;
|
||||||
pMgmt->msgCb = pInput->msgCb;
|
pMgmt->msgCb = pInput->msgCb;
|
||||||
|
pMgmt->pTfs = pInput->pTfs;
|
||||||
pMgmt->path = pInput->path;
|
pMgmt->path = pInput->path;
|
||||||
pMgmt->name = pInput->name;
|
pMgmt->name = pInput->name;
|
||||||
pMgmt->processCreateNodeFp = pInput->processCreateNodeFp;
|
pMgmt->processCreateNodeFp = pInput->processCreateNodeFp;
|
||||||
|
|
|
@ -726,3 +726,22 @@ int32_t tfsGetMonitorInfo(STfs *pTfs, SMonDiskInfo *pInfo) {
|
||||||
|
|
||||||
TAOS_RETURN(0);
|
TAOS_RETURN(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t tfsUpdateDiskDisable(STfs *pTfs, const char *dir, int8_t disable) {
|
||||||
|
TAOS_UNUSED(tfsLock(pTfs));
|
||||||
|
for (int32_t level = 0; level < pTfs->nlevel; level++) {
|
||||||
|
STfsTier *pTier = &pTfs->tiers[level];
|
||||||
|
for (int32_t disk = 0; disk < pTier->ndisk; ++disk) {
|
||||||
|
STfsDisk *pDisk = pTier->disks[disk];
|
||||||
|
if (strcmp(pDisk->path, dir) == 0) {
|
||||||
|
pDisk->disable = disable;
|
||||||
|
TAOS_UNUSED(tfsUnLock(pTfs));
|
||||||
|
fInfo("disk %s is %s", dir, disable ? "disabled" : "enabled");
|
||||||
|
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TAOS_UNUSED(tfsUnLock(pTfs));
|
||||||
|
fError("failed to update disk disable since %s not found", dir);
|
||||||
|
TAOS_RETURN(TSDB_CODE_FS_NO_VALID_DISK);
|
||||||
|
}
|
|
@ -432,56 +432,6 @@ _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) {
|
||||||
|
@ -555,18 +505,13 @@ int32_t cfgGetAndSetItem(SConfig *pCfg, SConfigItem **pItem, const char *name, c
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcasecmp(name, "dataDir") == 0) {
|
|
||||||
code = cfgUpdateTfsItemDisable(*pItem, value);
|
|
||||||
goto _exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
TAOS_CHECK_GOTO(cfgSetItemVal(*pItem, name, value, stype), NULL, _exit);
|
TAOS_CHECK_GOTO(cfgSetItemVal(*pItem, name, value, stype), NULL, _exit);
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (lock) {
|
if (lock) {
|
||||||
(void)taosThreadMutexUnlock(&pCfg->lock);
|
(void)taosThreadMutexUnlock(&pCfg->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue