From ac8220012c88400bf7ab1585b027ace4da5dc887 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Wed, 6 Sep 2023 17:22:30 +0800 Subject: [PATCH] add rpc update interface --- include/common/tmsg.h | 2 ++ source/common/src/tmsg.c | 8 ++++++ source/dnode/mgmt/mgmt_dnode/inc/dmInt.h | 31 +++++++++++---------- source/dnode/mgmt/mgmt_dnode/src/dmHandle.c | 4 +++ source/dnode/mnode/impl/inc/mndUser.h | 6 ++-- source/dnode/mnode/impl/src/mndDnode.c | 1 + source/dnode/mnode/impl/src/mndUser.c | 2 +- 7 files changed, 36 insertions(+), 18 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index e5ec7f48c3..70fa864853 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -1469,6 +1469,7 @@ typedef struct { SClusterCfg clusterCfg; SArray* pVloads; // array of SVnodeLoad int32_t statusSeq; + int64_t ipWhiteVer; } SStatusReq; int32_t tSerializeSStatusReq(void* buf, int32_t bufLen, SStatusReq* pReq); @@ -1499,6 +1500,7 @@ typedef struct { SDnodeCfg dnodeCfg; SArray* pDnodeEps; // Array of SDnodeEp int32_t statusSeq; + int64_t ipWhiteVer; } SStatusRsp; int32_t tSerializeSStatusRsp(void* buf, int32_t bufLen, SStatusRsp* pRsp); diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index e581a2d5df..6957c70706 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -1116,6 +1116,8 @@ int32_t tSerializeSStatusReq(void *buf, int32_t bufLen, SStatusReq *pReq) { if (tEncodeI64(&encoder, reserved) < 0) return -1; if (tEncodeI64(&encoder, reserved) < 0) return -1; } + + if (tEncodeI64(&encoder, pReq->ipWhiteVer) < 0) return -1; tEndEncode(&encoder); int32_t tlen = encoder.pos; @@ -1226,6 +1228,9 @@ int32_t tDeserializeSStatusReq(void *buf, int32_t bufLen, SStatusReq *pReq) { if (tDecodeI64(&decoder, &reserved) < 0) return -1; } } + + if (tDecodeI64(&decoder, &pReq->ipWhiteVer) < 0) return -1; + tEndDecode(&decoder); tDecoderClear(&decoder); return 0; @@ -1258,6 +1263,8 @@ int32_t tSerializeSStatusRsp(void *buf, int32_t bufLen, SStatusRsp *pRsp) { } if (tEncodeI32(&encoder, pRsp->statusSeq) < 0) return -1; + + if (tEncodeI64(&encoder, pRsp->ipWhiteVer) < 0) return -1; tEndEncode(&encoder); int32_t tlen = encoder.pos; @@ -1300,6 +1307,7 @@ int32_t tDeserializeSStatusRsp(void *buf, int32_t bufLen, SStatusRsp *pRsp) { } if (tDecodeI32(&decoder, &pRsp->statusSeq) < 0) return -1; + if (tDecodeI64(&decoder, &pRsp->ipWhiteVer) < 0) return -1; tEndDecode(&decoder); tDecoderClear(&decoder); return 0; diff --git a/source/dnode/mgmt/mgmt_dnode/inc/dmInt.h b/source/dnode/mgmt/mgmt_dnode/inc/dmInt.h index 6c40fa808f..6551183de0 100644 --- a/source/dnode/mgmt/mgmt_dnode/inc/dmInt.h +++ b/source/dnode/mgmt/mgmt_dnode/inc/dmInt.h @@ -23,22 +23,23 @@ extern "C" { #endif typedef struct SDnodeMgmt { - SDnodeData *pData; - SMsgCb msgCb; - const char *path; - const char *name; - TdThread statusThread; - TdThread monitorThread; - TdThread crashReportThread; - SSingleWorker mgmtWorker; - ProcessCreateNodeFp processCreateNodeFp; + SDnodeData *pData; + SMsgCb msgCb; + const char *path; + const char *name; + TdThread statusThread; + TdThread monitorThread; + TdThread crashReportThread; + SSingleWorker mgmtWorker; + ProcessCreateNodeFp processCreateNodeFp; ProcessAlterNodeTypeFp processAlterNodeTypeFp; - ProcessDropNodeFp processDropNodeFp; - SendMonitorReportFp sendMonitorReportFp; - GetVnodeLoadsFp getVnodeLoadsFp; - GetMnodeLoadsFp getMnodeLoadsFp; - GetQnodeLoadsFp getQnodeLoadsFp; - int32_t statusSeq; + ProcessDropNodeFp processDropNodeFp; + SendMonitorReportFp sendMonitorReportFp; + GetVnodeLoadsFp getVnodeLoadsFp; + GetMnodeLoadsFp getMnodeLoadsFp; + GetQnodeLoadsFp getQnodeLoadsFp; + int32_t statusSeq; + int64_t ipWhiteVer; } SDnodeMgmt; // dmHandle.c diff --git a/source/dnode/mgmt/mgmt_dnode/src/dmHandle.c b/source/dnode/mgmt/mgmt_dnode/src/dmHandle.c index e6b7c0cb68..ef474f0cde 100644 --- a/source/dnode/mgmt/mgmt_dnode/src/dmHandle.c +++ b/source/dnode/mgmt/mgmt_dnode/src/dmHandle.c @@ -55,6 +55,10 @@ static void dmProcessStatusRsp(SDnodeMgmt *pMgmt, SRpcMsg *pRsp) { dmUpdateDnodeCfg(pMgmt, &statusRsp.dnodeCfg); dmUpdateEps(pMgmt->pData, statusRsp.pDnodeEps); } + + if (pMgmt->ipWhiteVer != statusRsp.ipWhiteVer) { + // + } } tFreeSStatusRsp(&statusRsp); } diff --git a/source/dnode/mnode/impl/inc/mndUser.h b/source/dnode/mnode/impl/inc/mndUser.h index 8b930e7f18..e9847f439d 100644 --- a/source/dnode/mnode/impl/inc/mndUser.h +++ b/source/dnode/mnode/impl/inc/mndUser.h @@ -38,8 +38,10 @@ int32_t mndValidateUserAuthInfo(SMnode *pMnode, SUserAuthVersion *pUsers, int3 int32_t mndUserRemoveDb(SMnode *pMnode, STrans *pTrans, char *db); int32_t mndUserRemoveTopic(SMnode *pMnode, STrans *pTrans, char *topic); -int32_t mndUserDupObj(SUserObj *pUser, SUserObj *pNew); -void mndUserFreeObj(SUserObj *pUser); +int32_t mndUserDupObj(SUserObj *pUser, SUserObj *pNew); +void mndUserFreeObj(SUserObj *pUser); + +int64_t mndGetIpWhiteVer(SMnode *pMnode); #ifdef __cplusplus } #endif diff --git a/source/dnode/mnode/impl/src/mndDnode.c b/source/dnode/mnode/impl/src/mndDnode.c index a11bd2556e..b18fab2eee 100644 --- a/source/dnode/mnode/impl/src/mndDnode.c +++ b/source/dnode/mnode/impl/src/mndDnode.c @@ -645,6 +645,7 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) { } mndGetDnodeEps(pMnode, statusRsp.pDnodeEps); + statusRsp.ipWhiteVer = mndGetIpWhiteVer(pMnode); int32_t contLen = tSerializeSStatusRsp(NULL, 0, &statusRsp); void *pHead = rpcMallocCont(contLen); diff --git a/source/dnode/mnode/impl/src/mndUser.c b/source/dnode/mnode/impl/src/mndUser.c index 1a0134ea46..0c89b12734 100644 --- a/source/dnode/mnode/impl/src/mndUser.c +++ b/source/dnode/mnode/impl/src/mndUser.c @@ -113,7 +113,7 @@ void ipWhiteMgtUpdate2(SMnode *pMnode) { taosThreadRwlockUnlock(&ipWhiteMgt.rw); } -int64_t ipWhiteMgtGetVer(SMnode *pMnode) { +int64_t mndGetIpWhiteVer(SMnode *pMnode) { taosThreadRwlockWrlock(&ipWhiteMgt.rw); int64_t ver = ipWhiteMgt.ver; if (ver == 0) {