diff --git a/src/inc/mnode.h b/src/inc/mnode.h index b608defc6a1a86847f7d211f560fc2e2c5d9731a..ecfd041b0ab5a2fec6a3be9c7dc53e0e5111cfbb 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 7c29b618906b89d19e33db710970eb590c1b9740..79c3509ece15dc6380ea63d1104a282851ef3616 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 8c835493af354c757b776be7122f6eca945180fd..a881601364b99ad14b4b487543c1e4e4afc199ea 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 83d30884148b1db191fe6685c2d601e6458ad3eb..20de92b6ef08730779f36c6e94222fa5521b3013 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 d32639823be88c1db33f1a70a4b0154441163402..94ec307c43e23c70a00b7ab29adf5a1ed29acc51 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 0000000000000000000000000000000000000000..22650adc3d9e29d405415e83ce92142e32cbc195 --- /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 6f0c669e158cf14429fbab1a08e85f0831a6bf1f..6bbea549c72c7733808c4c776e367916350316d3 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 c5fe623c4d4e34aab20e565c19d1fd92aba514d5..f4a5466ff85116efce61e98c2eabc5e4bf908db3 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 0000000000000000000000000000000000000000..52f19baff049695f85cf01f651aa39c52b72c947 --- /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 0000000000000000000000000000000000000000..121ae000b00f7433526f2581c7a0c7c955f99b2f --- /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 1fcfc4bb08425ee8f156cca25ef144c440afa832..67b14c319e36b615e9ec7690a1dd715ddde94b6c 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 5b32ff0405d40d7ed1c52543b00f1f2159dbd37c..aa7448865f4b4a1e72a63881217b40363563b95e 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 bb764ce0f94f16edecfa721261bf59deb4b56c2a..c8bed2e497b529fc746e3efa7f6bbec910ece76e 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 c96f331be828980f8a5f643f6ec7b40e66efd405..c3791ab8d1c2ec97c7904ebeb5e9d940828f122c 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 7e8c733b62aa8e1eaa0da0c936923e04e1738709..ef47510810004a736b67db5a196deb60ca462b48 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 a047f6d8569a974a9d5c1189404e5368d360bfe3..83171fc1491537480e2ca595af2e8ed86dba26a0 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 5cf0ab5623be9ec410b0a8e28546e1fa7f66a584..1204ba9720a3f35a1d430c19519fb6fbbaa0609c 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 5d7786ccd363fba58a480824485c402ad2405096..0000000000000000000000000000000000000000 --- 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 ec1fbcb3cedbd6cbb4af1d332eddb38d0638c58c..3ed29fdd0912d9483cdc404d59e315f38ac22b68 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 8f686703558188010e483622211c03e6901c7125..e7a4aebb9cee00835e8a2f1754415b032a54c4dc 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 dd97d7b377800cee24e9a4f4fa6bd65033128eaa..1e2a782d09583ba30719664c3b981bfcb458da3c 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 99f57b9bae9aedf89b29e1efb4acc1ae506a0e38..645758401b78f0ce6b2875d79f967240e516db14 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 7b01fdca6c1ab7de6cc5701c724b86432c6194f5..2f4c78f2a8cea31ff5047eaf75c73968da58ddf1 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"