Add logic to set configs while init dnode.
This commit is contained in:
parent
f46037870d
commit
1089f323e4
|
@ -35,7 +35,6 @@
|
|||
// GRANT_CFG_DECLARE;
|
||||
|
||||
SConfig *tsCfg = NULL;
|
||||
|
||||
// cluster
|
||||
char tsFirst[TSDB_EP_LEN] = {0};
|
||||
char tsSecond[TSDB_EP_LEN] = {0};
|
||||
|
@ -602,6 +601,8 @@ static int32_t taosAddClientCfg(SConfig *pCfg) {
|
|||
(void)strcpy(defaultFqdn, "localhost");
|
||||
}
|
||||
|
||||
TAOS_CHECK_RETURN(
|
||||
cfgAddBool(pCfg, "forceReadConfig", tsForceReadConfig, CFG_SCOPE_BOTH, CFG_DYN_NONE, CFG_CATEGORY_LOCAL));
|
||||
TAOS_CHECK_RETURN(cfgAddString(pCfg, "firstEp", "", CFG_SCOPE_BOTH, CFG_DYN_CLIENT, CFG_CATEGORY_LOCAL));
|
||||
TAOS_CHECK_RETURN(cfgAddString(pCfg, "secondEp", "", CFG_SCOPE_BOTH, CFG_DYN_CLIENT, CFG_CATEGORY_LOCAL));
|
||||
TAOS_CHECK_RETURN(cfgAddString(pCfg, "fqdn", defaultFqdn, CFG_SCOPE_SERVER, CFG_DYN_CLIENT, CFG_CATEGORY_LOCAL));
|
||||
|
@ -1230,6 +1231,9 @@ static int32_t taosSetClientCfg(SConfig *pCfg) {
|
|||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "fqdn");
|
||||
tstrncpy(tsLocalFqdn, pItem->str, TSDB_FQDN_LEN);
|
||||
|
||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "forceReadConfig");
|
||||
tsForceReadConfig = pItem->bval;
|
||||
|
||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "serverPort");
|
||||
tsServerPort = (uint16_t)pItem->i32;
|
||||
(void)snprintf(tsLocalEp, sizeof(tsLocalEp), "%s:%u", tsLocalFqdn, tsServerPort);
|
||||
|
@ -2060,7 +2064,7 @@ int32_t taosInitCfg(const char *cfgDir, const char **envCmd, const char *envFile
|
|||
tsCfg = NULL;
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
tryLoadCfgFromDataDir(tsCfg);
|
||||
TAOS_CHECK_GOTO(tryLoadCfgFromDataDir(tsCfg), &lino, _exit);
|
||||
|
||||
if (tsc) {
|
||||
TAOS_CHECK_GOTO(taosSetClientCfg(tsCfg), &lino, _exit);
|
||||
|
|
|
@ -286,7 +286,6 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) {
|
|||
static void dmProcessConfigRsp(SDnodeMgmt *pMgmt, SRpcMsg *pRsp) {
|
||||
const STraceId *trace = &pRsp->info.traceId;
|
||||
SConfigRsp configRsp = {0};
|
||||
dGTrace("status rsp received from mnode, statusSeq:%d code:0x%x", pMgmt->statusSeq, pRsp->code);
|
||||
|
||||
if (pRsp->code != 0) {
|
||||
if (pRsp->code == TSDB_CODE_MND_DNODE_NOT_EXIST && !pMgmt->pData->dropped && pMgmt->pData->dnodeId > 0) {
|
||||
|
@ -300,8 +299,10 @@ static void dmProcessConfigRsp(SDnodeMgmt *pMgmt, SRpcMsg *pRsp) {
|
|||
(void)raise(SIGINT);
|
||||
}
|
||||
} else {
|
||||
bool needUpdate = false;
|
||||
if (pRsp->pCont != NULL && pRsp->contLen > 0 &&
|
||||
tDeserializeSConfigRsp(pRsp->pCont, pRsp->contLen, &configRsp) == 0) {
|
||||
// Try to use cfg file in current dnode.
|
||||
if (configRsp.forceReadConfig) {
|
||||
if (configRsp.isConifgVerified) {
|
||||
persistGlobalConfig(taosGetGlobalCfg(tsCfg), pMgmt->path, configRsp.cver);
|
||||
|
@ -311,11 +312,15 @@ static void dmProcessConfigRsp(SDnodeMgmt *pMgmt, SRpcMsg *pRsp) {
|
|||
goto _exit;
|
||||
}
|
||||
}
|
||||
// Try to use cfg from mnode sdb.
|
||||
if (!configRsp.isVersionVerified) {
|
||||
needUpdate = true;
|
||||
persistGlobalConfig(configRsp.array, pMgmt->path, configRsp.cver);
|
||||
}
|
||||
}
|
||||
setAllConfigs(tsCfg);
|
||||
if (needUpdate) {
|
||||
setAllConfigs(tsCfg);
|
||||
}
|
||||
persistLocalConfig(pMgmt->path);
|
||||
tsConfigInited = 1;
|
||||
}
|
||||
|
|
|
@ -27,8 +27,8 @@
|
|||
|
||||
static int32_t mndMCfgGetValInt32(SMCfgDnodeReq *pInMCfgReq, int32_t optLen, int32_t *pOutValue);
|
||||
static int32_t cfgUpdateItem(SConfigItem *pItem, SConfigObj *obj);
|
||||
static int32_t mndConfigUpdateTrans(SMnode *pMnode, const char *name, char *pValue) static int32_t
|
||||
mndProcessConfigDnodeReq(SRpcMsg *pReq);
|
||||
static int32_t mndConfigUpdateTrans(SMnode *pMnode, const char *name, char *pValue);
|
||||
static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq);
|
||||
static int32_t mndProcessConfigDnodeRsp(SRpcMsg *pRsp);
|
||||
static int32_t mndProcessConfigReq(SRpcMsg *pReq);
|
||||
static int32_t mndInitWriteCfg(SMnode *pMnode);
|
||||
|
|
Loading…
Reference in New Issue