diff --git a/src/dnode/inc/dnodeSystem.h b/src/dnode/inc/dnodeSystem.h index d2c29845997b591b53b70eb31b3793e3a72dd7a1..7aeb26b54ff9afd7390a12d31dc4307eb302bceb 100644 --- a/src/dnode/inc/dnodeSystem.h +++ b/src/dnode/inc/dnodeSystem.h @@ -33,7 +33,6 @@ extern int32_t (*dnodeInitPeers)(int32_t numOfThreads); extern int32_t (*dnodeCheckSystem)(); extern int32_t (*dnodeInitStorage)(); extern void (*dnodeCleanupStorage)(); -extern void (*dnodeParseParameterK)(); extern int32_t tsMaxQueues; extern void ** tsRpcQhandle; extern void *tsQueryQhandle; diff --git a/src/dnode/src/dnodeService.c b/src/dnode/src/dnodeService.c index d7f9721fda9091efeb06d72f9fad2f76b4f65ebc..a8a110ab4cff681d79fb68782b6ab782bb3820c2 100644 --- a/src/dnode/src/dnodeService.c +++ b/src/dnode/src/dnodeService.c @@ -19,6 +19,8 @@ #include "tglobalcfg.h" #include "dnodeSystem.h" +void (*dnodeParseParameterKFp)() = NULL; + /* * Termination handler */ @@ -63,7 +65,9 @@ int main(int argc, char *argv[]) { printf("buildinfo: %s\n", buildinfo); return 0; } else if (strcmp(argv[i], "-k") == 0) { - dnodeParseParameterK(); + if (dnodeParseParameterKFp) { + dnodeParseParameterKFp(); + } #ifdef TAOS_MEM_CHECK } else if (strcmp(argv[i], "--alloc-random-fail") == 0) { if ((i < argc - 1) && (argv[i+1][0] != '-')) { diff --git a/src/dnode/src/dnodeSystem.c b/src/dnode/src/dnodeSystem.c index 23962ec075b4d2fe1e7833ec4387d0af8fde7550..67a1d42565dfac1316833208ee1c0e89bddc5293 100644 --- a/src/dnode/src/dnodeSystem.c +++ b/src/dnode/src/dnodeSystem.c @@ -294,10 +294,6 @@ int32_t dnodeCheckSystemImp() { int32_t (*dnodeCheckSystem)() = dnodeCheckSystemImp; -void dnodeParseParameterKImp() {} - -void (*dnodeParseParameterK)() = dnodeParseParameterKImp; - int32_t dnodeInitPeersImp(int32_t numOfThreads) { return 0; } diff --git a/src/inc/dnode.h b/src/inc/dnode.h index c69e1d2b26534654c390c2e41fa2d7cd987b004b..15a6096826f2c0e96e6890956856ad783a592fae 100644 --- a/src/inc/dnode.h +++ b/src/inc/dnode.h @@ -42,7 +42,6 @@ extern uint32_t tsRebootTime; // dnodeCluster extern void (*dnodeStartModules)(); -extern void (*dnodeParseParameterK)(); extern int32_t (*dnodeCheckSystem)(); diff --git a/src/mnode/inc/mgmtGrant.h b/src/mnode/inc/mgmtGrant.h index 2e7122f6190fc248e57d1fa6a508bf596467a15c..1cfc88f94af206c4291e4cf2be7551cffbe77244 100644 --- a/src/mnode/inc/mgmtGrant.h +++ b/src/mnode/inc/mgmtGrant.h @@ -31,7 +31,9 @@ int32_t mgmtCheckTimeSeries(uint32_t timeseries); int32_t mgmtCheckUserGrant(); int32_t mgmtCheckDbGrant(); int32_t mgmtGetGrantsMeta(STableMeta *pMeta, SShowObj *pShow, void *pConn); -int32_t mgmtRetrieveGrants(SShowObj *pShow, char *data, int rows, void *pConn); +int32_t mgmtRetrieveGrants(SShowObj *pShow, char *data, int32_t rows, void *pConn); + +extern void (*mgmtUpdateGrantInfoFp)(void *pCont); #ifdef __cplusplus } diff --git a/src/mnode/src/mgmtChildTable.c b/src/mnode/src/mgmtChildTable.c index e2b141fb64edb1507cf7758bc56f16b209614af4..02771b19c9018f3c98fbd2361c922918ba12ab0e 100644 --- a/src/mnode/src/mgmtChildTable.c +++ b/src/mnode/src/mgmtChildTable.c @@ -442,7 +442,7 @@ int32_t mgmtModifyChildTableTagValueByName(SChildTableObj *pTable, char *tagName // // mgmtMeterActionEncode(pTable, msg, size, &rowSize); // -// int32_t ret = sdbUpdateRow(meterSdb, msg, rowSize, 1); // Need callback function +// int32_t ret = sdbUpdateRow(tsChildTableSdb, msg, rowSize, 1); // Need callback function // tfree(msg); // // if (pTable->isDirty) pTable->isDirty = 0; diff --git a/src/mnode/src/mgmtDnodeInt.c b/src/mnode/src/mgmtDnodeInt.c index fb3110d93d62e7769f8e5f2635788803811062b5..5a365f220a7098257ac7ea5e1273c17970671eaf 100644 --- a/src/mnode/src/mgmtDnodeInt.c +++ b/src/mnode/src/mgmtDnodeInt.c @@ -26,6 +26,7 @@ #include "mgmtDb.h" #include "mgmtDnode.h" #include "mgmtDnodeInt.h" +#include "mgmtGrant.h" #include "mgmtProfile.h" #include "mgmtShell.h" #include "mgmtTable.h" @@ -230,6 +231,14 @@ void mgmtSendCreateVnodeMsg(SVgObj *pVgroup, int32_t vnode, SRpcIpSet *ipSet, vo } } +static void mgmtProcessDnodeGrantMsg(void *pCont, void *thandle) { + if (mgmtUpdateGrantInfoFp) { + mgmtUpdateGrantInfoFp(pCont); + mTrace("grant info is updated"); + } + rpcSendResponse(thandle, TSDB_CODE_SUCCESS, NULL, 0); +} + void mgmtProcessMsgFromDnode(char msgType, void *pCont, int32_t contLen, void *pConn, int32_t code) { if (msgType < 0 || msgType >= TSDB_MSG_TYPE_MAX) { mError("invalid msg type:%d", msgType); @@ -255,9 +264,9 @@ void mgmtProcessMsgFromDnode(char msgType, void *pCont, int32_t contLen, void *p } else if (msgType == TSDB_MSG_TYPE_DNODE_CFG_RSP) { } else if (msgType == TSDB_MSG_TYPE_ALTER_STREAM_RSP) { } else if (msgType == TSDB_MSG_TYPE_STATUS) { - mgmtProcessDnodeStatus(msgType, pConn, contLen, pConn, code); + mgmtProcessDnodeStatus(msgType, pCont, contLen, pConn, code); } else if (msgType == TSDB_MSG_TYPE_GRANT) { - mgmtProcessDropStableRsp(msgType, pCont, contLen, pConn, code); + mgmtProcessDnodeGrantMsg(pCont, pConn); } else { mError("%s from dnode is not processed", taosMsg[(int8_t)msgType]); } diff --git a/src/mnode/src/mgmtGrant.c b/src/mnode/src/mgmtGrant.c index df151ac5001ef140c23082922f97b8925ad51672..c24fb82aa6e3ccfb40cbecfd79548a7b258edc8d 100644 --- a/src/mnode/src/mgmtGrant.c +++ b/src/mnode/src/mgmtGrant.c @@ -18,6 +18,7 @@ #include "mnode.h" #include "mgmtAcct.h" #include "mgmtGrant.h" +#include "mgmtUser.h" int32_t (*mgmtCheckUserGrantFp)() = NULL; int32_t (*mgmtCheckDbGrantFp)() = NULL; @@ -27,6 +28,7 @@ int32_t (*mgmtCheckTimeSeriesFp)(uint32_t timeseries) = NULL; bool (*mgmtCheckExpiredFp)() = NULL; int32_t (*mgmtGetGrantsMetaFp)(STableMeta *pMeta, SShowObj *pShow, void *pConn) = NULL; int32_t (*mgmtRetrieveGrantsFp)(SShowObj *pShow, char *data, int rows, void *pConn) = NULL; +void (*mgmtUpdateGrantInfoFp)(void *pCont) = NULL; int32_t mgmtCheckUserGrant() { if (mgmtCheckUserGrantFp) { @@ -76,17 +78,19 @@ bool mgmtCheckExpired() { int32_t mgmtGetGrantsMeta(STableMeta *pMeta, SShowObj *pShow, void *pConn) { if (mgmtGetGrantsMetaFp) { + SUserObj *pUser = mgmtGetUserFromConn(pConn); + if (pUser == NULL) return 0; + if (strcmp(pUser->user, "root") != 0) return TSDB_CODE_NO_RIGHTS; return mgmtGetGrantsMetaFp(pMeta, pShow, pConn); } else { return TSDB_CODE_OPS_NOT_SUPPORT; } } -int32_t mgmtRetrieveGrants(SShowObj *pShow, char *data, int rows, void *pConn) { +int32_t mgmtRetrieveGrants(SShowObj *pShow, char *data, int32_t rows, void *pConn) { if (mgmtRetrieveGrantsFp) { return mgmtRetrieveGrantsFp(pShow, data, rows, pConn); } else { return 0; } } -