Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
dc081e52
T
TDengine
项目概览
taosdata
/
TDengine
11 个月 前同步成功
通知
1179
Star
22014
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
dc081e52
编写于
1月 07, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
差异文件
Merge branch '3.0' of
https://github.com/taosdata/TDengine
into feature/vnode
上级
79dafa10
61136183
变更
51
隐藏空白更改
内联
并排
Showing
51 changed file
with
1141 addition
and
475 deletion
+1141
-475
include/common/tmsg.h
include/common/tmsg.h
+17
-16
include/dnode/mnode/sdb/sdb.h
include/dnode/mnode/sdb/sdb.h
+9
-0
include/libs/catalog/catalog.h
include/libs/catalog/catalog.h
+1
-1
include/util/tcoding.h
include/util/tcoding.h
+24
-1
include/util/thash.h
include/util/thash.h
+8
-0
source/client/inc/clientHb.h
source/client/inc/clientHb.h
+148
-0
source/client/src/clientHb.c
source/client/src/clientHb.c
+60
-0
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+2
-2
source/dnode/mgmt/impl/inc/dndInt.h
source/dnode/mgmt/impl/inc/dndInt.h
+14
-14
source/dnode/mgmt/impl/inc/dndMgmt.h
source/dnode/mgmt/impl/inc/dndMgmt.h
+0
-0
source/dnode/mgmt/impl/src/dndBnode.c
source/dnode/mgmt/impl/src/dndBnode.c
+1
-1
source/dnode/mgmt/impl/src/dndMgmt.c
source/dnode/mgmt/impl/src/dndMgmt.c
+49
-94
source/dnode/mgmt/impl/src/dndMnode.c
source/dnode/mgmt/impl/src/dndMnode.c
+1
-1
source/dnode/mgmt/impl/src/dndQnode.c
source/dnode/mgmt/impl/src/dndQnode.c
+1
-1
source/dnode/mgmt/impl/src/dndSnode.c
source/dnode/mgmt/impl/src/dndSnode.c
+1
-1
source/dnode/mgmt/impl/src/dndTransport.c
source/dnode/mgmt/impl/src/dndTransport.c
+1
-1
source/dnode/mgmt/impl/src/dndVnodes.c
source/dnode/mgmt/impl/src/dndVnodes.c
+1
-1
source/dnode/mgmt/impl/src/dndWorker.c
source/dnode/mgmt/impl/src/dndWorker.c
+3
-1
source/dnode/mgmt/impl/src/dnode.c
source/dnode/mgmt/impl/src/dnode.c
+1
-1
source/dnode/mgmt/impl/test/CMakeLists.txt
source/dnode/mgmt/impl/test/CMakeLists.txt
+1
-10
source/dnode/mgmt/impl/test/mnode/CMakeLists.txt
source/dnode/mgmt/impl/test/mnode/CMakeLists.txt
+2
-2
source/dnode/mgmt/impl/test/mnode/qmnode.cpp
source/dnode/mgmt/impl/test/mnode/qmnode.cpp
+26
-0
source/dnode/mnode/impl/src/mndConsumer.c
source/dnode/mnode/impl/src/mndConsumer.c
+20
-13
source/dnode/mnode/impl/src/mndDnode.c
source/dnode/mnode/impl/src/mndDnode.c
+75
-59
source/dnode/mnode/impl/src/mndProfile.c
source/dnode/mnode/impl/src/mndProfile.c
+69
-69
source/dnode/mnode/impl/src/mndShow.c
source/dnode/mnode/impl/src/mndShow.c
+5
-5
source/dnode/mnode/impl/src/mndTopic.c
source/dnode/mnode/impl/src/mndTopic.c
+30
-19
source/dnode/mnode/impl/test/CMakeLists.txt
source/dnode/mnode/impl/test/CMakeLists.txt
+3
-0
source/dnode/mnode/impl/test/bnode/bnode.cpp
source/dnode/mnode/impl/test/bnode/bnode.cpp
+2
-2
source/dnode/mnode/impl/test/dnode/CMakeLists.txt
source/dnode/mnode/impl/test/dnode/CMakeLists.txt
+11
-0
source/dnode/mnode/impl/test/dnode/dnode.cpp
source/dnode/mnode/impl/test/dnode/dnode.cpp
+350
-0
source/dnode/mnode/impl/test/mnode/CMakeLists.txt
source/dnode/mnode/impl/test/mnode/CMakeLists.txt
+11
-0
source/dnode/mnode/impl/test/mnode/mnode.cpp
source/dnode/mnode/impl/test/mnode/mnode.cpp
+48
-48
source/dnode/mnode/impl/test/profile/CMakeLists.txt
source/dnode/mnode/impl/test/profile/CMakeLists.txt
+11
-0
source/dnode/mnode/impl/test/profile/profile.cpp
source/dnode/mnode/impl/test/profile/profile.cpp
+48
-48
source/dnode/mnode/impl/test/qnode/qnode.cpp
source/dnode/mnode/impl/test/qnode/qnode.cpp
+2
-2
source/dnode/mnode/impl/test/show/show.cpp
source/dnode/mnode/impl/test/show/show.cpp
+3
-3
source/dnode/mnode/impl/test/snode/snode.cpp
source/dnode/mnode/impl/test/snode/snode.cpp
+2
-2
source/dnode/mnode/impl/test/trans/trans.cpp
source/dnode/mnode/impl/test/trans/trans.cpp
+2
-2
source/dnode/mnode/sdb/src/sdbHash.c
source/dnode/mnode/sdb/src/sdbHash.c
+9
-0
source/libs/catalog/src/catalog.c
source/libs/catalog/src/catalog.c
+13
-13
source/libs/parser/inc/astToMsg.h
source/libs/parser/inc/astToMsg.h
+2
-2
source/libs/parser/src/astToMsg.c
source/libs/parser/src/astToMsg.c
+6
-6
source/libs/parser/src/astValidate.c
source/libs/parser/src/astValidate.c
+1
-1
source/libs/parser/src/dCDAstProcess.c
source/libs/parser/src/dCDAstProcess.c
+1
-1
source/util/src/thash.c
source/util/src/thash.c
+5
-0
src/client/src/tscProfile.c
src/client/src/tscProfile.c
+2
-2
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+1
-1
src/client/src/tscServer.c
src/client/src/tscServer.c
+10
-10
tests/script/general/table/basic1.sim
tests/script/general/table/basic1.sim
+8
-1
tests/test/c/create_table.c
tests/test/c/create_table.c
+20
-18
未找到文件。
include/common/tmsg.h
浏览文件 @
dc081e52
...
@@ -320,7 +320,7 @@ typedef struct {
...
@@ -320,7 +320,7 @@ typedef struct {
char
app
[
TSDB_APP_NAME_LEN
];
char
app
[
TSDB_APP_NAME_LEN
];
char
db
[
TSDB_DB_NAME_LEN
];
char
db
[
TSDB_DB_NAME_LEN
];
int64_t
startTime
;
int64_t
startTime
;
}
SConnect
Msg
;
}
SConnect
Req
;
typedef
struct
SEpSet
{
typedef
struct
SEpSet
{
int8_t
inUse
;
int8_t
inUse
;
...
@@ -668,6 +668,7 @@ typedef struct {
...
@@ -668,6 +668,7 @@ typedef struct {
int32_t
sver
;
int32_t
sver
;
int32_t
dnodeId
;
int32_t
dnodeId
;
int64_t
clusterId
;
int64_t
clusterId
;
int64_t
dver
;
int64_t
rebootTime
;
int64_t
rebootTime
;
int64_t
updateTime
;
int64_t
updateTime
;
int32_t
numOfCores
;
int32_t
numOfCores
;
...
@@ -675,7 +676,7 @@ typedef struct {
...
@@ -675,7 +676,7 @@ typedef struct {
char
dnodeEp
[
TSDB_EP_LEN
];
char
dnodeEp
[
TSDB_EP_LEN
];
SClusterCfg
clusterCfg
;
SClusterCfg
clusterCfg
;
SVnodeLoads
vnodeLoads
;
SVnodeLoads
vnodeLoads
;
}
SStatus
Msg
;
}
SStatus
Req
;
typedef
struct
{
typedef
struct
{
int32_t
reserved
;
int32_t
reserved
;
...
@@ -700,6 +701,7 @@ typedef struct {
...
@@ -700,6 +701,7 @@ typedef struct {
}
SDnodeEps
;
}
SDnodeEps
;
typedef
struct
{
typedef
struct
{
int64_t
dver
;
SDnodeCfg
dnodeCfg
;
SDnodeCfg
dnodeCfg
;
SDnodeEps
dnodeEps
;
SDnodeEps
dnodeEps
;
}
SStatusRsp
;
}
SStatusRsp
;
...
@@ -851,16 +853,16 @@ typedef struct SShowRsp {
...
@@ -851,16 +853,16 @@ typedef struct SShowRsp {
typedef
struct
{
typedef
struct
{
char
fqdn
[
TSDB_FQDN_LEN
];
// end point, hostname:port
char
fqdn
[
TSDB_FQDN_LEN
];
// end point, hostname:port
int32_t
port
;
int32_t
port
;
}
SCreateDnode
Msg
;
}
SCreateDnode
Req
;
typedef
struct
{
typedef
struct
{
int32_t
dnodeId
;
int32_t
dnodeId
;
}
SDropDnode
Msg
;
}
SDropDnode
Req
;
typedef
struct
{
typedef
struct
{
int32_t
dnodeId
;
int32_t
dnodeId
;
char
config
[
TSDB_DNODE_CONFIG_LEN
];
char
config
[
TSDB_DNODE_CONFIG_LEN
];
}
S
CfgDnodeMsg
;
}
S
MCfgDnodeReq
,
SDCfgDnodeReq
;
typedef
struct
{
typedef
struct
{
int32_t
dnodeId
;
int32_t
dnodeId
;
...
@@ -916,7 +918,7 @@ typedef struct {
...
@@ -916,7 +918,7 @@ typedef struct {
int32_t
numOfStreams
;
int32_t
numOfStreams
;
char
app
[
TSDB_APP_NAME_LEN
];
char
app
[
TSDB_APP_NAME_LEN
];
char
pData
[];
char
pData
[];
}
SHeartBeat
Msg
;
}
SHeartBeat
Req
;
typedef
struct
{
typedef
struct
{
int32_t
connId
;
int32_t
connId
;
...
@@ -929,19 +931,14 @@ typedef struct {
...
@@ -929,19 +931,14 @@ typedef struct {
SEpSet
epSet
;
SEpSet
epSet
;
}
SHeartBeatRsp
;
}
SHeartBeatRsp
;
typedef
struct
{
int32_t
connId
;
int32_t
streamId
;
}
SKillStreamMsg
;
typedef
struct
{
typedef
struct
{
int32_t
connId
;
int32_t
connId
;
int32_t
queryId
;
int32_t
queryId
;
}
SKillQuery
Msg
;
}
SKillQuery
Req
;
typedef
struct
{
typedef
struct
{
int32_t
connId
;
int32_t
connId
;
}
SKillConn
Msg
;
}
SKillConn
Req
;
typedef
struct
{
typedef
struct
{
char
user
[
TSDB_USER_LEN
];
char
user
[
TSDB_USER_LEN
];
...
@@ -1144,7 +1141,7 @@ typedef struct {
...
@@ -1144,7 +1141,7 @@ typedef struct {
int32_t
topicNum
;
int32_t
topicNum
;
int64_t
consumerId
;
int64_t
consumerId
;
char
*
consumerGroup
;
char
*
consumerGroup
;
char
*
topicName
[];
SArray
*
topicNames
;
// SArray<char*>
}
SCMSubscribeReq
;
}
SCMSubscribeReq
;
static
FORCE_INLINE
int
tSerializeSCMSubscribeReq
(
void
**
buf
,
const
SCMSubscribeReq
*
pReq
)
{
static
FORCE_INLINE
int
tSerializeSCMSubscribeReq
(
void
**
buf
,
const
SCMSubscribeReq
*
pReq
)
{
...
@@ -1152,8 +1149,9 @@ static FORCE_INLINE int tSerializeSCMSubscribeReq(void** buf, const SCMSubscribe
...
@@ -1152,8 +1149,9 @@ static FORCE_INLINE int tSerializeSCMSubscribeReq(void** buf, const SCMSubscribe
tlen
+=
taosEncodeFixedI32
(
buf
,
pReq
->
topicNum
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pReq
->
topicNum
);
tlen
+=
taosEncodeFixedI64
(
buf
,
pReq
->
consumerId
);
tlen
+=
taosEncodeFixedI64
(
buf
,
pReq
->
consumerId
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
consumerGroup
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
consumerGroup
);
for
(
int
i
=
0
;
i
<
pReq
->
topicNum
;
i
++
)
{
for
(
int
i
=
0
;
i
<
pReq
->
topicNum
;
i
++
)
{
tlen
+=
taosEncodeString
(
buf
,
pReq
->
topicName
[
i
]
);
tlen
+=
taosEncodeString
(
buf
,
(
char
*
)
taosArrayGetP
(
pReq
->
topicNames
,
i
)
);
}
}
return
tlen
;
return
tlen
;
}
}
...
@@ -1162,8 +1160,11 @@ static FORCE_INLINE void* tDeserializeSCMSubscribeReq(void* buf, SCMSubscribeReq
...
@@ -1162,8 +1160,11 @@ static FORCE_INLINE void* tDeserializeSCMSubscribeReq(void* buf, SCMSubscribeReq
buf
=
taosDecodeFixedI32
(
buf
,
&
pReq
->
topicNum
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pReq
->
topicNum
);
buf
=
taosDecodeFixedI64
(
buf
,
&
pReq
->
consumerId
);
buf
=
taosDecodeFixedI64
(
buf
,
&
pReq
->
consumerId
);
buf
=
taosDecodeString
(
buf
,
&
pReq
->
consumerGroup
);
buf
=
taosDecodeString
(
buf
,
&
pReq
->
consumerGroup
);
pReq
->
topicNames
=
taosArrayInit
(
pReq
->
topicNum
,
sizeof
(
void
*
));
for
(
int
i
=
0
;
i
<
pReq
->
topicNum
;
i
++
)
{
for
(
int
i
=
0
;
i
<
pReq
->
topicNum
;
i
++
)
{
buf
=
taosDecodeString
(
buf
,
&
pReq
->
topicName
[
i
]);
char
*
name
=
NULL
;
buf
=
taosDecodeString
(
buf
,
&
name
);
taosArrayPush
(
pReq
->
topicNames
,
&
name
);
}
}
return
buf
;
return
buf
;
}
}
...
...
include/dnode/mnode/sdb/sdb.h
浏览文件 @
dc081e52
...
@@ -281,6 +281,15 @@ int32_t sdbGetSize(SSdb *pSdb, ESdbType type);
...
@@ -281,6 +281,15 @@ int32_t sdbGetSize(SSdb *pSdb, ESdbType type);
*/
*/
int32_t
sdbGetMaxId
(
SSdb
*
pSdb
,
ESdbType
type
);
int32_t
sdbGetMaxId
(
SSdb
*
pSdb
,
ESdbType
type
);
/**
* @brief Get the version of the table
*
* @param pSdb The sdb object.
* @param pIter The type of the table.
* @return int32_t The version of the table
*/
int64_t
sdbGetTableVer
(
SSdb
*
pSdb
,
ESdbType
type
);
/**
/**
* @brief Update the version of sdb
* @brief Update the version of sdb
*
*
...
...
include/libs/catalog/catalog.h
浏览文件 @
dc081e52
...
@@ -72,7 +72,7 @@ int32_t catalogGetDBVgroupVersion(struct SCatalog* pCatalog, const char* dbName,
...
@@ -72,7 +72,7 @@ int32_t catalogGetDBVgroupVersion(struct SCatalog* pCatalog, const char* dbName,
* @param pVgroupList (output, vgroup info list, element is SVgroupInfo, NEED to simply free the array by caller)
* @param pVgroupList (output, vgroup info list, element is SVgroupInfo, NEED to simply free the array by caller)
* @return error code
* @return error code
*/
*/
int32_t
catalogGetDBVgroup
(
struct
SCatalog
*
pCatalog
,
void
*
pRpc
,
const
SEpSet
*
pMgmtEps
,
const
char
*
pDBName
,
int32_t
forceUpdate
,
SArray
**
pVgroupList
);
int32_t
catalogGetDBVgroup
(
struct
SCatalog
*
pCatalog
,
void
*
pRpc
,
const
SEpSet
*
pMgmtEps
,
const
char
*
pDBName
,
bool
forceUpdate
,
SArray
**
pVgroupList
);
int32_t
catalogUpdateDBVgroup
(
struct
SCatalog
*
pCatalog
,
const
char
*
dbName
,
SDBVgroupInfo
*
dbInfo
);
int32_t
catalogUpdateDBVgroup
(
struct
SCatalog
*
pCatalog
,
const
char
*
dbName
,
SDBVgroupInfo
*
dbInfo
);
...
...
include/util/tcoding.h
浏览文件 @
dc081e52
...
@@ -370,10 +370,33 @@ static FORCE_INLINE void *taosDecodeStringTo(void *buf, char *value) {
...
@@ -370,10 +370,33 @@ static FORCE_INLINE void *taosDecodeStringTo(void *buf, char *value) {
return
POINTER_SHIFT
(
buf
,
size
);
return
POINTER_SHIFT
(
buf
,
size
);
}
}
// ---- binary
static
FORCE_INLINE
int
taosEncodeBinary
(
void
**
buf
,
const
void
*
value
,
int
valueLen
)
{
int
tlen
=
0
;
if
(
buf
!=
NULL
)
{
memcpy
(
*
buf
,
value
,
valueLen
);
*
buf
=
POINTER_SHIFT
(
*
buf
,
valueLen
);
}
tlen
+=
(
int
)
valueLen
;
return
tlen
;
}
static
FORCE_INLINE
void
*
taosDecodeBinary
(
void
*
buf
,
void
**
value
,
int
valueLen
)
{
uint64_t
size
=
0
;
*
value
=
malloc
((
size_t
)
valueLen
);
if
(
*
value
==
NULL
)
return
NULL
;
memcpy
(
*
value
,
buf
,
(
size_t
)
size
);
return
POINTER_SHIFT
(
buf
,
size
);
}
#endif
#endif
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
#endif
/*_TD_UTIL_CODING_H*/
#endif
/*_TD_UTIL_CODING_H*/
\ No newline at end of file
include/util/thash.h
浏览文件 @
dc081e52
...
@@ -210,6 +210,14 @@ void taosHashCancelIterate(SHashObj *pHashObj, void *p);
...
@@ -210,6 +210,14 @@ void taosHashCancelIterate(SHashObj *pHashObj, void *p);
*/
*/
int32_t
taosHashGetKey
(
void
*
data
,
void
**
key
,
size_t
*
keyLen
);
int32_t
taosHashGetKey
(
void
*
data
,
void
**
key
,
size_t
*
keyLen
);
/**
* Get the corresponding data length for a given data in hash table
* @param data
* @return
*/
int32_t
taosHashGetDataLen
(
void
*
data
);
/**
/**
* return the payload data with the specified key(reference number added)
* return the payload data with the specified key(reference number added)
*
*
...
...
source/client/inc/clientHb.h
0 → 100644
浏览文件 @
dc081e52
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "os.h"
#include "tarray.h"
#include "thash.h"
#include "tmsg.h"
typedef
enum
{
mq
=
0
,
HEARTBEAT_TYPE_MAX
}
EHbType
;
typedef
struct
SKlv
{
int32_t
keyLen
;
int32_t
valueLen
;
void
*
key
;
void
*
value
;
}
SKlv
;
static
FORCE_INLINE
int
taosEncodeSKlv
(
void
**
buf
,
const
SKlv
*
pKlv
)
{
int
tlen
=
0
;
tlen
+=
taosEncodeFixedI32
(
buf
,
pKlv
->
keyLen
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pKlv
->
valueLen
);
tlen
+=
taosEncodeBinary
(
buf
,
pKlv
->
key
,
pKlv
->
keyLen
);
tlen
+=
taosEncodeBinary
(
buf
,
pKlv
->
value
,
pKlv
->
valueLen
);
return
tlen
;
}
static
FORCE_INLINE
void
*
taosDecodeSKlv
(
void
*
buf
,
SKlv
*
pKlv
)
{
buf
=
taosDecodeFixedI32
(
buf
,
&
pKlv
->
keyLen
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pKlv
->
valueLen
);
buf
=
taosDecodeBinary
(
buf
,
&
pKlv
->
key
,
pKlv
->
keyLen
);
buf
=
taosDecodeBinary
(
buf
,
&
pKlv
->
value
,
pKlv
->
valueLen
);
return
buf
;
}
typedef
struct
SClientHbKey
{
int32_t
connId
;
int32_t
hbType
;
}
SClientHbKey
;
static
FORCE_INLINE
int
taosEncodeSClientHbKey
(
void
**
buf
,
const
SClientHbKey
*
pKey
)
{
int
tlen
=
0
;
tlen
+=
taosEncodeFixedI32
(
buf
,
pKey
->
connId
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pKey
->
hbType
);
return
tlen
;
}
static
FORCE_INLINE
void
*
taosDecodeSClientHbKey
(
void
*
buf
,
SClientHbKey
*
pKey
)
{
buf
=
taosDecodeFixedI32
(
buf
,
&
pKey
->
connId
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pKey
->
hbType
);
return
buf
;
}
typedef
struct
SClientHbReq
{
SClientHbKey
hbKey
;
SHashObj
*
info
;
// hash<Sklv>
}
SClientHbReq
;
static
FORCE_INLINE
int
tSerializeSClientHbReq
(
void
**
buf
,
const
SClientHbReq
*
pReq
)
{
int
tlen
=
0
;
tlen
+=
taosEncodeSClientHbKey
(
buf
,
&
pReq
->
hbKey
);
void
*
pIter
=
NULL
;
void
*
data
;
SKlv
klv
;
data
=
taosHashIterate
(
pReq
->
info
,
pIter
);
while
(
data
!=
NULL
)
{
taosHashGetKey
(
data
,
&
klv
.
key
,
(
size_t
*
)
&
klv
.
keyLen
);
klv
.
valueLen
=
taosHashGetDataLen
(
data
);
klv
.
value
=
data
;
taosEncodeSKlv
(
buf
,
&
klv
);
data
=
taosHashIterate
(
pReq
->
info
,
pIter
);
}
return
tlen
;
}
static
FORCE_INLINE
void
*
tDeserializeClientHbReq
(
void
*
buf
,
SClientHbReq
*
pReq
)
{
ASSERT
(
pReq
->
info
!=
NULL
);
buf
=
taosDecodeSClientHbKey
(
buf
,
&
pReq
->
hbKey
);
//TODO: error handling
if
(
pReq
->
info
==
NULL
)
{
pReq
->
info
=
taosHashInit
(
64
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_NO_LOCK
);
}
SKlv
klv
;
buf
=
taosDecodeSKlv
(
buf
,
&
klv
);
taosHashPut
(
pReq
->
info
,
klv
.
key
,
klv
.
keyLen
,
klv
.
value
,
klv
.
valueLen
);
return
buf
;
}
typedef
struct
SClientHbBatchReq
{
int64_t
reqId
;
SArray
*
reqs
;
// SArray<SClientHbReq>
}
SClientHbBatchReq
;
typedef
struct
SClientHbHandleResult
{
}
SClientHbHandleResult
;
typedef
struct
SClientHbRsp
{
int32_t
connId
;
int32_t
hbType
;
}
SClientHbRsp
;
typedef
struct
SClientHbBatchRsp
{
int64_t
reqId
;
int64_t
rspId
;
SArray
*
rsps
;
// SArray<SClientHbRsp>
}
SClientHbBatchRsp
;
typedef
int32_t
(
*
FHbRspHandle
)(
SClientHbReq
*
pReq
);
typedef
int32_t
(
*
FGetConnInfo
)(
int32_t
conn
,
void
*
self
);
typedef
struct
SClientHbMgr
{
int8_t
inited
;
int32_t
reportInterval
;
// unit ms
int32_t
stats
;
SRWLatch
lock
;
SHashObj
*
info
;
//hash<SClientHbKey, SClientHbReq>
FHbRspHandle
handle
[
HEARTBEAT_TYPE_MAX
];
// input queue
}
SClientHbMgr
;
static
SClientHbMgr
clientHbMgr
=
{
0
};
int
hbMgrInit
();
void
hbMgrCleanUp
();
int
registerConn
(
int32_t
connId
,
FGetConnInfo
func
,
FHbRspHandle
rspHandle
);
int
registerHbRspHandle
(
int32_t
connId
,
int32_t
hbType
,
FHbRspHandle
rspHandle
);
int
HbAddConnInfo
(
int32_t
connId
,
void
*
key
,
void
*
value
,
int32_t
keyLen
,
int32_t
valueLen
);
source/client/src/clientHb.c
0 → 100644
浏览文件 @
dc081e52
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "clientHb.h"
static
int32_t
mqHbRspHandle
(
SClientHbReq
*
pReq
)
{
return
0
;
}
int
hbMgrInit
()
{
//init once
//
//init lock
//
//init handle funcs
clientHbMgr
.
handle
[
mq
]
=
mqHbRspHandle
;
//init stat
clientHbMgr
.
stats
=
0
;
//init config
clientHbMgr
.
reportInterval
=
1500
;
//init hash info
//
return
0
;
}
void
hbMgrCleanUp
()
{
}
int
registerConn
(
int32_t
connId
,
FGetConnInfo
func
,
FHbRspHandle
rspHandle
)
{
return
0
;
}
int
registerHbRspHandle
(
int32_t
connId
,
int32_t
hbType
,
FHbRspHandle
rspHandle
)
{
return
0
;
}
int
HbAddConnInfo
(
int32_t
connId
,
void
*
key
,
void
*
value
,
int32_t
keyLen
,
int32_t
valueLen
)
{
//lock
//find req by connection id
//unlock
return
0
;
}
source/client/src/clientImpl.c
浏览文件 @
dc081e52
...
@@ -395,13 +395,13 @@ static SMsgSendInfo* buildConnectMsg(SRequestObj *pRequest) {
...
@@ -395,13 +395,13 @@ static SMsgSendInfo* buildConnectMsg(SRequestObj *pRequest) {
}
}
pMsgSendInfo
->
msgType
=
TDMT_MND_CONNECT
;
pMsgSendInfo
->
msgType
=
TDMT_MND_CONNECT
;
pMsgSendInfo
->
msgInfo
.
len
=
sizeof
(
SConnect
Msg
);
pMsgSendInfo
->
msgInfo
.
len
=
sizeof
(
SConnect
Req
);
pMsgSendInfo
->
requestObjRefId
=
pRequest
->
self
;
pMsgSendInfo
->
requestObjRefId
=
pRequest
->
self
;
pMsgSendInfo
->
requestId
=
pRequest
->
requestId
;
pMsgSendInfo
->
requestId
=
pRequest
->
requestId
;
pMsgSendInfo
->
fp
=
handleRequestRspFp
[
TMSG_INDEX
(
pMsgSendInfo
->
msgType
)];
pMsgSendInfo
->
fp
=
handleRequestRspFp
[
TMSG_INDEX
(
pMsgSendInfo
->
msgType
)];
pMsgSendInfo
->
param
=
pRequest
;
pMsgSendInfo
->
param
=
pRequest
;
SConnect
Msg
*
pConnect
=
calloc
(
1
,
sizeof
(
SConnectMsg
));
SConnect
Req
*
pConnect
=
calloc
(
1
,
sizeof
(
SConnectReq
));
if
(
pConnect
==
NULL
)
{
if
(
pConnect
==
NULL
)
{
tfree
(
pMsgSendInfo
);
tfree
(
pMsgSendInfo
);
terrno
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
...
...
source/dnode/mgmt/impl/inc/dndInt.h
浏览文件 @
dc081e52
...
@@ -80,20 +80,20 @@ typedef struct {
...
@@ -80,20 +80,20 @@ typedef struct {
}
SDnodeDir
;
}
SDnodeDir
;
typedef
struct
{
typedef
struct
{
int32_t
dnodeId
;
int32_t
dnodeId
;
int32_t
dropped
;
int32_t
dropped
;
int64_t
clusterId
;
int64_t
clusterId
;
int64_t
rebootTime
;
int64_t
dver
;
int64_t
update
Time
;
int64_t
reboot
Time
;
int
8_t
statusSent
;
int
64_t
updateTime
;
SEpSet
mnodeEpSe
t
;
int8_t
statusSen
t
;
char
*
file
;
SEpSet
mnodeEpSet
;
SHashObj
*
dnodeHash
;
char
*
file
;
S
DnodeEps
*
dnodeEps
;
S
HashObj
*
dnodeHash
;
pthread_t
*
threadId
;
SDnodeEps
*
dnodeEps
;
SRWLatch
latch
;
pthread_t
*
threadId
;
S
TaosQueue
*
pMgmtQ
;
S
RWLatch
latch
;
S
WorkerPool
mgmtPool
;
S
DnodeWorker
mgmtWorker
;
}
SDnodeMgmt
;
}
SDnodeMgmt
;
typedef
struct
{
typedef
struct
{
...
...
source/dnode/mgmt/impl/inc/dnd
Dnode
.h
→
source/dnode/mgmt/impl/inc/dnd
Mgmt
.h
浏览文件 @
dc081e52
文件已移动
source/dnode/mgmt/impl/src/dndBnode.c
浏览文件 @
dc081e52
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "dndBnode.h"
#include "dndBnode.h"
#include "dnd
Dnode
.h"
#include "dnd
Mgmt
.h"
#include "dndTransport.h"
#include "dndTransport.h"
#include "dndWorker.h"
#include "dndWorker.h"
...
...
source/dnode/mgmt/impl/src/dnd
Dnode
.c
→
source/dnode/mgmt/impl/src/dnd
Mgmt
.c
浏览文件 @
dc081e52
...
@@ -14,28 +14,25 @@
...
@@ -14,28 +14,25 @@
*/
*/
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "dnd
Dnode
.h"
#include "dnd
Mgmt
.h"
#include "dndBnode.h"
#include "dndBnode.h"
#include "dndMnode.h"
#include "dndMnode.h"
#include "dndQnode.h"
#include "dndQnode.h"
#include "dndSnode.h"
#include "dndSnode.h"
#include "dndTransport.h"
#include "dndTransport.h"
#include "dndVnodes.h"
#include "dndVnodes.h"
#include "dndWorker.h"
static
int32_t
dndInitMgmtWorker
(
SDnode
*
pDnode
);
static
void
dndProcessMgmtQueue
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
);
static
void
dndCleanupMgmtWorker
(
SDnode
*
pDnode
);
static
int32_t
dndAllocMgmtQueue
(
SDnode
*
pDnode
);
static
void
dndFreeMgmtQueue
(
SDnode
*
pDnode
);
static
void
dndProcessMgmtQueue
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
);
static
int32_t
dndReadDnodes
(
SDnode
*
pDnode
);
static
int32_t
dndReadDnodes
(
SDnode
*
pDnode
);
static
int32_t
dndWriteDnodes
(
SDnode
*
pDnode
);
static
int32_t
dndWriteDnodes
(
SDnode
*
pDnode
);
static
void
*
dnodeThreadRoutine
(
void
*
param
);
static
void
*
dnodeThreadRoutine
(
void
*
param
);
static
int32_t
dndProcessConfigDnodeReq
(
SDnode
*
pDnode
,
SRpcMsg
*
p
Msg
);
static
int32_t
dndProcessConfigDnodeReq
(
SDnode
*
pDnode
,
SRpcMsg
*
p
Req
);
static
void
dndProcessStatusRsp
(
SDnode
*
pDnode
,
SRpcMsg
*
p
Msg
);
static
void
dndProcessStatusRsp
(
SDnode
*
pDnode
,
SRpcMsg
*
p
Rsp
);
static
void
dndProcessAuthRsp
(
SDnode
*
pDnode
,
SRpcMsg
*
p
Msg
);
static
void
dndProcessAuthRsp
(
SDnode
*
pDnode
,
SRpcMsg
*
p
Rsp
);
static
void
dndProcessGrantRsp
(
SDnode
*
pDnode
,
SRpcMsg
*
p
Msg
);
static
void
dndProcessGrantRsp
(
SDnode
*
pDnode
,
SRpcMsg
*
p
Rsp
);
int32_t
dndGetDnodeId
(
SDnode
*
pDnode
)
{
int32_t
dndGetDnodeId
(
SDnode
*
pDnode
)
{
SDnodeMgmt
*
pMgmt
=
&
pDnode
->
dmgmt
;
SDnodeMgmt
*
pMgmt
=
&
pDnode
->
dmgmt
;
...
@@ -80,13 +77,13 @@ void dndGetMnodeEpSet(SDnode *pDnode, SEpSet *pEpSet) {
...
@@ -80,13 +77,13 @@ void dndGetMnodeEpSet(SDnode *pDnode, SEpSet *pEpSet) {
taosRUnLockLatch
(
&
pMgmt
->
latch
);
taosRUnLockLatch
(
&
pMgmt
->
latch
);
}
}
void
dndSendRedirectRsp
(
SDnode
*
pDnode
,
SRpcMsg
*
p
Msg
)
{
void
dndSendRedirectRsp
(
SDnode
*
pDnode
,
SRpcMsg
*
p
Req
)
{
tmsg_t
msgType
=
p
Msg
->
msgType
;
tmsg_t
msgType
=
p
Req
->
msgType
;
SEpSet
epSet
=
{
0
};
SEpSet
epSet
=
{
0
};
dndGetMnodeEpSet
(
pDnode
,
&
epSet
);
dndGetMnodeEpSet
(
pDnode
,
&
epSet
);
dDebug
(
"RPC %p,
msg:%s is redirected, num:%d use:%d"
,
pMsg
->
handle
,
TMSG_INFO
(
msgType
),
epSet
.
numOfEps
,
epSet
.
inUse
);
dDebug
(
"RPC %p,
req:%s is redirected, num:%d use:%d"
,
pReq
->
handle
,
TMSG_INFO
(
msgType
),
epSet
.
numOfEps
,
epSet
.
inUse
);
for
(
int32_t
i
=
0
;
i
<
epSet
.
numOfEps
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
epSet
.
numOfEps
;
++
i
)
{
dDebug
(
"mnode index:%d %s:%u"
,
i
,
epSet
.
fqdn
[
i
],
epSet
.
port
[
i
]);
dDebug
(
"mnode index:%d %s:%u"
,
i
,
epSet
.
fqdn
[
i
],
epSet
.
port
[
i
]);
if
(
strcmp
(
epSet
.
fqdn
[
i
],
pDnode
->
opt
.
localFqdn
)
==
0
&&
epSet
.
port
[
i
]
==
pDnode
->
opt
.
serverPort
)
{
if
(
strcmp
(
epSet
.
fqdn
[
i
],
pDnode
->
opt
.
localFqdn
)
==
0
&&
epSet
.
port
[
i
]
==
pDnode
->
opt
.
serverPort
)
{
...
@@ -96,7 +93,7 @@ void dndSendRedirectRsp(SDnode *pDnode, SRpcMsg *pMsg) {
...
@@ -96,7 +93,7 @@ void dndSendRedirectRsp(SDnode *pDnode, SRpcMsg *pMsg) {
epSet
.
port
[
i
]
=
htons
(
epSet
.
port
[
i
]);
epSet
.
port
[
i
]
=
htons
(
epSet
.
port
[
i
]);
}
}
rpcSendRedirectRsp
(
p
Msg
->
handle
,
&
epSet
);
rpcSendRedirectRsp
(
p
Req
->
handle
,
&
epSet
);
}
}
static
void
dndUpdateMnodeEpSet
(
SDnode
*
pDnode
,
SEpSet
*
pEpSet
)
{
static
void
dndUpdateMnodeEpSet
(
SDnode
*
pDnode
,
SEpSet
*
pEpSet
)
{
...
@@ -350,14 +347,14 @@ static int32_t dndWriteDnodes(SDnode *pDnode) {
...
@@ -350,14 +347,14 @@ static int32_t dndWriteDnodes(SDnode *pDnode) {
terrno
=
0
;
terrno
=
0
;
pMgmt
->
updateTime
=
taosGetTimestampMs
();
pMgmt
->
updateTime
=
taosGetTimestampMs
();
d
Info
(
"successed to write %s"
,
pMgmt
->
file
);
d
Debug
(
"successed to write %s"
,
pMgmt
->
file
);
return
0
;
return
0
;
}
}
void
dndSendStatusReq
(
SDnode
*
pDnode
)
{
void
dndSendStatusReq
(
SDnode
*
pDnode
)
{
int32_t
contLen
=
sizeof
(
SStatus
Msg
)
+
TSDB_MAX_VNODES
*
sizeof
(
SVnodeLoad
);
int32_t
contLen
=
sizeof
(
SStatus
Req
)
+
TSDB_MAX_VNODES
*
sizeof
(
SVnodeLoad
);
SStatus
Msg
*
pStatus
=
rpcMallocCont
(
contLen
);
SStatus
Req
*
pStatus
=
rpcMallocCont
(
contLen
);
if
(
pStatus
==
NULL
)
{
if
(
pStatus
==
NULL
)
{
dError
(
"failed to malloc status message"
);
dError
(
"failed to malloc status message"
);
return
;
return
;
...
@@ -366,6 +363,7 @@ void dndSendStatusReq(SDnode *pDnode) {
...
@@ -366,6 +363,7 @@ void dndSendStatusReq(SDnode *pDnode) {
SDnodeMgmt
*
pMgmt
=
&
pDnode
->
dmgmt
;
SDnodeMgmt
*
pMgmt
=
&
pDnode
->
dmgmt
;
taosRLockLatch
(
&
pMgmt
->
latch
);
taosRLockLatch
(
&
pMgmt
->
latch
);
pStatus
->
sver
=
htonl
(
pDnode
->
opt
.
sver
);
pStatus
->
sver
=
htonl
(
pDnode
->
opt
.
sver
);
pStatus
->
dver
=
htobe64
(
pMgmt
->
dver
);
pStatus
->
dnodeId
=
htonl
(
pMgmt
->
dnodeId
);
pStatus
->
dnodeId
=
htonl
(
pMgmt
->
dnodeId
);
pStatus
->
clusterId
=
htobe64
(
pMgmt
->
clusterId
);
pStatus
->
clusterId
=
htobe64
(
pMgmt
->
clusterId
);
pStatus
->
rebootTime
=
htobe64
(
pMgmt
->
rebootTime
);
pStatus
->
rebootTime
=
htobe64
(
pMgmt
->
rebootTime
);
...
@@ -385,12 +383,12 @@ void dndSendStatusReq(SDnode *pDnode) {
...
@@ -385,12 +383,12 @@ void dndSendStatusReq(SDnode *pDnode) {
taosRUnLockLatch
(
&
pMgmt
->
latch
);
taosRUnLockLatch
(
&
pMgmt
->
latch
);
dndGetVnodeLoads
(
pDnode
,
&
pStatus
->
vnodeLoads
);
dndGetVnodeLoads
(
pDnode
,
&
pStatus
->
vnodeLoads
);
contLen
=
sizeof
(
SStatus
Msg
)
+
pStatus
->
vnodeLoads
.
num
*
sizeof
(
SVnodeLoad
);
contLen
=
sizeof
(
SStatus
Req
)
+
pStatus
->
vnodeLoads
.
num
*
sizeof
(
SVnodeLoad
);
SRpcMsg
rpcMsg
=
{.
pCont
=
pStatus
,
.
contLen
=
contLen
,
.
msgType
=
TDMT_MND_STATUS
,
.
ahandle
=
(
void
*
)
9527
};
SRpcMsg
rpcMsg
=
{.
pCont
=
pStatus
,
.
contLen
=
contLen
,
.
msgType
=
TDMT_MND_STATUS
,
.
ahandle
=
(
void
*
)
9527
};
pMgmt
->
statusSent
=
1
;
pMgmt
->
statusSent
=
1
;
dTrace
(
"pDnode:%p, send status
msg
to mnode"
,
pDnode
);
dTrace
(
"pDnode:%p, send status
req
to mnode"
,
pDnode
);
dndSendReqToMnode
(
pDnode
,
&
rpcMsg
);
dndSendReqToMnode
(
pDnode
,
&
rpcMsg
);
}
}
...
@@ -426,12 +424,12 @@ static void dndUpdateDnodeEps(SDnode *pDnode, SDnodeEps *pDnodeEps) {
...
@@ -426,12 +424,12 @@ static void dndUpdateDnodeEps(SDnode *pDnode, SDnodeEps *pDnodeEps) {
taosWUnLockLatch
(
&
pMgmt
->
latch
);
taosWUnLockLatch
(
&
pMgmt
->
latch
);
}
}
static
void
dndProcessStatusRsp
(
SDnode
*
pDnode
,
SRpcMsg
*
p
Msg
)
{
static
void
dndProcessStatusRsp
(
SDnode
*
pDnode
,
SRpcMsg
*
p
Rsp
)
{
SDnodeMgmt
*
pMgmt
=
&
pDnode
->
dmgmt
;
SDnodeMgmt
*
pMgmt
=
&
pDnode
->
dmgmt
;
if
(
p
Msg
->
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
p
Rsp
->
code
!=
TSDB_CODE_SUCCESS
)
{
pMgmt
->
statusSent
=
0
;
pMgmt
->
statusSent
=
0
;
if
(
p
Msg
->
code
==
TSDB_CODE_MND_DNODE_NOT_EXIST
&&
!
pMgmt
->
dropped
&&
pMgmt
->
dnodeId
>
0
)
{
if
(
p
Rsp
->
code
==
TSDB_CODE_MND_DNODE_NOT_EXIST
&&
!
pMgmt
->
dropped
&&
pMgmt
->
dnodeId
>
0
)
{
dInfo
(
"dnode:%d, set to dropped since not exist in mnode"
,
pMgmt
->
dnodeId
);
dInfo
(
"dnode:%d, set to dropped since not exist in mnode"
,
pMgmt
->
dnodeId
);
pMgmt
->
dropped
=
1
;
pMgmt
->
dropped
=
1
;
dndWriteDnodes
(
pDnode
);
dndWriteDnodes
(
pDnode
);
...
@@ -439,14 +437,16 @@ static void dndProcessStatusRsp(SDnode *pDnode, SRpcMsg *pMsg) {
...
@@ -439,14 +437,16 @@ static void dndProcessStatusRsp(SDnode *pDnode, SRpcMsg *pMsg) {
return
;
return
;
}
}
SStatusRsp
*
pRsp
=
pMsg
->
pCont
;
if
(
pRsp
->
pCont
!=
NULL
&&
pRsp
->
contLen
!=
0
)
{
if
(
pMsg
->
pCont
!=
NULL
&&
pMsg
->
contLen
!=
0
)
{
SStatusRsp
*
pStatus
=
pRsp
->
pCont
;
SDnodeCfg
*
pCfg
=
&
pRsp
->
dnodeCfg
;
pMgmt
->
dver
=
htobe64
(
pStatus
->
dver
);
SDnodeCfg
*
pCfg
=
&
pStatus
->
dnodeCfg
;
pCfg
->
dnodeId
=
htonl
(
pCfg
->
dnodeId
);
pCfg
->
dnodeId
=
htonl
(
pCfg
->
dnodeId
);
pCfg
->
clusterId
=
htobe64
(
pCfg
->
clusterId
);
pCfg
->
clusterId
=
htobe64
(
pCfg
->
clusterId
);
dndUpdateDnodeCfg
(
pDnode
,
pCfg
);
dndUpdateDnodeCfg
(
pDnode
,
pCfg
);
SDnodeEps
*
pDnodeEps
=
&
p
Rsp
->
dnodeEps
;
SDnodeEps
*
pDnodeEps
=
&
p
Status
->
dnodeEps
;
pDnodeEps
->
num
=
htonl
(
pDnodeEps
->
num
);
pDnodeEps
->
num
=
htonl
(
pDnodeEps
->
num
);
for
(
int32_t
i
=
0
;
i
<
pDnodeEps
->
num
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pDnodeEps
->
num
;
++
i
)
{
pDnodeEps
->
eps
[
i
].
id
=
htonl
(
pDnodeEps
->
eps
[
i
].
id
);
pDnodeEps
->
eps
[
i
].
id
=
htonl
(
pDnodeEps
->
eps
[
i
].
id
);
...
@@ -458,26 +458,27 @@ static void dndProcessStatusRsp(SDnode *pDnode, SRpcMsg *pMsg) {
...
@@ -458,26 +458,27 @@ static void dndProcessStatusRsp(SDnode *pDnode, SRpcMsg *pMsg) {
pMgmt
->
statusSent
=
0
;
pMgmt
->
statusSent
=
0
;
}
}
static
void
dndProcessAuthRsp
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
)
{
assert
(
1
);
}
static
void
dndProcessAuthRsp
(
SDnode
*
pDnode
,
SRpcMsg
*
pReq
)
{
dError
(
"auth rsp is received, but not supported yet"
);
}
static
void
dndProcessGrantRsp
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
)
{
assert
(
1
);
}
static
int32_t
dndProcessConfigDnodeReq
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
)
{
static
void
dndProcessGrantRsp
(
SDnode
*
pDnode
,
SRpcMsg
*
pReq
)
{
dError
(
"
config msg
is received, but not supported yet"
);
dError
(
"
grant rsp
is received, but not supported yet"
);
SCfgDnodeMsg
*
pCfg
=
pMsg
->
pCont
;
}
static
int32_t
dndProcessConfigDnodeReq
(
SDnode
*
pDnode
,
SRpcMsg
*
pReq
)
{
dError
(
"config req is received, but not supported yet"
);
SDCfgDnodeReq
*
pCfg
=
pReq
->
pCont
;
return
TSDB_CODE_OPS_NOT_SUPPORT
;
return
TSDB_CODE_OPS_NOT_SUPPORT
;
}
}
void
dndProcessStartupReq
(
SDnode
*
pDnode
,
SRpcMsg
*
p
Msg
)
{
void
dndProcessStartupReq
(
SDnode
*
pDnode
,
SRpcMsg
*
p
Req
)
{
dDebug
(
"startup
msg
is received"
);
dDebug
(
"startup
req
is received"
);
SStartupMsg
*
pStartup
=
rpcMallocCont
(
sizeof
(
SStartupMsg
));
SStartupMsg
*
pStartup
=
rpcMallocCont
(
sizeof
(
SStartupMsg
));
dndGetStartup
(
pDnode
,
pStartup
);
dndGetStartup
(
pDnode
,
pStartup
);
dDebug
(
"startup
msg
is sent, step:%s desc:%s finished:%d"
,
pStartup
->
name
,
pStartup
->
desc
,
pStartup
->
finished
);
dDebug
(
"startup
req
is sent, step:%s desc:%s finished:%d"
,
pStartup
->
name
,
pStartup
->
desc
,
pStartup
->
finished
);
SRpcMsg
rpcRsp
=
{.
handle
=
p
Msg
->
handle
,
.
pCont
=
pStartup
,
.
contLen
=
sizeof
(
SStartupMsg
)};
SRpcMsg
rpcRsp
=
{.
handle
=
p
Req
->
handle
,
.
pCont
=
pStartup
,
.
contLen
=
sizeof
(
SStartupMsg
)};
rpcSendResponse
(
&
rpcRsp
);
rpcSendResponse
(
&
rpcRsp
);
}
}
...
@@ -530,13 +531,8 @@ int32_t dndInitDnode(SDnode *pDnode) {
...
@@ -530,13 +531,8 @@ int32_t dndInitDnode(SDnode *pDnode) {
return
-
1
;
return
-
1
;
}
}
if
(
dndInitMgmtWorker
(
pDnode
)
!=
0
)
{
if
(
dndInitWorker
(
pDnode
,
&
pMgmt
->
mgmtWorker
,
DND_WORKER_SINGLE
,
"dnode-mgmt"
,
1
,
1
,
dndProcessMgmtQueue
)
!=
0
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
dError
(
"failed to start dnode mgmt worker since %s"
,
terrstr
());
return
-
1
;
}
if
(
dndAllocMgmtQueue
(
pDnode
)
!=
0
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
}
}
...
@@ -547,15 +543,14 @@ int32_t dndInitDnode(SDnode *pDnode) {
...
@@ -547,15 +543,14 @@ int32_t dndInitDnode(SDnode *pDnode) {
return
-
1
;
return
-
1
;
}
}
dInfo
(
"dnode-
dnode
is initialized"
);
dInfo
(
"dnode-
mgmt
is initialized"
);
return
0
;
return
0
;
}
}
void
dndCleanupDnode
(
SDnode
*
pDnode
)
{
void
dndCleanupDnode
(
SDnode
*
pDnode
)
{
SDnodeMgmt
*
pMgmt
=
&
pDnode
->
dmgmt
;
SDnodeMgmt
*
pMgmt
=
&
pDnode
->
dmgmt
;
dndCleanupMgmtWorker
(
pDnode
);
dndCleanupWorker
(
&
pMgmt
->
mgmtWorker
);
dndFreeMgmtQueue
(
pDnode
);
if
(
pMgmt
->
threadId
!=
NULL
)
{
if
(
pMgmt
->
threadId
!=
NULL
)
{
taosDestoryThread
(
pMgmt
->
threadId
);
taosDestoryThread
(
pMgmt
->
threadId
);
...
@@ -580,62 +575,22 @@ void dndCleanupDnode(SDnode *pDnode) {
...
@@ -580,62 +575,22 @@ void dndCleanupDnode(SDnode *pDnode) {
}
}
taosWUnLockLatch
(
&
pMgmt
->
latch
);
taosWUnLockLatch
(
&
pMgmt
->
latch
);
dInfo
(
"dnode-dnode is cleaned up"
);
dInfo
(
"dnode-mgmt is cleaned up"
);
}
static
int32_t
dndInitMgmtWorker
(
SDnode
*
pDnode
)
{
SDnodeMgmt
*
pMgmt
=
&
pDnode
->
dmgmt
;
SWorkerPool
*
pPool
=
&
pMgmt
->
mgmtPool
;
pPool
->
name
=
"dnode-mgmt"
;
pPool
->
min
=
1
;
pPool
->
max
=
1
;
if
(
tWorkerInit
(
pPool
)
!=
0
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
dDebug
(
"dnode mgmt worker is initialized"
);
return
0
;
}
}
static
void
dndCleanupMgmtWorker
(
SDnode
*
pDnode
)
{
void
dndProcessMgmtMsg
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
)
{
SDnodeMgmt
*
pMgmt
=
&
pDnode
->
dmgmt
;
SDnodeMgmt
*
pMgmt
=
&
pDnode
->
dmgmt
;
tWorkerCleanup
(
&
pMgmt
->
mgmtPool
);
dDebug
(
"dnode mgmt worker is closed"
);
}
static
int32_t
dndAllocMgmtQueue
(
SDnode
*
pDnode
)
{
SDnodeMgmt
*
pMgmt
=
&
pDnode
->
dmgmt
;
pMgmt
->
pMgmtQ
=
tWorkerAllocQueue
(
&
pMgmt
->
mgmtPool
,
pDnode
,
(
FProcessItem
)
dndProcessMgmtQueue
);
if
(
pMgmt
->
pMgmtQ
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
return
0
;
}
static
void
dndFreeMgmtQueue
(
SDnode
*
pDnode
)
{
SDnodeMgmt
*
pMgmt
=
&
pDnode
->
dmgmt
;
tWorkerFreeQueue
(
&
pMgmt
->
mgmtPool
,
pMgmt
->
pMgmtQ
);
pMgmt
->
pMgmtQ
=
NULL
;
}
void
dndProcessMgmtMsg
(
SDnode
*
pDnode
,
SRpcMsg
*
pRpcMsg
,
SEpSet
*
pEpSet
)
{
if
(
pEpSet
&&
pEpSet
->
numOfEps
>
0
&&
pMsg
->
msgType
==
TDMT_MND_STATUS_RSP
)
{
SDnodeMgmt
*
pMgmt
=
&
pDnode
->
dmgmt
;
if
(
pEpSet
&&
pEpSet
->
numOfEps
>
0
&&
pRpcMsg
->
msgType
==
TDMT_MND_STATUS_RSP
)
{
dndUpdateMnodeEpSet
(
pDnode
,
pEpSet
);
dndUpdateMnodeEpSet
(
pDnode
,
pEpSet
);
}
}
SRpcMsg
*
pMsg
=
taosAllocateQitem
(
sizeof
(
SRpcMsg
));
if
(
dndWriteMsgToWorker
(
&
pMgmt
->
mgmtWorker
,
pMsg
,
sizeof
(
SRpcMsg
))
!=
0
)
{
if
(
pMsg
!=
NULL
)
*
pMsg
=
*
pRpcMsg
;
if
(
pMsg
->
msgType
&
1u
)
{
SRpcMsg
rsp
=
{.
handle
=
pMsg
->
handle
,
.
code
=
TSDB_CODE_OUT_OF_MEMORY
};
if
(
pMsg
==
NULL
||
taosWriteQitem
(
pMgmt
->
pMgmtQ
,
pMsg
)
!=
0
)
{
if
(
pRpcMsg
->
msgType
&
1u
)
{
SRpcMsg
rsp
=
{.
handle
=
pRpcMsg
->
handle
,
.
code
=
TSDB_CODE_OUT_OF_MEMORY
};
rpcSendResponse
(
&
rsp
);
rpcSendResponse
(
&
rsp
);
}
}
rpcFreeCont
(
p
Rpc
Msg
->
pCont
);
rpcFreeCont
(
pMsg
->
pCont
);
taosFreeQitem
(
pMsg
);
taosFreeQitem
(
pMsg
);
}
}
}
}
...
@@ -704,7 +659,7 @@ static void dndProcessMgmtQueue(SDnode *pDnode, SRpcMsg *pMsg) {
...
@@ -704,7 +659,7 @@ static void dndProcessMgmtQueue(SDnode *pDnode, SRpcMsg *pMsg) {
default:
default:
terrno
=
TSDB_CODE_MSG_NOT_PROCESSED
;
terrno
=
TSDB_CODE_MSG_NOT_PROCESSED
;
code
=
-
1
;
code
=
-
1
;
dError
(
"RPC %p, dnode
req
:%s not processed"
,
pMsg
->
handle
,
TMSG_INFO
(
pMsg
->
msgType
));
dError
(
"RPC %p, dnode
msg
:%s not processed"
,
pMsg
->
handle
,
TMSG_INFO
(
pMsg
->
msgType
));
break
;
break
;
}
}
...
...
source/dnode/mgmt/impl/src/dndMnode.c
浏览文件 @
dc081e52
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "dndMnode.h"
#include "dndMnode.h"
#include "dnd
Dnode
.h"
#include "dnd
Mgmt
.h"
#include "dndTransport.h"
#include "dndTransport.h"
#include "dndWorker.h"
#include "dndWorker.h"
...
...
source/dnode/mgmt/impl/src/dndQnode.c
浏览文件 @
dc081e52
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "dndQnode.h"
#include "dndQnode.h"
#include "dnd
Dnode
.h"
#include "dnd
Mgmt
.h"
#include "dndTransport.h"
#include "dndTransport.h"
#include "dndWorker.h"
#include "dndWorker.h"
...
...
source/dnode/mgmt/impl/src/dndSnode.c
浏览文件 @
dc081e52
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "dndSnode.h"
#include "dndSnode.h"
#include "dnd
Dnode
.h"
#include "dnd
Mgmt
.h"
#include "dndTransport.h"
#include "dndTransport.h"
#include "dndWorker.h"
#include "dndWorker.h"
...
...
source/dnode/mgmt/impl/src/dndTransport.c
浏览文件 @
dc081e52
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "dndTransport.h"
#include "dndTransport.h"
#include "dnd
Dnode
.h"
#include "dnd
Mgmt
.h"
#include "dndMnode.h"
#include "dndMnode.h"
#include "dndVnodes.h"
#include "dndVnodes.h"
...
...
source/dnode/mgmt/impl/src/dndVnodes.c
浏览文件 @
dc081e52
...
@@ -388,7 +388,7 @@ static int32_t dndWriteVnodesToFile(SDnode *pDnode) {
...
@@ -388,7 +388,7 @@ static int32_t dndWriteVnodesToFile(SDnode *pDnode) {
free
(
pVnodes
);
free
(
pVnodes
);
}
}
d
Info
(
"successed to write %s"
,
file
);
d
Debug
(
"successed to write %s"
,
real
file
);
return
taosRenameFile
(
file
,
realfile
);
return
taosRenameFile
(
file
,
realfile
);
}
}
...
...
source/dnode/mgmt/impl/src/dndWorker.c
浏览文件 @
dc081e52
...
@@ -101,7 +101,9 @@ int32_t dndWriteMsgToWorker(SDnodeWorker *pWorker, void *pCont, int32_t contLen)
...
@@ -101,7 +101,9 @@ int32_t dndWriteMsgToWorker(SDnodeWorker *pWorker, void *pCont, int32_t contLen)
}
}
if
(
taosWriteQitem
(
pWorker
->
queue
,
pMsg
)
!=
0
)
{
if
(
taosWriteQitem
(
pWorker
->
queue
,
pMsg
)
!=
0
)
{
taosFreeQitem
(
pMsg
);
if
(
contLen
!=
0
)
{
taosFreeQitem
(
pMsg
);
}
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
}
}
...
...
source/dnode/mgmt/impl/src/dnode.c
浏览文件 @
dc081e52
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "dndBnode.h"
#include "dndBnode.h"
#include "dnd
Dnode
.h"
#include "dnd
Mgmt
.h"
#include "dndMnode.h"
#include "dndMnode.h"
#include "dndQnode.h"
#include "dndQnode.h"
#include "dndSnode.h"
#include "dndSnode.h"
...
...
source/dnode/mgmt/impl/test/CMakeLists.txt
浏览文件 @
dc081e52
...
@@ -3,18 +3,9 @@ enable_testing()
...
@@ -3,18 +3,9 @@ enable_testing()
add_subdirectory
(
qnode
)
add_subdirectory
(
qnode
)
add_subdirectory
(
bnode
)
add_subdirectory
(
bnode
)
add_subdirectory
(
snode
)
add_subdirectory
(
snode
)
# add_subdirectory(auth)
# add_subdirectory(balance)
add_subdirectory
(
db
)
add_subdirectory
(
dnode
)
# add_subdirectory(func)
add_subdirectory
(
mnode
)
add_subdirectory
(
mnode
)
add_subdirectory
(
profile
)
add_subdirectory
(
db
)
add_subdirectory
(
stb
)
add_subdirectory
(
stb
)
# add_subdirectory(sync)
# add_subdirectory(telem)
# add_subdirectory(trans)
add_subdirectory
(
vgroup
)
add_subdirectory
(
vgroup
)
add_subdirectory
(
sut
)
add_subdirectory
(
sut
)
source/dnode/mgmt/impl/test/mnode/CMakeLists.txt
浏览文件 @
dc081e52
aux_source_directory
(
. MTEST_SRC
)
aux_source_directory
(
.
D
MTEST_SRC
)
add_executable
(
dnode_test_mnode
${
MTEST_SRC
}
)
add_executable
(
dnode_test_mnode
${
D
MTEST_SRC
}
)
target_link_libraries
(
target_link_libraries
(
dnode_test_mnode
dnode_test_mnode
PUBLIC sut
PUBLIC sut
...
...
source/dnode/mgmt/impl/test/mnode/qmnode.cpp
0 → 100644
浏览文件 @
dc081e52
/**
* @file dmnode.cpp
* @author slguan (slguan@taosdata.com)
* @brief DNODE module mnode tests
* @version 1.0
* @date 2022-01-07
*
* @copyright Copyright (c) 2022
*
*/
#include "sut.h"
class
DndTestMnode
:
public
::
testing
::
Test
{
protected:
static
void
SetUpTestSuite
()
{
test
.
Init
(
"/tmp/dnode_test_mnode"
,
9113
);
}
static
void
TearDownTestSuite
()
{
test
.
Cleanup
();
}
static
Testbase
test
;
public:
void
SetUp
()
override
{}
void
TearDown
()
override
{}
};
Testbase
DndTestMnode
::
test
;
source/dnode/mnode/impl/src/mndConsumer.c
浏览文件 @
dc081e52
...
@@ -127,8 +127,8 @@ static SSdbRow *mndConsumerActionDecode(SSdbRaw *pRaw) {
...
@@ -127,8 +127,8 @@ static SSdbRow *mndConsumerActionDecode(SSdbRaw *pRaw) {
goto
CONSUME_DECODE_OVER
;
goto
CONSUME_DECODE_OVER
;
}
}
int32_t
size
=
sizeof
(
SMqConsumerObj
);
int32_t
size
=
sizeof
(
SMqConsumerObj
);
SSdbRow
*
pRow
=
sdbAllocRow
(
size
);
SSdbRow
*
pRow
=
sdbAllocRow
(
size
);
if
(
pRow
==
NULL
)
goto
CONSUME_DECODE_OVER
;
if
(
pRow
==
NULL
)
goto
CONSUME_DECODE_OVER
;
SMqConsumerObj
*
pConsumer
=
sdbGetRowObj
(
pRow
);
SMqConsumerObj
*
pConsumer
=
sdbGetRowObj
(
pRow
);
...
@@ -155,7 +155,6 @@ static SSdbRow *mndConsumerActionDecode(SSdbRaw *pRaw) {
...
@@ -155,7 +155,6 @@ static SSdbRow *mndConsumerActionDecode(SSdbRaw *pRaw) {
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
vgSize
,
CONSUME_DECODE_OVER
);
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
vgSize
,
CONSUME_DECODE_OVER
);
}
}
CONSUME_DECODE_OVER:
CONSUME_DECODE_OVER:
if
(
terrno
!=
0
)
{
if
(
terrno
!=
0
)
{
mError
(
"consumer:%ld, failed to decode from raw:%p since %s"
,
pConsumer
->
consumerId
,
pRaw
,
terrstr
());
mError
(
"consumer:%ld, failed to decode from raw:%p since %s"
,
pConsumer
->
consumerId
,
pRaw
,
terrstr
());
...
@@ -209,6 +208,7 @@ static int32_t mndProcessSubscribeReq(SMnodeMsg *pMsg) {
...
@@ -209,6 +208,7 @@ static int32_t mndProcessSubscribeReq(SMnodeMsg *pMsg) {
tDeserializeSCMSubscribeReq
(
msgStr
,
pSubscribe
);
tDeserializeSCMSubscribeReq
(
msgStr
,
pSubscribe
);
int64_t
consumerId
=
pSubscribe
->
consumerId
;
int64_t
consumerId
=
pSubscribe
->
consumerId
;
char
*
consumerGroup
=
pSubscribe
->
consumerGroup
;
char
*
consumerGroup
=
pSubscribe
->
consumerGroup
;
int32_t
cgroupLen
=
strlen
(
consumerGroup
);
SArray
*
newSub
=
NULL
;
SArray
*
newSub
=
NULL
;
int
newTopicNum
=
pSubscribe
->
topicNum
;
int
newTopicNum
=
pSubscribe
->
topicNum
;
...
@@ -216,13 +216,14 @@ static int32_t mndProcessSubscribeReq(SMnodeMsg *pMsg) {
...
@@ -216,13 +216,14 @@ static int32_t mndProcessSubscribeReq(SMnodeMsg *pMsg) {
newSub
=
taosArrayInit
(
newTopicNum
,
sizeof
(
SMqConsumerTopic
));
newSub
=
taosArrayInit
(
newTopicNum
,
sizeof
(
SMqConsumerTopic
));
}
}
for
(
int
i
=
0
;
i
<
newTopicNum
;
i
++
)
{
for
(
int
i
=
0
;
i
<
newTopicNum
;
i
++
)
{
char
*
topic
=
pSubscribe
->
topicName
[
i
]
;
char
*
newTopicName
=
taosArrayGetP
(
newSub
,
i
)
;
SMqConsumerTopic
*
pConsumerTopic
=
malloc
(
sizeof
(
SMqConsumerTopic
));
SMqConsumerTopic
*
pConsumerTopic
=
malloc
(
sizeof
(
SMqConsumerTopic
));
if
(
pConsumerTopic
==
NULL
)
{
if
(
pConsumerTopic
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
// TODO: free
// TODO: free
return
-
1
;
return
-
1
;
}
}
strcpy
(
pConsumerTopic
->
name
,
newTopicName
);
pConsumerTopic
->
vgroups
=
tdListNew
(
sizeof
(
int64_t
));
pConsumerTopic
->
vgroups
=
tdListNew
(
sizeof
(
int64_t
));
taosArrayPush
(
newSub
,
pConsumerTopic
);
taosArrayPush
(
newSub
,
pConsumerTopic
);
free
(
pConsumerTopic
);
free
(
pConsumerTopic
);
...
@@ -239,7 +240,8 @@ static int32_t mndProcessSubscribeReq(SMnodeMsg *pMsg) {
...
@@ -239,7 +240,8 @@ static int32_t mndProcessSubscribeReq(SMnodeMsg *pMsg) {
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
}
}
strcpy
(
pConsumer
->
cgroup
,
pSubscribe
->
consumerGroup
);
pConsumer
->
consumerId
=
consumerId
;
strcpy
(
pConsumer
->
cgroup
,
consumerGroup
);
}
else
{
}
else
{
oldSub
=
pConsumer
->
topics
;
oldSub
=
pConsumer
->
topics
;
...
@@ -260,6 +262,7 @@ static int32_t mndProcessSubscribeReq(SMnodeMsg *pMsg) {
...
@@ -260,6 +262,7 @@ static int32_t mndProcessSubscribeReq(SMnodeMsg *pMsg) {
j
++
;
j
++
;
}
else
if
(
j
>=
oldTopicNum
)
{
}
else
if
(
j
>=
oldTopicNum
)
{
pNewTopic
=
taosArrayGet
(
newSub
,
i
);
pNewTopic
=
taosArrayGet
(
newSub
,
i
);
i
++
;
}
else
{
}
else
{
pNewTopic
=
taosArrayGet
(
newSub
,
i
);
pNewTopic
=
taosArrayGet
(
newSub
,
i
);
pOldTopic
=
taosArrayGet
(
oldSub
,
j
);
pOldTopic
=
taosArrayGet
(
oldSub
,
j
);
...
@@ -292,7 +295,7 @@ static int32_t mndProcessSubscribeReq(SMnodeMsg *pMsg) {
...
@@ -292,7 +295,7 @@ static int32_t mndProcessSubscribeReq(SMnodeMsg *pMsg) {
SMqTopicObj
*
pTopic
=
mndAcquireTopic
(
pMnode
,
oldTopicName
);
SMqTopicObj
*
pTopic
=
mndAcquireTopic
(
pMnode
,
oldTopicName
);
ASSERT
(
pTopic
!=
NULL
);
ASSERT
(
pTopic
!=
NULL
);
SMqCGroup
*
pGroup
=
taosHashGet
(
pTopic
->
cgroups
,
pSubscribe
->
consumerGroup
,
strlen
(
pSubscribe
->
consumerGroup
)
);
SMqCGroup
*
pGroup
=
taosHashGet
(
pTopic
->
cgroups
,
consumerGroup
,
cgroupLen
);
while
((
pn
=
tdListNext
(
&
iter
))
!=
NULL
)
{
while
((
pn
=
tdListNext
(
&
iter
))
!=
NULL
)
{
int32_t
vgId
=
*
(
int64_t
*
)
pn
->
data
;
int32_t
vgId
=
*
(
int64_t
*
)
pn
->
data
;
SVgObj
*
pVgObj
=
mndAcquireVgroup
(
pMnode
,
vgId
);
SVgObj
*
pVgObj
=
mndAcquireVgroup
(
pMnode
,
vgId
);
...
@@ -302,8 +305,7 @@ static int32_t mndProcessSubscribeReq(SMnodeMsg *pMsg) {
...
@@ -302,8 +305,7 @@ static int32_t mndProcessSubscribeReq(SMnodeMsg *pMsg) {
continue
;
continue
;
}
}
// acquire and get epset
// acquire and get epset
void
*
pMqVgSetReq
=
void
*
pMqVgSetReq
=
mndBuildMqVGroupSetReq
(
pMnode
,
oldTopicName
,
vgId
,
consumerId
,
consumerGroup
);
mndBuildMqVGroupSetReq
(
pMnode
,
oldTopicName
,
vgId
,
pSubscribe
->
consumerId
,
pSubscribe
->
consumerGroup
);
// TODO:serialize
// TODO:serialize
if
(
pMsg
==
NULL
)
{
if
(
pMsg
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
...
@@ -321,7 +323,8 @@ static int32_t mndProcessSubscribeReq(SMnodeMsg *pMsg) {
...
@@ -321,7 +323,8 @@ static int32_t mndProcessSubscribeReq(SMnodeMsg *pMsg) {
return
-
1
;
return
-
1
;
}
}
}
}
taosHashRemove
(
pTopic
->
cgroups
,
pSubscribe
->
consumerGroup
,
strlen
(
pSubscribe
->
consumerGroup
));
taosHashRemove
(
pTopic
->
cgroups
,
consumerGroup
,
cgroupLen
);
mndReleaseTopic
(
pMnode
,
pTopic
);
}
else
if
(
pNewTopic
!=
NULL
)
{
}
else
if
(
pNewTopic
!=
NULL
)
{
ASSERT
(
pOldTopic
==
NULL
);
ASSERT
(
pOldTopic
==
NULL
);
...
@@ -330,7 +333,7 @@ static int32_t mndProcessSubscribeReq(SMnodeMsg *pMsg) {
...
@@ -330,7 +333,7 @@ static int32_t mndProcessSubscribeReq(SMnodeMsg *pMsg) {
SMqTopicObj
*
pTopic
=
mndAcquireTopic
(
pMnode
,
newTopicName
);
SMqTopicObj
*
pTopic
=
mndAcquireTopic
(
pMnode
,
newTopicName
);
ASSERT
(
pTopic
!=
NULL
);
ASSERT
(
pTopic
!=
NULL
);
SMqCGroup
*
pGroup
=
taosHashGet
(
pTopic
->
cgroups
,
pSubscribe
->
consumerGroup
,
strlen
(
pSubscribe
->
consumerGroup
)
);
SMqCGroup
*
pGroup
=
taosHashGet
(
pTopic
->
cgroups
,
consumerGroup
,
cgroupLen
);
if
(
pGroup
==
NULL
)
{
if
(
pGroup
==
NULL
)
{
// add new group
// add new group
pGroup
=
malloc
(
sizeof
(
SMqCGroup
));
pGroup
=
malloc
(
sizeof
(
SMqCGroup
));
...
@@ -346,18 +349,20 @@ static int32_t mndProcessSubscribeReq(SMnodeMsg *pMsg) {
...
@@ -346,18 +349,20 @@ static int32_t mndProcessSubscribeReq(SMnodeMsg *pMsg) {
}
}
pGroup
->
status
=
0
;
pGroup
->
status
=
0
;
// add into cgroups
// add into cgroups
taosHashPut
(
pTopic
->
cgroups
,
pSubscribe
->
consumerGroup
,
strlen
(
pSubscribe
->
consumerGroup
),
pGroup
,
taosHashPut
(
pTopic
->
cgroups
,
consumerGroup
,
cgroupLen
,
pGroup
,
sizeof
(
SMqCGroup
));
sizeof
(
SMqCGroup
));
}
}
// put the consumer into list
// put the consumer into list
// rebalance will be triggered by timer
// rebalance will be triggered by timer
tdListAppend
(
pGroup
->
consumerIds
,
&
pSubscribe
->
consumerId
);
tdListAppend
(
pGroup
->
consumerIds
,
&
consumerId
);
SSdbRaw
*
pTopicRaw
=
mndTopicActionEncode
(
pTopic
);
SSdbRaw
*
pTopicRaw
=
mndTopicActionEncode
(
pTopic
);
sdbSetRawStatus
(
pTopicRaw
,
SDB_STATUS_READY
);
sdbSetRawStatus
(
pTopicRaw
,
SDB_STATUS_READY
);
// TODO: error handling
// TODO: error handling
mndTransAppendRedolog
(
pTrans
,
pTopicRaw
);
mndTransAppendRedolog
(
pTrans
,
pTopicRaw
);
mndReleaseTopic
(
pMnode
,
pTopic
);
}
else
{
}
else
{
ASSERT
(
0
);
ASSERT
(
0
);
}
}
...
@@ -376,11 +381,13 @@ static int32_t mndProcessSubscribeReq(SMnodeMsg *pMsg) {
...
@@ -376,11 +381,13 @@ static int32_t mndProcessSubscribeReq(SMnodeMsg *pMsg) {
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
{
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
{
mError
(
"trans:%d, failed to prepare since %s"
,
pTrans
->
id
,
terrstr
());
mError
(
"trans:%d, failed to prepare since %s"
,
pTrans
->
id
,
terrstr
());
mndTransDrop
(
pTrans
);
mndTransDrop
(
pTrans
);
mndReleaseConsumer
(
pMnode
,
pConsumer
);
return
-
1
;
return
-
1
;
}
}
// TODO: free memory
// TODO: free memory
mndTransDrop
(
pTrans
);
mndTransDrop
(
pTrans
);
mndReleaseConsumer
(
pMnode
,
pConsumer
);
return
0
;
return
0
;
}
}
...
...
source/dnode/mnode/impl/src/mndDnode.c
浏览文件 @
dc081e52
...
@@ -45,19 +45,19 @@ static SSdbRaw *mndDnodeActionEncode(SDnodeObj *pDnode);
...
@@ -45,19 +45,19 @@ static SSdbRaw *mndDnodeActionEncode(SDnodeObj *pDnode);
static
SSdbRow
*
mndDnodeActionDecode
(
SSdbRaw
*
pRaw
);
static
SSdbRow
*
mndDnodeActionDecode
(
SSdbRaw
*
pRaw
);
static
int32_t
mndDnodeActionInsert
(
SSdb
*
pSdb
,
SDnodeObj
*
pDnode
);
static
int32_t
mndDnodeActionInsert
(
SSdb
*
pSdb
,
SDnodeObj
*
pDnode
);
static
int32_t
mndDnodeActionDelete
(
SSdb
*
pSdb
,
SDnodeObj
*
pDnode
);
static
int32_t
mndDnodeActionDelete
(
SSdb
*
pSdb
,
SDnodeObj
*
pDnode
);
static
int32_t
mndDnodeActionUpdate
(
SSdb
*
pSdb
,
SDnodeObj
*
pOld
Dnode
,
SDnodeObj
*
pNewDnode
);
static
int32_t
mndDnodeActionUpdate
(
SSdb
*
pSdb
,
SDnodeObj
*
pOld
,
SDnodeObj
*
pNew
);
static
int32_t
mndProcessCreateDnode
Msg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessCreateDnode
Req
(
SMnodeMsg
*
pReq
);
static
int32_t
mndProcessDropDnode
Msg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessDropDnode
Req
(
SMnodeMsg
*
pReq
);
static
int32_t
mndProcessConfigDnode
Msg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessConfigDnode
Req
(
SMnodeMsg
*
pReq
);
static
int32_t
mndProcessConfigDnodeRsp
(
SMnodeMsg
*
p
Msg
);
static
int32_t
mndProcessConfigDnodeRsp
(
SMnodeMsg
*
p
Rsp
);
static
int32_t
mndProcessStatus
Msg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessStatus
Req
(
SMnodeMsg
*
pReq
);
static
int32_t
mndGetConfigMeta
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
);
static
int32_t
mndGetConfigMeta
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
);
static
int32_t
mndRetrieveConfigs
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
int32_t
mndRetrieveConfigs
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
void
mndCancelGetNextConfig
(
SMnode
*
pMnode
,
void
*
pIter
);
static
void
mndCancelGetNextConfig
(
SMnode
*
pMnode
,
void
*
pIter
);
static
int32_t
mndGetDnodeMeta
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
);
static
int32_t
mndGetDnodeMeta
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
);
static
int32_t
mndRetrieveDnodes
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
int32_t
mndRetrieveDnodes
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
void
mndCancelGetNextDnode
(
SMnode
*
pMnode
,
void
*
pIter
);
static
void
mndCancelGetNextDnode
(
SMnode
*
pMnode
,
void
*
pIter
);
int32_t
mndInitDnode
(
SMnode
*
pMnode
)
{
int32_t
mndInitDnode
(
SMnode
*
pMnode
)
{
...
@@ -70,11 +70,11 @@ int32_t mndInitDnode(SMnode *pMnode) {
...
@@ -70,11 +70,11 @@ int32_t mndInitDnode(SMnode *pMnode) {
.
updateFp
=
(
SdbUpdateFp
)
mndDnodeActionUpdate
,
.
updateFp
=
(
SdbUpdateFp
)
mndDnodeActionUpdate
,
.
deleteFp
=
(
SdbDeleteFp
)
mndDnodeActionDelete
};
.
deleteFp
=
(
SdbDeleteFp
)
mndDnodeActionDelete
};
mndSetMsgHandle
(
pMnode
,
TDMT_MND_CREATE_DNODE
,
mndProcessCreateDnode
Msg
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_CREATE_DNODE
,
mndProcessCreateDnode
Req
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_DROP_DNODE
,
mndProcessDropDnode
Msg
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_DROP_DNODE
,
mndProcessDropDnode
Req
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_CONFIG_DNODE
,
mndProcessConfigDnode
Msg
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_CONFIG_DNODE
,
mndProcessConfigDnode
Req
);
mndSetMsgHandle
(
pMnode
,
TDMT_DND_CONFIG_DNODE_RSP
,
mndProcessConfigDnodeRsp
);
mndSetMsgHandle
(
pMnode
,
TDMT_DND_CONFIG_DNODE_RSP
,
mndProcessConfigDnodeRsp
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_STATUS
,
mndProcessStatus
Msg
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_STATUS
,
mndProcessStatus
Req
);
mndAddShowMetaHandle
(
pMnode
,
TSDB_MGMT_TABLE_VARIABLES
,
mndGetConfigMeta
);
mndAddShowMetaHandle
(
pMnode
,
TSDB_MGMT_TABLE_VARIABLES
,
mndGetConfigMeta
);
mndAddShowRetrieveHandle
(
pMnode
,
TSDB_MGMT_TABLE_VARIABLES
,
mndRetrieveConfigs
);
mndAddShowRetrieveHandle
(
pMnode
,
TSDB_MGMT_TABLE_VARIABLES
,
mndRetrieveConfigs
);
...
@@ -182,9 +182,9 @@ static int32_t mndDnodeActionDelete(SSdb *pSdb, SDnodeObj *pDnode) {
...
@@ -182,9 +182,9 @@ static int32_t mndDnodeActionDelete(SSdb *pSdb, SDnodeObj *pDnode) {
return
0
;
return
0
;
}
}
static
int32_t
mndDnodeActionUpdate
(
SSdb
*
pSdb
,
SDnodeObj
*
pOld
Dnode
,
SDnodeObj
*
pNewDnode
)
{
static
int32_t
mndDnodeActionUpdate
(
SSdb
*
pSdb
,
SDnodeObj
*
pOld
,
SDnodeObj
*
pNew
)
{
mTrace
(
"dnode:%d, perform update action, old_row:%p new_row:%p"
,
pOld
Dnode
->
id
,
pOldDnode
,
pNewDnode
);
mTrace
(
"dnode:%d, perform update action, old_row:%p new_row:%p"
,
pOld
->
id
,
pOld
,
pNew
);
pOld
Dnode
->
updateTime
=
pNewDnode
->
updateTime
;
pOld
->
updateTime
=
pNew
->
updateTime
;
return
0
;
return
0
;
}
}
...
@@ -244,22 +244,22 @@ bool mndIsDnodeOnline(SMnode *pMnode, SDnodeObj *pDnode, int64_t curMs) {
...
@@ -244,22 +244,22 @@ bool mndIsDnodeOnline(SMnode *pMnode, SDnodeObj *pDnode, int64_t curMs) {
return
true
;
return
true
;
}
}
static
void
mndGetDnodeData
(
SMnode
*
pMnode
,
SDnodeEps
*
pEps
,
int32_t
numOf
Eps
)
{
static
void
mndGetDnodeData
(
SMnode
*
pMnode
,
SDnodeEps
*
pEps
,
int32_t
max
Eps
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
i
=
0
;
int32_t
numOfEps
=
0
;
void
*
pIter
=
NULL
;
void
*
pIter
=
NULL
;
while
(
1
)
{
while
(
1
)
{
SDnodeObj
*
pDnode
=
NULL
;
SDnodeObj
*
pDnode
=
NULL
;
pIter
=
sdbFetch
(
pSdb
,
SDB_DNODE
,
pIter
,
(
void
**
)
&
pDnode
);
pIter
=
sdbFetch
(
pSdb
,
SDB_DNODE
,
pIter
,
(
void
**
)
&
pDnode
);
if
(
pIter
==
NULL
)
break
;
if
(
pIter
==
NULL
)
break
;
if
(
i
>=
numOf
Eps
)
{
if
(
numOfEps
>=
max
Eps
)
{
sdbCancelFetch
(
pSdb
,
pIter
);
sdbCancelFetch
(
pSdb
,
pIter
);
sdbRelease
(
pSdb
,
pDnode
);
sdbRelease
(
pSdb
,
pDnode
);
break
;
break
;
}
}
SDnodeEp
*
pEp
=
&
pEps
->
eps
[
i
];
SDnodeEp
*
pEp
=
&
pEps
->
eps
[
numOfEps
];
pEp
->
id
=
htonl
(
pDnode
->
id
);
pEp
->
id
=
htonl
(
pDnode
->
id
);
pEp
->
port
=
htons
(
pDnode
->
port
);
pEp
->
port
=
htons
(
pDnode
->
port
);
memcpy
(
pEp
->
fqdn
,
pDnode
->
fqdn
,
TSDB_FQDN_LEN
);
memcpy
(
pEp
->
fqdn
,
pDnode
->
fqdn
,
TSDB_FQDN_LEN
);
...
@@ -267,11 +267,11 @@ static void mndGetDnodeData(SMnode *pMnode, SDnodeEps *pEps, int32_t numOfEps) {
...
@@ -267,11 +267,11 @@ static void mndGetDnodeData(SMnode *pMnode, SDnodeEps *pEps, int32_t numOfEps) {
if
(
mndIsMnode
(
pMnode
,
pDnode
->
id
))
{
if
(
mndIsMnode
(
pMnode
,
pDnode
->
id
))
{
pEp
->
isMnode
=
1
;
pEp
->
isMnode
=
1
;
}
}
i
++
;
numOfEps
++
;
sdbRelease
(
pSdb
,
pDnode
);
sdbRelease
(
pSdb
,
pDnode
);
}
}
pEps
->
num
=
htonl
(
i
);
pEps
->
num
=
htonl
(
numOfEps
);
}
}
static
int32_t
mndCheckClusterCfgPara
(
SMnode
*
pMnode
,
const
SClusterCfg
*
pCfg
)
{
static
int32_t
mndCheckClusterCfgPara
(
SMnode
*
pMnode
,
const
SClusterCfg
*
pCfg
)
{
...
@@ -299,8 +299,9 @@ static int32_t mndCheckClusterCfgPara(SMnode *pMnode, const SClusterCfg *pCfg) {
...
@@ -299,8 +299,9 @@ static int32_t mndCheckClusterCfgPara(SMnode *pMnode, const SClusterCfg *pCfg) {
return
0
;
return
0
;
}
}
static
void
mndParseStatusMsg
(
SStatus
Msg
*
pStatus
)
{
static
void
mndParseStatusMsg
(
SStatus
Req
*
pStatus
)
{
pStatus
->
sver
=
htonl
(
pStatus
->
sver
);
pStatus
->
sver
=
htonl
(
pStatus
->
sver
);
pStatus
->
dver
=
htobe64
(
pStatus
->
dver
);
pStatus
->
dnodeId
=
htonl
(
pStatus
->
dnodeId
);
pStatus
->
dnodeId
=
htonl
(
pStatus
->
dnodeId
);
pStatus
->
clusterId
=
htobe64
(
pStatus
->
clusterId
);
pStatus
->
clusterId
=
htobe64
(
pStatus
->
clusterId
);
pStatus
->
rebootTime
=
htobe64
(
pStatus
->
rebootTime
);
pStatus
->
rebootTime
=
htobe64
(
pStatus
->
rebootTime
);
...
@@ -309,11 +310,19 @@ static void mndParseStatusMsg(SStatusMsg *pStatus) {
...
@@ -309,11 +310,19 @@ static void mndParseStatusMsg(SStatusMsg *pStatus) {
pStatus
->
numOfSupportVnodes
=
htonl
(
pStatus
->
numOfSupportVnodes
);
pStatus
->
numOfSupportVnodes
=
htonl
(
pStatus
->
numOfSupportVnodes
);
pStatus
->
clusterCfg
.
statusInterval
=
htonl
(
pStatus
->
clusterCfg
.
statusInterval
);
pStatus
->
clusterCfg
.
statusInterval
=
htonl
(
pStatus
->
clusterCfg
.
statusInterval
);
pStatus
->
clusterCfg
.
checkTime
=
htobe64
(
pStatus
->
clusterCfg
.
checkTime
);
pStatus
->
clusterCfg
.
checkTime
=
htobe64
(
pStatus
->
clusterCfg
.
checkTime
);
for
(
int32_t
v
=
0
;
v
<
pStatus
->
vnodeLoads
.
num
;
++
v
)
{
SVnodeLoad
*
pVload
=
&
pStatus
->
vnodeLoads
.
data
[
v
];
pVload
->
vgId
=
htonl
(
pVload
->
vgId
);
pVload
->
totalStorage
=
htobe64
(
pVload
->
totalStorage
);
pVload
->
compStorage
=
htobe64
(
pVload
->
compStorage
);
pVload
->
pointsWritten
=
htobe64
(
pVload
->
pointsWritten
);
pVload
->
tablesNum
=
htobe64
(
pVload
->
tablesNum
);
}
}
}
static
int32_t
mndProcessStatus
Msg
(
SMnodeMsg
*
pMsg
)
{
static
int32_t
mndProcessStatus
Req
(
SMnodeMsg
*
pReq
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SStatus
Msg
*
pStatus
=
pMsg
->
rpcMsg
.
pCont
;
SStatus
Req
*
pStatus
=
pReq
->
rpcMsg
.
pCont
;
SDnodeObj
*
pDnode
=
NULL
;
SDnodeObj
*
pDnode
=
NULL
;
int32_t
code
=
-
1
;
int32_t
code
=
-
1
;
...
@@ -341,9 +350,11 @@ static int32_t mndProcessStatusMsg(SMnodeMsg *pMsg) {
...
@@ -341,9 +350,11 @@ static int32_t mndProcessStatusMsg(SMnodeMsg *pMsg) {
int64_t
curMs
=
taosGetTimestampMs
();
int64_t
curMs
=
taosGetTimestampMs
();
bool
online
=
mndIsDnodeOnline
(
pMnode
,
pDnode
,
curMs
);
bool
online
=
mndIsDnodeOnline
(
pMnode
,
pDnode
,
curMs
);
bool
needCheckCfg
=
!
(
online
&&
pDnode
->
rebootTime
==
pStatus
->
rebootTime
);
bool
dnodeChanged
=
(
pStatus
->
dver
!=
sdbGetTableVer
(
pMnode
->
pSdb
,
SDB_DNODE
));
bool
reboot
=
(
pDnode
->
rebootTime
!=
pStatus
->
rebootTime
);
bool
needCheck
=
!
online
||
dnodeChanged
||
reboot
;
if
(
needCheck
Cfg
)
{
if
(
needCheck
)
{
if
(
pStatus
->
sver
!=
pMnode
->
cfg
.
sver
)
{
if
(
pStatus
->
sver
!=
pMnode
->
cfg
.
sver
)
{
if
(
pDnode
!=
NULL
)
{
if
(
pDnode
!=
NULL
)
{
pDnode
->
offlineReason
=
DND_REASON_VERSION_NOT_MATCH
;
pDnode
->
offlineReason
=
DND_REASON_VERSION_NOT_MATCH
;
...
@@ -379,7 +390,11 @@ static int32_t mndProcessStatusMsg(SMnodeMsg *pMsg) {
...
@@ -379,7 +390,11 @@ static int32_t mndProcessStatusMsg(SMnodeMsg *pMsg) {
goto
PROCESS_STATUS_MSG_OVER
;
goto
PROCESS_STATUS_MSG_OVER
;
}
}
mInfo
(
"dnode:%d, from offline to online"
,
pDnode
->
id
);
if
(
!
online
)
{
mInfo
(
"dnode:%d, from offline to online"
,
pDnode
->
id
);
}
else
{
mDebug
(
"dnode:%d, send dnode eps"
,
pDnode
->
id
);
}
pDnode
->
rebootTime
=
pStatus
->
rebootTime
;
pDnode
->
rebootTime
=
pStatus
->
rebootTime
;
pDnode
->
numOfCores
=
pStatus
->
numOfCores
;
pDnode
->
numOfCores
=
pStatus
->
numOfCores
;
...
@@ -393,12 +408,13 @@ static int32_t mndProcessStatusMsg(SMnodeMsg *pMsg) {
...
@@ -393,12 +408,13 @@ static int32_t mndProcessStatusMsg(SMnodeMsg *pMsg) {
goto
PROCESS_STATUS_MSG_OVER
;
goto
PROCESS_STATUS_MSG_OVER
;
}
}
pRsp
->
dver
=
htobe64
(
sdbGetTableVer
(
pMnode
->
pSdb
,
SDB_DNODE
));
pRsp
->
dnodeCfg
.
dnodeId
=
htonl
(
pDnode
->
id
);
pRsp
->
dnodeCfg
.
dnodeId
=
htonl
(
pDnode
->
id
);
pRsp
->
dnodeCfg
.
clusterId
=
htobe64
(
pMnode
->
clusterId
);
pRsp
->
dnodeCfg
.
clusterId
=
htobe64
(
pMnode
->
clusterId
);
mndGetDnodeData
(
pMnode
,
&
pRsp
->
dnodeEps
,
numOfEps
);
mndGetDnodeData
(
pMnode
,
&
pRsp
->
dnodeEps
,
numOfEps
);
p
Msg
->
contLen
=
contLen
;
p
Req
->
contLen
=
contLen
;
p
Msg
->
pCont
=
pRsp
;
p
Req
->
pCont
=
pRsp
;
}
}
pDnode
->
lastAccessTime
=
curMs
;
pDnode
->
lastAccessTime
=
curMs
;
...
@@ -409,7 +425,7 @@ PROCESS_STATUS_MSG_OVER:
...
@@ -409,7 +425,7 @@ PROCESS_STATUS_MSG_OVER:
return
code
;
return
code
;
}
}
static
int32_t
mndCreateDnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
p
Msg
,
SCreateDnodeMsg
*
pCreate
)
{
static
int32_t
mndCreateDnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
p
Req
,
SCreateDnodeReq
*
pCreate
)
{
SDnodeObj
dnodeObj
=
{
0
};
SDnodeObj
dnodeObj
=
{
0
};
dnodeObj
.
id
=
sdbGetMaxId
(
pMnode
->
pSdb
,
SDB_DNODE
);
dnodeObj
.
id
=
sdbGetMaxId
(
pMnode
->
pSdb
,
SDB_DNODE
);
dnodeObj
.
createdTime
=
taosGetTimestampMs
();
dnodeObj
.
createdTime
=
taosGetTimestampMs
();
...
@@ -418,7 +434,7 @@ static int32_t mndCreateDnode(SMnode *pMnode, SMnodeMsg *pMsg, SCreateDnodeMsg *
...
@@ -418,7 +434,7 @@ static int32_t mndCreateDnode(SMnode *pMnode, SMnodeMsg *pMsg, SCreateDnodeMsg *
memcpy
(
dnodeObj
.
fqdn
,
pCreate
->
fqdn
,
TSDB_FQDN_LEN
);
memcpy
(
dnodeObj
.
fqdn
,
pCreate
->
fqdn
,
TSDB_FQDN_LEN
);
snprintf
(
dnodeObj
.
ep
,
TSDB_EP_LEN
,
"%s:%u"
,
dnodeObj
.
fqdn
,
dnodeObj
.
port
);
snprintf
(
dnodeObj
.
ep
,
TSDB_EP_LEN
,
"%s:%u"
,
dnodeObj
.
fqdn
,
dnodeObj
.
port
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
&
p
Msg
->
rpcMsg
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
&
p
Req
->
rpcMsg
);
if
(
pTrans
==
NULL
)
{
if
(
pTrans
==
NULL
)
{
mError
(
"dnode:%s, failed to create since %s"
,
dnodeObj
.
ep
,
terrstr
());
mError
(
"dnode:%s, failed to create since %s"
,
dnodeObj
.
ep
,
terrstr
());
return
-
1
;
return
-
1
;
...
@@ -443,9 +459,9 @@ static int32_t mndCreateDnode(SMnode *pMnode, SMnodeMsg *pMsg, SCreateDnodeMsg *
...
@@ -443,9 +459,9 @@ static int32_t mndCreateDnode(SMnode *pMnode, SMnodeMsg *pMsg, SCreateDnodeMsg *
return
0
;
return
0
;
}
}
static
int32_t
mndProcessCreateDnode
Msg
(
SMnodeMsg
*
pMsg
)
{
static
int32_t
mndProcessCreateDnode
Req
(
SMnodeMsg
*
pReq
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SCreateDnode
Msg
*
pCreate
=
pMsg
->
rpcMsg
.
pCont
;
SCreateDnode
Req
*
pCreate
=
pReq
->
rpcMsg
.
pCont
;
pCreate
->
port
=
htonl
(
pCreate
->
port
);
pCreate
->
port
=
htonl
(
pCreate
->
port
);
mDebug
(
"dnode:%s:%d, start to create"
,
pCreate
->
fqdn
,
pCreate
->
port
);
mDebug
(
"dnode:%s:%d, start to create"
,
pCreate
->
fqdn
,
pCreate
->
port
);
...
@@ -465,7 +481,7 @@ static int32_t mndProcessCreateDnodeMsg(SMnodeMsg *pMsg) {
...
@@ -465,7 +481,7 @@ static int32_t mndProcessCreateDnodeMsg(SMnodeMsg *pMsg) {
return
-
1
;
return
-
1
;
}
}
int32_t
code
=
mndCreateDnode
(
pMnode
,
p
Msg
,
pCreate
);
int32_t
code
=
mndCreateDnode
(
pMnode
,
p
Req
,
pCreate
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
mError
(
"dnode:%s:%d, failed to create since %s"
,
pCreate
->
fqdn
,
pCreate
->
port
,
terrstr
());
mError
(
"dnode:%s:%d, failed to create since %s"
,
pCreate
->
fqdn
,
pCreate
->
port
,
terrstr
());
...
@@ -475,8 +491,8 @@ static int32_t mndProcessCreateDnodeMsg(SMnodeMsg *pMsg) {
...
@@ -475,8 +491,8 @@ static int32_t mndProcessCreateDnodeMsg(SMnodeMsg *pMsg) {
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
}
static
int32_t
mndDropDnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
p
Msg
,
SDnodeObj
*
pDnode
)
{
static
int32_t
mndDropDnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
p
Req
,
SDnodeObj
*
pDnode
)
{
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
&
p
Msg
->
rpcMsg
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
&
p
Req
->
rpcMsg
);
if
(
pTrans
==
NULL
)
{
if
(
pTrans
==
NULL
)
{
mError
(
"dnode:%d, failed to drop since %s"
,
pDnode
->
id
,
terrstr
());
mError
(
"dnode:%d, failed to drop since %s"
,
pDnode
->
id
,
terrstr
());
return
-
1
;
return
-
1
;
...
@@ -501,9 +517,9 @@ static int32_t mndDropDnode(SMnode *pMnode, SMnodeMsg *pMsg, SDnodeObj *pDnode)
...
@@ -501,9 +517,9 @@ static int32_t mndDropDnode(SMnode *pMnode, SMnodeMsg *pMsg, SDnodeObj *pDnode)
return
0
;
return
0
;
}
}
static
int32_t
mndProcessDropDnode
Msg
(
SMnodeMsg
*
pMsg
)
{
static
int32_t
mndProcessDropDnode
Req
(
SMnodeMsg
*
pReq
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SDropDnode
Msg
*
pDrop
=
pMsg
->
rpcMsg
.
pCont
;
SDropDnode
Req
*
pDrop
=
pReq
->
rpcMsg
.
pCont
;
pDrop
->
dnodeId
=
htonl
(
pDrop
->
dnodeId
);
pDrop
->
dnodeId
=
htonl
(
pDrop
->
dnodeId
);
mDebug
(
"dnode:%d, start to drop"
,
pDrop
->
dnodeId
);
mDebug
(
"dnode:%d, start to drop"
,
pDrop
->
dnodeId
);
...
@@ -521,7 +537,7 @@ static int32_t mndProcessDropDnodeMsg(SMnodeMsg *pMsg) {
...
@@ -521,7 +537,7 @@ static int32_t mndProcessDropDnodeMsg(SMnodeMsg *pMsg) {
return
-
1
;
return
-
1
;
}
}
int32_t
code
=
mndDropDnode
(
pMnode
,
p
Msg
,
pDnode
);
int32_t
code
=
mndDropDnode
(
pMnode
,
p
Req
,
pDnode
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
mndReleaseDnode
(
pMnode
,
pDnode
);
mndReleaseDnode
(
pMnode
,
pDnode
);
mError
(
"dnode:%d, failed to drop since %s"
,
pDrop
->
dnodeId
,
terrstr
());
mError
(
"dnode:%d, failed to drop since %s"
,
pDrop
->
dnodeId
,
terrstr
());
...
@@ -532,9 +548,9 @@ static int32_t mndProcessDropDnodeMsg(SMnodeMsg *pMsg) {
...
@@ -532,9 +548,9 @@ static int32_t mndProcessDropDnodeMsg(SMnodeMsg *pMsg) {
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
}
static
int32_t
mndProcessConfigDnode
Msg
(
SMnodeMsg
*
pMsg
)
{
static
int32_t
mndProcessConfigDnode
Req
(
SMnodeMsg
*
pReq
)
{
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SMnode
*
pMnode
=
pReq
->
pMnode
;
S
CfgDnodeMsg
*
pCfg
=
pMsg
->
rpcMsg
.
pCont
;
S
MCfgDnodeReq
*
pCfg
=
pReq
->
rpcMsg
.
pCont
;
pCfg
->
dnodeId
=
htonl
(
pCfg
->
dnodeId
);
pCfg
->
dnodeId
=
htonl
(
pCfg
->
dnodeId
);
SDnodeObj
*
pDnode
=
mndAcquireDnode
(
pMnode
,
pCfg
->
dnodeId
);
SDnodeObj
*
pDnode
=
mndAcquireDnode
(
pMnode
,
pCfg
->
dnodeId
);
...
@@ -547,14 +563,14 @@ static int32_t mndProcessConfigDnodeMsg(SMnodeMsg *pMsg) {
...
@@ -547,14 +563,14 @@ static int32_t mndProcessConfigDnodeMsg(SMnodeMsg *pMsg) {
SEpSet
epSet
=
mndGetDnodeEpset
(
pDnode
);
SEpSet
epSet
=
mndGetDnodeEpset
(
pDnode
);
mndReleaseDnode
(
pMnode
,
pDnode
);
mndReleaseDnode
(
pMnode
,
pDnode
);
S
CfgDnodeMsg
*
pCfgDnode
=
rpcMallocCont
(
sizeof
(
SCfgDnodeMsg
));
S
DCfgDnodeReq
*
pCfgDnode
=
rpcMallocCont
(
sizeof
(
SDCfgDnodeReq
));
pCfgDnode
->
dnodeId
=
htonl
(
pCfg
->
dnodeId
);
pCfgDnode
->
dnodeId
=
htonl
(
pCfg
->
dnodeId
);
memcpy
(
pCfgDnode
->
config
,
pCfg
->
config
,
TSDB_DNODE_CONFIG_LEN
);
memcpy
(
pCfgDnode
->
config
,
pCfg
->
config
,
TSDB_DNODE_CONFIG_LEN
);
SRpcMsg
rpcMsg
=
{.
msgType
=
TDMT_DND_CONFIG_DNODE
,
SRpcMsg
rpcMsg
=
{.
msgType
=
TDMT_DND_CONFIG_DNODE
,
.
pCont
=
pCfgDnode
,
.
pCont
=
pCfgDnode
,
.
contLen
=
sizeof
(
S
CfgDnodeMsg
),
.
contLen
=
sizeof
(
S
DCfgDnodeReq
),
.
ahandle
=
p
Msg
->
rpcMsg
.
ahandle
};
.
ahandle
=
p
Req
->
rpcMsg
.
ahandle
};
mInfo
(
"dnode:%d, app:%p config:%s req send to dnode"
,
pCfg
->
dnodeId
,
rpcMsg
.
ahandle
,
pCfg
->
config
);
mInfo
(
"dnode:%d, app:%p config:%s req send to dnode"
,
pCfg
->
dnodeId
,
rpcMsg
.
ahandle
,
pCfg
->
config
);
mndSendReqToDnode
(
pMnode
,
&
epSet
,
&
rpcMsg
);
mndSendReqToDnode
(
pMnode
,
&
epSet
,
&
rpcMsg
);
...
@@ -562,11 +578,11 @@ static int32_t mndProcessConfigDnodeMsg(SMnodeMsg *pMsg) {
...
@@ -562,11 +578,11 @@ static int32_t mndProcessConfigDnodeMsg(SMnodeMsg *pMsg) {
return
0
;
return
0
;
}
}
static
int32_t
mndProcessConfigDnodeRsp
(
SMnodeMsg
*
p
Msg
)
{
static
int32_t
mndProcessConfigDnodeRsp
(
SMnodeMsg
*
p
Rsp
)
{
mInfo
(
"app:%p config rsp from dnode"
,
p
Msg
->
rpcMsg
.
ahandle
);
mInfo
(
"app:%p config rsp from dnode"
,
p
Rsp
->
rpcMsg
.
ahandle
);
}
}
static
int32_t
mndGetConfigMeta
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
)
{
static
int32_t
mndGetConfigMeta
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
)
{
int32_t
cols
=
0
;
int32_t
cols
=
0
;
SSchema
*
pSchema
=
pMeta
->
pSchema
;
SSchema
*
pSchema
=
pMeta
->
pSchema
;
...
@@ -597,8 +613,8 @@ static int32_t mndGetConfigMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg
...
@@ -597,8 +613,8 @@ static int32_t mndGetConfigMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg
return
0
;
return
0
;
}
}
static
int32_t
mndRetrieveConfigs
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
static
int32_t
mndRetrieveConfigs
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
SMnode
*
pMnode
=
p
Req
->
pMnode
;
int32_t
numOfRows
=
0
;
int32_t
numOfRows
=
0
;
char
*
cfgOpts
[
TSDB_CONFIG_NUMBER
]
=
{
0
};
char
*
cfgOpts
[
TSDB_CONFIG_NUMBER
]
=
{
0
};
char
cfgVals
[
TSDB_CONFIG_NUMBER
][
TSDB_CONIIG_VALUE_LEN
+
1
]
=
{
0
};
char
cfgVals
[
TSDB_CONFIG_NUMBER
][
TSDB_CONIIG_VALUE_LEN
+
1
]
=
{
0
};
...
@@ -640,8 +656,8 @@ static int32_t mndRetrieveConfigs(SMnodeMsg *pMsg, SShowObj *pShow, char *data,
...
@@ -640,8 +656,8 @@ static int32_t mndRetrieveConfigs(SMnodeMsg *pMsg, SShowObj *pShow, char *data,
static
void
mndCancelGetNextConfig
(
SMnode
*
pMnode
,
void
*
pIter
)
{}
static
void
mndCancelGetNextConfig
(
SMnode
*
pMnode
,
void
*
pIter
)
{}
static
int32_t
mndGetDnodeMeta
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
)
{
static
int32_t
mndGetDnodeMeta
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
cols
=
0
;
int32_t
cols
=
0
;
...
@@ -704,8 +720,8 @@ static int32_t mndGetDnodeMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *
...
@@ -704,8 +720,8 @@ static int32_t mndGetDnodeMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *
return
0
;
return
0
;
}
}
static
int32_t
mndRetrieveDnodes
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
static
int32_t
mndRetrieveDnodes
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
numOfRows
=
0
;
int32_t
numOfRows
=
0
;
int32_t
cols
=
0
;
int32_t
cols
=
0
;
...
...
source/dnode/mnode/impl/src/mndProfile.c
浏览文件 @
dc081e52
...
@@ -47,14 +47,14 @@ static SConnObj *mndAcquireConn(SMnode *pMnode, int32_t connId);
...
@@ -47,14 +47,14 @@ static SConnObj *mndAcquireConn(SMnode *pMnode, int32_t connId);
static
void
mndReleaseConn
(
SMnode
*
pMnode
,
SConnObj
*
pConn
);
static
void
mndReleaseConn
(
SMnode
*
pMnode
,
SConnObj
*
pConn
);
static
void
*
mndGetNextConn
(
SMnode
*
pMnode
,
void
*
pIter
,
SConnObj
**
pConn
);
static
void
*
mndGetNextConn
(
SMnode
*
pMnode
,
void
*
pIter
,
SConnObj
**
pConn
);
static
void
mndCancelGetNextConn
(
SMnode
*
pMnode
,
void
*
pIter
);
static
void
mndCancelGetNextConn
(
SMnode
*
pMnode
,
void
*
pIter
);
static
int32_t
mndProcessHeartBeat
Msg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessHeartBeat
Req
(
SMnodeMsg
*
pReq
);
static
int32_t
mndProcessConnect
Msg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessConnect
Req
(
SMnodeMsg
*
pReq
);
static
int32_t
mndProcessKillQuery
Msg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessKillQuery
Req
(
SMnodeMsg
*
pReq
);
static
int32_t
mndProcessKillConn
ectionMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessKillConn
Req
(
SMnodeMsg
*
pReq
);
static
int32_t
mndGetConnsMeta
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
);
static
int32_t
mndGetConnsMeta
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
);
static
int32_t
mndRetrieveConns
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
int32_t
mndRetrieveConns
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
int32_t
mndGetQueryMeta
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
);
static
int32_t
mndGetQueryMeta
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
);
static
int32_t
mndRetrieveQueries
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
int32_t
mndRetrieveQueries
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
void
mndCancelGetNextQuery
(
SMnode
*
pMnode
,
void
*
pIter
);
static
void
mndCancelGetNextQuery
(
SMnode
*
pMnode
,
void
*
pIter
);
int32_t
mndInitProfile
(
SMnode
*
pMnode
)
{
int32_t
mndInitProfile
(
SMnode
*
pMnode
)
{
...
@@ -68,10 +68,10 @@ int32_t mndInitProfile(SMnode *pMnode) {
...
@@ -68,10 +68,10 @@ int32_t mndInitProfile(SMnode *pMnode) {
return
-
1
;
return
-
1
;
}
}
mndSetMsgHandle
(
pMnode
,
TDMT_MND_HEARTBEAT
,
mndProcessHeartBeat
Msg
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_HEARTBEAT
,
mndProcessHeartBeat
Req
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_CONNECT
,
mndProcessConnect
Msg
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_CONNECT
,
mndProcessConnect
Req
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_KILL_QUERY
,
mndProcessKillQuery
Msg
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_KILL_QUERY
,
mndProcessKillQuery
Req
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_KILL_CONN
,
mndProcessKillConn
ectionMsg
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_KILL_CONN
,
mndProcessKillConn
Req
);
mndAddShowMetaHandle
(
pMnode
,
TSDB_MGMT_TABLE_CONNS
,
mndGetConnsMeta
);
mndAddShowMetaHandle
(
pMnode
,
TSDB_MGMT_TABLE_CONNS
,
mndGetConnsMeta
);
mndAddShowRetrieveHandle
(
pMnode
,
TSDB_MGMT_TABLE_CONNS
,
mndRetrieveConns
);
mndAddShowRetrieveHandle
(
pMnode
,
TSDB_MGMT_TABLE_CONNS
,
mndRetrieveConns
);
...
@@ -178,35 +178,35 @@ static void mndCancelGetNextConn(SMnode *pMnode, void *pIter) {
...
@@ -178,35 +178,35 @@ static void mndCancelGetNextConn(SMnode *pMnode, void *pIter) {
taosHashCancelIterate
(
pMgmt
->
cache
->
pHashTable
,
pIter
);
taosHashCancelIterate
(
pMgmt
->
cache
->
pHashTable
,
pIter
);
}
}
static
int32_t
mndProcessConnect
Msg
(
SMnodeMsg
*
pMsg
)
{
static
int32_t
mndProcessConnect
Req
(
SMnodeMsg
*
pReq
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SConnect
Msg
*
pReq
=
pMsg
->
rpcMsg
.
pCont
;
SConnect
Req
*
pConnReq
=
pReq
->
rpcMsg
.
pCont
;
p
Req
->
pid
=
htonl
(
p
Req
->
pid
);
p
ConnReq
->
pid
=
htonl
(
pConn
Req
->
pid
);
p
Req
->
startTime
=
htobe64
(
p
Req
->
startTime
);
p
ConnReq
->
startTime
=
htobe64
(
pConn
Req
->
startTime
);
SRpcConnInfo
info
=
{
0
};
SRpcConnInfo
info
=
{
0
};
if
(
rpcGetConnInfo
(
p
Msg
->
rpcMsg
.
handle
,
&
info
)
!=
0
)
{
if
(
rpcGetConnInfo
(
p
Req
->
rpcMsg
.
handle
,
&
info
)
!=
0
)
{
mError
(
"user:%s, failed to login while get connection info since %s"
,
p
Msg
->
user
,
terrstr
());
mError
(
"user:%s, failed to login while get connection info since %s"
,
p
Req
->
user
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
char
ip
[
30
];
char
ip
[
30
];
taosIp2String
(
info
.
clientIp
,
ip
);
taosIp2String
(
info
.
clientIp
,
ip
);
if
(
pReq
->
db
[
0
])
{
if
(
p
Conn
Req
->
db
[
0
])
{
snprintf
(
p
Msg
->
db
,
TSDB_DB_FNAME_LEN
,
"%d%s%s"
,
pMsg
->
acctId
,
TS_PATH_DELIMITER
,
p
Req
->
db
);
snprintf
(
p
Req
->
db
,
TSDB_DB_FNAME_LEN
,
"%d%s%s"
,
pReq
->
acctId
,
TS_PATH_DELIMITER
,
pConn
Req
->
db
);
SDbObj
*
pDb
=
mndAcquireDb
(
pMnode
,
p
Msg
->
db
);
SDbObj
*
pDb
=
mndAcquireDb
(
pMnode
,
p
Req
->
db
);
if
(
pDb
==
NULL
)
{
if
(
pDb
==
NULL
)
{
terrno
=
TSDB_CODE_MND_INVALID_DB
;
terrno
=
TSDB_CODE_MND_INVALID_DB
;
mError
(
"user:%s, failed to login from %s while use db:%s since %s"
,
p
Msg
->
user
,
ip
,
p
Req
->
db
,
terrstr
());
mError
(
"user:%s, failed to login from %s while use db:%s since %s"
,
p
Req
->
user
,
ip
,
pConn
Req
->
db
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
mndReleaseDb
(
pMnode
,
pDb
);
mndReleaseDb
(
pMnode
,
pDb
);
}
}
SConnObj
*
pConn
=
mndCreateConn
(
pMnode
,
&
info
,
p
Req
->
pid
,
pReq
->
app
,
p
Req
->
startTime
);
SConnObj
*
pConn
=
mndCreateConn
(
pMnode
,
&
info
,
p
ConnReq
->
pid
,
pConnReq
->
app
,
pConn
Req
->
startTime
);
if
(
pConn
==
NULL
)
{
if
(
pConn
==
NULL
)
{
mError
(
"user:%s, failed to login from %s while create connection since %s"
,
p
Msg
->
user
,
ip
,
terrstr
());
mError
(
"user:%s, failed to login from %s while create connection since %s"
,
p
Req
->
user
,
ip
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
...
@@ -214,11 +214,11 @@ static int32_t mndProcessConnectMsg(SMnodeMsg *pMsg) {
...
@@ -214,11 +214,11 @@ static int32_t mndProcessConnectMsg(SMnodeMsg *pMsg) {
if
(
pRsp
==
NULL
)
{
if
(
pRsp
==
NULL
)
{
mndReleaseConn
(
pMnode
,
pConn
);
mndReleaseConn
(
pMnode
,
pConn
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
mError
(
"user:%s, failed to login from %s while create rsp since %s"
,
p
Msg
->
user
,
ip
,
terrstr
());
mError
(
"user:%s, failed to login from %s while create rsp since %s"
,
p
Req
->
user
,
ip
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
SUserObj
*
pUser
=
mndAcquireUser
(
pMnode
,
p
Msg
->
user
);
SUserObj
*
pUser
=
mndAcquireUser
(
pMnode
,
p
Req
->
user
);
if
(
pUser
!=
NULL
)
{
if
(
pUser
!=
NULL
)
{
pRsp
->
acctId
=
htonl
(
pUser
->
acctId
);
pRsp
->
acctId
=
htonl
(
pUser
->
acctId
);
pRsp
->
superUser
=
pUser
->
superUser
;
pRsp
->
superUser
=
pUser
->
superUser
;
...
@@ -230,16 +230,16 @@ static int32_t mndProcessConnectMsg(SMnodeMsg *pMsg) {
...
@@ -230,16 +230,16 @@ static int32_t mndProcessConnectMsg(SMnodeMsg *pMsg) {
mndGetMnodeEpSet
(
pMnode
,
&
pRsp
->
epSet
);
mndGetMnodeEpSet
(
pMnode
,
&
pRsp
->
epSet
);
mndReleaseConn
(
pMnode
,
pConn
);
mndReleaseConn
(
pMnode
,
pConn
);
p
Msg
->
contLen
=
sizeof
(
SConnectRsp
);
p
Req
->
contLen
=
sizeof
(
SConnectRsp
);
p
Msg
->
pCont
=
pRsp
;
p
Req
->
pCont
=
pRsp
;
mDebug
(
"user:%s, login from %s, conn:%d, app:%s"
,
info
.
user
,
ip
,
pConn
->
id
,
pReq
->
app
);
mDebug
(
"user:%s, login from %s, conn:%d, app:%s"
,
info
.
user
,
ip
,
pConn
->
id
,
p
Conn
Req
->
app
);
return
0
;
return
0
;
}
}
static
int32_t
mndSaveQueryStreamList
(
SConnObj
*
pConn
,
SHeartBeat
Msg
*
pMsg
)
{
static
int32_t
mndSaveQueryStreamList
(
SConnObj
*
pConn
,
SHeartBeat
Req
*
pReq
)
{
pConn
->
numOfQueries
=
0
;
pConn
->
numOfQueries
=
0
;
int32_t
numOfQueries
=
htonl
(
p
Msg
->
numOfQueries
);
int32_t
numOfQueries
=
htonl
(
p
Req
->
numOfQueries
);
if
(
numOfQueries
>
0
)
{
if
(
numOfQueries
>
0
)
{
if
(
pConn
->
pQueries
==
NULL
)
{
if
(
pConn
->
pQueries
==
NULL
)
{
...
@@ -250,38 +250,38 @@ static int32_t mndSaveQueryStreamList(SConnObj *pConn, SHeartBeatMsg *pMsg) {
...
@@ -250,38 +250,38 @@ static int32_t mndSaveQueryStreamList(SConnObj *pConn, SHeartBeatMsg *pMsg) {
int32_t
saveSize
=
pConn
->
numOfQueries
*
sizeof
(
SQueryDesc
);
int32_t
saveSize
=
pConn
->
numOfQueries
*
sizeof
(
SQueryDesc
);
if
(
saveSize
>
0
&&
pConn
->
pQueries
!=
NULL
)
{
if
(
saveSize
>
0
&&
pConn
->
pQueries
!=
NULL
)
{
memcpy
(
pConn
->
pQueries
,
p
Msg
->
pData
,
saveSize
);
memcpy
(
pConn
->
pQueries
,
p
Req
->
pData
,
saveSize
);
}
}
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
mndProcessHeartBeat
Msg
(
SMnodeMsg
*
pMsg
)
{
static
int32_t
mndProcessHeartBeat
Req
(
SMnodeMsg
*
pReq
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
SHeartBeat
Msg
*
pReq
=
pMsg
->
rpcMsg
.
pCont
;
SHeartBeat
Req
*
pHeartbeat
=
pReq
->
rpcMsg
.
pCont
;
p
Req
->
connId
=
htonl
(
pReq
->
connId
);
p
Heartbeat
->
connId
=
htonl
(
pHeartbeat
->
connId
);
p
Req
->
pid
=
htonl
(
pReq
->
pid
);
p
Heartbeat
->
pid
=
htonl
(
pHeartbeat
->
pid
);
SRpcConnInfo
info
=
{
0
};
SRpcConnInfo
info
=
{
0
};
if
(
rpcGetConnInfo
(
p
Msg
->
rpcMsg
.
handle
,
&
info
)
!=
0
)
{
if
(
rpcGetConnInfo
(
p
Req
->
rpcMsg
.
handle
,
&
info
)
!=
0
)
{
mError
(
"user:%s, connId:%d failed to process hb since %s"
,
p
Msg
->
user
,
pReq
->
connId
,
terrstr
());
mError
(
"user:%s, connId:%d failed to process hb since %s"
,
p
Req
->
user
,
pHeartbeat
->
connId
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
SConnObj
*
pConn
=
mndAcquireConn
(
pMnode
,
p
Req
->
connId
);
SConnObj
*
pConn
=
mndAcquireConn
(
pMnode
,
p
Heartbeat
->
connId
);
if
(
pConn
==
NULL
)
{
if
(
pConn
==
NULL
)
{
pConn
=
mndCreateConn
(
pMnode
,
&
info
,
p
Req
->
pid
,
pReq
->
app
,
0
);
pConn
=
mndCreateConn
(
pMnode
,
&
info
,
p
Heartbeat
->
pid
,
pHeartbeat
->
app
,
0
);
if
(
pConn
==
NULL
)
{
if
(
pConn
==
NULL
)
{
mError
(
"user:%s, conn:%d is freed and failed to create new
conn since %s"
,
pMsg
->
user
,
pReq
->
connId
,
terrstr
());
mError
(
"user:%s, conn:%d is freed and failed to create new
since %s"
,
pReq
->
user
,
pHeartbeat
->
connId
,
terrstr
());
return
-
1
;
return
-
1
;
}
else
{
}
else
{
mDebug
(
"user:%s, conn:%d is freed and create a new conn:%d"
,
p
Msg
->
user
,
pReq
->
connId
,
pConn
->
id
);
mDebug
(
"user:%s, conn:%d is freed and create a new conn:%d"
,
p
Req
->
user
,
pHeartbeat
->
connId
,
pConn
->
id
);
}
}
}
else
if
(
pConn
->
killed
)
{
}
else
if
(
pConn
->
killed
)
{
mError
(
"user:%s, conn:%d is already killed"
,
p
Msg
->
user
,
pConn
->
id
);
mError
(
"user:%s, conn:%d is already killed"
,
p
Req
->
user
,
pConn
->
id
);
terrno
=
TSDB_CODE_MND_INVALID_CONNECTION
;
terrno
=
TSDB_CODE_MND_INVALID_CONNECTION
;
return
-
1
;
return
-
1
;
}
else
{
}
else
{
...
@@ -304,11 +304,11 @@ static int32_t mndProcessHeartBeatMsg(SMnodeMsg *pMsg) {
...
@@ -304,11 +304,11 @@ static int32_t mndProcessHeartBeatMsg(SMnodeMsg *pMsg) {
if
(
pRsp
==
NULL
)
{
if
(
pRsp
==
NULL
)
{
mndReleaseConn
(
pMnode
,
pConn
);
mndReleaseConn
(
pMnode
,
pConn
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
mError
(
"user:%s, conn:%d failed to process hb while
create rsp since %s"
,
pMsg
->
user
,
pReq
->
connId
,
terrstr
());
mError
(
"user:%s, conn:%d failed to process hb while
since %s"
,
pReq
->
user
,
pHeartbeat
->
connId
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
mndSaveQueryStreamList
(
pConn
,
p
Req
);
mndSaveQueryStreamList
(
pConn
,
p
Heartbeat
);
if
(
pConn
->
killed
!=
0
)
{
if
(
pConn
->
killed
!=
0
)
{
pRsp
->
killConnection
=
1
;
pRsp
->
killConnection
=
1
;
}
}
...
@@ -324,16 +324,16 @@ static int32_t mndProcessHeartBeatMsg(SMnodeMsg *pMsg) {
...
@@ -324,16 +324,16 @@ static int32_t mndProcessHeartBeatMsg(SMnodeMsg *pMsg) {
mndGetMnodeEpSet
(
pMnode
,
&
pRsp
->
epSet
);
mndGetMnodeEpSet
(
pMnode
,
&
pRsp
->
epSet
);
mndReleaseConn
(
pMnode
,
pConn
);
mndReleaseConn
(
pMnode
,
pConn
);
p
Msg
->
contLen
=
sizeof
(
SConnectRsp
);
p
Req
->
contLen
=
sizeof
(
SConnectRsp
);
p
Msg
->
pCont
=
pRsp
;
p
Req
->
pCont
=
pRsp
;
return
0
;
return
0
;
}
}
static
int32_t
mndProcessKillQuery
Msg
(
SMnodeMsg
*
pMsg
)
{
static
int32_t
mndProcessKillQuery
Req
(
SMnodeMsg
*
pReq
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
SUserObj
*
pUser
=
mndAcquireUser
(
pMnode
,
p
Msg
->
user
);
SUserObj
*
pUser
=
mndAcquireUser
(
pMnode
,
p
Req
->
user
);
if
(
pUser
==
NULL
)
return
0
;
if
(
pUser
==
NULL
)
return
0
;
if
(
!
pUser
->
superUser
)
{
if
(
!
pUser
->
superUser
)
{
mndReleaseUser
(
pMnode
,
pUser
);
mndReleaseUser
(
pMnode
,
pUser
);
...
@@ -342,7 +342,7 @@ static int32_t mndProcessKillQueryMsg(SMnodeMsg *pMsg) {
...
@@ -342,7 +342,7 @@ static int32_t mndProcessKillQueryMsg(SMnodeMsg *pMsg) {
}
}
mndReleaseUser
(
pMnode
,
pUser
);
mndReleaseUser
(
pMnode
,
pUser
);
SKillQuery
Msg
*
pKill
=
pMsg
->
rpcMsg
.
pCont
;
SKillQuery
Req
*
pKill
=
pReq
->
rpcMsg
.
pCont
;
int32_t
connId
=
htonl
(
pKill
->
connId
);
int32_t
connId
=
htonl
(
pKill
->
connId
);
int32_t
queryId
=
htonl
(
pKill
->
queryId
);
int32_t
queryId
=
htonl
(
pKill
->
queryId
);
mInfo
(
"kill query msg is received, queryId:%d"
,
pKill
->
queryId
);
mInfo
(
"kill query msg is received, queryId:%d"
,
pKill
->
queryId
);
...
@@ -353,18 +353,18 @@ static int32_t mndProcessKillQueryMsg(SMnodeMsg *pMsg) {
...
@@ -353,18 +353,18 @@ static int32_t mndProcessKillQueryMsg(SMnodeMsg *pMsg) {
terrno
=
TSDB_CODE_MND_INVALID_CONN_ID
;
terrno
=
TSDB_CODE_MND_INVALID_CONN_ID
;
return
-
1
;
return
-
1
;
}
else
{
}
else
{
mInfo
(
"connId:%d, queryId:%d is killed by user:%s"
,
connId
,
queryId
,
p
Msg
->
user
);
mInfo
(
"connId:%d, queryId:%d is killed by user:%s"
,
connId
,
queryId
,
p
Req
->
user
);
pConn
->
queryId
=
queryId
;
pConn
->
queryId
=
queryId
;
taosCacheRelease
(
pMgmt
->
cache
,
(
void
**
)
&
pConn
,
false
);
taosCacheRelease
(
pMgmt
->
cache
,
(
void
**
)
&
pConn
,
false
);
return
0
;
return
0
;
}
}
}
}
static
int32_t
mndProcessKillConn
ectionMsg
(
SMnodeMsg
*
pMsg
)
{
static
int32_t
mndProcessKillConn
Req
(
SMnodeMsg
*
pReq
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
SUserObj
*
pUser
=
mndAcquireUser
(
pMnode
,
p
Msg
->
user
);
SUserObj
*
pUser
=
mndAcquireUser
(
pMnode
,
p
Req
->
user
);
if
(
pUser
==
NULL
)
return
0
;
if
(
pUser
==
NULL
)
return
0
;
if
(
!
pUser
->
superUser
)
{
if
(
!
pUser
->
superUser
)
{
mndReleaseUser
(
pMnode
,
pUser
);
mndReleaseUser
(
pMnode
,
pUser
);
...
@@ -373,7 +373,7 @@ static int32_t mndProcessKillConnectionMsg(SMnodeMsg *pMsg) {
...
@@ -373,7 +373,7 @@ static int32_t mndProcessKillConnectionMsg(SMnodeMsg *pMsg) {
}
}
mndReleaseUser
(
pMnode
,
pUser
);
mndReleaseUser
(
pMnode
,
pUser
);
SKillConn
Msg
*
pKill
=
pMsg
->
rpcMsg
.
pCont
;
SKillConn
Req
*
pKill
=
pReq
->
rpcMsg
.
pCont
;
int32_t
connId
=
htonl
(
pKill
->
connId
);
int32_t
connId
=
htonl
(
pKill
->
connId
);
SConnObj
*
pConn
=
taosCacheAcquireByKey
(
pMgmt
->
cache
,
&
connId
,
sizeof
(
int32_t
));
SConnObj
*
pConn
=
taosCacheAcquireByKey
(
pMgmt
->
cache
,
&
connId
,
sizeof
(
int32_t
));
...
@@ -382,18 +382,18 @@ static int32_t mndProcessKillConnectionMsg(SMnodeMsg *pMsg) {
...
@@ -382,18 +382,18 @@ static int32_t mndProcessKillConnectionMsg(SMnodeMsg *pMsg) {
terrno
=
TSDB_CODE_MND_INVALID_CONN_ID
;
terrno
=
TSDB_CODE_MND_INVALID_CONN_ID
;
return
-
1
;
return
-
1
;
}
else
{
}
else
{
mInfo
(
"connId:%d, is killed by user:%s"
,
connId
,
p
Msg
->
user
);
mInfo
(
"connId:%d, is killed by user:%s"
,
connId
,
p
Req
->
user
);
pConn
->
killed
=
1
;
pConn
->
killed
=
1
;
taosCacheRelease
(
pMgmt
->
cache
,
(
void
**
)
&
pConn
,
false
);
taosCacheRelease
(
pMgmt
->
cache
,
(
void
**
)
&
pConn
,
false
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
}
}
static
int32_t
mndGetConnsMeta
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
)
{
static
int32_t
mndGetConnsMeta
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
SUserObj
*
pUser
=
mndAcquireUser
(
pMnode
,
p
Msg
->
user
);
SUserObj
*
pUser
=
mndAcquireUser
(
pMnode
,
p
Req
->
user
);
if
(
pUser
==
NULL
)
return
0
;
if
(
pUser
==
NULL
)
return
0
;
if
(
!
pUser
->
superUser
)
{
if
(
!
pUser
->
superUser
)
{
mndReleaseUser
(
pMnode
,
pUser
);
mndReleaseUser
(
pMnode
,
pUser
);
...
@@ -464,8 +464,8 @@ static int32_t mndGetConnsMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *
...
@@ -464,8 +464,8 @@ static int32_t mndGetConnsMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *
return
0
;
return
0
;
}
}
static
int32_t
mndRetrieveConns
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
static
int32_t
mndRetrieveConns
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
SMnode
*
pMnode
=
p
Req
->
pMnode
;
int32_t
numOfRows
=
0
;
int32_t
numOfRows
=
0
;
SConnObj
*
pConn
=
NULL
;
SConnObj
*
pConn
=
NULL
;
int32_t
cols
=
0
;
int32_t
cols
=
0
;
...
@@ -518,11 +518,11 @@ static int32_t mndRetrieveConns(SMnodeMsg *pMsg, SShowObj *pShow, char *data, in
...
@@ -518,11 +518,11 @@ static int32_t mndRetrieveConns(SMnodeMsg *pMsg, SShowObj *pShow, char *data, in
return
numOfRows
;
return
numOfRows
;
}
}
static
int32_t
mndGetQueryMeta
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
)
{
static
int32_t
mndGetQueryMeta
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
SUserObj
*
pUser
=
mndAcquireUser
(
pMnode
,
p
Msg
->
user
);
SUserObj
*
pUser
=
mndAcquireUser
(
pMnode
,
p
Req
->
user
);
if
(
pUser
==
NULL
)
return
0
;
if
(
pUser
==
NULL
)
return
0
;
if
(
!
pUser
->
superUser
)
{
if
(
!
pUser
->
superUser
)
{
mndReleaseUser
(
pMnode
,
pUser
);
mndReleaseUser
(
pMnode
,
pUser
);
...
@@ -633,8 +633,8 @@ static int32_t mndGetQueryMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *
...
@@ -633,8 +633,8 @@ static int32_t mndGetQueryMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *
return
0
;
return
0
;
}
}
static
int32_t
mndRetrieveQueries
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
static
int32_t
mndRetrieveQueries
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
SMnode
*
pMnode
=
p
Req
->
pMnode
;
int32_t
numOfRows
=
0
;
int32_t
numOfRows
=
0
;
SConnObj
*
pConn
=
NULL
;
SConnObj
*
pConn
=
NULL
;
int32_t
cols
=
0
;
int32_t
cols
=
0
;
...
...
source/dnode/mnode/impl/src/mndShow.c
浏览文件 @
dc081e52
...
@@ -124,20 +124,20 @@ static int32_t mndProcessShowReq(SMnodeMsg *pReq) {
...
@@ -124,20 +124,20 @@ static int32_t mndProcessShowReq(SMnodeMsg *pReq) {
if
(
type
<=
TSDB_MGMT_TABLE_START
||
type
>=
TSDB_MGMT_TABLE_MAX
)
{
if
(
type
<=
TSDB_MGMT_TABLE_START
||
type
>=
TSDB_MGMT_TABLE_MAX
)
{
terrno
=
TSDB_CODE_MND_INVALID_MSG_TYPE
;
terrno
=
TSDB_CODE_MND_INVALID_MSG_TYPE
;
mError
(
"failed to process show
msg
since %s"
,
terrstr
());
mError
(
"failed to process show
-meta req
since %s"
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
ShowMetaFp
metaFp
=
pMgmt
->
metaFps
[
type
];
ShowMetaFp
metaFp
=
pMgmt
->
metaFps
[
type
];
if
(
metaFp
==
NULL
)
{
if
(
metaFp
==
NULL
)
{
terrno
=
TSDB_CODE_MND_INVALID_MSG_TYPE
;
terrno
=
TSDB_CODE_MND_INVALID_MSG_TYPE
;
mError
(
"failed to process show-meta
msg
:%s since %s"
,
mndShowStr
(
type
),
terrstr
());
mError
(
"failed to process show-meta
req
:%s since %s"
,
mndShowStr
(
type
),
terrstr
());
return
-
1
;
return
-
1
;
}
}
SShowObj
*
pShow
=
mndCreateShowObj
(
pMnode
,
pShowReq
);
SShowObj
*
pShow
=
mndCreateShowObj
(
pMnode
,
pShowReq
);
if
(
pShow
==
NULL
)
{
if
(
pShow
==
NULL
)
{
mError
(
"failed to process show-meta
msg
:%s since %s"
,
mndShowStr
(
type
),
terrstr
());
mError
(
"failed to process show-meta
req
:%s since %s"
,
mndShowStr
(
type
),
terrstr
());
return
-
1
;
return
-
1
;
}
}
...
@@ -146,7 +146,7 @@ static int32_t mndProcessShowReq(SMnodeMsg *pReq) {
...
@@ -146,7 +146,7 @@ static int32_t mndProcessShowReq(SMnodeMsg *pReq) {
if
(
pRsp
==
NULL
)
{
if
(
pRsp
==
NULL
)
{
mndReleaseShowObj
(
pShow
,
true
);
mndReleaseShowObj
(
pShow
,
true
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
mError
(
"show:0x%"
PRIx64
", failed to process show-meta
msg
:%s since malloc rsp error"
,
pShow
->
id
,
mError
(
"show:0x%"
PRIx64
", failed to process show-meta
req
:%s since malloc rsp error"
,
pShow
->
id
,
mndShowStr
(
type
));
mndShowStr
(
type
));
return
-
1
;
return
-
1
;
}
}
...
@@ -181,7 +181,7 @@ static int32_t mndProcessRetrieveReq(SMnodeMsg *pReq) {
...
@@ -181,7 +181,7 @@ static int32_t mndProcessRetrieveReq(SMnodeMsg *pReq) {
SShowObj
*
pShow
=
mndAcquireShowObj
(
pMnode
,
showId
);
SShowObj
*
pShow
=
mndAcquireShowObj
(
pMnode
,
showId
);
if
(
pShow
==
NULL
)
{
if
(
pShow
==
NULL
)
{
terrno
=
TSDB_CODE_MND_INVALID_SHOWOBJ
;
terrno
=
TSDB_CODE_MND_INVALID_SHOWOBJ
;
mError
(
"failed to process show-retrieve
msg
:%p since %s"
,
pShow
,
terrstr
());
mError
(
"failed to process show-retrieve
req
:%p since %s"
,
pShow
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
...
...
source/dnode/mnode/impl/src/mndTopic.c
浏览文件 @
dc081e52
...
@@ -58,25 +58,36 @@ int32_t mndInitTopic(SMnode *pMnode) {
...
@@ -58,25 +58,36 @@ int32_t mndInitTopic(SMnode *pMnode) {
void
mndCleanupTopic
(
SMnode
*
pMnode
)
{}
void
mndCleanupTopic
(
SMnode
*
pMnode
)
{}
SSdbRaw
*
mndTopicActionEncode
(
SMqTopicObj
*
pTopic
)
{
SSdbRaw
*
mndTopicActionEncode
(
SMqTopicObj
*
pTopic
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
int32_t
size
=
sizeof
(
SMqTopicObj
)
+
MND_TOPIC_RESERVE_SIZE
;
int32_t
size
=
sizeof
(
SMqTopicObj
)
+
MND_TOPIC_RESERVE_SIZE
;
SSdbRaw
*
pRaw
=
sdbAllocRaw
(
SDB_TOPIC
,
MND_TOPIC_VER_NUMBER
,
size
);
SSdbRaw
*
pRaw
=
sdbAllocRaw
(
SDB_TOPIC
,
MND_TOPIC_VER_NUMBER
,
size
);
if
(
pRaw
==
NULL
)
goto
WTF
;
if
(
pRaw
==
NULL
)
goto
TOPIC_ENCODE_OVER
;
int32_t
dataPos
=
0
;
int32_t
dataPos
=
0
;
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pTopic
->
name
,
TSDB_TABLE_FNAME_LEN
,
WTF
);
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pTopic
->
name
,
TSDB_TABLE_FNAME_LEN
,
TOPIC_ENCODE_OVER
);
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pTopic
->
db
,
TSDB_DB_FNAME_LEN
,
WTF
);
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pTopic
->
db
,
TSDB_DB_FNAME_LEN
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT64
(
pRaw
,
dataPos
,
pTopic
->
createTime
,
WTF
);
SDB_SET_INT64
(
pRaw
,
dataPos
,
pTopic
->
createTime
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT64
(
pRaw
,
dataPos
,
pTopic
->
updateTime
,
WTF
);
SDB_SET_INT64
(
pRaw
,
dataPos
,
pTopic
->
updateTime
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT64
(
pRaw
,
dataPos
,
pTopic
->
uid
,
WTF
);
SDB_SET_INT64
(
pRaw
,
dataPos
,
pTopic
->
uid
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT64
(
pRaw
,
dataPos
,
pTopic
->
dbUid
,
WTF
);
SDB_SET_INT64
(
pRaw
,
dataPos
,
pTopic
->
dbUid
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
pTopic
->
version
,
WTF
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
pTopic
->
version
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
pTopic
->
sqlLen
,
WTF
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
pTopic
->
sqlLen
,
TOPIC_ENCODE_OVER
);
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pTopic
->
sql
,
pTopic
->
sqlLen
,
WTF
);
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pTopic
->
sql
,
pTopic
->
sqlLen
,
TOPIC_ENCODE_OVER
);
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
MND_TOPIC_RESERVE_SIZE
,
WTF
);
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
MND_TOPIC_RESERVE_SIZE
,
TOPIC_ENCODE_OVER
);
SDB_SET_DATALEN
(
pRaw
,
dataPos
,
WTF
);
SDB_SET_DATALEN
(
pRaw
,
dataPos
,
TOPIC_ENCODE_OVER
);
WTF:
terrno
=
TSDB_CODE_SUCCESS
;
TOPIC_ENCODE_OVER:
if
(
terrno
!=
TSDB_CODE_SUCCESS
)
{
mError
(
"topic:%s, failed to encode to raw:%p since %s"
,
pTopic
->
name
,
pRaw
,
terrstr
());
sdbFreeRaw
(
pRaw
);
return
NULL
;
}
mTrace
(
"topic:%s, encode to raw:%p, row:%p"
,
pTopic
->
name
,
pRaw
,
pTopic
);
return
pRaw
;
return
pRaw
;
}
}
...
@@ -90,8 +101,8 @@ SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) {
...
@@ -90,8 +101,8 @@ SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) {
goto
TOPIC_DECODE_OVER
;
goto
TOPIC_DECODE_OVER
;
}
}
int32_t
size
=
sizeof
(
SMqTopicObj
);
int32_t
size
=
sizeof
(
SMqTopicObj
);
SSdbRow
*
pRow
=
sdbAllocRow
(
size
);
SSdbRow
*
pRow
=
sdbAllocRow
(
size
);
if
(
pRow
==
NULL
)
goto
TOPIC_DECODE_OVER
;
if
(
pRow
==
NULL
)
goto
TOPIC_DECODE_OVER
;
SMqTopicObj
*
pTopic
=
sdbGetRowObj
(
pRow
);
SMqTopicObj
*
pTopic
=
sdbGetRowObj
(
pRow
);
...
@@ -115,10 +126,10 @@ SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) {
...
@@ -115,10 +126,10 @@ SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) {
SDB_GET_RESERVE
(
pRaw
,
dataPos
,
MND_TOPIC_RESERVE_SIZE
,
TOPIC_DECODE_OVER
)
SDB_GET_RESERVE
(
pRaw
,
dataPos
,
MND_TOPIC_RESERVE_SIZE
,
TOPIC_DECODE_OVER
)
terrno
=
0
;
terrno
=
TSDB_CODE_SUCCESS
;
TOPIC_DECODE_OVER:
TOPIC_DECODE_OVER:
if
(
terrno
!=
0
)
{
if
(
terrno
!=
TSDB_CODE_SUCCESS
)
{
mError
(
"topic:%s, failed to decode from raw:%p since %s"
,
pTopic
->
name
,
pRaw
,
terrstr
());
mError
(
"topic:%s, failed to decode from raw:%p since %s"
,
pTopic
->
name
,
pRaw
,
terrstr
());
tfree
(
pRow
);
tfree
(
pRow
);
return
NULL
;
return
NULL
;
...
...
source/dnode/mnode/impl/test/CMakeLists.txt
浏览文件 @
dc081e52
...
@@ -7,3 +7,6 @@ add_subdirectory(qnode)
...
@@ -7,3 +7,6 @@ add_subdirectory(qnode)
add_subdirectory
(
snode
)
add_subdirectory
(
snode
)
add_subdirectory
(
bnode
)
add_subdirectory
(
bnode
)
add_subdirectory
(
show
)
add_subdirectory
(
show
)
add_subdirectory
(
profile
)
add_subdirectory
(
dnode
)
add_subdirectory
(
mnode
)
source/dnode/mnode/impl/test/bnode/bnode.cpp
浏览文件 @
dc081e52
...
@@ -96,9 +96,9 @@ TEST_F(MndTestBnode, 02_Create_Bnode) {
...
@@ -96,9 +96,9 @@ TEST_F(MndTestBnode, 02_Create_Bnode) {
TEST_F
(
MndTestBnode
,
03
_Drop_Bnode
)
{
TEST_F
(
MndTestBnode
,
03
_Drop_Bnode
)
{
{
{
int32_t
contLen
=
sizeof
(
SCreateDnode
Msg
);
int32_t
contLen
=
sizeof
(
SCreateDnode
Req
);
SCreateDnode
Msg
*
pReq
=
(
SCreateDnodeMsg
*
)
rpcMallocCont
(
contLen
);
SCreateDnode
Req
*
pReq
=
(
SCreateDnodeReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
pReq
->
port
=
htonl
(
9019
);
pReq
->
port
=
htonl
(
9019
);
...
...
source/dnode/m
gmt
/impl/test/dnode/CMakeLists.txt
→
source/dnode/m
node
/impl/test/dnode/CMakeLists.txt
浏览文件 @
dc081e52
aux_source_directory
(
. DTEST_SRC
)
aux_source_directory
(
. DTEST_SRC
)
add_executable
(
d
node_test_dnode
${
DTEST_SRC
}
)
add_executable
(
m
node_test_dnode
${
DTEST_SRC
}
)
target_link_libraries
(
target_link_libraries
(
d
node_test_dnode
m
node_test_dnode
PUBLIC sut
PUBLIC sut
)
)
add_test
(
add_test
(
NAME
d
node_test_dnode
NAME
m
node_test_dnode
COMMAND
d
node_test_dnode
COMMAND
m
node_test_dnode
)
)
source/dnode/m
gmt
/impl/test/dnode/dnode.cpp
→
source/dnode/m
node
/impl/test/dnode/dnode.cpp
浏览文件 @
dc081e52
/**
/**
* @file dnode.cpp
* @file dnode.cpp
* @author slguan (slguan@taosdata.com)
* @author slguan (slguan@taosdata.com)
* @brief
DNODE module dnode-msg
tests
* @brief
MNODE module dnode
tests
* @version
0.1
* @version
1.0
* @date 202
1-12-15
* @date 202
2-01-06
*
*
* @copyright Copyright (c) 202
1
* @copyright Copyright (c) 202
2
*
*
*/
*/
#include "sut.h"
#include "sut.h"
class
D
ndTestDnode
:
public
::
testing
::
Test
{
class
M
ndTestDnode
:
public
::
testing
::
Test
{
public:
public:
void
SetUp
()
override
{}
void
SetUp
()
override
{}
void
TearDown
()
override
{}
void
TearDown
()
override
{}
public:
public:
static
void
SetUpTestSuite
()
{
static
void
SetUpTestSuite
()
{
test
.
Init
(
"/tmp/dnode_test_dnode1"
,
90
41
);
test
.
Init
(
"/tmp/dnode_test_dnode1"
,
90
23
);
const
char
*
fqdn
=
"localhost"
;
const
char
*
fqdn
=
"localhost"
;
const
char
*
firstEp
=
"localhost:90
41
"
;
const
char
*
firstEp
=
"localhost:90
23
"
;
server2
.
Start
(
"/tmp/dnode_test_dnode2"
,
fqdn
,
90
42
,
firstEp
);
server2
.
Start
(
"/tmp/dnode_test_dnode2"
,
fqdn
,
90
24
,
firstEp
);
server3
.
Start
(
"/tmp/dnode_test_dnode3"
,
fqdn
,
90
43
,
firstEp
);
server3
.
Start
(
"/tmp/dnode_test_dnode3"
,
fqdn
,
90
25
,
firstEp
);
server4
.
Start
(
"/tmp/dnode_test_dnode4"
,
fqdn
,
90
44
,
firstEp
);
server4
.
Start
(
"/tmp/dnode_test_dnode4"
,
fqdn
,
90
26
,
firstEp
);
server5
.
Start
(
"/tmp/dnode_test_dnode5"
,
fqdn
,
90
45
,
firstEp
);
server5
.
Start
(
"/tmp/dnode_test_dnode5"
,
fqdn
,
90
27
,
firstEp
);
taosMsleep
(
300
);
taosMsleep
(
300
);
}
}
...
@@ -44,13 +44,13 @@ class DndTestDnode : public ::testing::Test {
...
@@ -44,13 +44,13 @@ class DndTestDnode : public ::testing::Test {
static
TestServer
server5
;
static
TestServer
server5
;
};
};
Testbase
D
ndTestDnode
::
test
;
Testbase
M
ndTestDnode
::
test
;
TestServer
D
ndTestDnode
::
server2
;
TestServer
M
ndTestDnode
::
server2
;
TestServer
D
ndTestDnode
::
server3
;
TestServer
M
ndTestDnode
::
server3
;
TestServer
D
ndTestDnode
::
server4
;
TestServer
M
ndTestDnode
::
server4
;
TestServer
D
ndTestDnode
::
server5
;
TestServer
M
ndTestDnode
::
server5
;
TEST_F
(
D
ndTestDnode
,
01
_ShowDnode
)
{
TEST_F
(
M
ndTestDnode
,
01
_ShowDnode
)
{
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_DNODE
,
""
);
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_DNODE
,
""
);
CHECK_META
(
"show dnodes"
,
7
);
CHECK_META
(
"show dnodes"
,
7
);
...
@@ -66,7 +66,7 @@ TEST_F(DndTestDnode, 01_ShowDnode) {
...
@@ -66,7 +66,7 @@ TEST_F(DndTestDnode, 01_ShowDnode) {
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckInt16
(
1
);
CheckInt16
(
1
);
CheckBinary
(
"localhost:90
41
"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
23
"
,
TSDB_EP_LEN
);
CheckInt16
(
0
);
CheckInt16
(
0
);
CheckInt16
(
16
);
CheckInt16
(
16
);
CheckBinary
(
"ready"
,
10
);
CheckBinary
(
"ready"
,
10
);
...
@@ -74,10 +74,10 @@ TEST_F(DndTestDnode, 01_ShowDnode) {
...
@@ -74,10 +74,10 @@ TEST_F(DndTestDnode, 01_ShowDnode) {
CheckBinary
(
""
,
24
);
CheckBinary
(
""
,
24
);
}
}
TEST_F
(
D
ndTestDnode
,
02
_ConfigDnode
)
{
TEST_F
(
M
ndTestDnode
,
02
_ConfigDnode
)
{
int32_t
contLen
=
sizeof
(
S
CfgDnodeMsg
);
int32_t
contLen
=
sizeof
(
S
MCfgDnodeReq
);
S
CfgDnodeMsg
*
pReq
=
(
SCfgDnodeMsg
*
)
rpcMallocCont
(
contLen
);
S
MCfgDnodeReq
*
pReq
=
(
SMCfgDnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
pReq
->
dnodeId
=
htonl
(
1
);
strcpy
(
pReq
->
config
,
"ddebugflag 131"
);
strcpy
(
pReq
->
config
,
"ddebugflag 131"
);
...
@@ -86,19 +86,67 @@ TEST_F(DndTestDnode, 02_ConfigDnode) {
...
@@ -86,19 +86,67 @@ TEST_F(DndTestDnode, 02_ConfigDnode) {
ASSERT_EQ
(
pRsp
->
code
,
0
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
}
TEST_F
(
DndTestDnode
,
03
_Create_Drop_Restart
_Dnode
)
{
TEST_F
(
MndTestDnode
,
03
_Create
_Dnode
)
{
{
{
int32_t
contLen
=
sizeof
(
SCreateDnode
Msg
);
int32_t
contLen
=
sizeof
(
SCreateDnode
Req
);
SCreateDnodeMsg
*
pReq
=
(
SCreateDnodeMsg
*
)
rpcMallocCont
(
contLen
);
SCreateDnodeReq
*
pReq
=
(
SCreateDnodeReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
fqdn
,
""
);
pReq
->
port
=
htonl
(
9024
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_DNODE_EP
);
}
{
int32_t
contLen
=
sizeof
(
SCreateDnodeReq
);
SCreateDnodeReq
*
pReq
=
(
SCreateDnodeReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
pReq
->
port
=
htonl
(
-
1
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_DNODE_EP
);
}
{
int32_t
contLen
=
sizeof
(
SCreateDnodeReq
);
SCreateDnodeReq
*
pReq
=
(
SCreateDnodeReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
pReq
->
port
=
htonl
(
123456
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_DNODE_EP
);
}
{
int32_t
contLen
=
sizeof
(
SCreateDnodeReq
);
SCreateDnodeReq
*
pReq
=
(
SCreateDnodeReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
pReq
->
port
=
htonl
(
90
42
);
pReq
->
port
=
htonl
(
90
24
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
}
{
int32_t
contLen
=
sizeof
(
SCreateDnodeReq
);
SCreateDnodeReq
*
pReq
=
(
SCreateDnodeReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
pReq
->
port
=
htonl
(
9024
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_DNODE_ALREADY_EXIST
);
}
taosMsleep
(
1300
);
taosMsleep
(
1300
);
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_DNODE
,
""
);
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_DNODE
,
""
);
...
@@ -108,8 +156,8 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
...
@@ -108,8 +156,8 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
CheckInt16
(
1
);
CheckInt16
(
1
);
CheckInt16
(
2
);
CheckInt16
(
2
);
CheckBinary
(
"localhost:90
41
"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
23
"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
42
"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
24
"
,
TSDB_EP_LEN
);
CheckInt16
(
0
);
CheckInt16
(
0
);
CheckInt16
(
0
);
CheckInt16
(
0
);
CheckInt16
(
16
);
CheckInt16
(
16
);
...
@@ -120,11 +168,35 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
...
@@ -120,11 +168,35 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
CheckTimestamp
();
CheckTimestamp
();
CheckBinary
(
""
,
24
);
CheckBinary
(
""
,
24
);
CheckBinary
(
""
,
24
);
CheckBinary
(
""
,
24
);
}
TEST_F
(
MndTestDnode
,
04
_Drop_Dnode
)
{
{
int32_t
contLen
=
sizeof
(
SDropDnodeReq
);
SDropDnodeReq
*
pReq
=
(
SDropDnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
-
3
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_DNODE_ID
);
}
{
int32_t
contLen
=
sizeof
(
SDropDnodeReq
);
SDropDnodeReq
*
pReq
=
(
SDropDnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
5
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_DNODE_NOT_EXIST
);
}
{
{
int32_t
contLen
=
sizeof
(
SDropDnode
Msg
);
int32_t
contLen
=
sizeof
(
SDropDnode
Req
);
SDropDnode
Msg
*
pReq
=
(
SDropDnodeMsg
*
)
rpcMallocCont
(
contLen
);
SDropDnode
Req
*
pReq
=
(
SDropDnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_DNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_DNODE
,
pReq
,
contLen
);
...
@@ -132,25 +204,42 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
...
@@ -132,25 +204,42 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
ASSERT_EQ
(
pRsp
->
code
,
0
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
}
{
int32_t
contLen
=
sizeof
(
SDropDnodeReq
);
SDropDnodeReq
*
pReq
=
(
SDropDnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_DNODE_NOT_EXIST
);
}
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_DNODE
,
""
);
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_DNODE
,
""
);
CHECK_META
(
"show dnodes"
,
7
);
CHECK_META
(
"show dnodes"
,
7
);
test
.
SendShowRetrieveReq
();
test
.
SendShowRetrieveReq
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckInt16
(
1
);
CheckInt16
(
1
);
CheckBinary
(
"localhost:90
41
"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
23
"
,
TSDB_EP_LEN
);
CheckInt16
(
0
);
CheckInt16
(
0
);
CheckInt16
(
16
);
CheckInt16
(
16
);
CheckBinary
(
"ready"
,
10
);
CheckBinary
(
"ready"
,
10
);
CheckTimestamp
();
CheckTimestamp
();
CheckBinary
(
""
,
24
);
CheckBinary
(
""
,
24
);
taosMsleep
(
2000
);
server2
.
Stop
();
server2
.
DoStart
();
}
TEST_F
(
MndTestDnode
,
05
_Create_Drop_Restart_Dnode
)
{
{
{
int32_t
contLen
=
sizeof
(
SCreateDnode
Msg
);
int32_t
contLen
=
sizeof
(
SCreateDnode
Req
);
SCreateDnode
Msg
*
pReq
=
(
SCreateDnodeMsg
*
)
rpcMallocCont
(
contLen
);
SCreateDnode
Req
*
pReq
=
(
SCreateDnodeReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
pReq
->
port
=
htonl
(
90
43
);
pReq
->
port
=
htonl
(
90
25
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -158,11 +247,11 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
...
@@ -158,11 +247,11 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
}
}
{
{
int32_t
contLen
=
sizeof
(
SCreateDnode
Msg
);
int32_t
contLen
=
sizeof
(
SCreateDnode
Req
);
SCreateDnode
Msg
*
pReq
=
(
SCreateDnodeMsg
*
)
rpcMallocCont
(
contLen
);
SCreateDnode
Req
*
pReq
=
(
SCreateDnodeReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
pReq
->
port
=
htonl
(
90
44
);
pReq
->
port
=
htonl
(
90
26
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -170,11 +259,11 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
...
@@ -170,11 +259,11 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
}
}
{
{
int32_t
contLen
=
sizeof
(
SCreateDnode
Msg
);
int32_t
contLen
=
sizeof
(
SCreateDnode
Req
);
SCreateDnode
Msg
*
pReq
=
(
SCreateDnodeMsg
*
)
rpcMallocCont
(
contLen
);
SCreateDnode
Req
*
pReq
=
(
SCreateDnodeReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
pReq
->
port
=
htonl
(
90
45
);
pReq
->
port
=
htonl
(
90
27
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -191,10 +280,10 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
...
@@ -191,10 +280,10 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
CheckInt16
(
3
);
CheckInt16
(
3
);
CheckInt16
(
4
);
CheckInt16
(
4
);
CheckInt16
(
5
);
CheckInt16
(
5
);
CheckBinary
(
"localhost:90
41
"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
23
"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
43
"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
25
"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
44
"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
26
"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
45
"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
27
"
,
TSDB_EP_LEN
);
CheckInt16
(
0
);
CheckInt16
(
0
);
CheckInt16
(
0
);
CheckInt16
(
0
);
CheckInt16
(
0
);
CheckInt16
(
0
);
...
@@ -234,10 +323,10 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
...
@@ -234,10 +323,10 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
CheckInt16
(
3
);
CheckInt16
(
3
);
CheckInt16
(
4
);
CheckInt16
(
4
);
CheckInt16
(
5
);
CheckInt16
(
5
);
CheckBinary
(
"localhost:90
41
"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
23
"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
43
"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
25
"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
44
"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
26
"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
45
"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
27
"
,
TSDB_EP_LEN
);
CheckInt16
(
0
);
CheckInt16
(
0
);
CheckInt16
(
0
);
CheckInt16
(
0
);
CheckInt16
(
0
);
CheckInt16
(
0
);
...
...
source/dnode/mnode/impl/test/mnode/CMakeLists.txt
0 → 100644
浏览文件 @
dc081e52
aux_source_directory
(
. MTEST_SRC
)
add_executable
(
mnode_test_mnode
${
MTEST_SRC
}
)
target_link_libraries
(
mnode_test_mnode
PUBLIC sut
)
add_test
(
NAME mnode_test_mnode
COMMAND mnode_test_mnode
)
source/dnode/m
gmt
/impl/test/mnode/mnode.cpp
→
source/dnode/m
node
/impl/test/mnode/mnode.cpp
浏览文件 @
dc081e52
/**
/**
* @file
d
node.cpp
* @file
m
node.cpp
* @author slguan (slguan@taosdata.com)
* @author slguan (slguan@taosdata.com)
* @brief
DNODE module dnode-msg
tests
* @brief
MNODE module mnode
tests
* @version
0.1
* @version
1.0
* @date 202
1-12-15
* @date 202
2-01-07
*
*
* @copyright Copyright (c) 202
1
* @copyright Copyright (c) 202
2
*
*
*/
*/
#include "sut.h"
#include "sut.h"
class
D
ndTestMnode
:
public
::
testing
::
Test
{
class
M
ndTestMnode
:
public
::
testing
::
Test
{
public:
public:
void
SetUp
()
override
{}
void
SetUp
()
override
{}
void
TearDown
()
override
{}
void
TearDown
()
override
{}
public:
public:
static
void
SetUpTestSuite
()
{
static
void
SetUpTestSuite
()
{
test
.
Init
(
"/tmp/
dnode_test_mnode1"
,
906
1
);
test
.
Init
(
"/tmp/
mnode_test_mnode1"
,
903
1
);
const
char
*
fqdn
=
"localhost"
;
const
char
*
fqdn
=
"localhost"
;
const
char
*
firstEp
=
"localhost:90
6
1"
;
const
char
*
firstEp
=
"localhost:90
3
1"
;
server2
.
Start
(
"/tmp/
dnode_test_mnode2"
,
fqdn
,
906
2
,
firstEp
);
server2
.
Start
(
"/tmp/
mnode_test_mnode2"
,
fqdn
,
903
2
,
firstEp
);
server3
.
Start
(
"/tmp/
dnode_test_mnode3"
,
fqdn
,
906
3
,
firstEp
);
server3
.
Start
(
"/tmp/
mnode_test_mnode3"
,
fqdn
,
903
3
,
firstEp
);
server4
.
Start
(
"/tmp/
dnode_test_mnode4"
,
fqdn
,
906
4
,
firstEp
);
server4
.
Start
(
"/tmp/
mnode_test_mnode4"
,
fqdn
,
903
4
,
firstEp
);
server5
.
Start
(
"/tmp/
dnode_test_mnode5"
,
fqdn
,
906
5
,
firstEp
);
server5
.
Start
(
"/tmp/
mnode_test_mnode5"
,
fqdn
,
903
5
,
firstEp
);
taosMsleep
(
300
);
taosMsleep
(
300
);
}
}
...
@@ -44,13 +44,13 @@ class DndTestMnode : public ::testing::Test {
...
@@ -44,13 +44,13 @@ class DndTestMnode : public ::testing::Test {
static
TestServer
server5
;
static
TestServer
server5
;
};
};
Testbase
D
ndTestMnode
::
test
;
Testbase
M
ndTestMnode
::
test
;
TestServer
D
ndTestMnode
::
server2
;
TestServer
M
ndTestMnode
::
server2
;
TestServer
D
ndTestMnode
::
server3
;
TestServer
M
ndTestMnode
::
server3
;
TestServer
D
ndTestMnode
::
server4
;
TestServer
M
ndTestMnode
::
server4
;
TestServer
D
ndTestMnode
::
server5
;
TestServer
M
ndTestMnode
::
server5
;
TEST_F
(
D
ndTestMnode
,
01
_ShowDnode
)
{
TEST_F
(
M
ndTestMnode
,
01
_ShowDnode
)
{
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_MNODE
,
""
);
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_MNODE
,
""
);
CHECK_META
(
"show mnodes"
,
5
);
CHECK_META
(
"show mnodes"
,
5
);
...
@@ -64,13 +64,13 @@ TEST_F(DndTestMnode, 01_ShowDnode) {
...
@@ -64,13 +64,13 @@ TEST_F(DndTestMnode, 01_ShowDnode) {
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckInt16
(
1
);
CheckInt16
(
1
);
CheckBinary
(
"localhost:90
6
1"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
3
1"
,
TSDB_EP_LEN
);
CheckBinary
(
"master"
,
12
);
CheckBinary
(
"master"
,
12
);
CheckInt64
(
0
);
CheckInt64
(
0
);
CheckTimestamp
();
CheckTimestamp
();
}
}
TEST_F
(
D
ndTestMnode
,
02
_Create_Mnode_Invalid_Id
)
{
TEST_F
(
M
ndTestMnode
,
02
_Create_Mnode_Invalid_Id
)
{
{
{
int32_t
contLen
=
sizeof
(
SMCreateMnodeMsg
);
int32_t
contLen
=
sizeof
(
SMCreateMnodeMsg
);
...
@@ -83,7 +83,7 @@ TEST_F(DndTestMnode, 02_Create_Mnode_Invalid_Id) {
...
@@ -83,7 +83,7 @@ TEST_F(DndTestMnode, 02_Create_Mnode_Invalid_Id) {
}
}
}
}
TEST_F
(
D
ndTestMnode
,
03
_Create_Mnode_Invalid_Id
)
{
TEST_F
(
M
ndTestMnode
,
03
_Create_Mnode_Invalid_Id
)
{
{
{
int32_t
contLen
=
sizeof
(
SMCreateMnodeMsg
);
int32_t
contLen
=
sizeof
(
SMCreateMnodeMsg
);
...
@@ -96,14 +96,14 @@ TEST_F(DndTestMnode, 03_Create_Mnode_Invalid_Id) {
...
@@ -96,14 +96,14 @@ TEST_F(DndTestMnode, 03_Create_Mnode_Invalid_Id) {
}
}
}
}
TEST_F
(
D
ndTestMnode
,
04
_Create_Mnode
)
{
TEST_F
(
M
ndTestMnode
,
04
_Create_Mnode
)
{
{
{
// create dnode
// create dnode
int32_t
contLen
=
sizeof
(
SCreateDnode
Msg
);
int32_t
contLen
=
sizeof
(
SCreateDnode
Req
);
SCreateDnode
Msg
*
pReq
=
(
SCreateDnodeMsg
*
)
rpcMallocCont
(
contLen
);
SCreateDnode
Req
*
pReq
=
(
SCreateDnodeReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
pReq
->
port
=
htonl
(
90
6
2
);
pReq
->
port
=
htonl
(
90
3
2
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -132,8 +132,8 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
...
@@ -132,8 +132,8 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
CheckInt16
(
1
);
CheckInt16
(
1
);
CheckInt16
(
2
);
CheckInt16
(
2
);
CheckBinary
(
"localhost:90
6
1"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
3
1"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
6
2"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
3
2"
,
TSDB_EP_LEN
);
CheckBinary
(
"master"
,
12
);
CheckBinary
(
"master"
,
12
);
CheckBinary
(
"slave"
,
12
);
CheckBinary
(
"slave"
,
12
);
CheckInt64
(
0
);
CheckInt64
(
0
);
...
@@ -158,16 +158,16 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
...
@@ -158,16 +158,16 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckInt16
(
1
);
CheckInt16
(
1
);
CheckBinary
(
"localhost:90
6
1"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
3
1"
,
TSDB_EP_LEN
);
CheckBinary
(
"master"
,
12
);
CheckBinary
(
"master"
,
12
);
CheckInt64
(
0
);
CheckInt64
(
0
);
CheckTimestamp
();
CheckTimestamp
();
}
}
}
}
// {
// {
// int32_t contLen = sizeof(SDropDnode
Msg
);
// int32_t contLen = sizeof(SDropDnode
Req
);
// SDropDnode
Msg* pReq = (SDropDnodeMsg
*)rpcMallocCont(contLen);
// SDropDnode
Req* pReq = (SDropDnodeReq
*)rpcMallocCont(contLen);
// pReq->dnodeId = htonl(2);
// pReq->dnodeId = htonl(2);
// SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_DNODE, pReq, contLen);
// SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_DNODE, pReq, contLen);
...
@@ -181,7 +181,7 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
...
@@ -181,7 +181,7 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
// EXPECT_EQ(test.GetShowRows(), 1);
// EXPECT_EQ(test.GetShowRows(), 1);
// CheckInt16(1);
// CheckInt16(1);
// CheckBinary("localhost:90
6
1", TSDB_EP_LEN);
// CheckBinary("localhost:90
3
1", TSDB_EP_LEN);
// CheckInt16(0);
// CheckInt16(0);
// CheckInt16(1);
// CheckInt16(1);
// CheckBinary("ready", 10);
// CheckBinary("ready", 10);
...
@@ -189,10 +189,10 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
...
@@ -189,10 +189,10 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
// CheckBinary("", 24);
// CheckBinary("", 24);
// {
// {
// int32_t contLen = sizeof(SCreateDnode
Msg
);
// int32_t contLen = sizeof(SCreateDnode
Req
);
// SCreateDnode
Msg* pReq = (SCreateDnodeMsg
*)rpcMallocCont(contLen);
// SCreateDnode
Req* pReq = (SCreateDnodeReq
*)rpcMallocCont(contLen);
// strcpy(pReq->ep, "localhost:90
6
3");
// strcpy(pReq->ep, "localhost:90
3
3");
// SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
// SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
// ASSERT_NE(pRsp, nullptr);
// ASSERT_NE(pRsp, nullptr);
...
@@ -200,10 +200,10 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
...
@@ -200,10 +200,10 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
// }
// }
// {
// {
// int32_t contLen = sizeof(SCreateDnode
Msg
);
// int32_t contLen = sizeof(SCreateDnode
Req
);
// SCreateDnode
Msg* pReq = (SCreateDnodeMsg
*)rpcMallocCont(contLen);
// SCreateDnode
Req* pReq = (SCreateDnodeReq
*)rpcMallocCont(contLen);
// strcpy(pReq->ep, "localhost:90
6
4");
// strcpy(pReq->ep, "localhost:90
3
4");
// SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
// SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
// ASSERT_NE(pRsp, nullptr);
// ASSERT_NE(pRsp, nullptr);
...
@@ -211,10 +211,10 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
...
@@ -211,10 +211,10 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
// }
// }
// {
// {
// int32_t contLen = sizeof(SCreateDnode
Msg
);
// int32_t contLen = sizeof(SCreateDnode
Req
);
// SCreateDnode
Msg* pReq = (SCreateDnodeMsg
*)rpcMallocCont(contLen);
// SCreateDnode
Req* pReq = (SCreateDnodeReq
*)rpcMallocCont(contLen);
// strcpy(pReq->ep, "localhost:90
6
5");
// strcpy(pReq->ep, "localhost:90
3
5");
// SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
// SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
// ASSERT_NE(pRsp, nullptr);
// ASSERT_NE(pRsp, nullptr);
...
@@ -231,10 +231,10 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
...
@@ -231,10 +231,10 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
// CheckInt16(3);
// CheckInt16(3);
// CheckInt16(4);
// CheckInt16(4);
// CheckInt16(5);
// CheckInt16(5);
// CheckBinary("localhost:90
6
1", TSDB_EP_LEN);
// CheckBinary("localhost:90
3
1", TSDB_EP_LEN);
// CheckBinary("localhost:90
6
3", TSDB_EP_LEN);
// CheckBinary("localhost:90
3
3", TSDB_EP_LEN);
// CheckBinary("localhost:90
6
4", TSDB_EP_LEN);
// CheckBinary("localhost:90
3
4", TSDB_EP_LEN);
// CheckBinary("localhost:90
6
5", TSDB_EP_LEN);
// CheckBinary("localhost:90
3
5", TSDB_EP_LEN);
// CheckInt16(0);
// CheckInt16(0);
// CheckInt16(0);
// CheckInt16(0);
// CheckInt16(0);
// CheckInt16(0);
...
@@ -274,10 +274,10 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
...
@@ -274,10 +274,10 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
// CheckInt16(3);
// CheckInt16(3);
// CheckInt16(4);
// CheckInt16(4);
// CheckInt16(5);
// CheckInt16(5);
// CheckBinary("localhost:90
6
1", TSDB_EP_LEN);
// CheckBinary("localhost:90
3
1", TSDB_EP_LEN);
// CheckBinary("localhost:90
6
3", TSDB_EP_LEN);
// CheckBinary("localhost:90
3
3", TSDB_EP_LEN);
// CheckBinary("localhost:90
6
4", TSDB_EP_LEN);
// CheckBinary("localhost:90
3
4", TSDB_EP_LEN);
// CheckBinary("localhost:90
6
5", TSDB_EP_LEN);
// CheckBinary("localhost:90
3
5", TSDB_EP_LEN);
// CheckInt16(0);
// CheckInt16(0);
// CheckInt16(0);
// CheckInt16(0);
// CheckInt16(0);
// CheckInt16(0);
...
...
source/dnode/m
gmt
/impl/test/profile/CMakeLists.txt
→
source/dnode/m
node
/impl/test/profile/CMakeLists.txt
浏览文件 @
dc081e52
aux_source_directory
(
. PROFILE_SRC
)
aux_source_directory
(
. PROFILE_SRC
)
add_executable
(
d
node_test_profile
${
PROFILE_SRC
}
)
add_executable
(
m
node_test_profile
${
PROFILE_SRC
}
)
target_link_libraries
(
target_link_libraries
(
d
node_test_profile
m
node_test_profile
PUBLIC sut
PUBLIC sut
)
)
add_test
(
add_test
(
NAME
d
node_test_profile
NAME
m
node_test_profile
COMMAND
d
node_test_profile
COMMAND
m
node_test_profile
)
)
source/dnode/m
gmt
/impl/test/profile/profile.cpp
→
source/dnode/m
node
/impl/test/profile/profile.cpp
浏览文件 @
dc081e52
/**
/**
* @file profile.cpp
* @file profile.cpp
* @author slguan (slguan@taosdata.com)
* @author slguan (slguan@taosdata.com)
* @brief
DNODE module profile-msg
tests
* @brief
MNODE module profile
tests
* @version
0.1
* @version
1.0
* @date 202
1-12-15
* @date 202
2-01-06
*
*
* @copyright Copyright (c) 202
1
* @copyright Copyright (c) 202
2
*
*
*/
*/
#include "sut.h"
#include "sut.h"
class
D
ndTestProfile
:
public
::
testing
::
Test
{
class
M
ndTestProfile
:
public
::
testing
::
Test
{
protected:
protected:
static
void
SetUpTestSuite
()
{
test
.
Init
(
"/tmp/
dnode_test_profile"
,
9080
);
}
static
void
SetUpTestSuite
()
{
test
.
Init
(
"/tmp/
mnode_test_profile"
,
9022
);
}
static
void
TearDownTestSuite
()
{
test
.
Cleanup
();
}
static
void
TearDownTestSuite
()
{
test
.
Cleanup
();
}
static
Testbase
test
;
static
Testbase
test
;
...
@@ -24,15 +24,15 @@ class DndTestProfile : public ::testing::Test {
...
@@ -24,15 +24,15 @@ class DndTestProfile : public ::testing::Test {
void
TearDown
()
override
{}
void
TearDown
()
override
{}
};
};
Testbase
D
ndTestProfile
::
test
;
Testbase
M
ndTestProfile
::
test
;
int32_t
D
ndTestProfile
::
connId
;
int32_t
M
ndTestProfile
::
connId
;
TEST_F
(
D
ndTestProfile
,
01
_ConnectMsg
)
{
TEST_F
(
M
ndTestProfile
,
01
_ConnectMsg
)
{
int32_t
contLen
=
sizeof
(
SConnect
Msg
);
int32_t
contLen
=
sizeof
(
SConnect
Req
);
SConnect
Msg
*
pReq
=
(
SConnectMsg
*
)
rpcMallocCont
(
contLen
);
SConnect
Req
*
pReq
=
(
SConnectReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
pid
=
htonl
(
1234
);
pReq
->
pid
=
htonl
(
1234
);
strcpy
(
pReq
->
app
,
"
d
node_test_profile"
);
strcpy
(
pReq
->
app
,
"
m
node_test_profile"
);
strcpy
(
pReq
->
db
,
""
);
strcpy
(
pReq
->
db
,
""
);
SRpcMsg
*
pMsg
=
test
.
SendReq
(
TDMT_MND_CONNECT
,
pReq
,
contLen
);
SRpcMsg
*
pMsg
=
test
.
SendReq
(
TDMT_MND_CONNECT
,
pReq
,
contLen
);
...
@@ -53,18 +53,18 @@ TEST_F(DndTestProfile, 01_ConnectMsg) {
...
@@ -53,18 +53,18 @@ TEST_F(DndTestProfile, 01_ConnectMsg) {
EXPECT_EQ
(
pRsp
->
epSet
.
inUse
,
0
);
EXPECT_EQ
(
pRsp
->
epSet
.
inUse
,
0
);
EXPECT_EQ
(
pRsp
->
epSet
.
numOfEps
,
1
);
EXPECT_EQ
(
pRsp
->
epSet
.
numOfEps
,
1
);
EXPECT_EQ
(
pRsp
->
epSet
.
port
[
0
],
90
80
);
EXPECT_EQ
(
pRsp
->
epSet
.
port
[
0
],
90
22
);
EXPECT_STREQ
(
pRsp
->
epSet
.
fqdn
[
0
],
"localhost"
);
EXPECT_STREQ
(
pRsp
->
epSet
.
fqdn
[
0
],
"localhost"
);
connId
=
pRsp
->
connId
;
connId
=
pRsp
->
connId
;
}
}
TEST_F
(
D
ndTestProfile
,
02
_ConnectMsg_InvalidDB
)
{
TEST_F
(
M
ndTestProfile
,
02
_ConnectMsg_InvalidDB
)
{
int32_t
contLen
=
sizeof
(
SConnect
Msg
);
int32_t
contLen
=
sizeof
(
SConnect
Req
);
SConnect
Msg
*
pReq
=
(
SConnectMsg
*
)
rpcMallocCont
(
contLen
);
SConnect
Req
*
pReq
=
(
SConnectReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
pid
=
htonl
(
1234
);
pReq
->
pid
=
htonl
(
1234
);
strcpy
(
pReq
->
app
,
"
d
node_test_profile"
);
strcpy
(
pReq
->
app
,
"
m
node_test_profile"
);
strcpy
(
pReq
->
db
,
"invalid_db"
);
strcpy
(
pReq
->
db
,
"invalid_db"
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CONNECT
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CONNECT
,
pReq
,
contLen
);
...
@@ -73,7 +73,7 @@ TEST_F(DndTestProfile, 02_ConnectMsg_InvalidDB) {
...
@@ -73,7 +73,7 @@ TEST_F(DndTestProfile, 02_ConnectMsg_InvalidDB) {
ASSERT_EQ
(
pRsp
->
contLen
,
0
);
ASSERT_EQ
(
pRsp
->
contLen
,
0
);
}
}
TEST_F
(
D
ndTestProfile
,
03
_ConnectMsg_Show
)
{
TEST_F
(
M
ndTestProfile
,
03
_ConnectMsg_Show
)
{
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_CONNS
,
""
);
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_CONNS
,
""
);
CHECK_META
(
"show connections"
,
7
);
CHECK_META
(
"show connections"
,
7
);
CHECK_SCHEMA
(
0
,
TSDB_DATA_TYPE_INT
,
4
,
"connId"
);
CHECK_SCHEMA
(
0
,
TSDB_DATA_TYPE_INT
,
4
,
"connId"
);
...
@@ -88,22 +88,22 @@ TEST_F(DndTestProfile, 03_ConnectMsg_Show) {
...
@@ -88,22 +88,22 @@ TEST_F(DndTestProfile, 03_ConnectMsg_Show) {
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckInt32
(
1
);
CheckInt32
(
1
);
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
CheckBinary
(
"
d
node_test_profile"
,
TSDB_APP_NAME_LEN
);
CheckBinary
(
"
m
node_test_profile"
,
TSDB_APP_NAME_LEN
);
CheckInt32
(
1234
);
CheckInt32
(
1234
);
IgnoreBinary
(
TSDB_IPv4ADDR_LEN
+
6
);
IgnoreBinary
(
TSDB_IPv4ADDR_LEN
+
6
);
CheckTimestamp
();
CheckTimestamp
();
CheckTimestamp
();
CheckTimestamp
();
}
}
TEST_F
(
D
ndTestProfile
,
04
_HeartBeatMsg
)
{
TEST_F
(
M
ndTestProfile
,
04
_HeartBeatMsg
)
{
int32_t
contLen
=
sizeof
(
SHeartBeat
Msg
);
int32_t
contLen
=
sizeof
(
SHeartBeat
Req
);
SHeartBeat
Msg
*
pReq
=
(
SHeartBeatMsg
*
)
rpcMallocCont
(
contLen
);
SHeartBeat
Req
*
pReq
=
(
SHeartBeatReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
connId
=
htonl
(
connId
);
pReq
->
connId
=
htonl
(
connId
);
pReq
->
pid
=
htonl
(
1234
);
pReq
->
pid
=
htonl
(
1234
);
pReq
->
numOfQueries
=
htonl
(
0
);
pReq
->
numOfQueries
=
htonl
(
0
);
pReq
->
numOfStreams
=
htonl
(
0
);
pReq
->
numOfStreams
=
htonl
(
0
);
strcpy
(
pReq
->
app
,
"
d
node_test_profile"
);
strcpy
(
pReq
->
app
,
"
m
node_test_profile"
);
SRpcMsg
*
pMsg
=
test
.
SendReq
(
TDMT_MND_HEARTBEAT
,
pReq
,
contLen
);
SRpcMsg
*
pMsg
=
test
.
SendReq
(
TDMT_MND_HEARTBEAT
,
pReq
,
contLen
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_NE
(
pMsg
,
nullptr
);
...
@@ -127,15 +127,15 @@ TEST_F(DndTestProfile, 04_HeartBeatMsg) {
...
@@ -127,15 +127,15 @@ TEST_F(DndTestProfile, 04_HeartBeatMsg) {
EXPECT_EQ
(
pRsp
->
epSet
.
inUse
,
0
);
EXPECT_EQ
(
pRsp
->
epSet
.
inUse
,
0
);
EXPECT_EQ
(
pRsp
->
epSet
.
numOfEps
,
1
);
EXPECT_EQ
(
pRsp
->
epSet
.
numOfEps
,
1
);
EXPECT_EQ
(
pRsp
->
epSet
.
port
[
0
],
90
80
);
EXPECT_EQ
(
pRsp
->
epSet
.
port
[
0
],
90
22
);
EXPECT_STREQ
(
pRsp
->
epSet
.
fqdn
[
0
],
"localhost"
);
EXPECT_STREQ
(
pRsp
->
epSet
.
fqdn
[
0
],
"localhost"
);
}
}
TEST_F
(
D
ndTestProfile
,
05
_KillConnMsg
)
{
TEST_F
(
M
ndTestProfile
,
05
_KillConnMsg
)
{
{
{
int32_t
contLen
=
sizeof
(
SKillConn
Msg
);
int32_t
contLen
=
sizeof
(
SKillConn
Req
);
SKillConn
Msg
*
pReq
=
(
SKillConnMsg
*
)
rpcMallocCont
(
contLen
);
SKillConn
Req
*
pReq
=
(
SKillConnReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
connId
=
htonl
(
connId
);
pReq
->
connId
=
htonl
(
connId
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_KILL_CONN
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_KILL_CONN
,
pReq
,
contLen
);
...
@@ -144,14 +144,14 @@ TEST_F(DndTestProfile, 05_KillConnMsg) {
...
@@ -144,14 +144,14 @@ TEST_F(DndTestProfile, 05_KillConnMsg) {
}
}
{
{
int32_t
contLen
=
sizeof
(
SHeartBeat
Msg
);
int32_t
contLen
=
sizeof
(
SHeartBeat
Req
);
SHeartBeat
Msg
*
pReq
=
(
SHeartBeatMsg
*
)
rpcMallocCont
(
contLen
);
SHeartBeat
Req
*
pReq
=
(
SHeartBeatReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
connId
=
htonl
(
connId
);
pReq
->
connId
=
htonl
(
connId
);
pReq
->
pid
=
htonl
(
1234
);
pReq
->
pid
=
htonl
(
1234
);
pReq
->
numOfQueries
=
htonl
(
0
);
pReq
->
numOfQueries
=
htonl
(
0
);
pReq
->
numOfStreams
=
htonl
(
0
);
pReq
->
numOfStreams
=
htonl
(
0
);
strcpy
(
pReq
->
app
,
"
d
node_test_profile"
);
strcpy
(
pReq
->
app
,
"
m
node_test_profile"
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_HEARTBEAT
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_HEARTBEAT
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -160,11 +160,11 @@ TEST_F(DndTestProfile, 05_KillConnMsg) {
...
@@ -160,11 +160,11 @@ TEST_F(DndTestProfile, 05_KillConnMsg) {
}
}
{
{
int32_t
contLen
=
sizeof
(
SConnect
Msg
);
int32_t
contLen
=
sizeof
(
SConnect
Req
);
SConnect
Msg
*
pReq
=
(
SConnectMsg
*
)
rpcMallocCont
(
contLen
);
SConnect
Req
*
pReq
=
(
SConnectReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
pid
=
htonl
(
1234
);
pReq
->
pid
=
htonl
(
1234
);
strcpy
(
pReq
->
app
,
"
d
node_test_profile"
);
strcpy
(
pReq
->
app
,
"
m
node_test_profile"
);
strcpy
(
pReq
->
db
,
""
);
strcpy
(
pReq
->
db
,
""
);
SRpcMsg
*
pMsg
=
test
.
SendReq
(
TDMT_MND_CONNECT
,
pReq
,
contLen
);
SRpcMsg
*
pMsg
=
test
.
SendReq
(
TDMT_MND_CONNECT
,
pReq
,
contLen
);
...
@@ -185,17 +185,17 @@ TEST_F(DndTestProfile, 05_KillConnMsg) {
...
@@ -185,17 +185,17 @@ TEST_F(DndTestProfile, 05_KillConnMsg) {
EXPECT_EQ
(
pRsp
->
epSet
.
inUse
,
0
);
EXPECT_EQ
(
pRsp
->
epSet
.
inUse
,
0
);
EXPECT_EQ
(
pRsp
->
epSet
.
numOfEps
,
1
);
EXPECT_EQ
(
pRsp
->
epSet
.
numOfEps
,
1
);
EXPECT_EQ
(
pRsp
->
epSet
.
port
[
0
],
90
80
);
EXPECT_EQ
(
pRsp
->
epSet
.
port
[
0
],
90
22
);
EXPECT_STREQ
(
pRsp
->
epSet
.
fqdn
[
0
],
"localhost"
);
EXPECT_STREQ
(
pRsp
->
epSet
.
fqdn
[
0
],
"localhost"
);
connId
=
pRsp
->
connId
;
connId
=
pRsp
->
connId
;
}
}
}
}
TEST_F
(
D
ndTestProfile
,
06
_KillConnMsg_InvalidConn
)
{
TEST_F
(
M
ndTestProfile
,
06
_KillConnMsg_InvalidConn
)
{
int32_t
contLen
=
sizeof
(
SKillConn
Msg
);
int32_t
contLen
=
sizeof
(
SKillConn
Req
);
SKillConn
Msg
*
pReq
=
(
SKillConnMsg
*
)
rpcMallocCont
(
contLen
);
SKillConn
Req
*
pReq
=
(
SKillConnReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
connId
=
htonl
(
2345
);
pReq
->
connId
=
htonl
(
2345
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_KILL_CONN
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_KILL_CONN
,
pReq
,
contLen
);
...
@@ -203,11 +203,11 @@ TEST_F(DndTestProfile, 06_KillConnMsg_InvalidConn) {
...
@@ -203,11 +203,11 @@ TEST_F(DndTestProfile, 06_KillConnMsg_InvalidConn) {
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_CONN_ID
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_CONN_ID
);
}
}
TEST_F
(
D
ndTestProfile
,
07
_KillQueryMsg
)
{
TEST_F
(
M
ndTestProfile
,
07
_KillQueryMsg
)
{
{
{
int32_t
contLen
=
sizeof
(
SKillQuery
Msg
);
int32_t
contLen
=
sizeof
(
SKillQuery
Req
);
SKillQuery
Msg
*
pReq
=
(
SKillQueryMsg
*
)
rpcMallocCont
(
contLen
);
SKillQuery
Req
*
pReq
=
(
SKillQueryReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
connId
=
htonl
(
connId
);
pReq
->
connId
=
htonl
(
connId
);
pReq
->
queryId
=
htonl
(
1234
);
pReq
->
queryId
=
htonl
(
1234
);
...
@@ -218,14 +218,14 @@ TEST_F(DndTestProfile, 07_KillQueryMsg) {
...
@@ -218,14 +218,14 @@ TEST_F(DndTestProfile, 07_KillQueryMsg) {
}
}
{
{
int32_t
contLen
=
sizeof
(
SHeartBeat
Msg
);
int32_t
contLen
=
sizeof
(
SHeartBeat
Req
);
SHeartBeat
Msg
*
pReq
=
(
SHeartBeatMsg
*
)
rpcMallocCont
(
contLen
);
SHeartBeat
Req
*
pReq
=
(
SHeartBeatReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
connId
=
htonl
(
connId
);
pReq
->
connId
=
htonl
(
connId
);
pReq
->
pid
=
htonl
(
1234
);
pReq
->
pid
=
htonl
(
1234
);
pReq
->
numOfQueries
=
htonl
(
0
);
pReq
->
numOfQueries
=
htonl
(
0
);
pReq
->
numOfStreams
=
htonl
(
0
);
pReq
->
numOfStreams
=
htonl
(
0
);
strcpy
(
pReq
->
app
,
"
d
node_test_profile"
);
strcpy
(
pReq
->
app
,
"
m
node_test_profile"
);
SRpcMsg
*
pMsg
=
test
.
SendReq
(
TDMT_MND_HEARTBEAT
,
pReq
,
contLen
);
SRpcMsg
*
pMsg
=
test
.
SendReq
(
TDMT_MND_HEARTBEAT
,
pReq
,
contLen
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_NE
(
pMsg
,
nullptr
);
...
@@ -249,15 +249,15 @@ TEST_F(DndTestProfile, 07_KillQueryMsg) {
...
@@ -249,15 +249,15 @@ TEST_F(DndTestProfile, 07_KillQueryMsg) {
EXPECT_EQ
(
pRsp
->
epSet
.
inUse
,
0
);
EXPECT_EQ
(
pRsp
->
epSet
.
inUse
,
0
);
EXPECT_EQ
(
pRsp
->
epSet
.
numOfEps
,
1
);
EXPECT_EQ
(
pRsp
->
epSet
.
numOfEps
,
1
);
EXPECT_EQ
(
pRsp
->
epSet
.
port
[
0
],
90
80
);
EXPECT_EQ
(
pRsp
->
epSet
.
port
[
0
],
90
22
);
EXPECT_STREQ
(
pRsp
->
epSet
.
fqdn
[
0
],
"localhost"
);
EXPECT_STREQ
(
pRsp
->
epSet
.
fqdn
[
0
],
"localhost"
);
}
}
}
}
TEST_F
(
D
ndTestProfile
,
08
_KillQueryMsg_InvalidConn
)
{
TEST_F
(
M
ndTestProfile
,
08
_KillQueryMsg_InvalidConn
)
{
int32_t
contLen
=
sizeof
(
SKillQuery
Msg
);
int32_t
contLen
=
sizeof
(
SKillQuery
Req
);
SKillQuery
Msg
*
pReq
=
(
SKillQueryMsg
*
)
rpcMallocCont
(
contLen
);
SKillQuery
Req
*
pReq
=
(
SKillQueryReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
connId
=
htonl
(
2345
);
pReq
->
connId
=
htonl
(
2345
);
pReq
->
queryId
=
htonl
(
1234
);
pReq
->
queryId
=
htonl
(
1234
);
...
@@ -266,7 +266,7 @@ TEST_F(DndTestProfile, 08_KillQueryMsg_InvalidConn) {
...
@@ -266,7 +266,7 @@ TEST_F(DndTestProfile, 08_KillQueryMsg_InvalidConn) {
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_CONN_ID
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_CONN_ID
);
}
}
TEST_F
(
D
ndTestProfile
,
09
_KillQueryMsg
)
{
TEST_F
(
M
ndTestProfile
,
09
_KillQueryMsg
)
{
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_QUERIES
,
""
);
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_QUERIES
,
""
);
CHECK_META
(
"show queries"
,
14
);
CHECK_META
(
"show queries"
,
14
);
...
...
source/dnode/mnode/impl/test/qnode/qnode.cpp
浏览文件 @
dc081e52
...
@@ -96,9 +96,9 @@ TEST_F(MndTestQnode, 02_Create_Qnode) {
...
@@ -96,9 +96,9 @@ TEST_F(MndTestQnode, 02_Create_Qnode) {
TEST_F
(
MndTestQnode
,
03
_Drop_Qnode
)
{
TEST_F
(
MndTestQnode
,
03
_Drop_Qnode
)
{
{
{
int32_t
contLen
=
sizeof
(
SCreateDnode
Msg
);
int32_t
contLen
=
sizeof
(
SCreateDnode
Req
);
SCreateDnode
Msg
*
pReq
=
(
SCreateDnodeMsg
*
)
rpcMallocCont
(
contLen
);
SCreateDnode
Req
*
pReq
=
(
SCreateDnodeReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
pReq
->
port
=
htonl
(
9015
);
pReq
->
port
=
htonl
(
9015
);
...
...
source/dnode/mnode/impl/test/show/show.cpp
浏览文件 @
dc081e52
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
class
MndTestShow
:
public
::
testing
::
Test
{
class
MndTestShow
:
public
::
testing
::
Test
{
protected:
protected:
static
void
SetUpTestSuite
()
{
test
.
Init
(
"/tmp/mnode_test_show"
,
902
0
);
}
static
void
SetUpTestSuite
()
{
test
.
Init
(
"/tmp/mnode_test_show"
,
902
1
);
}
static
void
TearDownTestSuite
()
{
test
.
Cleanup
();
}
static
void
TearDownTestSuite
()
{
test
.
Cleanup
();
}
static
Testbase
test
;
static
Testbase
test
;
...
@@ -50,9 +50,9 @@ TEST_F(MndTestShow, 02_ShowMsg_InvalidMsgStart) {
...
@@ -50,9 +50,9 @@ TEST_F(MndTestShow, 02_ShowMsg_InvalidMsgStart) {
}
}
TEST_F
(
MndTestShow
,
03
_ShowMsg_Conn
)
{
TEST_F
(
MndTestShow
,
03
_ShowMsg_Conn
)
{
int32_t
contLen
=
sizeof
(
SConnect
Msg
);
int32_t
contLen
=
sizeof
(
SConnect
Req
);
SConnect
Msg
*
pReq
=
(
SConnectMsg
*
)
rpcMallocCont
(
contLen
);
SConnect
Req
*
pReq
=
(
SConnectReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
pid
=
htonl
(
1234
);
pReq
->
pid
=
htonl
(
1234
);
strcpy
(
pReq
->
app
,
"mnode_test_show"
);
strcpy
(
pReq
->
app
,
"mnode_test_show"
);
strcpy
(
pReq
->
db
,
""
);
strcpy
(
pReq
->
db
,
""
);
...
...
source/dnode/mnode/impl/test/snode/snode.cpp
浏览文件 @
dc081e52
...
@@ -96,9 +96,9 @@ TEST_F(MndTestSnode, 02_Create_Snode) {
...
@@ -96,9 +96,9 @@ TEST_F(MndTestSnode, 02_Create_Snode) {
TEST_F
(
MndTestSnode
,
03
_Drop_Snode
)
{
TEST_F
(
MndTestSnode
,
03
_Drop_Snode
)
{
{
{
int32_t
contLen
=
sizeof
(
SCreateDnode
Msg
);
int32_t
contLen
=
sizeof
(
SCreateDnode
Req
);
SCreateDnode
Msg
*
pReq
=
(
SCreateDnodeMsg
*
)
rpcMallocCont
(
contLen
);
SCreateDnode
Req
*
pReq
=
(
SCreateDnodeReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
pReq
->
port
=
htonl
(
9017
);
pReq
->
port
=
htonl
(
9017
);
...
...
source/dnode/mnode/impl/test/trans/trans.cpp
浏览文件 @
dc081e52
...
@@ -133,9 +133,9 @@ TEST_F(MndTestTrans, 02_Create_Qnode1_Crash) {
...
@@ -133,9 +133,9 @@ TEST_F(MndTestTrans, 02_Create_Qnode1_Crash) {
TEST_F
(
MndTestTrans
,
03
_Create_Qnode2_Crash
)
{
TEST_F
(
MndTestTrans
,
03
_Create_Qnode2_Crash
)
{
{
{
int32_t
contLen
=
sizeof
(
SCreateDnode
Msg
);
int32_t
contLen
=
sizeof
(
SCreateDnode
Req
);
SCreateDnode
Msg
*
pReq
=
(
SCreateDnodeMsg
*
)
rpcMallocCont
(
contLen
);
SCreateDnode
Req
*
pReq
=
(
SCreateDnodeReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
pReq
->
port
=
htonl
(
9020
);
pReq
->
port
=
htonl
(
9020
);
...
...
source/dnode/mnode/sdb/src/sdbHash.c
浏览文件 @
dc081e52
...
@@ -429,3 +429,12 @@ int32_t sdbGetMaxId(SSdb *pSdb, ESdbType type) {
...
@@ -429,3 +429,12 @@ int32_t sdbGetMaxId(SSdb *pSdb, ESdbType type) {
maxId
=
MAX
(
maxId
,
pSdb
->
maxId
[
type
]);
maxId
=
MAX
(
maxId
,
pSdb
->
maxId
[
type
]);
return
maxId
+
1
;
return
maxId
+
1
;
}
}
int64_t
sdbGetTableVer
(
SSdb
*
pSdb
,
ESdbType
type
)
{
if
(
type
>=
SDB_MAX
||
type
<
0
)
{
terrno
=
TSDB_CODE_SDB_INVALID_TABLE_TYPE
;
return
-
1
;
}
return
pSdb
->
tableVer
[
type
];
}
source/libs/catalog/src/catalog.c
浏览文件 @
dc081e52
...
@@ -302,6 +302,7 @@ int32_t ctgGetVgInfoFromHashValue(SDBVgroupInfo *dbInfo, const SName *pTableName
...
@@ -302,6 +302,7 @@ int32_t ctgGetVgInfoFromHashValue(SDBVgroupInfo *dbInfo, const SName *pTableName
while
(
pIter
)
{
while
(
pIter
)
{
vgInfo
=
pIter
;
vgInfo
=
pIter
;
if
(
hashValue
>=
vgInfo
->
hashBegin
&&
hashValue
<=
vgInfo
->
hashEnd
)
{
if
(
hashValue
>=
vgInfo
->
hashBegin
&&
hashValue
<=
vgInfo
->
hashEnd
)
{
taosHashCancelIterate
(
dbInfo
->
vgInfo
,
pIter
);
break
;
break
;
}
}
...
@@ -309,6 +310,8 @@ int32_t ctgGetVgInfoFromHashValue(SDBVgroupInfo *dbInfo, const SName *pTableName
...
@@ -309,6 +310,8 @@ int32_t ctgGetVgInfoFromHashValue(SDBVgroupInfo *dbInfo, const SName *pTableName
vgInfo
=
NULL
;
vgInfo
=
NULL
;
}
}
ctgInfo
(
"numOfVgroup:%d"
,
taosHashGetSize
(
dbInfo
->
vgInfo
));
if
(
NULL
==
vgInfo
)
{
if
(
NULL
==
vgInfo
)
{
ctgError
(
"no hash range found for hash value [%u], numOfVgId:%d"
,
hashValue
,
taosHashGetSize
(
dbInfo
->
vgInfo
));
ctgError
(
"no hash range found for hash value [%u], numOfVgId:%d"
,
hashValue
,
taosHashGetSize
(
dbInfo
->
vgInfo
));
...
@@ -325,7 +328,7 @@ int32_t ctgGetVgInfoFromHashValue(SDBVgroupInfo *dbInfo, const SName *pTableName
...
@@ -325,7 +328,7 @@ int32_t ctgGetVgInfoFromHashValue(SDBVgroupInfo *dbInfo, const SName *pTableName
*
pVgroup
=
*
vgInfo
;
*
pVgroup
=
*
vgInfo
;
_return:
_return:
CTG_RET
(
TSDB_CODE_SUCCESS
);
CTG_RET
(
code
);
}
}
int32_t
ctgGetTableMetaImpl
(
struct
SCatalog
*
pCatalog
,
void
*
pRpc
,
const
SEpSet
*
pMgmtEps
,
const
SName
*
pTableName
,
bool
forceUpdate
,
STableMeta
**
pTableMeta
)
{
int32_t
ctgGetTableMetaImpl
(
struct
SCatalog
*
pCatalog
,
void
*
pRpc
,
const
SEpSet
*
pMgmtEps
,
const
SName
*
pTableName
,
bool
forceUpdate
,
STableMeta
**
pTableMeta
)
{
...
@@ -424,33 +427,30 @@ int32_t ctgUpdateTableMetaCache(struct SCatalog *pCatalog, STableMetaOutput *out
...
@@ -424,33 +427,30 @@ int32_t ctgUpdateTableMetaCache(struct SCatalog *pCatalog, STableMetaOutput *out
CTG_RET
(
code
);
CTG_RET
(
code
);
}
}
int32_t
ctgGetDBVgroup
(
struct
SCatalog
*
pCatalog
,
void
*
pRpc
,
const
SEpSet
*
pMgmtEps
,
const
char
*
dbName
,
bool
forceUpdate
,
SDBVgroupInfo
**
dbInfo
)
{
int32_t
ctgGetDBVgroup
(
struct
SCatalog
*
pCatalog
,
void
*
pRpc
,
const
SEpSet
*
pMgmtEps
,
const
char
*
dbName
,
int32_t
forceUpdate
,
SDBVgroupInfo
**
dbInfo
)
{
bool
inCache
=
false
;
bool
inCache
=
false
;
if
(
0
==
forceUpdate
)
{
if
(
!
forceUpdate
)
{
CTG_ERR_RET
(
ctgGetDBVgroupFromCache
(
pCatalog
,
dbName
,
dbInfo
,
&
inCache
));
CTG_ERR_RET
(
ctgGetDBVgroupFromCache
(
pCatalog
,
dbName
,
dbInfo
,
&
inCache
));
if
(
inCache
)
{
if
(
inCache
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
ctgDebug
(
"failed to get DB vgroupInfo from cache, dbName:%s, load it from mnode, update:%d"
,
dbName
,
forceUpdate
);
}
}
SUseDbOutput
DbOut
=
{
0
};
SUseDbOutput
DbOut
=
{
0
};
SBuildUseDBInput
input
=
{
0
};
SBuildUseDBInput
input
=
{
0
};
strncpy
(
input
.
db
,
dbName
,
sizeof
(
input
.
db
));
tstrncpy
(
input
.
db
,
dbName
,
tListLen
(
input
.
db
));
input
.
db
[
sizeof
(
input
.
db
)
-
1
]
=
0
;
input
.
vgVersion
=
CTG_DEFAULT_INVALID_VERSION
;
input
.
vgVersion
=
CTG_DEFAULT_INVALID_VERSION
;
while
(
true
)
{
while
(
true
)
{
CTG_ERR_RET
(
ctgGetDBVgroupFromMnode
(
pCatalog
,
pRpc
,
pMgmtEps
,
&
input
,
&
DbOut
));
CTG_ERR_RET
(
ctgGetDBVgroupFromMnode
(
pCatalog
,
pRpc
,
pMgmtEps
,
&
input
,
&
DbOut
));
CTG_ERR_RET
(
catalogUpdateDBVgroup
(
pCatalog
,
dbName
,
&
DbOut
.
dbVgroup
));
CTG_ERR_RET
(
catalogUpdateDBVgroup
(
pCatalog
,
dbName
,
&
DbOut
.
dbVgroup
));
CTG_ERR_RET
(
ctgGetDBVgroupFromCache
(
pCatalog
,
dbName
,
dbInfo
,
&
inCache
));
CTG_ERR_RET
(
ctgGetDBVgroupFromCache
(
pCatalog
,
dbName
,
dbInfo
,
&
inCache
));
if
(
!
inCache
)
{
if
(
!
inCache
)
{
ctgWarn
(
"get
db vgroup from cache failed, db
:%s"
,
dbName
);
ctgWarn
(
"get
DB vgroupInfo from cache failed, dbName
:%s"
,
dbName
);
continue
;
continue
;
}
}
...
@@ -573,14 +573,15 @@ int32_t catalogGetDBVgroupVersion(struct SCatalog* pCatalog, const char* dbName,
...
@@ -573,14 +573,15 @@ int32_t catalogGetDBVgroupVersion(struct SCatalog* pCatalog, const char* dbName,
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
catalogGetDBVgroup
(
struct
SCatalog
*
pCatalog
,
void
*
pRpc
,
const
SEpSet
*
pMgmtEps
,
const
char
*
dbName
,
int32_t
forceUpdate
,
SArray
**
vgroupList
)
{
int32_t
catalogGetDBVgroup
(
struct
SCatalog
*
pCatalog
,
void
*
pRpc
,
const
SEpSet
*
pMgmtEps
,
const
char
*
dbName
,
bool
forceUpdate
,
SArray
**
vgroupList
)
{
if
(
NULL
==
pCatalog
||
NULL
==
dbName
||
NULL
==
pRpc
||
NULL
==
pMgmtEps
||
NULL
==
vgroupList
)
{
if
(
NULL
==
pCatalog
||
NULL
==
dbName
||
NULL
==
pRpc
||
NULL
==
pMgmtEps
||
NULL
==
vgroupList
)
{
CTG_ERR_RET
(
TSDB_CODE_CTG_INVALID_INPUT
);
CTG_ERR_RET
(
TSDB_CODE_CTG_INVALID_INPUT
);
}
}
SDBVgroupInfo
*
db
=
NULL
;
SDBVgroupInfo
*
db
=
NULL
;
int32_t
code
=
0
;
SVgroupInfo
*
vgInfo
=
NULL
;
SVgroupInfo
*
vgInfo
=
NULL
;
int32_t
code
=
0
;
SArray
*
vgList
=
NULL
;
SArray
*
vgList
=
NULL
;
CTG_ERR_JRET
(
ctgGetDBVgroup
(
pCatalog
,
pRpc
,
pMgmtEps
,
dbName
,
forceUpdate
,
&
db
));
CTG_ERR_JRET
(
ctgGetDBVgroup
(
pCatalog
,
pRpc
,
pMgmtEps
,
dbName
,
forceUpdate
,
&
db
));
...
@@ -776,7 +777,6 @@ int32_t catalogGetTableHashVgroup(struct SCatalog *pCatalog, void *pTransporter,
...
@@ -776,7 +777,6 @@ int32_t catalogGetTableHashVgroup(struct SCatalog *pCatalog, void *pTransporter,
tNameGetFullDbName
(
pTableName
,
db
);
tNameGetFullDbName
(
pTableName
,
db
);
CTG_ERR_RET
(
ctgGetDBVgroup
(
pCatalog
,
pTransporter
,
pMgmtEps
,
db
,
false
,
&
dbInfo
));
CTG_ERR_RET
(
ctgGetDBVgroup
(
pCatalog
,
pTransporter
,
pMgmtEps
,
db
,
false
,
&
dbInfo
));
CTG_ERR_JRET
(
ctgGetVgInfoFromHashValue
(
dbInfo
,
pTableName
,
pVgroup
));
CTG_ERR_JRET
(
ctgGetVgInfoFromHashValue
(
dbInfo
,
pTableName
,
pVgroup
));
_return:
_return:
...
...
source/libs/parser/inc/astToMsg.h
浏览文件 @
dc081e52
...
@@ -12,7 +12,7 @@ SShowReq* buildShowMsg(SShowInfo* pShowInfo, SParseBasicCtx* pParseCtx, char* ms
...
@@ -12,7 +12,7 @@ SShowReq* buildShowMsg(SShowInfo* pShowInfo, SParseBasicCtx* pParseCtx, char* ms
SCreateDbMsg
*
buildCreateDbMsg
(
SCreateDbInfo
*
pCreateDbInfo
,
SParseBasicCtx
*
pCtx
,
SMsgBuf
*
pMsgBuf
);
SCreateDbMsg
*
buildCreateDbMsg
(
SCreateDbInfo
*
pCreateDbInfo
,
SParseBasicCtx
*
pCtx
,
SMsgBuf
*
pMsgBuf
);
SCreateStbMsg
*
buildCreateStbMsg
(
SCreateTableSql
*
pCreateTableSql
,
int32_t
*
len
,
SParseBasicCtx
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
);
SCreateStbMsg
*
buildCreateStbMsg
(
SCreateTableSql
*
pCreateTableSql
,
int32_t
*
len
,
SParseBasicCtx
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
);
SDropStbMsg
*
buildDropStableMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
len
,
SParseBasicCtx
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
);
SDropStbMsg
*
buildDropStableMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
len
,
SParseBasicCtx
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
);
SCreateDnode
Msg
*
buildCreateDnodeMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
len
,
SMsgBuf
*
pMsgBuf
);
SCreateDnode
Req
*
buildCreateDnodeMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
len
,
SMsgBuf
*
pMsgBuf
);
SDropDnode
Msg
*
buildDropDnodeMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
len
,
SMsgBuf
*
pMsgBuf
);
SDropDnode
Req
*
buildDropDnodeMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
len
,
SMsgBuf
*
pMsgBuf
);
#endif // TDENGINE_ASTTOMSG_H
#endif // TDENGINE_ASTTOMSG_H
source/libs/parser/src/astToMsg.c
浏览文件 @
dc081e52
...
@@ -335,7 +335,7 @@ SDropStbMsg* buildDropStableMsg(SSqlInfo* pInfo, int32_t* len, SParseBasicCtx* p
...
@@ -335,7 +335,7 @@ SDropStbMsg* buildDropStableMsg(SSqlInfo* pInfo, int32_t* len, SParseBasicCtx* p
return
pDropTableMsg
;
return
pDropTableMsg
;
}
}
SCreateDnode
Msg
*
buildCreateDnodeMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
len
,
SMsgBuf
*
pMsgBuf
)
{
SCreateDnode
Req
*
buildCreateDnodeMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
len
,
SMsgBuf
*
pMsgBuf
)
{
const
char
*
msg1
=
"invalid host name (name too long, maximum length 128)"
;
const
char
*
msg1
=
"invalid host name (name too long, maximum length 128)"
;
const
char
*
msg2
=
"dnode name can not be string"
;
const
char
*
msg2
=
"dnode name can not be string"
;
const
char
*
msg3
=
"port should be an integer that is less than 65535 and greater than 0"
;
const
char
*
msg3
=
"port should be an integer that is less than 65535 and greater than 0"
;
...
@@ -367,7 +367,7 @@ SCreateDnodeMsg *buildCreateDnodeMsg(SSqlInfo* pInfo, int32_t* len, SMsgBuf* pMs
...
@@ -367,7 +367,7 @@ SCreateDnodeMsg *buildCreateDnodeMsg(SSqlInfo* pInfo, int32_t* len, SMsgBuf* pMs
return
NULL
;
return
NULL
;
}
}
SCreateDnode
Msg
*
pCreate
=
(
SCreateDnodeMsg
*
)
calloc
(
1
,
sizeof
(
SCreateDnodeMsg
));
SCreateDnode
Req
*
pCreate
=
(
SCreateDnodeReq
*
)
calloc
(
1
,
sizeof
(
SCreateDnodeReq
));
if
(
pCreate
==
NULL
)
{
if
(
pCreate
==
NULL
)
{
buildInvalidOperationMsg
(
pMsgBuf
,
msg4
);
buildInvalidOperationMsg
(
pMsgBuf
,
msg4
);
return
NULL
;
return
NULL
;
...
@@ -376,18 +376,18 @@ SCreateDnodeMsg *buildCreateDnodeMsg(SSqlInfo* pInfo, int32_t* len, SMsgBuf* pMs
...
@@ -376,18 +376,18 @@ SCreateDnodeMsg *buildCreateDnodeMsg(SSqlInfo* pInfo, int32_t* len, SMsgBuf* pMs
strncpy
(
pCreate
->
fqdn
,
id
->
z
,
id
->
n
);
strncpy
(
pCreate
->
fqdn
,
id
->
z
,
id
->
n
);
pCreate
->
port
=
htonl
(
val
);
pCreate
->
port
=
htonl
(
val
);
*
len
=
sizeof
(
SCreateDnode
Msg
);
*
len
=
sizeof
(
SCreateDnode
Req
);
return
pCreate
;
return
pCreate
;
}
}
SDropDnode
Msg
*
buildDropDnodeMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
len
,
SMsgBuf
*
pMsgBuf
)
{
SDropDnode
Req
*
buildDropDnodeMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
len
,
SMsgBuf
*
pMsgBuf
)
{
SToken
*
pzName
=
taosArrayGet
(
pInfo
->
pMiscInfo
->
a
,
0
);
SToken
*
pzName
=
taosArrayGet
(
pInfo
->
pMiscInfo
->
a
,
0
);
char
*
end
=
NULL
;
char
*
end
=
NULL
;
SDropDnode
Msg
*
pDrop
=
(
SDropDnodeMsg
*
)
calloc
(
1
,
sizeof
(
SDropDnodeMsg
));
SDropDnode
Req
*
pDrop
=
(
SDropDnodeReq
*
)
calloc
(
1
,
sizeof
(
SDropDnodeReq
));
pDrop
->
dnodeId
=
strtoll
(
pzName
->
z
,
&
end
,
10
);
pDrop
->
dnodeId
=
strtoll
(
pzName
->
z
,
&
end
,
10
);
pDrop
->
dnodeId
=
htonl
(
pDrop
->
dnodeId
);
pDrop
->
dnodeId
=
htonl
(
pDrop
->
dnodeId
);
*
len
=
sizeof
(
SDropDnode
Msg
);
*
len
=
sizeof
(
SDropDnode
Req
);
if
(
end
-
pzName
->
z
!=
pzName
->
n
)
{
if
(
end
-
pzName
->
z
!=
pzName
->
n
)
{
buildInvalidOperationMsg
(
pMsgBuf
,
"invalid dnode id"
);
buildInvalidOperationMsg
(
pMsgBuf
,
"invalid dnode id"
);
...
...
source/libs/parser/src/astValidate.c
浏览文件 @
dc081e52
...
@@ -3819,7 +3819,7 @@ int32_t qParserValidateSqlNode(struct SCatalog* pCatalog, SSqlInfo* pInfo, SQuer
...
@@ -3819,7 +3819,7 @@ int32_t qParserValidateSqlNode(struct SCatalog* pCatalog, SSqlInfo* pInfo, SQuer
char* pMsg = pCmd->payload;
char* pMsg = pCmd->payload;
S
CfgDnodeMsg* pCfg = (SCfgDnodeMsg
*)pMsg;
S
MCfgDnodeReq* pCfg = (SMCfgDnodeReq
*)pMsg;
SToken* t0 = taosArrayGet(pMiscInfo->a, 0);
SToken* t0 = taosArrayGet(pMiscInfo->a, 0);
SToken* t1 = taosArrayGet(pMiscInfo->a, 1);
SToken* t1 = taosArrayGet(pMiscInfo->a, 1);
...
...
source/libs/parser/src/dCDAstProcess.c
浏览文件 @
dc081e52
...
@@ -43,7 +43,7 @@ static int32_t setShowInfo(SShowInfo* pShowInfo, SParseBasicCtx* pCtx, void** ou
...
@@ -43,7 +43,7 @@ static int32_t setShowInfo(SShowInfo* pShowInfo, SParseBasicCtx* pCtx, void** ou
char
dbFname
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
char
dbFname
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
tNameGetFullDbName
(
&
name
,
dbFname
);
tNameGetFullDbName
(
&
name
,
dbFname
);
catalogGetDBVgroup
(
pCtx
->
pCatalog
,
pCtx
->
pTransporter
,
&
pCtx
->
mgmtEpSet
,
dbFname
,
0
,
&
array
);
catalogGetDBVgroup
(
pCtx
->
pCatalog
,
pCtx
->
pTransporter
,
&
pCtx
->
mgmtEpSet
,
dbFname
,
false
,
&
array
);
SVgroupInfo
*
info
=
taosArrayGet
(
array
,
0
);
SVgroupInfo
*
info
=
taosArrayGet
(
array
,
0
);
pShowReq
->
head
.
vgId
=
htonl
(
info
->
vgId
);
pShowReq
->
head
.
vgId
=
htonl
(
info
->
vgId
);
...
...
source/util/src/thash.c
浏览文件 @
dc081e52
...
@@ -799,6 +799,11 @@ FORCE_INLINE int32_t taosHashGetKey(void *data, void** key, size_t* keyLen) {
...
@@ -799,6 +799,11 @@ FORCE_INLINE int32_t taosHashGetKey(void *data, void** key, size_t* keyLen) {
return
0
;
return
0
;
}
}
FORCE_INLINE
int32_t
taosHashGetDataLen
(
void
*
data
)
{
SHashNode
*
node
=
GET_HASH_PNODE
(
data
);
return
node
->
keyLen
;
}
FORCE_INLINE
uint32_t
taosHashGetDataKeyLen
(
SHashObj
*
pHashObj
,
void
*
data
)
{
FORCE_INLINE
uint32_t
taosHashGetDataKeyLen
(
SHashObj
*
pHashObj
,
void
*
data
)
{
SHashNode
*
node
=
GET_HASH_PNODE
(
data
);
SHashNode
*
node
=
GET_HASH_PNODE
(
data
);
return
node
->
keyLen
;
return
node
->
keyLen
;
...
...
src/client/src/tscProfile.c
浏览文件 @
dc081e52
...
@@ -226,7 +226,7 @@ void tscKillStream(STscObj *pObj, uint32_t killId) {
...
@@ -226,7 +226,7 @@ void tscKillStream(STscObj *pObj, uint32_t killId) {
}
}
int
tscBuildQueryStreamDesc
(
void
*
pMsg
,
STscObj
*
pObj
)
{
int
tscBuildQueryStreamDesc
(
void
*
pMsg
,
STscObj
*
pObj
)
{
SHeartBeat
Msg
*
pHeartbeat
=
pMsg
;
SHeartBeat
Req
*
pHeartbeat
=
pMsg
;
int
allocedQueriesNum
=
pHeartbeat
->
numOfQueries
;
int
allocedQueriesNum
=
pHeartbeat
->
numOfQueries
;
int
allocedStreamsNum
=
pHeartbeat
->
numOfStreams
;
int
allocedStreamsNum
=
pHeartbeat
->
numOfStreams
;
...
@@ -327,7 +327,7 @@ int tscBuildQueryStreamDesc(void *pMsg, STscObj *pObj) {
...
@@ -327,7 +327,7 @@ int tscBuildQueryStreamDesc(void *pMsg, STscObj *pObj) {
}
}
int32_t
msgLen
=
pHeartbeat
->
numOfQueries
*
sizeof
(
SQueryDesc
)
+
pHeartbeat
->
numOfStreams
*
sizeof
(
SStreamDesc
)
+
int32_t
msgLen
=
pHeartbeat
->
numOfQueries
*
sizeof
(
SQueryDesc
)
+
pHeartbeat
->
numOfStreams
*
sizeof
(
SStreamDesc
)
+
sizeof
(
SHeartBeat
Msg
);
sizeof
(
SHeartBeat
Req
);
pHeartbeat
->
connId
=
htonl
(
pObj
->
connId
);
pHeartbeat
->
connId
=
htonl
(
pObj
->
connId
);
pHeartbeat
->
numOfQueries
=
htonl
(
pHeartbeat
->
numOfQueries
);
pHeartbeat
->
numOfQueries
=
htonl
(
pHeartbeat
->
numOfQueries
);
pHeartbeat
->
numOfStreams
=
htonl
(
pHeartbeat
->
numOfStreams
);
pHeartbeat
->
numOfStreams
=
htonl
(
pHeartbeat
->
numOfStreams
);
...
...
src/client/src/tscSQLParser.c
浏览文件 @
dc081e52
...
@@ -776,7 +776,7 @@ int32_t tscValidateSqlInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
...
@@ -776,7 +776,7 @@ int32_t tscValidateSqlInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
char
*
pMsg
=
pCmd
->
payload
;
char
*
pMsg
=
pCmd
->
payload
;
S
CfgDnodeMsg
*
pCfg
=
(
SCfgDnodeMsg
*
)
pMsg
;
S
MCfgDnodeReq
*
pCfg
=
(
SMCfgDnodeReq
*
)
pMsg
;
SStrToken
*
t0
=
taosArrayGet
(
pMiscInfo
->
a
,
0
);
SStrToken
*
t0
=
taosArrayGet
(
pMiscInfo
->
a
,
0
);
SStrToken
*
t1
=
taosArrayGet
(
pMiscInfo
->
a
,
1
);
SStrToken
*
t1
=
taosArrayGet
(
pMiscInfo
->
a
,
1
);
...
...
src/client/src/tscServer.c
浏览文件 @
dc081e52
...
@@ -1192,13 +1192,13 @@ int32_t tscBuildCreateFuncMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -1192,13 +1192,13 @@ int32_t tscBuildCreateFuncMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
int32_t
tscBuildCreateDnodeMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
int32_t
tscBuildCreateDnodeMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
pCmd
->
payloadLen
=
sizeof
(
SCreateDnode
Msg
);
pCmd
->
payloadLen
=
sizeof
(
SCreateDnode
Req
);
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
pCmd
->
payloadLen
))
{
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
pCmd
->
payloadLen
))
{
tscError
(
"0x%"
PRIx64
" failed to malloc for query msg"
,
pSql
->
self
);
tscError
(
"0x%"
PRIx64
" failed to malloc for query msg"
,
pSql
->
self
);
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
}
SCreateDnode
Msg
*
pCreate
=
(
SCreateDnodeMsg
*
)
pCmd
->
payload
;
SCreateDnode
Req
*
pCreate
=
(
SCreateDnodeReq
*
)
pCmd
->
payload
;
SStrToken
*
t0
=
taosArrayGet
(
pInfo
->
pMiscInfo
->
a
,
0
);
SStrToken
*
t0
=
taosArrayGet
(
pInfo
->
pMiscInfo
->
a
,
0
);
strncpy
(
pCreate
->
ep
,
t0
->
z
,
t0
->
n
);
strncpy
(
pCreate
->
ep
,
t0
->
z
,
t0
->
n
);
...
@@ -1287,7 +1287,7 @@ int32_t tscBuildUserMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -1287,7 +1287,7 @@ int32_t tscBuildUserMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
int32_t
tscBuildCfgDnodeMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
int32_t
tscBuildCfgDnodeMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
pCmd
->
payloadLen
=
sizeof
(
S
CfgDnodeMsg
);
pCmd
->
payloadLen
=
sizeof
(
S
MCfgDnodeReq
);
pCmd
->
msgType
=
TDMT_MND_CONFIG_DNODE
;
pCmd
->
msgType
=
TDMT_MND_CONFIG_DNODE
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -1350,13 +1350,13 @@ int32_t tscBuildDropDnodeMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -1350,13 +1350,13 @@ int32_t tscBuildDropDnodeMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
char
dnodeEp
[
TSDB_EP_LEN
]
=
{
0
};
char
dnodeEp
[
TSDB_EP_LEN
]
=
{
0
};
tstrncpy
(
dnodeEp
,
pCmd
->
payload
,
TSDB_EP_LEN
);
tstrncpy
(
dnodeEp
,
pCmd
->
payload
,
TSDB_EP_LEN
);
pCmd
->
payloadLen
=
sizeof
(
SDropDnode
Msg
);
pCmd
->
payloadLen
=
sizeof
(
SDropDnode
Req
);
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
pCmd
->
payloadLen
))
{
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
pCmd
->
payloadLen
))
{
tscError
(
"0x%"
PRIx64
" failed to malloc for query msg"
,
pSql
->
self
);
tscError
(
"0x%"
PRIx64
" failed to malloc for query msg"
,
pSql
->
self
);
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
}
SDropDnode
Msg
*
pDrop
=
(
SDropDnodeMsg
*
)
pCmd
->
payload
;
SDropDnode
Req
*
pDrop
=
(
SDropDnodeReq
*
)
pCmd
->
payload
;
tstrncpy
(
pDrop
->
ep
,
dnodeEp
,
tListLen
(
pDrop
->
ep
));
tstrncpy
(
pDrop
->
ep
,
dnodeEp
,
tListLen
(
pDrop
->
ep
));
pCmd
->
msgType
=
TDMT_MND_DROP_DNODE
;
pCmd
->
msgType
=
TDMT_MND_DROP_DNODE
;
...
@@ -1469,7 +1469,7 @@ int32_t tscBuildShowMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -1469,7 +1469,7 @@ int32_t tscBuildShowMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
int32_t
tscBuildKillMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
int32_t
tscBuildKillMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
pCmd
->
payloadLen
=
sizeof
(
SKillQuery
Msg
);
pCmd
->
payloadLen
=
sizeof
(
SKillQuery
Req
);
switch
(
pCmd
->
command
)
{
switch
(
pCmd
->
command
)
{
case
TSDB_SQL_KILL_QUERY
:
case
TSDB_SQL_KILL_QUERY
:
...
@@ -1862,14 +1862,14 @@ int tscBuildConnectMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -1862,14 +1862,14 @@ int tscBuildConnectMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
STscObj
*
pObj
=
pSql
->
pTscObj
;
STscObj
*
pObj
=
pSql
->
pTscObj
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
pCmd
->
msgType
=
TDMT_MND_CONNECT
;
pCmd
->
msgType
=
TDMT_MND_CONNECT
;
pCmd
->
payloadLen
=
sizeof
(
SConnect
Msg
);
pCmd
->
payloadLen
=
sizeof
(
SConnect
Req
);
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
pCmd
->
payloadLen
))
{
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
pCmd
->
payloadLen
))
{
tscError
(
"0x%"
PRIx64
" failed to malloc for query msg"
,
pSql
->
self
);
tscError
(
"0x%"
PRIx64
" failed to malloc for query msg"
,
pSql
->
self
);
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
}
SConnect
Msg
*
pConnect
=
(
SConnectMsg
*
)
pCmd
->
payload
;
SConnect
Req
*
pConnect
=
(
SConnectReq
*
)
pCmd
->
payload
;
// TODO refactor full_name
// TODO refactor full_name
char
*
db
;
// ugly code to move the space
char
*
db
;
// ugly code to move the space
...
@@ -1974,7 +1974,7 @@ int tscBuildHeartBeatMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -1974,7 +1974,7 @@ int tscBuildHeartBeatMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
numOfStreams
++
;
numOfStreams
++
;
}
}
int
size
=
numOfQueries
*
sizeof
(
SQueryDesc
)
+
numOfStreams
*
sizeof
(
SStreamDesc
)
+
sizeof
(
SHeartBeat
Msg
)
+
100
;
int
size
=
numOfQueries
*
sizeof
(
SQueryDesc
)
+
numOfStreams
*
sizeof
(
SStreamDesc
)
+
sizeof
(
SHeartBeat
Req
)
+
100
;
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
size
))
{
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
size
))
{
pthread_mutex_unlock
(
&
pObj
->
mutex
);
pthread_mutex_unlock
(
&
pObj
->
mutex
);
tscError
(
"0x%"
PRIx64
" failed to create heartbeat msg"
,
pSql
->
self
);
tscError
(
"0x%"
PRIx64
" failed to create heartbeat msg"
,
pSql
->
self
);
...
@@ -1982,7 +1982,7 @@ int tscBuildHeartBeatMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -1982,7 +1982,7 @@ int tscBuildHeartBeatMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
}
}
// TODO the expired hb and client can not be identified by server till now.
// TODO the expired hb and client can not be identified by server till now.
SHeartBeat
Msg
*
pHeartbeat
=
(
SHeartBeatMsg
*
)
pCmd
->
payload
;
SHeartBeat
Req
*
pHeartbeat
=
(
SHeartBeatReq
*
)
pCmd
->
payload
;
tstrncpy
(
pHeartbeat
->
clientVer
,
version
,
tListLen
(
pHeartbeat
->
clientVer
));
tstrncpy
(
pHeartbeat
->
clientVer
,
version
,
tListLen
(
pHeartbeat
->
clientVer
));
pHeartbeat
->
numOfQueries
=
numOfQueries
;
pHeartbeat
->
numOfQueries
=
numOfQueries
;
...
...
tests/script/general/table/basic1.sim
浏览文件 @
dc081e52
...
@@ -44,13 +44,20 @@ print $data10 $data11 $data12
...
@@ -44,13 +44,20 @@ print $data10 $data11 $data12
print =============== create child table
print =============== create child table
sql create table c1 using st tags(1)
sql create table c1 using st tags(1)
sql create table c2 using st tags(2)
sql create table c2 using st tags(2)
sql show tables
sql show tables
if $rows != 2 then
if $rows != 2 then
return -1
return -1
endi
endi
sql create table c3 using st tags(3) c4 using st tags(4) c5 using st tags(5) c6 using st tags(6) c7 using st tags(7)
sql show tables
if $rows != 7 then
return -1
endi
print $data00 $data01 $data02
print $data00 $data01 $data02
print $data10 $data11 $data22
print $data10 $data11 $data22
print $data20 $data11 $data22
print $data20 $data11 $data22
...
...
tests/test/c/create_table.c
浏览文件 @
dc081e52
...
@@ -15,25 +15,20 @@
...
@@ -15,25 +15,20 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "os.h"
#include "os.h"
#include "taos.h"
#include "taos.h"
#include "taosdef.h"
#include "taoserror.h"
#include "taoserror.h"
#include "thash.h"
#include "tutil.h"
#include "ulog.h"
#include "ulog.h"
#define MAX_RANDOM_POINTS 20000
#define GREEN "\033[1;32m"
#define GREEN "\033[1;32m"
#define NC "\033[0m"
#define NC "\033[0m"
char
dbName
[
32
]
=
"db"
;
char
dbName
[
32
]
=
"db"
;
char
stbName
[
64
]
=
"st"
;
char
stbName
[
64
]
=
"st"
;
int32_t
numOfThreads
=
2
;
int32_t
numOfThreads
=
1
;
int32_t
numOfTables
=
10000
;
int32_t
numOfTables
=
10000
;
int32_t
createTable
=
1
;
int32_t
createTable
=
1
;
int32_t
insertData
=
0
;
int32_t
insertData
=
0
;
int32_t
batchNum
=
1
;
int32_t
batchNum
=
1
0
;
int32_t
numOfVgroups
=
2
;
int32_t
numOfVgroups
=
2
;
typedef
struct
{
typedef
struct
{
...
@@ -47,11 +42,11 @@ typedef struct {
...
@@ -47,11 +42,11 @@ typedef struct {
pthread_t
thread
;
pthread_t
thread
;
}
SThreadInfo
;
}
SThreadInfo
;
void
parseArgument
(
int
argc
,
char
*
argv
[]);
void
parseArgument
(
int
32_t
argc
,
char
*
argv
[]);
void
*
threadFunc
(
void
*
param
);
void
*
threadFunc
(
void
*
param
);
void
createDbAndStb
();
void
createDbAndStb
();
int
main
(
in
t
argc
,
char
*
argv
[])
{
int
32_t
main
(
int32_
t
argc
,
char
*
argv
[])
{
parseArgument
(
argc
,
argv
);
parseArgument
(
argc
,
argv
);
createDbAndStb
();
createDbAndStb
();
...
@@ -64,7 +59,7 @@ int main(int argc, char *argv[]) {
...
@@ -64,7 +59,7 @@ int main(int argc, char *argv[]) {
int32_t
numOfTablesPerThread
=
numOfTables
/
numOfThreads
;
int32_t
numOfTablesPerThread
=
numOfTables
/
numOfThreads
;
numOfTables
=
numOfTablesPerThread
*
numOfThreads
;
numOfTables
=
numOfTablesPerThread
*
numOfThreads
;
for
(
int
i
=
0
;
i
<
numOfThreads
;
++
i
)
{
for
(
int
32_t
i
=
0
;
i
<
numOfThreads
;
++
i
)
{
pInfo
[
i
].
tableBeginIndex
=
i
*
numOfTablesPerThread
;
pInfo
[
i
].
tableBeginIndex
=
i
*
numOfTablesPerThread
;
pInfo
[
i
].
tableEndIndex
=
(
i
+
1
)
*
numOfTablesPerThread
;
pInfo
[
i
].
tableEndIndex
=
(
i
+
1
)
*
numOfTablesPerThread
;
pInfo
[
i
].
threadIndex
=
i
;
pInfo
[
i
].
threadIndex
=
i
;
...
@@ -74,17 +69,17 @@ int main(int argc, char *argv[]) {
...
@@ -74,17 +69,17 @@ int main(int argc, char *argv[]) {
}
}
taosMsleep
(
300
);
taosMsleep
(
300
);
for
(
int
i
=
0
;
i
<
numOfThreads
;
i
++
)
{
for
(
int
32_t
i
=
0
;
i
<
numOfThreads
;
i
++
)
{
pthread_join
(
pInfo
[
i
].
thread
,
NULL
);
pthread_join
(
pInfo
[
i
].
thread
,
NULL
);
}
}
float
createTableSpeed
=
0
;
float
createTableSpeed
=
0
;
for
(
int
i
=
0
;
i
<
numOfThreads
;
++
i
)
{
for
(
int
32_t
i
=
0
;
i
<
numOfThreads
;
++
i
)
{
createTableSpeed
+=
pInfo
[
i
].
createTableSpeed
;
createTableSpeed
+=
pInfo
[
i
].
createTableSpeed
;
}
}
float
insertDataSpeed
=
0
;
float
insertDataSpeed
=
0
;
for
(
int
i
=
0
;
i
<
numOfThreads
;
++
i
)
{
for
(
int
32_t
i
=
0
;
i
<
numOfThreads
;
++
i
)
{
insertDataSpeed
+=
pInfo
[
i
].
insertDataSpeed
;
insertDataSpeed
+=
pInfo
[
i
].
insertDataSpeed
;
}
}
...
@@ -137,8 +132,8 @@ void createDbAndStb() {
...
@@ -137,8 +132,8 @@ void createDbAndStb() {
void
*
threadFunc
(
void
*
param
)
{
void
*
threadFunc
(
void
*
param
)
{
SThreadInfo
*
pInfo
=
(
SThreadInfo
*
)
param
;
SThreadInfo
*
pInfo
=
(
SThreadInfo
*
)
param
;
char
qstr
[
65000
]
;
char
*
qstr
=
malloc
(
2000
*
1000
)
;
int
code
;
int
32_t
code
=
0
;
TAOS
*
con
=
taos_connect
(
NULL
,
"root"
,
"taosdata"
,
NULL
,
0
);
TAOS
*
con
=
taos_connect
(
NULL
,
"root"
,
"taosdata"
,
NULL
,
0
);
if
(
con
==
NULL
)
{
if
(
con
==
NULL
)
{
...
@@ -153,7 +148,13 @@ void *threadFunc(void *param) {
...
@@ -153,7 +148,13 @@ void *threadFunc(void *param) {
if
(
createTable
)
{
if
(
createTable
)
{
int64_t
startMs
=
taosGetTimestampMs
();
int64_t
startMs
=
taosGetTimestampMs
();
for
(
int32_t
t
=
pInfo
->
tableBeginIndex
;
t
<
pInfo
->
tableEndIndex
;
++
t
)
{
for
(
int32_t
t
=
pInfo
->
tableBeginIndex
;
t
<
pInfo
->
tableEndIndex
;
++
t
)
{
sprintf
(
qstr
,
"create table t%d using %s tags(%d)"
,
t
,
stbName
,
t
);
int32_t
batch
=
(
pInfo
->
tableEndIndex
-
t
);
batch
=
MIN
(
batch
,
batchNum
);
int32_t
len
=
sprintf
(
qstr
,
"create table"
);
for
(
int32_t
i
=
0
;
i
<
batch
;
++
i
)
{
len
+=
sprintf
(
qstr
+
len
,
" t%d using %s tags(%d)"
,
t
+
i
,
stbName
,
t
+
i
);
}
TAOS_RES
*
pSql
=
taos_query
(
con
,
qstr
);
TAOS_RES
*
pSql
=
taos_query
(
con
,
qstr
);
code
=
taos_errno
(
pSql
);
code
=
taos_errno
(
pSql
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
...
@@ -189,6 +190,7 @@ void *threadFunc(void *param) {
...
@@ -189,6 +190,7 @@ void *threadFunc(void *param) {
}
}
taos_close
(
con
);
taos_close
(
con
);
free
(
qstr
);
return
0
;
return
0
;
}
}
...
@@ -218,8 +220,8 @@ void printHelp() {
...
@@ -218,8 +220,8 @@ void printHelp() {
exit
(
EXIT_SUCCESS
);
exit
(
EXIT_SUCCESS
);
}
}
void
parseArgument
(
int
argc
,
char
*
argv
[])
{
void
parseArgument
(
int
32_t
argc
,
char
*
argv
[])
{
for
(
int
i
=
1
;
i
<
argc
;
i
++
)
{
for
(
int
32_t
i
=
1
;
i
<
argc
;
i
++
)
{
if
(
strcmp
(
argv
[
i
],
"-h"
)
==
0
||
strcmp
(
argv
[
i
],
"--help"
)
==
0
)
{
if
(
strcmp
(
argv
[
i
],
"-h"
)
==
0
||
strcmp
(
argv
[
i
],
"--help"
)
==
0
)
{
printHelp
();
printHelp
();
exit
(
0
);
exit
(
0
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录