From 74039b30dca2e32f12e3727841d18319f66c19e2 Mon Sep 17 00:00:00 2001 From: slguan Date: Tue, 11 Feb 2020 18:26:28 +0800 Subject: [PATCH] #1177 --- src/inc/mnode.h | 95 ++----------------- src/mnode/inc/mgmtDb.h | 25 ++++- src/mnode/inc/mgmtDnode.h | 5 + src/mnode/inc/mgmtDnodeInt.h | 3 +- .../{src/mgmtMnode.spec.c => inc/mgmtMnode.h} | 19 +++- src/mnode/inc/mgmtShell.h | 44 +++++++++ src/mnode/inc/mgmtSystem.h | 31 ++---- src/mnode/inc/mgmtTable.h | 19 ++++ src/mnode/inc/mgmtUser.h | 40 ++++++++ src/mnode/inc/mgmtVgroup.h | 40 ++++++++ src/mnode/src/mgmtAcct.c | 2 + src/mnode/src/mgmtBalance.c | 1 + src/mnode/src/mgmtDb.c | 4 +- src/mnode/src/mgmtDnode.c | 4 +- src/mnode/src/mgmtDnodeInt.c | 2 + .../src/{mgmtSystem.spec.c => mgmtMnode.c} | 25 +---- src/mnode/src/mgmtShell.c | 55 ++++++++--- src/mnode/src/mgmtShell.spec.c | 48 ---------- src/mnode/src/mgmtSystem.c | 34 ++++++- src/mnode/src/mgmtTable.c | 2 + src/mnode/src/mgmtUser.c | 4 +- src/mnode/src/mgmtUtil.c | 1 + src/mnode/src/mgmtVgroup.c | 2 + 23 files changed, 301 insertions(+), 204 deletions(-) rename src/mnode/{src/mgmtMnode.spec.c => inc/mgmtMnode.h} (64%) create mode 100644 src/mnode/inc/mgmtShell.h create mode 100644 src/mnode/inc/mgmtUser.h create mode 100644 src/mnode/inc/mgmtVgroup.h rename src/mnode/src/{mgmtSystem.spec.c => mgmtMnode.c} (56%) delete mode 100644 src/mnode/src/mgmtShell.spec.c diff --git a/src/inc/mnode.h b/src/inc/mnode.h index b608defc6a..ecfd041b0a 100644 --- a/src/inc/mnode.h +++ b/src/inc/mnode.h @@ -45,6 +45,12 @@ extern int mgmtShellConns; extern int mgmtDnodeConns; extern char mgmtDirectory[]; +extern int tsAcctUpdateSize; +extern int tsDbUpdateSize; +extern int tsDnodeUpdateSize; +extern int tsMnodeUpdateSize; +extern int tsUserUpdateSize; +extern int tsVgUpdateSize; typedef struct { uint32_t privateIp; @@ -256,96 +262,9 @@ typedef struct { char payload[]; /* payload for wildcard match in show tables */ } SShowObj; -extern SAcctObj acctObj; -extern SDnodeObj dnodeObj; - - -// shell API -int mgmtInitShell(); -void mgmtCleanUpShell(); -int mgmtRetriveUserAuthInfo(char *user, char *spi, char *encrypt, uint8_t *secret, uint8_t *ckey); - -// user API -int mgmtInitUsers(); -SUserObj *mgmtGetUser(char *name); -int mgmtCreateUser(SAcctObj *pAcct, char *name, char *pass); -int mgmtDropUser(SAcctObj *pAcct, char *name); -int mgmtUpdateUser(SUserObj *pUser); -int mgmtGetUserMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn); -int mgmtRetrieveUsers(SShowObj *pShow, char *data, int rows, SConnObj *pConn); -void mgmtCleanUpUsers(); - -// metric API -int mgmtAddMeterIntoMetric(STabObj *pMetric, STabObj *pTable); -int mgmtRemoveMeterFromMetric(STabObj *pMetric, STabObj *pTable); -int mgmtGetMetricMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn); -int mgmtRetrieveMetrics(SShowObj *pShow, char *data, int rows, SConnObj *pConn); - -// DB API -/* void mgmtMonitorDbDrop(void *unused); */ -void mgmtMonitorDbDrop(void *unused, void *unusedt); -int mgmtAlterDb(SAcctObj *pAcct, SAlterDbMsg *pAlter); -int mgmtUseDb(SConnObj *pConn, char *name); -int mgmtAddVgroupIntoDb(SDbObj *pDb, SVgObj *pVgroup); -int mgmtAddVgroupIntoDbTail(SDbObj *pDb, SVgObj *pVgroup); -int mgmtRemoveVgroupFromDb(SDbObj *pDb, SVgObj *pVgroup); -int mgmtAddMetricIntoDb(SDbObj *pDb, STabObj *pMetric); -int mgmtRemoveMetricFromDb(SDbObj *pDb, STabObj *pMetric); -int mgmtMoveVgroupToTail(SDbObj *pDb, SVgObj *pVgroup); -int mgmtMoveVgroupToHead(SDbObj *pDb, SVgObj *pVgroup); -int mgmtGetDbMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn); -int mgmtRetrieveDbs(SShowObj *pShow, char *data, int rows, SConnObj *pConn); -void mgmtCleanUpDbs(); - -// vGroup API -int mgmtInitVgroups(); -SVgObj *mgmtGetVgroup(int vgId); -SVgObj *mgmtCreateVgroup(SDbObj *pDb); -int mgmtDropVgroup(SDbObj *pDb, SVgObj *pVgroup); -void mgmtSetVgroupIdPool(); -int mgmtGetVgroupMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn); -int mgmtRetrieveVgroups(SShowObj *pShow, char *data, int rows, SConnObj *pConn); -void mgmtCleanUpVgroups(); - -// meter API -int mgmtInitMeters(); -STabObj *mgmtGetTable(char *meterId); -STabObj *mgmtGetTableInfo(char *src, char *tags[]); -int mgmtRetrieveMetricMeta(SConnObj *pConn, char **pStart, SSuperTableMetaMsg *pInfo); -int mgmtCreateMeter(SDbObj *pDb, SCreateTableMsg *pCreate); -int mgmtDropMeter(SDbObj *pDb, char *meterId, int ignore); -int mgmtAlterMeter(SDbObj *pDb, SAlterTableMsg *pAlter); -int mgmtGetTableMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn); -int mgmtRetrieveMeters(SShowObj *pShow, char *data, int rows, SConnObj *pConn); -void mgmtCleanUpMeters(); -SSchema *mgmtGetTableSchema(STabObj *pTable); // get schema for a meter - - -// dnode API - -int mgmtGetMnodeMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn); -int mgmtRetrieveMnodes(SShowObj *pShow, char *data, int rows, SConnObj *pConn); - - - - -int mgmtGetVnodeMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn); -int mgmtRetrieveVnodes(SShowObj *pShow, char *data, int rows, SConnObj *pConn); - - -void mgmtSetModuleInDnode(SDnodeObj *pDnode, int moduleType); -int mgmtUnSetModuleInDnode(SDnodeObj *pDnode, int moduleType); - - -extern int tsDnodeUpdateSize; -extern int tsVgUpdateSize; -extern int tsDbUpdateSize; -extern int tsUserUpdateSize; -extern int tsAcctUpdateSize; -extern int tsMnodeUpdateSize; #ifdef __cplusplus } #endif -#endif // TDENGINE_MGMT_H +#endif diff --git a/src/mnode/inc/mgmtDb.h b/src/mnode/inc/mgmtDb.h index 7c29b61890..79c3509ece 100644 --- a/src/mnode/inc/mgmtDb.h +++ b/src/mnode/inc/mgmtDb.h @@ -22,13 +22,28 @@ extern "C" { #include "mnode.h" -int mgmtInitDbs(); -int mgmtUpdateDb(SDbObj *pDb); +void mgmtMonitorDbDrop(void *unused, void *unusedt); +int mgmtAlterDb(SAcctObj *pAcct, SAlterDbMsg *pAlter); +int mgmtUseDb(SConnObj *pConn, char *name); +int mgmtAddVgroupIntoDb(SDbObj *pDb, SVgObj *pVgroup); +int mgmtAddVgroupIntoDbTail(SDbObj *pDb, SVgObj *pVgroup); +int mgmtRemoveVgroupFromDb(SDbObj *pDb, SVgObj *pVgroup); +int mgmtAddMetricIntoDb(SDbObj *pDb, STabObj *pMetric); +int mgmtRemoveMetricFromDb(SDbObj *pDb, STabObj *pMetric); +int mgmtMoveVgroupToTail(SDbObj *pDb, SVgObj *pVgroup); +int mgmtMoveVgroupToHead(SDbObj *pDb, SVgObj *pVgroup); +int mgmtGetDbMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn); +int mgmtRetrieveDbs(SShowObj *pShow, char *data, int rows, SConnObj *pConn); +void mgmtCleanUpDbs(); + + +int32_t mgmtInitDbs(); +int mgmtUpdateDb(SDbObj *pDb); SDbObj *mgmtGetDb(char *db); SDbObj *mgmtGetDbByMeterId(char *db); -int mgmtCreateDb(SAcctObj *pAcct, SCreateDbMsg *pCreate); -int mgmtDropDbByName(SAcctObj *pAcct, char *name, short ignoreNotExists); -int mgmtDropDb(SDbObj *pDb); +int mgmtCreateDb(SAcctObj *pAcct, SCreateDbMsg *pCreate); +int mgmtDropDbByName(SAcctObj *pAcct, char *name, short ignoreNotExists); +int mgmtDropDb(SDbObj *pDb); #ifdef __cplusplus } diff --git a/src/mnode/inc/mgmtDnode.h b/src/mnode/inc/mgmtDnode.h index 8c835493af..a881601364 100644 --- a/src/mnode/inc/mgmtDnode.h +++ b/src/mnode/inc/mgmtDnode.h @@ -41,6 +41,9 @@ int32_t mgmtRetrieveConfigs(SShowObj *pShow, char *data, int rows, SConnObj *pCo int32_t mgmtGetModuleMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn); int32_t mgmtRetrieveModules(SShowObj *pShow, char *data, int rows, SConnObj *pConn); +int32_t mgmtGetVnodeMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn); +int32_t mgmtRetrieveVnodes(SShowObj *pShow, char *data, int rows, SConnObj *pConn); + extern int32_t (*mgmtInitDnodes)(); extern void (*mgmtCleanUpDnodes)(); extern SDnodeObj* (*mgmtGetDnode)(uint32_t ip); @@ -52,6 +55,8 @@ extern int32_t (*mgmtGetScoresMeta)(SMeterMeta *pMeta, SShowObj *pShow, SConn extern int32_t (*mgmtRetrieveScores)(SShowObj *pShow, char *data, int rows, SConnObj *pConn); extern bool (*mgmtCheckConfigShow)(SGlobalConfig *cfg); +extern SDnodeObj dnodeObj; + #ifdef __cplusplus } #endif diff --git a/src/mnode/inc/mgmtDnodeInt.h b/src/mnode/inc/mgmtDnodeInt.h index 83d3088414..20de92b6ef 100644 --- a/src/mnode/inc/mgmtDnodeInt.h +++ b/src/mnode/inc/mgmtDnodeInt.h @@ -24,7 +24,8 @@ extern "C" { #include #include "mnode.h" -// dnodeInt API +extern void *mgmtStatusTimer; + int mgmtSendCreateMsgToVgroup(STabObj *pTable, SVgObj *pVgroup); int mgmtSendRemoveMeterMsgToDnode(STabObj *pTable, SVgObj *pVgroup); int mgmtSendVPeersMsg(SVgObj *pVgroup); diff --git a/src/mnode/src/mgmtMnode.spec.c b/src/mnode/inc/mgmtMnode.h similarity index 64% rename from src/mnode/src/mgmtMnode.spec.c rename to src/mnode/inc/mgmtMnode.h index d32639823b..94ec307c43 100644 --- a/src/mnode/src/mgmtMnode.spec.c +++ b/src/mnode/inc/mgmtMnode.h @@ -13,9 +13,22 @@ * along with this program. If not, see . */ -#define _DEFAULT_SOURCE +#ifndef TDENGINE_MGMT_MNODE_H +#define TDENGINE_MGMT_MNODE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include #include "mnode.h" -int mgmtGetMnodeMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) { return TSDB_CODE_OPS_NOT_SUPPORT; } +extern int32_t (*mgmtGetMnodeMeta)(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn); +extern int32_t (*mgmtRetrieveMnodes)(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn); + +#ifdef __cplusplus +} +#endif -int mgmtRetrieveMnodes(SShowObj *pShow, char *data, int rows, SConnObj *pConn) { return 0; } +#endif diff --git a/src/mnode/inc/mgmtShell.h b/src/mnode/inc/mgmtShell.h new file mode 100644 index 0000000000..22650adc3d --- /dev/null +++ b/src/mnode/inc/mgmtShell.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * 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 . + */ + +#ifndef TDENGINE_MGMT_SHELL_H +#define TDENGINE_MGMT_SHELL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include "mnode.h" + +int mgmtInitShell(); +void mgmtCleanUpShell(); +int mgmtRetriveUserAuthInfo(char *user, char *spi, char *encrypt, uint8_t *secret, uint8_t *ckey); + +extern int32_t (*mgmtCheckRedirectMsg)(SConnObj *pConn, int32_t msgType); +extern int32_t (*mgmtProcessAlterAcctMsg)(char *pMsg, int32_t msgLen, SConnObj *pConn); +extern int32_t (*mgmtProcessCreateDnodeMsg)(char *pMsg, int32_t msgLen, SConnObj *pConn); +extern int32_t (*mgmtProcessCfgMnodeMsg)(char *pMsg, int32_t msgLen, SConnObj *pConn); +extern int32_t (*mgmtProcessDropMnodeMsg)(char *pMsg, int32_t msgLen, SConnObj *pConn); +extern int32_t (*mgmtProcessDropDnodeMsg)(char *pMsg, int32_t msgLen, SConnObj *pConn); +extern int32_t (*mgmtProcessDropAcctMsg)(char *pMsg, int32_t msgLen, SConnObj *pConn); +extern int32_t (*mgmtProcessCreateAcctMsg)(char *pMsg, int32_t msgLen, SConnObj *pConn); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/mnode/inc/mgmtSystem.h b/src/mnode/inc/mgmtSystem.h index 6f0c669e15..6bbea549c7 100644 --- a/src/mnode/inc/mgmtSystem.h +++ b/src/mnode/inc/mgmtSystem.h @@ -20,30 +20,17 @@ extern "C" { #endif -int mgmtInitRedirect(); +#include -void mgmtCleanUpRedirect(); +int32_t mgmtStartSystem(); +void mgmtCleanUpSystem(); -void*mgmtRedirectAllMsgs(char *msg, void *ahandle, void *thandle); - -void mgmtSdbWorkAsMasterCallback(); - -void mgmtSetDnodeOfflineOnSdbChanged(); - -void mgmtPrintSystemInfo(); - -int mgmtInitSystem(); - -int mgmtStartCheckMgmtRunning(); - -void mgmtDoStatistic(void *handle, void *tmrId); - -void mgmtStartMgmtTimer(); - -int mgmtStartSystem(); -void mgmtStopSystem(); - -void mgmtCleanUpSystem(); +extern int32_t (*mgmtInitSystem)(); +extern int32_t (*mgmtCheckMgmtRunning)(); +extern void (*mgmtDoStatistic)(void *handle, void *tmrId); +extern void (*mgmtStartMgmtTimer)(); +extern void (*mgmtStopSystem)(); +extern void (*mgmtCleanUpRedirect)(); #ifdef __cplusplus } diff --git a/src/mnode/inc/mgmtTable.h b/src/mnode/inc/mgmtTable.h index c5fe623c4d..f4a5466ff8 100644 --- a/src/mnode/inc/mgmtTable.h +++ b/src/mnode/inc/mgmtTable.h @@ -25,8 +25,27 @@ extern "C" { #include #include "mnode.h" +int mgmtInitMeters(); +STabObj *mgmtGetTable(char *meterId); +STabObj *mgmtGetTableInfo(char *src, char *tags[]); +int mgmtRetrieveMetricMeta(SConnObj *pConn, char **pStart, SSuperTableMetaMsg *pInfo); +int mgmtCreateMeter(SDbObj *pDb, SCreateTableMsg *pCreate); +int mgmtDropMeter(SDbObj *pDb, char *meterId, int ignore); +int mgmtAlterMeter(SDbObj *pDb, SAlterTableMsg *pAlter); +int mgmtGetTableMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn); +int mgmtRetrieveMeters(SShowObj *pShow, char *data, int rows, SConnObj *pConn); +void mgmtCleanUpMeters(); +SSchema *mgmtGetTableSchema(STabObj *pTable); // get schema for a meter + int32_t mgmtFindTagCol(STabObj * pTable, const char * tagName); +int mgmtAddMeterIntoMetric(STabObj *pMetric, STabObj *pTable); +int mgmtRemoveMeterFromMetric(STabObj *pMetric, STabObj *pTable); +int mgmtGetMetricMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn); +int mgmtRetrieveMetrics(SShowObj *pShow, char *data, int rows, SConnObj *pConn); + + + #ifdef __cplusplus } #endif diff --git a/src/mnode/inc/mgmtUser.h b/src/mnode/inc/mgmtUser.h new file mode 100644 index 0000000000..52f19baff0 --- /dev/null +++ b/src/mnode/inc/mgmtUser.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * 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 . + */ + +#ifndef TDENGINE_MGMT_USER_H +#define TDENGINE_MGMT_USER_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include "mnode.h" + +int mgmtInitUsers(); +SUserObj *mgmtGetUser(char *name); +int mgmtCreateUser(SAcctObj *pAcct, char *name, char *pass); +int mgmtDropUser(SAcctObj *pAcct, char *name); +int mgmtUpdateUser(SUserObj *pUser); +int mgmtGetUserMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn); +int mgmtRetrieveUsers(SShowObj *pShow, char *data, int rows, SConnObj *pConn); +void mgmtCleanUpUsers(); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/mnode/inc/mgmtVgroup.h b/src/mnode/inc/mgmtVgroup.h new file mode 100644 index 0000000000..121ae000b0 --- /dev/null +++ b/src/mnode/inc/mgmtVgroup.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * 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 . + */ + +#ifndef TDENGINE_MGMT_VGROUP_H +#define TDENGINE_MGMT_VGROUP_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include "mnode.h" + +int mgmtInitVgroups(); +SVgObj *mgmtGetVgroup(int vgId); +SVgObj *mgmtCreateVgroup(SDbObj *pDb); +int mgmtDropVgroup(SDbObj *pDb, SVgObj *pVgroup); +void mgmtSetVgroupIdPool(); +int mgmtGetVgroupMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn); +int mgmtRetrieveVgroups(SShowObj *pShow, char *data, int rows, SConnObj *pConn); +void mgmtCleanUpVgroups(); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/mnode/src/mgmtAcct.c b/src/mnode/src/mgmtAcct.c index 1fcfc4bb08..67b14c319e 100644 --- a/src/mnode/src/mgmtAcct.c +++ b/src/mnode/src/mgmtAcct.c @@ -17,6 +17,8 @@ #include "os.h" #include "mnode.h" #include "mgmtAcct.h" +#include "mgmtTable.h" +#include "mgmtUser.h" #include "tschemautil.h" extern void *userSdb; diff --git a/src/mnode/src/mgmtBalance.c b/src/mnode/src/mgmtBalance.c index 5b32ff0405..aa7448865f 100644 --- a/src/mnode/src/mgmtBalance.c +++ b/src/mnode/src/mgmtBalance.c @@ -15,6 +15,7 @@ #define _DEFAULT_SOURCE #include "mgmtBalance.h" +#include "mgmtDnode.h" #include "dnodeModule.h" #include "tstatus.h" #include "tglobalcfg.h" diff --git a/src/mnode/src/mgmtDb.c b/src/mnode/src/mgmtDb.c index bb764ce0f9..c8bed2e497 100644 --- a/src/mnode/src/mgmtDb.c +++ b/src/mnode/src/mgmtDb.c @@ -22,6 +22,8 @@ #include "mgmtBalance.h" #include "mgmtDnodeInt.h" #include "mgmtUtil.h" +#include "mgmtVgroup.h" +#include "mgmtTable.h" #include "tschemautil.h" #include "tstatus.h" #include "mnode.h" @@ -73,7 +75,7 @@ void mgmtGetAcctStr(char *src, char *dest) { *dest = 0; } -int mgmtInitDbs() { +int32_t mgmtInitDbs() { void * pNode = NULL; SDbObj * pDb = NULL; SAcctObj *pAcct = NULL; diff --git a/src/mnode/src/mgmtDnode.c b/src/mnode/src/mgmtDnode.c index c96f331be8..c3791ab8d1 100644 --- a/src/mnode/src/mgmtDnode.c +++ b/src/mnode/src/mgmtDnode.c @@ -387,7 +387,7 @@ int mgmtRetrieveConfigs(SShowObj *pShow, char *data, int rows, SConnObj *pConn) return numOfRows; } -int mgmtGetVnodeMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) { +int32_t mgmtGetVnodeMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) { int cols = 0; if (strcmp(pConn->pAcct->user, "root") != 0) return TSDB_CODE_NO_RIGHTS; @@ -460,7 +460,7 @@ int mgmtGetVnodeMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) { return 0; } -int mgmtRetrieveVnodes(SShowObj *pShow, char *data, int rows, SConnObj *pConn) { +int32_t mgmtRetrieveVnodes(SShowObj *pShow, char *data, int rows, SConnObj *pConn) { int numOfRows = 0; SDnodeObj *pDnode = NULL; char * pWrite; diff --git a/src/mnode/src/mgmtDnodeInt.c b/src/mnode/src/mgmtDnodeInt.c index 7e8c733b62..ef47510810 100644 --- a/src/mnode/src/mgmtDnodeInt.c +++ b/src/mnode/src/mgmtDnodeInt.c @@ -22,6 +22,8 @@ #include "mgmtBalance.h" #include "mgmtDnode.h" #include "mgmtDb.h" +#include "mgmtVgroup.h" +#include "mgmtTable.h" #include "tutil.h" #include "tstatus.h" #include "tsystem.h" diff --git a/src/mnode/src/mgmtSystem.spec.c b/src/mnode/src/mgmtMnode.c similarity index 56% rename from src/mnode/src/mgmtSystem.spec.c rename to src/mnode/src/mgmtMnode.c index a047f6d856..83171fc149 100644 --- a/src/mnode/src/mgmtSystem.spec.c +++ b/src/mnode/src/mgmtMnode.c @@ -14,25 +14,10 @@ */ #define _DEFAULT_SOURCE -#include +#include "mgmtMnode.h" -#include "dnodeSystem.h" -#include "mnode.h" - -extern void *mgmtTmr; -extern void *mgmtStatusTimer; - -void mgmtProcessDnodeStatus(void *handle, void *tmrId); - -int mgmtInitSystem() { return mgmtStartSystem(); } - -int32_t mgmtStartCheckMgmtRunning() { return 0; } - -void mgmtDoStatistic(void *handle, void *tmrId) {} - -void mgmtStartMgmtTimer() { taosTmrReset(mgmtProcessDnodeStatus, 500, NULL, mgmtTmr, &mgmtStatusTimer); } - -void mgmtStopSystem() {} - -void mgmtCleanUpRedirect() {} +int32_t mgmtGetMnodeMetaImp(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) { return TSDB_CODE_OPS_NOT_SUPPORT; } +int32_t (*mgmtGetMnodeMeta)(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) = mgmtGetMnodeMetaImp; +int32_t mgmtRetrieveMnodesImp(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn) { return 0; } +int32_t (*mgmtRetrieveMnodes)(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn) = mgmtRetrieveMnodesImp; diff --git a/src/mnode/src/mgmtShell.c b/src/mnode/src/mgmtShell.c index 5cf0ab5623..1204ba9720 100644 --- a/src/mnode/src/mgmtShell.c +++ b/src/mnode/src/mgmtShell.c @@ -24,9 +24,13 @@ #include "mgmtDb.h" #include "mgmtDnode.h" #include "mgmtGrant.h" +#include "mgmtMnode.h" #include "mgmtProfile.h" +#include "mgmtShell.h" #include "mgmtTable.h" +#include "mgmtUser.h" #include "mgmtUtil.h" +#include "mgmtVgroup.h" #include "taosmsg.h" #include "tlog.h" #include "tstatus.h" @@ -48,17 +52,6 @@ void mgmtInitProcessShellMsg(); int mgmtRedirectMsg(SConnObj *pConn, int msgType); int mgmtKillQuery(char *queryId, SConnObj *pConn); -int mgmtCheckRedirectMsg(SConnObj *pConn, int msgType); -int mgmtProcessAlterAcctMsg(char *pMsg, int msgLen, SConnObj *pConn); -int mgmtProcessCreateMnodeMsg(char *pMsg, int msgLen, SConnObj *pConn); -int mgmtProcessCreateDnodeMsg(char *pMsg, int msgLen, SConnObj *pConn); -int mgmtProcessCfgMnodeMsg(char *pMsg, int msgLen, SConnObj *pConn); -int mgmtProcessDropMnodeMsg(char *pMsg, int msgLen, SConnObj *pConn); -int mgmtProcessDropDnodeMsg(char *pMsg, int msgLen, SConnObj *pConn); -int mgmtProcessDropAcctMsg(char *pMsg, int msgLen, SConnObj *pConn); -int mgmtProcessCreateAcctMsg(char *pMsg, int msgLen, SConnObj *pConn); -int mgmtProcessCfgDnodeMsg(char *pMsg, int msgLen, SConnObj *pConn); - void mgmtProcessTranRequest(SSchedMsg *pSchedMsg) { SIntMsg * pMsg = (SIntMsg *)(pSchedMsg->msg); SConnObj *pConn = (SConnObj *)(pSchedMsg->thandle); @@ -1537,3 +1530,43 @@ void mgmtInitProcessShellMsg() { mgmtProcessShellMsg[TSDB_MSG_TYPE_KILL_STREAM] = mgmtProcessKillStreamMsg; mgmtProcessShellMsg[TSDB_MSG_TYPE_KILL_CONNECTION] = mgmtProcessKillConnectionMsg; } + +int32_t mgmtCheckRedirectMsgImp(SConnObj *pConn, int32_t msgType) { + return 0; +} +int32_t (*mgmtCheckRedirectMsg)(SConnObj *pConn, int32_t msgType) = mgmtCheckRedirectMsgImp; + +int32_t mgmtProcessAlterAcctMsgImp(char *pMsg, int32_t msgLen, SConnObj *pConn) { + return taosSendSimpleRsp(pConn->thandle, TSDB_MSG_TYPE_ALTER_ACCT_RSP, TSDB_CODE_OPS_NOT_SUPPORT); +} +int32_t (*mgmtProcessAlterAcctMsg)(char *pMsg, int32_t msgLen, SConnObj *pConn) = mgmtProcessAlterAcctMsgImp; + +int32_t mgmtProcessCreateDnodeMsgImp(char *pMsg, int32_t msgLen, SConnObj *pConn) { + return taosSendSimpleRsp(pConn->thandle, TSDB_MSG_TYPE_CREATE_DNODE_RSP, TSDB_CODE_OPS_NOT_SUPPORT); +} +int32_t (*mgmtProcessCreateDnodeMsg)(char *pMsg, int32_t msgLen, SConnObj *pConn) = mgmtProcessCreateDnodeMsgImp; + +int32_t mgmtProcessCfgMnodeMsgImp(char *pMsg, int32_t msgLen, SConnObj *pConn) { + return taosSendSimpleRsp(pConn->thandle, TSDB_MSG_TYPE_CFG_MNODE_RSP, TSDB_CODE_OPS_NOT_SUPPORT); +} +int32_t (*mgmtProcessCfgMnodeMsg)(char *pMsg, int32_t msgLen, SConnObj *pConn) = mgmtProcessCfgMnodeMsgImp; + +int32_t mgmtProcessDropMnodeMsgImp(char *pMsg, int32_t msgLen, SConnObj *pConn) { + return taosSendSimpleRsp(pConn->thandle, TSDB_MSG_TYPE_DROP_MNODE_RSP, TSDB_CODE_OPS_NOT_SUPPORT); +} +int32_t (*mgmtProcessDropMnodeMsg)(char *pMsg, int32_t msgLen, SConnObj *pConn) = mgmtProcessDropMnodeMsgImp; + +int32_t mgmtProcessDropDnodeMsgImp(char *pMsg, int32_t msgLen, SConnObj *pConn) { + return taosSendSimpleRsp(pConn->thandle, TSDB_MSG_TYPE_DROP_DNODE_RSP, TSDB_CODE_OPS_NOT_SUPPORT); +} +int32_t (*mgmtProcessDropDnodeMsg)(char *pMsg, int32_t msgLen, SConnObj *pConn) = mgmtProcessDropDnodeMsgImp; + +int32_t mgmtProcessDropAcctMsgImp(char *pMsg, int32_t msgLen, SConnObj *pConn) { + return taosSendSimpleRsp(pConn->thandle, TSDB_MSG_TYPE_DROP_ACCT_RSP, TSDB_CODE_OPS_NOT_SUPPORT); +} +int32_t (*mgmtProcessDropAcctMsg)(char *pMsg, int32_t msgLen, SConnObj *pConn) = mgmtProcessDropAcctMsgImp; + +int32_t mgmtProcessCreateAcctMsgImp(char *pMsg, int32_t msgLen, SConnObj *pConn) { + return taosSendSimpleRsp(pConn->thandle, TSDB_MSG_TYPE_CREATE_ACCT_RSP, TSDB_CODE_OPS_NOT_SUPPORT); +} +int32_t (*mgmtProcessCreateAcctMsg)(char *pMsg, int32_t msgLen, SConnObj *pConn) = mgmtProcessCreateAcctMsgImp; \ No newline at end of file diff --git a/src/mnode/src/mgmtShell.spec.c b/src/mnode/src/mgmtShell.spec.c deleted file mode 100644 index 5d7786ccd3..0000000000 --- a/src/mnode/src/mgmtShell.spec.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * 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 . - */ - -#define _DEFAULT_SOURCE -#include -#include "mnode.h" - -int mgmtCheckRedirectMsg(SConnObj *pConn, int msgType) { return 0; } - -int mgmtProcessAlterAcctMsg(char *pMsg, int msgLen, SConnObj *pConn) { - return taosSendSimpleRsp(pConn->thandle, TSDB_MSG_TYPE_ALTER_ACCT_RSP, TSDB_CODE_OPS_NOT_SUPPORT); -} - -int mgmtProcessCreateDnodeMsg(char *pMsg, int msgLen, SConnObj *pConn) { - return taosSendSimpleRsp(pConn->thandle, TSDB_MSG_TYPE_CREATE_DNODE_RSP, TSDB_CODE_OPS_NOT_SUPPORT); -} - -int mgmtProcessCfgMnodeMsg(char *pMsg, int msgLen, SConnObj *pConn) { - return taosSendSimpleRsp(pConn->thandle, TSDB_MSG_TYPE_CFG_MNODE_RSP, TSDB_CODE_OPS_NOT_SUPPORT); -} - -int mgmtProcessDropMnodeMsg(char *pMsg, int msgLen, SConnObj *pConn) { - return taosSendSimpleRsp(pConn->thandle, TSDB_MSG_TYPE_DROP_MNODE_RSP, TSDB_CODE_OPS_NOT_SUPPORT); -} - -int mgmtProcessDropDnodeMsg(char *pMsg, int msgLen, SConnObj *pConn) { - return taosSendSimpleRsp(pConn->thandle, TSDB_MSG_TYPE_DROP_DNODE_RSP, TSDB_CODE_OPS_NOT_SUPPORT); -} - -int mgmtProcessDropAcctMsg(char *pMsg, int msgLen, SConnObj *pConn) { - return taosSendSimpleRsp(pConn->thandle, TSDB_MSG_TYPE_DROP_ACCT_RSP, TSDB_CODE_OPS_NOT_SUPPORT); -} - -int mgmtProcessCreateAcctMsg(char *pMsg, int msgLen, SConnObj *pConn) { - return taosSendSimpleRsp(pConn->thandle, TSDB_MSG_TYPE_CREATE_ACCT_RSP, TSDB_CODE_OPS_NOT_SUPPORT); -} \ No newline at end of file diff --git a/src/mnode/src/mgmtSystem.c b/src/mnode/src/mgmtSystem.c index ec1fbcb3ce..3ed29fdd09 100644 --- a/src/mnode/src/mgmtSystem.c +++ b/src/mnode/src/mgmtSystem.c @@ -18,9 +18,18 @@ #include "dnodeSystem.h" #include "mnode.h" -#include "tsdb.h" +#include "mgmtAcct.h" +#include "mgmtBalance.h" +#include "mgmtDb.h" +#include "mgmtDnode.h" +#include "mgmtDnodeInt.h" +#include "mgmtVgroup.h" +#include "mgmtUser.h" #include "mgmtSystem.h" +#include "mgmtTable.h" +#include "mgmtShell.h" #include "dnodeModule.h" +#include "tsdb.h" // global, not configurable char mgmtDirectory[128]; @@ -76,7 +85,7 @@ int mgmtStartSystem() { mkdir(mgmtDirectory, 0755); } - if (mgmtStartCheckMgmtRunning() != 0) { + if (mgmtCheckMgmtRunning() != 0) { mPrint("TDengine mgmt module already started..."); return 0; } @@ -152,3 +161,24 @@ int mgmtStartSystem() { return 0; } + +int32_t mgmtInitSystemImp() { return mgmtStartSystem(); } +int32_t (*mgmtInitSystem)() = mgmtInitSystemImp; + +int32_t mgmtCheckMgmtRunningImp() { return 0; } +int32_t (*mgmtCheckMgmtRunning)() = mgmtCheckMgmtRunningImp; + +void mgmtDoStatisticImp(void *handle, void *tmrId) {} +void (*mgmtDoStatistic)(void *handle, void *tmrId) = mgmtDoStatisticImp; + +void mgmtStartMgmtTimerImp() { + taosTmrReset(mgmtProcessDnodeStatus, 500, NULL, mgmtTmr, &mgmtStatusTimer); +} +void (*mgmtStartMgmtTimer)() = mgmtStartMgmtTimerImp; + +void mgmtStopSystemImp() {} +void (*mgmtStopSystem)() = mgmtStopSystemImp; + +void mgmtCleanUpRedirectImp() {} +void (*mgmtCleanUpRedirect)() = mgmtCleanUpRedirectImp; + diff --git a/src/mnode/src/mgmtTable.c b/src/mnode/src/mgmtTable.c index 8f68670355..e7a4aebb9c 100644 --- a/src/mnode/src/mgmtTable.c +++ b/src/mnode/src/mgmtTable.c @@ -22,7 +22,9 @@ #include "mgmtUtil.h" #include "mgmtDb.h" #include "mgmtDnodeInt.h" +#include "mgmtVgroup.h" #include "mgmtSupertableQuery.h" +#include "mgmtTable.h" #include "taosmsg.h" #include "tast.h" #include "textbuffer.h" diff --git a/src/mnode/src/mgmtUser.c b/src/mnode/src/mgmtUser.c index dd97d7b377..1e2a782d09 100644 --- a/src/mnode/src/mgmtUser.c +++ b/src/mnode/src/mgmtUser.c @@ -17,8 +17,10 @@ #include "os.h" #include "mnode.h" -#include "mgmtGrant.h" #include "mgmtAcct.h" +#include "mgmtUser.h" +#include "mgmtGrant.h" +#include "mgmtTable.h" #include "tschemautil.h" #include "ttime.h" diff --git a/src/mnode/src/mgmtUtil.c b/src/mnode/src/mgmtUtil.c index 99f57b9bae..645758401b 100644 --- a/src/mnode/src/mgmtUtil.c +++ b/src/mnode/src/mgmtUtil.c @@ -17,6 +17,7 @@ #include "os.h" #include "mnode.h" #include "mgmtUtil.h" +#include "mgmtTable.h" #include "tschemautil.h" bool mgmtTableCreateFromSuperTable(STabObj* pTableObj) { diff --git a/src/mnode/src/mgmtVgroup.c b/src/mnode/src/mgmtVgroup.c index 7b01fdca6c..2f4c78f2a8 100644 --- a/src/mnode/src/mgmtVgroup.c +++ b/src/mnode/src/mgmtVgroup.c @@ -21,6 +21,8 @@ #include "mgmtDb.h" #include "mgmtDnode.h" #include "mgmtDnodeInt.h" +#include "mgmtVgroup.h" +#include "mgmtTable.h" #include "tschemautil.h" #include "tlog.h" #include "tstatus.h" -- GitLab