diff --git a/src/dnode/inc/dnodeMgmt.h b/src/dnode/inc/dnodeMgmt.h index 194bde30546d6c60bd10ae2e90f437f9cc5d31e3..f92475f8ae659dda302d28edd15a93c38e92d055 100644 --- a/src/dnode/inc/dnodeMgmt.h +++ b/src/dnode/inc/dnodeMgmt.h @@ -27,7 +27,6 @@ int vnodeProcessCreateMeterRequest(char *pMsg, int msgLen, SMgmtObj *pMgmtObj); int vnodeProcessRemoveMeterRequest(char *pMsg, int msgLen, SMgmtObj *pMgmtObj); void dnodeDistributeMsgFromMgmt(char *content, int msgLen, int msgType, SMgmtObj *pObj); -void mgmtProcessMsgFromDnodeSpec(SSchedMsg *sched); extern void *dmQhandle; diff --git a/src/dnode/src/dnodeMgmt.c b/src/dnode/src/dnodeMgmt.c index 90cbf5e983ef82a0606e85ec28a2638abd57e4bf..d69ca7c2f36ac8b545ea0a6beae6400f8fafc47f 100644 --- a/src/dnode/src/dnodeMgmt.c +++ b/src/dnode/src/dnodeMgmt.c @@ -112,7 +112,7 @@ int32_t (*dnodeInitMgmt)() = dnodeInitMgmtImp; void dnodeInitMgmtIpImp() {} void (*dnodeInitMgmtIp)() = dnodeInitMgmtIpImp; -void* dnodeProcessMsgFromMgmtImp(SSchedMsg *sched) { +void dnodeProcessMsgFromMgmtImp(SSchedMsg *sched) { char msgType = *sched->msg; char *content = sched->msg + 1; @@ -121,8 +121,6 @@ void* dnodeProcessMsgFromMgmtImp(SSchedMsg *sched) { dnodeDistributeMsgFromMgmt(content, 0, msgType, 0); free(sched->msg); - - return NULL; } void dnodeDistributeMsgFromMgmt(char *content, int msgLen, int msgType, SMgmtObj *pObj) { diff --git a/src/inc/dnode.h b/src/inc/dnode.h index 8da538d6e71e09b770282b192f03d7f40a810400..d77d583dcc1d55dcb6b44a084fc76cf39151e2e3 100644 --- a/src/inc/dnode.h +++ b/src/inc/dnode.h @@ -54,6 +54,9 @@ extern void (*dnodeCleanupStorage)(); void dnodeCheckDbRunning(const char* dir); + +void dnodeProcessMsgFromMgmtImp(SSchedMsg *sched); + #ifdef __cplusplus } #endif diff --git a/src/inc/mnode.h b/src/inc/mnode.h index 7933f0461a60208d2ce829bf8a3f51b15d76f441..b608defc6a1a86847f7d211f560fc2e2c5d9731a 100644 --- a/src/inc/mnode.h +++ b/src/inc/mnode.h @@ -259,14 +259,6 @@ typedef struct { extern SAcctObj acctObj; extern SDnodeObj dnodeObj; -// dnodeInt API -int mgmtInitDnodeInt(); -void mgmtCleanUpDnodeInt(); -int mgmtSendCreateMsgToVgroup(STabObj *pTable, SVgObj *pVgroup); -int mgmtSendRemoveMeterMsgToDnode(STabObj *pTable, SVgObj *pVgroup); -int mgmtSendVPeersMsg(SVgObj *pVgroup); -int mgmtSendFreeVnodeMsg(SVgObj *pVgroup); -int mgmtSendOneFreeVnodeMsg(SVnodeGid *pVnodeGid); // shell API int mgmtInitShell(); @@ -290,13 +282,6 @@ int mgmtGetMetricMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn); int mgmtRetrieveMetrics(SShowObj *pShow, char *data, int rows, SConnObj *pConn); // DB API -int 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); /* void mgmtMonitorDbDrop(void *unused); */ void mgmtMonitorDbDrop(void *unused, void *unusedt); int mgmtAlterDb(SAcctObj *pAcct, SAlterDbMsg *pAlter); @@ -337,38 +322,12 @@ SSchema *mgmtGetTableSchema(STabObj *pTable); // get schema for a meter // dnode API -int mgmtInitDnodes(); -SDnodeObj *mgmtGetDnode(uint32_t ip); -int mgmtCreateDnode(uint32_t ip); -int mgmtDropDnode(SDnodeObj *pDnode); -int mgmtDropDnodeByIp(uint32_t ip); -int mgmtUpdateDnode(SDnodeObj *pDnode); -int mgmtGetNextVnode(SVnodeGid *pVnodeGid); -void mgmtSetDnodeVgid(SVnodeGid vnodeGid[], int numOfVnodes, int vgId); -void mgmtUnSetDnodeVgid(SVnodeGid vnodeGid[], int numOfVnodes); -int mgmtGetDnodeMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn); -int mgmtRetrieveDnodes(SShowObj *pShow, char *data, int rows, SConnObj *pConn); -void mgmtCleanUpDnodes(); -int mgmtSendCfgDnodeMsg(char *cont); -void mgmtSetDnodeMaxVnodes(SDnodeObj *pDnode); int mgmtGetMnodeMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn); int mgmtRetrieveMnodes(SShowObj *pShow, char *data, int rows, SConnObj *pConn); -int mgmtGetModuleMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn); -int mgmtRetrieveModules(SShowObj *pShow, char *data, int rows, SConnObj *pConn); -int mgmtGetConfigMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn); -int mgmtRetrieveConfigs(SShowObj *pShow, char *data, int rows, SConnObj *pConn); -int mgmtGetConnsMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn); -int mgmtRetrieveConns(SShowObj *pShow, char *data, int rows, SConnObj *pConn); - -int mgmtGetScoresMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn); -int mgmtRetrieveScores(SShowObj *pShow, char *data, int rows, SConnObj *pConn); - -int grantGetGrantsMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn); -int grantRetrieveGrants(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); @@ -377,8 +336,6 @@ int mgmtRetrieveVnodes(SShowObj *pShow, char *data, int rows, SConnObj *pConn); void mgmtSetModuleInDnode(SDnodeObj *pDnode, int moduleType); int mgmtUnSetModuleInDnode(SDnodeObj *pDnode, int moduleType); -extern int (*mgmtGetMetaFp[])(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn); -extern int (*mgmtRetrieveFp[])(SShowObj *pShow, char *data, int rows, SConnObj *pConn); extern int tsDnodeUpdateSize; extern int tsVgUpdateSize; diff --git a/src/mnode/inc/mgmtAcct.h b/src/mnode/inc/mgmtAcct.h index 3fde509ff24e6884243350eb3be9495db16ece55..8d0fb726675f5f182bda1c82948de9cdb55a643f 100644 --- a/src/mnode/inc/mgmtAcct.h +++ b/src/mnode/inc/mgmtAcct.h @@ -39,14 +39,14 @@ extern SAcctObj* (*mgmtGetAcct)(char *acctName); extern void (*mgmtCreateRootAcct)(); extern int32_t (*mgmtCheckUserLimit)(SAcctObj *pAcct); extern int32_t (*mgmtCheckDbLimit)(SAcctObj *pAcct); -extern int32_t (*mgmtCheckTableLimit)(SAcctObj *pAcct); +extern int32_t (*mgmtCheckTableLimit)(SAcctObj *pAcct, SCreateTableMsg *pCreate); extern void (*mgmtCheckAcct)(); extern void (*mgmtCleanUpAccts)(); extern int32_t (*mgmtGetAcctMeta)(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn); -extern int32_t (*mgmtRetrieveAccts)(SShowObj *pShow, char *data, int rows, SConnObj *pConn); +extern int32_t (*mgmtRetrieveAccts)(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn); #ifdef __cplusplus } #endif -#endif // TDENGINE_MGMTSYSTEM_H +#endif diff --git a/src/mnode/inc/mgmtBalance.h b/src/mnode/inc/mgmtBalance.h index 655d0444de202dfb3a17a2db9d0cf33653e69759..493f2fba0d6203a7c9ac9d3ce3134f75c94ffe67 100644 --- a/src/mnode/inc/mgmtBalance.h +++ b/src/mnode/inc/mgmtBalance.h @@ -22,9 +22,6 @@ extern "C" { #include "os.h" #include "mnode.h" -#include "tglobalcfg.h" -#include "vnodeStatus.h" -#include "ttime.h" extern void (*mgmtStartBalanceTimer)(int64_t mseconds); extern int32_t (*mgmtInitBalance)(); diff --git a/src/mnode/inc/mgmtConn.h b/src/mnode/inc/mgmtConn.h new file mode 100644 index 0000000000000000000000000000000000000000..550cf6c20d2c10f20082281186c831cc642294f1 --- /dev/null +++ b/src/mnode/inc/mgmtConn.h @@ -0,0 +1,32 @@ +/* + * 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_CONN_H +#define TDENGINE_MGMT_CONN_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "mnode.h" + +int mgmtGetConnsMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn); +int mgmtRetrieveConns(SShowObj *pShow, char *data, int rows, SConnObj *pConn); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/mnode/inc/mgmtDb.h b/src/mnode/inc/mgmtDb.h new file mode 100644 index 0000000000000000000000000000000000000000..7c29b618906b89d19e33db710970eb590c1b9740 --- /dev/null +++ b/src/mnode/inc/mgmtDb.h @@ -0,0 +1,37 @@ +/* + * 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_DB_H +#define TDENGINE_MGMT_DB_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "mnode.h" + +int 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); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/mnode/inc/mgmtDnode.h b/src/mnode/inc/mgmtDnode.h new file mode 100644 index 0000000000000000000000000000000000000000..8c835493af354c757b776be7122f6eca945180fd --- /dev/null +++ b/src/mnode/inc/mgmtDnode.h @@ -0,0 +1,59 @@ +/* + * 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_DNODE_H +#define TDENGINE_MGMT_DNODE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include "mnode.h" + +int32_t mgmtCreateDnode(uint32_t ip); +int32_t mgmtDropDnode(SDnodeObj *pDnode); +int32_t mgmtDropDnodeByIp(uint32_t ip); +int32_t mgmtGetNextVnode(SVnodeGid *pVnodeGid); +void mgmtSetDnodeVgid(SVnodeGid vnodeGid[], int numOfVnodes, int vgId); +void mgmtUnSetDnodeVgid(SVnodeGid vnodeGid[], int numOfVnodes); +int32_t mgmtGetDnodeMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn); +int32_t mgmtRetrieveDnodes(SShowObj *pShow, char *data, int rows, SConnObj *pConn); +int32_t mgmtSendCfgDnodeMsg(char *cont); +void mgmtSetDnodeMaxVnodes(SDnodeObj *pDnode); + +int32_t mgmtGetConfigMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn); +int32_t mgmtRetrieveConfigs(SShowObj *pShow, char *data, int rows, SConnObj *pConn); + +int32_t mgmtGetModuleMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn); +int32_t mgmtRetrieveModules(SShowObj *pShow, char *data, int rows, SConnObj *pConn); + +extern int32_t (*mgmtInitDnodes)(); +extern void (*mgmtCleanUpDnodes)(); +extern SDnodeObj* (*mgmtGetDnode)(uint32_t ip); +extern int32_t (*mgmtGetDnodesNum)(); +extern void* (*mgmtGetNextDnode)(SShowObj *pShow, SDnodeObj **pDnode); +extern int32_t (*mgmtUpdateDnode)(SDnodeObj *pDnode); +extern void (*mgmtSetDnodeUnRemove)(SDnodeObj *pDnode); +extern int32_t (*mgmtGetScoresMeta)(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn); +extern int32_t (*mgmtRetrieveScores)(SShowObj *pShow, char *data, int rows, SConnObj *pConn); +extern bool (*mgmtCheckConfigShow)(SGlobalConfig *cfg); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/mnode/inc/mgmtDnodeInt.h b/src/mnode/inc/mgmtDnodeInt.h new file mode 100644 index 0000000000000000000000000000000000000000..83d30884148b1db191fe6685c2d601e6458ad3eb --- /dev/null +++ b/src/mnode/inc/mgmtDnodeInt.h @@ -0,0 +1,51 @@ +/* + * 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_DNODE_INT_H +#define TDENGINE_MGMT_DNODE_INT_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include "mnode.h" + +// dnodeInt API +int mgmtSendCreateMsgToVgroup(STabObj *pTable, SVgObj *pVgroup); +int mgmtSendRemoveMeterMsgToDnode(STabObj *pTable, SVgObj *pVgroup); +int mgmtSendVPeersMsg(SVgObj *pVgroup); +int mgmtSendFreeVnodeMsg(SVgObj *pVgroup); +int mgmtSendOneFreeVnodeMsg(SVnodeGid *pVnodeGid); + +char *taosBuildRspMsgToDnode(SDnodeObj *pObj, char type); +char *taosBuildReqMsgToDnode(SDnodeObj *pObj, char type); + +extern char* (*taosBuildRspMsgToDnodeWithSize)(SDnodeObj *pObj, char type, int32_t size); +extern char* (*taosBuildReqMsgToDnodeWithSize)(SDnodeObj *pObj, char type, int32_t size); +extern int32_t (*taosSendSimpleRspToDnode)(SDnodeObj *pObj, char rsptype, char code); +extern int32_t (*taosSendMsgToDnode)(SDnodeObj *pObj, char *msg, int32_t msgLen); +extern int32_t (*mgmtInitDnodeInt)(); +extern void (*mgmtCleanUpDnodeInt)(); +extern void (*mgmtProcessDnodeStatus)(void *handle, void *tmrId); +extern void (*mgmtProcessMsgFromDnodeSpec)(SSchedMsg *sched); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/mnode/inc/mgmtGrant.h b/src/mnode/inc/mgmtGrant.h index bf19437a173451a12118473d1f659c30eb58accf..d8ae27430e630f765a559277b932c6ce6f277e00 100644 --- a/src/mnode/inc/mgmtGrant.h +++ b/src/mnode/inc/mgmtGrant.h @@ -22,6 +22,7 @@ extern "C" { #include #include +#include "mnode.h" extern bool (*mgmtCheckExpired)(); extern void (*mgmtAddTimeSeries)(uint32_t timeSeriesNum); @@ -29,6 +30,8 @@ extern void (*mgmtRestoreTimeSeries)(uint32_t timeseries); extern int32_t (*mgmtCheckTimeSeries)(uint32_t timeseries); extern int32_t (*mgmtCheckUserGrant)(); extern int32_t (*mgmtCheckDbGrant)(); +extern int32_t (*mgmtGetGrantsMeta)(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn); +extern int32_t (*mgmtRetrieveGrants)(SShowObj *pShow, char *data, int rows, SConnObj *pConn); #ifdef __cplusplus } diff --git a/src/mnode/inc/mgmtProfile.h b/src/mnode/inc/mgmtProfile.h index efc7b365c75ebd494634ece77166ee4050e41e2a..6d5a08c4bb51d827f16b4b83f85f2bc1a23241a5 100644 --- a/src/mnode/inc/mgmtProfile.h +++ b/src/mnode/inc/mgmtProfile.h @@ -13,8 +13,8 @@ * along with this program. If not, see . */ -#ifndef TDENGINE_MGMTPROFILE_H -#define TDENGINE_MGMTPROFILE_H +#ifndef TDENGINE_MGMT_PROFILE_H +#define TDENGINE_MGMT_PROFILE_H #ifdef __cplusplus extern "C" { @@ -42,4 +42,4 @@ int mgmtKillConnection(char *qidstr, SConnObj *pConn); } #endif -#endif // TDENGINE_MGMTPROFILE_H +#endif \ No newline at end of file diff --git a/src/mnode/inc/mgmtSupertableQuery.h b/src/mnode/inc/mgmtSupertableQuery.h index 86d880db446a7afc7d109213a16f9acf2b757a75..b11e763ac29517d7e20326a46d70696df442653d 100644 --- a/src/mnode/inc/mgmtSupertableQuery.h +++ b/src/mnode/inc/mgmtSupertableQuery.h @@ -20,6 +20,7 @@ #include #include #include "mnode.h" +#include "tast.h" int32_t mgmtRetrieveMetersFromSuperTable(SSuperTableMetaMsg* pInfo, int32_t tableIndex, tQueryResultset* pRes); int32_t mgmtDoJoin(SSuperTableMetaMsg* pSuperTableMetaMsg, tQueryResultset* pRes); diff --git a/src/mnode/inc/mgmtSystem.h b/src/mnode/inc/mgmtSystem.h index eabea9d4185dfce8d72a5fbd6e38141b5b9cadc0..6f0c669e158cf14429fbab1a08e85f0831a6bf1f 100644 --- a/src/mnode/inc/mgmtSystem.h +++ b/src/mnode/inc/mgmtSystem.h @@ -13,8 +13,8 @@ * along with this program. If not, see . */ -#ifndef TDENGINE_MGMTSYSTEM_H -#define TDENGINE_MGMTSYSTEM_H +#ifndef TDENGINE_MGMT_SYSTEM_H +#define TDENGINE_MGMT_SYSTEM_H #ifdef __cplusplus extern "C" { @@ -49,4 +49,4 @@ void mgmtCleanUpSystem(); } #endif -#endif // TDENGINE_MGMTSYSTEM_H +#endif diff --git a/src/mnode/inc/mgmtTable.h b/src/mnode/inc/mgmtTable.h index cf4186146d3be2413e014ef4dbe4b95ab62e55f2..c5fe623c4d4e34aab20e565c19d1fd92aba514d5 100644 --- a/src/mnode/inc/mgmtTable.h +++ b/src/mnode/inc/mgmtTable.h @@ -16,6 +16,10 @@ #ifndef TBASE_MNODE_TABLE_H #define TBASE_MNODE_TABLE_H +#ifdef __cplusplus +extern "C" { +#endif + #include #include #include @@ -23,4 +27,8 @@ int32_t mgmtFindTagCol(STabObj * pTable, const char * tagName); +#ifdef __cplusplus +} +#endif + #endif diff --git a/src/mnode/inc/mgmtUtil.h b/src/mnode/inc/mgmtUtil.h index f6fc4d0b6d6eb4ef268f3a76f18acdf49611d9d6..78889607a6f302b68e5417b90ed2cbb662b6871a 100644 --- a/src/mnode/inc/mgmtUtil.h +++ b/src/mnode/inc/mgmtUtil.h @@ -16,6 +16,10 @@ #ifndef TBASE_MNODE_UTIL_H #define TBASE_MNODE_UTIL_H +#ifdef __cplusplus +extern "C" { +#endif + #include #include #include @@ -29,4 +33,8 @@ int32_t mgmtGetTagsLength(STabObj* pSuperTable, int32_t col); bool mgmtCheckIsMonitorDB(char *db, char *monitordb); int32_t mgmtCheckDBParams(SCreateDbMsg *pCreate); +#ifdef __cplusplus +} +#endif + #endif diff --git a/src/mnode/src/mgmtAcct.c b/src/mnode/src/mgmtAcct.c index 55360e287956a6742f415d99e53895c06c87b3df..1fcfc4bb08425ee8f156cca25ef144c440afa832 100644 --- a/src/mnode/src/mgmtAcct.c +++ b/src/mnode/src/mgmtAcct.c @@ -160,8 +160,8 @@ int32_t mgmtCheckDbLimitImp(SAcctObj *pAcct) { } int32_t (*mgmtCheckDbLimit)(SAcctObj *pAcct) = mgmtCheckDbLimitImp; -int32_t mgmtCheckTableLimitImp(SAcctObj *pAcct) { return 0; } -int32_t (*mgmtCheckTableLimit)(SAcctObj *pAcct) = mgmtCheckTableLimitImp; +int32_t mgmtCheckTableLimitImp(SAcctObj *pAcct, SCreateTableMsg *pCreate) { return 0; } +int32_t (*mgmtCheckTableLimit)(SAcctObj *pAcct, SCreateTableMsg *pCreate) = mgmtCheckTableLimitImp; void mgmtCheckAcctImp() { SAcctObj *pAcct = &acctObj; diff --git a/src/mnode/src/mgmtBalance.c b/src/mnode/src/mgmtBalance.c index d7b4a88a721abd91d088ffce0b26b99a36580cba..5b32ff0405d40d7ed1c52543b00f1f2159dbd37c 100644 --- a/src/mnode/src/mgmtBalance.c +++ b/src/mnode/src/mgmtBalance.c @@ -15,8 +15,10 @@ #define _DEFAULT_SOURCE #include "mgmtBalance.h" -#include "vnodeStatus.h" #include "dnodeModule.h" +#include "tstatus.h" +#include "tglobalcfg.h" +#include "ttime.h" void mgmtStartBalanceTimerImp(int64_t mseconds) {} void (*mgmtStartBalanceTimer)(int64_t mseconds) = mgmtStartBalanceTimerImp; diff --git a/src/mnode/src/mgmtConn.c b/src/mnode/src/mgmtConn.c index 0b09b76871714f5b9404387bc27ecd3b62fb650c..9314d0b479af54d594c56a0193bc0840030a5411 100644 --- a/src/mnode/src/mgmtConn.c +++ b/src/mnode/src/mgmtConn.c @@ -15,7 +15,7 @@ #define _DEFAULT_SOURCE #include "os.h" -#include "mnode.h" +#include "mgmtConn.h" #include "taosmsg.h" #include "tschemautil.h" diff --git a/src/mnode/src/mgmtDb.c b/src/mnode/src/mgmtDb.c index 4470f58b2d9a011c1d045c9f4c66d35b3d858bb4..bb764ce0f94f16edecfa721261bf59deb4b56c2a 100644 --- a/src/mnode/src/mgmtDb.c +++ b/src/mnode/src/mgmtDb.c @@ -15,15 +15,19 @@ #define _DEFAULT_SOURCE #include "os.h" - -#include "mnode.h" +#include "mgmtDnode.h" +#include "mgmtDb.h" +#include "mgmtAcct.h" #include "mgmtGrant.h" #include "mgmtBalance.h" +#include "mgmtDnodeInt.h" #include "mgmtUtil.h" #include "tschemautil.h" -#include "vnodeStatus.h" +#include "tstatus.h" +#include "mnode.h" void *dbSdb = NULL; +extern void *vgSdb; int tsDbUpdateSize; void *(*mgmtDbActionFp[SDB_MAX_ACTION_TYPES])(void *row, char *str, int size, int *ssize); @@ -38,8 +42,6 @@ void *mgmtDbActionAfterBatchUpdate(void *row, char *str, int size, int *ssize); void *mgmtDbActionReset(void *row, char *str, int size, int *ssize); void *mgmtDbActionDestroy(void *row, char *str, int size, int *ssize); -int mgmtCheckDbLimit(SAcctObj *pAcct); - void mgmtDbActionInit() { mgmtDbActionFp[SDB_TYPE_INSERT] = mgmtDbActionInsert; mgmtDbActionFp[SDB_TYPE_DELETE] = mgmtDbActionDelete; diff --git a/src/mnode/src/mgmtDnode.c b/src/mnode/src/mgmtDnode.c index 49a0f2d45ab59a974b5a6105ee1e46c9aeeb44ad..c96f331be828980f8a5f643f6ec7b40e66efd405 100644 --- a/src/mnode/src/mgmtDnode.c +++ b/src/mnode/src/mgmtDnode.c @@ -19,15 +19,12 @@ #include "dnodeSystem.h" #include "mnode.h" +#include "mgmtDnode.h" +#include "mgmtBalance.h" #include "tschemautil.h" -#include "vnodeStatus.h" +#include "tstatus.h" #include "dnodeModule.h" -bool mgmtCheckModuleInDnode(SDnodeObj *pDnode, int moduleType); -int mgmtGetDnodesNum(); -void*mgmtGetNextDnode(SShowObj *pShow, SDnodeObj **pDnode); -bool mgmtCheckConfigShow(SGlobalConfig *cfg); - void mgmtSetDnodeMaxVnodes(SDnodeObj *pDnode) { int maxVnodes = pDnode->numOfCores * tsNumOfVnodesPerCore; maxVnodes = maxVnodes > TSDB_MAX_VNODES ? TSDB_MAX_VNODES : maxVnodes; @@ -512,4 +509,63 @@ int mgmtRetrieveVnodes(SShowObj *pShow, char *data, int rows, SConnObj *pConn) { return numOfRows; } +SDnodeObj dnodeObj; +extern uint32_t tsRebootTime; + +SDnodeObj* mgmtGetDnodeImp(uint32_t ip) { return &dnodeObj; } +SDnodeObj* (*mgmtGetDnode)(uint32_t ip) = mgmtGetDnodeImp; + +int32_t mgmtUpdateDnodeImp(SDnodeObj *pDnode) { return 0; } +int32_t (*mgmtUpdateDnode)(SDnodeObj *pDnode) = mgmtUpdateDnodeImp; + +void mgmtCleanUpDnodesImp() {} +void (*mgmtCleanUpDnodes)() = mgmtCleanUpDnodesImp; + +int32_t mgmtInitDnodesImp() { + dnodeObj.privateIp = inet_addr(tsPrivateIp);; + dnodeObj.createdTime = (int64_t)tsRebootTime * 1000; + dnodeObj.lastReboot = tsRebootTime; + dnodeObj.numOfCores = (uint16_t)tsNumOfCores; + dnodeObj.status = TSDB_DN_STATUS_READY; + dnodeObj.alternativeRole = TSDB_DNODE_ROLE_ANY; + dnodeObj.numOfTotalVnodes = tsNumOfTotalVnodes; + dnodeObj.thandle = (void*)(1); //hack way + if (dnodeObj.numOfVnodes == TSDB_INVALID_VNODE_NUM) { + mgmtSetDnodeMaxVnodes(&dnodeObj); + mPrint("dnode first access, set total vnodes:%d", dnodeObj.numOfVnodes); + } + return 0; +} +int32_t (*mgmtInitDnodes)() = mgmtInitDnodesImp; + +int32_t mgmtGetDnodesNumImp() { return 1; } +int32_t (*mgmtGetDnodesNum)() = mgmtGetDnodesNumImp; + +void* mgmtGetNextDnodeImp(SShowObj *pShow, SDnodeObj **pDnode) { + if (*pDnode == NULL) { + *pDnode = &dnodeObj; + } else { + *pDnode = NULL; + } + return *pDnode; +} +void* (*mgmtGetNextDnode)(SShowObj *pShow, SDnodeObj **pDnode) = mgmtGetNextDnodeImp; + +int32_t mgmtGetScoresMetaImp(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) { return TSDB_CODE_OPS_NOT_SUPPORT; } +int32_t (*mgmtGetScoresMeta)(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) = mgmtGetScoresMetaImp; + +int32_t mgmtRetrieveScoresImp(SShowObj *pShow, char *data, int rows, SConnObj *pConn) { return 0; } +int32_t (*mgmtRetrieveScores)(SShowObj *pShow, char *data, int rows, SConnObj *pConn) = mgmtRetrieveScoresImp; + +void mgmtSetDnodeUnRemoveImp(SDnodeObj *pDnode) {} +void (*mgmtSetDnodeUnRemove)(SDnodeObj *pDnode) = mgmtSetDnodeUnRemoveImp; + +bool mgmtCheckConfigShowImp(SGlobalConfig *cfg) { + if (cfg->cfgType & TSDB_CFG_CTYPE_B_CLUSTER) + return false; + if (cfg->cfgType & TSDB_CFG_CTYPE_B_NOT_PRINT) + return false; + return true; +} +bool (*mgmtCheckConfigShow)(SGlobalConfig *cfg) = mgmtCheckConfigShowImp; \ No newline at end of file diff --git a/src/mnode/src/mgmtDnode.spec.c b/src/mnode/src/mgmtDnode.spec.c deleted file mode 100644 index b7460360aad8bc1d004bae050a776da832eccfbf..0000000000000000000000000000000000000000 --- a/src/mnode/src/mgmtDnode.spec.c +++ /dev/null @@ -1,70 +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 "mnode.h" -#include "vnodeStatus.h" -#include "dnodeModule.h" - -SDnodeObj dnodeObj; -extern uint32_t tsRebootTime; - -SDnodeObj *mgmtGetDnode(uint32_t ip) { return &dnodeObj; } - -int mgmtUpdateDnode(SDnodeObj *pDnode) { return 0; } - -void mgmtCleanUpDnodes() {} - -int mgmtInitDnodes() { - dnodeObj.privateIp = inet_addr(tsPrivateIp);; - dnodeObj.createdTime = (int64_t)tsRebootTime * 1000; - dnodeObj.lastReboot = tsRebootTime; - dnodeObj.numOfCores = (uint16_t)tsNumOfCores; - dnodeObj.status = TSDB_DN_STATUS_READY; - dnodeObj.alternativeRole = TSDB_DNODE_ROLE_ANY; - dnodeObj.numOfTotalVnodes = tsNumOfTotalVnodes; - dnodeObj.thandle = (void*)(1); //hack way - if (dnodeObj.numOfVnodes == TSDB_INVALID_VNODE_NUM) { - mgmtSetDnodeMaxVnodes(&dnodeObj); - mPrint("dnode first access, set total vnodes:%d", dnodeObj.numOfVnodes); - } - return 0; -} - -int mgmtGetDnodesNum() { return 1; } - -void *mgmtGetNextDnode(SShowObj *pShow, SDnodeObj **pDnode) { - if (*pDnode == NULL) { - *pDnode = &dnodeObj; - } else { - *pDnode = NULL; - } - - return *pDnode; -} - -int mgmtGetScoresMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) { return TSDB_CODE_OPS_NOT_SUPPORT; } - -int mgmtRetrieveScores(SShowObj *pShow, char *data, int rows, SConnObj *pConn) { return 0; } - -void mgmtSetDnodeUnRemove(SDnodeObj *pDnode) {} - -bool mgmtCheckConfigShow(SGlobalConfig *cfg) { - if (cfg->cfgType & TSDB_CFG_CTYPE_B_CLUSTER) - return false; - if (cfg->cfgType & TSDB_CFG_CTYPE_B_NOT_PRINT) - return false; - return true; -} \ No newline at end of file diff --git a/src/mnode/src/mgmtDnodeInt.c b/src/mnode/src/mgmtDnodeInt.c index e2e9749f4b7e2671cb960eb5c5c1e66f052c37cd..7e8c733b62aa8e1eaa0da0c936923e04e1738709 100644 --- a/src/mnode/src/mgmtDnodeInt.c +++ b/src/mnode/src/mgmtDnodeInt.c @@ -16,25 +16,24 @@ #define _DEFAULT_SOURCE #include "os.h" -#include "dnodeSystem.h" #include "mnode.h" +#include "dnode.h" +#include "mgmtDnodeInt.h" #include "mgmtBalance.h" +#include "mgmtDnode.h" +#include "mgmtDb.h" #include "tutil.h" +#include "tstatus.h" +#include "tsystem.h" +#include "tsched.h" + +#include "dnodeSystem.h" void mgmtProcessMsgFromDnode(char *content, int msgLen, int msgType, SDnodeObj *pObj); int mgmtSendVPeersMsg(SVgObj *pVgroup); char *mgmtBuildVpeersIe(char *pMsg, SVgObj *pVgroup, int vnode); char *mgmtBuildCreateMeterIe(STabObj *pTable, char *pMsg, int vnode); -/* - * functions for communicate between dnode and mnode - */ -char *taosBuildRspMsgToDnodeWithSize(SDnodeObj *pObj, char type, int size); -char *taosBuildReqMsgToDnodeWithSize(SDnodeObj *pObj, char type, int size); -char *taosBuildRspMsgToDnode(SDnodeObj *pObj, char type); -char *taosBuildReqMsgToDnode(SDnodeObj *pObj, char type); -int taosSendSimpleRspToDnode(SDnodeObj *pObj, char rsptype, char code); -int taosSendMsgToDnode(SDnodeObj *pObj, char *msg, int msgLen); int mgmtProcessMeterCfgMsg(char *cont, int contLen, SDnodeObj *pObj) { char * pMsg, *pStart; @@ -502,3 +501,142 @@ int mgmtSendCfgDnodeMsg(char *cont) { #endif return 0; } + + +/* + * functions for communicate between dnode and mnode + */ + +extern void *dmQhandle; +void * mgmtStatusTimer = NULL; +void mgmtProcessMsgFromDnode(char *content, int msgLen, int msgType, SDnodeObj *pObj); + + +char* taosBuildRspMsgToDnodeWithSizeImp(SDnodeObj *pObj, char type, int32_t size) { + char *pStart = (char *)malloc(size); + if (pStart == NULL) { + return NULL; + } + + *pStart = type; + return pStart + 1; +} +char* (*taosBuildRspMsgToDnodeWithSize)(SDnodeObj *pObj, char type, int32_t size) = taosBuildRspMsgToDnodeWithSizeImp; + +char* taosBuildReqMsgToDnodeWithSizeImp(SDnodeObj *pObj, char type, int32_t size) { + char *pStart = (char *)malloc(size); + if (pStart == NULL) { + return NULL; + } + + *pStart = type; + return pStart + 1; +} +char* (*taosBuildReqMsgToDnodeWithSize)(SDnodeObj *pObj, char type, int32_t size) = taosBuildReqMsgToDnodeWithSizeImp; + +char *taosBuildRspMsgToDnode(SDnodeObj *pObj, char type) { + return taosBuildRspMsgToDnodeWithSize(pObj, type, 256); +} + +char *taosBuildReqMsgToDnode(SDnodeObj *pObj, char type) { + return taosBuildReqMsgToDnodeWithSize(pObj, type, 256); +} + +int32_t taosSendSimpleRspToDnodeImp(SDnodeObj *pObj, char rsptype, char code) { return 0; } +int32_t (*taosSendSimpleRspToDnode)(SDnodeObj *pObj, char rsptype, char code) = taosSendSimpleRspToDnodeImp; + +int32_t taosSendMsgToDnodeImp(SDnodeObj *pObj, char *msg, int32_t msgLen) { + mTrace("msg:%s is sent to dnode", taosMsg[(uint8_t)(*(msg-1))]); + + /* + * Lite version has no message header, so minus one + */ + SSchedMsg schedMsg; + schedMsg.fp = dnodeProcessMsgFromMgmtImp; + schedMsg.msg = msg - 1; + schedMsg.ahandle = NULL; + schedMsg.thandle = NULL; + taosScheduleTask(dmQhandle, &schedMsg); + + return 0; +} +int32_t (*taosSendMsgToDnode)(SDnodeObj *pObj, char *msg, int msgLen) = taosSendMsgToDnodeImp; + + +int32_t mgmtInitDnodeIntImp() { return 0; } +int32_t (*mgmtInitDnodeInt)() = mgmtInitDnodeIntImp; + +void mgmtCleanUpDnodeIntImp() {} +void (*mgmtCleanUpDnodeInt)() = mgmtCleanUpDnodeIntImp; + +void mgmtProcessDnodeStatusImp(void *handle, void *tmrId) { +/* + SDnodeObj *pObj = &dnodeObj; + pObj->openVnodes = tsOpenVnodes; + pObj->status = TSDB_DN_STATUS_READY; + + float memoryUsedMB = 0; + taosGetSysMemory(&memoryUsedMB); + pObj->diskAvailable = tsAvailDataDirGB; + + for (int vnode = 0; vnode < pObj->numOfVnodes; ++vnode) { + SVnodeLoad *pVload = &(pObj->vload[vnode]); + SVnodeObj * pVnode = vnodeList + vnode; + + // wait vnode dropped + if (pVload->dropStatus == TSDB_VN_DROP_STATUS_DROPPING) { + if (vnodeList[vnode].cfg.maxSessions <= 0) { + pVload->dropStatus = TSDB_VN_DROP_STATUS_READY; + pVload->status = TSDB_VN_STATUS_OFFLINE; + mPrint("dnode:%s, vid:%d, drop finished", taosIpStr(pObj->privateIp), vnode); + taosTmrStart(mgmtMonitorDbDrop, 10000, NULL, mgmtTmr); + } + } + + if (vnodeList[vnode].cfg.maxSessions <= 0) { + continue; + } + + pVload->vnode = vnode; + pVload->status = TSDB_VN_STATUS_MASTER; + pVload->totalStorage = pVnode->vnodeStatistic.totalStorage; + pVload->compStorage = pVnode->vnodeStatistic.compStorage; + pVload->pointsWritten = pVnode->vnodeStatistic.pointsWritten; + uint32_t vgId = pVnode->cfg.vgId; + + SVgObj *pVgroup = mgmtGetVgroup(vgId); + if (pVgroup == NULL) { + mError("vgroup:%d is not there, but associated with vnode %d", vgId, vnode); + pVload->dropStatus = TSDB_VN_DROP_STATUS_DROPPING; + continue; + } + + SDbObj *pDb = mgmtGetDb(pVgroup->dbName); + if (pDb == NULL) { + mError("vgroup:%d not belongs to any database, vnode:%d", vgId, vnode); + continue; + } + + if (pVload->vgId == 0 || pVload->dropStatus == TSDB_VN_DROP_STATUS_DROPPING) { + mError("vid:%d, mgmt not exist, drop it", vnode); + pVload->dropStatus = TSDB_VN_DROP_STATUS_DROPPING; + } + } + + taosTmrReset(mgmtProcessDnodeStatus, tsStatusInterval * 1000, NULL, mgmtTmr, &mgmtStatusTimer); + if (mgmtStatusTimer == NULL) { + mError("Failed to start status timer"); + } +*/ +} +void (*mgmtProcessDnodeStatus)(void *handle, void *tmrId) = mgmtProcessDnodeStatusImp; + +void mgmtProcessMsgFromDnodeSpecImp(SSchedMsg *sched) { + char msgType = *sched->msg; + char *content = sched->msg + 1; + mTrace("msg:%s is received from dnode", taosMsg[(uint8_t)msgType]); + + mgmtProcessMsgFromDnode(content, 0, msgType, mgmtGetDnode(0)); + free(sched->msg); +} +void (*mgmtProcessMsgFromDnodeSpec)(SSchedMsg *sched) = mgmtProcessMsgFromDnodeSpecImp; diff --git a/src/mnode/src/mgmtDnodeInt.spec.c b/src/mnode/src/mgmtDnodeInt.spec.c deleted file mode 100644 index 37d3583c0d09d5fb7917093325ac614caa520074..0000000000000000000000000000000000000000 --- a/src/mnode/src/mgmtDnodeInt.spec.c +++ /dev/null @@ -1,149 +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 - -#include "dnodeSystem.h" -#include "mnode.h" -#include "tsched.h" -#include "tutil.h" -#include "vnode.h" -#include "tsystem.h" -#include "vnodeStatus.h" - -extern void *dmQhandle; -void * mgmtStatusTimer = NULL; -void mgmtProcessMsgFromDnode(char *content, int msgLen, int msgType, SDnodeObj *pObj); -void* dnodeProcessMsgFromMgmtImp(SSchedMsg *sched); - -char *taosBuildRspMsgToDnodeWithSize(SDnodeObj *pObj, char type, int size) { - char *pStart = (char *)malloc(size); - if (pStart == NULL) { - return NULL; - } - - *pStart = type; - return pStart + 1; -} - -char *taosBuildReqMsgToDnodeWithSize(SDnodeObj *pObj, char type, int size) { - char *pStart = (char *)malloc(size); - if (pStart == NULL) { - return NULL; - } - - *pStart = type; - return pStart + 1; -} - -char *taosBuildRspMsgToDnode(SDnodeObj *pObj, char type) { - return taosBuildRspMsgToDnodeWithSize(pObj, type, 256); -} - -char *taosBuildReqMsgToDnode(SDnodeObj *pObj, char type) { - return taosBuildReqMsgToDnodeWithSize(pObj, type, 256); -} - -int taosSendSimpleRspToDnode(SDnodeObj *pObj, char rsptype, char code) { return 0; } - -int taosSendMsgToDnode(SDnodeObj *pObj, char *msg, int msgLen) { - mTrace("msg:%s is sent to dnode", taosMsg[(uint8_t)(*(msg-1))]); - - /* - * Lite version has no message header, so minus one - */ - SSchedMsg schedMsg; - schedMsg.fp = dnodeProcessMsgFromMgmtImp; - schedMsg.msg = msg - 1; - schedMsg.ahandle = NULL; - schedMsg.thandle = NULL; - taosScheduleTask(dmQhandle, &schedMsg); - - return 0; -} - -int mgmtInitDnodeInt() { return 0; } - -void mgmtCleanUpDnodeInt() {} - -void mgmtProcessDnodeStatus(void *handle, void *tmrId) { - SDnodeObj *pObj = &dnodeObj; - pObj->openVnodes = tsOpenVnodes; - pObj->status = TSDB_DN_STATUS_READY; - - float memoryUsedMB = 0; - taosGetSysMemory(&memoryUsedMB); - pObj->diskAvailable = tsAvailDataDirGB; - - for (int vnode = 0; vnode < pObj->numOfVnodes; ++vnode) { - SVnodeLoad *pVload = &(pObj->vload[vnode]); - SVnodeObj * pVnode = vnodeList + vnode; - - // wait vnode dropped - if (pVload->dropStatus == TSDB_VN_DROP_STATUS_DROPPING) { - if (vnodeList[vnode].cfg.maxSessions <= 0) { - pVload->dropStatus = TSDB_VN_DROP_STATUS_READY; - pVload->status = TSDB_VN_STATUS_OFFLINE; - mPrint("dnode:%s, vid:%d, drop finished", taosIpStr(pObj->privateIp), vnode); - taosTmrStart(mgmtMonitorDbDrop, 10000, NULL, mgmtTmr); - } - } - - if (vnodeList[vnode].cfg.maxSessions <= 0) { - continue; - } - - pVload->vnode = vnode; - pVload->status = TSDB_VN_STATUS_MASTER; - pVload->totalStorage = pVnode->vnodeStatistic.totalStorage; - pVload->compStorage = pVnode->vnodeStatistic.compStorage; - pVload->pointsWritten = pVnode->vnodeStatistic.pointsWritten; - uint32_t vgId = pVnode->cfg.vgId; - - SVgObj *pVgroup = mgmtGetVgroup(vgId); - if (pVgroup == NULL) { - mError("vgroup:%d is not there, but associated with vnode %d", vgId, vnode); - pVload->dropStatus = TSDB_VN_DROP_STATUS_DROPPING; - continue; - } - - SDbObj *pDb = mgmtGetDb(pVgroup->dbName); - if (pDb == NULL) { - mError("vgroup:%d not belongs to any database, vnode:%d", vgId, vnode); - continue; - } - - if (pVload->vgId == 0 || pVload->dropStatus == TSDB_VN_DROP_STATUS_DROPPING) { - mError("vid:%d, mgmt not exist, drop it", vnode); - pVload->dropStatus = TSDB_VN_DROP_STATUS_DROPPING; - } - } - - taosTmrReset(mgmtProcessDnodeStatus, tsStatusInterval * 1000, NULL, mgmtTmr, &mgmtStatusTimer); - if (mgmtStatusTimer == NULL) { - mError("Failed to start status timer"); - } -} - -void mgmtProcessMsgFromDnodeSpec(SSchedMsg *sched) { - char msgType = *sched->msg; - char *content = sched->msg + 1; - mTrace("msg:%s is received from dnode", taosMsg[(uint8_t)msgType]); - - mgmtProcessMsgFromDnode(content, 0, msgType, mgmtGetDnode(0)); - free(sched->msg); -} diff --git a/src/mnode/src/mgmtGrant.c b/src/mnode/src/mgmtGrant.c index 01202d98a02267a31bbbf40b0e8a30fda6e6df56..8beeae154d5ec0737f97b56a7c6768aae24bd488 100644 --- a/src/mnode/src/mgmtGrant.c +++ b/src/mnode/src/mgmtGrant.c @@ -35,4 +35,11 @@ int32_t mgmtCheckTimeSeriesImp(uint32_t timeseries) { return 0; } int32_t (*mgmtCheckTimeSeries)(uint32_t timeseries) = mgmtCheckTimeSeriesImp; bool mgmtCheckExpiredImp() { return false; } -bool (*mgmtCheckExpired)() = mgmtCheckExpiredImp; \ No newline at end of file +bool (*mgmtCheckExpired)() = mgmtCheckExpiredImp; + +int32_t mgmtGetGrantsMetaImp(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) { return TSDB_CODE_OPS_NOT_SUPPORT; } +int32_t (*mgmtGetGrantsMeta)(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) = mgmtGetGrantsMetaImp; + +int32_t mgmtRetrieveGrantsImp(SShowObj *pShow, char *data, int rows, SConnObj *pConn) { return 0; } +int32_t (*mgmtRetrieveGrants)(SShowObj *pShow, char *data, int rows, SConnObj *pConn) = mgmtRetrieveGrantsImp; + diff --git a/src/mnode/src/mgmtShell.c b/src/mnode/src/mgmtShell.c index 7867422301f1ad4ad9901f8163311e898dca7165..5cf0ab5623be9ec410b0a8e28546e1fa7f66a584 100644 --- a/src/mnode/src/mgmtShell.c +++ b/src/mnode/src/mgmtShell.c @@ -18,14 +18,28 @@ #include "dnodeSystem.h" #include "mnode.h" +#include "mgmtAcct.h" +#include "mgmtBalance.h" +#include "mgmtConn.h" +#include "mgmtDb.h" +#include "mgmtDnode.h" #include "mgmtGrant.h" #include "mgmtProfile.h" +#include "mgmtTable.h" +#include "mgmtUtil.h" #include "taosmsg.h" #include "tlog.h" -#include "vnodeStatus.h" +#include "tstatus.h" #define MAX_LEN_OF_METER_META (sizeof(SMultiMeterMeta) + sizeof(SSchema) * TSDB_MAX_COLUMNS + sizeof(SSchema) * TSDB_MAX_TAGS + TSDB_MAX_TAGS_LEN) +typedef int32_t (*GetMateFp)(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn); +typedef int32_t (*RetrieveMetaFp)(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn); +static GetMateFp* mgmtGetMetaFp; +static RetrieveMetaFp* mgmtRetrieveFp; +static void mgmtInitShowMsgFp(); + + void * pShellConn = NULL; SConnObj *connList; void * mgmtProcessMsgFromShell(char *msg, void *ahandle, void *thandle); @@ -61,6 +75,7 @@ int mgmtInitShell() { SRpcInit rpcInit; mgmtInitProcessShellMsg(); + mgmtInitShowMsgFp(); int size = sizeof(SConnObj) * tsMaxShellConns; connList = (SConnObj *)malloc(size); @@ -879,19 +894,43 @@ int mgmtProcessUseDbMsg(char *pMsg, int msgLen, SConnObj *pConn) { return 0; } -int (*mgmtGetMetaFp[])(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) = { - mgmtGetAcctMeta, mgmtGetUserMeta, mgmtGetDbMeta, mgmtGetTableMeta, mgmtGetDnodeMeta, - mgmtGetMnodeMeta, mgmtGetVgroupMeta, mgmtGetMetricMeta, mgmtGetModuleMeta, mgmtGetQueryMeta, - mgmtGetStreamMeta, mgmtGetConfigMeta, mgmtGetConnsMeta, mgmtGetScoresMeta, grantGetGrantsMeta, - mgmtGetVnodeMeta, -}; - -int (*mgmtRetrieveFp[])(SShowObj *pShow, char *data, int rows, SConnObj *pConn) = { - mgmtRetrieveAccts, mgmtRetrieveUsers, mgmtRetrieveDbs, mgmtRetrieveMeters, mgmtRetrieveDnodes, - mgmtRetrieveMnodes, mgmtRetrieveVgroups, mgmtRetrieveMetrics, mgmtRetrieveModules, mgmtRetrieveQueries, - mgmtRetrieveStreams, mgmtRetrieveConfigs, mgmtRetrieveConns, mgmtRetrieveScores, grantRetrieveGrants, - mgmtRetrieveVnodes, -}; +static void mgmtInitShowMsgFp() { + mgmtGetMetaFp = (GetMateFp *)malloc(TSDB_MGMT_TABLE_MAX * sizeof(GetMateFp)); + mgmtGetMetaFp[TSDB_MGMT_TABLE_ACCT] = mgmtGetAcctMeta; + mgmtGetMetaFp[TSDB_MGMT_TABLE_USER] = mgmtGetUserMeta; + mgmtGetMetaFp[TSDB_MGMT_TABLE_DB] = mgmtGetDbMeta; + mgmtGetMetaFp[TSDB_MGMT_TABLE_TABLE] = mgmtGetTableMeta; + mgmtGetMetaFp[TSDB_MGMT_TABLE_DNODE] = mgmtGetDnodeMeta; + mgmtGetMetaFp[TSDB_MGMT_TABLE_MNODE] = mgmtGetMnodeMeta; + mgmtGetMetaFp[TSDB_MGMT_TABLE_VGROUP] = mgmtGetVgroupMeta; + mgmtGetMetaFp[TSDB_MGMT_TABLE_METRIC] = mgmtGetMetricMeta; + mgmtGetMetaFp[TSDB_MGMT_TABLE_MODULE] = mgmtGetModuleMeta; + mgmtGetMetaFp[TSDB_MGMT_TABLE_QUERIES] = mgmtGetQueryMeta; + mgmtGetMetaFp[TSDB_MGMT_TABLE_STREAMS] = mgmtGetStreamMeta; + mgmtGetMetaFp[TSDB_MGMT_TABLE_CONFIGS] = mgmtGetConfigMeta; + mgmtGetMetaFp[TSDB_MGMT_TABLE_CONNS] = mgmtGetConnsMeta; + mgmtGetMetaFp[TSDB_MGMT_TABLE_SCORES] = mgmtGetScoresMeta; + mgmtGetMetaFp[TSDB_MGMT_TABLE_GRANTS] = mgmtGetGrantsMeta; + mgmtGetMetaFp[TSDB_MGMT_TABLE_VNODES] = mgmtGetVnodeMeta; + + mgmtRetrieveFp = (RetrieveMetaFp *)malloc(TSDB_MGMT_TABLE_MAX * sizeof(RetrieveMetaFp)); + mgmtRetrieveFp[TSDB_MGMT_TABLE_ACCT] = mgmtRetrieveAccts; + mgmtRetrieveFp[TSDB_MGMT_TABLE_USER] = mgmtRetrieveUsers; + mgmtRetrieveFp[TSDB_MGMT_TABLE_DB] = mgmtRetrieveDbs; + mgmtRetrieveFp[TSDB_MGMT_TABLE_TABLE] = mgmtRetrieveMeters; + mgmtRetrieveFp[TSDB_MGMT_TABLE_DNODE] = mgmtRetrieveDnodes; + mgmtRetrieveFp[TSDB_MGMT_TABLE_MNODE] = mgmtRetrieveMnodes; + mgmtRetrieveFp[TSDB_MGMT_TABLE_VGROUP] = mgmtRetrieveVgroups; + mgmtRetrieveFp[TSDB_MGMT_TABLE_METRIC] = mgmtRetrieveMetrics; + mgmtRetrieveFp[TSDB_MGMT_TABLE_MODULE] = mgmtRetrieveModules; + mgmtRetrieveFp[TSDB_MGMT_TABLE_QUERIES] = mgmtRetrieveQueries; + mgmtRetrieveFp[TSDB_MGMT_TABLE_STREAMS] = mgmtRetrieveStreams; + mgmtRetrieveFp[TSDB_MGMT_TABLE_CONFIGS] = mgmtRetrieveConfigs; + mgmtRetrieveFp[TSDB_MGMT_TABLE_CONNS] = mgmtRetrieveConns; + mgmtRetrieveFp[TSDB_MGMT_TABLE_SCORES] = mgmtRetrieveScores; + mgmtRetrieveFp[TSDB_MGMT_TABLE_GRANTS] = mgmtRetrieveGrants; + mgmtRetrieveFp[TSDB_MGMT_TABLE_VNODES] = mgmtRetrieveVnodes; +} int mgmtProcessShowMsg(char *pMsg, int msgLen, SConnObj *pConn) { SShowMsg * pShowMsg = (SShowMsg *)pMsg; diff --git a/src/mnode/src/mgmtSupertableQuery.c b/src/mnode/src/mgmtSupertableQuery.c index 022251ab57b14c107d5497afd5f783f810b3cba9..9dcff0b1af3cc4f3e1febb8c2b8563f365c9634c 100644 --- a/src/mnode/src/mgmtSupertableQuery.c +++ b/src/mnode/src/mgmtSupertableQuery.c @@ -15,13 +15,13 @@ #define _DEFAULT_SOURCE #include "os.h" - #include "mnode.h" #include "mgmtUtil.h" #include "textbuffer.h" #include "tschemautil.h" #include "tsqlfunction.h" -#include "vnodeTagMgmt.h" +#include "tast.h" +//#include "vnodeTagMgmt.h" typedef struct SSyntaxTreeFilterSupporter { SSchema* pTagSchema; diff --git a/src/mnode/src/mgmtSystem.spec.c b/src/mnode/src/mgmtSystem.spec.c index 17a089243656d88b9833bf4158eb71cb80fcf9da..a047f6d8569a974a9d5c1189404e5368d360bfe3 100644 --- a/src/mnode/src/mgmtSystem.spec.c +++ b/src/mnode/src/mgmtSystem.spec.c @@ -36,8 +36,3 @@ void mgmtStopSystem() {} void mgmtCleanUpRedirect() {} - -int grantGetGrantsMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) { return TSDB_CODE_OPS_NOT_SUPPORT; } - -int grantRetrieveGrants(SShowObj *pShow, char *data, int rows, SConnObj *pConn) { return 0; } - diff --git a/src/mnode/src/mgmtTable.c b/src/mnode/src/mgmtTable.c index 325d880d332493c9541b87fb257a5c7e48012ecc..8f686703558188010e483622211c03e6901c7125 100644 --- a/src/mnode/src/mgmtTable.c +++ b/src/mnode/src/mgmtTable.c @@ -20,6 +20,9 @@ #include "mgmtAcct.h" #include "mgmtGrant.h" #include "mgmtUtil.h" +#include "mgmtDb.h" +#include "mgmtDnodeInt.h" +#include "mgmtSupertableQuery.h" #include "taosmsg.h" #include "tast.h" #include "textbuffer.h" @@ -28,8 +31,7 @@ #include "tskiplist.h" #include "tsqlfunction.h" #include "ttime.h" -#include "vnodeTagMgmt.h" -#include "vnodeStatus.h" +#include "tstatus.h" extern int64_t sdbVersion; @@ -93,8 +95,6 @@ int32_t mgmtMeterDropColumnByName(STabObj *pTable, const char *name); static int dropMeterImp(SDbObj *pDb, STabObj * pTable, SAcctObj *pAcct); static void dropAllMetersOfMetric(SDbObj *pDb, STabObj * pMetric, SAcctObj *pAcct); -int mgmtCheckTableLimit(SAcctObj *pAcct, SCreateTableMsg *pCreate); - void mgmtMeterActionInit() { mgmtMeterActionFp[SDB_TYPE_INSERT] = mgmtMeterActionInsert; mgmtMeterActionFp[SDB_TYPE_DELETE] = mgmtMeterActionDelete; diff --git a/src/mnode/src/mgmtVgroup.c b/src/mnode/src/mgmtVgroup.c index 4594da1a910bdfc1d7b35c954b0ac79abdcba05a..7b01fdca6c1ab7de6cc5701c724b86432c6194f5 100644 --- a/src/mnode/src/mgmtVgroup.c +++ b/src/mnode/src/mgmtVgroup.c @@ -17,9 +17,13 @@ #include "os.h" #include "mnode.h" +#include "mgmtBalance.h" +#include "mgmtDb.h" +#include "mgmtDnode.h" +#include "mgmtDnodeInt.h" #include "tschemautil.h" #include "tlog.h" -#include "vnodeStatus.h" +#include "tstatus.h" void * vgSdb = NULL; int tsVgUpdateSize; @@ -39,8 +43,6 @@ void *mgmtVgroupActionBatchUpdate(void *row, char *str, int size, int *ssize); void *mgmtVgroupActionAfterBatchUpdate(void *row, char *str, int size, int *ssize); void *mgmtVgroupActionReset(void *row, char *str, int size, int *ssize); void *mgmtVgroupActionDestroy(void *row, char *str, int size, int *ssize); -bool mgmtCheckVnodeReady(SDnodeObj *pDnode, SVgObj *pVgroup, SVnodeGid *pVnode); -char *mgmtGetVnodeStatus(SVgObj *pVgroup, SVnodeGid *pVnode); void mgmtVgroupActionInit() { mgmtVgroupActionFp[SDB_TYPE_INSERT] = mgmtVgroupActionInsert; diff --git a/src/util/inc/textbuffer.h b/src/util/inc/textbuffer.h index c7de20bd746d5889cc9d2c6407743ecace557bae..b5e3c55ad69020be80bb41fe9bb161f5e0903600 100644 --- a/src/util/inc/textbuffer.h +++ b/src/util/inc/textbuffer.h @@ -123,6 +123,22 @@ typedef struct tExtMemBuffer { EXT_BUFFER_FLUSH_MODEL flushModel; } tExtMemBuffer; +typedef struct tTagSchema { + struct SSchema *pSchema; + int32_t numOfCols; + int32_t colOffset[]; +} tTagSchema; + +typedef struct tSidSet { + int32_t numOfSids; + int32_t numOfSubSet; + SMeterSidExtInfo **pSids; + int32_t * starterPos; // position of each subgroup, generated according to + + tTagSchema *pTagSchema; + tOrderIdx orderIdx; +} tSidSet; + void getTmpfilePath(const char *fileNamePattern, char *dstPath); /* diff --git a/src/util/inc/tstatus.h b/src/util/inc/tstatus.h index bdcd2e68a2de2c5405406b317d68049ea4d8d54f..2e848ebfcdc56e8fff4102900ae7dd8c67fb4e08 100644 --- a/src/util/inc/tstatus.h +++ b/src/util/inc/tstatus.h @@ -19,7 +19,7 @@ #ifdef __cplusplus extern "C" { #endif - + #include #include #include "taoserror.h" diff --git a/src/vnode/detail/inc/vnodeTagMgmt.h b/src/vnode/detail/inc/vnodeTagMgmt.h index 320ef5645395e08578d206b4f9db89809b56dafb..952dc58993bfd709590e0d5c8d3fbd8966973dbf 100644 --- a/src/vnode/detail/inc/vnodeTagMgmt.h +++ b/src/vnode/detail/inc/vnodeTagMgmt.h @@ -33,22 +33,6 @@ extern "C" { * 1. we implement a quick sort algorithm, may remove it later. */ -typedef struct tTagSchema { - struct SSchema *pSchema; - int32_t numOfCols; - int32_t colOffset[]; -} tTagSchema; - -typedef struct tSidSet { - int32_t numOfSids; - int32_t numOfSubSet; - SMeterSidExtInfo **pSids; - int32_t * starterPos; // position of each subgroup, generated according to - - tTagSchema *pTagSchema; - tOrderIdx orderIdx; -} tSidSet; - typedef int32_t (*__ext_compar_fn_t)(const void *p1, const void *p2, void *param); tSidSet *tSidSetCreate(struct SMeterSidExtInfo **pMeterSidExtInfo, int32_t numOfMeters, SSchema *pSchema,