remove connObj
This commit is contained in:
parent
d2605d0ece
commit
b4d1bc952b
|
@ -244,6 +244,8 @@ typedef struct _db_obj {
|
||||||
void * vgTimer;
|
void * vgTimer;
|
||||||
} SDbObj;
|
} SDbObj;
|
||||||
|
|
||||||
|
struct _acctObj;
|
||||||
|
|
||||||
typedef struct _user_obj {
|
typedef struct _user_obj {
|
||||||
char user[TSDB_USER_LEN + 1];
|
char user[TSDB_USER_LEN + 1];
|
||||||
char pass[TSDB_KEY_LEN];
|
char pass[TSDB_KEY_LEN];
|
||||||
|
@ -254,6 +256,9 @@ typedef struct _user_obj {
|
||||||
char reserved[16];
|
char reserved[16];
|
||||||
char updateEnd[1];
|
char updateEnd[1];
|
||||||
struct _user_obj *prev, *next;
|
struct _user_obj *prev, *next;
|
||||||
|
struct _acctObj * pAcct;
|
||||||
|
SCMQqueryList * pQList; // query list
|
||||||
|
SCMStreamList * pSList; // stream list
|
||||||
} SUserObj;
|
} SUserObj;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -274,7 +279,7 @@ typedef struct {
|
||||||
char accessState; // Checked by mgmt heartbeat message
|
char accessState; // Checked by mgmt heartbeat message
|
||||||
} SAcctInfo;
|
} SAcctInfo;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct _acctObj {
|
||||||
char user[TSDB_USER_LEN + 1];
|
char user[TSDB_USER_LEN + 1];
|
||||||
char pass[TSDB_KEY_LEN];
|
char pass[TSDB_KEY_LEN];
|
||||||
SAcctCfg cfg;
|
SAcctCfg cfg;
|
||||||
|
@ -290,28 +295,6 @@ typedef struct {
|
||||||
pthread_mutex_t mutex;
|
pthread_mutex_t mutex;
|
||||||
} SAcctObj;
|
} SAcctObj;
|
||||||
|
|
||||||
typedef struct _connObj {
|
|
||||||
SAcctObj * pAcct;
|
|
||||||
SDbObj * pDb;
|
|
||||||
SUserObj * pUser;
|
|
||||||
char user[TSDB_USER_LEN];
|
|
||||||
uint64_t stime; // login time
|
|
||||||
char superAuth : 1; // super user flag
|
|
||||||
char writeAuth : 1; // write flag
|
|
||||||
char killConnection : 1; // kill the connection flag
|
|
||||||
uint8_t usePublicIp : 1; // if the connection request is publicIp
|
|
||||||
uint8_t reserved : 4;
|
|
||||||
uint32_t queryId; // query ID to be killed
|
|
||||||
uint32_t streamId; // stream ID to be killed
|
|
||||||
uint32_t ip; // shell IP
|
|
||||||
uint16_t port; // shell port
|
|
||||||
void * thandle;
|
|
||||||
SCMQqueryList * pQList; // query list
|
|
||||||
SCMStreamList * pSList; // stream list
|
|
||||||
uint64_t qhandle;
|
|
||||||
struct _connObj *prev, *next;
|
|
||||||
} SConnObj;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char spi;
|
char spi;
|
||||||
char encrypt;
|
char encrypt;
|
||||||
|
|
|
@ -34,8 +34,8 @@ extern int32_t (*mgmtCheckDbLimit)(SAcctObj *pAcct);
|
||||||
extern int32_t (*mgmtCheckTableLimit)(SAcctObj *pAcct, SCreateTableMsg *pCreate);
|
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, void *pConn);
|
||||||
extern int32_t (*mgmtRetrieveAccts)(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn);
|
extern int32_t (*mgmtRetrieveAccts)(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,8 @@ extern "C" {
|
||||||
|
|
||||||
#include "mnode.h"
|
#include "mnode.h"
|
||||||
|
|
||||||
int mgmtGetConnsMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn);
|
int mgmtGetConnsMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn);
|
||||||
int mgmtRetrieveConns(SShowObj *pShow, char *data, int rows, SConnObj *pConn);
|
int mgmtRetrieveConns(SShowObj *pShow, char *data, int rows, void *pConn);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,14 +24,13 @@ extern "C" {
|
||||||
|
|
||||||
void mgmtMonitorDbDrop(void *unused, void *unusedt);
|
void mgmtMonitorDbDrop(void *unused, void *unusedt);
|
||||||
int32_t mgmtAlterDb(SAcctObj *pAcct, SAlterDbMsg *pAlter);
|
int32_t mgmtAlterDb(SAcctObj *pAcct, SAlterDbMsg *pAlter);
|
||||||
int32_t mgmtUseDb(SConnObj *pConn, char *name);
|
|
||||||
int32_t mgmtAddVgroupIntoDb(SDbObj *pDb, SVgObj *pVgroup);
|
int32_t mgmtAddVgroupIntoDb(SDbObj *pDb, SVgObj *pVgroup);
|
||||||
int32_t mgmtAddVgroupIntoDbTail(SDbObj *pDb, SVgObj *pVgroup);
|
int32_t mgmtAddVgroupIntoDbTail(SDbObj *pDb, SVgObj *pVgroup);
|
||||||
int32_t mgmtRemoveVgroupFromDb(SDbObj *pDb, SVgObj *pVgroup);
|
int32_t mgmtRemoveVgroupFromDb(SDbObj *pDb, SVgObj *pVgroup);
|
||||||
int32_t mgmtMoveVgroupToTail(SDbObj *pDb, SVgObj *pVgroup);
|
int32_t mgmtMoveVgroupToTail(SDbObj *pDb, SVgObj *pVgroup);
|
||||||
int32_t mgmtMoveVgroupToHead(SDbObj *pDb, SVgObj *pVgroup);
|
int32_t mgmtMoveVgroupToHead(SDbObj *pDb, SVgObj *pVgroup);
|
||||||
int32_t mgmtGetDbMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn);
|
int32_t mgmtGetDbMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn);
|
||||||
int32_t mgmtRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn);
|
int32_t mgmtRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
||||||
void mgmtCleanUpDbs();
|
void mgmtCleanUpDbs();
|
||||||
|
|
||||||
int32_t mgmtInitDbs();
|
int32_t mgmtInitDbs();
|
||||||
|
|
|
@ -30,19 +30,19 @@ int32_t mgmtDropDnodeByIp(uint32_t ip);
|
||||||
int32_t mgmtGetNextVnode(SVnodeGid *pVnodeGid);
|
int32_t mgmtGetNextVnode(SVnodeGid *pVnodeGid);
|
||||||
void mgmtSetDnodeVgid(SVnodeGid vnodeGid[], int32_t numOfVnodes, int32_t vgId);
|
void mgmtSetDnodeVgid(SVnodeGid vnodeGid[], int32_t numOfVnodes, int32_t vgId);
|
||||||
void mgmtUnSetDnodeVgid(SVnodeGid vnodeGid[], int32_t numOfVnodes);
|
void mgmtUnSetDnodeVgid(SVnodeGid vnodeGid[], int32_t numOfVnodes);
|
||||||
int32_t mgmtGetDnodeMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn);
|
int32_t mgmtGetDnodeMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn);
|
||||||
int32_t mgmtRetrieveDnodes(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn);
|
int32_t mgmtRetrieveDnodes(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
||||||
int32_t mgmtSendCfgDnodeMsg(char *cont);
|
int32_t mgmtSendCfgDnodeMsg(char *cont);
|
||||||
void mgmtSetDnodeMaxVnodes(SDnodeObj *pDnode);
|
void mgmtSetDnodeMaxVnodes(SDnodeObj *pDnode);
|
||||||
|
|
||||||
int32_t mgmtGetConfigMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn);
|
int32_t mgmtGetConfigMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn);
|
||||||
int32_t mgmtRetrieveConfigs(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn);
|
int32_t mgmtRetrieveConfigs(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
||||||
|
|
||||||
int32_t mgmtGetModuleMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn);
|
int32_t mgmtGetModuleMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn);
|
||||||
int32_t mgmtRetrieveModules(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn);
|
int32_t mgmtRetrieveModules(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
||||||
|
|
||||||
int32_t mgmtGetVnodeMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn);
|
int32_t mgmtGetVnodeMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn);
|
||||||
int32_t mgmtRetrieveVnodes(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn);
|
int32_t mgmtRetrieveVnodes(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
||||||
|
|
||||||
extern int32_t (*mgmtInitDnodes)();
|
extern int32_t (*mgmtInitDnodes)();
|
||||||
extern void (*mgmtCleanUpDnodes)();
|
extern void (*mgmtCleanUpDnodes)();
|
||||||
|
@ -51,8 +51,8 @@ extern int32_t (*mgmtGetDnodesNum)();
|
||||||
extern void* (*mgmtGetNextDnode)(SShowObj *pShow, SDnodeObj **pDnode);
|
extern void* (*mgmtGetNextDnode)(SShowObj *pShow, SDnodeObj **pDnode);
|
||||||
extern int32_t (*mgmtUpdateDnode)(SDnodeObj *pDnode);
|
extern int32_t (*mgmtUpdateDnode)(SDnodeObj *pDnode);
|
||||||
extern void (*mgmtSetDnodeUnRemove)(SDnodeObj *pDnode);
|
extern void (*mgmtSetDnodeUnRemove)(SDnodeObj *pDnode);
|
||||||
extern int32_t (*mgmtGetScoresMeta)(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn);
|
extern int32_t (*mgmtGetScoresMeta)(SMeterMeta *pMeta, SShowObj *pShow, void *pConn);
|
||||||
extern int32_t (*mgmtRetrieveScores)(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn);
|
extern int32_t (*mgmtRetrieveScores)(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
||||||
extern bool (*mgmtCheckConfigShow)(SGlobalConfig *cfg);
|
extern bool (*mgmtCheckConfigShow)(SGlobalConfig *cfg);
|
||||||
|
|
||||||
extern SDnodeObj tsDnodeObj;
|
extern SDnodeObj tsDnodeObj;
|
||||||
|
|
|
@ -30,8 +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 (*mgmtGetGrantsMeta)(SMeterMeta *pMeta, SShowObj *pShow, void *pConn);
|
||||||
extern int32_t (*mgmtRetrieveGrants)(SShowObj *pShow, char *data, int rows, SConnObj *pConn);
|
extern int32_t (*mgmtRetrieveGrants)(SShowObj *pShow, char *data, int rows, void *pConn);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,8 +24,8 @@ extern "C" {
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include "mnode.h"
|
#include "mnode.h"
|
||||||
|
|
||||||
extern int32_t (*mgmtGetMnodeMeta)(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn);
|
extern int32_t (*mgmtGetMnodeMeta)(SMeterMeta *pMeta, SShowObj *pShow, void *pConn);
|
||||||
extern int32_t (*mgmtRetrieveMnodes)(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn);
|
extern int32_t (*mgmtRetrieveMnodes)(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,21 +22,21 @@ extern "C" {
|
||||||
|
|
||||||
#include "mnode.h"
|
#include "mnode.h"
|
||||||
|
|
||||||
int32_t mgmtGetQueryMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn);
|
int32_t mgmtGetQueryMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn);
|
||||||
|
|
||||||
int32_t mgmtGetStreamMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn);
|
int32_t mgmtGetStreamMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn);
|
||||||
|
|
||||||
int32_t mgmtRetrieveQueries(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn);
|
int32_t mgmtRetrieveQueries(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
||||||
|
|
||||||
int32_t mgmtRetrieveStreams(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn);
|
int32_t mgmtRetrieveStreams(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
||||||
|
|
||||||
int32_t mgmtSaveQueryStreamList(SCMHeartBeatMsg *pHBMsg);
|
int32_t mgmtSaveQueryStreamList(SCMHeartBeatMsg *pHBMsg);
|
||||||
|
|
||||||
int32_t mgmtKillQuery(char *qidstr, SConnObj *pConn);
|
int32_t mgmtKillQuery(char *qidstr, void *pConn);
|
||||||
|
|
||||||
int32_t mgmtKillStream(char *qidstr, SConnObj *pConn);
|
int32_t mgmtKillStream(char *qidstr, void *pConn);
|
||||||
|
|
||||||
int32_t mgmtKillConnection(char *qidstr, SConnObj *pConn);
|
int32_t mgmtKillConnection(char *qidstr, void *pConn);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ extern "C" {
|
||||||
int32_t mgmtInitShell();
|
int32_t mgmtInitShell();
|
||||||
void mgmtCleanUpShell();
|
void mgmtCleanUpShell();
|
||||||
|
|
||||||
extern int32_t (*mgmtCheckRedirectMsg)(SConnObj *pConn, int32_t msgType);
|
extern int32_t (*mgmtCheckRedirectMsg)(void *pConn, int32_t msgType);
|
||||||
extern int32_t (*mgmtProcessAlterAcctMsg)(void *pCont, int32_t contLen, void *ahandle);
|
extern int32_t (*mgmtProcessAlterAcctMsg)(void *pCont, int32_t contLen, void *ahandle);
|
||||||
extern int32_t (*mgmtProcessCreateDnodeMsg)(void *pCont, int32_t contLen, void *ahandle);
|
extern int32_t (*mgmtProcessCreateDnodeMsg)(void *pCont, int32_t contLen, void *ahandle);
|
||||||
extern int32_t (*mgmtProcessCfgMnodeMsg)(void *pCont, int32_t contLen, void *ahandle);
|
extern int32_t (*mgmtProcessCfgMnodeMsg)(void *pCont, int32_t contLen, void *ahandle);
|
||||||
|
|
|
@ -29,18 +29,18 @@ int32_t mgmtInitTables();
|
||||||
STableInfo* mgmtGetTable(char *tableId);
|
STableInfo* mgmtGetTable(char *tableId);
|
||||||
STableInfo* mgmtGetTableByPos(uint32_t dnodeIp, int32_t vnode, int32_t sid);
|
STableInfo* mgmtGetTableByPos(uint32_t dnodeIp, int32_t vnode, int32_t sid);
|
||||||
|
|
||||||
int32_t mgmtRetrieveMetricMeta(SConnObj *pConn, char **pStart, SSuperTableMetaMsg *pInfo);
|
int32_t mgmtRetrieveMetricMeta(void *pConn, char **pStart, SSuperTableMetaMsg *pInfo);
|
||||||
int32_t mgmtCreateTable(SDbObj *pDb, SCreateTableMsg *pCreate);
|
int32_t mgmtCreateTable(SDbObj *pDb, SCreateTableMsg *pCreate);
|
||||||
int32_t mgmtDropTable(SDbObj *pDb, char *meterId, int32_t ignore);
|
int32_t mgmtDropTable(SDbObj *pDb, char *meterId, int32_t ignore);
|
||||||
int32_t mgmtAlterTable(SDbObj *pDb, SAlterTableMsg *pAlter);
|
int32_t mgmtAlterTable(SDbObj *pDb, SAlterTableMsg *pAlter);
|
||||||
int32_t mgmtGetTableMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn);
|
int32_t mgmtGetTableMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn);
|
||||||
int32_t mgmtRetrieveTables(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn);
|
int32_t mgmtRetrieveTables(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
||||||
void mgmtCleanUpMeters();
|
void mgmtCleanUpMeters();
|
||||||
|
|
||||||
void mgmtAddTableIntoSuperTable(SSuperTableObj *pStable);
|
void mgmtAddTableIntoSuperTable(SSuperTableObj *pStable);
|
||||||
void mgmtRemoveTableFromSuperTable(SSuperTableObj *pStable);
|
void mgmtRemoveTableFromSuperTable(SSuperTableObj *pStable);
|
||||||
int32_t mgmtGetSuperTableMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn);
|
int32_t mgmtGetSuperTableMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn);
|
||||||
int32_t mgmtRetrieveSuperTables(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn);
|
int32_t mgmtRetrieveSuperTables(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -29,9 +29,10 @@ SUserObj *mgmtGetUser(char *name);
|
||||||
int32_t mgmtCreateUser(SAcctObj *pAcct, char *name, char *pass);
|
int32_t mgmtCreateUser(SAcctObj *pAcct, char *name, char *pass);
|
||||||
int32_t mgmtDropUser(SAcctObj *pAcct, char *name);
|
int32_t mgmtDropUser(SAcctObj *pAcct, char *name);
|
||||||
int32_t mgmtUpdateUser(SUserObj *pUser);
|
int32_t mgmtUpdateUser(SUserObj *pUser);
|
||||||
int32_t mgmtGetUserMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn);
|
int32_t mgmtGetUserMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn);
|
||||||
int32_t mgmtRetrieveUsers(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn);
|
int32_t mgmtRetrieveUsers(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
||||||
void mgmtCleanUpUsers();
|
void mgmtCleanUpUsers();
|
||||||
|
SUserObj *mgmtGetUserFromConn(void *pConn);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,8 @@ SVgObj *mgmtGetVgroup(int32_t vgId);
|
||||||
SVgObj *mgmtCreateVgroup(SDbObj *pDb);
|
SVgObj *mgmtCreateVgroup(SDbObj *pDb);
|
||||||
int32_t mgmtDropVgroup(SDbObj *pDb, SVgObj *pVgroup);
|
int32_t mgmtDropVgroup(SDbObj *pDb, SVgObj *pVgroup);
|
||||||
void mgmtSetVgroupIdPool();
|
void mgmtSetVgroupIdPool();
|
||||||
int32_t mgmtGetVgroupMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn);
|
int32_t mgmtGetVgroupMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn);
|
||||||
int32_t mgmtRetrieveVgroups(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn);
|
int32_t mgmtRetrieveVgroups(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
||||||
void mgmtCleanUpVgroups();
|
void mgmtCleanUpVgroups();
|
||||||
|
|
||||||
SVgObj *mgmtGetAvailVgroup(SDbObj *pDb);
|
SVgObj *mgmtGetAvailVgroup(SDbObj *pDb);
|
||||||
|
|
|
@ -153,14 +153,14 @@ void mgmtCleanUpAcctsImp() {
|
||||||
|
|
||||||
void (*mgmtCleanUpAccts)() = mgmtCleanUpAcctsImp;
|
void (*mgmtCleanUpAccts)() = mgmtCleanUpAcctsImp;
|
||||||
|
|
||||||
int32_t mgmtGetAcctMetaImp(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
int32_t mgmtGetAcctMetaImp(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
|
||||||
return TSDB_CODE_OPS_NOT_SUPPORT;
|
return TSDB_CODE_OPS_NOT_SUPPORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t (*mgmtGetAcctMeta)(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) = mgmtGetAcctMetaImp;
|
int32_t (*mgmtGetAcctMeta)(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) = mgmtGetAcctMetaImp;
|
||||||
|
|
||||||
int32_t mgmtRetrieveAcctsImp(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn) {
|
int32_t mgmtRetrieveAcctsImp(SShowObj *pShow, char *data, int32_t rows, void *pConn) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t (*mgmtRetrieveAccts)(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn) = mgmtRetrieveAcctsImp;
|
int32_t (*mgmtRetrieveAccts)(SShowObj *pShow, char *data, int32_t rows, void *pConn) = mgmtRetrieveAcctsImp;
|
||||||
|
|
|
@ -32,42 +32,42 @@ typedef struct {
|
||||||
SConnInfo connInfo[];
|
SConnInfo connInfo[];
|
||||||
} SConnShow;
|
} SConnShow;
|
||||||
|
|
||||||
int mgmtGetConns(SShowObj *pShow, SConnObj *pConn) {
|
int mgmtGetConns(SShowObj *pShow, void *pConn) {
|
||||||
SAcctObj * pAcct = pConn->pAcct;
|
// SAcctObj * pAcct = pConn->pAcct;
|
||||||
SConnShow *pConnShow;
|
// SConnShow *pConnShow;
|
||||||
|
//
|
||||||
pthread_mutex_lock(&pAcct->mutex);
|
// pthread_mutex_lock(&pAcct->mutex);
|
||||||
|
//
|
||||||
pConnShow = malloc(sizeof(SConnInfo) * pAcct->acctInfo.numOfConns + sizeof(SConnShow));
|
// pConnShow = malloc(sizeof(SConnInfo) * pAcct->acctInfo.numOfConns + sizeof(SConnShow));
|
||||||
pConnShow->index = 0;
|
// pConnShow->index = 0;
|
||||||
pConnShow->numOfConns = 0;
|
// pConnShow->numOfConns = 0;
|
||||||
|
//
|
||||||
if (pAcct->acctInfo.numOfConns > 0) {
|
// if (pAcct->acctInfo.numOfConns > 0) {
|
||||||
pConn = pAcct->pConn;
|
// pConn = pAcct->pConn;
|
||||||
SConnInfo *pConnInfo = pConnShow->connInfo;
|
// SConnInfo *pConnInfo = pConnShow->connInfo;
|
||||||
|
//
|
||||||
while (pConn && pConn->pUser) {
|
// while (pConn && pConn->pUser) {
|
||||||
strcpy(pConnInfo->user, pConn->pUser->user);
|
// strcpy(pConnInfo->user, pConn->pUser->user);
|
||||||
pConnInfo->ip = pConn->ip;
|
// pConnInfo->ip = pConn->ip;
|
||||||
pConnInfo->port = pConn->port;
|
// pConnInfo->port = pConn->port;
|
||||||
pConnInfo->stime = pConn->stime;
|
// pConnInfo->stime = pConn->stime;
|
||||||
|
//
|
||||||
pConnShow->numOfConns++;
|
// pConnShow->numOfConns++;
|
||||||
pConnInfo++;
|
// pConnInfo++;
|
||||||
pConn = pConn->next;
|
// pConn = pConn->next;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
pthread_mutex_unlock(&pAcct->mutex);
|
// pthread_mutex_unlock(&pAcct->mutex);
|
||||||
|
//
|
||||||
// sorting based on useconds
|
// // sorting based on useconds
|
||||||
|
//
|
||||||
pShow->pNode = pConnShow;
|
// pShow->pNode = pConnShow;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mgmtGetConnsMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
int mgmtGetConnsMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
|
||||||
int cols = 0;
|
int cols = 0;
|
||||||
|
|
||||||
pShow->bytes[cols] = TSDB_METER_NAME_LEN;
|
pShow->bytes[cols] = TSDB_METER_NAME_LEN;
|
||||||
|
@ -104,7 +104,7 @@ int mgmtGetConnsMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mgmtRetrieveConns(SShowObj *pShow, char *data, int rows, SConnObj *pConn) {
|
int mgmtRetrieveConns(SShowObj *pShow, char *data, int rows, void *pConn) {
|
||||||
int numOfRows = 0;
|
int numOfRows = 0;
|
||||||
char *pWrite;
|
char *pWrite;
|
||||||
int cols = 0;
|
int cols = 0;
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "mgmtDnodeInt.h"
|
#include "mgmtDnodeInt.h"
|
||||||
#include "mgmtGrant.h"
|
#include "mgmtGrant.h"
|
||||||
#include "mgmtTable.h"
|
#include "mgmtTable.h"
|
||||||
|
#include "mgmtUser.h"
|
||||||
#include "mgmtVgroup.h"
|
#include "mgmtVgroup.h"
|
||||||
|
|
||||||
extern void *tsVgroupSdb;
|
extern void *tsVgroupSdb;
|
||||||
|
@ -472,20 +473,6 @@ int32_t mgmtAlterDb(SAcctObj *pAcct, SAlterDbMsg *pAlter) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtUseDb(SConnObj *pConn, char *name) {
|
|
||||||
SDbObj *pDb;
|
|
||||||
int32_t code = TSDB_CODE_INVALID_DB;
|
|
||||||
|
|
||||||
// here change the default db for connect.
|
|
||||||
pDb = mgmtGetDb(name);
|
|
||||||
if (pDb) {
|
|
||||||
pConn->pDb = pDb;
|
|
||||||
code = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t mgmtAddVgroupIntoDb(SDbObj *pDb, SVgObj *pVgroup) {
|
int32_t mgmtAddVgroupIntoDb(SDbObj *pDb, SVgObj *pVgroup) {
|
||||||
pVgroup->next = pDb->pHead;
|
pVgroup->next = pDb->pHead;
|
||||||
pVgroup->prev = NULL;
|
pVgroup->prev = NULL;
|
||||||
|
@ -540,10 +527,12 @@ void mgmtCleanUpDbs() {
|
||||||
sdbCloseTable(tsDbSdb);
|
sdbCloseTable(tsDbSdb);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtGetDbMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
int32_t mgmtGetDbMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
|
||||||
int32_t cols = 0;
|
int32_t cols = 0;
|
||||||
|
|
||||||
SSchema *pSchema = tsGetSchema(pMeta);
|
SSchema *pSchema = tsGetSchema(pMeta);
|
||||||
|
SUserObj *pUser = mgmtGetUserFromConn(pConn);
|
||||||
|
if (pUser == NULL) return 0;
|
||||||
|
|
||||||
pShow->bytes[cols] = TSDB_DB_NAME_LEN;
|
pShow->bytes[cols] = TSDB_DB_NAME_LEN;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||||
|
@ -564,7 +553,7 @@ int32_t mgmtGetDbMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
||||||
cols++;
|
cols++;
|
||||||
|
|
||||||
#ifndef __CLOUD_VERSION__
|
#ifndef __CLOUD_VERSION__
|
||||||
if (strcmp(pConn->pAcct->user, "root") == 0) {
|
if (strcmp(pUser->user, "root") == 0) {
|
||||||
#endif
|
#endif
|
||||||
pShow->bytes[cols] = 4;
|
pShow->bytes[cols] = 4;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
||||||
|
@ -576,7 +565,7 @@ int32_t mgmtGetDbMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __CLOUD_VERSION__
|
#ifndef __CLOUD_VERSION__
|
||||||
if (strcmp(pConn->pAcct->user, "root") == 0) {
|
if (strcmp(pUser->user, "root") == 0) {
|
||||||
#endif
|
#endif
|
||||||
pShow->bytes[cols] = 2;
|
pShow->bytes[cols] = 2;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT;
|
pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT;
|
||||||
|
@ -600,7 +589,7 @@ int32_t mgmtGetDbMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
||||||
cols++;
|
cols++;
|
||||||
|
|
||||||
#ifndef __CLOUD_VERSION__
|
#ifndef __CLOUD_VERSION__
|
||||||
if (strcmp(pConn->pAcct->user, "root") == 0) {
|
if (strcmp(pUser->user, "root") == 0) {
|
||||||
#endif
|
#endif
|
||||||
pShow->bytes[cols] = 4;
|
pShow->bytes[cols] = 4;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
||||||
|
@ -675,8 +664,8 @@ int32_t mgmtGetDbMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
||||||
|
|
||||||
pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1];
|
pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1];
|
||||||
|
|
||||||
pShow->numOfRows = pConn->pAcct->acctInfo.numOfDbs;
|
pShow->numOfRows = pUser->pAcct->acctInfo.numOfDbs;
|
||||||
pShow->pNode = pConn->pAcct->pHead;
|
pShow->pNode = pUser->pAcct->pHead;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -687,18 +676,20 @@ char *mgmtGetDbStr(char *src) {
|
||||||
return ++pos;
|
return ++pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn) {
|
int32_t mgmtRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, void *pConn) {
|
||||||
int32_t numOfRows = 0;
|
int32_t numOfRows = 0;
|
||||||
SDbObj *pDb = NULL;
|
SDbObj *pDb = NULL;
|
||||||
char * pWrite;
|
char * pWrite;
|
||||||
int32_t cols = 0;
|
int32_t cols = 0;
|
||||||
|
SUserObj *pUser = mgmtGetUserFromConn(pConn);
|
||||||
|
if (pUser == NULL) return 0;
|
||||||
|
|
||||||
while (numOfRows < rows) {
|
while (numOfRows < rows) {
|
||||||
pDb = (SDbObj *)pShow->pNode;
|
pDb = (SDbObj *)pShow->pNode;
|
||||||
if (pDb == NULL) break;
|
if (pDb == NULL) break;
|
||||||
pShow->pNode = (void *)pDb->next;
|
pShow->pNode = (void *)pDb->next;
|
||||||
if (mgmtCheckIsMonitorDB(pDb->name, tsMonitorDbName)) {
|
if (mgmtCheckIsMonitorDB(pDb->name, tsMonitorDbName)) {
|
||||||
if (strcmp(pConn->pUser->user, "root") != 0 && strcmp(pConn->pUser->user, "_root") != 0 && strcmp(pConn->pUser->user, "monitor") != 0 ) {
|
if (strcmp(pUser->user, "root") != 0 && strcmp(pUser->user, "_root") != 0 && strcmp(pUser->user, "monitor") != 0 ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -718,7 +709,7 @@ int32_t mgmtRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, SConnObj *pCo
|
||||||
cols++;
|
cols++;
|
||||||
|
|
||||||
#ifndef __CLOUD_VERSION__
|
#ifndef __CLOUD_VERSION__
|
||||||
if (strcmp(pConn->pAcct->user, "root") == 0) {
|
if (strcmp(pUser->user, "root") == 0) {
|
||||||
#endif
|
#endif
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
*(int32_t *)pWrite = pDb->numOfVgroups;
|
*(int32_t *)pWrite = pDb->numOfVgroups;
|
||||||
|
@ -728,7 +719,7 @@ int32_t mgmtRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, SConnObj *pCo
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __CLOUD_VERSION__
|
#ifndef __CLOUD_VERSION__
|
||||||
if (strcmp(pConn->pAcct->user, "root") == 0) {
|
if (strcmp(pUser->user, "root") == 0) {
|
||||||
#endif
|
#endif
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
*(int16_t *)pWrite = pDb->cfg.replications;
|
*(int16_t *)pWrite = pDb->cfg.replications;
|
||||||
|
@ -746,7 +737,7 @@ int32_t mgmtRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, SConnObj *pCo
|
||||||
cols++;
|
cols++;
|
||||||
|
|
||||||
#ifndef __CLOUD_VERSION__
|
#ifndef __CLOUD_VERSION__
|
||||||
if (strcmp(pConn->pAcct->user, "root") == 0) {
|
if (strcmp(pUser->user, "root") == 0) {
|
||||||
#endif
|
#endif
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
*(int32_t *)pWrite = pDb->cfg.maxSessions - 1; // table num can be created should minus 1
|
*(int32_t *)pWrite = pDb->cfg.maxSessions - 1; // table num can be created should minus 1
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "mnode.h"
|
#include "mnode.h"
|
||||||
#include "mgmtDnode.h"
|
#include "mgmtDnode.h"
|
||||||
#include "mgmtBalance.h"
|
#include "mgmtBalance.h"
|
||||||
|
#include "mgmtUser.h"
|
||||||
|
|
||||||
SDnodeObj tsDnodeObj;
|
SDnodeObj tsDnodeObj;
|
||||||
|
|
||||||
|
@ -96,10 +97,13 @@ void mgmtUnSetDnodeVgid(SVnodeGid vnodeGid[], int32_t numOfVnodes) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtGetDnodeMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
int32_t mgmtGetDnodeMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
|
||||||
int32_t cols = 0;
|
int32_t cols = 0;
|
||||||
|
|
||||||
if (strcmp(pConn->pAcct->user, "root") != 0) return TSDB_CODE_NO_RIGHTS;
|
SUserObj *pUser = mgmtGetUserFromConn(pConn);
|
||||||
|
if (pUser == NULL) return 0;
|
||||||
|
|
||||||
|
if (strcmp(pUser->user, "root") != 0) return TSDB_CODE_NO_RIGHTS;
|
||||||
|
|
||||||
SSchema *pSchema = tsGetSchema(pMeta);
|
SSchema *pSchema = tsGetSchema(pMeta);
|
||||||
|
|
||||||
|
@ -158,7 +162,7 @@ int32_t mgmtGetDnodeMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtRetrieveDnodes(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn) {
|
int32_t mgmtRetrieveDnodes(SShowObj *pShow, char *data, int32_t rows, void *pConn) {
|
||||||
int32_t numOfRows = 0;
|
int32_t numOfRows = 0;
|
||||||
SDnodeObj *pDnode = NULL;
|
SDnodeObj *pDnode = NULL;
|
||||||
char *pWrite;
|
char *pWrite;
|
||||||
|
@ -208,10 +212,13 @@ int32_t mgmtRetrieveDnodes(SShowObj *pShow, char *data, int32_t rows, SConnObj *
|
||||||
return numOfRows;
|
return numOfRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtGetModuleMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
int32_t mgmtGetModuleMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
|
||||||
int32_t cols = 0;
|
int32_t cols = 0;
|
||||||
|
|
||||||
if (strcmp(pConn->pAcct->user, "root") != 0) return TSDB_CODE_NO_RIGHTS;
|
SUserObj *pUser = mgmtGetUserFromConn(pConn);
|
||||||
|
if (pUser == NULL) return 0;
|
||||||
|
|
||||||
|
if (strcmp(pUser->user, "root") != 0) return TSDB_CODE_NO_RIGHTS;
|
||||||
|
|
||||||
SSchema *pSchema = tsGetSchema(pMeta);
|
SSchema *pSchema = tsGetSchema(pMeta);
|
||||||
|
|
||||||
|
@ -259,7 +266,7 @@ int32_t mgmtGetModuleMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtRetrieveModules(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn) {
|
int32_t mgmtRetrieveModules(SShowObj *pShow, char *data, int32_t rows, void *pConn) {
|
||||||
int32_t numOfRows = 0;
|
int32_t numOfRows = 0;
|
||||||
SDnodeObj *pDnode = NULL;
|
SDnodeObj *pDnode = NULL;
|
||||||
char * pWrite;
|
char * pWrite;
|
||||||
|
@ -298,10 +305,13 @@ int32_t mgmtRetrieveModules(SShowObj *pShow, char *data, int32_t rows, SConnObj
|
||||||
return numOfRows;
|
return numOfRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtGetConfigMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
int32_t mgmtGetConfigMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
|
||||||
int32_t cols = 0;
|
int32_t cols = 0;
|
||||||
|
|
||||||
if (strcmp(pConn->pAcct->user, "root") != 0) return TSDB_CODE_NO_RIGHTS;
|
SUserObj *pUser = mgmtGetUserFromConn(pConn);
|
||||||
|
if (pUser == NULL) return 0;
|
||||||
|
|
||||||
|
if (strcmp(pUser->user, "root") != 0) return TSDB_CODE_NO_RIGHTS;
|
||||||
|
|
||||||
SSchema *pSchema = tsGetSchema(pMeta);
|
SSchema *pSchema = tsGetSchema(pMeta);
|
||||||
|
|
||||||
|
@ -336,7 +346,7 @@ int32_t mgmtGetConfigMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtRetrieveConfigs(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn) {
|
int32_t mgmtRetrieveConfigs(SShowObj *pShow, char *data, int32_t rows, void *pConn) {
|
||||||
int32_t numOfRows = 0;
|
int32_t numOfRows = 0;
|
||||||
|
|
||||||
for (int32_t i = tsGlobalConfigNum - 1; i >= 0 && numOfRows < rows; --i) {
|
for (int32_t i = tsGlobalConfigNum - 1; i >= 0 && numOfRows < rows; --i) {
|
||||||
|
@ -383,10 +393,11 @@ int32_t mgmtRetrieveConfigs(SShowObj *pShow, char *data, int32_t rows, SConnObj
|
||||||
return numOfRows;
|
return numOfRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtGetVnodeMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
int32_t mgmtGetVnodeMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
|
||||||
int32_t cols = 0;
|
int32_t cols = 0;
|
||||||
|
SUserObj *pUser = mgmtGetUserFromConn(pConn);
|
||||||
if (strcmp(pConn->pAcct->user, "root") != 0) return TSDB_CODE_NO_RIGHTS;
|
if (pUser == NULL) return 0;
|
||||||
|
if (strcmp(pUser->user, "root") != 0) return TSDB_CODE_NO_RIGHTS;
|
||||||
|
|
||||||
SSchema *pSchema = tsGetSchema(pMeta);
|
SSchema *pSchema = tsGetSchema(pMeta);
|
||||||
|
|
||||||
|
@ -456,7 +467,7 @@ int32_t mgmtGetVnodeMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtRetrieveVnodes(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn) {
|
int32_t mgmtRetrieveVnodes(SShowObj *pShow, char *data, int32_t rows, void *pConn) {
|
||||||
int32_t numOfRows = 0;
|
int32_t numOfRows = 0;
|
||||||
SDnodeObj *pDnode = NULL;
|
SDnodeObj *pDnode = NULL;
|
||||||
char * pWrite;
|
char * pWrite;
|
||||||
|
@ -560,17 +571,17 @@ void *mgmtGetNextDnodeImp(SShowObj *pShow, SDnodeObj **pDnode) {
|
||||||
|
|
||||||
void *(*mgmtGetNextDnode)(SShowObj *pShow, SDnodeObj **pDnode) = mgmtGetNextDnodeImp;
|
void *(*mgmtGetNextDnode)(SShowObj *pShow, SDnodeObj **pDnode) = mgmtGetNextDnodeImp;
|
||||||
|
|
||||||
int32_t mgmtGetScoresMetaImp(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
int32_t mgmtGetScoresMetaImp(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
|
||||||
return TSDB_CODE_OPS_NOT_SUPPORT;
|
return TSDB_CODE_OPS_NOT_SUPPORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t (*mgmtGetScoresMeta)(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) = mgmtGetScoresMetaImp;
|
int32_t (*mgmtGetScoresMeta)(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) = mgmtGetScoresMetaImp;
|
||||||
|
|
||||||
int32_t mgmtRetrieveScoresImp(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn) {
|
int32_t mgmtRetrieveScoresImp(SShowObj *pShow, char *data, int32_t rows, void *pConn) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t (*mgmtRetrieveScores)(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn) = mgmtRetrieveScoresImp;
|
int32_t (*mgmtRetrieveScores)(SShowObj *pShow, char *data, int32_t rows, void *pConn) = mgmtRetrieveScoresImp;
|
||||||
|
|
||||||
void mgmtSetDnodeUnRemoveImp(SDnodeObj *pDnode) {
|
void mgmtSetDnodeUnRemoveImp(SDnodeObj *pDnode) {
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,9 +37,9 @@ int32_t (*mgmtCheckTimeSeries)(uint32_t timeseries) = mgmtCheckTimeSeriesImp;
|
||||||
bool mgmtCheckExpiredImp() { return false; }
|
bool mgmtCheckExpiredImp() { return false; }
|
||||||
bool (*mgmtCheckExpired)() = mgmtCheckExpiredImp;
|
bool (*mgmtCheckExpired)() = mgmtCheckExpiredImp;
|
||||||
|
|
||||||
int32_t mgmtGetGrantsMetaImp(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) { return TSDB_CODE_OPS_NOT_SUPPORT; }
|
int32_t mgmtGetGrantsMetaImp(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) { return TSDB_CODE_OPS_NOT_SUPPORT; }
|
||||||
int32_t (*mgmtGetGrantsMeta)(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) = mgmtGetGrantsMetaImp;
|
int32_t (*mgmtGetGrantsMeta)(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) = mgmtGetGrantsMetaImp;
|
||||||
|
|
||||||
int32_t mgmtRetrieveGrantsImp(SShowObj *pShow, char *data, int rows, SConnObj *pConn) { return 0; }
|
int32_t mgmtRetrieveGrantsImp(SShowObj *pShow, char *data, int rows, void *pConn) { return 0; }
|
||||||
int32_t (*mgmtRetrieveGrants)(SShowObj *pShow, char *data, int rows, SConnObj *pConn) = mgmtRetrieveGrantsImp;
|
int32_t (*mgmtRetrieveGrants)(SShowObj *pShow, char *data, int rows, void *pConn) = mgmtRetrieveGrantsImp;
|
||||||
|
|
||||||
|
|
|
@ -16,14 +16,14 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "mgmtMnode.h"
|
#include "mgmtMnode.h"
|
||||||
|
|
||||||
int32_t mgmtGetMnodeMetaImp(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
int32_t mgmtGetMnodeMetaImp(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
|
||||||
return TSDB_CODE_OPS_NOT_SUPPORT;
|
return TSDB_CODE_OPS_NOT_SUPPORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t (*mgmtGetMnodeMeta)(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) = mgmtGetMnodeMetaImp;
|
int32_t (*mgmtGetMnodeMeta)(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) = mgmtGetMnodeMetaImp;
|
||||||
|
|
||||||
int32_t mgmtRetrieveMnodesImp(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn) {
|
int32_t mgmtRetrieveMnodesImp(SShowObj *pShow, char *data, int32_t rows, void *pConn) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t (*mgmtRetrieveMnodes)(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn) = mgmtRetrieveMnodesImp;
|
int32_t (*mgmtRetrieveMnodes)(SShowObj *pShow, char *data, int32_t rows, void *pConn) = mgmtRetrieveMnodesImp;
|
||||||
|
|
|
@ -70,54 +70,54 @@ int32_t mgmtSaveQueryStreamList(SCMHeartBeatMsg *pHBMsg) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtGetQueries(SShowObj *pShow, SConnObj *pConn) {
|
int32_t mgmtGetQueries(SShowObj *pShow, void *pConn) {
|
||||||
SAcctObj * pAcct = pConn->pAcct;
|
// SAcctObj * pAcct = pConn->pAcct;
|
||||||
SQueryShow *pQueryShow;
|
// SQueryShow *pQueryShow;
|
||||||
|
//
|
||||||
pthread_mutex_lock(&pAcct->mutex);
|
// pthread_mutex_lock(&pAcct->mutex);
|
||||||
|
//
|
||||||
pQueryShow = malloc(sizeof(SCMQueryDesc) * pAcct->acctInfo.numOfQueries + sizeof(SQueryShow));
|
// pQueryShow = malloc(sizeof(SCMQueryDesc) * pAcct->acctInfo.numOfQueries + sizeof(SQueryShow));
|
||||||
pQueryShow->numOfQueries = 0;
|
// pQueryShow->numOfQueries = 0;
|
||||||
pQueryShow->index = 0;
|
// pQueryShow->index = 0;
|
||||||
pQueryShow->connInfo = NULL;
|
// pQueryShow->connInfo = NULL;
|
||||||
pQueryShow->cdesc = NULL;
|
// pQueryShow->cdesc = NULL;
|
||||||
|
//
|
||||||
if (pAcct->acctInfo.numOfQueries > 0) {
|
// if (pAcct->acctInfo.numOfQueries > 0) {
|
||||||
pQueryShow->connInfo = (SCDesc *)malloc(pAcct->acctInfo.numOfConns * sizeof(SCDesc));
|
// pQueryShow->connInfo = (SCDesc *)malloc(pAcct->acctInfo.numOfConns * sizeof(SCDesc));
|
||||||
pQueryShow->cdesc = (SCDesc **)malloc(pAcct->acctInfo.numOfQueries * sizeof(SCDesc *));
|
// pQueryShow->cdesc = (SCDesc **)malloc(pAcct->acctInfo.numOfQueries * sizeof(SCDesc *));
|
||||||
|
//
|
||||||
pConn = pAcct->pConn;
|
// pConn = pAcct->pConn;
|
||||||
SCMQueryDesc * pQdesc = pQueryShow->qdesc;
|
// SCMQueryDesc * pQdesc = pQueryShow->qdesc;
|
||||||
SCDesc * pCDesc = pQueryShow->connInfo;
|
// SCDesc * pCDesc = pQueryShow->connInfo;
|
||||||
SCDesc **ppCDesc = pQueryShow->cdesc;
|
// SCDesc **ppCDesc = pQueryShow->cdesc;
|
||||||
|
//
|
||||||
while (pConn) {
|
// while (pConn) {
|
||||||
if (pConn->pQList && pConn->pQList->numOfQueries > 0) {
|
// if (pConn->pQList && pConn->pQList->numOfQueries > 0) {
|
||||||
pCDesc->ip = pConn->ip;
|
// pCDesc->ip = pConn->ip;
|
||||||
pCDesc->port = pConn->port;
|
// pCDesc->port = pConn->port;
|
||||||
strcpy(pCDesc->user, pConn->pUser->user);
|
// strcpy(pCDesc->user, pConn->pUser->user);
|
||||||
|
//
|
||||||
memcpy(pQdesc, pConn->pQList->qdesc, sizeof(SCMQueryDesc) * pConn->pQList->numOfQueries);
|
// memcpy(pQdesc, pConn->pQList->qdesc, sizeof(SCMQueryDesc) * pConn->pQList->numOfQueries);
|
||||||
pQdesc += pConn->pQList->numOfQueries;
|
// pQdesc += pConn->pQList->numOfQueries;
|
||||||
pQueryShow->numOfQueries += pConn->pQList->numOfQueries;
|
// pQueryShow->numOfQueries += pConn->pQList->numOfQueries;
|
||||||
for (int32_t i = 0; i < pConn->pQList->numOfQueries; ++i, ++ppCDesc) *ppCDesc = pCDesc;
|
// for (int32_t i = 0; i < pConn->pQList->numOfQueries; ++i, ++ppCDesc) *ppCDesc = pCDesc;
|
||||||
|
//
|
||||||
pCDesc++;
|
// pCDesc++;
|
||||||
}
|
// }
|
||||||
pConn = pConn->next;
|
// pConn = pConn->next;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
pthread_mutex_unlock(&pAcct->mutex);
|
// pthread_mutex_unlock(&pAcct->mutex);
|
||||||
|
//
|
||||||
// sorting based on useconds
|
// // sorting based on useconds
|
||||||
|
//
|
||||||
pShow->pNode = pQueryShow;
|
// pShow->pNode = pQueryShow;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtGetQueryMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
int32_t mgmtGetQueryMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
|
||||||
int32_t cols = 0;
|
int32_t cols = 0;
|
||||||
|
|
||||||
SSchema *pSchema = tsGetSchema(pMeta);
|
SSchema *pSchema = tsGetSchema(pMeta);
|
||||||
|
@ -166,60 +166,60 @@ int32_t mgmtGetQueryMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtKillQuery(char *qidstr, SConnObj *pConn) {
|
int32_t mgmtKillQuery(char *qidstr, void *pConn) {
|
||||||
char *temp, *chr, idstr[64];
|
// char *temp, *chr, idstr[64];
|
||||||
strcpy(idstr, qidstr);
|
// strcpy(idstr, qidstr);
|
||||||
|
//
|
||||||
temp = idstr;
|
// temp = idstr;
|
||||||
chr = strchr(temp, ':');
|
// chr = strchr(temp, ':');
|
||||||
if (chr == NULL) goto _error;
|
// if (chr == NULL) goto _error;
|
||||||
*chr = 0;
|
// *chr = 0;
|
||||||
uint32_t ip = inet_addr(temp);
|
// uint32_t ip = inet_addr(temp);
|
||||||
|
//
|
||||||
temp = chr + 1;
|
// temp = chr + 1;
|
||||||
chr = strchr(temp, ':');
|
// chr = strchr(temp, ':');
|
||||||
if (chr == NULL) goto _error;
|
// if (chr == NULL) goto _error;
|
||||||
*chr = 0;
|
// *chr = 0;
|
||||||
uint16_t port = htons(atoi(temp));
|
// uint16_t port = htons(atoi(temp));
|
||||||
|
//
|
||||||
temp = chr + 1;
|
// temp = chr + 1;
|
||||||
uint32_t queryId = atoi(temp);
|
// uint32_t queryId = atoi(temp);
|
||||||
|
//
|
||||||
SAcctObj *pAcct = pConn->pAcct;
|
// SAcctObj *pAcct = pConn->pAcct;
|
||||||
|
//
|
||||||
pthread_mutex_lock(&pAcct->mutex);
|
// pthread_mutex_lock(&pAcct->mutex);
|
||||||
|
//
|
||||||
pConn = pAcct->pConn;
|
// pConn = pAcct->pConn;
|
||||||
while (pConn) {
|
// while (pConn) {
|
||||||
if (pConn->ip == ip && pConn->port == port && pConn->pQList) {
|
// if (pConn->ip == ip && pConn->port == port && pConn->pQList) {
|
||||||
int32_t i;
|
// int32_t i;
|
||||||
SCMQueryDesc *pQDesc = pConn->pQList->qdesc;
|
// SCMQueryDesc *pQDesc = pConn->pQList->qdesc;
|
||||||
for (i = 0; i < pConn->pQList->numOfQueries; ++i, ++pQDesc) {
|
// for (i = 0; i < pConn->pQList->numOfQueries; ++i, ++pQDesc) {
|
||||||
if (pQDesc->queryId == queryId) break;
|
// if (pQDesc->queryId == queryId) break;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (i < pConn->pQList->numOfQueries) break;
|
// if (i < pConn->pQList->numOfQueries) break;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
pConn = pConn->next;
|
// pConn = pConn->next;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (pConn) pConn->queryId = queryId;
|
// if (pConn) pConn->queryId = queryId;
|
||||||
|
//
|
||||||
pthread_mutex_unlock(&pAcct->mutex);
|
// pthread_mutex_unlock(&pAcct->mutex);
|
||||||
|
//
|
||||||
if (pConn == NULL || pConn->pQList == NULL || pConn->pQList->numOfQueries == 0) goto _error;
|
// if (pConn == NULL || pConn->pQList == NULL || pConn->pQList->numOfQueries == 0) goto _error;
|
||||||
|
//
|
||||||
mTrace("query:%s is there, kill it", qidstr);
|
// mTrace("query:%s is there, kill it", qidstr);
|
||||||
return 0;
|
// return 0;
|
||||||
|
//
|
||||||
_error:
|
//_error:
|
||||||
mTrace("query:%s is not there", qidstr);
|
// mTrace("query:%s is not there", qidstr);
|
||||||
|
|
||||||
return TSDB_CODE_INVALID_QUERY_ID;
|
return TSDB_CODE_INVALID_QUERY_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtRetrieveQueries(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn) {
|
int32_t mgmtRetrieveQueries(SShowObj *pShow, char *data, int32_t rows, void *pConn) {
|
||||||
int32_t numOfRows = 0;
|
int32_t numOfRows = 0;
|
||||||
char *pWrite;
|
char *pWrite;
|
||||||
int32_t cols = 0;
|
int32_t cols = 0;
|
||||||
|
@ -269,54 +269,54 @@ int32_t mgmtRetrieveQueries(SShowObj *pShow, char *data, int32_t rows, SConnObj
|
||||||
return numOfRows;
|
return numOfRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtGetStreams(SShowObj *pShow, SConnObj *pConn) {
|
int32_t mgmtGetStreams(SShowObj *pShow, void *pConn) {
|
||||||
SAcctObj * pAcct = pConn->pAcct;
|
// SAcctObj * pAcct = pConn->pAcct;
|
||||||
SStreamShow *pStreamShow;
|
// SStreamShow *pStreamShow;
|
||||||
|
//
|
||||||
pthread_mutex_lock(&pAcct->mutex);
|
// pthread_mutex_lock(&pAcct->mutex);
|
||||||
|
//
|
||||||
pStreamShow = malloc(sizeof(SCMStreamDesc) * pAcct->acctInfo.numOfStreams + sizeof(SQueryShow));
|
// pStreamShow = malloc(sizeof(SCMStreamDesc) * pAcct->acctInfo.numOfStreams + sizeof(SQueryShow));
|
||||||
pStreamShow->numOfStreams = 0;
|
// pStreamShow->numOfStreams = 0;
|
||||||
pStreamShow->index = 0;
|
// pStreamShow->index = 0;
|
||||||
pStreamShow->connInfo = NULL;
|
// pStreamShow->connInfo = NULL;
|
||||||
pStreamShow->cdesc = NULL;
|
// pStreamShow->cdesc = NULL;
|
||||||
|
//
|
||||||
if (pAcct->acctInfo.numOfStreams > 0) {
|
// if (pAcct->acctInfo.numOfStreams > 0) {
|
||||||
pStreamShow->connInfo = (SCDesc *)malloc(pAcct->acctInfo.numOfConns * sizeof(SCDesc));
|
// pStreamShow->connInfo = (SCDesc *)malloc(pAcct->acctInfo.numOfConns * sizeof(SCDesc));
|
||||||
pStreamShow->cdesc = (SCDesc **)malloc(pAcct->acctInfo.numOfStreams * sizeof(SCDesc *));
|
// pStreamShow->cdesc = (SCDesc **)malloc(pAcct->acctInfo.numOfStreams * sizeof(SCDesc *));
|
||||||
|
//
|
||||||
pConn = pAcct->pConn;
|
// pConn = pAcct->pConn;
|
||||||
SCMStreamDesc * pSdesc = pStreamShow->sdesc;
|
// SCMStreamDesc * pSdesc = pStreamShow->sdesc;
|
||||||
SCDesc * pCDesc = pStreamShow->connInfo;
|
// SCDesc * pCDesc = pStreamShow->connInfo;
|
||||||
SCDesc **ppCDesc = pStreamShow->cdesc;
|
// SCDesc **ppCDesc = pStreamShow->cdesc;
|
||||||
|
//
|
||||||
while (pConn) {
|
// while (pConn) {
|
||||||
if (pConn->pSList && pConn->pSList->numOfStreams > 0) {
|
// if (pConn->pSList && pConn->pSList->numOfStreams > 0) {
|
||||||
pCDesc->ip = pConn->ip;
|
// pCDesc->ip = pConn->ip;
|
||||||
pCDesc->port = pConn->port;
|
// pCDesc->port = pConn->port;
|
||||||
strcpy(pCDesc->user, pConn->pUser->user);
|
// strcpy(pCDesc->user, pConn->pUser->user);
|
||||||
|
//
|
||||||
memcpy(pSdesc, pConn->pSList->sdesc, sizeof(SCMStreamDesc) * pConn->pSList->numOfStreams);
|
// memcpy(pSdesc, pConn->pSList->sdesc, sizeof(SCMStreamDesc) * pConn->pSList->numOfStreams);
|
||||||
pSdesc += pConn->pSList->numOfStreams;
|
// pSdesc += pConn->pSList->numOfStreams;
|
||||||
pStreamShow->numOfStreams += pConn->pSList->numOfStreams;
|
// pStreamShow->numOfStreams += pConn->pSList->numOfStreams;
|
||||||
for (int32_t i = 0; i < pConn->pSList->numOfStreams; ++i, ++ppCDesc) *ppCDesc = pCDesc;
|
// for (int32_t i = 0; i < pConn->pSList->numOfStreams; ++i, ++ppCDesc) *ppCDesc = pCDesc;
|
||||||
|
//
|
||||||
pCDesc++;
|
// pCDesc++;
|
||||||
}
|
// }
|
||||||
pConn = pConn->next;
|
// pConn = pConn->next;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
pthread_mutex_unlock(&pAcct->mutex);
|
// pthread_mutex_unlock(&pAcct->mutex);
|
||||||
|
//
|
||||||
// sorting based on useconds
|
// // sorting based on useconds
|
||||||
|
//
|
||||||
pShow->pNode = pStreamShow;
|
// pShow->pNode = pStreamShow;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtGetStreamMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
int32_t mgmtGetStreamMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
|
||||||
int32_t cols = 0;
|
int32_t cols = 0;
|
||||||
SSchema *pSchema = tsGetSchema(pMeta);
|
SSchema *pSchema = tsGetSchema(pMeta);
|
||||||
|
|
||||||
|
@ -376,7 +376,7 @@ int32_t mgmtGetStreamMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtRetrieveStreams(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn) {
|
int32_t mgmtRetrieveStreams(SShowObj *pShow, char *data, int32_t rows, void *pConn) {
|
||||||
int32_t numOfRows = 0;
|
int32_t numOfRows = 0;
|
||||||
char *pWrite;
|
char *pWrite;
|
||||||
int32_t cols = 0;
|
int32_t cols = 0;
|
||||||
|
@ -434,101 +434,101 @@ int32_t mgmtRetrieveStreams(SShowObj *pShow, char *data, int32_t rows, SConnObj
|
||||||
return numOfRows;
|
return numOfRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtKillStream(char *qidstr, SConnObj *pConn) {
|
int32_t mgmtKillStream(char *qidstr, void *pConn) {
|
||||||
char *temp, *chr, idstr[64];
|
// char *temp, *chr, idstr[64];
|
||||||
strcpy(idstr, qidstr);
|
// strcpy(idstr, qidstr);
|
||||||
|
//
|
||||||
temp = idstr;
|
// temp = idstr;
|
||||||
chr = strchr(temp, ':');
|
// chr = strchr(temp, ':');
|
||||||
if (chr == NULL) goto _error;
|
// if (chr == NULL) goto _error;
|
||||||
*chr = 0;
|
// *chr = 0;
|
||||||
uint32_t ip = inet_addr(temp);
|
// uint32_t ip = inet_addr(temp);
|
||||||
|
//
|
||||||
temp = chr + 1;
|
// temp = chr + 1;
|
||||||
chr = strchr(temp, ':');
|
// chr = strchr(temp, ':');
|
||||||
if (chr == NULL) goto _error;
|
// if (chr == NULL) goto _error;
|
||||||
*chr = 0;
|
// *chr = 0;
|
||||||
uint16_t port = htons(atoi(temp));
|
// uint16_t port = htons(atoi(temp));
|
||||||
|
//
|
||||||
temp = chr + 1;
|
// temp = chr + 1;
|
||||||
uint32_t streamId = atoi(temp);
|
// uint32_t streamId = atoi(temp);
|
||||||
|
//
|
||||||
SAcctObj *pAcct = pConn->pAcct;
|
// SAcctObj *pAcct = pConn->pAcct;
|
||||||
|
//
|
||||||
pthread_mutex_lock(&pAcct->mutex);
|
// pthread_mutex_lock(&pAcct->mutex);
|
||||||
|
//
|
||||||
pConn = pAcct->pConn;
|
// pConn = pAcct->pConn;
|
||||||
while (pConn) {
|
// while (pConn) {
|
||||||
if (pConn->ip == ip && pConn->port == port && pConn->pSList) {
|
// if (pConn->ip == ip && pConn->port == port && pConn->pSList) {
|
||||||
int32_t i;
|
// int32_t i;
|
||||||
SCMStreamDesc *pSDesc = pConn->pSList->sdesc;
|
// SCMStreamDesc *pSDesc = pConn->pSList->sdesc;
|
||||||
for (i = 0; i < pConn->pSList->numOfStreams; ++i, ++pSDesc) {
|
// for (i = 0; i < pConn->pSList->numOfStreams; ++i, ++pSDesc) {
|
||||||
if (pSDesc->streamId == streamId) break;
|
// if (pSDesc->streamId == streamId) break;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (i < pConn->pSList->numOfStreams) break;
|
// if (i < pConn->pSList->numOfStreams) break;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
pConn = pConn->next;
|
// pConn = pConn->next;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (pConn) pConn->streamId = streamId;
|
// if (pConn) pConn->streamId = streamId;
|
||||||
|
//
|
||||||
pthread_mutex_unlock(&pAcct->mutex);
|
// pthread_mutex_unlock(&pAcct->mutex);
|
||||||
|
//
|
||||||
if (pConn == NULL || pConn->pSList == NULL || pConn->pSList->numOfStreams == 0) goto _error;
|
// if (pConn == NULL || pConn->pSList == NULL || pConn->pSList->numOfStreams == 0) goto _error;
|
||||||
|
//
|
||||||
mTrace("stream:%s is there, kill it", qidstr);
|
// mTrace("stream:%s is there, kill it", qidstr);
|
||||||
return 0;
|
// return 0;
|
||||||
|
//
|
||||||
_error:
|
//_error:
|
||||||
mTrace("stream:%s is not there", qidstr);
|
// mTrace("stream:%s is not there", qidstr);
|
||||||
|
|
||||||
return TSDB_CODE_INVALID_STREAM_ID;
|
return TSDB_CODE_INVALID_STREAM_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtKillConnection(char *qidstr, SConnObj *pConn) {
|
int32_t mgmtKillConnection(char *qidstr, void *pConn) {
|
||||||
SConnObj *pConn1 = NULL;
|
// void *pConn1 = NULL;
|
||||||
char * temp, *chr, idstr[64];
|
// char * temp, *chr, idstr[64];
|
||||||
strcpy(idstr, qidstr);
|
// strcpy(idstr, qidstr);
|
||||||
|
//
|
||||||
temp = idstr;
|
// temp = idstr;
|
||||||
chr = strchr(temp, ':');
|
// chr = strchr(temp, ':');
|
||||||
if (chr == NULL) goto _error;
|
// if (chr == NULL) goto _error;
|
||||||
*chr = 0;
|
// *chr = 0;
|
||||||
uint32_t ip = inet_addr(temp);
|
// uint32_t ip = inet_addr(temp);
|
||||||
|
//
|
||||||
temp = chr + 1;
|
// temp = chr + 1;
|
||||||
uint16_t port = htons(atoi(temp));
|
// uint16_t port = htons(atoi(temp));
|
||||||
SAcctObj *pAcct = pConn->pAcct;
|
// SAcctObj *pAcct = pConn->pAcct;
|
||||||
|
//
|
||||||
pthread_mutex_lock(&pAcct->mutex);
|
// pthread_mutex_lock(&pAcct->mutex);
|
||||||
|
//
|
||||||
pConn = pAcct->pConn;
|
// pConn = pAcct->pConn;
|
||||||
while (pConn) {
|
// while (pConn) {
|
||||||
if (pConn->ip == ip && pConn->port == port) {
|
// if (pConn->ip == ip && pConn->port == port) {
|
||||||
// there maybe two connections from a shell
|
// // there maybe two connections from a shell
|
||||||
if (pConn1 == NULL)
|
// if (pConn1 == NULL)
|
||||||
pConn1 = pConn;
|
// pConn1 = pConn;
|
||||||
else
|
// else
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
pConn = pConn->next;
|
// pConn = pConn->next;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (pConn1) pConn1->killConnection = 1;
|
// if (pConn1) pConn1->killConnection = 1;
|
||||||
if (pConn) pConn->killConnection = 1;
|
// if (pConn) pConn->killConnection = 1;
|
||||||
|
//
|
||||||
pthread_mutex_unlock(&pAcct->mutex);
|
// pthread_mutex_unlock(&pAcct->mutex);
|
||||||
|
//
|
||||||
if (pConn1 == NULL) goto _error;
|
// if (pConn1 == NULL) goto _error;
|
||||||
|
//
|
||||||
mTrace("connection:%s is there, kill it", qidstr);
|
// mTrace("connection:%s is there, kill it", qidstr);
|
||||||
return 0;
|
// return 0;
|
||||||
|
//
|
||||||
_error:
|
//_error:
|
||||||
mTrace("connection:%s is not there", qidstr);
|
// mTrace("connection:%s is not there", qidstr);
|
||||||
|
|
||||||
return TSDB_CODE_INVALID_CONNECTION;
|
return TSDB_CODE_INVALID_CONNECTION;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,33 +38,44 @@
|
||||||
|
|
||||||
#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 (*GetMateFp)(SMeterMeta *pMeta, SShowObj *pShow, void *pConn);
|
||||||
typedef int32_t (*RetrieveMetaFp)(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn);
|
typedef int32_t (*RetrieveMetaFp)(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
||||||
static GetMateFp* mgmtGetMetaFp;
|
static GetMateFp* mgmtGetMetaFp;
|
||||||
static RetrieveMetaFp* mgmtRetrieveFp;
|
static RetrieveMetaFp* mgmtRetrieveFp;
|
||||||
static void mgmtInitShowMsgFp();
|
static void mgmtInitShowMsgFp();
|
||||||
|
|
||||||
void * tsShellConn = NULL;
|
void * tsShellConn = NULL;
|
||||||
SConnObj *connList;
|
|
||||||
|
|
||||||
static void mgmtProcessMsgFromShell(char type, void *pCont, int contLen, void *ahandle, int32_t code);
|
static void mgmtProcessMsgFromShell(char type, void *pCont, int contLen, void *ahandle, int32_t code);
|
||||||
static int32_t (*mgmtProcessShellMsg[TSDB_MSG_TYPE_MAX])(void *pCont, int32_t contLen, void *ahandle);
|
static int32_t (*mgmtProcessShellMsg[TSDB_MSG_TYPE_MAX])(void *pCont, int32_t contLen, void *ahandle);
|
||||||
static int32_t mgmtRetriveUserAuthInfo(char *user, char *spi, char *encrypt, char *secret, char *ckey);
|
static int32_t mgmtRetriveUserAuthInfo(char *user, char *spi, char *encrypt, char *secret, char *ckey);
|
||||||
|
|
||||||
void mgmtInitProcessShellMsg();
|
void mgmtInitProcessShellMsg();
|
||||||
int32_t mgmtRedirectMsg(SConnObj *pConn, int32_t msgType);
|
int32_t mgmtKillQuery(char *queryId, void *pConn);
|
||||||
int32_t mgmtKillQuery(char *queryId, SConnObj *pConn);
|
|
||||||
|
|
||||||
void mgmtProcessTranRequest(SSchedMsg *pSchedMsg) {
|
void mgmtProcessTranRequest(SSchedMsg *sched) {
|
||||||
SIntMsg * pMsg = (SIntMsg *)(pSchedMsg->msg);
|
int8_t msgType = *(int8_t *) (sched->msg);
|
||||||
SConnObj *pConn = (SConnObj *)(pSchedMsg->thandle);
|
int32_t contLen = *(int32_t *) (sched->msg + sizeof(int8_t));
|
||||||
|
int8_t *pCont = sched->msg + sizeof(int32_t) + sizeof(int8_t);
|
||||||
|
void *pConn = sched->thandle;
|
||||||
|
|
||||||
char *cont = (char *)pMsg->content + sizeof(SMgmtHead);
|
(*mgmtProcessShellMsg[msgType])(pCont, contLen, pConn);
|
||||||
int32_t contLen = pMsg->msgLen - sizeof(SIntMsg) - sizeof(SMgmtHead);
|
if (sched->msg) {
|
||||||
|
free(sched->msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (pConn->pAcct) (*mgmtProcessShellMsg[pMsg->msgType])(cont, contLen, pConn);
|
void mgmtAddToTranRequest(int8_t type, void *pCont, int contLen, void *ahandle) {
|
||||||
|
SSchedMsg schedMsg;
|
||||||
|
schedMsg.msg = malloc(contLen + sizeof(int32_t) + sizeof(int8_t));
|
||||||
|
schedMsg.fp = mgmtProcessTranRequest;
|
||||||
|
schedMsg.tfp = NULL;
|
||||||
|
schedMsg.thandle = ahandle;
|
||||||
|
*(int8_t *) (schedMsg.msg) = type;
|
||||||
|
*(int32_t *) (schedMsg.msg + sizeof(int8_t)) = contLen;
|
||||||
|
memcpy(schedMsg.msg, pCont + sizeof(int32_t) + sizeof(int8_t), contLen);
|
||||||
|
|
||||||
if (pSchedMsg->msg) free(pSchedMsg->msg);
|
taosScheduleTask(tsMgmtTranQhandle, &schedMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtInitShell() {
|
int32_t mgmtInitShell() {
|
||||||
|
@ -73,14 +84,6 @@ int32_t mgmtInitShell() {
|
||||||
mgmtInitProcessShellMsg();
|
mgmtInitProcessShellMsg();
|
||||||
mgmtInitShowMsgFp();
|
mgmtInitShowMsgFp();
|
||||||
|
|
||||||
int32_t size = sizeof(SConnObj) * tsMaxShellConns;
|
|
||||||
connList = (SConnObj *)malloc(size);
|
|
||||||
if (connList == NULL) {
|
|
||||||
mError("failed to malloc for connList to shell");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
memset(connList, 0, size);
|
|
||||||
|
|
||||||
int32_t numOfThreads = tsNumOfCores * tsNumOfThreadsPerCore / 4.0;
|
int32_t numOfThreads = tsNumOfCores * tsNumOfThreadsPerCore / 4.0;
|
||||||
if (numOfThreads < 1) numOfThreads = 1;
|
if (numOfThreads < 1) numOfThreads = 1;
|
||||||
|
|
||||||
|
@ -110,7 +113,6 @@ void mgmtCleanUpShell() {
|
||||||
rpcClose(tsShellConn);
|
rpcClose(tsShellConn);
|
||||||
tsShellConn = NULL;
|
tsShellConn = NULL;
|
||||||
}
|
}
|
||||||
tfree(connList);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mgmtSetSchemaFromMeters(SSchema *pSchema, STabObj *pMeterObj, uint32_t numOfCols) {
|
static void mgmtSetSchemaFromMeters(SSchema *pSchema, STabObj *pMeterObj, uint32_t numOfCols) {
|
||||||
|
@ -138,27 +140,6 @@ static uint32_t mgmtSetMeterTagValue(char *pTags, STabObj *pMetric, STabObj *pMe
|
||||||
return tagsLen;
|
return tagsLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
//static char *mgmtAllocMsg(SConnObj *pConn, int32_t size, char **pMsg, STaosRsp **pRsp) {
|
|
||||||
// char *pStart = taosBuildRspMsgWithSize(pConn->thandle, TSDB_MSG_TYPE_TABLE_META_RSP, size);
|
|
||||||
// if (pStart == NULL) return 0;
|
|
||||||
// *pMsg = pStart;
|
|
||||||
// *pRsp = (STaosRsp *)(*pMsg);
|
|
||||||
//
|
|
||||||
// return pStart;
|
|
||||||
// return 0;
|
|
||||||
//}
|
|
||||||
|
|
||||||
//static char *mgmtForMultiAllocMsg(SConnObj *pConn, int32_t size, char **pMsg, STaosRsp **pRsp) {
|
|
||||||
// char *pStart = taosBuildRspMsgWithSize(pConn->thandle, TSDB_MSG_TYPE_MULTI_TABLE_META_RSP, size);
|
|
||||||
// if (pStart == NULL) return 0;
|
|
||||||
// *pMsg = pStart;
|
|
||||||
// *pRsp = (STaosRsp *)(*pMsg);
|
|
||||||
//
|
|
||||||
// return pStart;
|
|
||||||
// return 0;
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
int32_t mgmtProcessMeterMetaMsg(void *pCont, int32_t contLen, void *ahandle) {
|
int32_t mgmtProcessMeterMetaMsg(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
// SMeterInfoMsg *pInfo = (SMeterInfoMsg *)pMsg;
|
// SMeterInfoMsg *pInfo = (SMeterInfoMsg *)pMsg;
|
||||||
// STabObj * pMeterObj = NULL;
|
// STabObj * pMeterObj = NULL;
|
||||||
|
@ -1380,13 +1361,7 @@ static void mgmtProcessMsgFromShell(char type, void *pCont, int contLen, void *a
|
||||||
(*mgmtProcessShellMsg[(int8_t)type])(pCont, contLen, ahandle);
|
(*mgmtProcessShellMsg[(int8_t)type])(pCont, contLen, ahandle);
|
||||||
} else {
|
} else {
|
||||||
if (mgmtProcessShellMsg[(int8_t)type]) {
|
if (mgmtProcessShellMsg[(int8_t)type]) {
|
||||||
SSchedMsg schedMsg;
|
mgmtAddToTranRequest((int8_t)type, pCont, contLen, ahandle);
|
||||||
schedMsg.msg = malloc(contLen);
|
|
||||||
memcpy(schedMsg.msg, pCont, contLen);
|
|
||||||
schedMsg.fp = mgmtProcessTranRequest;
|
|
||||||
schedMsg.tfp = NULL;
|
|
||||||
schedMsg.thandle = ahandle;
|
|
||||||
taosScheduleTask(tsMgmtTranQhandle, &schedMsg);
|
|
||||||
} else {
|
} else {
|
||||||
mError("%s from shell is not processed", taosMsg[(int8_t)type]);
|
mError("%s from shell is not processed", taosMsg[(int8_t)type]);
|
||||||
}
|
}
|
||||||
|
@ -1427,10 +1402,10 @@ void mgmtInitProcessShellMsg() {
|
||||||
mgmtProcessShellMsg[TSDB_MSG_TYPE_KILL_CONNECTION] = mgmtProcessKillConnectionMsg;
|
mgmtProcessShellMsg[TSDB_MSG_TYPE_KILL_CONNECTION] = mgmtProcessKillConnectionMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtCheckRedirectMsgImp(SConnObj *pConn, int32_t msgType) {
|
int32_t mgmtCheckRedirectMsgImp(void *pConn, int32_t msgType) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int32_t (*mgmtCheckRedirectMsg)(SConnObj *pConn, int32_t msgType) = mgmtCheckRedirectMsgImp;
|
int32_t (*mgmtCheckRedirectMsg)(void *pConn, int32_t msgType) = mgmtCheckRedirectMsgImp;
|
||||||
|
|
||||||
int32_t mgmtProcessAlterAcctMsgImp(void *pCont, int32_t contLen, void *ahandle) {
|
int32_t mgmtProcessAlterAcctMsgImp(void *pCont, int32_t contLen, void *ahandle) {
|
||||||
//return taosSendSimpleRsp(pConn->thandle, TSDB_MSG_TYPE_ALTER_ACCT_RSP, TSDB_CODE_OPS_NOT_SUPPORT);
|
//return taosSendSimpleRsp(pConn->thandle, TSDB_MSG_TYPE_ALTER_ACCT_RSP, TSDB_CODE_OPS_NOT_SUPPORT);
|
||||||
|
|
|
@ -457,130 +457,130 @@ int32_t mgmtDropSuperTableColumnByName(SSuperTableObj *pStable, char *colName) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtGetSuperTableMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
int32_t mgmtGetSuperTableMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
|
||||||
int32_t cols = 0;
|
// int32_t cols = 0;
|
||||||
|
//
|
||||||
SDbObj *pDb = NULL;
|
// SDbObj *pDb = NULL;
|
||||||
if (pConn->pDb != NULL) pDb = mgmtGetDb(pConn->pDb->name);
|
// if (pConn->pDb != NULL) pDb = mgmtGetDb(pConn->pDb->name);
|
||||||
|
//
|
||||||
if (pDb == NULL) return TSDB_CODE_DB_NOT_SELECTED;
|
// if (pDb == NULL) return TSDB_CODE_DB_NOT_SELECTED;
|
||||||
|
//
|
||||||
SSchema *pSchema = tsGetSchema(pMeta);
|
// SSchema *pSchema = tsGetSchema(pMeta);
|
||||||
|
//
|
||||||
pShow->bytes[cols] = TSDB_METER_NAME_LEN;
|
// pShow->bytes[cols] = TSDB_METER_NAME_LEN;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
// pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||||
strcpy(pSchema[cols].name, "name");
|
// strcpy(pSchema[cols].name, "name");
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pShow->bytes[cols] = 8;
|
// pShow->bytes[cols] = 8;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP;
|
// pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||||
strcpy(pSchema[cols].name, "created_time");
|
// strcpy(pSchema[cols].name, "created_time");
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pShow->bytes[cols] = 2;
|
// pShow->bytes[cols] = 2;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT;
|
// pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT;
|
||||||
strcpy(pSchema[cols].name, "columns");
|
// strcpy(pSchema[cols].name, "columns");
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pShow->bytes[cols] = 2;
|
// pShow->bytes[cols] = 2;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT;
|
// pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT;
|
||||||
strcpy(pSchema[cols].name, "tags");
|
// strcpy(pSchema[cols].name, "tags");
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pShow->bytes[cols] = 4;
|
// pShow->bytes[cols] = 4;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
// pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
||||||
strcpy(pSchema[cols].name, "tables");
|
// strcpy(pSchema[cols].name, "tables");
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pMeta->numOfColumns = htons(cols);
|
// pMeta->numOfColumns = htons(cols);
|
||||||
pShow->numOfColumns = cols;
|
// pShow->numOfColumns = cols;
|
||||||
|
//
|
||||||
pShow->offset[0] = 0;
|
// pShow->offset[0] = 0;
|
||||||
for (int32_t i = 1; i < cols; ++i) pShow->offset[i] = pShow->offset[i - 1] + pShow->bytes[i - 1];
|
// for (int32_t i = 1; i < cols; ++i) pShow->offset[i] = pShow->offset[i - 1] + pShow->bytes[i - 1];
|
||||||
|
//
|
||||||
pShow->numOfRows = pDb->numOfMetrics;
|
// pShow->numOfRows = pDb->numOfMetrics;
|
||||||
pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1];
|
// pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1];
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtRetrieveSuperTables(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn) {
|
int32_t mgmtRetrieveSuperTables(SShowObj *pShow, char *data, int32_t rows, void *pConn) {
|
||||||
int32_t numOfRows = 0;
|
int32_t numOfRows = 0;
|
||||||
char * pWrite;
|
// char * pWrite;
|
||||||
int32_t cols = 0;
|
// int32_t cols = 0;
|
||||||
SSuperTableObj *pTable = NULL;
|
// SSuperTableObj *pTable = NULL;
|
||||||
char prefix[20] = {0};
|
// char prefix[20] = {0};
|
||||||
int32_t prefixLen;
|
// int32_t prefixLen;
|
||||||
|
//
|
||||||
SDbObj *pDb = NULL;
|
// SDbObj *pDb = NULL;
|
||||||
if (pConn->pDb != NULL) {
|
// if (pConn->pDb != NULL) {
|
||||||
pDb = mgmtGetDb(pConn->pDb->name);
|
// pDb = mgmtGetDb(pConn->pDb->name);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (pDb == NULL) {
|
// if (pDb == NULL) {
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (mgmtCheckIsMonitorDB(pDb->name, tsMonitorDbName)) {
|
// if (mgmtCheckIsMonitorDB(pDb->name, tsMonitorDbName)) {
|
||||||
if (strcmp(pConn->pUser->user, "root") != 0 && strcmp(pConn->pUser->user, "_root") != 0 && strcmp(pConn->pUser->user, "monitor") != 0 ) {
|
// if (strcmp(pConn->pUser->user, "root") != 0 && strcmp(pConn->pUser->user, "_root") != 0 && strcmp(pConn->pUser->user, "monitor") != 0 ) {
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
strcpy(prefix, pDb->name);
|
// strcpy(prefix, pDb->name);
|
||||||
strcat(prefix, TS_PATH_DELIMITER);
|
// strcat(prefix, TS_PATH_DELIMITER);
|
||||||
prefixLen = strlen(prefix);
|
// prefixLen = strlen(prefix);
|
||||||
|
//
|
||||||
SPatternCompareInfo info = PATTERN_COMPARE_INFO_INITIALIZER;
|
// SPatternCompareInfo info = PATTERN_COMPARE_INFO_INITIALIZER;
|
||||||
char metricName[TSDB_METER_NAME_LEN] = {0};
|
// char metricName[TSDB_METER_NAME_LEN] = {0};
|
||||||
|
//
|
||||||
while (numOfRows < rows) {
|
// while (numOfRows < rows) {
|
||||||
pTable = (SSuperTableObj *)pShow->pNode;
|
// pTable = (SSuperTableObj *)pShow->pNode;
|
||||||
if (pTable == NULL) break;
|
// if (pTable == NULL) break;
|
||||||
//pShow->pNode = (void *)pTable->next;
|
// //pShow->pNode = (void *)pTable->next;
|
||||||
|
//
|
||||||
if (strncmp(pTable->tableId, prefix, prefixLen)) {
|
// if (strncmp(pTable->tableId, prefix, prefixLen)) {
|
||||||
continue;
|
// continue;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
memset(metricName, 0, tListLen(metricName));
|
// memset(metricName, 0, tListLen(metricName));
|
||||||
extractTableName(pTable->tableId, metricName);
|
// extractTableName(pTable->tableId, metricName);
|
||||||
|
//
|
||||||
if (pShow->payloadLen > 0 &&
|
// if (pShow->payloadLen > 0 &&
|
||||||
patternMatch(pShow->payload, metricName, TSDB_METER_NAME_LEN, &info) != TSDB_PATTERN_MATCH)
|
// patternMatch(pShow->payload, metricName, TSDB_METER_NAME_LEN, &info) != TSDB_PATTERN_MATCH)
|
||||||
continue;
|
// continue;
|
||||||
|
//
|
||||||
cols = 0;
|
// cols = 0;
|
||||||
|
//
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
// pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
extractTableName(pTable->tableId, pWrite);
|
// extractTableName(pTable->tableId, pWrite);
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
// pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
*(int64_t *)pWrite = pTable->createdTime;
|
// *(int64_t *)pWrite = pTable->createdTime;
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
// pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
*(int16_t *)pWrite = pTable->numOfColumns;
|
// *(int16_t *)pWrite = pTable->numOfColumns;
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
// pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
*(int16_t *)pWrite = pTable->numOfTags;
|
// *(int16_t *)pWrite = pTable->numOfTags;
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
// pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
*(int32_t *)pWrite = pTable->numOfTables;
|
// *(int32_t *)pWrite = pTable->numOfTables;
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
numOfRows++;
|
// numOfRows++;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
pShow->numOfReads += numOfRows;
|
// pShow->numOfReads += numOfRows;
|
||||||
return numOfRows;
|
return numOfRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -229,54 +229,54 @@ void mgmtCleanUpMeters() {
|
||||||
mgmtCleanUpSuperTables();
|
mgmtCleanUpSuperTables();
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtGetTableMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
int32_t mgmtGetTableMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
|
||||||
int32_t cols = 0;
|
// int32_t cols = 0;
|
||||||
|
//
|
||||||
SDbObj *pDb = NULL;
|
// SDbObj *pDb = NULL;
|
||||||
if (pConn->pDb != NULL) {
|
// if (pConn->pDb != NULL) {
|
||||||
pDb = mgmtGetDb(pConn->pDb->name);
|
// pDb = mgmtGetDb(pConn->pDb->name);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (pDb == NULL) {
|
// if (pDb == NULL) {
|
||||||
return TSDB_CODE_DB_NOT_SELECTED;
|
// return TSDB_CODE_DB_NOT_SELECTED;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
SSchema *pSchema = tsGetSchema(pMeta);
|
// SSchema *pSchema = tsGetSchema(pMeta);
|
||||||
|
//
|
||||||
pShow->bytes[cols] = TSDB_METER_NAME_LEN;
|
// pShow->bytes[cols] = TSDB_METER_NAME_LEN;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
// pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||||
strcpy(pSchema[cols].name, "table_name");
|
// strcpy(pSchema[cols].name, "table_name");
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pShow->bytes[cols] = 8;
|
// pShow->bytes[cols] = 8;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP;
|
// pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||||
strcpy(pSchema[cols].name, "created_time");
|
// strcpy(pSchema[cols].name, "created_time");
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pShow->bytes[cols] = 2;
|
// pShow->bytes[cols] = 2;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT;
|
// pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT;
|
||||||
strcpy(pSchema[cols].name, "columns");
|
// strcpy(pSchema[cols].name, "columns");
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pShow->bytes[cols] = TSDB_METER_NAME_LEN;
|
// pShow->bytes[cols] = TSDB_METER_NAME_LEN;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
// pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||||
strcpy(pSchema[cols].name, "stable");
|
// strcpy(pSchema[cols].name, "stable");
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pMeta->numOfColumns = htons(cols);
|
// pMeta->numOfColumns = htons(cols);
|
||||||
pShow->numOfColumns = cols;
|
// pShow->numOfColumns = cols;
|
||||||
|
//
|
||||||
pShow->offset[0] = 0;
|
// pShow->offset[0] = 0;
|
||||||
for (int32_t i = 1; i < cols; ++i) {
|
// for (int32_t i = 1; i < cols; ++i) {
|
||||||
pShow->offset[i] = pShow->offset[i - 1] + pShow->bytes[i - 1];
|
// pShow->offset[i] = pShow->offset[i - 1] + pShow->bytes[i - 1];
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
pShow->numOfRows = pDb->numOfTables;
|
// pShow->numOfRows = pDb->numOfTables;
|
||||||
pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1];
|
// pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1];
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -292,117 +292,117 @@ static void mgmtVacuumResult(char *data, int32_t numOfCols, int32_t rows, int32_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtRetrieveTables(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn) {
|
int32_t mgmtRetrieveTables(SShowObj *pShow, char *data, int32_t rows, void *pConn) {
|
||||||
int32_t numOfRows = 0;
|
int32_t numOfRows = 0;
|
||||||
int32_t numOfRead = 0;
|
// int32_t numOfRead = 0;
|
||||||
int32_t cols = 0;
|
// int32_t cols = 0;
|
||||||
void *pTable = NULL;
|
// void *pTable = NULL;
|
||||||
char *pWrite = NULL;
|
// char *pWrite = NULL;
|
||||||
|
//
|
||||||
int16_t numOfColumns;
|
// int16_t numOfColumns;
|
||||||
int64_t createdTime;
|
// int64_t createdTime;
|
||||||
char *tableId;
|
// char *tableId;
|
||||||
char *superTableId;
|
// char *superTableId;
|
||||||
SPatternCompareInfo info = PATTERN_COMPARE_INFO_INITIALIZER;
|
// SPatternCompareInfo info = PATTERN_COMPARE_INFO_INITIALIZER;
|
||||||
|
//
|
||||||
SDbObj *pDb = NULL;
|
// SDbObj *pDb = NULL;
|
||||||
if (pConn->pDb != NULL) {
|
// if (pConn->pDb != NULL) {
|
||||||
pDb = mgmtGetDb(pConn->pDb->name);
|
// pDb = mgmtGetDb(pConn->pDb->name);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (pDb == NULL) {
|
// if (pDb == NULL) {
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (mgmtCheckIsMonitorDB(pDb->name, tsMonitorDbName)) {
|
// if (mgmtCheckIsMonitorDB(pDb->name, tsMonitorDbName)) {
|
||||||
if (strcmp(pConn->pUser->user, "root") != 0 && strcmp(pConn->pUser->user, "_root") != 0 &&
|
// if (strcmp(pConn->pUser->user, "root") != 0 && strcmp(pConn->pUser->user, "_root") != 0 &&
|
||||||
strcmp(pConn->pUser->user, "monitor") != 0) {
|
// strcmp(pConn->pUser->user, "monitor") != 0) {
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
char prefix[20] = {0};
|
// char prefix[20] = {0};
|
||||||
strcpy(prefix, pDb->name);
|
// strcpy(prefix, pDb->name);
|
||||||
strcat(prefix, TS_PATH_DELIMITER);
|
// strcat(prefix, TS_PATH_DELIMITER);
|
||||||
int32_t prefixLen = strlen(prefix);
|
// int32_t prefixLen = strlen(prefix);
|
||||||
|
//
|
||||||
while (numOfRows < rows) {
|
// while (numOfRows < rows) {
|
||||||
void *pNormalTableNode = sdbFetchRow(tsNormalTableSdb, pShow->pNode, (void **) &pTable);
|
// void *pNormalTableNode = sdbFetchRow(tsNormalTableSdb, pShow->pNode, (void **) &pTable);
|
||||||
if (pTable != NULL) {
|
// if (pTable != NULL) {
|
||||||
SNormalTableObj *pNormalTable = (SNormalTableObj *) pTable;
|
// SNormalTableObj *pNormalTable = (SNormalTableObj *) pTable;
|
||||||
pShow->pNode = pNormalTableNode;
|
// pShow->pNode = pNormalTableNode;
|
||||||
tableId = pNormalTable->tableId;
|
// tableId = pNormalTable->tableId;
|
||||||
superTableId = NULL;
|
// superTableId = NULL;
|
||||||
createdTime = pNormalTable->createdTime;
|
// createdTime = pNormalTable->createdTime;
|
||||||
numOfColumns = pNormalTable->numOfColumns;
|
// numOfColumns = pNormalTable->numOfColumns;
|
||||||
} else {
|
// } else {
|
||||||
void *pStreamTableNode = sdbFetchRow(tsStreamTableSdb, pShow->pNode, (void **) &pTable);
|
// void *pStreamTableNode = sdbFetchRow(tsStreamTableSdb, pShow->pNode, (void **) &pTable);
|
||||||
if (pTable != NULL) {
|
// if (pTable != NULL) {
|
||||||
SStreamTableObj *pChildTable = (SStreamTableObj *) pTable;
|
// SStreamTableObj *pChildTable = (SStreamTableObj *) pTable;
|
||||||
pShow->pNode = pStreamTableNode;
|
// pShow->pNode = pStreamTableNode;
|
||||||
tableId = pChildTable->tableId;
|
// tableId = pChildTable->tableId;
|
||||||
superTableId = NULL;
|
// superTableId = NULL;
|
||||||
createdTime = pChildTable->createdTime;
|
// createdTime = pChildTable->createdTime;
|
||||||
numOfColumns = pChildTable->numOfColumns;
|
// numOfColumns = pChildTable->numOfColumns;
|
||||||
} else {
|
// } else {
|
||||||
void *pChildTableNode = sdbFetchRow(tsChildTableSdb, pShow->pNode, (void **) &pTable);
|
// void *pChildTableNode = sdbFetchRow(tsChildTableSdb, pShow->pNode, (void **) &pTable);
|
||||||
if (pTable != NULL) {
|
// if (pTable != NULL) {
|
||||||
SChildTableObj *pChildTable = (SChildTableObj *) pTable;
|
// SChildTableObj *pChildTable = (SChildTableObj *) pTable;
|
||||||
pShow->pNode = pChildTableNode;
|
// pShow->pNode = pChildTableNode;
|
||||||
tableId = pChildTable->tableId;
|
// tableId = pChildTable->tableId;
|
||||||
superTableId = NULL;
|
// superTableId = NULL;
|
||||||
createdTime = pChildTable->createdTime;
|
// createdTime = pChildTable->createdTime;
|
||||||
numOfColumns = pChildTable->superTable->numOfColumns;
|
// numOfColumns = pChildTable->superTable->numOfColumns;
|
||||||
} else {
|
// } else {
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// not belong to current db
|
// // not belong to current db
|
||||||
if (strncmp(tableId, prefix, prefixLen)) {
|
// if (strncmp(tableId, prefix, prefixLen)) {
|
||||||
continue;
|
// continue;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
char meterName[TSDB_METER_NAME_LEN] = {0};
|
// char meterName[TSDB_METER_NAME_LEN] = {0};
|
||||||
memset(meterName, 0, tListLen(meterName));
|
// memset(meterName, 0, tListLen(meterName));
|
||||||
numOfRead++;
|
// numOfRead++;
|
||||||
|
//
|
||||||
// pattern compare for meter name
|
// // pattern compare for meter name
|
||||||
extractTableName(tableId, meterName);
|
// extractTableName(tableId, meterName);
|
||||||
|
//
|
||||||
if (pShow->payloadLen > 0 &&
|
// if (pShow->payloadLen > 0 &&
|
||||||
patternMatch(pShow->payload, meterName, TSDB_METER_NAME_LEN, &info) != TSDB_PATTERN_MATCH) {
|
// patternMatch(pShow->payload, meterName, TSDB_METER_NAME_LEN, &info) != TSDB_PATTERN_MATCH) {
|
||||||
continue;
|
// continue;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
cols = 0;
|
// cols = 0;
|
||||||
|
//
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
// pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
strncpy(pWrite, meterName, TSDB_METER_NAME_LEN);
|
// strncpy(pWrite, meterName, TSDB_METER_NAME_LEN);
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
// pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
*(int64_t *) pWrite = createdTime;
|
// *(int64_t *) pWrite = createdTime;
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
// pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
*(int16_t *) pWrite = numOfColumns;
|
// *(int16_t *) pWrite = numOfColumns;
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
// pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
if (superTableId != NULL) {
|
// if (superTableId != NULL) {
|
||||||
extractTableName(superTableId, pWrite);
|
// extractTableName(superTableId, pWrite);
|
||||||
}
|
// }
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
numOfRows++;
|
// numOfRows++;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
pShow->numOfReads += numOfRead;
|
// pShow->numOfReads += numOfRead;
|
||||||
const int32_t NUM_OF_COLUMNS = 4;
|
// const int32_t NUM_OF_COLUMNS = 4;
|
||||||
|
//
|
||||||
mgmtVacuumResult(data, NUM_OF_COLUMNS, numOfRows, rows, pShow);
|
// mgmtVacuumResult(data, NUM_OF_COLUMNS, numOfRows, rows, pShow);
|
||||||
|
|
||||||
return numOfRows;
|
return numOfRows;
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,75 +153,75 @@ void mgmtCleanUpUsers() {
|
||||||
sdbCloseTable(tsUserSdb);
|
sdbCloseTable(tsUserSdb);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtGetUserMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
int32_t mgmtGetUserMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
|
||||||
int32_t cols = 0;
|
// int32_t cols = 0;
|
||||||
SSchema *pSchema = tsGetSchema(pMeta);
|
// SSchema *pSchema = tsGetSchema(pMeta);
|
||||||
|
//
|
||||||
pShow->bytes[cols] = TSDB_USER_LEN;
|
// pShow->bytes[cols] = TSDB_USER_LEN;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
// pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||||
strcpy(pSchema[cols].name, "name");
|
// strcpy(pSchema[cols].name, "name");
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pShow->bytes[cols] = 6;
|
// pShow->bytes[cols] = 6;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
// pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||||
strcpy(pSchema[cols].name, "privilege");
|
// strcpy(pSchema[cols].name, "privilege");
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pShow->bytes[cols] = 8;
|
// pShow->bytes[cols] = 8;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP;
|
// pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||||
strcpy(pSchema[cols].name, "created time");
|
// strcpy(pSchema[cols].name, "created time");
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pMeta->numOfColumns = htons(cols);
|
// pMeta->numOfColumns = htons(cols);
|
||||||
pShow->numOfColumns = cols;
|
// pShow->numOfColumns = cols;
|
||||||
|
//
|
||||||
pShow->offset[0] = 0;
|
// pShow->offset[0] = 0;
|
||||||
for (int32_t i = 1; i < cols; ++i) pShow->offset[i] = pShow->offset[i - 1] + pShow->bytes[i - 1];
|
// for (int32_t i = 1; i < cols; ++i) pShow->offset[i] = pShow->offset[i - 1] + pShow->bytes[i - 1];
|
||||||
|
//
|
||||||
pShow->numOfRows = pConn->pAcct->acctInfo.numOfUsers;
|
// pShow->numOfRows = pConn->pAcct->acctInfo.numOfUsers;
|
||||||
pShow->pNode = pConn->pAcct->pUser;
|
// pShow->pNode = pConn->pAcct->pUser;
|
||||||
pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1];
|
// pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1];
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtRetrieveUsers(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn) {
|
int32_t mgmtRetrieveUsers(SShowObj *pShow, char *data, int32_t rows, void *pConn) {
|
||||||
int32_t numOfRows = 0;
|
int32_t numOfRows = 0;
|
||||||
SUserObj *pUser = NULL;
|
// SUserObj *pUser = NULL;
|
||||||
char * pWrite;
|
// char * pWrite;
|
||||||
int32_t cols = 0;
|
// int32_t cols = 0;
|
||||||
|
//
|
||||||
while (numOfRows < rows) {
|
// while (numOfRows < rows) {
|
||||||
pUser = (SUserObj *)pShow->pNode;
|
// pUser = (SUserObj *)pShow->pNode;
|
||||||
if (pUser == NULL) break;
|
// if (pUser == NULL) break;
|
||||||
pShow->pNode = (void *)pUser->next;
|
// pShow->pNode = (void *)pUser->next;
|
||||||
|
//
|
||||||
cols = 0;
|
// cols = 0;
|
||||||
|
//
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
// pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
strcpy(pWrite, pUser->user);
|
// strcpy(pWrite, pUser->user);
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
// pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
if (pUser->superAuth) {
|
// if (pUser->superAuth) {
|
||||||
strcpy(pWrite, "super");
|
// strcpy(pWrite, "super");
|
||||||
} else if (pUser->writeAuth) {
|
// } else if (pUser->writeAuth) {
|
||||||
strcpy(pWrite, "write");
|
// strcpy(pWrite, "write");
|
||||||
} else {
|
// } else {
|
||||||
strcpy(pWrite, "read");
|
// strcpy(pWrite, "read");
|
||||||
}
|
// }
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
// pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
*(int64_t *)pWrite = pUser->createdTime;
|
// *(int64_t *)pWrite = pUser->createdTime;
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
numOfRows++;
|
// numOfRows++;
|
||||||
}
|
// }
|
||||||
pShow->numOfReads += numOfRows;
|
// pShow->numOfReads += numOfRows;
|
||||||
return numOfRows;
|
return numOfRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,3 +279,9 @@ void *mgmtUserActionDestroy(void *row, char *str, int32_t size, int32_t *ssize)
|
||||||
tfree(row);
|
tfree(row);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SUserObj *mgmtGetUserFromConn(void *pConn) {
|
||||||
|
SRpcConnInfo connInfo;
|
||||||
|
rpcGetConnInfo(pConn, &connInfo);
|
||||||
|
return mgmtGetUser(connInfo.user);
|
||||||
|
}
|
||||||
|
|
|
@ -248,168 +248,168 @@ void mgmtSetVgroupIdPool() {
|
||||||
|
|
||||||
void mgmtCleanUpVgroups() { sdbCloseTable(tsVgroupSdb); }
|
void mgmtCleanUpVgroups() { sdbCloseTable(tsVgroupSdb); }
|
||||||
|
|
||||||
int32_t mgmtGetVgroupMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
|
int32_t mgmtGetVgroupMeta(SMeterMeta *pMeta, SShowObj *pShow, void *pConn) {
|
||||||
int32_t cols = 0;
|
// int32_t cols = 0;
|
||||||
|
//
|
||||||
SDbObj *pDb = NULL;
|
// SDbObj *pDb = NULL;
|
||||||
if (pConn->pDb != NULL) pDb = mgmtGetDb(pConn->pDb->name);
|
// if (pConn->pDb != NULL) pDb = mgmtGetDb(pConn->pDb->name);
|
||||||
|
//
|
||||||
if (pDb == NULL) return TSDB_CODE_DB_NOT_SELECTED;
|
// if (pDb == NULL) return TSDB_CODE_DB_NOT_SELECTED;
|
||||||
|
//
|
||||||
SSchema *pSchema = tsGetSchema(pMeta);
|
// SSchema *pSchema = tsGetSchema(pMeta);
|
||||||
|
//
|
||||||
pShow->bytes[cols] = 4;
|
// pShow->bytes[cols] = 4;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
// pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
||||||
strcpy(pSchema[cols].name, "vgId");
|
// strcpy(pSchema[cols].name, "vgId");
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pShow->bytes[cols] = 4;
|
// pShow->bytes[cols] = 4;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
// pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
||||||
strcpy(pSchema[cols].name, "meters");
|
// strcpy(pSchema[cols].name, "meters");
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pShow->bytes[cols] = 9;
|
// pShow->bytes[cols] = 9;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
// pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||||
strcpy(pSchema[cols].name, "vgroup status");
|
// strcpy(pSchema[cols].name, "vgroup status");
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
int32_t maxReplica = 0;
|
// int32_t maxReplica = 0;
|
||||||
SVgObj *pVgroup = NULL;
|
// SVgObj *pVgroup = NULL;
|
||||||
STableInfo *pTable = NULL;
|
// STableInfo *pTable = NULL;
|
||||||
if (pShow->payloadLen > 0 ) {
|
// if (pShow->payloadLen > 0 ) {
|
||||||
pTable = mgmtGetTable(pShow->payload);
|
// pTable = mgmtGetTable(pShow->payload);
|
||||||
if (NULL == pTable) {
|
// if (NULL == pTable) {
|
||||||
return TSDB_CODE_INVALID_TABLE_ID;
|
// return TSDB_CODE_INVALID_TABLE_ID;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
pVgroup = mgmtGetVgroup(pTable->vgId);
|
// pVgroup = mgmtGetVgroup(pTable->vgId);
|
||||||
if (NULL == pVgroup) return TSDB_CODE_INVALID_TABLE_ID;
|
// if (NULL == pVgroup) return TSDB_CODE_INVALID_TABLE_ID;
|
||||||
|
//
|
||||||
maxReplica = pVgroup->numOfVnodes > maxReplica ? pVgroup->numOfVnodes : maxReplica;
|
// maxReplica = pVgroup->numOfVnodes > maxReplica ? pVgroup->numOfVnodes : maxReplica;
|
||||||
} else {
|
// } else {
|
||||||
SVgObj *pVgroup = pDb->pHead;
|
// SVgObj *pVgroup = pDb->pHead;
|
||||||
while (pVgroup != NULL) {
|
// while (pVgroup != NULL) {
|
||||||
maxReplica = pVgroup->numOfVnodes > maxReplica ? pVgroup->numOfVnodes : maxReplica;
|
// maxReplica = pVgroup->numOfVnodes > maxReplica ? pVgroup->numOfVnodes : maxReplica;
|
||||||
pVgroup = pVgroup->next;
|
// pVgroup = pVgroup->next;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
for (int32_t i = 0; i < maxReplica; ++i) {
|
// for (int32_t i = 0; i < maxReplica; ++i) {
|
||||||
pShow->bytes[cols] = 16;
|
// pShow->bytes[cols] = 16;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
// pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||||
strcpy(pSchema[cols].name, "ip");
|
// strcpy(pSchema[cols].name, "ip");
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pShow->bytes[cols] = 2;
|
// pShow->bytes[cols] = 2;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT;
|
// pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT;
|
||||||
strcpy(pSchema[cols].name, "vnode");
|
// strcpy(pSchema[cols].name, "vnode");
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pShow->bytes[cols] = 9;
|
// pShow->bytes[cols] = 9;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
// pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||||
strcpy(pSchema[cols].name, "vnode status");
|
// strcpy(pSchema[cols].name, "vnode status");
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pShow->bytes[cols] = 16;
|
// pShow->bytes[cols] = 16;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
// pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||||
strcpy(pSchema[cols].name, "public ip");
|
// strcpy(pSchema[cols].name, "public ip");
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
// pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
cols++;
|
// cols++;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
pMeta->numOfColumns = htons(cols);
|
// pMeta->numOfColumns = htons(cols);
|
||||||
pShow->numOfColumns = cols;
|
// pShow->numOfColumns = cols;
|
||||||
|
//
|
||||||
pShow->offset[0] = 0;
|
// pShow->offset[0] = 0;
|
||||||
for (int32_t i = 1; i < cols; ++i) pShow->offset[i] = pShow->offset[i - 1] + pShow->bytes[i - 1];
|
// for (int32_t i = 1; i < cols; ++i) pShow->offset[i] = pShow->offset[i - 1] + pShow->bytes[i - 1];
|
||||||
|
//
|
||||||
pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1];
|
// pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1];
|
||||||
|
//
|
||||||
if (NULL == pTable) {
|
// if (NULL == pTable) {
|
||||||
pShow->numOfRows = pDb->numOfVgroups;
|
// pShow->numOfRows = pDb->numOfVgroups;
|
||||||
pShow->pNode = pDb->pHead;
|
// pShow->pNode = pDb->pHead;
|
||||||
} else {
|
// } else {
|
||||||
pShow->numOfRows = 1;
|
// pShow->numOfRows = 1;
|
||||||
pShow->pNode = pVgroup;
|
// pShow->pNode = pVgroup;
|
||||||
}
|
// }
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mgmtRetrieveVgroups(SShowObj *pShow, char *data, int32_t rows, SConnObj *pConn) {
|
int32_t mgmtRetrieveVgroups(SShowObj *pShow, char *data, int32_t rows, void *pConn) {
|
||||||
int32_t numOfRows = 0;
|
int32_t numOfRows = 0;
|
||||||
SVgObj *pVgroup = NULL;
|
// SVgObj *pVgroup = NULL;
|
||||||
char * pWrite;
|
// char * pWrite;
|
||||||
int32_t cols = 0;
|
// int32_t cols = 0;
|
||||||
char ipstr[20];
|
// char ipstr[20];
|
||||||
|
//
|
||||||
int32_t maxReplica = 0;
|
// int32_t maxReplica = 0;
|
||||||
|
//
|
||||||
SDbObj *pDb = NULL;
|
// SDbObj *pDb = NULL;
|
||||||
if (pConn->pDb != NULL) pDb = mgmtGetDb(pConn->pDb->name);
|
// if (pConn->pDb != NULL) pDb = mgmtGetDb(pConn->pDb->name);
|
||||||
assert(pDb != NULL);
|
// assert(pDb != NULL);
|
||||||
|
//
|
||||||
pVgroup = pDb->pHead;
|
// pVgroup = pDb->pHead;
|
||||||
while (pVgroup != NULL) {
|
// while (pVgroup != NULL) {
|
||||||
maxReplica = pVgroup->numOfVnodes > maxReplica ? pVgroup->numOfVnodes : maxReplica;
|
// maxReplica = pVgroup->numOfVnodes > maxReplica ? pVgroup->numOfVnodes : maxReplica;
|
||||||
pVgroup = pVgroup->next;
|
// pVgroup = pVgroup->next;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
while (numOfRows < rows) {
|
// while (numOfRows < rows) {
|
||||||
// pShow->pNode = sdbFetchRow(tsVgroupSdb, pShow->pNode, (void **)&pVgroup);
|
// // pShow->pNode = sdbFetchRow(tsVgroupSdb, pShow->pNode, (void **)&pVgroup);
|
||||||
pVgroup = (SVgObj *)pShow->pNode;
|
// pVgroup = (SVgObj *)pShow->pNode;
|
||||||
if (pVgroup == NULL) break;
|
// if (pVgroup == NULL) break;
|
||||||
pShow->pNode = (void *)pVgroup->next;
|
// pShow->pNode = (void *)pVgroup->next;
|
||||||
|
//
|
||||||
cols = 0;
|
// cols = 0;
|
||||||
|
//
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
// pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
*(int32_t *)pWrite = pVgroup->vgId;
|
// *(int32_t *)pWrite = pVgroup->vgId;
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
// pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
*(int32_t *)pWrite = pVgroup->numOfTables;
|
// *(int32_t *)pWrite = pVgroup->numOfTables;
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
// pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
strcpy(pWrite, taosGetVgroupLbStatusStr(pVgroup->lbStatus));
|
// strcpy(pWrite, taosGetVgroupLbStatusStr(pVgroup->lbStatus));
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
for (int32_t i = 0; i < maxReplica; ++i) {
|
// for (int32_t i = 0; i < maxReplica; ++i) {
|
||||||
tinet_ntoa(ipstr, pVgroup->vnodeGid[i].ip);
|
// tinet_ntoa(ipstr, pVgroup->vnodeGid[i].ip);
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
// pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
strcpy(pWrite, ipstr);
|
// strcpy(pWrite, ipstr);
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
// pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
*(int16_t *)pWrite = pVgroup->vnodeGid[i].vnode;
|
// *(int16_t *)pWrite = pVgroup->vnodeGid[i].vnode;
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
// pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
if (pVgroup->vnodeGid[i].ip != 0) {
|
// if (pVgroup->vnodeGid[i].ip != 0) {
|
||||||
char *vnodeStatus = mgmtGetVnodeStatus(pVgroup, pVgroup->vnodeGid + i);
|
// char *vnodeStatus = mgmtGetVnodeStatus(pVgroup, pVgroup->vnodeGid + i);
|
||||||
strcpy(pWrite, vnodeStatus);
|
// strcpy(pWrite, vnodeStatus);
|
||||||
} else {
|
// } else {
|
||||||
strcpy(pWrite, "null");
|
// strcpy(pWrite, "null");
|
||||||
}
|
// }
|
||||||
cols++;
|
// cols++;
|
||||||
|
//
|
||||||
tinet_ntoa(ipstr, pVgroup->vnodeGid[i].publicIp);
|
// tinet_ntoa(ipstr, pVgroup->vnodeGid[i].publicIp);
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
// pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
strcpy(pWrite, ipstr);
|
// strcpy(pWrite, ipstr);
|
||||||
cols++;
|
// cols++;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
numOfRows++;
|
// numOfRows++;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
pShow->numOfReads += numOfRows;
|
// pShow->numOfReads += numOfRows;
|
||||||
return numOfRows;
|
return numOfRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue