提交 9427e9d8 编写于 作者: S slguan

sort out mnode

上级 ded484b5
...@@ -27,7 +27,6 @@ int vnodeProcessCreateMeterRequest(char *pMsg, int msgLen, SMgmtObj *pMgmtObj); ...@@ -27,7 +27,6 @@ int vnodeProcessCreateMeterRequest(char *pMsg, int msgLen, SMgmtObj *pMgmtObj);
int vnodeProcessRemoveMeterRequest(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 dnodeDistributeMsgFromMgmt(char *content, int msgLen, int msgType, SMgmtObj *pObj);
void mgmtProcessMsgFromDnodeSpec(SSchedMsg *sched);
extern void *dmQhandle; extern void *dmQhandle;
......
...@@ -112,7 +112,7 @@ int32_t (*dnodeInitMgmt)() = dnodeInitMgmtImp; ...@@ -112,7 +112,7 @@ int32_t (*dnodeInitMgmt)() = dnodeInitMgmtImp;
void dnodeInitMgmtIpImp() {} void dnodeInitMgmtIpImp() {}
void (*dnodeInitMgmtIp)() = dnodeInitMgmtIpImp; void (*dnodeInitMgmtIp)() = dnodeInitMgmtIpImp;
void* dnodeProcessMsgFromMgmtImp(SSchedMsg *sched) { void dnodeProcessMsgFromMgmtImp(SSchedMsg *sched) {
char msgType = *sched->msg; char msgType = *sched->msg;
char *content = sched->msg + 1; char *content = sched->msg + 1;
...@@ -121,8 +121,6 @@ void* dnodeProcessMsgFromMgmtImp(SSchedMsg *sched) { ...@@ -121,8 +121,6 @@ void* dnodeProcessMsgFromMgmtImp(SSchedMsg *sched) {
dnodeDistributeMsgFromMgmt(content, 0, msgType, 0); dnodeDistributeMsgFromMgmt(content, 0, msgType, 0);
free(sched->msg); free(sched->msg);
return NULL;
} }
void dnodeDistributeMsgFromMgmt(char *content, int msgLen, int msgType, SMgmtObj *pObj) { void dnodeDistributeMsgFromMgmt(char *content, int msgLen, int msgType, SMgmtObj *pObj) {
......
...@@ -54,6 +54,9 @@ extern void (*dnodeCleanupStorage)(); ...@@ -54,6 +54,9 @@ extern void (*dnodeCleanupStorage)();
void dnodeCheckDbRunning(const char* dir); void dnodeCheckDbRunning(const char* dir);
void dnodeProcessMsgFromMgmtImp(SSchedMsg *sched);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -259,14 +259,6 @@ typedef struct { ...@@ -259,14 +259,6 @@ typedef struct {
extern SAcctObj acctObj; extern SAcctObj acctObj;
extern SDnodeObj dnodeObj; 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 // shell API
int mgmtInitShell(); int mgmtInitShell();
...@@ -290,13 +282,6 @@ int mgmtGetMetricMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn); ...@@ -290,13 +282,6 @@ int mgmtGetMetricMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn);
int mgmtRetrieveMetrics(SShowObj *pShow, char *data, int rows, SConnObj *pConn); int mgmtRetrieveMetrics(SShowObj *pShow, char *data, int rows, SConnObj *pConn);
// DB API // 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 mgmtMonitorDbDrop(void *unused, void *unusedt); void mgmtMonitorDbDrop(void *unused, void *unusedt);
int mgmtAlterDb(SAcctObj *pAcct, SAlterDbMsg *pAlter); int mgmtAlterDb(SAcctObj *pAcct, SAlterDbMsg *pAlter);
...@@ -337,38 +322,12 @@ SSchema *mgmtGetTableSchema(STabObj *pTable); // get schema for a meter ...@@ -337,38 +322,12 @@ SSchema *mgmtGetTableSchema(STabObj *pTable); // get schema for a meter
// dnode API // 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 mgmtGetMnodeMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn);
int mgmtRetrieveMnodes(SShowObj *pShow, char *data, int rows, 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 mgmtGetVnodeMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn);
int mgmtRetrieveVnodes(SShowObj *pShow, char *data, int rows, 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); ...@@ -377,8 +336,6 @@ int mgmtRetrieveVnodes(SShowObj *pShow, char *data, int rows, SConnObj *pConn);
void mgmtSetModuleInDnode(SDnodeObj *pDnode, int moduleType); void mgmtSetModuleInDnode(SDnodeObj *pDnode, int moduleType);
int mgmtUnSetModuleInDnode(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 tsDnodeUpdateSize;
extern int tsVgUpdateSize; extern int tsVgUpdateSize;
......
...@@ -39,14 +39,14 @@ extern SAcctObj* (*mgmtGetAcct)(char *acctName); ...@@ -39,14 +39,14 @@ extern SAcctObj* (*mgmtGetAcct)(char *acctName);
extern void (*mgmtCreateRootAcct)(); extern void (*mgmtCreateRootAcct)();
extern int32_t (*mgmtCheckUserLimit)(SAcctObj *pAcct); extern int32_t (*mgmtCheckUserLimit)(SAcctObj *pAcct);
extern int32_t (*mgmtCheckDbLimit)(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 (*mgmtCheckAcct)();
extern void (*mgmtCleanUpAccts)(); extern void (*mgmtCleanUpAccts)();
extern int32_t (*mgmtGetAcctMeta)(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn); 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 #ifdef __cplusplus
} }
#endif #endif
#endif // TDENGINE_MGMTSYSTEM_H #endif
...@@ -22,9 +22,6 @@ extern "C" { ...@@ -22,9 +22,6 @@ extern "C" {
#include "os.h" #include "os.h"
#include "mnode.h" #include "mnode.h"
#include "tglobalcfg.h"
#include "vnodeStatus.h"
#include "ttime.h"
extern void (*mgmtStartBalanceTimer)(int64_t mseconds); extern void (*mgmtStartBalanceTimer)(int64_t mseconds);
extern int32_t (*mgmtInitBalance)(); extern int32_t (*mgmtInitBalance)();
......
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#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
...@@ -13,58 +13,25 @@ ...@@ -13,58 +13,25 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#define _DEFAULT_SOURCE #ifndef TDENGINE_MGMT_DB_H
#include "mnode.h" #define TDENGINE_MGMT_DB_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() { #ifdef __cplusplus
dnodeObj.privateIp = inet_addr(tsPrivateIp);; extern "C" {
dnodeObj.createdTime = (int64_t)tsRebootTime * 1000; #endif
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; } #include "mnode.h"
void *mgmtGetNextDnode(SShowObj *pShow, SDnodeObj **pDnode) { int mgmtInitDbs();
if (*pDnode == NULL) { int mgmtUpdateDb(SDbObj *pDb);
*pDnode = &dnodeObj; SDbObj *mgmtGetDb(char *db);
} else { SDbObj *mgmtGetDbByMeterId(char *db);
*pDnode = NULL; int mgmtCreateDb(SAcctObj *pAcct, SCreateDbMsg *pCreate);
} int mgmtDropDbByName(SAcctObj *pAcct, char *name, short ignoreNotExists);
int mgmtDropDb(SDbObj *pDb);
return *pDnode; #ifdef __cplusplus
} }
#endif
int mgmtGetScoresMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) { return TSDB_CODE_OPS_NOT_SUPPORT; } #endif
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
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TDENGINE_MGMT_DNODE_H
#define TDENGINE_MGMT_DNODE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stdbool.h>
#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
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TDENGINE_MGMT_DNODE_INT_H
#define TDENGINE_MGMT_DNODE_INT_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stdbool.h>
#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
...@@ -22,6 +22,7 @@ extern "C" { ...@@ -22,6 +22,7 @@ extern "C" {
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include "mnode.h"
extern bool (*mgmtCheckExpired)(); extern bool (*mgmtCheckExpired)();
extern void (*mgmtAddTimeSeries)(uint32_t timeSeriesNum); extern void (*mgmtAddTimeSeries)(uint32_t timeSeriesNum);
...@@ -29,6 +30,8 @@ extern void (*mgmtRestoreTimeSeries)(uint32_t timeseries); ...@@ -29,6 +30,8 @@ extern void (*mgmtRestoreTimeSeries)(uint32_t timeseries);
extern int32_t (*mgmtCheckTimeSeries)(uint32_t timeseries); extern int32_t (*mgmtCheckTimeSeries)(uint32_t timeseries);
extern int32_t (*mgmtCheckUserGrant)(); extern int32_t (*mgmtCheckUserGrant)();
extern int32_t (*mgmtCheckDbGrant)(); 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 #ifdef __cplusplus
} }
......
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TDENGINE_MGMTPROFILE_H #ifndef TDENGINE_MGMT_PROFILE_H
#define TDENGINE_MGMTPROFILE_H #define TDENGINE_MGMT_PROFILE_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
...@@ -42,4 +42,4 @@ int mgmtKillConnection(char *qidstr, SConnObj *pConn); ...@@ -42,4 +42,4 @@ int mgmtKillConnection(char *qidstr, SConnObj *pConn);
} }
#endif #endif
#endif // TDENGINE_MGMTPROFILE_H #endif
\ No newline at end of file
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
#include "mnode.h" #include "mnode.h"
#include "tast.h"
int32_t mgmtRetrieveMetersFromSuperTable(SSuperTableMetaMsg* pInfo, int32_t tableIndex, tQueryResultset* pRes); int32_t mgmtRetrieveMetersFromSuperTable(SSuperTableMetaMsg* pInfo, int32_t tableIndex, tQueryResultset* pRes);
int32_t mgmtDoJoin(SSuperTableMetaMsg* pSuperTableMetaMsg, tQueryResultset* pRes); int32_t mgmtDoJoin(SSuperTableMetaMsg* pSuperTableMetaMsg, tQueryResultset* pRes);
......
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TDENGINE_MGMTSYSTEM_H #ifndef TDENGINE_MGMT_SYSTEM_H
#define TDENGINE_MGMTSYSTEM_H #define TDENGINE_MGMT_SYSTEM_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
...@@ -49,4 +49,4 @@ void mgmtCleanUpSystem(); ...@@ -49,4 +49,4 @@ void mgmtCleanUpSystem();
} }
#endif #endif
#endif // TDENGINE_MGMTSYSTEM_H #endif
...@@ -16,6 +16,10 @@ ...@@ -16,6 +16,10 @@
#ifndef TBASE_MNODE_TABLE_H #ifndef TBASE_MNODE_TABLE_H
#define TBASE_MNODE_TABLE_H #define TBASE_MNODE_TABLE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
...@@ -23,4 +27,8 @@ ...@@ -23,4 +27,8 @@
int32_t mgmtFindTagCol(STabObj * pTable, const char * tagName); int32_t mgmtFindTagCol(STabObj * pTable, const char * tagName);
#ifdef __cplusplus
}
#endif
#endif #endif
...@@ -16,6 +16,10 @@ ...@@ -16,6 +16,10 @@
#ifndef TBASE_MNODE_UTIL_H #ifndef TBASE_MNODE_UTIL_H
#define TBASE_MNODE_UTIL_H #define TBASE_MNODE_UTIL_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
...@@ -29,4 +33,8 @@ int32_t mgmtGetTagsLength(STabObj* pSuperTable, int32_t col); ...@@ -29,4 +33,8 @@ int32_t mgmtGetTagsLength(STabObj* pSuperTable, int32_t col);
bool mgmtCheckIsMonitorDB(char *db, char *monitordb); bool mgmtCheckIsMonitorDB(char *db, char *monitordb);
int32_t mgmtCheckDBParams(SCreateDbMsg *pCreate); int32_t mgmtCheckDBParams(SCreateDbMsg *pCreate);
#ifdef __cplusplus
}
#endif
#endif #endif
...@@ -160,8 +160,8 @@ int32_t mgmtCheckDbLimitImp(SAcctObj *pAcct) { ...@@ -160,8 +160,8 @@ int32_t mgmtCheckDbLimitImp(SAcctObj *pAcct) {
} }
int32_t (*mgmtCheckDbLimit)(SAcctObj *pAcct) = mgmtCheckDbLimitImp; int32_t (*mgmtCheckDbLimit)(SAcctObj *pAcct) = mgmtCheckDbLimitImp;
int32_t mgmtCheckTableLimitImp(SAcctObj *pAcct) { return 0; } int32_t mgmtCheckTableLimitImp(SAcctObj *pAcct, SCreateTableMsg *pCreate) { return 0; }
int32_t (*mgmtCheckTableLimit)(SAcctObj *pAcct) = mgmtCheckTableLimitImp; int32_t (*mgmtCheckTableLimit)(SAcctObj *pAcct, SCreateTableMsg *pCreate) = mgmtCheckTableLimitImp;
void mgmtCheckAcctImp() { void mgmtCheckAcctImp() {
SAcctObj *pAcct = &acctObj; SAcctObj *pAcct = &acctObj;
......
...@@ -15,8 +15,10 @@ ...@@ -15,8 +15,10 @@
#define _DEFAULT_SOURCE #define _DEFAULT_SOURCE
#include "mgmtBalance.h" #include "mgmtBalance.h"
#include "vnodeStatus.h"
#include "dnodeModule.h" #include "dnodeModule.h"
#include "tstatus.h"
#include "tglobalcfg.h"
#include "ttime.h"
void mgmtStartBalanceTimerImp(int64_t mseconds) {} void mgmtStartBalanceTimerImp(int64_t mseconds) {}
void (*mgmtStartBalanceTimer)(int64_t mseconds) = mgmtStartBalanceTimerImp; void (*mgmtStartBalanceTimer)(int64_t mseconds) = mgmtStartBalanceTimerImp;
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#define _DEFAULT_SOURCE #define _DEFAULT_SOURCE
#include "os.h" #include "os.h"
#include "mnode.h" #include "mgmtConn.h"
#include "taosmsg.h" #include "taosmsg.h"
#include "tschemautil.h" #include "tschemautil.h"
......
...@@ -15,15 +15,19 @@ ...@@ -15,15 +15,19 @@
#define _DEFAULT_SOURCE #define _DEFAULT_SOURCE
#include "os.h" #include "os.h"
#include "mgmtDnode.h"
#include "mnode.h" #include "mgmtDb.h"
#include "mgmtAcct.h"
#include "mgmtGrant.h" #include "mgmtGrant.h"
#include "mgmtBalance.h" #include "mgmtBalance.h"
#include "mgmtDnodeInt.h"
#include "mgmtUtil.h" #include "mgmtUtil.h"
#include "tschemautil.h" #include "tschemautil.h"
#include "vnodeStatus.h" #include "tstatus.h"
#include "mnode.h"
void *dbSdb = NULL; void *dbSdb = NULL;
extern void *vgSdb;
int tsDbUpdateSize; int tsDbUpdateSize;
void *(*mgmtDbActionFp[SDB_MAX_ACTION_TYPES])(void *row, char *str, int size, int *ssize); 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); ...@@ -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 *mgmtDbActionReset(void *row, char *str, int size, int *ssize);
void *mgmtDbActionDestroy(void *row, char *str, int size, int *ssize); void *mgmtDbActionDestroy(void *row, char *str, int size, int *ssize);
int mgmtCheckDbLimit(SAcctObj *pAcct);
void mgmtDbActionInit() { void mgmtDbActionInit() {
mgmtDbActionFp[SDB_TYPE_INSERT] = mgmtDbActionInsert; mgmtDbActionFp[SDB_TYPE_INSERT] = mgmtDbActionInsert;
mgmtDbActionFp[SDB_TYPE_DELETE] = mgmtDbActionDelete; mgmtDbActionFp[SDB_TYPE_DELETE] = mgmtDbActionDelete;
......
...@@ -19,15 +19,12 @@ ...@@ -19,15 +19,12 @@
#include "dnodeSystem.h" #include "dnodeSystem.h"
#include "mnode.h" #include "mnode.h"
#include "mgmtDnode.h"
#include "mgmtBalance.h"
#include "tschemautil.h" #include "tschemautil.h"
#include "vnodeStatus.h" #include "tstatus.h"
#include "dnodeModule.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) { void mgmtSetDnodeMaxVnodes(SDnodeObj *pDnode) {
int maxVnodes = pDnode->numOfCores * tsNumOfVnodesPerCore; int maxVnodes = pDnode->numOfCores * tsNumOfVnodesPerCore;
maxVnodes = maxVnodes > TSDB_MAX_VNODES ? TSDB_MAX_VNODES : maxVnodes; maxVnodes = maxVnodes > TSDB_MAX_VNODES ? TSDB_MAX_VNODES : maxVnodes;
...@@ -512,4 +509,63 @@ int mgmtRetrieveVnodes(SShowObj *pShow, char *data, int rows, SConnObj *pConn) { ...@@ -512,4 +509,63 @@ int mgmtRetrieveVnodes(SShowObj *pShow, char *data, int rows, SConnObj *pConn) {
return numOfRows; 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
...@@ -16,25 +16,24 @@ ...@@ -16,25 +16,24 @@
#define _DEFAULT_SOURCE #define _DEFAULT_SOURCE
#include "os.h" #include "os.h"
#include "dnodeSystem.h"
#include "mnode.h" #include "mnode.h"
#include "dnode.h"
#include "mgmtDnodeInt.h"
#include "mgmtBalance.h" #include "mgmtBalance.h"
#include "mgmtDnode.h"
#include "mgmtDb.h"
#include "tutil.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); void mgmtProcessMsgFromDnode(char *content, int msgLen, int msgType, SDnodeObj *pObj);
int mgmtSendVPeersMsg(SVgObj *pVgroup); int mgmtSendVPeersMsg(SVgObj *pVgroup);
char *mgmtBuildVpeersIe(char *pMsg, SVgObj *pVgroup, int vnode); char *mgmtBuildVpeersIe(char *pMsg, SVgObj *pVgroup, int vnode);
char *mgmtBuildCreateMeterIe(STabObj *pTable, char *pMsg, 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) { int mgmtProcessMeterCfgMsg(char *cont, int contLen, SDnodeObj *pObj) {
char * pMsg, *pStart; char * pMsg, *pStart;
...@@ -502,3 +501,142 @@ int mgmtSendCfgDnodeMsg(char *cont) { ...@@ -502,3 +501,142 @@ int mgmtSendCfgDnodeMsg(char *cont) {
#endif #endif
return 0; 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;
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include <arpa/inet.h>
#include <endian.h>
#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);
}
...@@ -35,4 +35,11 @@ int32_t mgmtCheckTimeSeriesImp(uint32_t timeseries) { return 0; } ...@@ -35,4 +35,11 @@ int32_t mgmtCheckTimeSeriesImp(uint32_t timeseries) { return 0; }
int32_t (*mgmtCheckTimeSeries)(uint32_t timeseries) = mgmtCheckTimeSeriesImp; int32_t (*mgmtCheckTimeSeries)(uint32_t timeseries) = mgmtCheckTimeSeriesImp;
bool mgmtCheckExpiredImp() { return false; } bool mgmtCheckExpiredImp() { return false; }
bool (*mgmtCheckExpired)() = mgmtCheckExpiredImp; bool (*mgmtCheckExpired)() = mgmtCheckExpiredImp;
\ No newline at end of file
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;
...@@ -18,14 +18,28 @@ ...@@ -18,14 +18,28 @@
#include "dnodeSystem.h" #include "dnodeSystem.h"
#include "mnode.h" #include "mnode.h"
#include "mgmtAcct.h"
#include "mgmtBalance.h"
#include "mgmtConn.h"
#include "mgmtDb.h"
#include "mgmtDnode.h"
#include "mgmtGrant.h" #include "mgmtGrant.h"
#include "mgmtProfile.h" #include "mgmtProfile.h"
#include "mgmtTable.h"
#include "mgmtUtil.h"
#include "taosmsg.h" #include "taosmsg.h"
#include "tlog.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) #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; void * pShellConn = NULL;
SConnObj *connList; SConnObj *connList;
void * mgmtProcessMsgFromShell(char *msg, void *ahandle, void *thandle); void * mgmtProcessMsgFromShell(char *msg, void *ahandle, void *thandle);
...@@ -61,6 +75,7 @@ int mgmtInitShell() { ...@@ -61,6 +75,7 @@ int mgmtInitShell() {
SRpcInit rpcInit; SRpcInit rpcInit;
mgmtInitProcessShellMsg(); mgmtInitProcessShellMsg();
mgmtInitShowMsgFp();
int size = sizeof(SConnObj) * tsMaxShellConns; int size = sizeof(SConnObj) * tsMaxShellConns;
connList = (SConnObj *)malloc(size); connList = (SConnObj *)malloc(size);
...@@ -879,19 +894,43 @@ int mgmtProcessUseDbMsg(char *pMsg, int msgLen, SConnObj *pConn) { ...@@ -879,19 +894,43 @@ int mgmtProcessUseDbMsg(char *pMsg, int msgLen, SConnObj *pConn) {
return 0; return 0;
} }
int (*mgmtGetMetaFp[])(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) = { static void mgmtInitShowMsgFp() {
mgmtGetAcctMeta, mgmtGetUserMeta, mgmtGetDbMeta, mgmtGetTableMeta, mgmtGetDnodeMeta, mgmtGetMetaFp = (GetMateFp *)malloc(TSDB_MGMT_TABLE_MAX * sizeof(GetMateFp));
mgmtGetMnodeMeta, mgmtGetVgroupMeta, mgmtGetMetricMeta, mgmtGetModuleMeta, mgmtGetQueryMeta, mgmtGetMetaFp[TSDB_MGMT_TABLE_ACCT] = mgmtGetAcctMeta;
mgmtGetStreamMeta, mgmtGetConfigMeta, mgmtGetConnsMeta, mgmtGetScoresMeta, grantGetGrantsMeta, mgmtGetMetaFp[TSDB_MGMT_TABLE_USER] = mgmtGetUserMeta;
mgmtGetVnodeMeta, mgmtGetMetaFp[TSDB_MGMT_TABLE_DB] = mgmtGetDbMeta;
}; mgmtGetMetaFp[TSDB_MGMT_TABLE_TABLE] = mgmtGetTableMeta;
mgmtGetMetaFp[TSDB_MGMT_TABLE_DNODE] = mgmtGetDnodeMeta;
int (*mgmtRetrieveFp[])(SShowObj *pShow, char *data, int rows, SConnObj *pConn) = { mgmtGetMetaFp[TSDB_MGMT_TABLE_MNODE] = mgmtGetMnodeMeta;
mgmtRetrieveAccts, mgmtRetrieveUsers, mgmtRetrieveDbs, mgmtRetrieveMeters, mgmtRetrieveDnodes, mgmtGetMetaFp[TSDB_MGMT_TABLE_VGROUP] = mgmtGetVgroupMeta;
mgmtRetrieveMnodes, mgmtRetrieveVgroups, mgmtRetrieveMetrics, mgmtRetrieveModules, mgmtRetrieveQueries, mgmtGetMetaFp[TSDB_MGMT_TABLE_METRIC] = mgmtGetMetricMeta;
mgmtRetrieveStreams, mgmtRetrieveConfigs, mgmtRetrieveConns, mgmtRetrieveScores, grantRetrieveGrants, mgmtGetMetaFp[TSDB_MGMT_TABLE_MODULE] = mgmtGetModuleMeta;
mgmtRetrieveVnodes, 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) { int mgmtProcessShowMsg(char *pMsg, int msgLen, SConnObj *pConn) {
SShowMsg * pShowMsg = (SShowMsg *)pMsg; SShowMsg * pShowMsg = (SShowMsg *)pMsg;
......
...@@ -15,13 +15,13 @@ ...@@ -15,13 +15,13 @@
#define _DEFAULT_SOURCE #define _DEFAULT_SOURCE
#include "os.h" #include "os.h"
#include "mnode.h" #include "mnode.h"
#include "mgmtUtil.h" #include "mgmtUtil.h"
#include "textbuffer.h" #include "textbuffer.h"
#include "tschemautil.h" #include "tschemautil.h"
#include "tsqlfunction.h" #include "tsqlfunction.h"
#include "vnodeTagMgmt.h" #include "tast.h"
//#include "vnodeTagMgmt.h"
typedef struct SSyntaxTreeFilterSupporter { typedef struct SSyntaxTreeFilterSupporter {
SSchema* pTagSchema; SSchema* pTagSchema;
......
...@@ -36,8 +36,3 @@ void mgmtStopSystem() {} ...@@ -36,8 +36,3 @@ void mgmtStopSystem() {}
void mgmtCleanUpRedirect() {} 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; }
...@@ -20,6 +20,9 @@ ...@@ -20,6 +20,9 @@
#include "mgmtAcct.h" #include "mgmtAcct.h"
#include "mgmtGrant.h" #include "mgmtGrant.h"
#include "mgmtUtil.h" #include "mgmtUtil.h"
#include "mgmtDb.h"
#include "mgmtDnodeInt.h"
#include "mgmtSupertableQuery.h"
#include "taosmsg.h" #include "taosmsg.h"
#include "tast.h" #include "tast.h"
#include "textbuffer.h" #include "textbuffer.h"
...@@ -28,8 +31,7 @@ ...@@ -28,8 +31,7 @@
#include "tskiplist.h" #include "tskiplist.h"
#include "tsqlfunction.h" #include "tsqlfunction.h"
#include "ttime.h" #include "ttime.h"
#include "vnodeTagMgmt.h" #include "tstatus.h"
#include "vnodeStatus.h"
extern int64_t sdbVersion; extern int64_t sdbVersion;
...@@ -93,8 +95,6 @@ int32_t mgmtMeterDropColumnByName(STabObj *pTable, const char *name); ...@@ -93,8 +95,6 @@ int32_t mgmtMeterDropColumnByName(STabObj *pTable, const char *name);
static int dropMeterImp(SDbObj *pDb, STabObj * pTable, SAcctObj *pAcct); static int dropMeterImp(SDbObj *pDb, STabObj * pTable, SAcctObj *pAcct);
static void dropAllMetersOfMetric(SDbObj *pDb, STabObj * pMetric, SAcctObj *pAcct); static void dropAllMetersOfMetric(SDbObj *pDb, STabObj * pMetric, SAcctObj *pAcct);
int mgmtCheckTableLimit(SAcctObj *pAcct, SCreateTableMsg *pCreate);
void mgmtMeterActionInit() { void mgmtMeterActionInit() {
mgmtMeterActionFp[SDB_TYPE_INSERT] = mgmtMeterActionInsert; mgmtMeterActionFp[SDB_TYPE_INSERT] = mgmtMeterActionInsert;
mgmtMeterActionFp[SDB_TYPE_DELETE] = mgmtMeterActionDelete; mgmtMeterActionFp[SDB_TYPE_DELETE] = mgmtMeterActionDelete;
......
...@@ -17,9 +17,13 @@ ...@@ -17,9 +17,13 @@
#include "os.h" #include "os.h"
#include "mnode.h" #include "mnode.h"
#include "mgmtBalance.h"
#include "mgmtDb.h"
#include "mgmtDnode.h"
#include "mgmtDnodeInt.h"
#include "tschemautil.h" #include "tschemautil.h"
#include "tlog.h" #include "tlog.h"
#include "vnodeStatus.h" #include "tstatus.h"
void * vgSdb = NULL; void * vgSdb = NULL;
int tsVgUpdateSize; int tsVgUpdateSize;
...@@ -39,8 +43,6 @@ void *mgmtVgroupActionBatchUpdate(void *row, char *str, int size, int *ssize); ...@@ -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 *mgmtVgroupActionAfterBatchUpdate(void *row, char *str, int size, int *ssize);
void *mgmtVgroupActionReset(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); 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() { void mgmtVgroupActionInit() {
mgmtVgroupActionFp[SDB_TYPE_INSERT] = mgmtVgroupActionInsert; mgmtVgroupActionFp[SDB_TYPE_INSERT] = mgmtVgroupActionInsert;
......
...@@ -123,6 +123,22 @@ typedef struct tExtMemBuffer { ...@@ -123,6 +123,22 @@ typedef struct tExtMemBuffer {
EXT_BUFFER_FLUSH_MODEL flushModel; EXT_BUFFER_FLUSH_MODEL flushModel;
} tExtMemBuffer; } 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); void getTmpfilePath(const char *fileNamePattern, char *dstPath);
/* /*
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include "taoserror.h" #include "taoserror.h"
......
...@@ -33,22 +33,6 @@ extern "C" { ...@@ -33,22 +33,6 @@ extern "C" {
* 1. we implement a quick sort algorithm, may remove it later. * 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); 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, tSidSet *tSidSetCreate(struct SMeterSidExtInfo **pMeterSidExtInfo, int32_t numOfMeters, SSchema *pSchema,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册