Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a241006d
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
a241006d
编写于
2月 22, 2020
作者:
S
slguan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
server in mgmtShell
上级
cbbe8c16
变更
11
展开全部
隐藏空白更改
内联
并排
Showing
11 changed file
with
324 addition
and
421 deletion
+324
-421
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+1
-1
src/client/src/tscProfile.c
src/client/src/tscProfile.c
+8
-8
src/client/src/tscServer.c
src/client/src/tscServer.c
+34
-38
src/inc/mnode.h
src/inc/mnode.h
+2
-2
src/inc/sdb.h
src/inc/sdb.h
+3
-6
src/inc/taosmsg.h
src/inc/taosmsg.h
+27
-41
src/mnode/inc/mgmtProfile.h
src/mnode/inc/mgmtProfile.h
+8
-8
src/mnode/inc/mgmtShell.h
src/mnode/inc/mgmtShell.h
+7
-7
src/mnode/src/mgmtProfile.c
src/mnode/src/mgmtProfile.c
+62
-62
src/mnode/src/mgmtShell.c
src/mnode/src/mgmtShell.c
+162
-246
src/sdb/src/sdbEngine.c
src/sdb/src/sdbEngine.c
+10
-2
未找到文件。
src/client/inc/tsclient.h
浏览文件 @
a241006d
...
...
@@ -325,7 +325,7 @@ typedef struct _sql_obj {
int64_t
stime
;
uint32_t
queryId
;
void
*
thandle
;
SRpcIpSet
ipSet
;
SRpcIpSet
*
ipSet
;
void
*
pStream
;
void
*
pSubscription
;
char
*
sqlstr
;
...
...
src/client/src/tscProfile.c
浏览文件 @
a241006d
...
...
@@ -209,16 +209,16 @@ void tscKillStream(STscObj *pObj, uint32_t killId) {
}
char
*
tscBuildQueryStreamDesc
(
char
*
pMsg
,
STscObj
*
pObj
)
{
S
QList
*
pQList
=
(
SQ
List
*
)
pMsg
;
S
CMQqueryList
*
pQList
=
(
SCMQquery
List
*
)
pMsg
;
char
*
pMax
=
pMsg
+
TSDB_PAYLOAD_SIZE
-
256
;
S
Q
Desc
*
pQdesc
=
pQList
->
qdesc
;
S
CMQuery
Desc
*
pQdesc
=
pQList
->
qdesc
;
pQList
->
numOfQueries
=
0
;
// We extract the lock to tscBuildHeartBeatMsg function.
/* pthread_mutex_lock (&pObj->mutex); */
pMsg
+=
sizeof
(
S
Q
List
);
pMsg
+=
sizeof
(
S
CMQquery
List
);
SSqlObj
*
pSql
=
pObj
->
sqlList
;
while
(
pSql
)
{
/*
...
...
@@ -239,15 +239,15 @@ char *tscBuildQueryStreamDesc(char *pMsg, STscObj *pObj) {
pQList
->
numOfQueries
++
;
pQdesc
++
;
pSql
=
pSql
->
next
;
pMsg
+=
sizeof
(
S
Q
Desc
);
pMsg
+=
sizeof
(
S
CMQuery
Desc
);
if
(
pMsg
>
pMax
)
break
;
}
S
SList
*
pSList
=
(
SS
List
*
)
pMsg
;
S
S
Desc
*
pSdesc
=
pSList
->
sdesc
;
S
CMStreamList
*
pSList
=
(
SCMStream
List
*
)
pMsg
;
S
CMStream
Desc
*
pSdesc
=
pSList
->
sdesc
;
pSList
->
numOfStreams
=
0
;
pMsg
+=
sizeof
(
S
S
List
);
pMsg
+=
sizeof
(
S
CMStream
List
);
SSqlStream
*
pStream
=
pObj
->
streamList
;
while
(
pStream
)
{
strncpy
(
pSdesc
->
sql
,
pStream
->
pSql
->
sqlstr
,
TSDB_SHOW_SQL_LEN
-
1
);
...
...
@@ -265,7 +265,7 @@ char *tscBuildQueryStreamDesc(char *pMsg, STscObj *pObj) {
pSList
->
numOfStreams
++
;
pSdesc
++
;
pStream
=
pStream
->
next
;
pMsg
+=
sizeof
(
S
S
Desc
);
pMsg
+=
sizeof
(
S
CMStream
Desc
);
if
(
pMsg
>
pMax
)
break
;
}
...
...
src/client/src/tscServer.c
浏览文件 @
a241006d
...
...
@@ -31,12 +31,10 @@
#define TSC_MGMT_VNODE 999
SRpcIpSet
tscMgmtIpList
;
int
tsMasterIndex
=
0
;
int
tsSlaveIndex
=
1
;
//temp
SRpcIpSet
tscMgmtIpSet
;
SRpcIpSet
tscMgmtIpList
;
SRpcIpSet
tscDnodeIpSet
;
int
(
*
tscBuildMsg
[
TSDB_SQL_MAX
])(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
=
{
0
};
...
...
@@ -62,29 +60,27 @@ void tscPrintMgmtIp() {
}
}
void
tscSetMgmtIpListFromCluster
(
SIpList
*
pIpList
)
{
tscMgmtIpList
.
numOfIps
=
pIpList
->
numOfIps
;
if
(
memcmp
(
tscMgmtIpList
.
ip
,
pIpList
->
ip
,
pIpList
->
numOfIps
*
4
)
!=
0
)
{
for
(
int
i
=
0
;
i
<
pIpList
->
numOfIps
;
++
i
)
{
//tinet_ntoa(tscMgmtIpList.ipStr[i], pIpList->ip[i]);
tscMgmtIpList
.
ip
[
i
]
=
pIpList
->
ip
[
i
];
}
tscTrace
(
"cluster mgmt IP list:"
);
tscPrintMgmtIp
();
void
tscSetMgmtIpListFromCluster
(
SRpcIpSet
*
pIpList
)
{
tscMgmtIpList
.
numOfIps
=
htons
(
pIpList
->
numOfIps
);
tscMgmtIpList
.
index
=
htons
(
pIpList
->
index
);
tscMgmtIpList
.
port
=
htons
(
pIpList
->
port
);
for
(
int32_t
i
=
0
;
i
<
tscMgmtIpList
.
numOfIps
;
++
i
)
{
tscMgmtIpList
.
ip
[
i
]
=
pIpList
->
ip
[
i
];
}
}
void
tscSetMgmtIpListFromEdge
()
{
if
(
tscMgmtIpList
.
numOfIps
!=
2
)
{
tscMgmtIpList
.
numOfIps
=
2
;
if
(
tscMgmtIpList
.
numOfIps
!=
1
)
{
tscMgmtIpList
.
numOfIps
=
1
;
tscMgmtIpList
.
index
=
0
;
tscMgmtIpList
.
port
=
tsMgmtShellPort
;
tscMgmtIpList
.
ip
[
0
]
=
inet_addr
(
tsMasterIp
);
tscMgmtIpList
.
ip
[
1
]
=
inet_addr
(
tsMasterIp
);
tscTrace
(
"edge mgmt IP list:"
);
tscPrintMgmtIp
();
}
}
void
tscSetMgmtIpList
(
S
IpLis
t
*
pIpList
)
{
void
tscSetMgmtIpList
(
S
RpcIpSe
t
*
pIpList
)
{
/*
* The iplist returned by the cluster edition is the current management nodes
* and the iplist returned by the edge edition is empty
...
...
@@ -120,8 +116,8 @@ void tscProcessHeartBeatRsp(void *param, TAOS_RES *tres, int code) {
SSqlRes
*
pRes
=
&
pSql
->
res
;
if
(
code
==
0
)
{
S
HeartBeatRsp
*
pRsp
=
(
S
HeartBeatRsp
*
)
pRes
->
pRsp
;
S
IpLis
t
*
pIpList
=
&
pRsp
->
ipList
;
S
CMHeartBeatRsp
*
pRsp
=
(
SCM
HeartBeatRsp
*
)
pRes
->
pRsp
;
S
RpcIpSe
t
*
pIpList
=
&
pRsp
->
ipList
;
tscSetMgmtIpList
(
pIpList
);
if
(
pRsp
->
killConnection
)
{
...
...
@@ -296,7 +292,7 @@ void tscGetConnToVnode(SSqlObj *pSql, uint8_t *pCode) {
pVPeersDesc
[
pSql
->
index
].
ip
,
pSql
->
index
,
pSql
->
thandle
);
//TODO fetch from vpeerdesc
pSql
->
ipSet
=
tscMgmtIpSe
t
;
pSql
->
ipSet
=
&
tscMgmtIpLis
t
;
break
;
}
...
...
@@ -364,17 +360,17 @@ int tscSendMsgToServer(SSqlObj *pSql) {
}
void
tscProcessMgmtRedirect
(
SSqlObj
*
pSql
,
uint8_t
*
cont
)
{
SIpList
*
pIpList
=
(
SIpList
*
)(
cont
);
tscSetMgmtIpList
(
pIpList
);
if
(
pSql
->
cmd
.
command
<
TSDB_SQL_READ
)
{
tsMasterIndex
=
0
;
pSql
->
index
=
0
;
}
else
{
pSql
->
index
++
;
}
tscPrintMgmtIp
();
//
SIpList *pIpList = (SIpList *)(cont);
//
tscSetMgmtIpList(pIpList);
//
//
if (pSql->cmd.command < TSDB_SQL_READ) {
//
tsMasterIndex = 0;
//
pSql->index = 0;
//
} else {
//
pSql->index++;
//
}
//
//
tscPrintMgmtIp();
}
void
*
tscProcessMsgFromServer
(
char
*
msg
,
void
*
ahandle
,
void
*
thandle
)
{
...
...
@@ -2884,18 +2880,18 @@ int tscEstimateHeartBeatMsgLength(SSqlObj *pSql) {
STscObj
*
pObj
=
pSql
->
pTscObj
;
size
+=
tsRpcHeadSize
+
sizeof
(
SMgmtHead
);
size
+=
sizeof
(
S
Q
List
);
size
+=
sizeof
(
S
CMQquery
List
);
SSqlObj
*
tpSql
=
pObj
->
sqlList
;
while
(
tpSql
)
{
size
+=
sizeof
(
S
Q
Desc
);
size
+=
sizeof
(
S
CMQuery
Desc
);
tpSql
=
tpSql
->
next
;
}
size
+=
sizeof
(
S
S
List
);
size
+=
sizeof
(
S
CMStream
List
);
SSqlStream
*
pStream
=
pObj
->
streamList
;
while
(
pStream
)
{
size
+=
sizeof
(
S
S
Desc
);
size
+=
sizeof
(
S
CMStream
Desc
);
pStream
=
pStream
->
next
;
}
...
...
@@ -3323,10 +3319,10 @@ int tscProcessConnectRsp(SSqlObj *pSql) {
assert
(
len
<=
tListLen
(
pObj
->
db
));
strncpy
(
pObj
->
db
,
temp
,
tListLen
(
pObj
->
db
));
SIpList
*
pIpList
;
char
*
rsp
=
pRes
->
pRsp
+
sizeof
(
SCMConnectRsp
);
pIpList
=
(
SIpList
*
)
rsp
;
tscSetMgmtIpList
(
pIpList
);
//
SIpList * pIpList;
//
char *rsp = pRes->pRsp + sizeof(SCMConnectRsp);
//
pIpList = (SIpList *)rsp;
//
tscSetMgmtIpList(pIpList);
strcpy
(
pObj
->
sversion
,
pConnect
->
serverVersion
);
pObj
->
writeAuth
=
pConnect
->
writeAuth
;
...
...
src/inc/mnode.h
浏览文件 @
a241006d
...
...
@@ -306,8 +306,8 @@ typedef struct _connObj {
uint32_t
ip
;
// shell IP
uint16_t
port
;
// shell port
void
*
thandle
;
S
Q
List
*
pQList
;
// query list
S
S
List
*
pSList
;
// stream list
S
CMQquery
List
*
pQList
;
// query list
S
CMStream
List
*
pSList
;
// stream list
uint64_t
qhandle
;
struct
_connObj
*
prev
,
*
next
;
}
SConnObj
;
...
...
src/inc/sdb.h
浏览文件 @
a241006d
...
...
@@ -37,8 +37,8 @@ extern int sdbExtConns;
extern
int
sdbMaster
;
extern
uint32_t
sdbPublicIp
;
extern
uint32_t
sdbMasterStartTime
;
extern
S
IpLis
t
*
pSdbIpList
;
extern
S
IpLis
t
*
pSdbPublicIpList
;
extern
S
RpcIpSe
t
*
pSdbIpList
;
extern
S
RpcIpSe
t
*
pSdbPublicIpList
;
extern
void
(
*
sdbWorkAsMasterCallback
)();
// this function pointer will be set by taosd
...
...
@@ -71,8 +71,6 @@ enum _sdbaction {
SDB_MAX_ACTION_TYPES
};
#ifdef CLUSTER
#define SDB_MAX_PEERS 4
typedef
struct
{
uint32_t
ip
;
...
...
@@ -103,8 +101,6 @@ extern SSdbPeer *sdbPeer[];
#define sdbInited (sdbPeer[0])
#define sdbStatus (sdbPeer[0]->status)
#endif
void
*
sdbOpenTable
(
int
maxRows
,
int32_t
maxRowSize
,
char
*
name
,
uint8_t
keyType
,
char
*
directory
,
void
*
(
*
appTool
)(
char
,
void
*
,
char
*
,
int
,
int
*
));
...
...
@@ -138,6 +134,7 @@ int sdbCfgNode(char *cont);
int64_t
sdbGetVersion
();
int32_t
sdbGetRunStatus
();
#define TSDB_MAX_TABLES 1000
extern
void
*
tsChildTableSdb
;
...
...
src/inc/taosmsg.h
浏览文件 @
a241006d
...
...
@@ -26,6 +26,7 @@ extern "C" {
#include "taosdef.h"
#include "taoserror.h"
#include "taosdef.h"
#include "trpc.h"
// message type
#define TSDB_MSG_TYPE_REG 1
...
...
@@ -187,25 +188,8 @@ typedef enum {
extern
char
*
taosMsg
[];
#define TSDB_MSG_DEF_MAX_MPEERS 5
#define TSDB_MSG_DEF_VERSION_LEN 64
#define TSDB_MSG_DEF_DB_LEN 128
#define TSDB_MSG_DEF_USER_LEN 128
#define TSDB_MSG_DEF_TABLE_LEN 128
#define TSDB_MSG_DEF_ACCT_LEN 128
#pragma pack(push, 1)
typedef
struct
{
char
numOfIps
;
uint32_t
ip
[];
}
SIpList
;
typedef
struct
{
char
numOfIps
;
uint32_t
ip
[
TSDB_MAX_MGMT_IPS
];
}
SMgmtIpList
;
typedef
struct
{
uint32_t
customerId
;
uint32_t
osId
;
...
...
@@ -332,20 +316,17 @@ typedef struct {
}
SAlterTableMsg
;
typedef
struct
{
char
clientVersion
[
TSDB_
MSG_DEF_
VERSION_LEN
];
char
msgVersion
[
TSDB_
MSG_DEF_
VERSION_LEN
];
char
db
[
TSDB_
MSG_DEF_DB
_LEN
];
char
clientVersion
[
TSDB_VERSION_LEN
];
char
msgVersion
[
TSDB_VERSION_LEN
];
char
db
[
TSDB_
TABLE_ID
_LEN
];
}
SCMConnectMsg
;
typedef
struct
{
char
acctId
[
TSDB_MSG_DEF_ACCT_LEN
];
char
serverVersion
[
TSDB_MSG_DEF_VERSION_LEN
];
int8_t
writeAuth
;
int8_t
superAuth
;
int16_t
index
;
int16_t
numOfIps
;
uint16_t
port
;
uint32_t
ip
[
TSDB_MSG_DEF_MAX_MPEERS
];
char
acctId
[
TSDB_ACCT_LEN
];
char
serverVersion
[
TSDB_VERSION_LEN
];
int8_t
writeAuth
;
int8_t
superAuth
;
SRpcIpSet
ipList
;
}
SCMConnectRsp
;
typedef
struct
{
...
...
@@ -799,19 +780,12 @@ typedef struct {
char
config
[
60
];
}
SCfgMsg
;
typedef
struct
{
uint32_t
queryId
;
uint32_t
streamId
;
char
killConnection
;
SIpList
ipList
;
}
SHeartBeatRsp
;
typedef
struct
{
char
sql
[
TSDB_SHOW_SQL_LEN
];
uint32_t
queryId
;
int64_t
useconds
;
int64_t
stime
;
}
S
Q
Desc
;
}
S
CMQuery
Desc
;
typedef
struct
{
char
sql
[
TSDB_SHOW_SQL_LEN
];
...
...
@@ -822,17 +796,29 @@ typedef struct {
int64_t
stime
;
int64_t
slidingTime
;
int64_t
interval
;
}
S
S
Desc
;
}
S
CMStream
Desc
;
typedef
struct
{
int32_t
numOfQueries
;
S
Q
Desc
qdesc
[];
}
S
Q
List
;
S
CMQuery
Desc
qdesc
[];
}
S
CMQquery
List
;
typedef
struct
{
int32_t
numOfStreams
;
SSDesc
sdesc
[];
}
SSList
;
SCMStreamDesc
sdesc
[];
}
SCMStreamList
;
typedef
struct
{
SCMQqueryList
qlist
;
SCMStreamList
slist
;
}
SCMHeartBeatMsg
;
typedef
struct
{
uint32_t
queryId
;
uint32_t
streamId
;
int8_t
killConnection
;
SRpcIpSet
ipList
;
}
SCMHeartBeatRsp
;
typedef
struct
{
uint64_t
handle
;
...
...
src/mnode/inc/mgmtProfile.h
浏览文件 @
a241006d
...
...
@@ -22,21 +22,21 @@ extern "C" {
#include "mnode.h"
int
mgmtGetQueryMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
);
int
32_t
mgmtGetQueryMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
);
int
mgmtGetStreamMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
);
int
32_t
mgmtGetStreamMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
);
int
mgmtRetrieveQueries
(
SShowObj
*
pShow
,
char
*
data
,
in
t
rows
,
SConnObj
*
pConn
);
int
32_t
mgmtRetrieveQueries
(
SShowObj
*
pShow
,
char
*
data
,
int32_
t
rows
,
SConnObj
*
pConn
);
int
mgmtRetrieveStreams
(
SShowObj
*
pShow
,
char
*
data
,
in
t
rows
,
SConnObj
*
pConn
);
int
32_t
mgmtRetrieveStreams
(
SShowObj
*
pShow
,
char
*
data
,
int32_
t
rows
,
SConnObj
*
pConn
);
int
mgmtSaveQueryStreamList
(
char
*
cont
,
int
contLen
,
SConnObj
*
pConn
);
int
32_t
mgmtSaveQueryStreamList
(
SCMHeartBeatMsg
*
pHBMsg
);
int
mgmtKillQuery
(
char
*
qidstr
,
SConnObj
*
pConn
);
int
32_t
mgmtKillQuery
(
char
*
qidstr
,
SConnObj
*
pConn
);
int
mgmtKillStream
(
char
*
qidstr
,
SConnObj
*
pConn
);
int
32_t
mgmtKillStream
(
char
*
qidstr
,
SConnObj
*
pConn
);
int
mgmtKillConnection
(
char
*
qidstr
,
SConnObj
*
pConn
);
int
32_t
mgmtKillConnection
(
char
*
qidstr
,
SConnObj
*
pConn
);
#ifdef __cplusplus
}
...
...
src/mnode/inc/mgmtShell.h
浏览文件 @
a241006d
...
...
@@ -28,13 +28,13 @@ int32_t mgmtInitShell();
void
mgmtCleanUpShell
();
extern
int32_t
(
*
mgmtCheckRedirectMsg
)(
SConnObj
*
pConn
,
int32_t
msgType
);
extern
int32_t
(
*
mgmtProcessAlterAcctMsg
)(
char
*
pMsg
,
int32_t
msgLen
,
SConnObj
*
pConn
);
extern
int32_t
(
*
mgmtProcessCreateDnodeMsg
)(
char
*
pMsg
,
int32_t
msgLen
,
SConnObj
*
pConn
);
extern
int32_t
(
*
mgmtProcessCfgMnodeMsg
)(
char
*
pMsg
,
int32_t
msgLen
,
SConnObj
*
pConn
);
extern
int32_t
(
*
mgmtProcessDropMnodeMsg
)(
char
*
pMsg
,
int32_t
msgLen
,
SConnObj
*
pConn
);
extern
int32_t
(
*
mgmtProcessDropDnodeMsg
)(
char
*
pMsg
,
int32_t
msgLen
,
SConnObj
*
pConn
);
extern
int32_t
(
*
mgmtProcessDropAcctMsg
)(
char
*
pMsg
,
int32_t
msgLen
,
SConnObj
*
pConn
);
extern
int32_t
(
*
mgmtProcessCreateAcctMsg
)(
char
*
pMsg
,
int32_t
msgLen
,
SConnObj
*
pConn
);
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
(
*
mgmtProcessCfgMnodeMsg
)(
void
*
pCont
,
int32_t
contLen
,
void
*
ahandle
);
extern
int32_t
(
*
mgmtProcessDropMnodeMsg
)(
void
*
pCont
,
int32_t
contLen
,
void
*
ahandle
);
extern
int32_t
(
*
mgmtProcessDropDnodeMsg
)(
void
*
pCont
,
int32_t
contLen
,
void
*
ahandle
);
extern
int32_t
(
*
mgmtProcessDropAcctMsg
)(
void
*
pCont
,
int32_t
contLen
,
void
*
ahandle
);
extern
int32_t
(
*
mgmtProcessCreateAcctMsg
)(
void
*
pCont
,
int32_t
contLen
,
void
*
ahandle
);
#ifdef __cplusplus
}
...
...
src/mnode/src/mgmtProfile.c
浏览文件 @
a241006d
...
...
@@ -28,55 +28,55 @@ typedef struct {
}
SCDesc
;
typedef
struct
{
int
index
;
int
numOfQueries
;
int
32_t
index
;
int
32_t
numOfQueries
;
SCDesc
*
connInfo
;
SCDesc
**
cdesc
;
S
Q
Desc
qdesc
[];
S
CMQuery
Desc
qdesc
[];
}
SQueryShow
;
typedef
struct
{
int
index
;
int
numOfStreams
;
int
32_t
index
;
int
32_t
numOfStreams
;
SCDesc
*
connInfo
;
SCDesc
**
cdesc
;
S
S
Desc
sdesc
[];
S
CMStream
Desc
sdesc
[];
}
SStreamShow
;
int
mgmtSaveQueryStreamList
(
char
*
cont
,
int
contLen
,
SConnObj
*
pConn
)
{
SAcctObj
*
pAcct
=
pConn
->
pAcct
;
if
(
contLen
<=
0
||
pAcct
==
NULL
)
{
return
0
;
}
pthread_mutex_lock
(
&
pAcct
->
mutex
);
if
(
pConn
->
pQList
)
{
pAcct
->
acctInfo
.
numOfQueries
-=
pConn
->
pQList
->
numOfQueries
;
pAcct
->
acctInfo
.
numOfStreams
-=
pConn
->
pSList
->
numOfStreams
;
}
pConn
->
pQList
=
realloc
(
pConn
->
pQList
,
contLen
);
memcpy
(
pConn
->
pQList
,
cont
,
contLen
);
pConn
->
pSList
=
(
SSList
*
)(((
char
*
)
pConn
->
pQList
)
+
pConn
->
pQList
->
numOfQueries
*
sizeof
(
SQDesc
)
+
sizeof
(
SQ
List
));
pAcct
->
acctInfo
.
numOfQueries
+=
pConn
->
pQList
->
numOfQueries
;
pAcct
->
acctInfo
.
numOfStreams
+=
pConn
->
pSList
->
numOfStreams
;
pthread_mutex_unlock
(
&
pAcct
->
mutex
);
return
0
;
int
32_t
mgmtSaveQueryStreamList
(
SCMHeartBeatMsg
*
pHBMsg
)
{
//
SAcctObj *pAcct = pConn->pAcct;
//
//
if (contLen <= 0 || pAcct == NULL) {
//
return 0;
//
}
//
//
pthread_mutex_lock(&pAcct->mutex);
//
//
if (pConn->pQList) {
//
pAcct->acctInfo.numOfQueries -= pConn->pQList->numOfQueries;
//
pAcct->acctInfo.numOfStreams -= pConn->pSList->numOfStreams;
//
}
//
//
pConn->pQList = realloc(pConn->pQList, contLen);
//
memcpy(pConn->pQList, cont, contLen);
//
// pConn->pSList = (SCMStreamList *)(((char *)pConn->pQList) + pConn->pQList->numOfQueries * sizeof(SCMQueryDesc) + sizeof(SCMQquery
List));
//
//
pAcct->acctInfo.numOfQueries += pConn->pQList->numOfQueries;
//
pAcct->acctInfo.numOfStreams += pConn->pSList->numOfStreams;
//
//
pthread_mutex_unlock(&pAcct->mutex);
return
TSDB_CODE_SUCCESS
;
}
int
mgmtGetQueries
(
SShowObj
*
pShow
,
SConnObj
*
pConn
)
{
int
32_t
mgmtGetQueries
(
SShowObj
*
pShow
,
SConnObj
*
pConn
)
{
SAcctObj
*
pAcct
=
pConn
->
pAcct
;
SQueryShow
*
pQueryShow
;
pthread_mutex_lock
(
&
pAcct
->
mutex
);
pQueryShow
=
malloc
(
sizeof
(
S
Q
Desc
)
*
pAcct
->
acctInfo
.
numOfQueries
+
sizeof
(
SQueryShow
));
pQueryShow
=
malloc
(
sizeof
(
S
CMQuery
Desc
)
*
pAcct
->
acctInfo
.
numOfQueries
+
sizeof
(
SQueryShow
));
pQueryShow
->
numOfQueries
=
0
;
pQueryShow
->
index
=
0
;
pQueryShow
->
connInfo
=
NULL
;
...
...
@@ -87,7 +87,7 @@ int mgmtGetQueries(SShowObj *pShow, SConnObj *pConn) {
pQueryShow
->
cdesc
=
(
SCDesc
**
)
malloc
(
pAcct
->
acctInfo
.
numOfQueries
*
sizeof
(
SCDesc
*
));
pConn
=
pAcct
->
pConn
;
S
Q
Desc
*
pQdesc
=
pQueryShow
->
qdesc
;
S
CMQuery
Desc
*
pQdesc
=
pQueryShow
->
qdesc
;
SCDesc
*
pCDesc
=
pQueryShow
->
connInfo
;
SCDesc
**
ppCDesc
=
pQueryShow
->
cdesc
;
...
...
@@ -97,10 +97,10 @@ int mgmtGetQueries(SShowObj *pShow, SConnObj *pConn) {
pCDesc
->
port
=
pConn
->
port
;
strcpy
(
pCDesc
->
user
,
pConn
->
pUser
->
user
);
memcpy
(
pQdesc
,
pConn
->
pQList
->
qdesc
,
sizeof
(
S
Q
Desc
)
*
pConn
->
pQList
->
numOfQueries
);
memcpy
(
pQdesc
,
pConn
->
pQList
->
qdesc
,
sizeof
(
S
CMQuery
Desc
)
*
pConn
->
pQList
->
numOfQueries
);
pQdesc
+=
pConn
->
pQList
->
numOfQueries
;
pQueryShow
->
numOfQueries
+=
pConn
->
pQList
->
numOfQueries
;
for
(
int
i
=
0
;
i
<
pConn
->
pQList
->
numOfQueries
;
++
i
,
++
ppCDesc
)
*
ppCDesc
=
pCDesc
;
for
(
int
32_t
i
=
0
;
i
<
pConn
->
pQList
->
numOfQueries
;
++
i
,
++
ppCDesc
)
*
ppCDesc
=
pCDesc
;
pCDesc
++
;
}
...
...
@@ -117,8 +117,8 @@ int mgmtGetQueries(SShowObj *pShow, SConnObj *pConn) {
return
0
;
}
int
mgmtGetQueryMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
)
{
int
cols
=
0
;
int
32_t
mgmtGetQueryMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
)
{
int
32_t
cols
=
0
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
);
...
...
@@ -156,7 +156,7 @@ int mgmtGetQueryMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
pShow
->
numOfColumns
=
cols
;
pShow
->
offset
[
0
]
=
0
;
for
(
int
i
=
1
;
i
<
cols
;
++
i
)
pShow
->
offset
[
i
]
=
pShow
->
offset
[
i
-
1
]
+
pShow
->
bytes
[
i
-
1
];
for
(
int
32_t
i
=
1
;
i
<
cols
;
++
i
)
pShow
->
offset
[
i
]
=
pShow
->
offset
[
i
-
1
]
+
pShow
->
bytes
[
i
-
1
];
pShow
->
numOfRows
=
1000000
;
pShow
->
pNode
=
NULL
;
...
...
@@ -166,7 +166,7 @@ int mgmtGetQueryMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
return
0
;
}
int
mgmtKillQuery
(
char
*
qidstr
,
SConnObj
*
pConn
)
{
int
32_t
mgmtKillQuery
(
char
*
qidstr
,
SConnObj
*
pConn
)
{
char
*
temp
,
*
chr
,
idstr
[
64
];
strcpy
(
idstr
,
qidstr
);
...
...
@@ -192,8 +192,8 @@ int mgmtKillQuery(char *qidstr, SConnObj *pConn) {
pConn
=
pAcct
->
pConn
;
while
(
pConn
)
{
if
(
pConn
->
ip
==
ip
&&
pConn
->
port
==
port
&&
pConn
->
pQList
)
{
int
i
;
S
Q
Desc
*
pQDesc
=
pConn
->
pQList
->
qdesc
;
int
32_t
i
;
S
CMQuery
Desc
*
pQDesc
=
pConn
->
pQList
->
qdesc
;
for
(
i
=
0
;
i
<
pConn
->
pQList
->
numOfQueries
;
++
i
,
++
pQDesc
)
{
if
(
pQDesc
->
queryId
==
queryId
)
break
;
}
...
...
@@ -219,17 +219,17 @@ _error:
return
TSDB_CODE_INVALID_QUERY_ID
;
}
int
mgmtRetrieveQueries
(
SShowObj
*
pShow
,
char
*
data
,
in
t
rows
,
SConnObj
*
pConn
)
{
int
numOfRows
=
0
;
int
32_t
mgmtRetrieveQueries
(
SShowObj
*
pShow
,
char
*
data
,
int32_
t
rows
,
SConnObj
*
pConn
)
{
int
32_t
numOfRows
=
0
;
char
*
pWrite
;
int
cols
=
0
;
int
32_t
cols
=
0
;
SQueryShow
*
pQueryShow
=
(
SQueryShow
*
)
pShow
->
pNode
;
if
(
rows
>
pQueryShow
->
numOfQueries
-
pQueryShow
->
index
)
rows
=
pQueryShow
->
numOfQueries
-
pQueryShow
->
index
;
while
(
numOfRows
<
rows
)
{
S
Q
Desc
*
pNode
=
pQueryShow
->
qdesc
+
pQueryShow
->
index
;
S
CMQuery
Desc
*
pNode
=
pQueryShow
->
qdesc
+
pQueryShow
->
index
;
SCDesc
*
pCDesc
=
pQueryShow
->
cdesc
[
pQueryShow
->
index
];
cols
=
0
;
...
...
@@ -269,13 +269,13 @@ int mgmtRetrieveQueries(SShowObj *pShow, char *data, int rows, SConnObj *pConn)
return
numOfRows
;
}
int
mgmtGetStreams
(
SShowObj
*
pShow
,
SConnObj
*
pConn
)
{
int
32_t
mgmtGetStreams
(
SShowObj
*
pShow
,
SConnObj
*
pConn
)
{
SAcctObj
*
pAcct
=
pConn
->
pAcct
;
SStreamShow
*
pStreamShow
;
pthread_mutex_lock
(
&
pAcct
->
mutex
);
pStreamShow
=
malloc
(
sizeof
(
S
S
Desc
)
*
pAcct
->
acctInfo
.
numOfStreams
+
sizeof
(
SQueryShow
));
pStreamShow
=
malloc
(
sizeof
(
S
CMStream
Desc
)
*
pAcct
->
acctInfo
.
numOfStreams
+
sizeof
(
SQueryShow
));
pStreamShow
->
numOfStreams
=
0
;
pStreamShow
->
index
=
0
;
pStreamShow
->
connInfo
=
NULL
;
...
...
@@ -286,7 +286,7 @@ int mgmtGetStreams(SShowObj *pShow, SConnObj *pConn) {
pStreamShow
->
cdesc
=
(
SCDesc
**
)
malloc
(
pAcct
->
acctInfo
.
numOfStreams
*
sizeof
(
SCDesc
*
));
pConn
=
pAcct
->
pConn
;
S
S
Desc
*
pSdesc
=
pStreamShow
->
sdesc
;
S
CMStream
Desc
*
pSdesc
=
pStreamShow
->
sdesc
;
SCDesc
*
pCDesc
=
pStreamShow
->
connInfo
;
SCDesc
**
ppCDesc
=
pStreamShow
->
cdesc
;
...
...
@@ -296,10 +296,10 @@ int mgmtGetStreams(SShowObj *pShow, SConnObj *pConn) {
pCDesc
->
port
=
pConn
->
port
;
strcpy
(
pCDesc
->
user
,
pConn
->
pUser
->
user
);
memcpy
(
pSdesc
,
pConn
->
pSList
->
sdesc
,
sizeof
(
S
S
Desc
)
*
pConn
->
pSList
->
numOfStreams
);
memcpy
(
pSdesc
,
pConn
->
pSList
->
sdesc
,
sizeof
(
S
CMStream
Desc
)
*
pConn
->
pSList
->
numOfStreams
);
pSdesc
+=
pConn
->
pSList
->
numOfStreams
;
pStreamShow
->
numOfStreams
+=
pConn
->
pSList
->
numOfStreams
;
for
(
int
i
=
0
;
i
<
pConn
->
pSList
->
numOfStreams
;
++
i
,
++
ppCDesc
)
*
ppCDesc
=
pCDesc
;
for
(
int
32_t
i
=
0
;
i
<
pConn
->
pSList
->
numOfStreams
;
++
i
,
++
ppCDesc
)
*
ppCDesc
=
pCDesc
;
pCDesc
++
;
}
...
...
@@ -316,8 +316,8 @@ int mgmtGetStreams(SShowObj *pShow, SConnObj *pConn) {
return
0
;
}
int
mgmtGetStreamMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
)
{
int
cols
=
0
;
int
32_t
mgmtGetStreamMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
)
{
int
32_t
cols
=
0
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
);
pShow
->
bytes
[
cols
]
=
TSDB_USER_LEN
;
...
...
@@ -366,7 +366,7 @@ int mgmtGetStreamMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
pShow
->
numOfColumns
=
cols
;
pShow
->
offset
[
0
]
=
0
;
for
(
int
i
=
1
;
i
<
cols
;
++
i
)
pShow
->
offset
[
i
]
=
pShow
->
offset
[
i
-
1
]
+
pShow
->
bytes
[
i
-
1
];
for
(
int
32_t
i
=
1
;
i
<
cols
;
++
i
)
pShow
->
offset
[
i
]
=
pShow
->
offset
[
i
-
1
]
+
pShow
->
bytes
[
i
-
1
];
pShow
->
numOfRows
=
1000000
;
pShow
->
pNode
=
NULL
;
...
...
@@ -376,17 +376,17 @@ int mgmtGetStreamMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
return
0
;
}
int
mgmtRetrieveStreams
(
SShowObj
*
pShow
,
char
*
data
,
in
t
rows
,
SConnObj
*
pConn
)
{
int
numOfRows
=
0
;
int
32_t
mgmtRetrieveStreams
(
SShowObj
*
pShow
,
char
*
data
,
int32_
t
rows
,
SConnObj
*
pConn
)
{
int
32_t
numOfRows
=
0
;
char
*
pWrite
;
int
cols
=
0
;
int
32_t
cols
=
0
;
SStreamShow
*
pStreamShow
=
(
SStreamShow
*
)
pShow
->
pNode
;
if
(
rows
>
pStreamShow
->
numOfStreams
-
pStreamShow
->
index
)
rows
=
pStreamShow
->
numOfStreams
-
pStreamShow
->
index
;
while
(
numOfRows
<
rows
)
{
S
S
Desc
*
pNode
=
pStreamShow
->
sdesc
+
pStreamShow
->
index
;
S
CMStream
Desc
*
pNode
=
pStreamShow
->
sdesc
+
pStreamShow
->
index
;
SCDesc
*
pCDesc
=
pStreamShow
->
cdesc
[
pStreamShow
->
index
];
cols
=
0
;
...
...
@@ -434,7 +434,7 @@ int mgmtRetrieveStreams(SShowObj *pShow, char *data, int rows, SConnObj *pConn)
return
numOfRows
;
}
int
mgmtKillStream
(
char
*
qidstr
,
SConnObj
*
pConn
)
{
int
32_t
mgmtKillStream
(
char
*
qidstr
,
SConnObj
*
pConn
)
{
char
*
temp
,
*
chr
,
idstr
[
64
];
strcpy
(
idstr
,
qidstr
);
...
...
@@ -460,8 +460,8 @@ int mgmtKillStream(char *qidstr, SConnObj *pConn) {
pConn
=
pAcct
->
pConn
;
while
(
pConn
)
{
if
(
pConn
->
ip
==
ip
&&
pConn
->
port
==
port
&&
pConn
->
pSList
)
{
int
i
;
S
S
Desc
*
pSDesc
=
pConn
->
pSList
->
sdesc
;
int
32_t
i
;
S
CMStream
Desc
*
pSDesc
=
pConn
->
pSList
->
sdesc
;
for
(
i
=
0
;
i
<
pConn
->
pSList
->
numOfStreams
;
++
i
,
++
pSDesc
)
{
if
(
pSDesc
->
streamId
==
streamId
)
break
;
}
...
...
@@ -487,7 +487,7 @@ _error:
return
TSDB_CODE_INVALID_STREAM_ID
;
}
int
mgmtKillConnection
(
char
*
qidstr
,
SConnObj
*
pConn
)
{
int
32_t
mgmtKillConnection
(
char
*
qidstr
,
SConnObj
*
pConn
)
{
SConnObj
*
pConn1
=
NULL
;
char
*
temp
,
*
chr
,
idstr
[
64
];
strcpy
(
idstr
,
qidstr
);
...
...
src/mnode/src/mgmtShell.c
浏览文件 @
a241006d
此差异已折叠。
点击以展开。
src/sdb/src/sdbEngine.c
浏览文件 @
a241006d
...
...
@@ -24,8 +24,9 @@
extern
char
version
[];
const
int16_t
sdbFileVersion
=
0
;
int
sdbExtConns
=
0
;
SIpList
*
pSdbIpList
=
NULL
;
SIpList
*
pSdbPublicIpList
=
NULL
;
SRpcIpSet
*
pSdbIpList
=
NULL
;
SRpcIpSet
*
pSdbPublicIpList
=
NULL
;
SSdbPeer
*
sdbPeer
[
SDB_MAX_PEERS
];
// first slot for self
#ifdef CLUSTER
int
sdbMaster
=
0
;
...
...
@@ -57,6 +58,13 @@ int64_t sdbGetVersion() {
return
sdbVersion
;
};
int32_t
sdbGetRunStatus
()
{
if
(
sdbInited
==
NULL
)
{
return
SDB_STATUS_OFFLINE
;
}
return
sdbStatus
;
}
void
sdbFinishCommit
(
void
*
handle
)
{
SSdbTable
*
pTable
=
(
SSdbTable
*
)
handle
;
uint32_t
sdbEcommit
=
SDB_ENDCOMMIT
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录