feat/TS-5805-add-sql-command
This commit is contained in:
parent
513e564adb
commit
d9401fd75d
|
@ -359,6 +359,7 @@ typedef enum ENodeType {
|
||||||
QUERY_NODE_CREATE_ANODE_STMT,
|
QUERY_NODE_CREATE_ANODE_STMT,
|
||||||
QUERY_NODE_DROP_ANODE_STMT,
|
QUERY_NODE_DROP_ANODE_STMT,
|
||||||
QUERY_NODE_UPDATE_ANODE_STMT,
|
QUERY_NODE_UPDATE_ANODE_STMT,
|
||||||
|
QUERY_NODE_ASSIGN_LEADER_STMT,
|
||||||
|
|
||||||
// show statement nodes
|
// show statement nodes
|
||||||
// see 'sysTableShowAdapter', 'SYSTABLE_SHOW_TYPE_OFFSET'
|
// see 'sysTableShowAdapter', 'SYSTABLE_SHOW_TYPE_OFFSET'
|
||||||
|
@ -2653,6 +2654,15 @@ int32_t tSerializeSBalanceVgroupReq(void* buf, int32_t bufLen, SBalanceVgroupReq
|
||||||
int32_t tDeserializeSBalanceVgroupReq(void* buf, int32_t bufLen, SBalanceVgroupReq* pReq);
|
int32_t tDeserializeSBalanceVgroupReq(void* buf, int32_t bufLen, SBalanceVgroupReq* pReq);
|
||||||
void tFreeSBalanceVgroupReq(SBalanceVgroupReq* pReq);
|
void tFreeSBalanceVgroupReq(SBalanceVgroupReq* pReq);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int32_t useless; // useless
|
||||||
|
int32_t sqlLen;
|
||||||
|
char* sql;
|
||||||
|
} SAssignLeaderReq;
|
||||||
|
|
||||||
|
int32_t tSerializeSAssignLeaderReq(void* buf, int32_t bufLen, SAssignLeaderReq* pReq);
|
||||||
|
int32_t tDeserializeSAssignLeaderReq(void* buf, int32_t bufLen, SAssignLeaderReq* pReq);
|
||||||
|
void tFreeSAssignLeaderReq(SAssignLeaderReq* pReq);
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t vgId1;
|
int32_t vgId1;
|
||||||
int32_t vgId2;
|
int32_t vgId2;
|
||||||
|
|
|
@ -263,6 +263,7 @@
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_CONFIG, "init-config", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_CONFIG, "init-config", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_CONFIG_SDB, "config-sdb", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_CONFIG_SDB, "config-sdb", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_RESET_STREAM, "reset-stream", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_RESET_STREAM, "reset-stream", NULL, NULL)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_MND_ASSIGN_LEADER, "assign-leader", NULL, NULL)
|
||||||
TD_CLOSE_MSG_SEG(TDMT_END_MND_MSG)
|
TD_CLOSE_MSG_SEG(TDMT_END_MND_MSG)
|
||||||
|
|
||||||
TD_NEW_MSG_SEG(TDMT_VND_MSG) // 2<<8
|
TD_NEW_MSG_SEG(TDMT_VND_MSG) // 2<<8
|
||||||
|
|
|
@ -681,6 +681,10 @@ typedef struct SBalanceVgroupStmt {
|
||||||
ENodeType type;
|
ENodeType type;
|
||||||
} SBalanceVgroupStmt;
|
} SBalanceVgroupStmt;
|
||||||
|
|
||||||
|
typedef struct SAssignLeaderStmt {
|
||||||
|
ENodeType type;
|
||||||
|
} SAssignLeaderStmt;
|
||||||
|
|
||||||
typedef struct SBalanceVgroupLeaderStmt {
|
typedef struct SBalanceVgroupLeaderStmt {
|
||||||
ENodeType type;
|
ENodeType type;
|
||||||
int32_t vgId;
|
int32_t vgId;
|
||||||
|
|
|
@ -7644,6 +7644,46 @@ _exit:
|
||||||
|
|
||||||
void tFreeSBalanceVgroupReq(SBalanceVgroupReq *pReq) { FREESQL(); }
|
void tFreeSBalanceVgroupReq(SBalanceVgroupReq *pReq) { FREESQL(); }
|
||||||
|
|
||||||
|
int32_t tSerializeSAssignLeaderReq(void *buf, int32_t bufLen, SAssignLeaderReq *pReq) {
|
||||||
|
SEncoder encoder = {0};
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t lino;
|
||||||
|
int32_t tlen;
|
||||||
|
tEncoderInit(&encoder, buf, bufLen);
|
||||||
|
|
||||||
|
TAOS_CHECK_EXIT(tStartEncode(&encoder));
|
||||||
|
TAOS_CHECK_EXIT(tEncodeI32(&encoder, pReq->useless));
|
||||||
|
ENCODESQL();
|
||||||
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
|
_exit:
|
||||||
|
if (code) {
|
||||||
|
tlen = code;
|
||||||
|
} else {
|
||||||
|
tlen = encoder.pos;
|
||||||
|
}
|
||||||
|
tEncoderClear(&encoder);
|
||||||
|
return tlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tDeserializeSAssignLeaderReq(void *buf, int32_t bufLen, SAssignLeaderReq *pReq) {
|
||||||
|
SDecoder decoder = {0};
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t lino;
|
||||||
|
tDecoderInit(&decoder, buf, bufLen);
|
||||||
|
|
||||||
|
TAOS_CHECK_EXIT(tStartDecode(&decoder));
|
||||||
|
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &pReq->useless));
|
||||||
|
DECODESQL();
|
||||||
|
tEndDecode(&decoder);
|
||||||
|
|
||||||
|
_exit:
|
||||||
|
tDecoderClear(&decoder);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tFreeSAssignLeaderReq(SAssignLeaderReq *pReq) { FREESQL(); }
|
||||||
|
|
||||||
int32_t tSerializeSBalanceVgroupLeaderReq(void *buf, int32_t bufLen, SBalanceVgroupLeaderReq *pReq) {
|
int32_t tSerializeSBalanceVgroupLeaderReq(void *buf, int32_t bufLen, SBalanceVgroupLeaderReq *pReq) {
|
||||||
SEncoder encoder = {0};
|
SEncoder encoder = {0};
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
|
@ -160,6 +160,7 @@ SArray *mmGetMsgHandles() {
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_MERGE_VGROUP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_MERGE_VGROUP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_SPLIT_VGROUP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_SPLIT_VGROUP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_BALANCE_VGROUP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_BALANCE_VGROUP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
|
if (dmSetMgmtHandle(pArray, TDMT_MND_ASSIGN_LEADER, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_BALANCE_VGROUP_LEADER, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_BALANCE_VGROUP_LEADER, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_FUNC, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_FUNC, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_RETRIEVE_FUNC, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_RETRIEVE_FUNC, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
|
@ -46,6 +46,7 @@ static int32_t mndProcessRedistributeVgroupMsg(SRpcMsg *pReq);
|
||||||
static int32_t mndProcessSplitVgroupMsg(SRpcMsg *pReq);
|
static int32_t mndProcessSplitVgroupMsg(SRpcMsg *pReq);
|
||||||
static int32_t mndProcessBalanceVgroupMsg(SRpcMsg *pReq);
|
static int32_t mndProcessBalanceVgroupMsg(SRpcMsg *pReq);
|
||||||
static int32_t mndProcessVgroupBalanceLeaderMsg(SRpcMsg *pReq);
|
static int32_t mndProcessVgroupBalanceLeaderMsg(SRpcMsg *pReq);
|
||||||
|
static int32_t mndProcessAssignLeaderMsg(SRpcMsg *pReq);
|
||||||
|
|
||||||
int32_t mndInitVgroup(SMnode *pMnode) {
|
int32_t mndInitVgroup(SMnode *pMnode) {
|
||||||
SSdbTable table = {
|
SSdbTable table = {
|
||||||
|
@ -77,6 +78,7 @@ int32_t mndInitVgroup(SMnode *pMnode) {
|
||||||
// mndSetMsgHandle(pMnode, TDMT_MND_BALANCE_VGROUP, mndProcessVgroupBalanceLeaderMsg);
|
// mndSetMsgHandle(pMnode, TDMT_MND_BALANCE_VGROUP, mndProcessVgroupBalanceLeaderMsg);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_BALANCE_VGROUP, mndProcessBalanceVgroupMsg);
|
mndSetMsgHandle(pMnode, TDMT_MND_BALANCE_VGROUP, mndProcessBalanceVgroupMsg);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_BALANCE_VGROUP_LEADER, mndProcessVgroupBalanceLeaderMsg);
|
mndSetMsgHandle(pMnode, TDMT_MND_BALANCE_VGROUP_LEADER, mndProcessVgroupBalanceLeaderMsg);
|
||||||
|
mndSetMsgHandle(pMnode, TDMT_MND_ASSIGN_LEADER, mndProcessAssignLeaderMsg);
|
||||||
|
|
||||||
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_VGROUP, mndRetrieveVgroups);
|
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_VGROUP, mndRetrieveVgroups);
|
||||||
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_VGROUP, mndCancelGetNextVgroup);
|
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_VGROUP, mndCancelGetNextVgroup);
|
||||||
|
@ -3570,6 +3572,30 @@ _OVER:
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t mndProcessAssignLeaderMsg(SRpcMsg *pReq){
|
||||||
|
SMnode *pMnode = pReq->info.node;
|
||||||
|
int32_t code = -1;
|
||||||
|
SArray *pArray = NULL;
|
||||||
|
void *pIter = NULL;
|
||||||
|
int64_t curMs = taosGetTimestampMs();
|
||||||
|
|
||||||
|
SAssignLeaderReq req = {0};
|
||||||
|
if (tDeserializeSAssignLeaderReq(pReq->pCont, pReq->contLen, &req) != 0) {
|
||||||
|
code = TSDB_CODE_INVALID_MSG;
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
auditRecord(pReq, pMnode->clusterId, "assignLeader", "", "", req.sql, req.sqlLen);
|
||||||
|
|
||||||
|
_OVER:
|
||||||
|
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||||
|
mError("failed to assign leader since %s", tstrerror(code));
|
||||||
|
}
|
||||||
|
|
||||||
|
tFreeSAssignLeaderReq(&req);
|
||||||
|
TAOS_RETURN(code);
|
||||||
|
}
|
||||||
|
|
||||||
bool mndVgroupInDb(SVgObj *pVgroup, int64_t dbUid) { return !pVgroup->isTsma && pVgroup->dbUid == dbUid; }
|
bool mndVgroupInDb(SVgObj *pVgroup, int64_t dbUid) { return !pVgroup->isTsma && pVgroup->dbUid == dbUid; }
|
||||||
|
|
||||||
bool mndVgroupInDnode(SVgObj *pVgroup, int32_t dnodeId) {
|
bool mndVgroupInDnode(SVgObj *pVgroup, int32_t dnodeId) {
|
||||||
|
|
|
@ -199,6 +199,8 @@ const char* nodesNodeName(ENodeType type) {
|
||||||
return "ResetStreamStmt";
|
return "ResetStreamStmt";
|
||||||
case QUERY_NODE_BALANCE_VGROUP_STMT:
|
case QUERY_NODE_BALANCE_VGROUP_STMT:
|
||||||
return "BalanceVgroupStmt";
|
return "BalanceVgroupStmt";
|
||||||
|
case QUERY_NODE_ASSIGN_LEADER_STMT:
|
||||||
|
return "AssignLeaderStmt";
|
||||||
case QUERY_NODE_BALANCE_VGROUP_LEADER_STMT:
|
case QUERY_NODE_BALANCE_VGROUP_LEADER_STMT:
|
||||||
return "BalanceVgroupLeaderStmt";
|
return "BalanceVgroupLeaderStmt";
|
||||||
case QUERY_NODE_BALANCE_VGROUP_LEADER_DATABASE_STMT:
|
case QUERY_NODE_BALANCE_VGROUP_LEADER_DATABASE_STMT:
|
||||||
|
@ -8167,6 +8169,8 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
return dropStreamStmtToJson(pObj, pJson);
|
return dropStreamStmtToJson(pObj, pJson);
|
||||||
case QUERY_NODE_BALANCE_VGROUP_STMT:
|
case QUERY_NODE_BALANCE_VGROUP_STMT:
|
||||||
return TSDB_CODE_SUCCESS; // SBalanceVgroupStmt has no fields to serialize.
|
return TSDB_CODE_SUCCESS; // SBalanceVgroupStmt has no fields to serialize.
|
||||||
|
case QUERY_NODE_ASSIGN_LEADER_STMT:
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
case QUERY_NODE_BALANCE_VGROUP_LEADER_STMT:
|
case QUERY_NODE_BALANCE_VGROUP_LEADER_STMT:
|
||||||
return TSDB_CODE_SUCCESS; // SBalanceVgroupLeaderStmt has no fields to serialize.
|
return TSDB_CODE_SUCCESS; // SBalanceVgroupLeaderStmt has no fields to serialize.
|
||||||
case QUERY_NODE_BALANCE_VGROUP_LEADER_DATABASE_STMT:
|
case QUERY_NODE_BALANCE_VGROUP_LEADER_DATABASE_STMT:
|
||||||
|
@ -8536,6 +8540,8 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
|
||||||
return jsonToDropStreamStmt(pJson, pObj);
|
return jsonToDropStreamStmt(pJson, pObj);
|
||||||
case QUERY_NODE_BALANCE_VGROUP_STMT:
|
case QUERY_NODE_BALANCE_VGROUP_STMT:
|
||||||
return TSDB_CODE_SUCCESS; // SBalanceVgroupStmt has no fields to deserialize.
|
return TSDB_CODE_SUCCESS; // SBalanceVgroupStmt has no fields to deserialize.
|
||||||
|
case QUERY_NODE_ASSIGN_LEADER_STMT:
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
case QUERY_NODE_BALANCE_VGROUP_LEADER_STMT:
|
case QUERY_NODE_BALANCE_VGROUP_LEADER_STMT:
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
case QUERY_NODE_BALANCE_VGROUP_LEADER_DATABASE_STMT:
|
case QUERY_NODE_BALANCE_VGROUP_LEADER_DATABASE_STMT:
|
||||||
|
|
|
@ -624,6 +624,9 @@ int32_t nodesMakeNode(ENodeType type, SNode** ppNodeOut) {
|
||||||
case QUERY_NODE_BALANCE_VGROUP_STMT:
|
case QUERY_NODE_BALANCE_VGROUP_STMT:
|
||||||
code = makeNode(type, sizeof(SBalanceVgroupStmt), &pNode);
|
code = makeNode(type, sizeof(SBalanceVgroupStmt), &pNode);
|
||||||
break;
|
break;
|
||||||
|
case QUERY_NODE_ASSIGN_LEADER_STMT:
|
||||||
|
code = makeNode(type, sizeof(SAssignLeaderStmt), &pNode);
|
||||||
|
break;
|
||||||
case QUERY_NODE_BALANCE_VGROUP_LEADER_STMT:
|
case QUERY_NODE_BALANCE_VGROUP_LEADER_STMT:
|
||||||
code = makeNode(type, sizeof(SBalanceVgroupLeaderStmt), &pNode);
|
code = makeNode(type, sizeof(SBalanceVgroupLeaderStmt), &pNode);
|
||||||
break;
|
break;
|
||||||
|
@ -1497,6 +1500,7 @@ void nodesDestroyNode(SNode* pNode) {
|
||||||
case QUERY_NODE_RESUME_STREAM_STMT: // no pointer field
|
case QUERY_NODE_RESUME_STREAM_STMT: // no pointer field
|
||||||
case QUERY_NODE_RESET_STREAM_STMT: // no pointer field
|
case QUERY_NODE_RESET_STREAM_STMT: // no pointer field
|
||||||
case QUERY_NODE_BALANCE_VGROUP_STMT: // no pointer field
|
case QUERY_NODE_BALANCE_VGROUP_STMT: // no pointer field
|
||||||
|
case QUERY_NODE_ASSIGN_LEADER_STMT:
|
||||||
case QUERY_NODE_BALANCE_VGROUP_LEADER_STMT: // no pointer field
|
case QUERY_NODE_BALANCE_VGROUP_LEADER_STMT: // no pointer field
|
||||||
case QUERY_NODE_BALANCE_VGROUP_LEADER_DATABASE_STMT: // no pointer field
|
case QUERY_NODE_BALANCE_VGROUP_LEADER_DATABASE_STMT: // no pointer field
|
||||||
case QUERY_NODE_MERGE_VGROUP_STMT: // no pointer field
|
case QUERY_NODE_MERGE_VGROUP_STMT: // no pointer field
|
||||||
|
|
|
@ -309,6 +309,7 @@ SNode* createResetStreamStmt(SAstCreateContext* pCxt, bool ignoreNotExists, STok
|
||||||
SNode* createKillStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pId);
|
SNode* createKillStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pId);
|
||||||
SNode* createKillQueryStmt(SAstCreateContext* pCxt, const SToken* pQueryId);
|
SNode* createKillQueryStmt(SAstCreateContext* pCxt, const SToken* pQueryId);
|
||||||
SNode* createBalanceVgroupStmt(SAstCreateContext* pCxt);
|
SNode* createBalanceVgroupStmt(SAstCreateContext* pCxt);
|
||||||
|
SNode* createAssingLeaderStmt(SAstCreateContext* pCxt);
|
||||||
SNode* createBalanceVgroupLeaderStmt(SAstCreateContext* pCxt, const SToken* pVgId);
|
SNode* createBalanceVgroupLeaderStmt(SAstCreateContext* pCxt, const SToken* pVgId);
|
||||||
SNode* createBalanceVgroupLeaderDBNameStmt(SAstCreateContext* pCxt, const SToken* pDbName);
|
SNode* createBalanceVgroupLeaderDBNameStmt(SAstCreateContext* pCxt, const SToken* pDbName);
|
||||||
SNode* createMergeVgroupStmt(SAstCreateContext* pCxt, const SToken* pVgId1, const SToken* pVgId2);
|
SNode* createMergeVgroupStmt(SAstCreateContext* pCxt, const SToken* pVgId1, const SToken* pVgId2);
|
||||||
|
|
|
@ -860,6 +860,9 @@ cmd ::= KILL COMPACT NK_INTEGER(A).
|
||||||
|
|
||||||
/************************************************ merge/redistribute/ vgroup ******************************************/
|
/************************************************ merge/redistribute/ vgroup ******************************************/
|
||||||
cmd ::= BALANCE VGROUP. { pCxt->pRootNode = createBalanceVgroupStmt(pCxt); }
|
cmd ::= BALANCE VGROUP. { pCxt->pRootNode = createBalanceVgroupStmt(pCxt); }
|
||||||
|
|
||||||
|
cmd ::= ASSIGN LEADER FORCE. { pCxt->pRootNode = createBalanceVgroupStmt(pCxt); }
|
||||||
|
|
||||||
cmd ::= BALANCE VGROUP LEADER on_vgroup_id(A). { pCxt->pRootNode = createBalanceVgroupLeaderStmt(pCxt, &A); }
|
cmd ::= BALANCE VGROUP LEADER on_vgroup_id(A). { pCxt->pRootNode = createBalanceVgroupLeaderStmt(pCxt, &A); }
|
||||||
cmd ::= BALANCE VGROUP LEADER DATABASE db_name(A). { pCxt->pRootNode = createBalanceVgroupLeaderDBNameStmt(pCxt, &A); }
|
cmd ::= BALANCE VGROUP LEADER DATABASE db_name(A). { pCxt->pRootNode = createBalanceVgroupLeaderDBNameStmt(pCxt, &A); }
|
||||||
cmd ::= MERGE VGROUP NK_INTEGER(A) NK_INTEGER(B). { pCxt->pRootNode = createMergeVgroupStmt(pCxt, &A, &B); }
|
cmd ::= MERGE VGROUP NK_INTEGER(A) NK_INTEGER(B). { pCxt->pRootNode = createMergeVgroupStmt(pCxt, &A, &B); }
|
||||||
|
|
|
@ -3873,7 +3873,7 @@ _err:
|
||||||
|
|
||||||
SNode* createBalanceVgroupStmt(SAstCreateContext* pCxt) {
|
SNode* createBalanceVgroupStmt(SAstCreateContext* pCxt) {
|
||||||
CHECK_PARSER_STATUS(pCxt);
|
CHECK_PARSER_STATUS(pCxt);
|
||||||
SBalanceVgroupStmt* pStmt = NULL;
|
SAssignLeaderStmt* pStmt = NULL;
|
||||||
pCxt->errCode = nodesMakeNode(QUERY_NODE_BALANCE_VGROUP_STMT, (SNode**)&pStmt);
|
pCxt->errCode = nodesMakeNode(QUERY_NODE_BALANCE_VGROUP_STMT, (SNode**)&pStmt);
|
||||||
CHECK_MAKE_NODE(pStmt);
|
CHECK_MAKE_NODE(pStmt);
|
||||||
return (SNode*)pStmt;
|
return (SNode*)pStmt;
|
||||||
|
@ -3881,6 +3881,16 @@ _err:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SNode* createAssignLeaderStmt(SAstCreateContext* pCxt) {
|
||||||
|
CHECK_PARSER_STATUS(pCxt);
|
||||||
|
SBalanceVgroupStmt* pStmt = NULL;
|
||||||
|
pCxt->errCode = nodesMakeNode(QUERY_NODE_ASSIGN_LEADER_STMT, (SNode**)&pStmt);
|
||||||
|
CHECK_MAKE_NODE(pStmt);
|
||||||
|
return (SNode*)pStmt;
|
||||||
|
_err:
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
SNode* createBalanceVgroupLeaderStmt(SAstCreateContext* pCxt, const SToken* pVgId) {
|
SNode* createBalanceVgroupLeaderStmt(SAstCreateContext* pCxt, const SToken* pVgId) {
|
||||||
CHECK_PARSER_STATUS(pCxt);
|
CHECK_PARSER_STATUS(pCxt);
|
||||||
SBalanceVgroupLeaderStmt* pStmt = NULL;
|
SBalanceVgroupLeaderStmt* pStmt = NULL;
|
||||||
|
|
|
@ -8490,6 +8490,10 @@ static int32_t fillCmdSql(STranslateContext* pCxt, int16_t msgType, void* pReq)
|
||||||
FILL_CMD_SQL(sql, sqlLen, pCmdReq, SBalanceVgroupReq, pReq);
|
FILL_CMD_SQL(sql, sqlLen, pCmdReq, SBalanceVgroupReq, pReq);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case TDMT_MND_ASSIGN_LEADER: {
|
||||||
|
FILL_CMD_SQL(sql, sqlLen, pCmdReq, SAssignLeaderReq, pReq);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case TDMT_MND_REDISTRIBUTE_VGROUP: {
|
case TDMT_MND_REDISTRIBUTE_VGROUP: {
|
||||||
FILL_CMD_SQL(sql, sqlLen, pCmdReq, SRedistributeVgroupReq, pReq);
|
FILL_CMD_SQL(sql, sqlLen, pCmdReq, SRedistributeVgroupReq, pReq);
|
||||||
break;
|
break;
|
||||||
|
@ -12738,6 +12742,13 @@ static int32_t translateBalanceVgroup(STranslateContext* pCxt, SBalanceVgroupStm
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t translateAssignLeader(STranslateContext* pCxt, SAssignLeaderStmt* pStmt) {
|
||||||
|
SAssignLeaderReq req = {0};
|
||||||
|
int32_t code = buildCmdMsg(pCxt, TDMT_MND_BALANCE_VGROUP, (FSerializeFunc)tSerializeSAssignLeaderReq, &req);
|
||||||
|
tFreeSAssignLeaderReq(&req);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t translateBalanceVgroupLeader(STranslateContext* pCxt, SBalanceVgroupLeaderStmt* pStmt) {
|
static int32_t translateBalanceVgroupLeader(STranslateContext* pCxt, SBalanceVgroupLeaderStmt* pStmt) {
|
||||||
SBalanceVgroupLeaderReq req = {0};
|
SBalanceVgroupLeaderReq req = {0};
|
||||||
req.vgId = pStmt->vgId;
|
req.vgId = pStmt->vgId;
|
||||||
|
@ -13495,6 +13506,9 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) {
|
||||||
case QUERY_NODE_BALANCE_VGROUP_STMT:
|
case QUERY_NODE_BALANCE_VGROUP_STMT:
|
||||||
code = translateBalanceVgroup(pCxt, (SBalanceVgroupStmt*)pNode);
|
code = translateBalanceVgroup(pCxt, (SBalanceVgroupStmt*)pNode);
|
||||||
break;
|
break;
|
||||||
|
case QUERY_NODE_ASSIGN_LEADER_STMT:
|
||||||
|
code = translateAssignLeader(pCxt, (SAssignLeaderStmt*)pNode);
|
||||||
|
break;
|
||||||
case QUERY_NODE_BALANCE_VGROUP_LEADER_STMT:
|
case QUERY_NODE_BALANCE_VGROUP_LEADER_STMT:
|
||||||
code = translateBalanceVgroupLeader(pCxt, (SBalanceVgroupLeaderStmt*)pNode);
|
code = translateBalanceVgroupLeader(pCxt, (SBalanceVgroupLeaderStmt*)pNode);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue