Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
920edd13
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看板
提交
920edd13
编写于
8月 30, 2019
作者:
H
hjliao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix bugs #436
上级
b3cb1e20
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
51 addition
and
17 deletion
+51
-17
src/system/src/mgmtShell.c
src/system/src/mgmtShell.c
+51
-17
未找到文件。
src/system/src/mgmtShell.c
浏览文件 @
920edd13
...
...
@@ -14,16 +14,15 @@
*/
#include <arpa/inet.h>
#include <mgmt.h>
#include <taosmsg.h>
#include "taosmsg.h"
#include "dnodeSystem.h"
#include "mgmt.h"
#include "mgmtProfile.h"
#include "tlog.h"
#pragma GCC diagnostic ignored "-Wint-conversion"
#pragma GCC diagnostic ignored "-Wpointer-sign"
#pragma GCC diagnostic ignored "-Wint-conversion"
#pragma GCC diagnostic ignored "-Wpointer-sign"
void
*
pShellConn
=
NULL
;
SConnObj
*
connList
;
...
...
@@ -119,6 +118,27 @@ static char *mgmtAllocMsg(SConnObj *pConn, int32_t size, char **pMsg, STaosRsp *
return
pStart
;
}
/**
* check if we need to add mgmtProcessMeterMetaMsg into tranQueue, which will be executed one-by-one.
*
* @param pMsg
* @return
*/
bool
mgmtCheckMeterMetaMsgType
(
char
*
pMsg
)
{
SMeterInfoMsg
*
pInfo
=
(
SMeterInfoMsg
*
)
pMsg
;
int16_t
autoCreate
=
htons
(
pInfo
->
createFlag
);
STabObj
*
pMeterObj
=
mgmtGetMeter
(
pInfo
->
meterId
);
// If table does not exists and autoCreate flag is set, we add the handler into another task queue, namely tranQueue
bool
addIntoTranQueue
=
(
pMeterObj
==
NULL
&&
autoCreate
==
1
);
if
(
addIntoTranQueue
)
{
mTrace
(
"meter:%s auto created task added"
,
pInfo
->
meterId
);
}
return
addIntoTranQueue
;
}
int
mgmtProcessMeterMetaMsg
(
char
*
pMsg
,
int
msgLen
,
SConnObj
*
pConn
)
{
SMeterInfoMsg
*
pInfo
=
(
SMeterInfoMsg
*
)
pMsg
;
STabObj
*
pMeterObj
=
NULL
;
...
...
@@ -133,7 +153,8 @@ int mgmtProcessMeterMetaMsg(char *pMsg, int msgLen, SConnObj *pConn) {
int
size
=
sizeof
(
STaosHeader
)
+
sizeof
(
STaosRsp
)
+
sizeof
(
SMeterMeta
)
+
sizeof
(
SSchema
)
*
TSDB_MAX_COLUMNS
+
sizeof
(
SSchema
)
*
TSDB_MAX_TAGS
+
TSDB_MAX_TAGS_LEN
+
TSDB_EXTRA_PAYLOAD_SIZE
;
if
((
pConn
->
pDb
!=
NULL
&&
pConn
->
pDb
->
dropStatus
!=
TSDB_DB_STATUS_READY
)
||
pConn
->
pDb
==
NULL
)
{
if
(
pConn
->
pDb
==
NULL
||
(
pConn
->
pDb
!=
NULL
&&
pConn
->
pDb
->
dropStatus
!=
TSDB_DB_STATUS_READY
))
{
// todo handle failed to allocate msg buffer
if
((
pStart
=
mgmtAllocMsg
(
pConn
,
size
,
&
pMsg
,
&
pRsp
))
==
NULL
)
{
return
0
;
}
...
...
@@ -145,14 +166,24 @@ int mgmtProcessMeterMetaMsg(char *pMsg, int msgLen, SConnObj *pConn) {
}
pMeterObj
=
mgmtGetMeter
(
pInfo
->
meterId
);
// on demand create table from super table if meter does not exists
if
(
pMeterObj
==
NULL
&&
pInfo
->
createFlag
==
1
)
{
// create the meter objects if not exists
SCreateTableMsg
*
pCreateMsg
=
calloc
(
1
,
sizeof
(
SCreateTableMsg
)
+
sizeof
(
STagData
));
if
(
pCreateMsg
==
NULL
)
{
return
0
;
}
memcpy
(
pCreateMsg
->
schema
,
pInfo
->
tags
,
sizeof
(
STagData
));
strcpy
(
pCreateMsg
->
meterId
,
pInfo
->
meterId
);
// todo handle if not master mnode
int32_t
code
=
mgmtCreateMeter
(
pConn
->
pDb
,
pCreateMsg
);
mTrace
(
"meter:%s is automatically created by %s, code:%d"
,
pCreateMsg
->
meterId
,
pConn
->
pUser
->
user
,
code
);
char
stableName
[
TSDB_METER_ID_LEN
]
=
{
0
};
strncpy
(
stableName
,
pInfo
->
tags
,
TSDB_METER_ID_LEN
);
mTrace
(
"meter:%s is automatically created by %s from %s, code:%d"
,
pCreateMsg
->
meterId
,
pConn
->
pUser
->
user
,
stableName
,
code
);
tfree
(
pCreateMsg
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -180,7 +211,7 @@ int mgmtProcessMeterMetaMsg(char *pMsg, int msgLen, SConnObj *pConn) {
pRsp
->
code
=
TSDB_CODE_DB_NOT_SELECTED
;
pMsg
++
;
}
else
{
mTrace
(
"
meter:%s, meta is retrieved from:%s"
,
pInfo
->
meterId
,
pMeterObj
->
meterI
d
);
mTrace
(
"
%s, uid:%lld meter meta is retrieved"
,
pInfo
->
meterId
,
pMeterObj
->
ui
d
);
pRsp
->
code
=
0
;
pMsg
+=
sizeof
(
STaosRsp
);
*
pMsg
=
TSDB_IE_TYPE_META
;
...
...
@@ -199,8 +230,7 @@ int mgmtProcessMeterMetaMsg(char *pMsg, int msgLen, SConnObj *pConn) {
pMeta
->
meterType
=
htons
(
pMeterObj
->
meterType
);
pMsg
+=
sizeof
(
SMeterMeta
);
pSchema
=
(
SSchema
*
)
pMsg
;
// schema locates at the end of SMeterMeta
// struct
pSchema
=
(
SSchema
*
)
pMsg
;
// schema locates at the end of SMeterMeta struct
if
(
mgmtMeterCreateFromMetric
(
pMeterObj
))
{
assert
(
pMeterObj
->
numOfTags
==
0
);
...
...
@@ -208,8 +238,7 @@ int mgmtProcessMeterMetaMsg(char *pMsg, int msgLen, SConnObj *pConn) {
STabObj
*
pMetric
=
mgmtGetMeter
(
pMeterObj
->
pTagData
);
uint32_t
numOfTotalCols
=
(
uint32_t
)
pMetric
->
numOfTags
+
pMetric
->
numOfColumns
;
pMeta
->
numOfTags
=
htons
(
pMetric
->
numOfTags
);
// update the numOfTags
// info
pMeta
->
numOfTags
=
htons
(
pMetric
->
numOfTags
);
// update the numOfTags info
mgmtSetSchemaFromMeters
(
pSchema
,
pMetric
,
numOfTotalCols
);
pMsg
+=
numOfTotalCols
*
sizeof
(
SSchema
);
...
...
@@ -233,7 +262,10 @@ int mgmtProcessMeterMetaMsg(char *pMsg, int msgLen, SConnObj *pConn) {
pRsp
->
code
=
TSDB_CODE_INVALID_TABLE
;
goto
_exit_code
;
}
pMeta
->
vpeerDesc
[
0
].
vnode
=
htonl
(
pVgroup
->
vnodeGid
[
0
].
vnode
);
for
(
int
i
=
0
;
i
<
TSDB_VNODES_SUPPORT
;
++
i
)
{
pMeta
->
vpeerDesc
[
i
].
ip
=
pVgroup
->
vnodeGid
[
i
].
publicIp
;
pMeta
->
vpeerDesc
[
i
].
vnode
=
htonl
(
pVgroup
->
vnodeGid
[
i
].
vnode
);
}
}
}
...
...
@@ -934,12 +966,14 @@ void *mgmtProcessMsgFromShell(char *msg, void *ahandle, void *thandle) {
char
*
cont
=
(
char
*
)
pMsg
->
content
+
sizeof
(
SMgmtHead
);
int
contLen
=
pMsg
->
msgLen
-
sizeof
(
SIntMsg
)
-
sizeof
(
SMgmtHead
);
if
(
pMsg
->
msgType
==
TSDB_MSG_TYPE_METERINFO
||
pMsg
->
msgType
==
TSDB_MSG_TYPE_METRIC_META
||
pMsg
->
msgType
==
TSDB_MSG_TYPE_RETRIEVE
||
pMsg
->
msgType
==
TSDB_MSG_TYPE_SHOW
)
{
// read-only request can be executed concurrently
if
((
pMsg
->
msgType
==
TSDB_MSG_TYPE_METERINFO
&&
(
!
mgmtCheckMeterMetaMsgType
(
cont
)))
||
pMsg
->
msgType
==
TSDB_MSG_TYPE_METRIC_META
||
pMsg
->
msgType
==
TSDB_MSG_TYPE_RETRIEVE
||
pMsg
->
msgType
==
TSDB_MSG_TYPE_SHOW
)
{
(
*
mgmtProcessShellMsg
[
pMsg
->
msgType
])(
cont
,
contLen
,
pConn
);
}
else
{
if
(
mgmtProcessShellMsg
[
pMsg
->
msgType
])
{
// TODO : put the msg in tran queue
SSchedMsg
schedMsg
;
schedMsg
.
msg
=
malloc
(
pMsg
->
msgLen
);
// Message to deal with
memcpy
(
schedMsg
.
msg
,
pMsg
,
pMsg
->
msgLen
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录