enh: support spread active codes
This commit is contained in:
parent
188a4ce6a5
commit
50126e4425
|
@ -557,6 +557,7 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_GRANT_GEN_IVLD_KEY TAOS_DEF_ERROR_CODE(0, 0x0812)
|
#define TSDB_CODE_GRANT_GEN_IVLD_KEY TAOS_DEF_ERROR_CODE(0, 0x0812)
|
||||||
#define TSDB_CODE_GRANT_GEN_APP_LIMIT TAOS_DEF_ERROR_CODE(0, 0x0813)
|
#define TSDB_CODE_GRANT_GEN_APP_LIMIT TAOS_DEF_ERROR_CODE(0, 0x0813)
|
||||||
#define TSDB_CODE_GRANT_GEN_ENC_IVLD_KLEN TAOS_DEF_ERROR_CODE(0, 0x0814)
|
#define TSDB_CODE_GRANT_GEN_ENC_IVLD_KLEN TAOS_DEF_ERROR_CODE(0, 0x0814)
|
||||||
|
#define TSDB_CODE_GRANT_PAR_IVLD_DIST TAOS_DEF_ERROR_CODE(0, 0x0815)
|
||||||
|
|
||||||
// sync
|
// sync
|
||||||
// #define TSDB_CODE_SYN_INVALID_CONFIG TAOS_DEF_ERROR_CODE(0, 0x0900) // 2.x
|
// #define TSDB_CODE_SYN_INVALID_CONFIG TAOS_DEF_ERROR_CODE(0, 0x0900) // 2.x
|
||||||
|
|
|
@ -29,7 +29,7 @@ int64_t mndGetClusterId(SMnode *pMnode);
|
||||||
int64_t mndGetClusterCreateTime(SMnode *pMnode);
|
int64_t mndGetClusterCreateTime(SMnode *pMnode);
|
||||||
int32_t mndGetClusterGrantedInfo(SMnode *pMnode, SGrantedInfo *pInfo);
|
int32_t mndGetClusterGrantedInfo(SMnode *pMnode, SGrantedInfo *pInfo);
|
||||||
int64_t mndGetClusterUpTime(SMnode *pMnode);
|
int64_t mndGetClusterUpTime(SMnode *pMnode);
|
||||||
int32_t mndProcessGrantedTime(SMnode *pMnode, int64_t grantedTime);
|
int32_t mndProcessGrantedInfo(SMnode *pMnode, SGrantedInfo *pInfo);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -236,6 +236,7 @@ static int32_t mndClusterActionUpdate(SSdb *pSdb, SClusterObj *pOld, SClusterObj
|
||||||
pNew, pOld->upTime, pNew->upTime);
|
pNew, pOld->upTime, pNew->upTime);
|
||||||
pOld->upTime = pNew->upTime;
|
pOld->upTime = pNew->upTime;
|
||||||
pOld->grantedTime = pNew->grantedTime;
|
pOld->grantedTime = pNew->grantedTime;
|
||||||
|
pOld->connGrantedTime = pNew->connGrantedTime;
|
||||||
pOld->updateTime = taosGetTimestampMs();
|
pOld->updateTime = taosGetTimestampMs();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -378,17 +379,18 @@ static int32_t mndProcessUptimeTimer(SRpcMsg *pReq) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndProcessGrantedTime(SMnode *pMnode, int64_t grantedTime) {
|
int32_t mndProcessGrantedInfo(SMnode *pMnode, SGrantedInfo *pInfo) {
|
||||||
SClusterObj clusterObj = {0};
|
SClusterObj clusterObj = {0};
|
||||||
void *pIter = NULL;
|
void *pIter = NULL;
|
||||||
SClusterObj *pCluster = mndAcquireCluster(pMnode, &pIter);
|
SClusterObj *pCluster = mndAcquireCluster(pMnode, &pIter);
|
||||||
if (pCluster != NULL) {
|
if (pCluster != NULL) {
|
||||||
if (pCluster->grantedTime >= grantedTime) {
|
if (pCluster->grantedTime >= pInfo->grantedTime && pCluster->connGrantedTime > pInfo->connGrantedTime) {
|
||||||
mndReleaseCluster(pMnode, pCluster, pIter);
|
mndReleaseCluster(pMnode, pCluster, pIter);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
memcpy(&clusterObj, pCluster, sizeof(SClusterObj));
|
memcpy(&clusterObj, pCluster, sizeof(SClusterObj));
|
||||||
clusterObj.grantedTime = grantedTime;
|
if (pCluster->grantedTime < pInfo->grantedTime) clusterObj.grantedTime = pInfo->grantedTime;
|
||||||
|
if (pCluster->connGrantedTime < pInfo->connGrantedTime) clusterObj.connGrantedTime = pInfo->connGrantedTime;
|
||||||
mndReleaseCluster(pMnode, pCluster, pIter);
|
mndReleaseCluster(pMnode, pCluster, pIter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1284,6 +1284,10 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) {
|
||||||
strcpy(dcfgReq.config, "supportvnodes");
|
strcpy(dcfgReq.config, "supportvnodes");
|
||||||
snprintf(dcfgReq.value, TSDB_DNODE_VALUE_LEN, "%d", flag);
|
snprintf(dcfgReq.value, TSDB_DNODE_VALUE_LEN, "%d", flag);
|
||||||
} else if (strncasecmp(cfgReq.config, "activeCode", 10) == 0 || strncasecmp(cfgReq.config, "cActiveCode", 11) == 0) {
|
} else if (strncasecmp(cfgReq.config, "activeCode", 10) == 0 || strncasecmp(cfgReq.config, "cActiveCode", 11) == 0) {
|
||||||
|
if (cfgReq.dnodeId != -1) {
|
||||||
|
terrno = TSDB_CODE_INVALID_CFG;
|
||||||
|
goto _err_out;
|
||||||
|
}
|
||||||
int8_t opt = strncasecmp(cfgReq.config, "a", 1) == 0 ? DND_ACTIVE_CODE : DND_CONN_ACTIVE_CODE;
|
int8_t opt = strncasecmp(cfgReq.config, "a", 1) == 0 ? DND_ACTIVE_CODE : DND_CONN_ACTIVE_CODE;
|
||||||
int8_t index = opt == DND_ACTIVE_CODE ? 10 : 11;
|
int8_t index = opt == DND_ACTIVE_CODE ? 10 : 11;
|
||||||
if (' ' != cfgReq.config[index] && 0 != cfgReq.config[index]) {
|
if (' ' != cfgReq.config[index] && 0 != cfgReq.config[index]) {
|
||||||
|
@ -1304,9 +1308,8 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) {
|
||||||
strcpy(dcfgReq.config, opt == DND_ACTIVE_CODE ? "activeCode" : "cActiveCode");
|
strcpy(dcfgReq.config, opt == DND_ACTIVE_CODE ? "activeCode" : "cActiveCode");
|
||||||
snprintf(dcfgReq.value, TSDB_DNODE_VALUE_LEN, "%s", cfgReq.value);
|
snprintf(dcfgReq.value, TSDB_DNODE_VALUE_LEN, "%s", cfgReq.value);
|
||||||
|
|
||||||
if (mndConfigDnode(pMnode, pReq, &cfgReq, opt) != 0) {
|
if ((terrno = mndConfigDnode(pMnode, pReq, &cfgReq, opt)) != 0) {
|
||||||
mError("dnode:%d, failed to config activeCode since %s", cfgReq.dnodeId, terrstr());
|
mError("dnode:%d, failed to config activeCode since %s", cfgReq.dnodeId, terrstr());
|
||||||
terrno = TSDB_CODE_INVALID_CFG;
|
|
||||||
goto _err_out;
|
goto _err_out;
|
||||||
}
|
}
|
||||||
tFreeSMCfgDnodeReq(&cfgReq);
|
tFreeSMCfgDnodeReq(&cfgReq);
|
||||||
|
|
|
@ -444,6 +444,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_PAR_DEC_IVLD_KLEN, "Invalid klen to decod
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_GEN_IVLD_KEY, "Invalid key to gen active code")
|
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_GEN_IVLD_KEY, "Invalid key to gen active code")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_GEN_APP_LIMIT, "Limited app num to gen active code")
|
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_GEN_APP_LIMIT, "Limited app num to gen active code")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_GEN_ENC_IVLD_KLEN, "Invalid klen to encode active code")
|
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_GEN_ENC_IVLD_KLEN, "Invalid klen to encode active code")
|
||||||
|
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_PAR_IVLD_DIST, "Invalid dist to parse active code")
|
||||||
|
|
||||||
// sync
|
// sync
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_SYN_TIMEOUT, "Sync timeout")
|
TAOS_DEFINE_ERROR(TSDB_CODE_SYN_TIMEOUT, "Sync timeout")
|
||||||
|
|
Loading…
Reference in New Issue