enh: code optimization for active code
This commit is contained in:
parent
2cfb07548f
commit
3b62d555ab
|
@ -31,6 +31,8 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define GRANT_HEART_BEAT_MIN 2
|
#define GRANT_HEART_BEAT_MIN 2
|
||||||
|
#define GRANT_ACTIVE_CODE "activeCode"
|
||||||
|
#define GRANT_C_ACTIVE_CODE "cActiveCode"
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TSDB_GRANT_ALL,
|
TSDB_GRANT_ALL,
|
||||||
|
|
|
@ -790,7 +790,9 @@ static int32_t mndConfigDnode(SMnode *pMnode, SRpcMsg *pReq, SMCfgDnodeReq *pCfg
|
||||||
if (cfgAll) { // alter all dnodes:
|
if (cfgAll) { // alter all dnodes:
|
||||||
if (!failRecord) failRecord = taosArrayInit(1, sizeof(int32_t));
|
if (!failRecord) failRecord = taosArrayInit(1, sizeof(int32_t));
|
||||||
if (failRecord) taosArrayPush(failRecord, &pDnode->id);
|
if (failRecord) taosArrayPush(failRecord, &pDnode->id);
|
||||||
if (0 == cfgAllErr) cfgAllErr = terrno; // output 1st terrno.
|
if (0 == cfgAllErr || cfgAllErr == TSDB_CODE_GRANT_PAR_IVLD_ACTIVE) {
|
||||||
|
cfgAllErr = terrno; // output 1st or more specific error
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
terrno = 0; // no action for dup active code
|
terrno = 0; // no action for dup active code
|
||||||
|
@ -806,7 +808,9 @@ static int32_t mndConfigDnode(SMnode *pMnode, SRpcMsg *pReq, SMCfgDnodeReq *pCfg
|
||||||
if (cfgAll) {
|
if (cfgAll) {
|
||||||
if (!failRecord) failRecord = taosArrayInit(1, sizeof(int32_t));
|
if (!failRecord) failRecord = taosArrayInit(1, sizeof(int32_t));
|
||||||
if (failRecord) taosArrayPush(failRecord, &pDnode->id);
|
if (failRecord) taosArrayPush(failRecord, &pDnode->id);
|
||||||
if (0 == cfgAllErr) cfgAllErr = terrno;
|
if (0 == cfgAllErr || cfgAllErr == TSDB_CODE_GRANT_PAR_IVLD_ACTIVE) {
|
||||||
|
cfgAllErr = terrno; // output 1st or more specific error
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
terrno = 0;
|
terrno = 0;
|
||||||
|
@ -1283,7 +1287,8 @@ 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, GRANT_ACTIVE_CODE, 10) == 0 ||
|
||||||
|
strncasecmp(cfgReq.config, GRANT_C_ACTIVE_CODE, 11) == 0) {
|
||||||
if (cfgReq.dnodeId != -1) {
|
if (cfgReq.dnodeId != -1) {
|
||||||
terrno = TSDB_CODE_INVALID_CFG;
|
terrno = TSDB_CODE_INVALID_CFG;
|
||||||
goto _err_out;
|
goto _err_out;
|
||||||
|
@ -1305,7 +1310,7 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) {
|
||||||
goto _err_out;
|
goto _err_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(dcfgReq.config, opt == DND_ACTIVE_CODE ? "activeCode" : "cActiveCode");
|
strcpy(dcfgReq.config, opt == DND_ACTIVE_CODE ? GRANT_ACTIVE_CODE : GRANT_C_ACTIVE_CODE);
|
||||||
snprintf(dcfgReq.value, TSDB_DNODE_VALUE_LEN, "%s", cfgReq.value);
|
snprintf(dcfgReq.value, TSDB_DNODE_VALUE_LEN, "%s", cfgReq.value);
|
||||||
|
|
||||||
if ((terrno = mndConfigDnode(pMnode, pReq, &cfgReq, opt)) != 0) {
|
if ((terrno = mndConfigDnode(pMnode, pReq, &cfgReq, opt)) != 0) {
|
||||||
|
|
Loading…
Reference in New Issue