TDengine/source/dnode/mnode/impl/src/mndGrant.c

103 lines
4.2 KiB
C
Raw Normal View History

2022-04-12 16:42:21 +00:00
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
2022-04-13 08:48:29 +00:00
#include "mndGrant.h"
2022-04-14 09:49:48 +00:00
#include "mndShow.h"
2022-04-12 16:42:21 +00:00
2022-04-14 07:11:13 +00:00
#ifndef _GRANT
#define GRANT_ITEM_SHOW(display) \
do { \
if ((++cols) >= nCols) goto _end; \
if ((pColInfo = taosArrayGet(pBlock->pDataBlock, cols))) { \
src = (display); \
STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32); \
2025-07-12 07:39:29 +00:00
COL_DATA_SET_VAL_GOTO(tmp, false, NULL, NULL, _exit); \
} \
2024-01-18 07:23:38 +00:00
} while (0)
static int32_t mndRetrieveGrant(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) {
2024-07-23 10:40:58 +00:00
SMnode *pMnode = pReq->info.node;
SSdb *pSdb = pMnode->pSdb;
int32_t numOfRows = 0;
int32_t cols = 0;
2024-07-23 10:40:58 +00:00
int32_t code = 0;
int32_t lino = 0;
char tmp[32];
int32_t nCols = taosArrayGetSize(pBlock->pDataBlock);
if (pShow->numOfRows < 1) {
cols = 0;
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
2024-06-07 09:24:36 +00:00
const char *src = TD_PRODUCT_NAME;
STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
2025-07-12 07:39:29 +00:00
COL_DATA_SET_VAL_GOTO(tmp, false, NULL, NULL, _exit);
2024-01-26 11:06:56 +00:00
GRANT_ITEM_SHOW("unlimited");
GRANT_ITEM_SHOW("limited");
2024-01-31 05:02:17 +00:00
GRANT_ITEM_SHOW("false");
2024-01-26 11:06:56 +00:00
GRANT_ITEM_SHOW("ungranted");
for (int32_t i = 0; i < nCols - 5; ++i) {
GRANT_ITEM_SHOW("unlimited");
}
_end:
2024-01-26 11:06:56 +00:00
++numOfRows;
}
pShow->numOfRows += numOfRows;
2024-07-23 10:40:58 +00:00
_exit:
if (code != 0) {
mError("failed to retrieve grant at line %d since %s", lino, tstrerror(code));
TAOS_RETURN(code);
}
return numOfRows;
}
2022-04-14 07:11:13 +00:00
2024-01-18 07:23:38 +00:00
static int32_t mndRetrieveGrantFull(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) { return 0; }
2024-01-31 05:52:03 +00:00
static int32_t mndRetrieveGrantLogs(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) { return 0; }
2024-01-18 09:49:11 +00:00
static int32_t mndRetrieveMachines(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) { return 0; }
2024-04-17 06:41:47 +00:00
static int32_t mndRetrieveEncryptions(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) { return 0; }
2024-01-18 07:23:38 +00:00
2022-07-06 12:46:41 +00:00
static int32_t mndProcessGrantHB(SRpcMsg *pReq) { return TSDB_CODE_SUCCESS; }
2022-04-14 09:49:48 +00:00
int32_t mndInitGrant(SMnode *pMnode) {
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_GRANTS, mndRetrieveGrant);
2024-01-18 07:23:38 +00:00
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_GRANTS_FULL, mndRetrieveGrantFull);
2024-01-31 05:52:03 +00:00
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_GRANTS_LOGS, mndRetrieveGrantLogs);
2024-01-18 09:49:11 +00:00
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_MACHINES, mndRetrieveMachines);
2024-04-17 06:41:47 +00:00
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_ENCRYPTIONS, mndRetrieveEncryptions);
2022-07-06 12:46:41 +00:00
mndSetMsgHandle(pMnode, TDMT_MND_GRANT_HB_TIMER, mndProcessGrantHB);
return 0;
2022-04-14 09:49:48 +00:00
}
2024-01-31 02:43:31 +00:00
void mndCleanupGrant() {}
2022-04-12 16:42:21 +00:00
void grantParseParameter() { mError("can't parsed parameter k"); }
2022-07-16 07:11:50 +00:00
void grantReset(SMnode *pMnode, EGrantType grant, uint64_t value) {}
2022-04-12 16:42:21 +00:00
void grantAdd(EGrantType grant, uint64_t value) {}
void grantRestore(EGrantType grant, uint64_t value) {}
2024-04-27 20:37:30 +00:00
int64_t grantRemain(EGrantType grant) { return 0; }
2024-07-23 05:55:26 +00:00
int32_t tGetMachineId(char **result) {
*result = NULL;
return 0;
2024-07-23 05:55:26 +00:00
}
bool grantCheckDualReplicaDnodes(void *pMnode) { return false; }
2023-09-25 08:16:12 +00:00
int32_t dmProcessGrantReq(void *pInfo, SRpcMsg *pMsg) { return TSDB_CODE_SUCCESS; }
int32_t dmProcessGrantNotify(void *pInfo, SRpcMsg *pMsg) { return TSDB_CODE_SUCCESS; }
2024-02-01 14:57:56 +00:00
int32_t mndProcessConfigGrantReq(SMnode *pMnode, SRpcMsg *pReq, SMCfgClusterReq *pCfg) { return 0; }
2024-01-31 04:36:58 +00:00
#endif
2024-02-01 14:57:56 +00:00
void mndGenerateMachineCode() { grantParseParameter(); }