Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
96f2aea2
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
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看板
提交
96f2aea2
编写于
1月 06, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
差异文件
Merge branch '3.0' of
https://github.com/taosdata/TDengine
into feature/vnode
上级
5c66e5f2
08d5daf9
变更
63
展开全部
隐藏空白更改
内联
并排
Showing
63 changed file
with
1627 addition
and
1355 deletion
+1627
-1355
Jenkinsfile
Jenkinsfile
+4
-219
include/common/tmsg.h
include/common/tmsg.h
+78
-22
include/common/tmsgdef.h
include/common/tmsgdef.h
+1
-0
include/util/taoserror.h
include/util/taoserror.h
+2
-0
include/util/tdef.h
include/util/tdef.h
+1
-0
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+10
-3
source/client/src/clientMsgHandler.c
source/client/src/clientMsgHandler.c
+2
-2
source/client/test/clientTests.cpp
source/client/test/clientTests.cpp
+11
-11
source/dnode/mgmt/impl/test/CMakeLists.txt
source/dnode/mgmt/impl/test/CMakeLists.txt
+0
-2
source/dnode/mgmt/impl/test/bnode/dbnode.cpp
source/dnode/mgmt/impl/test/bnode/dbnode.cpp
+27
-27
source/dnode/mgmt/impl/test/cluster/CMakeLists.txt
source/dnode/mgmt/impl/test/cluster/CMakeLists.txt
+0
-11
source/dnode/mgmt/impl/test/cluster/cluster.cpp
source/dnode/mgmt/impl/test/cluster/cluster.cpp
+0
-41
source/dnode/mgmt/impl/test/db/db.cpp
source/dnode/mgmt/impl/test/db/db.cpp
+27
-27
source/dnode/mgmt/impl/test/dnode/dnode.cpp
source/dnode/mgmt/impl/test/dnode/dnode.cpp
+28
-28
source/dnode/mgmt/impl/test/mnode/mnode.cpp
source/dnode/mgmt/impl/test/mnode/mnode.cpp
+41
-41
source/dnode/mgmt/impl/test/profile/profile.cpp
source/dnode/mgmt/impl/test/profile/profile.cpp
+29
-29
source/dnode/mgmt/impl/test/qnode/dqnode.cpp
source/dnode/mgmt/impl/test/qnode/dqnode.cpp
+28
-28
source/dnode/mgmt/impl/test/snode/dsnode.cpp
source/dnode/mgmt/impl/test/snode/dsnode.cpp
+27
-27
source/dnode/mgmt/impl/test/stb/stb.cpp
source/dnode/mgmt/impl/test/stb/stb.cpp
+16
-16
source/dnode/mgmt/impl/test/sut/inc/client.h
source/dnode/mgmt/impl/test/sut/inc/client.h
+1
-1
source/dnode/mgmt/impl/test/sut/inc/sut.h
source/dnode/mgmt/impl/test/sut/inc/sut.h
+3
-3
source/dnode/mgmt/impl/test/sut/src/client.cpp
source/dnode/mgmt/impl/test/sut/src/client.cpp
+5
-5
source/dnode/mgmt/impl/test/sut/src/sut.cpp
source/dnode/mgmt/impl/test/sut/src/sut.cpp
+12
-12
source/dnode/mgmt/impl/test/vgroup/vgroup.cpp
source/dnode/mgmt/impl/test/vgroup/vgroup.cpp
+9
-9
source/dnode/mnode/impl/inc/mndConsumer.h
source/dnode/mnode/impl/inc/mndConsumer.h
+2
-5
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+105
-33
source/dnode/mnode/impl/inc/mndTopic.h
source/dnode/mnode/impl/inc/mndTopic.h
+5
-2
source/dnode/mnode/impl/src/mndAcct.c
source/dnode/mnode/impl/src/mndAcct.c
+6
-6
source/dnode/mnode/impl/src/mndAuth.c
source/dnode/mnode/impl/src/mndAuth.c
+0
-1
source/dnode/mnode/impl/src/mndBnode.c
source/dnode/mnode/impl/src/mndBnode.c
+41
-41
source/dnode/mnode/impl/src/mndCluster.c
source/dnode/mnode/impl/src/mndCluster.c
+0
-1
source/dnode/mnode/impl/src/mndConsumer.c
source/dnode/mnode/impl/src/mndConsumer.c
+252
-114
source/dnode/mnode/impl/src/mndQnode.c
source/dnode/mnode/impl/src/mndQnode.c
+41
-41
source/dnode/mnode/impl/src/mndShow.c
source/dnode/mnode/impl/src/mndShow.c
+26
-26
source/dnode/mnode/impl/src/mndSnode.c
source/dnode/mnode/impl/src/mndSnode.c
+41
-41
source/dnode/mnode/impl/src/mndSync.c
source/dnode/mnode/impl/src/mndSync.c
+2
-1
source/dnode/mnode/impl/src/mndTopic.c
source/dnode/mnode/impl/src/mndTopic.c
+71
-84
source/dnode/mnode/impl/src/mndTrans.c
source/dnode/mnode/impl/src/mndTrans.c
+16
-11
source/dnode/mnode/impl/src/mndUser.c
source/dnode/mnode/impl/src/mndUser.c
+31
-32
source/dnode/mnode/impl/test/CMakeLists.txt
source/dnode/mnode/impl/test/CMakeLists.txt
+1
-1
source/dnode/mnode/impl/test/acct/acct.cpp
source/dnode/mnode/impl/test/acct/acct.cpp
+14
-14
source/dnode/mnode/impl/test/bnode/bnode.cpp
source/dnode/mnode/impl/test/bnode/bnode.cpp
+57
-61
source/dnode/mnode/impl/test/qnode/qnode.cpp
source/dnode/mnode/impl/test/qnode/qnode.cpp
+57
-61
source/dnode/mnode/impl/test/show/CMakeLists.txt
source/dnode/mnode/impl/test/show/CMakeLists.txt
+11
-0
source/dnode/mnode/impl/test/show/show.cpp
source/dnode/mnode/impl/test/show/show.cpp
+102
-0
source/dnode/mnode/impl/test/snode/snode.cpp
source/dnode/mnode/impl/test/snode/snode.cpp
+57
-61
source/dnode/mnode/impl/test/trans/trans.cpp
source/dnode/mnode/impl/test/trans/trans.cpp
+117
-12
source/dnode/mnode/impl/test/user/user.cpp
source/dnode/mnode/impl/test/user/user.cpp
+59
-59
source/libs/index/inc/index_cache.h
source/libs/index/inc/index_cache.h
+2
-1
source/libs/index/src/index.c
source/libs/index/src/index.c
+15
-2
source/libs/index/src/index_cache.c
source/libs/index/src/index_cache.c
+19
-8
source/libs/index/src/index_tfile.c
source/libs/index/src/index_tfile.c
+0
-3
source/libs/index/test/indexTests.cc
source/libs/index/test/indexTests.cc
+3
-3
source/libs/parser/inc/astToMsg.h
source/libs/parser/inc/astToMsg.h
+1
-1
source/libs/parser/src/astToMsg.c
source/libs/parser/src/astToMsg.c
+2
-2
source/libs/parser/src/dCDAstProcess.c
source/libs/parser/src/dCDAstProcess.c
+1
-1
source/libs/scheduler/inc/schedulerInt.h
source/libs/scheduler/inc/schedulerInt.h
+15
-14
source/libs/scheduler/src/scheduler.c
source/libs/scheduler/src/scheduler.c
+60
-36
source/libs/wal/src/walMeta.c
source/libs/wal/src/walMeta.c
+3
-0
source/libs/wal/src/walRead.c
source/libs/wal/src/walRead.c
+11
-2
source/libs/wal/src/walSeek.c
source/libs/wal/src/walSeek.c
+8
-1
source/libs/wal/src/walWrite.c
source/libs/wal/src/walWrite.c
+2
-0
src/client/src/tscServer.c
src/client/src/tscServer.c
+9
-9
未找到文件。
Jenkinsfile
浏览文件 @
96f2aea2
...
@@ -110,227 +110,12 @@ pipeline {
...
@@ -110,227 +110,12 @@ pipeline {
cd ${WKC}/tests
cd ${WKC}/tests
./test-all.sh b1fq
./test-all.sh b1fq
'''
'''
sh
'''
cd ${WKC}/debug
ctest
'''
}
}
}
}
// stage('Parallel test stage') {
// skip defaultCheckout
// options { skipDefaultCheckout() }
// when {
// allOf{
// changeRequest()
// }
// }
// parallel {
// stage('python_1_s1') {
// agent{label " slave1 || slave11 "}
// steps {
// pre_test()
// // timeout(time: 55, unit: 'MINUTES'){
// // sh '''
// // date
// // cd ${WKC}/tests
// // ./test-all.sh p1
// // date'''
// // }
// }
// }
// stage('python_2_s5') {
// agent{label " slave5 || slave15 "}
// steps {
// pre_test()
// // timeout(time: 55, unit: 'MINUTES'){
// // sh '''
// // date
// // cd ${WKC}/tests
// // ./test-all.sh p2
// // date'''
// // }
// }
// }
// stage('python_3_s6') {
// agent{label " slave6 || slave16 "}
// steps {
// pre_test()
// // timeout(time: 55, unit: 'MINUTES'){
// // sh '''
// // date
// // cd ${WKC}/tests
// // ./test-all.sh p3
// // date'''
// // }
// }
// }
// stage('test_b1_s2') {
// agent{label " slave2 || slave12 "}
// steps {
// pre_test()
// // timeout(time: 55, unit: 'MINUTES'){
// // sh '''
// // rm -rf /var/lib/taos/*
// // rm -rf /var/log/taos/*
// // nohup taosd >/dev/null &
// // sleep 10
// // '''
// // sh '''
// // cd ${WKC}/tests/examples/nodejs
// // npm install td2.0-connector > /dev/null 2>&1
// // node nodejsChecker.js host=localhost
// // node test1970.js
// // cd ${WKC}/tests/connectorTest/nodejsTest/nanosupport
// // npm install td2.0-connector > /dev/null 2>&1
// // node nanosecondTest.js
// // '''
// // sh '''
// // cd ${WKC}/tests/examples/C#/taosdemo
// // mcs -out:taosdemo *.cs > /dev/null 2>&1
// // echo '' |./taosdemo -c /etc/taos
// // cd ${WKC}/tests/connectorTest/C#Test/nanosupport
// // mcs -out:nano *.cs > /dev/null 2>&1
// // echo '' |./nano
// // '''
// // sh '''
// // cd ${WKC}/tests/gotest
// // bash batchtest.sh
// // '''
// // sh '''
// // cd ${WKC}/tests
// // ./test-all.sh b1fq
// // date'''
// // }
// }
// }
// stage('test_crash_gen_s3') {
// agent{label " slave3 || slave13 "}
// steps {
// pre_test()
// // timeout(time: 60, unit: 'MINUTES'){
// // sh '''
// // cd ${WKC}/tests/pytest
// // ./crash_gen.sh -a -p -t 4 -s 2000
// // '''
// // }
// // timeout(time: 60, unit: 'MINUTES'){
// // // sh '''
// // // cd ${WKC}/tests/pytest
// // // rm -rf /var/lib/taos/*
// // // rm -rf /var/log/taos/*
// // // ./handle_crash_gen_val_log.sh
// // // '''
// // sh '''
// // cd ${WKC}/tests/pytest
// // rm -rf /var/lib/taos/*
// // rm -rf /var/log/taos/*
// // ./handle_taosd_val_log.sh
// // '''
// // }
// // timeout(time: 55, unit: 'MINUTES'){
// // sh '''
// // date
// // cd ${WKC}/tests
// // ./test-all.sh b2fq
// // date
// // '''
// // }
// }
// }
// stage('test_valgrind_s4') {
// agent{label " slave4 || slave14 "}
// steps {
// pre_test()
// // catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
// // sh '''
// // cd ${WKC}/tests/pytest
// // ./valgrind-test.sh 2>&1 > mem-error-out.log
// // ./handle_val_log.sh
// // '''
// // }
// // timeout(time: 55, unit: 'MINUTES'){
// // sh '''
// // date
// // cd ${WKC}/tests
// // ./test-all.sh b3fq
// // date'''
// // sh '''
// // date
// // cd ${WKC}/tests
// // ./test-all.sh full example
// // date'''
// // }
// }
// }
// stage('test_b4_s7') {
// agent{label " slave7 || slave17 "}
// steps {
// pre_test()
// // timeout(time: 55, unit: 'MINUTES'){
// // sh '''
// // date
// // cd ${WKC}/tests
// // ./test-all.sh b4fq
// // cd ${WKC}/tests
// // ./test-all.sh p4
// // cd ${WKC}/tests
// // ./test-all.sh full jdbc
// // cd ${WKC}/tests
// // ./test-all.sh full unit
// // date'''
// // }
// }
// }
// stage('test_b5_s8') {
// agent{label " slave8 || slave18 "}
// steps {
// pre_test()
// // timeout(time: 55, unit: 'MINUTES'){
// // sh '''
// // date
// // cd ${WKC}/tests
// // ./test-all.sh b5fq
// // date'''
// // }
// }
// }
// stage('test_b6_s9') {
// agent{label " slave9 || slave19 "}
// steps {
// pre_test()
// // timeout(time: 55, unit: 'MINUTES'){
// // sh '''
// // date
// // cd ${WKC}/tests
// // ./test-all.sh b6fq
// // date'''
// // }
// }
// }
// stage('test_b7_s10') {
// agent{label " slave10 || slave20 "}
// steps {
// pre_test()
// // timeout(time: 55, unit: 'MINUTES'){
// // sh '''
// // date
// // cd ${WKC}/tests
// // ./test-all.sh b7fq
// // date'''
// // }
// }
// }
// }
// }
}
}
post
{
post
{
success
{
success
{
...
...
include/common/tmsg.h
浏览文件 @
96f2aea2
...
@@ -330,14 +330,23 @@ typedef struct SEpSet {
...
@@ -330,14 +330,23 @@ typedef struct SEpSet {
}
SEpSet
;
}
SEpSet
;
static
FORCE_INLINE
int
taosEncodeSEpSet
(
void
**
buf
,
const
SEpSet
*
pEp
)
{
static
FORCE_INLINE
int
taosEncodeSEpSet
(
void
**
buf
,
const
SEpSet
*
pEp
)
{
if
(
buf
==
NULL
)
return
sizeof
(
SEpSet
);
int
tlen
=
0
;
memcpy
(
buf
,
pEp
,
sizeof
(
SEpSet
));
tlen
+=
taosEncodeFixedI8
(
buf
,
pEp
->
inUse
);
// TODO: endian conversion
tlen
+=
taosEncodeFixedI8
(
buf
,
pEp
->
numOfEps
);
return
sizeof
(
SEpSet
);
for
(
int
i
=
0
;
i
<
TSDB_MAX_REPLICA
;
i
++
)
{
tlen
+=
taosEncodeFixedU16
(
buf
,
pEp
->
port
[
i
]);
tlen
+=
taosEncodeString
(
buf
,
pEp
->
fqdn
[
i
]);
}
return
tlen
;
}
}
static
FORCE_INLINE
void
*
taosDecodeSEpSet
(
void
*
buf
,
SEpSet
*
pEpSet
)
{
static
FORCE_INLINE
void
*
taosDecodeSEpSet
(
void
*
buf
,
SEpSet
*
pEp
)
{
memcpy
(
pEpSet
,
buf
,
sizeof
(
SEpSet
));
buf
=
taosDecodeFixedI8
(
buf
,
&
pEp
->
inUse
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pEp
->
numOfEps
);
for
(
int
i
=
0
;
i
<
TSDB_MAX_REPLICA
;
i
++
)
{
buf
=
taosDecodeFixedU16
(
buf
,
&
pEp
->
port
[
i
]);
buf
=
taosDecodeStringTo
(
buf
,
pEp
->
fqdn
[
i
]);
}
return
buf
;
return
buf
;
}
}
...
@@ -524,7 +533,7 @@ typedef struct {
...
@@ -524,7 +533,7 @@ typedef struct {
int64_t
qId
;
int64_t
qId
;
};
// query handle
};
// query handle
int8_t
free
;
int8_t
free
;
}
SRetrieveTable
Msg
;
}
SRetrieveTable
Req
;
typedef
struct
SRetrieveTableRsp
{
typedef
struct
SRetrieveTableRsp
{
int64_t
useconds
;
int64_t
useconds
;
...
@@ -826,7 +835,7 @@ typedef struct {
...
@@ -826,7 +835,7 @@ typedef struct {
char
db
[
TSDB_DB_FNAME_LEN
];
char
db
[
TSDB_DB_FNAME_LEN
];
int16_t
payloadLen
;
int16_t
payloadLen
;
char
payload
[];
char
payload
[];
}
SShow
Msg
;
}
SShow
Req
;
typedef
struct
{
typedef
struct
{
char
db
[
TSDB_DB_FNAME_LEN
];
char
db
[
TSDB_DB_FNAME_LEN
];
...
@@ -1101,8 +1110,8 @@ typedef struct {
...
@@ -1101,8 +1110,8 @@ typedef struct {
static
FORCE_INLINE
int
tSerializeSCMCreateTopicReq
(
void
**
buf
,
const
SCMCreateTopicReq
*
pReq
)
{
static
FORCE_INLINE
int
tSerializeSCMCreateTopicReq
(
void
**
buf
,
const
SCMCreateTopicReq
*
pReq
)
{
int
tlen
=
0
;
int
tlen
=
0
;
tlen
+=
taosEncodeString
(
buf
,
pReq
->
name
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pReq
->
igExists
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pReq
->
igExists
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
name
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
physicalPlan
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
physicalPlan
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
logicalPlan
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
logicalPlan
);
return
tlen
;
return
tlen
;
...
@@ -1132,41 +1141,62 @@ static FORCE_INLINE void* tDeserializeSCMCreateTopicRsp(void* buf, SCMCreateTopi
...
@@ -1132,41 +1141,62 @@ static FORCE_INLINE void* tDeserializeSCMCreateTopicRsp(void* buf, SCMCreateTopi
}
}
typedef
struct
{
typedef
struct
{
char
*
topicName
;
int32_t
topicNum
;
char
*
consumerGroup
;
int64_t
consumerId
;
int64_t
consumerId
;
char
*
consumerGroup
;
char
*
topicName
[];
}
SCMSubscribeReq
;
}
SCMSubscribeReq
;
static
FORCE_INLINE
int
tSerializeSCMSubscribeReq
(
void
**
buf
,
const
SCMSubscribeReq
*
pReq
)
{
static
FORCE_INLINE
int
tSerializeSCMSubscribeReq
(
void
**
buf
,
const
SCMSubscribeReq
*
pReq
)
{
int
tlen
=
0
;
int
tlen
=
0
;
tlen
+=
taosEncodeString
(
buf
,
pReq
->
topicName
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pReq
->
topicNum
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
consumerGroup
);
tlen
+=
taosEncodeFixedI64
(
buf
,
pReq
->
consumerId
);
tlen
+=
taosEncodeFixedI64
(
buf
,
pReq
->
consumerId
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
consumerGroup
);
for
(
int
i
=
0
;
i
<
pReq
->
topicNum
;
i
++
)
{
tlen
+=
taosEncodeString
(
buf
,
pReq
->
topicName
[
i
]);
}
return
tlen
;
return
tlen
;
}
}
static
FORCE_INLINE
void
*
tDeserializeSCMSubscribeReq
(
void
*
buf
,
SCMSubscribeReq
*
pReq
)
{
static
FORCE_INLINE
void
*
tDeserializeSCMSubscribeReq
(
void
*
buf
,
SCMSubscribeReq
*
pReq
)
{
buf
=
taosDecodeString
(
buf
,
&
pReq
->
topicName
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pReq
->
topicNum
);
buf
=
taosDecodeString
(
buf
,
&
pReq
->
consumerGroup
);
buf
=
taosDecodeFixedI64
(
buf
,
&
pReq
->
consumerId
);
buf
=
taosDecodeFixedI64
(
buf
,
&
pReq
->
consumerId
);
buf
=
taosDecodeString
(
buf
,
&
pReq
->
consumerGroup
);
for
(
int
i
=
0
;
i
<
pReq
->
topicNum
;
i
++
)
{
buf
=
taosDecodeString
(
buf
,
&
pReq
->
topicName
[
i
]);
}
return
buf
;
return
buf
;
}
}
typedef
struct
{
typedef
struct
SMqSubTopic
{
int32_t
vgId
;
int32_t
vgId
;
SEpSet
pEpSet
;
int64_t
topicId
;
SEpSet
epSet
;
}
SMqSubTopic
;
typedef
struct
{
int32_t
topicNum
;
SMqSubTopic
topics
[];
}
SCMSubscribeRsp
;
}
SCMSubscribeRsp
;
static
FORCE_INLINE
int
tSerializeSCMSubscribeRsp
(
void
**
buf
,
const
SCMSubscribeRsp
*
pRsp
)
{
static
FORCE_INLINE
int
tSerializeSCMSubscribeRsp
(
void
**
buf
,
const
SCMSubscribeRsp
*
pRsp
)
{
int
tlen
=
0
;
int
tlen
=
0
;
tlen
+=
taosEncodeFixedI32
(
buf
,
pRsp
->
vgId
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pRsp
->
topicNum
);
tlen
+=
taosEncodeSEpSet
(
buf
,
&
pRsp
->
pEpSet
);
for
(
int
i
=
0
;
i
<
pRsp
->
topicNum
;
i
++
)
{
tlen
+=
taosEncodeFixedI32
(
buf
,
pRsp
->
topics
[
i
].
vgId
);
tlen
+=
taosEncodeFixedI64
(
buf
,
pRsp
->
topics
[
i
].
topicId
);
tlen
+=
taosEncodeSEpSet
(
buf
,
&
pRsp
->
topics
[
i
].
epSet
);
}
return
tlen
;
return
tlen
;
}
}
static
FORCE_INLINE
void
*
tDeserializeSCMSubscribeRsp
(
void
*
buf
,
SCMSubscribeRsp
*
pRsp
)
{
static
FORCE_INLINE
void
*
tDeserializeSCMSubscribeRsp
(
void
*
buf
,
SCMSubscribeRsp
*
pRsp
)
{
buf
=
taosDecodeFixedI32
(
buf
,
&
pRsp
->
vgId
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pRsp
->
topicNum
);
buf
=
taosDecodeSEpSet
(
buf
,
&
pRsp
->
pEpSet
);
for
(
int
i
=
0
;
i
<
pRsp
->
topicNum
;
i
++
)
{
buf
=
taosDecodeFixedI32
(
buf
,
&
pRsp
->
topics
[
i
].
vgId
);
buf
=
taosDecodeFixedI64
(
buf
,
&
pRsp
->
topics
[
i
].
topicId
);
buf
=
taosDecodeSEpSet
(
buf
,
&
pRsp
->
topics
[
i
].
epSet
);
}
return
buf
;
return
buf
;
}
}
...
@@ -1175,10 +1205,36 @@ typedef struct {
...
@@ -1175,10 +1205,36 @@ typedef struct {
int64_t
consumerId
;
int64_t
consumerId
;
int64_t
consumerGroupId
;
int64_t
consumerGroupId
;
int64_t
offset
;
int64_t
offset
;
char
*
sql
;
char
*
logicalPlan
;
char
*
physicalPlan
;
}
SMVSubscribeReq
;
}
SMVSubscribeReq
;
static
FORCE_INLINE
int
tSerializeSMVSubscribeReq
(
void
**
buf
,
SMVSubscribeReq
*
pReq
)
{
int
tlen
=
0
;
tlen
+=
taosEncodeFixedI64
(
buf
,
pReq
->
topicId
);
tlen
+=
taosEncodeFixedI64
(
buf
,
pReq
->
consumerId
);
tlen
+=
taosEncodeFixedI64
(
buf
,
pReq
->
consumerGroupId
);
tlen
+=
taosEncodeFixedI64
(
buf
,
pReq
->
offset
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
sql
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
logicalPlan
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
physicalPlan
);
return
tlen
;
}
static
FORCE_INLINE
void
*
tDeserializeSMVSubscribeReq
(
void
*
buf
,
SMVSubscribeReq
*
pReq
)
{
buf
=
taosDecodeFixedI64
(
buf
,
&
pReq
->
topicId
);
buf
=
taosDecodeFixedI64
(
buf
,
&
pReq
->
consumerId
);
buf
=
taosDecodeFixedI64
(
buf
,
&
pReq
->
consumerGroupId
);
buf
=
taosDecodeFixedI64
(
buf
,
&
pReq
->
offset
);
buf
=
taosDecodeString
(
buf
,
&
pReq
->
sql
);
buf
=
taosDecodeString
(
buf
,
&
pReq
->
logicalPlan
);
buf
=
taosDecodeString
(
buf
,
&
pReq
->
physicalPlan
);
return
buf
;
}
typedef
struct
{
typedef
struct
{
int64_t
newOffset
;
int64_t
status
;
}
SMVSubscribeRsp
;
}
SMVSubscribeRsp
;
typedef
struct
{
typedef
struct
{
...
...
include/common/tmsgdef.h
浏览文件 @
96f2aea2
...
@@ -159,6 +159,7 @@ enum {
...
@@ -159,6 +159,7 @@ enum {
TD_DEF_MSG_TYPE
(
TDMT_VND_MQ_QUERY
,
"vnode-mq-query"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_MQ_QUERY
,
"vnode-mq-query"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_MQ_CONNECT
,
"vnode-mq-connect"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_MQ_CONNECT
,
"vnode-mq-connect"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_MQ_DISCONNECT
,
"vnode-mq-disconnect"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_MQ_DISCONNECT
,
"vnode-mq-disconnect"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_MQ_SET_CONN
,
"vnode-mq-set-conn"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_MQ_SET_CUR
,
"vnode-mq-set-cur"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_MQ_SET_CUR
,
"vnode-mq-set-cur"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_RES_READY
,
"vnode-res-ready"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_RES_READY
,
"vnode-res-ready"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_TASKS_STATUS
,
"vnode-tasks-status"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_TASKS_STATUS
,
"vnode-tasks-status"
,
NULL
,
NULL
)
...
...
include/util/taoserror.h
浏览文件 @
96f2aea2
...
@@ -401,6 +401,8 @@ int32_t* taosGetErrno();
...
@@ -401,6 +401,8 @@ int32_t* taosGetErrno();
#define TSDB_CODE_WAL_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x1000) //"Unexpected generic error in wal")
#define TSDB_CODE_WAL_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x1000) //"Unexpected generic error in wal")
#define TSDB_CODE_WAL_FILE_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x1001) //"WAL file is corrupted")
#define TSDB_CODE_WAL_FILE_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x1001) //"WAL file is corrupted")
#define TSDB_CODE_WAL_SIZE_LIMIT TAOS_DEF_ERROR_CODE(0, 0x1002) //"WAL size exceeds limit")
#define TSDB_CODE_WAL_SIZE_LIMIT TAOS_DEF_ERROR_CODE(0, 0x1002) //"WAL size exceeds limit")
#define TSDB_CODE_WAL_INVALID_VER TAOS_DEF_ERROR_CODE(0, 0x1003) //"WAL invalid version")
#define TSDB_CODE_WAL_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x1004) //"WAL out of memory")
// tfs
// tfs
#define TSDB_CODE_FS_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x2200) //"tfs out of memory")
#define TSDB_CODE_FS_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x2200) //"tfs out of memory")
...
...
include/util/tdef.h
浏览文件 @
96f2aea2
...
@@ -177,6 +177,7 @@ do { \
...
@@ -177,6 +177,7 @@ do { \
#define TSDB_TYPE_STR_MAX_LEN 32
#define TSDB_TYPE_STR_MAX_LEN 32
#define TSDB_TABLE_FNAME_LEN (TSDB_DB_FNAME_LEN + TSDB_TABLE_NAME_LEN + TSDB_NAME_DELIMITER_LEN)
#define TSDB_TABLE_FNAME_LEN (TSDB_DB_FNAME_LEN + TSDB_TABLE_NAME_LEN + TSDB_NAME_DELIMITER_LEN)
#define TSDB_TOPIC_FNAME_LEN TSDB_TABLE_FNAME_LEN
#define TSDB_TOPIC_FNAME_LEN TSDB_TABLE_FNAME_LEN
#define TSDB_CONSUMER_GROUP_LEN 192
#define TSDB_COL_NAME_LEN 65
#define TSDB_COL_NAME_LEN 65
#define TSDB_MAX_SAVED_SQL_LEN TSDB_MAX_COLUMNS * 64
#define TSDB_MAX_SAVED_SQL_LEN TSDB_MAX_COLUMNS * 64
#define TSDB_MAX_SQL_LEN TSDB_PAYLOAD_SIZE
#define TSDB_MAX_SQL_LEN TSDB_PAYLOAD_SIZE
...
...
source/client/src/clientImpl.c
浏览文件 @
96f2aea2
...
@@ -203,12 +203,21 @@ int32_t getPlan(SRequestObj* pRequest, SQueryNode* pQueryNode, SQueryDag** pDag)
...
@@ -203,12 +203,21 @@ int32_t getPlan(SRequestObj* pRequest, SQueryNode* pQueryNode, SQueryDag** pDag)
int32_t
scheduleQuery
(
SRequestObj
*
pRequest
,
SQueryDag
*
pDag
,
void
**
pJob
)
{
int32_t
scheduleQuery
(
SRequestObj
*
pRequest
,
SQueryDag
*
pDag
,
void
**
pJob
)
{
if
(
TSDB_SQL_INSERT
==
pRequest
->
type
||
TSDB_SQL_CREATE_TABLE
==
pRequest
->
type
)
{
if
(
TSDB_SQL_INSERT
==
pRequest
->
type
||
TSDB_SQL_CREATE_TABLE
==
pRequest
->
type
)
{
SQueryResult
res
=
{.
code
=
0
,
.
numOfRows
=
0
,
.
msgSize
=
ERROR_MSG_BUF_DEFAULT_SIZE
,
.
msg
=
pRequest
->
msgBuf
};
SQueryResult
res
=
{.
code
=
0
,
.
numOfRows
=
0
,
.
msgSize
=
ERROR_MSG_BUF_DEFAULT_SIZE
,
.
msg
=
pRequest
->
msgBuf
};
int32_t
code
=
scheduleExecJob
(
pRequest
->
pTscObj
->
pTransporter
,
NULL
,
pDag
,
pJob
,
&
res
);
int32_t
code
=
scheduleExecJob
(
pRequest
->
pTscObj
->
pTransporter
,
NULL
,
pDag
,
pJob
,
&
res
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
// handle error and retry
}
else
{
if
(
*
pJob
!=
NULL
)
{
scheduleFreeJob
(
*
pJob
);
}
}
pRequest
->
affectedRows
=
res
.
numOfRows
;
pRequest
->
affectedRows
=
res
.
numOfRows
;
return
res
.
code
;
return
res
.
code
;
}
}
return
scheduleAsyncExecJob
(
pRequest
->
pTscObj
->
pTransporter
,
NULL
/*todo appInfo.xxx*/
,
pDag
,
pJob
);
return
scheduleAsyncExecJob
(
pRequest
->
pTscObj
->
pTransporter
,
NULL
/*todo appInfo.xxx*/
,
pDag
,
pJob
);
}
}
TAOS_RES
*
tmq_create_topic
(
TAOS
*
taos
,
const
char
*
name
,
const
char
*
sql
,
int
sqlLen
)
{
TAOS_RES
*
tmq_create_topic
(
TAOS
*
taos
,
const
char
*
name
,
const
char
*
sql
,
int
sqlLen
)
{
...
@@ -526,9 +535,7 @@ void* doFetchRow(SRequestObj* pRequest) {
...
@@ -526,9 +535,7 @@ void* doFetchRow(SRequestObj* pRequest) {
int64_t
transporterId
=
0
;
int64_t
transporterId
=
0
;
STscObj
*
pTscObj
=
pRequest
->
pTscObj
;
STscObj
*
pTscObj
=
pRequest
->
pTscObj
;
asyncSendMsgToServer
(
pTscObj
->
pTransporter
,
&
pTscObj
->
pAppInfo
->
mgmtEp
.
epSet
,
&
transporterId
,
body
);
asyncSendMsgToServer
(
pTscObj
->
pTransporter
,
&
pTscObj
->
pAppInfo
->
mgmtEp
.
epSet
,
&
transporterId
,
body
);
tsem_wait
(
&
pRequest
->
body
.
rspSem
);
tsem_wait
(
&
pRequest
->
body
.
rspSem
);
destroySendMsgInfo
(
body
);
pRequest
->
type
=
TDMT_VND_SHOW_TABLES_FETCH
;
pRequest
->
type
=
TDMT_VND_SHOW_TABLES_FETCH
;
}
}
...
...
source/client/src/clientMsgHandler.c
浏览文件 @
96f2aea2
...
@@ -90,14 +90,14 @@ SMsgSendInfo* buildMsgInfoImpl(SRequestObj *pRequest) {
...
@@ -90,14 +90,14 @@ SMsgSendInfo* buildMsgInfoImpl(SRequestObj *pRequest) {
if
(
pRequest
->
type
==
TDMT_MND_SHOW_RETRIEVE
||
pRequest
->
type
==
TDMT_VND_SHOW_TABLES_FETCH
)
{
if
(
pRequest
->
type
==
TDMT_MND_SHOW_RETRIEVE
||
pRequest
->
type
==
TDMT_VND_SHOW_TABLES_FETCH
)
{
if
(
pRequest
->
type
==
TDMT_MND_SHOW_RETRIEVE
)
{
if
(
pRequest
->
type
==
TDMT_MND_SHOW_RETRIEVE
)
{
SRetrieveTable
Msg
*
pRetrieveMsg
=
calloc
(
1
,
sizeof
(
SRetrieveTableMsg
));
SRetrieveTable
Req
*
pRetrieveMsg
=
calloc
(
1
,
sizeof
(
SRetrieveTableReq
));
if
(
pRetrieveMsg
==
NULL
)
{
if
(
pRetrieveMsg
==
NULL
)
{
return
NULL
;
return
NULL
;
}
}
pRetrieveMsg
->
showId
=
htobe64
(
pRequest
->
body
.
showInfo
.
execId
);
pRetrieveMsg
->
showId
=
htobe64
(
pRequest
->
body
.
showInfo
.
execId
);
pMsgSendInfo
->
msgInfo
.
pData
=
pRetrieveMsg
;
pMsgSendInfo
->
msgInfo
.
pData
=
pRetrieveMsg
;
pMsgSendInfo
->
msgInfo
.
len
=
sizeof
(
SRetrieveTable
Msg
);
pMsgSendInfo
->
msgInfo
.
len
=
sizeof
(
SRetrieveTable
Req
);
}
else
{
}
else
{
SVShowTablesFetchReq
*
pFetchMsg
=
calloc
(
1
,
sizeof
(
SVShowTablesFetchReq
));
SVShowTablesFetchReq
*
pFetchMsg
=
calloc
(
1
,
sizeof
(
SVShowTablesFetchReq
));
if
(
pFetchMsg
==
NULL
)
{
if
(
pFetchMsg
==
NULL
)
{
...
...
source/client/test/clientTests.cpp
浏览文件 @
96f2aea2
...
@@ -505,15 +505,15 @@ TEST(testCase, create_multiple_tables) {
...
@@ -505,15 +505,15 @@ TEST(testCase, create_multiple_tables) {
taos_free_result
(
pRes
);
taos_free_result
(
pRes
);
// for(int32_t i = 0; i < 10
000; ++i) {
for
(
int32_t
i
=
0
;
i
<
1
000
;
++
i
)
{
//
char sql[512] = {0};
char
sql
[
512
]
=
{
0
};
//
snprintf(sql, tListLen(sql), "create table t_x_%d using st1 tags(2)", i);
snprintf
(
sql
,
tListLen
(
sql
),
"create table t_x_%d using st1 tags(2)"
,
i
);
//
TAOS_RES* pres = taos_query(pConn, sql);
TAOS_RES
*
pres
=
taos_query
(
pConn
,
sql
);
//
if (taos_errno(pres) != 0) {
if
(
taos_errno
(
pres
)
!=
0
)
{
//
printf("failed to create table %d\n, reason:%s", i, taos_errstr(pres));
printf
(
"failed to create table %d
\n
, reason:%s"
,
i
,
taos_errstr
(
pres
));
//
}
}
//
taos_free_result(pres);
taos_free_result
(
pres
);
//
}
}
taos_close
(
pConn
);
taos_close
(
pConn
);
}
}
...
@@ -521,11 +521,11 @@ TEST(testCase, create_multiple_tables) {
...
@@ -521,11 +521,11 @@ TEST(testCase, create_multiple_tables) {
TEST
(
testCase
,
generated_request_id_test
)
{
TEST
(
testCase
,
generated_request_id_test
)
{
SHashObj
*
phash
=
taosHashInit
(
10000
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
,
HASH_ENTRY_LOCK
);
SHashObj
*
phash
=
taosHashInit
(
10000
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
,
HASH_ENTRY_LOCK
);
for
(
int32_t
i
=
0
;
i
<
50000
000
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
50000
;
++
i
)
{
uint64_t
v
=
generateRequestId
();
uint64_t
v
=
generateRequestId
();
void
*
result
=
taosHashGet
(
phash
,
&
v
,
sizeof
(
v
));
void
*
result
=
taosHashGet
(
phash
,
&
v
,
sizeof
(
v
));
if
(
result
!=
nullptr
)
{
if
(
result
!=
nullptr
)
{
printf
(
"0x%
"
PRIx64
"
, index:%d
\n
"
,
v
,
i
);
printf
(
"0x%
lx
, index:%d
\n
"
,
v
,
i
);
}
}
assert
(
result
==
nullptr
);
assert
(
result
==
nullptr
);
taosHashPut
(
phash
,
&
v
,
sizeof
(
v
),
NULL
,
0
);
taosHashPut
(
phash
,
&
v
,
sizeof
(
v
),
NULL
,
0
);
...
...
source/dnode/mgmt/impl/test/CMakeLists.txt
浏览文件 @
96f2aea2
...
@@ -6,13 +6,11 @@ add_subdirectory(snode)
...
@@ -6,13 +6,11 @@ add_subdirectory(snode)
# add_subdirectory(auth)
# add_subdirectory(auth)
# add_subdirectory(balance)
# add_subdirectory(balance)
add_subdirectory
(
cluster
)
add_subdirectory
(
db
)
add_subdirectory
(
db
)
add_subdirectory
(
dnode
)
add_subdirectory
(
dnode
)
# add_subdirectory(func)
# add_subdirectory(func)
add_subdirectory
(
mnode
)
add_subdirectory
(
mnode
)
add_subdirectory
(
profile
)
add_subdirectory
(
profile
)
add_subdirectory
(
show
)
add_subdirectory
(
stb
)
add_subdirectory
(
stb
)
# add_subdirectory(sync)
# add_subdirectory(sync)
# add_subdirectory(telem)
# add_subdirectory(telem)
...
...
source/dnode/mgmt/impl/test/bnode/dbnode.cpp
浏览文件 @
96f2aea2
...
@@ -32,9 +32,9 @@ TEST_F(DndTestBnode, 01_Create_Bnode) {
...
@@ -32,9 +32,9 @@ TEST_F(DndTestBnode, 01_Create_Bnode) {
SDCreateBnodeReq
*
pReq
=
(
SDCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
SDCreateBnodeReq
*
pReq
=
(
SDCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_CREATE_BNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_DND_BNODE_ID_INVALID
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_DND_BNODE_ID_INVALID
);
}
}
{
{
...
@@ -43,9 +43,9 @@ TEST_F(DndTestBnode, 01_Create_Bnode) {
...
@@ -43,9 +43,9 @@ TEST_F(DndTestBnode, 01_Create_Bnode) {
SDCreateBnodeReq
*
pReq
=
(
SDCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
SDCreateBnodeReq
*
pReq
=
(
SDCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_CREATE_BNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
}
{
{
...
@@ -54,9 +54,9 @@ TEST_F(DndTestBnode, 01_Create_Bnode) {
...
@@ -54,9 +54,9 @@ TEST_F(DndTestBnode, 01_Create_Bnode) {
SDCreateBnodeReq
*
pReq
=
(
SDCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
SDCreateBnodeReq
*
pReq
=
(
SDCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_CREATE_BNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_DND_BNODE_ALREADY_DEPLOYED
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_DND_BNODE_ALREADY_DEPLOYED
);
}
}
test
.
Restart
();
test
.
Restart
();
...
@@ -67,9 +67,9 @@ TEST_F(DndTestBnode, 01_Create_Bnode) {
...
@@ -67,9 +67,9 @@ TEST_F(DndTestBnode, 01_Create_Bnode) {
SDCreateBnodeReq
*
pReq
=
(
SDCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
SDCreateBnodeReq
*
pReq
=
(
SDCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_CREATE_BNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_DND_BNODE_ALREADY_DEPLOYED
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_DND_BNODE_ALREADY_DEPLOYED
);
}
}
}
}
...
@@ -80,9 +80,9 @@ TEST_F(DndTestBnode, 01_Drop_Bnode) {
...
@@ -80,9 +80,9 @@ TEST_F(DndTestBnode, 01_Drop_Bnode) {
SDDropBnodeReq
*
pReq
=
(
SDDropBnodeReq
*
)
rpcMallocCont
(
contLen
);
SDDropBnodeReq
*
pReq
=
(
SDDropBnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_DROP_BNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_DROP_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_DND_BNODE_ID_INVALID
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_DND_BNODE_ID_INVALID
);
}
}
{
{
...
@@ -91,9 +91,9 @@ TEST_F(DndTestBnode, 01_Drop_Bnode) {
...
@@ -91,9 +91,9 @@ TEST_F(DndTestBnode, 01_Drop_Bnode) {
SDDropBnodeReq
*
pReq
=
(
SDDropBnodeReq
*
)
rpcMallocCont
(
contLen
);
SDDropBnodeReq
*
pReq
=
(
SDDropBnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_DROP_BNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_DROP_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
}
{
{
...
@@ -102,9 +102,9 @@ TEST_F(DndTestBnode, 01_Drop_Bnode) {
...
@@ -102,9 +102,9 @@ TEST_F(DndTestBnode, 01_Drop_Bnode) {
SDDropBnodeReq
*
pReq
=
(
SDDropBnodeReq
*
)
rpcMallocCont
(
contLen
);
SDDropBnodeReq
*
pReq
=
(
SDDropBnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_DROP_BNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_DROP_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_DND_BNODE_NOT_DEPLOYED
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_DND_BNODE_NOT_DEPLOYED
);
}
}
test
.
Restart
();
test
.
Restart
();
...
@@ -115,9 +115,9 @@ TEST_F(DndTestBnode, 01_Drop_Bnode) {
...
@@ -115,9 +115,9 @@ TEST_F(DndTestBnode, 01_Drop_Bnode) {
SDDropBnodeReq
*
pReq
=
(
SDDropBnodeReq
*
)
rpcMallocCont
(
contLen
);
SDDropBnodeReq
*
pReq
=
(
SDDropBnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_DROP_BNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_DROP_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_DND_BNODE_NOT_DEPLOYED
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_DND_BNODE_NOT_DEPLOYED
);
}
}
{
{
...
@@ -126,8 +126,8 @@ TEST_F(DndTestBnode, 01_Drop_Bnode) {
...
@@ -126,8 +126,8 @@ TEST_F(DndTestBnode, 01_Drop_Bnode) {
SDCreateBnodeReq
*
pReq
=
(
SDCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
SDCreateBnodeReq
*
pReq
=
(
SDCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_CREATE_BNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
}
}
}
\ No newline at end of file
source/dnode/mgmt/impl/test/cluster/CMakeLists.txt
已删除
100644 → 0
浏览文件 @
5c66e5f2
aux_source_directory
(
. CLUSTER_SRC
)
add_executable
(
dnode_test_cluster
${
CLUSTER_SRC
}
)
target_link_libraries
(
dnode_test_cluster
PUBLIC sut
)
add_test
(
NAME dnode_test_cluster
COMMAND dnode_test_cluster
)
source/dnode/mgmt/impl/test/cluster/cluster.cpp
已删除
100644 → 0
浏览文件 @
5c66e5f2
/**
* @file cluster.cpp
* @author slguan (slguan@taosdata.com)
* @brief DNODE module cluster-msg tests
* @version 0.1
* @date 2021-12-15
*
* @copyright Copyright (c) 2021
*
*/
#include "sut.h"
class
DndTestCluster
:
public
::
testing
::
Test
{
protected:
static
void
SetUpTestSuite
()
{
test
.
Init
(
"/tmp/dnode_test_cluster"
,
9030
);
}
static
void
TearDownTestSuite
()
{
test
.
Cleanup
();
}
static
Testbase
test
;
public:
void
SetUp
()
override
{}
void
TearDown
()
override
{}
};
Testbase
DndTestCluster
::
test
;
TEST_F
(
DndTestCluster
,
01
_ShowCluster
)
{
test
.
SendShowMetaMsg
(
TSDB_MGMT_TABLE_CLUSTER
,
""
);
CHECK_META
(
"show cluster"
,
3
);
CHECK_SCHEMA
(
0
,
TSDB_DATA_TYPE_BIGINT
,
8
,
"id"
);
CHECK_SCHEMA
(
1
,
TSDB_DATA_TYPE_BINARY
,
TSDB_CLUSTER_ID_LEN
+
VARSTR_HEADER_SIZE
,
"name"
);
CHECK_SCHEMA
(
2
,
TSDB_DATA_TYPE_TIMESTAMP
,
8
,
"create_time"
);
test
.
SendShowRetrieveMsg
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
IgnoreInt64
();
IgnoreBinary
(
TSDB_CLUSTER_ID_LEN
);
CheckTimestamp
();
}
\ No newline at end of file
source/dnode/mgmt/impl/test/db/db.cpp
浏览文件 @
96f2aea2
...
@@ -26,7 +26,7 @@ class DndTestDb : public ::testing::Test {
...
@@ -26,7 +26,7 @@ class DndTestDb : public ::testing::Test {
Testbase
DndTestDb
::
test
;
Testbase
DndTestDb
::
test
;
TEST_F
(
DndTestDb
,
01
_ShowDb
)
{
TEST_F
(
DndTestDb
,
01
_ShowDb
)
{
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_DB
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_DB
,
""
);
CHECK_META
(
"show databases"
,
18
);
CHECK_META
(
"show databases"
,
18
);
CHECK_SCHEMA
(
0
,
TSDB_DATA_TYPE_BINARY
,
TSDB_DB_NAME_LEN
-
1
+
VARSTR_HEADER_SIZE
,
"name"
);
CHECK_SCHEMA
(
0
,
TSDB_DATA_TYPE_BINARY
,
TSDB_DB_NAME_LEN
-
1
+
VARSTR_HEADER_SIZE
,
"name"
);
CHECK_SCHEMA
(
1
,
TSDB_DATA_TYPE_TIMESTAMP
,
8
,
"create_time"
);
CHECK_SCHEMA
(
1
,
TSDB_DATA_TYPE_TIMESTAMP
,
8
,
"create_time"
);
...
@@ -47,7 +47,7 @@ TEST_F(DndTestDb, 01_ShowDb) {
...
@@ -47,7 +47,7 @@ TEST_F(DndTestDb, 01_ShowDb) {
CHECK_SCHEMA
(
16
,
TSDB_DATA_TYPE_BINARY
,
3
+
VARSTR_HEADER_SIZE
,
"precision"
);
CHECK_SCHEMA
(
16
,
TSDB_DATA_TYPE_BINARY
,
3
+
VARSTR_HEADER_SIZE
,
"precision"
);
CHECK_SCHEMA
(
17
,
TSDB_DATA_TYPE_TINYINT
,
1
,
"update"
);
CHECK_SCHEMA
(
17
,
TSDB_DATA_TYPE_TINYINT
,
1
,
"update"
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
0
);
EXPECT_EQ
(
test
.
GetShowRows
(),
0
);
}
}
...
@@ -77,15 +77,15 @@ TEST_F(DndTestDb, 02_Create_Alter_Drop_Db) {
...
@@ -77,15 +77,15 @@ TEST_F(DndTestDb, 02_Create_Alter_Drop_Db) {
pReq
->
cacheLastRow
=
0
;
pReq
->
cacheLastRow
=
0
;
pReq
->
ignoreExist
=
1
;
pReq
->
ignoreExist
=
1
;
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_DB
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DB
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
}
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_DB
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_DB
,
""
);
CHECK_META
(
"show databases"
,
18
);
CHECK_META
(
"show databases"
,
18
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckBinary
(
"d1"
,
TSDB_DB_NAME_LEN
-
1
);
CheckBinary
(
"d1"
,
TSDB_DB_NAME_LEN
-
1
);
CheckTimestamp
();
CheckTimestamp
();
...
@@ -106,14 +106,14 @@ TEST_F(DndTestDb, 02_Create_Alter_Drop_Db) {
...
@@ -106,14 +106,14 @@ TEST_F(DndTestDb, 02_Create_Alter_Drop_Db) {
CheckBinary
(
"ms"
,
3
);
// precision
CheckBinary
(
"ms"
,
3
);
// precision
CheckInt8
(
0
);
// update
CheckInt8
(
0
);
// update
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_VGROUP
,
"1.d1"
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_VGROUP
,
"1.d1"
);
CHECK_META
(
"show vgroups"
,
4
);
CHECK_META
(
"show vgroups"
,
4
);
CHECK_SCHEMA
(
0
,
TSDB_DATA_TYPE_INT
,
4
,
"vgId"
);
CHECK_SCHEMA
(
0
,
TSDB_DATA_TYPE_INT
,
4
,
"vgId"
);
CHECK_SCHEMA
(
1
,
TSDB_DATA_TYPE_INT
,
4
,
"tables"
);
CHECK_SCHEMA
(
1
,
TSDB_DATA_TYPE_INT
,
4
,
"tables"
);
CHECK_SCHEMA
(
2
,
TSDB_DATA_TYPE_SMALLINT
,
2
,
"v1_dnode"
);
CHECK_SCHEMA
(
2
,
TSDB_DATA_TYPE_SMALLINT
,
2
,
"v1_dnode"
);
CHECK_SCHEMA
(
3
,
TSDB_DATA_TYPE_BINARY
,
9
+
VARSTR_HEADER_SIZE
,
"v1_status"
);
CHECK_SCHEMA
(
3
,
TSDB_DATA_TYPE_BINARY
,
9
+
VARSTR_HEADER_SIZE
,
"v1_status"
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
CheckInt32
(
2
);
CheckInt32
(
2
);
CheckInt32
(
3
);
CheckInt32
(
3
);
...
@@ -138,13 +138,13 @@ TEST_F(DndTestDb, 02_Create_Alter_Drop_Db) {
...
@@ -138,13 +138,13 @@ TEST_F(DndTestDb, 02_Create_Alter_Drop_Db) {
pReq
->
quorum
=
2
;
pReq
->
quorum
=
2
;
pReq
->
cacheLastRow
=
1
;
pReq
->
cacheLastRow
=
1
;
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_ALTER_DB
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_ALTER_DB
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
}
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_DB
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_DB
,
""
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckBinary
(
"d1"
,
TSDB_DB_NAME_LEN
-
1
);
CheckBinary
(
"d1"
,
TSDB_DB_NAME_LEN
-
1
);
CheckTimestamp
();
CheckTimestamp
();
...
@@ -168,10 +168,10 @@ TEST_F(DndTestDb, 02_Create_Alter_Drop_Db) {
...
@@ -168,10 +168,10 @@ TEST_F(DndTestDb, 02_Create_Alter_Drop_Db) {
// restart
// restart
test
.
Restart
();
test
.
Restart
();
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_DB
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_DB
,
""
);
CHECK_META
(
"show databases"
,
18
);
CHECK_META
(
"show databases"
,
18
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckBinary
(
"d1"
,
TSDB_DB_NAME_LEN
-
1
);
CheckBinary
(
"d1"
,
TSDB_DB_NAME_LEN
-
1
);
...
@@ -199,15 +199,15 @@ TEST_F(DndTestDb, 02_Create_Alter_Drop_Db) {
...
@@ -199,15 +199,15 @@ TEST_F(DndTestDb, 02_Create_Alter_Drop_Db) {
SDropDbMsg
*
pReq
=
(
SDropDbMsg
*
)
rpcMallocCont
(
contLen
);
SDropDbMsg
*
pReq
=
(
SDropDbMsg
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
db
,
"1.d1"
);
strcpy
(
pReq
->
db
,
"1.d1"
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_DROP_DB
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_DROP_DB
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
}
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_DB
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_DB
,
""
);
CHECK_META
(
"show databases"
,
18
);
CHECK_META
(
"show databases"
,
18
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
0
);
EXPECT_EQ
(
test
.
GetShowRows
(),
0
);
}
}
...
@@ -237,15 +237,15 @@ TEST_F(DndTestDb, 03_Create_Use_Restart_Use_Db) {
...
@@ -237,15 +237,15 @@ TEST_F(DndTestDb, 03_Create_Use_Restart_Use_Db) {
pReq
->
cacheLastRow
=
0
;
pReq
->
cacheLastRow
=
0
;
pReq
->
ignoreExist
=
1
;
pReq
->
ignoreExist
=
1
;
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_DB
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DB
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
}
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_DB
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_DB
,
""
);
CHECK_META
(
"show databases"
,
18
);
CHECK_META
(
"show databases"
,
18
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckBinary
(
"d2"
,
TSDB_DB_NAME_LEN
-
1
);
CheckBinary
(
"d2"
,
TSDB_DB_NAME_LEN
-
1
);
...
@@ -256,7 +256,7 @@ TEST_F(DndTestDb, 03_Create_Use_Restart_Use_Db) {
...
@@ -256,7 +256,7 @@ TEST_F(DndTestDb, 03_Create_Use_Restart_Use_Db) {
strcpy
(
pReq
->
db
,
"1.d2"
);
strcpy
(
pReq
->
db
,
"1.d2"
);
pReq
->
vgVersion
=
htonl
(
-
1
);
pReq
->
vgVersion
=
htonl
(
-
1
);
SRpcMsg
*
pMsg
=
test
.
Send
Msg
(
TDMT_MND_USE_DB
,
pReq
,
contLen
);
SRpcMsg
*
pMsg
=
test
.
Send
Req
(
TDMT_MND_USE_DB
,
pReq
,
contLen
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
...
...
source/dnode/mgmt/impl/test/dnode/dnode.cpp
浏览文件 @
96f2aea2
...
@@ -51,7 +51,7 @@ TestServer DndTestDnode::server4;
...
@@ -51,7 +51,7 @@ TestServer DndTestDnode::server4;
TestServer
DndTestDnode
::
server5
;
TestServer
DndTestDnode
::
server5
;
TEST_F
(
DndTestDnode
,
01
_ShowDnode
)
{
TEST_F
(
DndTestDnode
,
01
_ShowDnode
)
{
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_DNODE
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_DNODE
,
""
);
CHECK_META
(
"show dnodes"
,
7
);
CHECK_META
(
"show dnodes"
,
7
);
CHECK_SCHEMA
(
0
,
TSDB_DATA_TYPE_SMALLINT
,
2
,
"id"
);
CHECK_SCHEMA
(
0
,
TSDB_DATA_TYPE_SMALLINT
,
2
,
"id"
);
...
@@ -62,7 +62,7 @@ TEST_F(DndTestDnode, 01_ShowDnode) {
...
@@ -62,7 +62,7 @@ TEST_F(DndTestDnode, 01_ShowDnode) {
CHECK_SCHEMA
(
5
,
TSDB_DATA_TYPE_TIMESTAMP
,
8
,
"create_time"
);
CHECK_SCHEMA
(
5
,
TSDB_DATA_TYPE_TIMESTAMP
,
8
,
"create_time"
);
CHECK_SCHEMA
(
6
,
TSDB_DATA_TYPE_BINARY
,
24
+
VARSTR_HEADER_SIZE
,
"offline_reason"
);
CHECK_SCHEMA
(
6
,
TSDB_DATA_TYPE_BINARY
,
24
+
VARSTR_HEADER_SIZE
,
"offline_reason"
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckInt16
(
1
);
CheckInt16
(
1
);
...
@@ -81,9 +81,9 @@ TEST_F(DndTestDnode, 02_ConfigDnode) {
...
@@ -81,9 +81,9 @@ TEST_F(DndTestDnode, 02_ConfigDnode) {
pReq
->
dnodeId
=
htonl
(
1
);
pReq
->
dnodeId
=
htonl
(
1
);
strcpy
(
pReq
->
config
,
"ddebugflag 131"
);
strcpy
(
pReq
->
config
,
"ddebugflag 131"
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CONFIG_DNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CONFIG_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
}
TEST_F
(
DndTestDnode
,
03
_Create_Drop_Restart_Dnode
)
{
TEST_F
(
DndTestDnode
,
03
_Create_Drop_Restart_Dnode
)
{
...
@@ -94,16 +94,16 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
...
@@ -94,16 +94,16 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
strcpy
(
pReq
->
fqdn
,
"localhost"
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
pReq
->
port
=
htonl
(
9042
);
pReq
->
port
=
htonl
(
9042
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
}
taosMsleep
(
1300
);
taosMsleep
(
1300
);
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_DNODE
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_DNODE
,
""
);
CHECK_META
(
"show dnodes"
,
7
);
CHECK_META
(
"show dnodes"
,
7
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
CheckInt16
(
1
);
CheckInt16
(
1
);
...
@@ -127,14 +127,14 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
...
@@ -127,14 +127,14 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
SDropDnodeMsg
*
pReq
=
(
SDropDnodeMsg
*
)
rpcMallocCont
(
contLen
);
SDropDnodeMsg
*
pReq
=
(
SDropDnodeMsg
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_DROP_DNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_DROP_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
}
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_DNODE
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_DNODE
,
""
);
CHECK_META
(
"show dnodes"
,
7
);
CHECK_META
(
"show dnodes"
,
7
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckInt16
(
1
);
CheckInt16
(
1
);
...
@@ -152,9 +152,9 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
...
@@ -152,9 +152,9 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
strcpy
(
pReq
->
fqdn
,
"localhost"
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
pReq
->
port
=
htonl
(
9043
);
pReq
->
port
=
htonl
(
9043
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
}
{
{
...
@@ -164,9 +164,9 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
...
@@ -164,9 +164,9 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
strcpy
(
pReq
->
fqdn
,
"localhost"
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
pReq
->
port
=
htonl
(
9044
);
pReq
->
port
=
htonl
(
9044
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
}
{
{
...
@@ -176,15 +176,15 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
...
@@ -176,15 +176,15 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
strcpy
(
pReq
->
fqdn
,
"localhost"
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
pReq
->
port
=
htonl
(
9045
);
pReq
->
port
=
htonl
(
9045
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
}
taosMsleep
(
1300
);
taosMsleep
(
1300
);
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_DNODE
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_DNODE
,
""
);
CHECK_META
(
"show dnodes"
,
7
);
CHECK_META
(
"show dnodes"
,
7
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
4
);
EXPECT_EQ
(
test
.
GetShowRows
(),
4
);
CheckInt16
(
1
);
CheckInt16
(
1
);
...
@@ -225,9 +225,9 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
...
@@ -225,9 +225,9 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
server5
.
Restart
();
server5
.
Restart
();
taosMsleep
(
1300
);
taosMsleep
(
1300
);
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_DNODE
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_DNODE
,
""
);
CHECK_META
(
"show dnodes"
,
7
);
CHECK_META
(
"show dnodes"
,
7
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
4
);
EXPECT_EQ
(
test
.
GetShowRows
(),
4
);
CheckInt16
(
1
);
CheckInt16
(
1
);
...
...
source/dnode/mgmt/impl/test/mnode/mnode.cpp
浏览文件 @
96f2aea2
...
@@ -51,7 +51,7 @@ TestServer DndTestMnode::server4;
...
@@ -51,7 +51,7 @@ TestServer DndTestMnode::server4;
TestServer
DndTestMnode
::
server5
;
TestServer
DndTestMnode
::
server5
;
TEST_F
(
DndTestMnode
,
01
_ShowDnode
)
{
TEST_F
(
DndTestMnode
,
01
_ShowDnode
)
{
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_MNODE
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_MNODE
,
""
);
CHECK_META
(
"show mnodes"
,
5
);
CHECK_META
(
"show mnodes"
,
5
);
CHECK_SCHEMA
(
0
,
TSDB_DATA_TYPE_SMALLINT
,
2
,
"id"
);
CHECK_SCHEMA
(
0
,
TSDB_DATA_TYPE_SMALLINT
,
2
,
"id"
);
...
@@ -60,7 +60,7 @@ TEST_F(DndTestMnode, 01_ShowDnode) {
...
@@ -60,7 +60,7 @@ TEST_F(DndTestMnode, 01_ShowDnode) {
CHECK_SCHEMA
(
3
,
TSDB_DATA_TYPE_TIMESTAMP
,
8
,
"role_time"
);
CHECK_SCHEMA
(
3
,
TSDB_DATA_TYPE_TIMESTAMP
,
8
,
"role_time"
);
CHECK_SCHEMA
(
4
,
TSDB_DATA_TYPE_TIMESTAMP
,
8
,
"create_time"
);
CHECK_SCHEMA
(
4
,
TSDB_DATA_TYPE_TIMESTAMP
,
8
,
"create_time"
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckInt16
(
1
);
CheckInt16
(
1
);
...
@@ -77,9 +77,9 @@ TEST_F(DndTestMnode, 02_Create_Mnode_Invalid_Id) {
...
@@ -77,9 +77,9 @@ TEST_F(DndTestMnode, 02_Create_Mnode_Invalid_Id) {
SMCreateMnodeMsg
*
pReq
=
(
SMCreateMnodeMsg
*
)
rpcMallocCont
(
contLen
);
SMCreateMnodeMsg
*
pReq
=
(
SMCreateMnodeMsg
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_MNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_MNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_MNODE_ALREADY_EXIST
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_MNODE_ALREADY_EXIST
);
}
}
}
}
...
@@ -90,9 +90,9 @@ TEST_F(DndTestMnode, 03_Create_Mnode_Invalid_Id) {
...
@@ -90,9 +90,9 @@ TEST_F(DndTestMnode, 03_Create_Mnode_Invalid_Id) {
SMCreateMnodeMsg
*
pReq
=
(
SMCreateMnodeMsg
*
)
rpcMallocCont
(
contLen
);
SMCreateMnodeMsg
*
pReq
=
(
SMCreateMnodeMsg
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_MNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_MNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_DNODE_NOT_EXIST
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_DNODE_NOT_EXIST
);
}
}
}
}
...
@@ -105,13 +105,13 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
...
@@ -105,13 +105,13 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
strcpy
(
pReq
->
fqdn
,
"localhost"
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
pReq
->
port
=
htonl
(
9062
);
pReq
->
port
=
htonl
(
9062
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
taosMsleep
(
1300
);
taosMsleep
(
1300
);
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_DNODE
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_DNODE
,
""
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
}
}
...
@@ -122,12 +122,12 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
...
@@ -122,12 +122,12 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
SMCreateMnodeMsg
*
pReq
=
(
SMCreateMnodeMsg
*
)
rpcMallocCont
(
contLen
);
SMCreateMnodeMsg
*
pReq
=
(
SMCreateMnodeMsg
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_MNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_MNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_MNODE
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_MNODE
,
""
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
CheckInt16
(
1
);
CheckInt16
(
1
);
...
@@ -149,12 +149,12 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
...
@@ -149,12 +149,12 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
SMDropMnodeMsg
*
pReq
=
(
SMDropMnodeMsg
*
)
rpcMallocCont
(
contLen
);
SMDropMnodeMsg
*
pReq
=
(
SMDropMnodeMsg
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_DROP_MNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_DROP_MNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_MNODE
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_MNODE
,
""
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckInt16
(
1
);
CheckInt16
(
1
);
...
@@ -170,14 +170,14 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
...
@@ -170,14 +170,14 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
// SDropDnodeMsg* pReq = (SDropDnodeMsg*)rpcMallocCont(contLen);
// SDropDnodeMsg* pReq = (SDropDnodeMsg*)rpcMallocCont(contLen);
// pReq->dnodeId = htonl(2);
// pReq->dnodeId = htonl(2);
// SRpcMsg* p
Msg = test.SendMsg
(TDMT_MND_DROP_DNODE, pReq, contLen);
// SRpcMsg* p
Rsp = test.SendReq
(TDMT_MND_DROP_DNODE, pReq, contLen);
// ASSERT_NE(p
Msg
, nullptr);
// ASSERT_NE(p
Rsp
, nullptr);
// ASSERT_EQ(p
Msg
->code, 0);
// ASSERT_EQ(p
Rsp
->code, 0);
// }
// }
// test.SendShowMeta
Msg
(TSDB_MGMT_TABLE_DNODE, "");
// test.SendShowMeta
Req
(TSDB_MGMT_TABLE_DNODE, "");
// CHECK_META("show dnodes", 7);
// CHECK_META("show dnodes", 7);
// test.SendShowRetrieve
Msg
();
// test.SendShowRetrieve
Req
();
// EXPECT_EQ(test.GetShowRows(), 1);
// EXPECT_EQ(test.GetShowRows(), 1);
// CheckInt16(1);
// CheckInt16(1);
...
@@ -194,9 +194,9 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
...
@@ -194,9 +194,9 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
// SCreateDnodeMsg* pReq = (SCreateDnodeMsg*)rpcMallocCont(contLen);
// SCreateDnodeMsg* pReq = (SCreateDnodeMsg*)rpcMallocCont(contLen);
// strcpy(pReq->ep, "localhost:9063");
// strcpy(pReq->ep, "localhost:9063");
// SRpcMsg* p
Msg = test.SendMsg
(TDMT_MND_CREATE_DNODE, pReq, contLen);
// SRpcMsg* p
Rsp = test.SendReq
(TDMT_MND_CREATE_DNODE, pReq, contLen);
// ASSERT_NE(p
Msg
, nullptr);
// ASSERT_NE(p
Rsp
, nullptr);
// ASSERT_EQ(p
Msg
->code, 0);
// ASSERT_EQ(p
Rsp
->code, 0);
// }
// }
// {
// {
...
@@ -205,9 +205,9 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
...
@@ -205,9 +205,9 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
// SCreateDnodeMsg* pReq = (SCreateDnodeMsg*)rpcMallocCont(contLen);
// SCreateDnodeMsg* pReq = (SCreateDnodeMsg*)rpcMallocCont(contLen);
// strcpy(pReq->ep, "localhost:9064");
// strcpy(pReq->ep, "localhost:9064");
// SRpcMsg* p
Msg = test.SendMsg
(TDMT_MND_CREATE_DNODE, pReq, contLen);
// SRpcMsg* p
Rsp = test.SendReq
(TDMT_MND_CREATE_DNODE, pReq, contLen);
// ASSERT_NE(p
Msg
, nullptr);
// ASSERT_NE(p
Rsp
, nullptr);
// ASSERT_EQ(p
Msg
->code, 0);
// ASSERT_EQ(p
Rsp
->code, 0);
// }
// }
// {
// {
...
@@ -216,15 +216,15 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
...
@@ -216,15 +216,15 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
// SCreateDnodeMsg* pReq = (SCreateDnodeMsg*)rpcMallocCont(contLen);
// SCreateDnodeMsg* pReq = (SCreateDnodeMsg*)rpcMallocCont(contLen);
// strcpy(pReq->ep, "localhost:9065");
// strcpy(pReq->ep, "localhost:9065");
// SRpcMsg* p
Msg = test.SendMsg
(TDMT_MND_CREATE_DNODE, pReq, contLen);
// SRpcMsg* p
Rsp = test.SendReq
(TDMT_MND_CREATE_DNODE, pReq, contLen);
// ASSERT_NE(p
Msg
, nullptr);
// ASSERT_NE(p
Rsp
, nullptr);
// ASSERT_EQ(p
Msg
->code, 0);
// ASSERT_EQ(p
Rsp
->code, 0);
// }
// }
// taosMsleep(1300);
// taosMsleep(1300);
// test.SendShowMeta
Msg
(TSDB_MGMT_TABLE_DNODE, "");
// test.SendShowMeta
Req
(TSDB_MGMT_TABLE_DNODE, "");
// CHECK_META("show dnodes", 7);
// CHECK_META("show dnodes", 7);
// test.SendShowRetrieve
Msg
();
// test.SendShowRetrieve
Req
();
// EXPECT_EQ(test.GetShowRows(), 4);
// EXPECT_EQ(test.GetShowRows(), 4);
// CheckInt16(1);
// CheckInt16(1);
...
@@ -265,9 +265,9 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
...
@@ -265,9 +265,9 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
// server5.Restart();
// server5.Restart();
// taosMsleep(1300);
// taosMsleep(1300);
// test.SendShowMeta
Msg
(TSDB_MGMT_TABLE_DNODE, "");
// test.SendShowMeta
Req
(TSDB_MGMT_TABLE_DNODE, "");
// CHECK_META("show dnodes", 7);
// CHECK_META("show dnodes", 7);
// test.SendShowRetrieve
Msg
();
// test.SendShowRetrieve
Req
();
// EXPECT_EQ(test.GetShowRows(), 4);
// EXPECT_EQ(test.GetShowRows(), 4);
// CheckInt16(1);
// CheckInt16(1);
...
...
source/dnode/mgmt/impl/test/profile/profile.cpp
浏览文件 @
96f2aea2
...
@@ -35,7 +35,7 @@ TEST_F(DndTestProfile, 01_ConnectMsg) {
...
@@ -35,7 +35,7 @@ TEST_F(DndTestProfile, 01_ConnectMsg) {
strcpy
(
pReq
->
app
,
"dnode_test_profile"
);
strcpy
(
pReq
->
app
,
"dnode_test_profile"
);
strcpy
(
pReq
->
db
,
""
);
strcpy
(
pReq
->
db
,
""
);
SRpcMsg
*
pMsg
=
test
.
Send
Msg
(
TDMT_MND_CONNECT
,
pReq
,
contLen
);
SRpcMsg
*
pMsg
=
test
.
Send
Req
(
TDMT_MND_CONNECT
,
pReq
,
contLen
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
...
@@ -67,14 +67,14 @@ TEST_F(DndTestProfile, 02_ConnectMsg_InvalidDB) {
...
@@ -67,14 +67,14 @@ TEST_F(DndTestProfile, 02_ConnectMsg_InvalidDB) {
strcpy
(
pReq
->
app
,
"dnode_test_profile"
);
strcpy
(
pReq
->
app
,
"dnode_test_profile"
);
strcpy
(
pReq
->
db
,
"invalid_db"
);
strcpy
(
pReq
->
db
,
"invalid_db"
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CONNECT
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CONNECT
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_INVALID_DB
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_INVALID_DB
);
ASSERT_EQ
(
p
Msg
->
contLen
,
0
);
ASSERT_EQ
(
p
Rsp
->
contLen
,
0
);
}
}
TEST_F
(
DndTestProfile
,
03
_ConnectMsg_Show
)
{
TEST_F
(
DndTestProfile
,
03
_ConnectMsg_Show
)
{
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_CONNS
,
""
);
test
.
SendShowMeta
Req
(
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"
);
CHECK_SCHEMA
(
1
,
TSDB_DATA_TYPE_BINARY
,
TSDB_USER_LEN
+
VARSTR_HEADER_SIZE
,
"user"
);
CHECK_SCHEMA
(
1
,
TSDB_DATA_TYPE_BINARY
,
TSDB_USER_LEN
+
VARSTR_HEADER_SIZE
,
"user"
);
...
@@ -84,7 +84,7 @@ TEST_F(DndTestProfile, 03_ConnectMsg_Show) {
...
@@ -84,7 +84,7 @@ TEST_F(DndTestProfile, 03_ConnectMsg_Show) {
CHECK_SCHEMA
(
5
,
TSDB_DATA_TYPE_TIMESTAMP
,
8
,
"login_time"
);
CHECK_SCHEMA
(
5
,
TSDB_DATA_TYPE_TIMESTAMP
,
8
,
"login_time"
);
CHECK_SCHEMA
(
6
,
TSDB_DATA_TYPE_TIMESTAMP
,
8
,
"last_access"
);
CHECK_SCHEMA
(
6
,
TSDB_DATA_TYPE_TIMESTAMP
,
8
,
"last_access"
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckInt32
(
1
);
CheckInt32
(
1
);
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
...
@@ -105,7 +105,7 @@ TEST_F(DndTestProfile, 04_HeartBeatMsg) {
...
@@ -105,7 +105,7 @@ TEST_F(DndTestProfile, 04_HeartBeatMsg) {
pReq
->
numOfStreams
=
htonl
(
0
);
pReq
->
numOfStreams
=
htonl
(
0
);
strcpy
(
pReq
->
app
,
"dnode_test_profile"
);
strcpy
(
pReq
->
app
,
"dnode_test_profile"
);
SRpcMsg
*
pMsg
=
test
.
Send
Msg
(
TDMT_MND_HEARTBEAT
,
pReq
,
contLen
);
SRpcMsg
*
pMsg
=
test
.
Send
Req
(
TDMT_MND_HEARTBEAT
,
pReq
,
contLen
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
...
@@ -138,9 +138,9 @@ TEST_F(DndTestProfile, 05_KillConnMsg) {
...
@@ -138,9 +138,9 @@ TEST_F(DndTestProfile, 05_KillConnMsg) {
SKillConnMsg
*
pReq
=
(
SKillConnMsg
*
)
rpcMallocCont
(
contLen
);
SKillConnMsg
*
pReq
=
(
SKillConnMsg
*
)
rpcMallocCont
(
contLen
);
pReq
->
connId
=
htonl
(
connId
);
pReq
->
connId
=
htonl
(
connId
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_KILL_CONN
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_KILL_CONN
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
}
{
{
...
@@ -153,10 +153,10 @@ TEST_F(DndTestProfile, 05_KillConnMsg) {
...
@@ -153,10 +153,10 @@ TEST_F(DndTestProfile, 05_KillConnMsg) {
pReq
->
numOfStreams
=
htonl
(
0
);
pReq
->
numOfStreams
=
htonl
(
0
);
strcpy
(
pReq
->
app
,
"dnode_test_profile"
);
strcpy
(
pReq
->
app
,
"dnode_test_profile"
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_HEARTBEAT
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_HEARTBEAT
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_INVALID_CONNECTION
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_INVALID_CONNECTION
);
ASSERT_EQ
(
p
Msg
->
contLen
,
0
);
ASSERT_EQ
(
p
Rsp
->
contLen
,
0
);
}
}
{
{
...
@@ -167,7 +167,7 @@ TEST_F(DndTestProfile, 05_KillConnMsg) {
...
@@ -167,7 +167,7 @@ TEST_F(DndTestProfile, 05_KillConnMsg) {
strcpy
(
pReq
->
app
,
"dnode_test_profile"
);
strcpy
(
pReq
->
app
,
"dnode_test_profile"
);
strcpy
(
pReq
->
db
,
""
);
strcpy
(
pReq
->
db
,
""
);
SRpcMsg
*
pMsg
=
test
.
Send
Msg
(
TDMT_MND_CONNECT
,
pReq
,
contLen
);
SRpcMsg
*
pMsg
=
test
.
Send
Req
(
TDMT_MND_CONNECT
,
pReq
,
contLen
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
...
@@ -198,9 +198,9 @@ TEST_F(DndTestProfile, 06_KillConnMsg_InvalidConn) {
...
@@ -198,9 +198,9 @@ TEST_F(DndTestProfile, 06_KillConnMsg_InvalidConn) {
SKillConnMsg
*
pReq
=
(
SKillConnMsg
*
)
rpcMallocCont
(
contLen
);
SKillConnMsg
*
pReq
=
(
SKillConnMsg
*
)
rpcMallocCont
(
contLen
);
pReq
->
connId
=
htonl
(
2345
);
pReq
->
connId
=
htonl
(
2345
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_KILL_CONN
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_KILL_CONN
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_INVALID_CONN_ID
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_INVALID_CONN_ID
);
}
}
TEST_F
(
DndTestProfile
,
07
_KillQueryMsg
)
{
TEST_F
(
DndTestProfile
,
07
_KillQueryMsg
)
{
...
@@ -211,10 +211,10 @@ TEST_F(DndTestProfile, 07_KillQueryMsg) {
...
@@ -211,10 +211,10 @@ TEST_F(DndTestProfile, 07_KillQueryMsg) {
pReq
->
connId
=
htonl
(
connId
);
pReq
->
connId
=
htonl
(
connId
);
pReq
->
queryId
=
htonl
(
1234
);
pReq
->
queryId
=
htonl
(
1234
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_KILL_QUERY
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_KILL_QUERY
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
ASSERT_EQ
(
p
Msg
->
contLen
,
0
);
ASSERT_EQ
(
p
Rsp
->
contLen
,
0
);
}
}
{
{
...
@@ -227,7 +227,7 @@ TEST_F(DndTestProfile, 07_KillQueryMsg) {
...
@@ -227,7 +227,7 @@ TEST_F(DndTestProfile, 07_KillQueryMsg) {
pReq
->
numOfStreams
=
htonl
(
0
);
pReq
->
numOfStreams
=
htonl
(
0
);
strcpy
(
pReq
->
app
,
"dnode_test_profile"
);
strcpy
(
pReq
->
app
,
"dnode_test_profile"
);
SRpcMsg
*
pMsg
=
test
.
Send
Msg
(
TDMT_MND_HEARTBEAT
,
pReq
,
contLen
);
SRpcMsg
*
pMsg
=
test
.
Send
Req
(
TDMT_MND_HEARTBEAT
,
pReq
,
contLen
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
...
@@ -261,13 +261,13 @@ TEST_F(DndTestProfile, 08_KillQueryMsg_InvalidConn) {
...
@@ -261,13 +261,13 @@ TEST_F(DndTestProfile, 08_KillQueryMsg_InvalidConn) {
pReq
->
connId
=
htonl
(
2345
);
pReq
->
connId
=
htonl
(
2345
);
pReq
->
queryId
=
htonl
(
1234
);
pReq
->
queryId
=
htonl
(
1234
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_KILL_QUERY
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_KILL_QUERY
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_INVALID_CONN_ID
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_INVALID_CONN_ID
);
}
}
TEST_F
(
DndTestProfile
,
09
_KillQueryMsg
)
{
TEST_F
(
DndTestProfile
,
09
_KillQueryMsg
)
{
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_QUERIES
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_QUERIES
,
""
);
CHECK_META
(
"show queries"
,
14
);
CHECK_META
(
"show queries"
,
14
);
CHECK_SCHEMA
(
0
,
TSDB_DATA_TYPE_INT
,
4
,
"queryId"
);
CHECK_SCHEMA
(
0
,
TSDB_DATA_TYPE_INT
,
4
,
"queryId"
);
...
@@ -285,6 +285,6 @@ TEST_F(DndTestProfile, 09_KillQueryMsg) {
...
@@ -285,6 +285,6 @@ TEST_F(DndTestProfile, 09_KillQueryMsg) {
CHECK_SCHEMA
(
12
,
TSDB_DATA_TYPE_BINARY
,
TSDB_SHOW_SUBQUERY_LEN
+
VARSTR_HEADER_SIZE
,
"sub_query_info"
);
CHECK_SCHEMA
(
12
,
TSDB_DATA_TYPE_BINARY
,
TSDB_SHOW_SUBQUERY_LEN
+
VARSTR_HEADER_SIZE
,
"sub_query_info"
);
CHECK_SCHEMA
(
13
,
TSDB_DATA_TYPE_BINARY
,
TSDB_SHOW_SQL_LEN
+
VARSTR_HEADER_SIZE
,
"sql"
);
CHECK_SCHEMA
(
13
,
TSDB_DATA_TYPE_BINARY
,
TSDB_SHOW_SQL_LEN
+
VARSTR_HEADER_SIZE
,
"sql"
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
0
);
EXPECT_EQ
(
test
.
GetShowRows
(),
0
);
}
}
source/dnode/mgmt/impl/test/qnode/dqnode.cpp
浏览文件 @
96f2aea2
...
@@ -32,9 +32,9 @@ TEST_F(DndTestQnode, 01_Create_Qnode) {
...
@@ -32,9 +32,9 @@ TEST_F(DndTestQnode, 01_Create_Qnode) {
SDCreateQnodeReq
*
pReq
=
(
SDCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
SDCreateQnodeReq
*
pReq
=
(
SDCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_CREATE_QNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_DND_QNODE_ID_INVALID
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_DND_QNODE_ID_INVALID
);
}
}
{
{
...
@@ -43,9 +43,9 @@ TEST_F(DndTestQnode, 01_Create_Qnode) {
...
@@ -43,9 +43,9 @@ TEST_F(DndTestQnode, 01_Create_Qnode) {
SDCreateQnodeReq
*
pReq
=
(
SDCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
SDCreateQnodeReq
*
pReq
=
(
SDCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_CREATE_QNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
}
{
{
...
@@ -54,9 +54,9 @@ TEST_F(DndTestQnode, 01_Create_Qnode) {
...
@@ -54,9 +54,9 @@ TEST_F(DndTestQnode, 01_Create_Qnode) {
SDCreateQnodeReq
*
pReq
=
(
SDCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
SDCreateQnodeReq
*
pReq
=
(
SDCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_CREATE_QNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_DND_QNODE_ALREADY_DEPLOYED
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_DND_QNODE_ALREADY_DEPLOYED
);
}
}
test
.
Restart
();
test
.
Restart
();
...
@@ -67,22 +67,22 @@ TEST_F(DndTestQnode, 01_Create_Qnode) {
...
@@ -67,22 +67,22 @@ TEST_F(DndTestQnode, 01_Create_Qnode) {
SDCreateQnodeReq
*
pReq
=
(
SDCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
SDCreateQnodeReq
*
pReq
=
(
SDCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_CREATE_QNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_DND_QNODE_ALREADY_DEPLOYED
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_DND_QNODE_ALREADY_DEPLOYED
);
}
}
}
}
TEST_F
(
DndTestQnode
,
0
1
_Drop_Qnode
)
{
TEST_F
(
DndTestQnode
,
0
2
_Drop_Qnode
)
{
{
{
int32_t
contLen
=
sizeof
(
SDDropQnodeReq
);
int32_t
contLen
=
sizeof
(
SDDropQnodeReq
);
SDDropQnodeReq
*
pReq
=
(
SDDropQnodeReq
*
)
rpcMallocCont
(
contLen
);
SDDropQnodeReq
*
pReq
=
(
SDDropQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_DROP_QNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_DROP_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_DND_QNODE_ID_INVALID
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_DND_QNODE_ID_INVALID
);
}
}
{
{
...
@@ -91,9 +91,9 @@ TEST_F(DndTestQnode, 01_Drop_Qnode) {
...
@@ -91,9 +91,9 @@ TEST_F(DndTestQnode, 01_Drop_Qnode) {
SDDropQnodeReq
*
pReq
=
(
SDDropQnodeReq
*
)
rpcMallocCont
(
contLen
);
SDDropQnodeReq
*
pReq
=
(
SDDropQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_DROP_QNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_DROP_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
}
{
{
...
@@ -102,9 +102,9 @@ TEST_F(DndTestQnode, 01_Drop_Qnode) {
...
@@ -102,9 +102,9 @@ TEST_F(DndTestQnode, 01_Drop_Qnode) {
SDDropQnodeReq
*
pReq
=
(
SDDropQnodeReq
*
)
rpcMallocCont
(
contLen
);
SDDropQnodeReq
*
pReq
=
(
SDDropQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_DROP_QNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_DROP_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_DND_QNODE_NOT_DEPLOYED
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_DND_QNODE_NOT_DEPLOYED
);
}
}
test
.
Restart
();
test
.
Restart
();
...
@@ -115,9 +115,9 @@ TEST_F(DndTestQnode, 01_Drop_Qnode) {
...
@@ -115,9 +115,9 @@ TEST_F(DndTestQnode, 01_Drop_Qnode) {
SDDropQnodeReq
*
pReq
=
(
SDDropQnodeReq
*
)
rpcMallocCont
(
contLen
);
SDDropQnodeReq
*
pReq
=
(
SDDropQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_DROP_QNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_DROP_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_DND_QNODE_NOT_DEPLOYED
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_DND_QNODE_NOT_DEPLOYED
);
}
}
{
{
...
@@ -126,8 +126,8 @@ TEST_F(DndTestQnode, 01_Drop_Qnode) {
...
@@ -126,8 +126,8 @@ TEST_F(DndTestQnode, 01_Drop_Qnode) {
SDCreateQnodeReq
*
pReq
=
(
SDCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
SDCreateQnodeReq
*
pReq
=
(
SDCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_CREATE_QNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
}
}
}
\ No newline at end of file
source/dnode/mgmt/impl/test/snode/dsnode.cpp
浏览文件 @
96f2aea2
...
@@ -32,9 +32,9 @@ TEST_F(DndTestSnode, 01_Create_Snode) {
...
@@ -32,9 +32,9 @@ TEST_F(DndTestSnode, 01_Create_Snode) {
SDCreateSnodeReq
*
pReq
=
(
SDCreateSnodeReq
*
)
rpcMallocCont
(
contLen
);
SDCreateSnodeReq
*
pReq
=
(
SDCreateSnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_CREATE_SNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_DND_SNODE_ID_INVALID
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_DND_SNODE_ID_INVALID
);
}
}
{
{
...
@@ -43,9 +43,9 @@ TEST_F(DndTestSnode, 01_Create_Snode) {
...
@@ -43,9 +43,9 @@ TEST_F(DndTestSnode, 01_Create_Snode) {
SDCreateSnodeReq
*
pReq
=
(
SDCreateSnodeReq
*
)
rpcMallocCont
(
contLen
);
SDCreateSnodeReq
*
pReq
=
(
SDCreateSnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_CREATE_SNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
}
{
{
...
@@ -54,9 +54,9 @@ TEST_F(DndTestSnode, 01_Create_Snode) {
...
@@ -54,9 +54,9 @@ TEST_F(DndTestSnode, 01_Create_Snode) {
SDCreateSnodeReq
*
pReq
=
(
SDCreateSnodeReq
*
)
rpcMallocCont
(
contLen
);
SDCreateSnodeReq
*
pReq
=
(
SDCreateSnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_CREATE_SNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_DND_SNODE_ALREADY_DEPLOYED
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_DND_SNODE_ALREADY_DEPLOYED
);
}
}
test
.
Restart
();
test
.
Restart
();
...
@@ -67,9 +67,9 @@ TEST_F(DndTestSnode, 01_Create_Snode) {
...
@@ -67,9 +67,9 @@ TEST_F(DndTestSnode, 01_Create_Snode) {
SDCreateSnodeReq
*
pReq
=
(
SDCreateSnodeReq
*
)
rpcMallocCont
(
contLen
);
SDCreateSnodeReq
*
pReq
=
(
SDCreateSnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_CREATE_SNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_DND_SNODE_ALREADY_DEPLOYED
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_DND_SNODE_ALREADY_DEPLOYED
);
}
}
}
}
...
@@ -80,9 +80,9 @@ TEST_F(DndTestSnode, 01_Drop_Snode) {
...
@@ -80,9 +80,9 @@ TEST_F(DndTestSnode, 01_Drop_Snode) {
SDDropSnodeReq
*
pReq
=
(
SDDropSnodeReq
*
)
rpcMallocCont
(
contLen
);
SDDropSnodeReq
*
pReq
=
(
SDDropSnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_DROP_SNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_DROP_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_DND_SNODE_ID_INVALID
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_DND_SNODE_ID_INVALID
);
}
}
{
{
...
@@ -91,9 +91,9 @@ TEST_F(DndTestSnode, 01_Drop_Snode) {
...
@@ -91,9 +91,9 @@ TEST_F(DndTestSnode, 01_Drop_Snode) {
SDDropSnodeReq
*
pReq
=
(
SDDropSnodeReq
*
)
rpcMallocCont
(
contLen
);
SDDropSnodeReq
*
pReq
=
(
SDDropSnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_DROP_SNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_DROP_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
}
{
{
...
@@ -102,9 +102,9 @@ TEST_F(DndTestSnode, 01_Drop_Snode) {
...
@@ -102,9 +102,9 @@ TEST_F(DndTestSnode, 01_Drop_Snode) {
SDDropSnodeReq
*
pReq
=
(
SDDropSnodeReq
*
)
rpcMallocCont
(
contLen
);
SDDropSnodeReq
*
pReq
=
(
SDDropSnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_DROP_SNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_DROP_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_DND_SNODE_NOT_DEPLOYED
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_DND_SNODE_NOT_DEPLOYED
);
}
}
test
.
Restart
();
test
.
Restart
();
...
@@ -115,9 +115,9 @@ TEST_F(DndTestSnode, 01_Drop_Snode) {
...
@@ -115,9 +115,9 @@ TEST_F(DndTestSnode, 01_Drop_Snode) {
SDDropSnodeReq
*
pReq
=
(
SDDropSnodeReq
*
)
rpcMallocCont
(
contLen
);
SDDropSnodeReq
*
pReq
=
(
SDDropSnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_DROP_SNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_DROP_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_DND_SNODE_NOT_DEPLOYED
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_DND_SNODE_NOT_DEPLOYED
);
}
}
{
{
...
@@ -126,8 +126,8 @@ TEST_F(DndTestSnode, 01_Drop_Snode) {
...
@@ -126,8 +126,8 @@ TEST_F(DndTestSnode, 01_Drop_Snode) {
SDCreateSnodeReq
*
pReq
=
(
SDCreateSnodeReq
*
)
rpcMallocCont
(
contLen
);
SDCreateSnodeReq
*
pReq
=
(
SDCreateSnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_CREATE_SNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
}
}
}
\ No newline at end of file
source/dnode/mgmt/impl/test/stb/stb.cpp
浏览文件 @
96f2aea2
...
@@ -51,9 +51,9 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
...
@@ -51,9 +51,9 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
pReq
->
cacheLastRow
=
0
;
pReq
->
cacheLastRow
=
0
;
pReq
->
ignoreExist
=
1
;
pReq
->
ignoreExist
=
1
;
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_DB
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DB
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
}
{
{
...
@@ -101,12 +101,12 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
...
@@ -101,12 +101,12 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
strcpy
(
pSchema
->
name
,
"tag3"
);
strcpy
(
pSchema
->
name
,
"tag3"
);
}
}
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_STB
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_STB
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
}
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_STB
,
"1.d1"
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_STB
,
"1.d1"
);
CHECK_META
(
"show stables"
,
4
);
CHECK_META
(
"show stables"
,
4
);
CHECK_SCHEMA
(
0
,
TSDB_DATA_TYPE_BINARY
,
TSDB_TABLE_NAME_LEN
+
VARSTR_HEADER_SIZE
,
"name"
);
CHECK_SCHEMA
(
0
,
TSDB_DATA_TYPE_BINARY
,
TSDB_TABLE_NAME_LEN
+
VARSTR_HEADER_SIZE
,
"name"
);
...
@@ -114,7 +114,7 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
...
@@ -114,7 +114,7 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
CHECK_SCHEMA
(
2
,
TSDB_DATA_TYPE_INT
,
4
,
"columns"
);
CHECK_SCHEMA
(
2
,
TSDB_DATA_TYPE_INT
,
4
,
"columns"
);
CHECK_SCHEMA
(
3
,
TSDB_DATA_TYPE_INT
,
4
,
"tags"
);
CHECK_SCHEMA
(
3
,
TSDB_DATA_TYPE_INT
,
4
,
"tags"
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckBinary
(
"stb"
,
TSDB_TABLE_NAME_LEN
);
CheckBinary
(
"stb"
,
TSDB_TABLE_NAME_LEN
);
CheckTimestamp
();
CheckTimestamp
();
...
@@ -128,7 +128,7 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
...
@@ -128,7 +128,7 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
STableInfoMsg
*
pReq
=
(
STableInfoMsg
*
)
rpcMallocCont
(
contLen
);
STableInfoMsg
*
pReq
=
(
STableInfoMsg
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
tableFname
,
"1.d1.stb"
);
strcpy
(
pReq
->
tableFname
,
"1.d1.stb"
);
SRpcMsg
*
pMsg
=
test
.
Send
Msg
(
TDMT_MND_STB_META
,
pReq
,
contLen
);
SRpcMsg
*
pMsg
=
test
.
Send
Req
(
TDMT_MND_STB_META
,
pReq
,
contLen
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
...
@@ -203,9 +203,9 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
...
@@ -203,9 +203,9 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
// restart
// restart
test
.
Restart
();
test
.
Restart
();
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_STB
,
"1.d1"
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_STB
,
"1.d1"
);
CHECK_META
(
"show stables"
,
4
);
CHECK_META
(
"show stables"
,
4
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckBinary
(
"stb"
,
TSDB_TABLE_NAME_LEN
);
CheckBinary
(
"stb"
,
TSDB_TABLE_NAME_LEN
);
...
@@ -219,13 +219,13 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
...
@@ -219,13 +219,13 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
SDropStbMsg
*
pReq
=
(
SDropStbMsg
*
)
rpcMallocCont
(
contLen
);
SDropStbMsg
*
pReq
=
(
SDropStbMsg
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
name
,
"1.d1.stb"
);
strcpy
(
pReq
->
name
,
"1.d1.stb"
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_DROP_STB
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_DROP_STB
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
}
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_STB
,
"1.d1"
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_STB
,
"1.d1"
);
CHECK_META
(
"show stables"
,
4
);
CHECK_META
(
"show stables"
,
4
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
0
);
EXPECT_EQ
(
test
.
GetShowRows
(),
0
);
}
}
source/dnode/mgmt/impl/test/sut/inc/client.h
浏览文件 @
96f2aea2
...
@@ -21,7 +21,7 @@ class TestClient {
...
@@ -21,7 +21,7 @@ class TestClient {
bool
Init
(
const
char
*
user
,
const
char
*
pass
,
const
char
*
fqdn
,
uint16_t
port
);
bool
Init
(
const
char
*
user
,
const
char
*
pass
,
const
char
*
fqdn
,
uint16_t
port
);
void
Cleanup
();
void
Cleanup
();
SRpcMsg
*
Send
Msg
(
SRpcMsg
*
pMsg
);
SRpcMsg
*
Send
Req
(
SRpcMsg
*
pReq
);
void
SetRpcRsp
(
SRpcMsg
*
pRsp
);
void
SetRpcRsp
(
SRpcMsg
*
pRsp
);
tsem_t
*
GetSem
();
tsem_t
*
GetSem
();
...
...
source/dnode/mgmt/impl/test/sut/inc/sut.h
浏览文件 @
96f2aea2
...
@@ -39,7 +39,7 @@ class Testbase {
...
@@ -39,7 +39,7 @@ class Testbase {
void
Restart
();
void
Restart
();
void
ServerStop
();
void
ServerStop
();
void
ServerStart
();
void
ServerStart
();
SRpcMsg
*
Send
Msg
(
tmsg_t
msgType
,
void
*
pCont
,
int32_t
contLen
);
SRpcMsg
*
Send
Req
(
tmsg_t
msgType
,
void
*
pCont
,
int32_t
contLen
);
private:
private:
void
InitLog
(
const
char
*
path
);
void
InitLog
(
const
char
*
path
);
...
@@ -50,8 +50,8 @@ class Testbase {
...
@@ -50,8 +50,8 @@ class Testbase {
int32_t
connId
;
int32_t
connId
;
public:
public:
void
SendShowMeta
Msg
(
int8_t
showType
,
const
char
*
db
);
void
SendShowMeta
Req
(
int8_t
showType
,
const
char
*
db
);
void
SendShowRetrieve
Msg
();
void
SendShowRetrieve
Req
();
STableMetaMsg
*
GetShowMeta
();
STableMetaMsg
*
GetShowMeta
();
SRetrieveTableRsp
*
GetRetrieveRsp
();
SRetrieveTableRsp
*
GetRetrieveRsp
();
...
...
source/dnode/mgmt/impl/test/sut/src/client.cpp
浏览文件 @
96f2aea2
...
@@ -15,10 +15,10 @@
...
@@ -15,10 +15,10 @@
#include "sut.h"
#include "sut.h"
static
void
processClientRsp
(
void
*
parent
,
SRpcMsg
*
p
Msg
,
SEpSet
*
pEpSet
)
{
static
void
processClientRsp
(
void
*
parent
,
SRpcMsg
*
p
Rsp
,
SEpSet
*
pEpSet
)
{
TestClient
*
client
=
(
TestClient
*
)
parent
;
TestClient
*
client
=
(
TestClient
*
)
parent
;
client
->
SetRpcRsp
(
p
Msg
);
client
->
SetRpcRsp
(
p
Rsp
);
uInfo
(
"response:%s from dnode, code:0x%x"
,
TMSG_INFO
(
p
Msg
->
msgType
),
pMsg
->
code
);
uInfo
(
"response:%s from dnode, code:0x%x"
,
TMSG_INFO
(
p
Rsp
->
msgType
),
pRsp
->
code
);
tsem_post
(
client
->
GetSem
());
tsem_post
(
client
->
GetSem
());
}
}
...
@@ -59,14 +59,14 @@ void TestClient::Cleanup() {
...
@@ -59,14 +59,14 @@ void TestClient::Cleanup() {
rpcClose
(
clientRpc
);
rpcClose
(
clientRpc
);
}
}
SRpcMsg
*
TestClient
::
Send
Msg
(
SRpcMsg
*
pMsg
)
{
SRpcMsg
*
TestClient
::
Send
Req
(
SRpcMsg
*
pReq
)
{
SEpSet
epSet
=
{
0
};
SEpSet
epSet
=
{
0
};
epSet
.
inUse
=
0
;
epSet
.
inUse
=
0
;
epSet
.
numOfEps
=
1
;
epSet
.
numOfEps
=
1
;
epSet
.
port
[
0
]
=
port
;
epSet
.
port
[
0
]
=
port
;
memcpy
(
epSet
.
fqdn
[
0
],
fqdn
,
TSDB_FQDN_LEN
);
memcpy
(
epSet
.
fqdn
[
0
],
fqdn
,
TSDB_FQDN_LEN
);
rpcSendRequest
(
clientRpc
,
&
epSet
,
p
Msg
,
NULL
);
rpcSendRequest
(
clientRpc
,
&
epSet
,
p
Req
,
NULL
);
tsem_wait
(
&
sem
);
tsem_wait
(
&
sem
);
return
pRsp
;
return
pRsp
;
...
...
source/dnode/mgmt/impl/test/sut/src/sut.cpp
浏览文件 @
96f2aea2
...
@@ -64,23 +64,23 @@ void Testbase::ServerStop() { server.Stop(); }
...
@@ -64,23 +64,23 @@ void Testbase::ServerStop() { server.Stop(); }
void
Testbase
::
ServerStart
()
{
server
.
DoStart
();
}
void
Testbase
::
ServerStart
()
{
server
.
DoStart
();
}
SRpcMsg
*
Testbase
::
Send
Msg
(
tmsg_t
msgType
,
void
*
pCont
,
int32_t
contLen
)
{
SRpcMsg
*
Testbase
::
Send
Req
(
tmsg_t
msgType
,
void
*
pCont
,
int32_t
contLen
)
{
SRpcMsg
rpcMsg
=
{
0
};
SRpcMsg
rpcMsg
=
{
0
};
rpcMsg
.
pCont
=
pCont
;
rpcMsg
.
pCont
=
pCont
;
rpcMsg
.
contLen
=
contLen
;
rpcMsg
.
contLen
=
contLen
;
rpcMsg
.
msgType
=
msgType
;
rpcMsg
.
msgType
=
msgType
;
return
client
.
Send
Msg
(
&
rpcMsg
);
return
client
.
Send
Req
(
&
rpcMsg
);
}
}
void
Testbase
::
SendShowMeta
Msg
(
int8_t
showType
,
const
char
*
db
)
{
void
Testbase
::
SendShowMeta
Req
(
int8_t
showType
,
const
char
*
db
)
{
int32_t
contLen
=
sizeof
(
SShow
Msg
);
int32_t
contLen
=
sizeof
(
SShow
Req
);
SShow
Msg
*
pShow
=
(
SShowMsg
*
)
rpcMallocCont
(
contLen
);
SShow
Req
*
pShow
=
(
SShowReq
*
)
rpcMallocCont
(
contLen
);
pShow
->
type
=
showType
;
pShow
->
type
=
showType
;
strcpy
(
pShow
->
db
,
db
);
strcpy
(
pShow
->
db
,
db
);
SRpcMsg
*
p
Msg
=
SendMsg
(
TDMT_MND_SHOW
,
pShow
,
contLen
);
SRpcMsg
*
p
Rsp
=
SendReq
(
TDMT_MND_SHOW
,
pShow
,
contLen
);
SShowRsp
*
pShowRsp
=
(
SShowRsp
*
)
p
Msg
->
pCont
;
SShowRsp
*
pShowRsp
=
(
SShowRsp
*
)
p
Rsp
->
pCont
;
ASSERT
(
pShowRsp
!=
nullptr
);
ASSERT
(
pShowRsp
!=
nullptr
);
pShowRsp
->
showId
=
htobe64
(
pShowRsp
->
showId
);
pShowRsp
->
showId
=
htobe64
(
pShowRsp
->
showId
);
...
@@ -121,15 +121,15 @@ int32_t Testbase::GetMetaNum() { return pMeta->numOfColumns; }
...
@@ -121,15 +121,15 @@ int32_t Testbase::GetMetaNum() { return pMeta->numOfColumns; }
const
char
*
Testbase
::
GetMetaTbName
()
{
return
pMeta
->
tbFname
;
}
const
char
*
Testbase
::
GetMetaTbName
()
{
return
pMeta
->
tbFname
;
}
void
Testbase
::
SendShowRetrieve
Msg
()
{
void
Testbase
::
SendShowRetrieve
Req
()
{
int32_t
contLen
=
sizeof
(
SRetrieveTable
Msg
);
int32_t
contLen
=
sizeof
(
SRetrieveTable
Req
);
SRetrieveTable
Msg
*
pRetrieve
=
(
SRetrieveTableMsg
*
)
rpcMallocCont
(
contLen
);
SRetrieveTable
Req
*
pRetrieve
=
(
SRetrieveTableReq
*
)
rpcMallocCont
(
contLen
);
pRetrieve
->
showId
=
htobe64
(
showId
);
pRetrieve
->
showId
=
htobe64
(
showId
);
pRetrieve
->
free
=
0
;
pRetrieve
->
free
=
0
;
SRpcMsg
*
p
Msg
=
SendMsg
(
TDMT_MND_SHOW_RETRIEVE
,
pRetrieve
,
contLen
);
SRpcMsg
*
p
Rsp
=
SendReq
(
TDMT_MND_SHOW_RETRIEVE
,
pRetrieve
,
contLen
);
pRetrieveRsp
=
(
SRetrieveTableRsp
*
)
p
Msg
->
pCont
;
pRetrieveRsp
=
(
SRetrieveTableRsp
*
)
p
Rsp
->
pCont
;
pRetrieveRsp
->
numOfRows
=
htonl
(
pRetrieveRsp
->
numOfRows
);
pRetrieveRsp
->
numOfRows
=
htonl
(
pRetrieveRsp
->
numOfRows
);
pRetrieveRsp
->
useconds
=
htobe64
(
pRetrieveRsp
->
useconds
);
pRetrieveRsp
->
useconds
=
htobe64
(
pRetrieveRsp
->
useconds
);
pRetrieveRsp
->
compLen
=
htonl
(
pRetrieveRsp
->
compLen
);
pRetrieveRsp
->
compLen
=
htonl
(
pRetrieveRsp
->
compLen
);
...
...
source/dnode/mgmt/impl/test/vgroup/vgroup.cpp
浏览文件 @
96f2aea2
...
@@ -60,9 +60,9 @@ TEST_F(DndTestVgroup, 01_Create_Restart_Drop_Vnode) {
...
@@ -60,9 +60,9 @@ TEST_F(DndTestVgroup, 01_Create_Restart_Drop_Vnode) {
pReplica
->
port
=
htons
(
9150
);
pReplica
->
port
=
htons
(
9150
);
}
}
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_CREATE_VNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_CREATE_VNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
}
}
}
...
@@ -100,9 +100,9 @@ TEST_F(DndTestVgroup, 01_Create_Restart_Drop_Vnode) {
...
@@ -100,9 +100,9 @@ TEST_F(DndTestVgroup, 01_Create_Restart_Drop_Vnode) {
pReplica
->
port
=
htons
(
9150
);
pReplica
->
port
=
htons
(
9150
);
}
}
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_ALTER_VNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_ALTER_VNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
}
}
}
...
@@ -121,9 +121,9 @@ TEST_F(DndTestVgroup, 01_Create_Restart_Drop_Vnode) {
...
@@ -121,9 +121,9 @@ TEST_F(DndTestVgroup, 01_Create_Restart_Drop_Vnode) {
rpcMsg
.
contLen
=
sizeof
(
SDropVnodeMsg
);
rpcMsg
.
contLen
=
sizeof
(
SDropVnodeMsg
);
rpcMsg
.
msgType
=
TDMT_DND_DROP_VNODE
;
rpcMsg
.
msgType
=
TDMT_DND_DROP_VNODE
;
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_DROP_VNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_DROP_VNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
}
}
}
}
}
source/dnode/mnode/impl/inc/mndConsumer.h
浏览文件 @
96f2aea2
...
@@ -25,11 +25,8 @@ extern "C" {
...
@@ -25,11 +25,8 @@ extern "C" {
int32_t
mndInitConsumer
(
SMnode
*
pMnode
);
int32_t
mndInitConsumer
(
SMnode
*
pMnode
);
void
mndCleanupConsumer
(
SMnode
*
pMnode
);
void
mndCleanupConsumer
(
SMnode
*
pMnode
);
SConsumerObj
*
mndAcquireConsumer
(
SMnode
*
pMnode
,
int32_t
consumerId
);
SMqConsumerObj
*
mndAcquireConsumer
(
SMnode
*
pMnode
,
int32_t
consumerId
);
void
mndReleaseConsumer
(
SMnode
*
pMnode
,
SConsumerObj
*
pConsumer
);
void
mndReleaseConsumer
(
SMnode
*
pMnode
,
SMqConsumerObj
*
pConsumer
);
SCGroupObj
*
mndAcquireCGroup
(
SMnode
*
pMnode
,
char
*
consumerGroup
);
void
mndReleaseCGroup
(
SMnode
*
pMnode
,
SCGroupObj
*
pCGroup
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
96f2aea2
...
@@ -22,6 +22,7 @@
...
@@ -22,6 +22,7 @@
#include "sync.h"
#include "sync.h"
#include "tmsg.h"
#include "tmsg.h"
#include "thash.h"
#include "thash.h"
#include "tlist.h"
#include "tlog.h"
#include "tlog.h"
#include "trpc.h"
#include "trpc.h"
#include "ttimer.h"
#include "ttimer.h"
...
@@ -64,8 +65,8 @@ typedef enum {
...
@@ -64,8 +65,8 @@ typedef enum {
TRN_STAGE_PREPARE
=
0
,
TRN_STAGE_PREPARE
=
0
,
TRN_STAGE_REDO_LOG
=
1
,
TRN_STAGE_REDO_LOG
=
1
,
TRN_STAGE_REDO_ACTION
=
2
,
TRN_STAGE_REDO_ACTION
=
2
,
TRN_STAGE_COMMIT
_LOG
=
3
,
TRN_STAGE_COMMIT
=
3
,
TRN_STAGE_COMMIT
=
4
,
TRN_STAGE_COMMIT
_LOG
=
4
,
TRN_STAGE_UNDO_ACTION
=
5
,
TRN_STAGE_UNDO_ACTION
=
5
,
TRN_STAGE_UNDO_LOG
=
6
,
TRN_STAGE_UNDO_LOG
=
6
,
TRN_STAGE_ROLLBACK
=
7
,
TRN_STAGE_ROLLBACK
=
7
,
...
@@ -307,46 +308,117 @@ typedef struct {
...
@@ -307,46 +308,117 @@ typedef struct {
char
payload
[];
char
payload
[];
}
SShowObj
;
}
SShowObj
;
typedef
struct
{
#if 0
char
name
[
TSDB_TOPIC_FNAME_LEN
];
typedef struct SConsumerObj {
char
db
[
TSDB_DB_FNAME_LEN
];
int64_t
createTime
;
int64_t
updateTime
;
uint64_t
uid
;
uint64_t
dbUid
;
int32_t
version
;
SRWLatch
lock
;
int32_t
execLen
;
void
*
executor
;
int32_t
sqlLen
;
char
*
sql
;
char
*
logicalPlan
;
char
*
physicalPlan
;
}
STopicObj
;
typedef
struct
{
char
name
[
TSDB_TOPIC_FNAME_LEN
];
char
db
[
TSDB_DB_FNAME_LEN
];
int64_t
createTime
;
int64_t
updateTime
;
uint64_t uid;
uint64_t uid;
int64_t createTime;
int64_t updateTime;
//uint64_t dbUid;
//uint64_t dbUid;
int32_t
version
;
int32_t
version;
SRWLatch lock;
SRWLatch lock;
SArray* topics;
} SConsumerObj;
} SConsumerObj;
typedef
struct
{
typedef struct SMqTopicConsumer {
char
name
[
TSDB_TOPIC_FNAME_LEN
];
int64_t consumerId;
char
db
[
TSDB_DB_FNAME_LEN
];
SList* topicList;
int64_t
createTime
;
} SMqTopicConsumer;
int64_t
updateTime
;
#endif
typedef
struct
SMqCGroup
{
char
name
[
TSDB_CONSUMER_GROUP_LEN
];
int32_t
status
;
// 0 - uninitialized, 1 - wait rebalance, 2- normal
SList
*
consumerIds
;
// SList<int64_t>
SList
*
idleVGroups
;
// SList<int32_t>
}
SMqCGroup
;
typedef
struct
SMqTopicObj
{
char
name
[
TSDB_TOPIC_FNAME_LEN
];
char
db
[
TSDB_DB_FNAME_LEN
];
int64_t
createTime
;
int64_t
updateTime
;
uint64_t
uid
;
uint64_t
dbUid
;
int32_t
version
;
SRWLatch
lock
;
int32_t
sqlLen
;
char
*
sql
;
char
*
logicalPlan
;
char
*
physicalPlan
;
SHashObj
*
cgroups
;
// SHashObj<SMqCGroup>
}
SMqTopicObj
;
// TODO: add cache and change name to id
typedef
struct
SMqConsumerTopic
{
char
name
[
TSDB_TOPIC_FNAME_LEN
];
SList
*
vgroups
;
// SList<int32_t>
}
SMqConsumerTopic
;
typedef
struct
SMqConsumerObj
{
SRWLatch
lock
;
int64_t
consumerId
;
char
cgroup
[
TSDB_CONSUMER_GROUP_LEN
];
SArray
*
topics
;
// SArray<SMqConsumerTopic>
}
SMqConsumerObj
;
typedef
struct
SMqSubConsumerObj
{
int64_t
consumerUid
;
// if -1, unassigned
SList
*
vgId
;
// SList<int32_t>
}
SMqSubConsumerObj
;
typedef
struct
SMqSubCGroupObj
{
char
name
[
TSDB_CONSUMER_GROUP_LEN
];
SList
*
consumers
;
// SList<SMqConsumerObj>
}
SMqSubCGroupObj
;
typedef
struct
SMqSubTopicObj
{
char
name
[
TSDB_TOPIC_FNAME_LEN
];
char
db
[
TSDB_DB_FNAME_LEN
];
int64_t
createTime
;
int64_t
updateTime
;
int64_t
uid
;
int64_t
dbUid
;
int32_t
version
;
SRWLatch
lock
;
int32_t
sqlLen
;
char
*
sql
;
char
*
logicalPlan
;
char
*
physicalPlan
;
SList
*
cgroups
;
// SList<SMqSubCGroupObj>
}
SMqSubTopicObj
;
typedef
struct
SMqConsumerSubObj
{
int64_t
topicUid
;
SList
*
vgIds
;
// SList<int64_t>
}
SMqConsumerSubObj
;
typedef
struct
SMqConsumerHbObj
{
int64_t
consumerId
;
SList
*
consumerSubs
;
// SList<SMqConsumerSubObj>
}
SMqConsumerHbObj
;
typedef
struct
SMqVGroupSubObj
{
int64_t
topicUid
;
SList
*
consumerIds
;
// SList<int64_t>
}
SMqVGroupSubObj
;
typedef
struct
SMqVGroupHbObj
{
int64_t
vgId
;
SList
*
vgSubs
;
// SList<SMqVGroupSubObj>
}
SMqVGroupHbObj
;
#if 0
typedef struct SCGroupObj {
char name[TSDB_TOPIC_FNAME_LEN];
int64_t createTime;
int64_t updateTime;
uint64_t uid;
uint64_t uid;
//uint64_t dbUid;
//uint64_t dbUid;
int32_t
version
;
int32_t
version;
SRWLatch lock;
SRWLatch lock;
SList* consumerIds;
} SCGroupObj;
} SCGroupObj;
#endif
typedef
struct
SMnodeMsg
{
typedef
struct
SMnodeMsg
{
char
user
[
TSDB_USER_LEN
];
char
user
[
TSDB_USER_LEN
];
...
...
source/dnode/mnode/impl/inc/mndTopic.h
浏览文件 @
96f2aea2
...
@@ -25,8 +25,11 @@ extern "C" {
...
@@ -25,8 +25,11 @@ extern "C" {
int32_t
mndInitTopic
(
SMnode
*
pMnode
);
int32_t
mndInitTopic
(
SMnode
*
pMnode
);
void
mndCleanupTopic
(
SMnode
*
pMnode
);
void
mndCleanupTopic
(
SMnode
*
pMnode
);
STopicObj
*
mndAcquireTopic
(
SMnode
*
pMnode
,
char
*
topicName
);
SMqTopicObj
*
mndAcquireTopic
(
SMnode
*
pMnode
,
char
*
topicName
);
void
mndReleaseTopic
(
SMnode
*
pMnode
,
STopicObj
*
pTopic
);
void
mndReleaseTopic
(
SMnode
*
pMnode
,
SMqTopicObj
*
pTopic
);
SSdbRaw
*
mndTopicActionEncode
(
SMqTopicObj
*
pTopic
);
SSdbRow
*
mndTopicActionDecode
(
SSdbRaw
*
pRaw
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/dnode/mnode/impl/src/mndAcct.c
浏览文件 @
96f2aea2
...
@@ -26,9 +26,9 @@ static SSdbRow *mndAcctActionDecode(SSdbRaw *pRaw);
...
@@ -26,9 +26,9 @@ static SSdbRow *mndAcctActionDecode(SSdbRaw *pRaw);
static
int32_t
mndAcctActionInsert
(
SSdb
*
pSdb
,
SAcctObj
*
pAcct
);
static
int32_t
mndAcctActionInsert
(
SSdb
*
pSdb
,
SAcctObj
*
pAcct
);
static
int32_t
mndAcctActionDelete
(
SSdb
*
pSdb
,
SAcctObj
*
pAcct
);
static
int32_t
mndAcctActionDelete
(
SSdb
*
pSdb
,
SAcctObj
*
pAcct
);
static
int32_t
mndAcctActionUpdate
(
SSdb
*
pSdb
,
SAcctObj
*
pOld
,
SAcctObj
*
pNew
);
static
int32_t
mndAcctActionUpdate
(
SSdb
*
pSdb
,
SAcctObj
*
pOld
,
SAcctObj
*
pNew
);
static
int32_t
mndProcessCreateAcctReq
(
SMnodeMsg
*
p
Msg
);
static
int32_t
mndProcessCreateAcctReq
(
SMnodeMsg
*
p
Req
);
static
int32_t
mndProcessAlterAcctReq
(
SMnodeMsg
*
p
Msg
);
static
int32_t
mndProcessAlterAcctReq
(
SMnodeMsg
*
p
Req
);
static
int32_t
mndProcessDropAcctReq
(
SMnodeMsg
*
p
Msg
);
static
int32_t
mndProcessDropAcctReq
(
SMnodeMsg
*
p
Req
);
int32_t
mndInitAcct
(
SMnode
*
pMnode
)
{
int32_t
mndInitAcct
(
SMnode
*
pMnode
)
{
SSdbTable
table
=
{.
sdbType
=
SDB_ACCT
,
SSdbTable
table
=
{.
sdbType
=
SDB_ACCT
,
...
@@ -185,19 +185,19 @@ static int32_t mndAcctActionUpdate(SSdb *pSdb, SAcctObj *pOld, SAcctObj *pNew) {
...
@@ -185,19 +185,19 @@ static int32_t mndAcctActionUpdate(SSdb *pSdb, SAcctObj *pOld, SAcctObj *pNew) {
return
0
;
return
0
;
}
}
static
int32_t
mndProcessCreateAcctReq
(
SMnodeMsg
*
p
Msg
)
{
static
int32_t
mndProcessCreateAcctReq
(
SMnodeMsg
*
p
Req
)
{
terrno
=
TSDB_CODE_MND_MSG_NOT_PROCESSED
;
terrno
=
TSDB_CODE_MND_MSG_NOT_PROCESSED
;
mError
(
"failed to process create acct request since %s"
,
terrstr
());
mError
(
"failed to process create acct request since %s"
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
static
int32_t
mndProcessAlterAcctReq
(
SMnodeMsg
*
p
Msg
)
{
static
int32_t
mndProcessAlterAcctReq
(
SMnodeMsg
*
p
Req
)
{
terrno
=
TSDB_CODE_MND_MSG_NOT_PROCESSED
;
terrno
=
TSDB_CODE_MND_MSG_NOT_PROCESSED
;
mError
(
"failed to process create acct request since %s"
,
terrstr
());
mError
(
"failed to process create acct request since %s"
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
static
int32_t
mndProcessDropAcctReq
(
SMnodeMsg
*
p
Msg
)
{
static
int32_t
mndProcessDropAcctReq
(
SMnodeMsg
*
p
Req
)
{
terrno
=
TSDB_CODE_MND_MSG_NOT_PROCESSED
;
terrno
=
TSDB_CODE_MND_MSG_NOT_PROCESSED
;
mError
(
"failed to process create acct request since %s"
,
terrstr
());
mError
(
"failed to process create acct request since %s"
,
terrstr
());
return
-
1
;
return
-
1
;
...
...
source/dnode/mnode/impl/src/mndAuth.c
浏览文件 @
96f2aea2
...
@@ -14,7 +14,6 @@
...
@@ -14,7 +14,6 @@
*/
*/
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "os.h"
#include "mndAuth.h"
#include "mndAuth.h"
int32_t
mndInitAuth
(
SMnode
*
pMnode
)
{
return
0
;
}
int32_t
mndInitAuth
(
SMnode
*
pMnode
)
{
return
0
;
}
...
...
source/dnode/mnode/impl/src/mndBnode.c
浏览文件 @
96f2aea2
...
@@ -27,12 +27,12 @@ static SSdbRow *mndBnodeActionDecode(SSdbRaw *pRaw);
...
@@ -27,12 +27,12 @@ static SSdbRow *mndBnodeActionDecode(SSdbRaw *pRaw);
static
int32_t
mndBnodeActionInsert
(
SSdb
*
pSdb
,
SBnodeObj
*
pObj
);
static
int32_t
mndBnodeActionInsert
(
SSdb
*
pSdb
,
SBnodeObj
*
pObj
);
static
int32_t
mndBnodeActionDelete
(
SSdb
*
pSdb
,
SBnodeObj
*
pObj
);
static
int32_t
mndBnodeActionDelete
(
SSdb
*
pSdb
,
SBnodeObj
*
pObj
);
static
int32_t
mndBnodeActionUpdate
(
SSdb
*
pSdb
,
SBnodeObj
*
pOld
,
SBnodeObj
*
pNew
);
static
int32_t
mndBnodeActionUpdate
(
SSdb
*
pSdb
,
SBnodeObj
*
pOld
,
SBnodeObj
*
pNew
);
static
int32_t
mndProcessCreateBnodeReq
(
SMnodeMsg
*
p
Msg
);
static
int32_t
mndProcessCreateBnodeReq
(
SMnodeMsg
*
p
Req
);
static
int32_t
mndProcessDropBnodeReq
(
SMnodeMsg
*
p
Msg
);
static
int32_t
mndProcessDropBnodeReq
(
SMnodeMsg
*
p
Req
);
static
int32_t
mndProcessCreateBnodeRsp
(
SMnodeMsg
*
p
Msg
);
static
int32_t
mndProcessCreateBnodeRsp
(
SMnodeMsg
*
p
Rsp
);
static
int32_t
mndProcessDropBnodeRsp
(
SMnodeMsg
*
p
Msg
);
static
int32_t
mndProcessDropBnodeRsp
(
SMnodeMsg
*
p
Rsp
);
static
int32_t
mndGetBnodeMeta
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
);
static
int32_t
mndGetBnodeMeta
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
);
static
int32_t
mndRetrieveBnodes
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
int32_t
mndRetrieveBnodes
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
void
mndCancelGetNextBnode
(
SMnode
*
pMnode
,
void
*
pIter
);
static
void
mndCancelGetNextBnode
(
SMnode
*
pMnode
,
void
*
pIter
);
int32_t
mndInitBnode
(
SMnode
*
pMnode
)
{
int32_t
mndInitBnode
(
SMnode
*
pMnode
)
{
...
@@ -185,22 +185,22 @@ static int32_t mndSetCreateBnodeCommitLogs(STrans *pTrans, SBnodeObj *pObj) {
...
@@ -185,22 +185,22 @@ static int32_t mndSetCreateBnodeCommitLogs(STrans *pTrans, SBnodeObj *pObj) {
}
}
static
int32_t
mndSetCreateBnodeRedoActions
(
STrans
*
pTrans
,
SDnodeObj
*
pDnode
,
SBnodeObj
*
pObj
)
{
static
int32_t
mndSetCreateBnodeRedoActions
(
STrans
*
pTrans
,
SDnodeObj
*
pDnode
,
SBnodeObj
*
pObj
)
{
SDCreateBnodeReq
*
p
Msg
=
malloc
(
sizeof
(
SDCreateBnodeReq
));
SDCreateBnodeReq
*
p
Req
=
malloc
(
sizeof
(
SDCreateBnodeReq
));
if
(
p
Msg
==
NULL
)
{
if
(
p
Req
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
}
}
p
Msg
->
dnodeId
=
htonl
(
pDnode
->
id
);
p
Req
->
dnodeId
=
htonl
(
pDnode
->
id
);
STransAction
action
=
{
0
};
STransAction
action
=
{
0
};
action
.
epSet
=
mndGetDnodeEpset
(
pDnode
);
action
.
epSet
=
mndGetDnodeEpset
(
pDnode
);
action
.
pCont
=
p
Msg
;
action
.
pCont
=
p
Req
;
action
.
contLen
=
sizeof
(
SDCreateBnodeReq
);
action
.
contLen
=
sizeof
(
SDCreateBnodeReq
);
action
.
msgType
=
TDMT_DND_CREATE_BNODE
;
action
.
msgType
=
TDMT_DND_CREATE_BNODE
;
action
.
acceptableCode
=
TSDB_CODE_DND_BNODE_ALREADY_DEPLOYED
;
action
.
acceptableCode
=
TSDB_CODE_DND_BNODE_ALREADY_DEPLOYED
;
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
free
(
p
Msg
);
free
(
p
Req
);
return
-
1
;
return
-
1
;
}
}
...
@@ -208,29 +208,29 @@ static int32_t mndSetCreateBnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, S
...
@@ -208,29 +208,29 @@ static int32_t mndSetCreateBnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, S
}
}
static
int32_t
mndSetCreateBnodeUndoActions
(
STrans
*
pTrans
,
SDnodeObj
*
pDnode
,
SBnodeObj
*
pObj
)
{
static
int32_t
mndSetCreateBnodeUndoActions
(
STrans
*
pTrans
,
SDnodeObj
*
pDnode
,
SBnodeObj
*
pObj
)
{
SDDropBnodeReq
*
p
Msg
=
malloc
(
sizeof
(
SDDropBnodeReq
));
SDDropBnodeReq
*
p
Req
=
malloc
(
sizeof
(
SDDropBnodeReq
));
if
(
p
Msg
==
NULL
)
{
if
(
p
Req
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
}
}
p
Msg
->
dnodeId
=
htonl
(
pDnode
->
id
);
p
Req
->
dnodeId
=
htonl
(
pDnode
->
id
);
STransAction
action
=
{
0
};
STransAction
action
=
{
0
};
action
.
epSet
=
mndGetDnodeEpset
(
pDnode
);
action
.
epSet
=
mndGetDnodeEpset
(
pDnode
);
action
.
pCont
=
p
Msg
;
action
.
pCont
=
p
Req
;
action
.
contLen
=
sizeof
(
SDDropBnodeReq
);
action
.
contLen
=
sizeof
(
SDDropBnodeReq
);
action
.
msgType
=
TDMT_DND_DROP_BNODE
;
action
.
msgType
=
TDMT_DND_DROP_BNODE
;
action
.
acceptableCode
=
TSDB_CODE_DND_BNODE_NOT_DEPLOYED
;
action
.
acceptableCode
=
TSDB_CODE_DND_BNODE_NOT_DEPLOYED
;
if
(
mndTransAppendUndoAction
(
pTrans
,
&
action
)
!=
0
)
{
if
(
mndTransAppendUndoAction
(
pTrans
,
&
action
)
!=
0
)
{
free
(
p
Msg
);
free
(
p
Req
);
return
-
1
;
return
-
1
;
}
}
return
0
;
return
0
;
}
}
static
int32_t
mndCreateBnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
p
Msg
,
SDnodeObj
*
pDnode
,
SMCreateBnodeReq
*
pCreate
)
{
static
int32_t
mndCreateBnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
p
Req
,
SDnodeObj
*
pDnode
,
SMCreateBnodeReq
*
pCreate
)
{
int32_t
code
=
-
1
;
int32_t
code
=
-
1
;
SBnodeObj
bnodeObj
=
{
0
};
SBnodeObj
bnodeObj
=
{
0
};
...
@@ -238,7 +238,7 @@ static int32_t mndCreateBnode(SMnode *pMnode, SMnodeMsg *pMsg, SDnodeObj *pDnode
...
@@ -238,7 +238,7 @@ static int32_t mndCreateBnode(SMnode *pMnode, SMnodeMsg *pMsg, SDnodeObj *pDnode
bnodeObj
.
createdTime
=
taosGetTimestampMs
();
bnodeObj
.
createdTime
=
taosGetTimestampMs
();
bnodeObj
.
updateTime
=
bnodeObj
.
createdTime
;
bnodeObj
.
updateTime
=
bnodeObj
.
createdTime
;
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
&
p
Msg
->
rpcMsg
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
&
p
Req
->
rpcMsg
);
if
(
pTrans
==
NULL
)
goto
CREATE_BNODE_OVER
;
if
(
pTrans
==
NULL
)
goto
CREATE_BNODE_OVER
;
mDebug
(
"trans:%d, used to create bnode:%d"
,
pTrans
->
id
,
pCreate
->
dnodeId
);
mDebug
(
"trans:%d, used to create bnode:%d"
,
pTrans
->
id
,
pCreate
->
dnodeId
);
...
@@ -256,9 +256,9 @@ CREATE_BNODE_OVER:
...
@@ -256,9 +256,9 @@ CREATE_BNODE_OVER:
return
code
;
return
code
;
}
}
static
int32_t
mndProcessCreateBnodeReq
(
SMnodeMsg
*
p
Msg
)
{
static
int32_t
mndProcessCreateBnodeReq
(
SMnodeMsg
*
p
Req
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SMCreateBnodeReq
*
pCreate
=
p
Msg
->
rpcMsg
.
pCont
;
SMCreateBnodeReq
*
pCreate
=
p
Req
->
rpcMsg
.
pCont
;
pCreate
->
dnodeId
=
htonl
(
pCreate
->
dnodeId
);
pCreate
->
dnodeId
=
htonl
(
pCreate
->
dnodeId
);
...
@@ -282,7 +282,7 @@ static int32_t mndProcessCreateBnodeReq(SMnodeMsg *pMsg) {
...
@@ -282,7 +282,7 @@ static int32_t mndProcessCreateBnodeReq(SMnodeMsg *pMsg) {
return
-
1
;
return
-
1
;
}
}
int32_t
code
=
mndCreateBnode
(
pMnode
,
p
Msg
,
pDnode
,
pCreate
);
int32_t
code
=
mndCreateBnode
(
pMnode
,
p
Req
,
pDnode
,
pCreate
);
mndReleaseDnode
(
pMnode
,
pDnode
);
mndReleaseDnode
(
pMnode
,
pDnode
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
...
@@ -310,32 +310,32 @@ static int32_t mndSetDropBnodeCommitLogs(STrans *pTrans, SBnodeObj *pObj) {
...
@@ -310,32 +310,32 @@ static int32_t mndSetDropBnodeCommitLogs(STrans *pTrans, SBnodeObj *pObj) {
}
}
static
int32_t
mndSetDropBnodeRedoActions
(
STrans
*
pTrans
,
SDnodeObj
*
pDnode
,
SBnodeObj
*
pObj
)
{
static
int32_t
mndSetDropBnodeRedoActions
(
STrans
*
pTrans
,
SDnodeObj
*
pDnode
,
SBnodeObj
*
pObj
)
{
SDDropBnodeReq
*
p
Msg
=
malloc
(
sizeof
(
SDDropBnodeReq
));
SDDropBnodeReq
*
p
Req
=
malloc
(
sizeof
(
SDDropBnodeReq
));
if
(
p
Msg
==
NULL
)
{
if
(
p
Req
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
}
}
p
Msg
->
dnodeId
=
htonl
(
pDnode
->
id
);
p
Req
->
dnodeId
=
htonl
(
pDnode
->
id
);
STransAction
action
=
{
0
};
STransAction
action
=
{
0
};
action
.
epSet
=
mndGetDnodeEpset
(
pDnode
);
action
.
epSet
=
mndGetDnodeEpset
(
pDnode
);
action
.
pCont
=
p
Msg
;
action
.
pCont
=
p
Req
;
action
.
contLen
=
sizeof
(
SDDropBnodeReq
);
action
.
contLen
=
sizeof
(
SDDropBnodeReq
);
action
.
msgType
=
TDMT_DND_DROP_BNODE
;
action
.
msgType
=
TDMT_DND_DROP_BNODE
;
action
.
acceptableCode
=
TSDB_CODE_DND_BNODE_NOT_DEPLOYED
;
action
.
acceptableCode
=
TSDB_CODE_DND_BNODE_NOT_DEPLOYED
;
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
free
(
p
Msg
);
free
(
p
Req
);
return
-
1
;
return
-
1
;
}
}
return
0
;
return
0
;
}
}
static
int32_t
mndDropBnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
p
Msg
,
SBnodeObj
*
pObj
)
{
static
int32_t
mndDropBnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
p
Req
,
SBnodeObj
*
pObj
)
{
int32_t
code
=
-
1
;
int32_t
code
=
-
1
;
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
&
p
Msg
->
rpcMsg
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
&
p
Req
->
rpcMsg
);
if
(
pTrans
==
NULL
)
goto
DROP_BNODE_OVER
;
if
(
pTrans
==
NULL
)
goto
DROP_BNODE_OVER
;
mDebug
(
"trans:%d, used to drop bnode:%d"
,
pTrans
->
id
,
pObj
->
id
);
mDebug
(
"trans:%d, used to drop bnode:%d"
,
pTrans
->
id
,
pObj
->
id
);
...
@@ -351,9 +351,9 @@ DROP_BNODE_OVER:
...
@@ -351,9 +351,9 @@ DROP_BNODE_OVER:
return
code
;
return
code
;
}
}
static
int32_t
mndProcessDropBnodeReq
(
SMnodeMsg
*
p
Msg
)
{
static
int32_t
mndProcessDropBnodeReq
(
SMnodeMsg
*
p
Req
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SMDropBnodeReq
*
pDrop
=
p
Msg
->
rpcMsg
.
pCont
;
SMDropBnodeReq
*
pDrop
=
p
Req
->
rpcMsg
.
pCont
;
pDrop
->
dnodeId
=
htonl
(
pDrop
->
dnodeId
);
pDrop
->
dnodeId
=
htonl
(
pDrop
->
dnodeId
);
mDebug
(
"bnode:%d, start to drop"
,
pDrop
->
dnodeId
);
mDebug
(
"bnode:%d, start to drop"
,
pDrop
->
dnodeId
);
...
@@ -370,7 +370,7 @@ static int32_t mndProcessDropBnodeReq(SMnodeMsg *pMsg) {
...
@@ -370,7 +370,7 @@ static int32_t mndProcessDropBnodeReq(SMnodeMsg *pMsg) {
return
-
1
;
return
-
1
;
}
}
int32_t
code
=
mndDropBnode
(
pMnode
,
p
Msg
,
pObj
);
int32_t
code
=
mndDropBnode
(
pMnode
,
p
Req
,
pObj
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
sdbRelease
(
pMnode
->
pSdb
,
pObj
);
sdbRelease
(
pMnode
->
pSdb
,
pObj
);
mError
(
"bnode:%d, failed to drop since %s"
,
pMnode
->
dnodeId
,
terrstr
());
mError
(
"bnode:%d, failed to drop since %s"
,
pMnode
->
dnodeId
,
terrstr
());
...
@@ -381,18 +381,18 @@ static int32_t mndProcessDropBnodeReq(SMnodeMsg *pMsg) {
...
@@ -381,18 +381,18 @@ static int32_t mndProcessDropBnodeReq(SMnodeMsg *pMsg) {
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
}
static
int32_t
mndProcessCreateBnodeRsp
(
SMnodeMsg
*
p
Msg
)
{
static
int32_t
mndProcessCreateBnodeRsp
(
SMnodeMsg
*
p
Rsp
)
{
mndTransProcessRsp
(
p
Msg
);
mndTransProcessRsp
(
p
Rsp
);
return
0
;
return
0
;
}
}
static
int32_t
mndProcessDropBnodeRsp
(
SMnodeMsg
*
p
Msg
)
{
static
int32_t
mndProcessDropBnodeRsp
(
SMnodeMsg
*
p
Rsp
)
{
mndTransProcessRsp
(
p
Msg
);
mndTransProcessRsp
(
p
Rsp
);
return
0
;
return
0
;
}
}
static
int32_t
mndGetBnodeMeta
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
)
{
static
int32_t
mndGetBnodeMeta
(
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
;
...
@@ -431,8 +431,8 @@ static int32_t mndGetBnodeMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *
...
@@ -431,8 +431,8 @@ static int32_t mndGetBnodeMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *
return
0
;
return
0
;
}
}
static
int32_t
mndRetrieveBnodes
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
static
int32_t
mndRetrieveBnodes
(
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/mndCluster.c
浏览文件 @
96f2aea2
...
@@ -16,7 +16,6 @@
...
@@ -16,7 +16,6 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "mndCluster.h"
#include "mndCluster.h"
#include "mndShow.h"
#include "mndShow.h"
#include "mndTrans.h"
#define TSDB_CLUSTER_VER_NUMBE 1
#define TSDB_CLUSTER_VER_NUMBE 1
#define TSDB_CLUSTER_RESERVE_SIZE 64
#define TSDB_CLUSTER_RESERVE_SIZE 64
...
...
source/dnode/mnode/impl/src/mndConsumer.c
浏览文件 @
96f2aea2
...
@@ -24,16 +24,17 @@
...
@@ -24,16 +24,17 @@
#include "mndTrans.h"
#include "mndTrans.h"
#include "mndUser.h"
#include "mndUser.h"
#include "mndVgroup.h"
#include "mndVgroup.h"
#include "tcompare.h"
#include "tname.h"
#include "tname.h"
#define MND_CONSUMER_VER_NUMBER 1
#define MND_CONSUMER_VER_NUMBER 1
#define MND_CONSUMER_RESERVE_SIZE 64
#define MND_CONSUMER_RESERVE_SIZE 64
static
SSdbRaw
*
mndConsumerActionEncode
(
SConsumerObj
*
pConsumer
);
static
SSdbRaw
*
mndConsumerActionEncode
(
S
Mq
ConsumerObj
*
pConsumer
);
static
SSdbRow
*
mndConsumerActionDecode
(
SSdbRaw
*
pRaw
);
static
SSdbRow
*
mndConsumerActionDecode
(
SSdbRaw
*
pRaw
);
static
int32_t
mndConsumerActionInsert
(
SSdb
*
pSdb
,
SConsumerObj
*
pConsumer
);
static
int32_t
mndConsumerActionInsert
(
SSdb
*
pSdb
,
S
Mq
ConsumerObj
*
pConsumer
);
static
int32_t
mndConsumerActionDelete
(
SSdb
*
pSdb
,
SConsumerObj
*
pConsumer
);
static
int32_t
mndConsumerActionDelete
(
SSdb
*
pSdb
,
S
Mq
ConsumerObj
*
pConsumer
);
static
int32_t
mndConsumerActionUpdate
(
SSdb
*
pSdb
,
S
ConsumerObj
*
pConsumer
,
S
ConsumerObj
*
pNewConsumer
);
static
int32_t
mndConsumerActionUpdate
(
SSdb
*
pSdb
,
S
MqConsumerObj
*
pConsumer
,
SMq
ConsumerObj
*
pNewConsumer
);
static
int32_t
mndProcessCreateConsumerMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessCreateConsumerMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessDropConsumerMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessDropConsumerMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessDropConsumerInRsp
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessDropConsumerInRsp
(
SMnodeMsg
*
pMsg
);
...
@@ -57,8 +58,8 @@ int32_t mndInitConsumer(SMnode *pMnode) {
...
@@ -57,8 +58,8 @@ int32_t mndInitConsumer(SMnode *pMnode) {
.
deleteFp
=
(
SdbDeleteFp
)
mndConsumerActionDelete
};
.
deleteFp
=
(
SdbDeleteFp
)
mndConsumerActionDelete
};
mndSetMsgHandle
(
pMnode
,
TDMT_MND_SUBSCRIBE
,
mndProcessSubscribeReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_SUBSCRIBE
,
mndProcessSubscribeReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_SUBSCRIBE_RSP
,
mndProcessSubscribeRsp
);
/*mndSetMsgHandle(pMnode, TDMT_MND_SUBSCRIBE_RSP, mndProcessSubscribeRsp);*/
mndSetMsgHandle
(
pMnode
,
TDMT_VND_SUBSCRIBE
,
mndProcessSubscribeInternalReq
);
/*mndSetMsgHandle(pMnode, TDMT_VND_SUBSCRIBE, mndProcessSubscribeInternalReq);*/
mndSetMsgHandle
(
pMnode
,
TDMT_VND_SUBSCRIBE_RSP
,
mndProcessSubscribeInternalRsp
);
mndSetMsgHandle
(
pMnode
,
TDMT_VND_SUBSCRIBE_RSP
,
mndProcessSubscribeInternalRsp
);
return
sdbSetTable
(
pMnode
->
pSdb
,
table
);
return
sdbSetTable
(
pMnode
->
pSdb
,
table
);
...
@@ -66,33 +67,52 @@ int32_t mndInitConsumer(SMnode *pMnode) {
...
@@ -66,33 +67,52 @@ int32_t mndInitConsumer(SMnode *pMnode) {
void
mndCleanupConsumer
(
SMnode
*
pMnode
)
{}
void
mndCleanupConsumer
(
SMnode
*
pMnode
)
{}
static
SSdbRaw
*
mndConsumerActionEncode
(
SConsumerObj
*
pConsumer
)
{
static
void
*
mndBuildMqVGroupSetReq
(
SMnode
*
pMnode
,
char
*
topicName
,
int32_t
vgId
,
int64_t
consumerId
,
char
*
cgroup
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
0
;
}
int32_t
size
=
sizeof
(
SConsumerObj
)
+
MND_CONSUMER_RESERVE_SIZE
;
static
SSdbRaw
*
mndConsumerActionEncode
(
SMqConsumerObj
*
pConsumer
)
{
int32_t
size
=
sizeof
(
SMqConsumerObj
)
+
MND_CONSUMER_RESERVE_SIZE
;
SSdbRaw
*
pRaw
=
sdbAllocRaw
(
SDB_CONSUMER
,
MND_CONSUMER_VER_NUMBER
,
size
);
SSdbRaw
*
pRaw
=
sdbAllocRaw
(
SDB_CONSUMER
,
MND_CONSUMER_VER_NUMBER
,
size
);
if
(
pRaw
==
NULL
)
goto
CM_ENCODE_OVER
;
if
(
pRaw
==
NULL
)
goto
CM_ENCODE_OVER
;
int32_t
dataPos
=
0
;
int32_t
dataPos
=
0
;
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pConsumer
->
name
,
TSDB_TABLE_FNAME_LEN
,
CM_ENCODE_OVER
)
int32_t
topicNum
=
taosArrayGetSize
(
pConsumer
->
topics
);
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pConsumer
->
db
,
TSDB_DB_FNAME_LEN
,
CM_ENCODE_OVER
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pConsumer
->
consumerId
,
CM_ENCODE_OVER
);
SDB_SET_INT64
(
pRaw
,
dataPos
,
pConsumer
->
createTime
,
CM_ENCODE_OVER
)
int32_t
len
=
strlen
(
pConsumer
->
cgroup
);
SDB_SET_INT64
(
pRaw
,
dataPos
,
pConsumer
->
updateTime
,
CM_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
len
,
CM_ENCODE_OVER
);
SDB_SET_INT64
(
pRaw
,
dataPos
,
pConsumer
->
uid
,
CM_ENCODE_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pConsumer
->
cgroup
,
len
,
CM_ENCODE_OVER
);
/*SDB_SET_INT64(pRaw, dataPos, pConsumer->dbUid);*/
SDB_SET_INT32
(
pRaw
,
dataPos
,
topicNum
,
CM_ENCODE_OVER
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
pConsumer
->
version
,
CM_ENCODE_OVER
)
for
(
int
i
=
0
;
i
<
topicNum
;
i
++
)
{
int32_t
len
;
SMqConsumerTopic
*
pConsumerTopic
=
taosArrayGet
(
pConsumer
->
topics
,
i
);
len
=
strlen
(
pConsumerTopic
->
name
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
len
,
CM_ENCODE_OVER
);
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pConsumerTopic
->
name
,
len
,
CM_ENCODE_OVER
);
int
vgSize
;
if
(
pConsumerTopic
->
vgroups
==
NULL
)
{
vgSize
=
0
;
}
else
{
vgSize
=
listNEles
(
pConsumerTopic
->
vgroups
);
}
SDB_SET_INT32
(
pRaw
,
dataPos
,
vgSize
,
CM_ENCODE_OVER
);
for
(
int
j
=
0
;
j
<
vgSize
;
j
++
)
{
// SList* head;
/*SDB_SET_INT64(pRaw, dataPos, 0[> change to list item <]);*/
}
}
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
MND_CONSUMER_RESERVE_SIZE
,
CM_ENCODE_OVER
)
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
MND_CONSUMER_RESERVE_SIZE
,
CM_ENCODE_OVER
)
;
SDB_SET_DATALEN
(
pRaw
,
dataPos
,
CM_ENCODE_OVER
)
SDB_SET_DATALEN
(
pRaw
,
dataPos
,
CM_ENCODE_OVER
)
;
CM_ENCODE_OVER:
CM_ENCODE_OVER:
if
(
terrno
!=
0
)
{
if
(
terrno
!=
0
)
{
mError
(
"consumer:%
s, failed to encode to raw:%p since %s"
,
pConsumer
->
name
,
pRaw
,
terrstr
());
mError
(
"consumer:%
ld, failed to encode to raw:%p since %s"
,
pConsumer
->
consumerId
,
pRaw
,
terrstr
());
sdbFreeRaw
(
pRaw
);
sdbFreeRaw
(
pRaw
);
return
NULL
;
return
NULL
;
}
}
mTrace
(
"consumer:%
s, encode to raw:%p, row:%p"
,
pConsumer
->
name
,
pRaw
,
pConsumer
);
mTrace
(
"consumer:%
ld, encode to raw:%p, row:%p"
,
pConsumer
->
consumerId
,
pRaw
,
pConsumer
);
return
pRaw
;
return
pRaw
;
}
}
...
@@ -107,68 +127,77 @@ static SSdbRow *mndConsumerActionDecode(SSdbRaw *pRaw) {
...
@@ -107,68 +127,77 @@ static SSdbRow *mndConsumerActionDecode(SSdbRaw *pRaw) {
goto
CONSUME_DECODE_OVER
;
goto
CONSUME_DECODE_OVER
;
}
}
int32_t
size
=
sizeof
(
SConsumerObj
)
+
TSDB_MAX_COLUMNS
*
sizeof
(
SSchema
);
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
;
SConsumerObj
*
pConsumer
=
sdbGetRowObj
(
pRow
);
S
Mq
ConsumerObj
*
pConsumer
=
sdbGetRowObj
(
pRow
);
if
(
pConsumer
==
NULL
)
goto
CONSUME_DECODE_OVER
;
if
(
pConsumer
==
NULL
)
goto
CONSUME_DECODE_OVER
;
int32_t
dataPos
=
0
;
int32_t
dataPos
=
0
;
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pConsumer
->
name
,
TSDB_TABLE_FNAME_LEN
,
CONSUME_DECODE_OVER
)
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pConsumer
->
consumerId
,
CONSUME_DECODE_OVER
);
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pConsumer
->
db
,
TSDB_DB_FNAME_LEN
,
CONSUME_DECODE_OVER
)
int32_t
len
,
topicNum
;
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pConsumer
->
createTime
,
CONSUME_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
len
,
CONSUME_DECODE_OVER
);
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pConsumer
->
updateTime
,
CONSUME_DECODE_OVER
)
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pConsumer
->
cgroup
,
len
,
CONSUME_DECODE_OVER
);
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pConsumer
->
uid
,
CONSUME_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
topicNum
,
CONSUME_DECODE_OVER
);
/*SDB_GET_INT64(pRaw, pRow, dataPos, &pConsumer->dbUid);*/
for
(
int
i
=
0
;
i
<
topicNum
;
i
++
)
{
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pConsumer
->
version
,
CONSUME_DECODE_OVER
)
int32_t
topicLen
;
SDB_GET_RESERVE
(
pRaw
,
dataPos
,
MND_CONSUMER_RESERVE_SIZE
,
CONSUME_DECODE_OVER
)
SMqConsumerTopic
*
pConsumerTopic
=
malloc
(
sizeof
(
SMqConsumerTopic
));
terrno
=
0
;
if
(
pConsumerTopic
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
// TODO
return
NULL
;
}
/*pConsumerTopic->vgroups = taosArrayInit(topicNum, sizeof(SMqConsumerTopic));*/
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
topicLen
,
CONSUME_DECODE_OVER
);
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pConsumerTopic
->
name
,
topicLen
,
CONSUME_DECODE_OVER
);
int32_t
vgSize
;
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
vgSize
,
CONSUME_DECODE_OVER
);
}
CONSUME_DECODE_OVER:
CONSUME_DECODE_OVER:
if
(
terrno
!=
0
)
{
if
(
terrno
!=
0
)
{
mError
(
"consumer:%
s, failed to decode from raw:%p since %s"
,
pConsumer
->
name
,
pRaw
,
terrstr
());
mError
(
"consumer:%
ld, failed to decode from raw:%p since %s"
,
pConsumer
->
consumerId
,
pRaw
,
terrstr
());
tfree
(
pRow
);
tfree
(
pRow
);
return
NULL
;
return
NULL
;
}
}
mTrace
(
"consumer:%s, decode from raw:%p, row:%p"
,
pConsumer
->
name
,
pRaw
,
pConsumer
);
/*SDB_GET_RESERVE(pRaw, dataPos, MND_CONSUMER_RESERVE_SIZE);*/
return
pRow
;
return
pRow
;
}
}
static
int32_t
mndConsumerActionInsert
(
SSdb
*
pSdb
,
SConsumerObj
*
pConsumer
)
{
static
int32_t
mndConsumerActionInsert
(
SSdb
*
pSdb
,
S
Mq
ConsumerObj
*
pConsumer
)
{
mTrace
(
"consumer:%
s, perform insert action, row:%p"
,
pConsumer
->
name
,
pConsumer
);
mTrace
(
"consumer:%
ld, perform insert action"
,
pConsumer
->
consumerId
);
return
0
;
return
0
;
}
}
static
int32_t
mndConsumerActionDelete
(
SSdb
*
pSdb
,
SConsumerObj
*
pConsumer
)
{
static
int32_t
mndConsumerActionDelete
(
SSdb
*
pSdb
,
S
Mq
ConsumerObj
*
pConsumer
)
{
mTrace
(
"consumer:%
s, perform delete action, row:%p"
,
pConsumer
->
name
,
pConsumer
);
mTrace
(
"consumer:%
ld, perform delete action"
,
pConsumer
->
consumerId
);
return
0
;
return
0
;
}
}
static
int32_t
mndConsumerActionUpdate
(
SSdb
*
pSdb
,
SConsumerObj
*
pOldConsumer
,
SConsumerObj
*
pNewConsumer
)
{
static
int32_t
mndConsumerActionUpdate
(
SSdb
*
pSdb
,
SMqConsumerObj
*
pOldConsumer
,
SMqConsumerObj
*
pNewConsumer
)
{
mTrace
(
"consumer:%s, perform update action, old_row:%p new_row:%p"
,
pOldConsumer
->
name
,
pOldConsumer
,
pNewConsumer
);
mTrace
(
"consumer:%ld, perform update action"
,
pOldConsumer
->
consumerId
);
atomic_exchange_32
(
&
pOldConsumer
->
updateTime
,
pNewConsumer
->
updateTime
);
atomic_exchange_32
(
&
pOldConsumer
->
version
,
pNewConsumer
->
version
);
taosWLockLatch
(
&
pOldConsumer
->
lock
);
// TODO handle update
// TODO handle update
/*taosWLockLatch(&pOldConsumer->lock);*/
/*taosWUnLockLatch(&pOldConsumer->lock);*/
taosWUnLockLatch
(
&
pOldConsumer
->
lock
);
return
0
;
return
0
;
}
}
SConsumerObj
*
mndAcquireConsumer
(
SMnode
*
pMnode
,
int32_t
consumerId
)
{
S
Mq
ConsumerObj
*
mndAcquireConsumer
(
SMnode
*
pMnode
,
int32_t
consumerId
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SConsumerObj
*
pConsumer
=
sdbAcquire
(
pSdb
,
SDB_CONSUMER
,
&
consumerId
);
S
Mq
ConsumerObj
*
pConsumer
=
sdbAcquire
(
pSdb
,
SDB_CONSUMER
,
&
consumerId
);
if
(
pConsumer
==
NULL
)
{
if
(
pConsumer
==
NULL
)
{
/*terrno = TSDB_CODE_MND_CONSUMER_NOT_EXIST;*/
/*terrno = TSDB_CODE_MND_CONSUMER_NOT_EXIST;*/
}
}
return
pConsumer
;
return
pConsumer
;
}
}
void
mndReleaseConsumer
(
SMnode
*
pMnode
,
SConsumerObj
*
pConsumer
)
{
void
mndReleaseConsumer
(
SMnode
*
pMnode
,
S
Mq
ConsumerObj
*
pConsumer
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
sdbRelease
(
pSdb
,
pConsumer
);
sdbRelease
(
pSdb
,
pConsumer
);
}
}
...
@@ -178,23 +207,185 @@ static int32_t mndProcessSubscribeReq(SMnodeMsg *pMsg) {
...
@@ -178,23 +207,185 @@ static int32_t mndProcessSubscribeReq(SMnodeMsg *pMsg) {
char
*
msgStr
=
pMsg
->
rpcMsg
.
pCont
;
char
*
msgStr
=
pMsg
->
rpcMsg
.
pCont
;
SCMSubscribeReq
*
pSubscribe
;
SCMSubscribeReq
*
pSubscribe
;
tDeserializeSCMSubscribeReq
(
msgStr
,
pSubscribe
);
tDeserializeSCMSubscribeReq
(
msgStr
,
pSubscribe
);
// add consumerGroupId -> list<consumerId> to sdb
int64_t
consumerId
=
pSubscribe
->
consumerId
;
// add consumerId -> list<consumer> to sdb
char
*
consumerGroup
=
pSubscribe
->
consumerGroup
;
// add consumer -> list<consumerId> to sdb
return
0
;
}
static
int32_t
mndProcessSubscribeRsp
(
SMnodeMsg
*
pMsg
)
{
return
0
;
}
SArray
*
newSub
=
NULL
;
int
newTopicNum
=
pSubscribe
->
topicNum
;
if
(
newTopicNum
)
{
newSub
=
taosArrayInit
(
newTopicNum
,
sizeof
(
SMqConsumerTopic
));
}
for
(
int
i
=
0
;
i
<
newTopicNum
;
i
++
)
{
char
*
topic
=
pSubscribe
->
topicName
[
i
];
SMqConsumerTopic
*
pConsumerTopic
=
malloc
(
sizeof
(
SMqConsumerTopic
));
if
(
pConsumerTopic
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
// TODO: free
return
-
1
;
}
pConsumerTopic
->
vgroups
=
tdListNew
(
sizeof
(
int64_t
));
taosArrayPush
(
newSub
,
pConsumerTopic
);
free
(
pConsumerTopic
);
}
taosArraySortString
(
newSub
,
taosArrayCompareString
);
static
int32_t
mndProcessSubscribeInternalReq
(
SMnodeMsg
*
pMsg
)
{
return
0
;
}
SArray
*
oldSub
=
NULL
;
int
oldTopicNum
=
0
;
SMqConsumerObj
*
pConsumer
=
mndAcquireConsumer
(
pMnode
,
consumerId
);
if
(
pConsumer
==
NULL
)
{
// create consumer
pConsumer
=
malloc
(
sizeof
(
SMqConsumerObj
));
if
(
pConsumer
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
strcpy
(
pConsumer
->
cgroup
,
pSubscribe
->
consumerGroup
);
static
int32_t
mndProcessSubscribeInternalRsp
(
SMnodeMsg
*
pMsg
)
{
return
0
;
}
}
else
{
oldSub
=
pConsumer
->
topics
;
oldTopicNum
=
taosArrayGetSize
(
oldSub
);
}
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
&
pMsg
->
rpcMsg
);
if
(
pTrans
==
NULL
)
{
return
-
1
;
}
static
int32_t
mndProcessDropConsumerInRsp
(
SMnodeMsg
*
pMsg
)
{
int
i
=
0
,
j
=
0
;
mndTransProcessRsp
(
pMsg
);
while
(
i
<
newTopicNum
||
j
<
oldTopicNum
)
{
SMqConsumerTopic
*
pOldTopic
=
NULL
;
SMqConsumerTopic
*
pNewTopic
=
NULL
;
if
(
i
>=
newTopicNum
)
{
// encode unset topic msg to all vnodes related to that topic
pOldTopic
=
taosArrayGet
(
oldSub
,
j
);
j
++
;
}
else
if
(
j
>=
oldTopicNum
)
{
pNewTopic
=
taosArrayGet
(
newSub
,
i
);
}
else
{
pNewTopic
=
taosArrayGet
(
newSub
,
i
);
pOldTopic
=
taosArrayGet
(
oldSub
,
j
);
char
*
newName
=
pNewTopic
->
name
;
char
*
oldName
=
pOldTopic
->
name
;
int
comp
=
compareLenPrefixedStr
(
newName
,
oldName
);
if
(
comp
==
0
)
{
// do nothing
pOldTopic
=
pNewTopic
=
NULL
;
i
++
;
j
++
;
continue
;
}
else
if
(
comp
<
0
)
{
pOldTopic
=
NULL
;
i
++
;
}
else
{
pNewTopic
=
NULL
;
j
++
;
}
}
if
(
pOldTopic
!=
NULL
)
{
ASSERT
(
pNewTopic
==
NULL
);
char
*
oldTopicName
=
pOldTopic
->
name
;
SList
*
vgroups
=
pOldTopic
->
vgroups
;
SListIter
iter
;
tdListInitIter
(
vgroups
,
&
iter
,
TD_LIST_FORWARD
);
SListNode
*
pn
;
SMqTopicObj
*
pTopic
=
mndAcquireTopic
(
pMnode
,
oldTopicName
);
ASSERT
(
pTopic
!=
NULL
);
SMqCGroup
*
pGroup
=
taosHashGet
(
pTopic
->
cgroups
,
pSubscribe
->
consumerGroup
,
strlen
(
pSubscribe
->
consumerGroup
));
while
((
pn
=
tdListNext
(
&
iter
))
!=
NULL
)
{
int32_t
vgId
=
*
(
int64_t
*
)
pn
->
data
;
SVgObj
*
pVgObj
=
mndAcquireVgroup
(
pMnode
,
vgId
);
// TODO release
if
(
pVgObj
==
NULL
)
{
// TODO handle error
continue
;
}
// acquire and get epset
void
*
pMqVgSetReq
=
mndBuildMqVGroupSetReq
(
pMnode
,
oldTopicName
,
vgId
,
pSubscribe
->
consumerId
,
pSubscribe
->
consumerGroup
);
// TODO:serialize
if
(
pMsg
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
STransAction
action
=
{
0
};
action
.
epSet
=
mndGetVgroupEpset
(
pMnode
,
pVgObj
);
action
.
pCont
=
pMqVgSetReq
;
action
.
contLen
=
0
;
// TODO
action
.
msgType
=
TDMT_VND_MQ_SET_CONN
;
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
free
(
pMqVgSetReq
);
mndTransDrop
(
pTrans
);
// TODO free
return
-
1
;
}
}
taosHashRemove
(
pTopic
->
cgroups
,
pSubscribe
->
consumerGroup
,
strlen
(
pSubscribe
->
consumerGroup
));
}
else
if
(
pNewTopic
!=
NULL
)
{
ASSERT
(
pOldTopic
==
NULL
);
char
*
newTopicName
=
pNewTopic
->
name
;
SMqTopicObj
*
pTopic
=
mndAcquireTopic
(
pMnode
,
newTopicName
);
ASSERT
(
pTopic
!=
NULL
);
SMqCGroup
*
pGroup
=
taosHashGet
(
pTopic
->
cgroups
,
pSubscribe
->
consumerGroup
,
strlen
(
pSubscribe
->
consumerGroup
));
if
(
pGroup
==
NULL
)
{
// add new group
pGroup
=
malloc
(
sizeof
(
SMqCGroup
));
if
(
pGroup
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
pGroup
->
consumerIds
=
tdListNew
(
sizeof
(
int64_t
));
if
(
pGroup
->
consumerIds
==
NULL
)
{
free
(
pGroup
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
pGroup
->
status
=
0
;
// add into cgroups
taosHashPut
(
pTopic
->
cgroups
,
pSubscribe
->
consumerGroup
,
strlen
(
pSubscribe
->
consumerGroup
),
pGroup
,
sizeof
(
SMqCGroup
));
}
// put the consumer into list
// rebalance will be triggered by timer
tdListAppend
(
pGroup
->
consumerIds
,
&
pSubscribe
->
consumerId
);
SSdbRaw
*
pTopicRaw
=
mndTopicActionEncode
(
pTopic
);
sdbSetRawStatus
(
pTopicRaw
,
SDB_STATUS_READY
);
// TODO: error handling
mndTransAppendRedolog
(
pTrans
,
pTopicRaw
);
}
else
{
ASSERT
(
0
);
}
}
// destroy old sub
taosArrayDestroy
(
oldSub
);
// put new sub into consumerobj
pConsumer
->
topics
=
newSub
;
// persist consumerObj
SSdbRaw
*
pConsumerRaw
=
mndConsumerActionEncode
(
pConsumer
);
sdbSetRawStatus
(
pConsumerRaw
,
SDB_STATUS_READY
);
// TODO: error handling
mndTransAppendRedolog
(
pTrans
,
pConsumerRaw
);
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
{
mError
(
"trans:%d, failed to prepare since %s"
,
pTrans
->
id
,
terrstr
());
mndTransDrop
(
pTrans
);
return
-
1
;
}
// TODO: free memory
mndTransDrop
(
pTrans
);
return
0
;
return
0
;
}
}
static
int32_t
mndProcessSubscribeInternalRsp
(
SMnodeMsg
*
pMsg
)
{
return
0
;
}
static
int32_t
mndProcessConsumerMetaMsg
(
SMnodeMsg
*
pMsg
)
{
static
int32_t
mndProcessConsumerMetaMsg
(
SMnodeMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SMnode
*
pMnode
=
pMsg
->
pMnode
;
STableInfoMsg
*
pInfo
=
pMsg
->
rpcMsg
.
pCont
;
STableInfoMsg
*
pInfo
=
pMsg
->
rpcMsg
.
pCont
;
...
@@ -272,13 +463,11 @@ static int32_t mndGetNumOfConsumers(SMnode *pMnode, char *dbName, int32_t *pNumO
...
@@ -272,13 +463,11 @@ static int32_t mndGetNumOfConsumers(SMnode *pMnode, char *dbName, int32_t *pNumO
int32_t
numOfConsumers
=
0
;
int32_t
numOfConsumers
=
0
;
void
*
pIter
=
NULL
;
void
*
pIter
=
NULL
;
while
(
1
)
{
while
(
1
)
{
SConsumerObj
*
pConsumer
=
NULL
;
S
Mq
ConsumerObj
*
pConsumer
=
NULL
;
pIter
=
sdbFetch
(
pSdb
,
SDB_CONSUMER
,
pIter
,
(
void
**
)
&
pConsumer
);
pIter
=
sdbFetch
(
pSdb
,
SDB_CONSUMER
,
pIter
,
(
void
**
)
&
pConsumer
);
if
(
pIter
==
NULL
)
break
;
if
(
pIter
==
NULL
)
break
;
if
(
strcmp
(
pConsumer
->
db
,
dbName
)
==
0
)
{
numOfConsumers
++
;
numOfConsumers
++
;
}
sdbRelease
(
pSdb
,
pConsumer
);
sdbRelease
(
pSdb
,
pConsumer
);
}
}
...
@@ -337,57 +526,6 @@ static int32_t mndGetConsumerMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMs
...
@@ -337,57 +526,6 @@ static int32_t mndGetConsumerMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMs
return
0
;
return
0
;
}
}
static
int32_t
mndRetrieveConsumer
(
SMnodeMsg
*
pMsg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
numOfRows
=
0
;
SConsumerObj
*
pConsumer
=
NULL
;
int32_t
cols
=
0
;
char
*
pWrite
;
char
prefix
[
64
]
=
{
0
};
tstrncpy
(
prefix
,
pShow
->
db
,
64
);
strcat
(
prefix
,
TS_PATH_DELIMITER
);
int32_t
prefixLen
=
(
int32_t
)
strlen
(
prefix
);
while
(
numOfRows
<
rows
)
{
pShow
->
pIter
=
sdbFetch
(
pSdb
,
SDB_CONSUMER
,
pShow
->
pIter
,
(
void
**
)
&
pConsumer
);
if
(
pShow
->
pIter
==
NULL
)
break
;
if
(
strncmp
(
pConsumer
->
name
,
prefix
,
prefixLen
)
!=
0
)
{
sdbRelease
(
pSdb
,
pConsumer
);
continue
;
}
cols
=
0
;
char
consumerName
[
TSDB_TABLE_NAME_LEN
]
=
{
0
};
tstrncpy
(
consumerName
,
pConsumer
->
name
+
prefixLen
,
TSDB_TABLE_NAME_LEN
);
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
STR_TO_VARSTR
(
pWrite
,
consumerName
);
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
int64_t
*
)
pWrite
=
pConsumer
->
createTime
;
cols
++
;
/*pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;*/
/**(int32_t *)pWrite = pConsumer->numOfColumns;*/
/*cols++;*/
/*pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;*/
/**(int32_t *)pWrite = pConsumer->numOfTags;*/
/*cols++;*/
numOfRows
++
;
sdbRelease
(
pSdb
,
pConsumer
);
}
pShow
->
numOfReads
+=
numOfRows
;
mndVacuumResult
(
data
,
pShow
->
numOfColumns
,
numOfRows
,
rows
,
pShow
);
return
numOfRows
;
}
static
void
mndCancelGetNextConsumer
(
SMnode
*
pMnode
,
void
*
pIter
)
{
static
void
mndCancelGetNextConsumer
(
SMnode
*
pMnode
,
void
*
pIter
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
sdbCancelFetch
(
pSdb
,
pIter
);
sdbCancelFetch
(
pSdb
,
pIter
);
...
...
source/dnode/mnode/impl/src/mndQnode.c
浏览文件 @
96f2aea2
...
@@ -27,12 +27,12 @@ static SSdbRow *mndQnodeActionDecode(SSdbRaw *pRaw);
...
@@ -27,12 +27,12 @@ static SSdbRow *mndQnodeActionDecode(SSdbRaw *pRaw);
static
int32_t
mndQnodeActionInsert
(
SSdb
*
pSdb
,
SQnodeObj
*
pObj
);
static
int32_t
mndQnodeActionInsert
(
SSdb
*
pSdb
,
SQnodeObj
*
pObj
);
static
int32_t
mndQnodeActionDelete
(
SSdb
*
pSdb
,
SQnodeObj
*
pObj
);
static
int32_t
mndQnodeActionDelete
(
SSdb
*
pSdb
,
SQnodeObj
*
pObj
);
static
int32_t
mndQnodeActionUpdate
(
SSdb
*
pSdb
,
SQnodeObj
*
pOld
,
SQnodeObj
*
pNew
);
static
int32_t
mndQnodeActionUpdate
(
SSdb
*
pSdb
,
SQnodeObj
*
pOld
,
SQnodeObj
*
pNew
);
static
int32_t
mndProcessCreateQnodeReq
(
SMnodeMsg
*
p
Msg
);
static
int32_t
mndProcessCreateQnodeReq
(
SMnodeMsg
*
p
Req
);
static
int32_t
mndProcessDropQnodeReq
(
SMnodeMsg
*
p
Msg
);
static
int32_t
mndProcessDropQnodeReq
(
SMnodeMsg
*
p
Req
);
static
int32_t
mndProcessCreateQnodeRsp
(
SMnodeMsg
*
p
Msg
);
static
int32_t
mndProcessCreateQnodeRsp
(
SMnodeMsg
*
p
Rsp
);
static
int32_t
mndProcessDropQnodeRsp
(
SMnodeMsg
*
p
Msg
);
static
int32_t
mndProcessDropQnodeRsp
(
SMnodeMsg
*
p
Rsp
);
static
int32_t
mndGetQnodeMeta
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
);
static
int32_t
mndGetQnodeMeta
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
);
static
int32_t
mndRetrieveQnodes
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
int32_t
mndRetrieveQnodes
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
void
mndCancelGetNextQnode
(
SMnode
*
pMnode
,
void
*
pIter
);
static
void
mndCancelGetNextQnode
(
SMnode
*
pMnode
,
void
*
pIter
);
int32_t
mndInitQnode
(
SMnode
*
pMnode
)
{
int32_t
mndInitQnode
(
SMnode
*
pMnode
)
{
...
@@ -185,22 +185,22 @@ static int32_t mndSetCreateQnodeCommitLogs(STrans *pTrans, SQnodeObj *pObj) {
...
@@ -185,22 +185,22 @@ static int32_t mndSetCreateQnodeCommitLogs(STrans *pTrans, SQnodeObj *pObj) {
}
}
static
int32_t
mndSetCreateQnodeRedoActions
(
STrans
*
pTrans
,
SDnodeObj
*
pDnode
,
SQnodeObj
*
pObj
)
{
static
int32_t
mndSetCreateQnodeRedoActions
(
STrans
*
pTrans
,
SDnodeObj
*
pDnode
,
SQnodeObj
*
pObj
)
{
SDCreateQnodeReq
*
p
Msg
=
malloc
(
sizeof
(
SDCreateQnodeReq
));
SDCreateQnodeReq
*
p
Req
=
malloc
(
sizeof
(
SDCreateQnodeReq
));
if
(
p
Msg
==
NULL
)
{
if
(
p
Req
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
}
}
p
Msg
->
dnodeId
=
htonl
(
pDnode
->
id
);
p
Req
->
dnodeId
=
htonl
(
pDnode
->
id
);
STransAction
action
=
{
0
};
STransAction
action
=
{
0
};
action
.
epSet
=
mndGetDnodeEpset
(
pDnode
);
action
.
epSet
=
mndGetDnodeEpset
(
pDnode
);
action
.
pCont
=
p
Msg
;
action
.
pCont
=
p
Req
;
action
.
contLen
=
sizeof
(
SDCreateQnodeReq
);
action
.
contLen
=
sizeof
(
SDCreateQnodeReq
);
action
.
msgType
=
TDMT_DND_CREATE_QNODE
;
action
.
msgType
=
TDMT_DND_CREATE_QNODE
;
action
.
acceptableCode
=
TSDB_CODE_DND_QNODE_ALREADY_DEPLOYED
;
action
.
acceptableCode
=
TSDB_CODE_DND_QNODE_ALREADY_DEPLOYED
;
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
free
(
p
Msg
);
free
(
p
Req
);
return
-
1
;
return
-
1
;
}
}
...
@@ -208,29 +208,29 @@ static int32_t mndSetCreateQnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, S
...
@@ -208,29 +208,29 @@ static int32_t mndSetCreateQnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, S
}
}
static
int32_t
mndSetCreateQnodeUndoActions
(
STrans
*
pTrans
,
SDnodeObj
*
pDnode
,
SQnodeObj
*
pObj
)
{
static
int32_t
mndSetCreateQnodeUndoActions
(
STrans
*
pTrans
,
SDnodeObj
*
pDnode
,
SQnodeObj
*
pObj
)
{
SDDropQnodeReq
*
p
Msg
=
malloc
(
sizeof
(
SDDropQnodeReq
));
SDDropQnodeReq
*
p
Req
=
malloc
(
sizeof
(
SDDropQnodeReq
));
if
(
p
Msg
==
NULL
)
{
if
(
p
Req
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
}
}
p
Msg
->
dnodeId
=
htonl
(
pDnode
->
id
);
p
Req
->
dnodeId
=
htonl
(
pDnode
->
id
);
STransAction
action
=
{
0
};
STransAction
action
=
{
0
};
action
.
epSet
=
mndGetDnodeEpset
(
pDnode
);
action
.
epSet
=
mndGetDnodeEpset
(
pDnode
);
action
.
pCont
=
p
Msg
;
action
.
pCont
=
p
Req
;
action
.
contLen
=
sizeof
(
SDDropQnodeReq
);
action
.
contLen
=
sizeof
(
SDDropQnodeReq
);
action
.
msgType
=
TDMT_DND_DROP_QNODE
;
action
.
msgType
=
TDMT_DND_DROP_QNODE
;
action
.
acceptableCode
=
TSDB_CODE_DND_QNODE_NOT_DEPLOYED
;
action
.
acceptableCode
=
TSDB_CODE_DND_QNODE_NOT_DEPLOYED
;
if
(
mndTransAppendUndoAction
(
pTrans
,
&
action
)
!=
0
)
{
if
(
mndTransAppendUndoAction
(
pTrans
,
&
action
)
!=
0
)
{
free
(
p
Msg
);
free
(
p
Req
);
return
-
1
;
return
-
1
;
}
}
return
0
;
return
0
;
}
}
static
int32_t
mndCreateQnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
p
Msg
,
SDnodeObj
*
pDnode
,
SMCreateQnodeReq
*
pCreate
)
{
static
int32_t
mndCreateQnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
p
Req
,
SDnodeObj
*
pDnode
,
SMCreateQnodeReq
*
pCreate
)
{
int32_t
code
=
-
1
;
int32_t
code
=
-
1
;
SQnodeObj
qnodeObj
=
{
0
};
SQnodeObj
qnodeObj
=
{
0
};
...
@@ -238,7 +238,7 @@ static int32_t mndCreateQnode(SMnode *pMnode, SMnodeMsg *pMsg, SDnodeObj *pDnode
...
@@ -238,7 +238,7 @@ static int32_t mndCreateQnode(SMnode *pMnode, SMnodeMsg *pMsg, SDnodeObj *pDnode
qnodeObj
.
createdTime
=
taosGetTimestampMs
();
qnodeObj
.
createdTime
=
taosGetTimestampMs
();
qnodeObj
.
updateTime
=
qnodeObj
.
createdTime
;
qnodeObj
.
updateTime
=
qnodeObj
.
createdTime
;
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
&
p
Msg
->
rpcMsg
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
&
p
Req
->
rpcMsg
);
if
(
pTrans
==
NULL
)
goto
CREATE_QNODE_OVER
;
if
(
pTrans
==
NULL
)
goto
CREATE_QNODE_OVER
;
mDebug
(
"trans:%d, used to create qnode:%d"
,
pTrans
->
id
,
pCreate
->
dnodeId
);
mDebug
(
"trans:%d, used to create qnode:%d"
,
pTrans
->
id
,
pCreate
->
dnodeId
);
...
@@ -256,9 +256,9 @@ CREATE_QNODE_OVER:
...
@@ -256,9 +256,9 @@ CREATE_QNODE_OVER:
return
code
;
return
code
;
}
}
static
int32_t
mndProcessCreateQnodeReq
(
SMnodeMsg
*
p
Msg
)
{
static
int32_t
mndProcessCreateQnodeReq
(
SMnodeMsg
*
p
Req
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SMCreateQnodeReq
*
pCreate
=
p
Msg
->
rpcMsg
.
pCont
;
SMCreateQnodeReq
*
pCreate
=
p
Req
->
rpcMsg
.
pCont
;
pCreate
->
dnodeId
=
htonl
(
pCreate
->
dnodeId
);
pCreate
->
dnodeId
=
htonl
(
pCreate
->
dnodeId
);
...
@@ -282,7 +282,7 @@ static int32_t mndProcessCreateQnodeReq(SMnodeMsg *pMsg) {
...
@@ -282,7 +282,7 @@ static int32_t mndProcessCreateQnodeReq(SMnodeMsg *pMsg) {
return
-
1
;
return
-
1
;
}
}
int32_t
code
=
mndCreateQnode
(
pMnode
,
p
Msg
,
pDnode
,
pCreate
);
int32_t
code
=
mndCreateQnode
(
pMnode
,
p
Req
,
pDnode
,
pCreate
);
mndReleaseDnode
(
pMnode
,
pDnode
);
mndReleaseDnode
(
pMnode
,
pDnode
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
...
@@ -310,32 +310,32 @@ static int32_t mndSetDropQnodeCommitLogs(STrans *pTrans, SQnodeObj *pObj) {
...
@@ -310,32 +310,32 @@ static int32_t mndSetDropQnodeCommitLogs(STrans *pTrans, SQnodeObj *pObj) {
}
}
static
int32_t
mndSetDropQnodeRedoActions
(
STrans
*
pTrans
,
SDnodeObj
*
pDnode
,
SQnodeObj
*
pObj
)
{
static
int32_t
mndSetDropQnodeRedoActions
(
STrans
*
pTrans
,
SDnodeObj
*
pDnode
,
SQnodeObj
*
pObj
)
{
SDDropQnodeReq
*
p
Msg
=
malloc
(
sizeof
(
SDDropQnodeReq
));
SDDropQnodeReq
*
p
Req
=
malloc
(
sizeof
(
SDDropQnodeReq
));
if
(
p
Msg
==
NULL
)
{
if
(
p
Req
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
}
}
p
Msg
->
dnodeId
=
htonl
(
pDnode
->
id
);
p
Req
->
dnodeId
=
htonl
(
pDnode
->
id
);
STransAction
action
=
{
0
};
STransAction
action
=
{
0
};
action
.
epSet
=
mndGetDnodeEpset
(
pDnode
);
action
.
epSet
=
mndGetDnodeEpset
(
pDnode
);
action
.
pCont
=
p
Msg
;
action
.
pCont
=
p
Req
;
action
.
contLen
=
sizeof
(
SDDropQnodeReq
);
action
.
contLen
=
sizeof
(
SDDropQnodeReq
);
action
.
msgType
=
TDMT_DND_DROP_QNODE
;
action
.
msgType
=
TDMT_DND_DROP_QNODE
;
action
.
acceptableCode
=
TSDB_CODE_DND_QNODE_NOT_DEPLOYED
;
action
.
acceptableCode
=
TSDB_CODE_DND_QNODE_NOT_DEPLOYED
;
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
free
(
p
Msg
);
free
(
p
Req
);
return
-
1
;
return
-
1
;
}
}
return
0
;
return
0
;
}
}
static
int32_t
mndDropQnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
p
Msg
,
SQnodeObj
*
pObj
)
{
static
int32_t
mndDropQnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
p
Req
,
SQnodeObj
*
pObj
)
{
int32_t
code
=
-
1
;
int32_t
code
=
-
1
;
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
&
p
Msg
->
rpcMsg
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
&
p
Req
->
rpcMsg
);
if
(
pTrans
==
NULL
)
goto
DROP_QNODE_OVER
;
if
(
pTrans
==
NULL
)
goto
DROP_QNODE_OVER
;
mDebug
(
"trans:%d, used to drop qnode:%d"
,
pTrans
->
id
,
pObj
->
id
);
mDebug
(
"trans:%d, used to drop qnode:%d"
,
pTrans
->
id
,
pObj
->
id
);
...
@@ -351,9 +351,9 @@ DROP_QNODE_OVER:
...
@@ -351,9 +351,9 @@ DROP_QNODE_OVER:
return
code
;
return
code
;
}
}
static
int32_t
mndProcessDropQnodeReq
(
SMnodeMsg
*
p
Msg
)
{
static
int32_t
mndProcessDropQnodeReq
(
SMnodeMsg
*
p
Req
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SMDropQnodeReq
*
pDrop
=
p
Msg
->
rpcMsg
.
pCont
;
SMDropQnodeReq
*
pDrop
=
p
Req
->
rpcMsg
.
pCont
;
pDrop
->
dnodeId
=
htonl
(
pDrop
->
dnodeId
);
pDrop
->
dnodeId
=
htonl
(
pDrop
->
dnodeId
);
mDebug
(
"qnode:%d, start to drop"
,
pDrop
->
dnodeId
);
mDebug
(
"qnode:%d, start to drop"
,
pDrop
->
dnodeId
);
...
@@ -370,7 +370,7 @@ static int32_t mndProcessDropQnodeReq(SMnodeMsg *pMsg) {
...
@@ -370,7 +370,7 @@ static int32_t mndProcessDropQnodeReq(SMnodeMsg *pMsg) {
return
-
1
;
return
-
1
;
}
}
int32_t
code
=
mndDropQnode
(
pMnode
,
p
Msg
,
pObj
);
int32_t
code
=
mndDropQnode
(
pMnode
,
p
Req
,
pObj
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
sdbRelease
(
pMnode
->
pSdb
,
pObj
);
sdbRelease
(
pMnode
->
pSdb
,
pObj
);
mError
(
"qnode:%d, failed to drop since %s"
,
pMnode
->
dnodeId
,
terrstr
());
mError
(
"qnode:%d, failed to drop since %s"
,
pMnode
->
dnodeId
,
terrstr
());
...
@@ -381,18 +381,18 @@ static int32_t mndProcessDropQnodeReq(SMnodeMsg *pMsg) {
...
@@ -381,18 +381,18 @@ static int32_t mndProcessDropQnodeReq(SMnodeMsg *pMsg) {
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
}
static
int32_t
mndProcessCreateQnodeRsp
(
SMnodeMsg
*
p
Msg
)
{
static
int32_t
mndProcessCreateQnodeRsp
(
SMnodeMsg
*
p
Rsp
)
{
mndTransProcessRsp
(
p
Msg
);
mndTransProcessRsp
(
p
Rsp
);
return
0
;
return
0
;
}
}
static
int32_t
mndProcessDropQnodeRsp
(
SMnodeMsg
*
p
Msg
)
{
static
int32_t
mndProcessDropQnodeRsp
(
SMnodeMsg
*
p
Rsp
)
{
mndTransProcessRsp
(
p
Msg
);
mndTransProcessRsp
(
p
Rsp
);
return
0
;
return
0
;
}
}
static
int32_t
mndGetQnodeMeta
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
)
{
static
int32_t
mndGetQnodeMeta
(
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
;
...
@@ -431,8 +431,8 @@ static int32_t mndGetQnodeMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *
...
@@ -431,8 +431,8 @@ static int32_t mndGetQnodeMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *
return
0
;
return
0
;
}
}
static
int32_t
mndRetrieveQnodes
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
static
int32_t
mndRetrieveQnodes
(
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/mndShow.c
浏览文件 @
96f2aea2
...
@@ -18,12 +18,12 @@
...
@@ -18,12 +18,12 @@
#define SHOW_STEP_SIZE 100
#define SHOW_STEP_SIZE 100
static
SShowObj
*
mndCreateShowObj
(
SMnode
*
pMnode
,
SShow
Msg
*
pMsg
);
static
SShowObj
*
mndCreateShowObj
(
SMnode
*
pMnode
,
SShow
Req
*
pReq
);
static
void
mndFreeShowObj
(
SShowObj
*
pShow
);
static
void
mndFreeShowObj
(
SShowObj
*
pShow
);
static
SShowObj
*
mndAcquireShowObj
(
SMnode
*
pMnode
,
int64_t
showId
);
static
SShowObj
*
mndAcquireShowObj
(
SMnode
*
pMnode
,
int64_t
showId
);
static
void
mndReleaseShowObj
(
SShowObj
*
pShow
,
bool
forceRemove
);
static
void
mndReleaseShowObj
(
SShowObj
*
pShow
,
bool
forceRemove
);
static
int32_t
mndProcessShow
Msg
(
SMnodeMsg
*
pMnodeMsg
);
static
int32_t
mndProcessShow
Req
(
SMnodeMsg
*
pReq
);
static
int32_t
mndProcessRetrieve
Msg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessRetrieve
Req
(
SMnodeMsg
*
pReq
);
static
bool
mndCheckRetrieveFinished
(
SShowObj
*
pShow
);
static
bool
mndCheckRetrieveFinished
(
SShowObj
*
pShow
);
int32_t
mndInitShow
(
SMnode
*
pMnode
)
{
int32_t
mndInitShow
(
SMnode
*
pMnode
)
{
...
@@ -36,8 +36,8 @@ int32_t mndInitShow(SMnode *pMnode) {
...
@@ -36,8 +36,8 @@ int32_t mndInitShow(SMnode *pMnode) {
return
-
1
;
return
-
1
;
}
}
mndSetMsgHandle
(
pMnode
,
TDMT_MND_SHOW
,
mndProcessShow
Msg
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_SHOW
,
mndProcessShow
Req
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_SHOW_RETRIEVE
,
mndProcessRetrieve
Msg
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_SHOW_RETRIEVE
,
mndProcessRetrieve
Req
);
return
0
;
return
0
;
}
}
...
@@ -49,20 +49,20 @@ void mndCleanupShow(SMnode *pMnode) {
...
@@ -49,20 +49,20 @@ void mndCleanupShow(SMnode *pMnode) {
}
}
}
}
static
SShowObj
*
mndCreateShowObj
(
SMnode
*
pMnode
,
SShow
Msg
*
pMsg
)
{
static
SShowObj
*
mndCreateShowObj
(
SMnode
*
pMnode
,
SShow
Req
*
pReq
)
{
SShowMgmt
*
pMgmt
=
&
pMnode
->
showMgmt
;
SShowMgmt
*
pMgmt
=
&
pMnode
->
showMgmt
;
int64_t
showId
=
atomic_add_fetch_64
(
&
pMgmt
->
showId
,
1
);
int64_t
showId
=
atomic_add_fetch_64
(
&
pMgmt
->
showId
,
1
);
if
(
showId
==
0
)
atomic_add_fetch_64
(
&
pMgmt
->
showId
,
1
);
if
(
showId
==
0
)
atomic_add_fetch_64
(
&
pMgmt
->
showId
,
1
);
int32_t
size
=
sizeof
(
SShowObj
)
+
p
Msg
->
payloadLen
;
int32_t
size
=
sizeof
(
SShowObj
)
+
p
Req
->
payloadLen
;
SShowObj
showObj
=
{
0
};
SShowObj
showObj
=
{
0
};
showObj
.
id
=
showId
;
showObj
.
id
=
showId
;
showObj
.
pMnode
=
pMnode
;
showObj
.
pMnode
=
pMnode
;
showObj
.
type
=
p
Msg
->
type
;
showObj
.
type
=
p
Req
->
type
;
showObj
.
payloadLen
=
p
Msg
->
payloadLen
;
showObj
.
payloadLen
=
p
Req
->
payloadLen
;
memcpy
(
showObj
.
db
,
p
Msg
->
db
,
TSDB_DB_FNAME_LEN
);
memcpy
(
showObj
.
db
,
p
Req
->
db
,
TSDB_DB_FNAME_LEN
);
memcpy
(
showObj
.
payload
,
p
Msg
->
payload
,
pMsg
->
payloadLen
);
memcpy
(
showObj
.
payload
,
p
Req
->
payload
,
pReq
->
payloadLen
);
int32_t
keepTime
=
pMnode
->
cfg
.
shellActivityTimer
*
6
*
1000
;
int32_t
keepTime
=
pMnode
->
cfg
.
shellActivityTimer
*
6
*
1000
;
SShowObj
*
pShow
=
taosCachePut
(
pMgmt
->
cache
,
&
showId
,
sizeof
(
int64_t
),
&
showObj
,
size
,
keepTime
);
SShowObj
*
pShow
=
taosCachePut
(
pMgmt
->
cache
,
&
showId
,
sizeof
(
int64_t
),
&
showObj
,
size
,
keepTime
);
...
@@ -115,12 +115,12 @@ static void mndReleaseShowObj(SShowObj *pShow, bool forceRemove) {
...
@@ -115,12 +115,12 @@ static void mndReleaseShowObj(SShowObj *pShow, bool forceRemove) {
taosCacheRelease
(
pMgmt
->
cache
,
(
void
**
)(
&
pShow
),
forceRemove
);
taosCacheRelease
(
pMgmt
->
cache
,
(
void
**
)(
&
pShow
),
forceRemove
);
}
}
static
int32_t
mndProcessShow
Msg
(
SMnodeMsg
*
pMnodeMsg
)
{
static
int32_t
mndProcessShow
Req
(
SMnodeMsg
*
pReq
)
{
SMnode
*
pMnode
=
p
MnodeMsg
->
pMnode
;
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SShowMgmt
*
pMgmt
=
&
pMnode
->
showMgmt
;
SShowMgmt
*
pMgmt
=
&
pMnode
->
showMgmt
;
SShow
Msg
*
pMsg
=
pMnodeMsg
->
rpcMsg
.
pCont
;
SShow
Req
*
pShowReq
=
pReq
->
rpcMsg
.
pCont
;
int8_t
type
=
p
Msg
->
type
;
int8_t
type
=
p
ShowReq
->
type
;
int16_t
payloadLen
=
htonl
(
p
Msg
->
payloadLen
);
int16_t
payloadLen
=
htonl
(
p
ShowReq
->
payloadLen
);
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
;
...
@@ -135,7 +135,7 @@ static int32_t mndProcessShowMsg(SMnodeMsg *pMnodeMsg) {
...
@@ -135,7 +135,7 @@ static int32_t mndProcessShowMsg(SMnodeMsg *pMnodeMsg) {
return
-
1
;
return
-
1
;
}
}
SShowObj
*
pShow
=
mndCreateShowObj
(
pMnode
,
p
Msg
);
SShowObj
*
pShow
=
mndCreateShowObj
(
pMnode
,
p
ShowReq
);
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 msg:%s since %s"
,
mndShowStr
(
type
),
terrstr
());
return
-
1
;
return
-
1
;
...
@@ -151,13 +151,13 @@ static int32_t mndProcessShowMsg(SMnodeMsg *pMnodeMsg) {
...
@@ -151,13 +151,13 @@ static int32_t mndProcessShowMsg(SMnodeMsg *pMnodeMsg) {
return
-
1
;
return
-
1
;
}
}
int32_t
code
=
(
*
metaFp
)(
p
MnodeMsg
,
pShow
,
&
pRsp
->
tableMeta
);
int32_t
code
=
(
*
metaFp
)(
p
Req
,
pShow
,
&
pRsp
->
tableMeta
);
mDebug
(
"show:0x%"
PRIx64
", get meta finished, numOfRows:%d cols:%d type:%s, result:%s"
,
pShow
->
id
,
pShow
->
numOfRows
,
mDebug
(
"show:0x%"
PRIx64
", get meta finished, numOfRows:%d cols:%d type:%s, result:%s"
,
pShow
->
id
,
pShow
->
numOfRows
,
pShow
->
numOfColumns
,
mndShowStr
(
type
),
tstrerror
(
code
));
pShow
->
numOfColumns
,
mndShowStr
(
type
),
tstrerror
(
code
));
if
(
code
==
TSDB_CODE_SUCCESS
)
{
if
(
code
==
TSDB_CODE_SUCCESS
)
{
p
MnodeMsg
->
contLen
=
sizeof
(
SShowRsp
)
+
sizeof
(
SSchema
)
*
pShow
->
numOfColumns
;
p
Req
->
contLen
=
sizeof
(
SShowRsp
)
+
sizeof
(
SSchema
)
*
pShow
->
numOfColumns
;
p
MnodeMsg
->
pCont
=
pRsp
;
p
Req
->
pCont
=
pRsp
;
pRsp
->
showId
=
htobe64
(
pShow
->
id
);
pRsp
->
showId
=
htobe64
(
pShow
->
id
);
mndReleaseShowObj
(
pShow
,
false
);
mndReleaseShowObj
(
pShow
,
false
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -168,14 +168,14 @@ static int32_t mndProcessShowMsg(SMnodeMsg *pMnodeMsg) {
...
@@ -168,14 +168,14 @@ static int32_t mndProcessShowMsg(SMnodeMsg *pMnodeMsg) {
}
}
}
}
static
int32_t
mndProcessRetrieve
Msg
(
SMnodeMsg
*
pMnodeMsg
)
{
static
int32_t
mndProcessRetrieve
Req
(
SMnodeMsg
*
pReq
)
{
SMnode
*
pMnode
=
p
MnodeMsg
->
pMnode
;
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SShowMgmt
*
pMgmt
=
&
pMnode
->
showMgmt
;
SShowMgmt
*
pMgmt
=
&
pMnode
->
showMgmt
;
int32_t
rowsToRead
=
0
;
int32_t
rowsToRead
=
0
;
int32_t
size
=
0
;
int32_t
size
=
0
;
int32_t
rowsRead
=
0
;
int32_t
rowsRead
=
0
;
SRetrieveTable
Msg
*
pRetrieve
=
pMnodeMsg
->
rpcMsg
.
pCont
;
SRetrieveTable
Req
*
pRetrieve
=
pReq
->
rpcMsg
.
pCont
;
int64_t
showId
=
htobe64
(
pRetrieve
->
showId
);
int64_t
showId
=
htobe64
(
pRetrieve
->
showId
);
SShowObj
*
pShow
=
mndAcquireShowObj
(
pMnode
,
showId
);
SShowObj
*
pShow
=
mndAcquireShowObj
(
pMnode
,
showId
);
...
@@ -227,7 +227,7 @@ static int32_t mndProcessRetrieveMsg(SMnodeMsg *pMnodeMsg) {
...
@@ -227,7 +227,7 @@ static int32_t mndProcessRetrieveMsg(SMnodeMsg *pMnodeMsg) {
// if free flag is set, client wants to clean the resources
// if free flag is set, client wants to clean the resources
if
((
pRetrieve
->
free
&
TSDB_QUERY_TYPE_FREE_RESOURCE
)
!=
TSDB_QUERY_TYPE_FREE_RESOURCE
)
{
if
((
pRetrieve
->
free
&
TSDB_QUERY_TYPE_FREE_RESOURCE
)
!=
TSDB_QUERY_TYPE_FREE_RESOURCE
)
{
rowsRead
=
(
*
retrieveFp
)(
p
MnodeMsg
,
pShow
,
pRsp
->
data
,
rowsToRead
);
rowsRead
=
(
*
retrieveFp
)(
p
Req
,
pShow
,
pRsp
->
data
,
rowsToRead
);
}
}
mDebug
(
"show:0x%"
PRIx64
", stop retrieve data, rowsRead:%d rowsToRead:%d"
,
pShow
->
id
,
rowsRead
,
rowsToRead
);
mDebug
(
"show:0x%"
PRIx64
", stop retrieve data, rowsRead:%d rowsToRead:%d"
,
pShow
->
id
,
rowsRead
,
rowsToRead
);
...
@@ -235,8 +235,8 @@ static int32_t mndProcessRetrieveMsg(SMnodeMsg *pMnodeMsg) {
...
@@ -235,8 +235,8 @@ static int32_t mndProcessRetrieveMsg(SMnodeMsg *pMnodeMsg) {
pRsp
->
numOfRows
=
htonl
(
rowsRead
);
pRsp
->
numOfRows
=
htonl
(
rowsRead
);
pRsp
->
precision
=
TSDB_TIME_PRECISION_MILLI
;
// millisecond time precision
pRsp
->
precision
=
TSDB_TIME_PRECISION_MILLI
;
// millisecond time precision
p
MnodeMsg
->
pCont
=
pRsp
;
p
Req
->
pCont
=
pRsp
;
p
MnodeMsg
->
contLen
=
size
;
p
Req
->
contLen
=
size
;
if
(
rowsRead
==
0
||
rowsToRead
==
0
||
(
rowsRead
==
rowsToRead
&&
pShow
->
numOfRows
==
pShow
->
numOfReads
))
{
if
(
rowsRead
==
0
||
rowsToRead
==
0
||
(
rowsRead
==
rowsToRead
&&
pShow
->
numOfRows
==
pShow
->
numOfReads
))
{
pRsp
->
completed
=
1
;
pRsp
->
completed
=
1
;
...
...
source/dnode/mnode/impl/src/mndSnode.c
浏览文件 @
96f2aea2
...
@@ -27,12 +27,12 @@ static SSdbRow *mndSnodeActionDecode(SSdbRaw *pRaw);
...
@@ -27,12 +27,12 @@ static SSdbRow *mndSnodeActionDecode(SSdbRaw *pRaw);
static
int32_t
mndSnodeActionInsert
(
SSdb
*
pSdb
,
SSnodeObj
*
pObj
);
static
int32_t
mndSnodeActionInsert
(
SSdb
*
pSdb
,
SSnodeObj
*
pObj
);
static
int32_t
mndSnodeActionDelete
(
SSdb
*
pSdb
,
SSnodeObj
*
pObj
);
static
int32_t
mndSnodeActionDelete
(
SSdb
*
pSdb
,
SSnodeObj
*
pObj
);
static
int32_t
mndSnodeActionUpdate
(
SSdb
*
pSdb
,
SSnodeObj
*
pOld
,
SSnodeObj
*
pNew
);
static
int32_t
mndSnodeActionUpdate
(
SSdb
*
pSdb
,
SSnodeObj
*
pOld
,
SSnodeObj
*
pNew
);
static
int32_t
mndProcessCreateSnodeReq
(
SMnodeMsg
*
p
Msg
);
static
int32_t
mndProcessCreateSnodeReq
(
SMnodeMsg
*
p
Req
);
static
int32_t
mndProcessDropSnodeReq
(
SMnodeMsg
*
p
Msg
);
static
int32_t
mndProcessDropSnodeReq
(
SMnodeMsg
*
p
Req
);
static
int32_t
mndProcessCreateSnodeRsp
(
SMnodeMsg
*
p
Msg
);
static
int32_t
mndProcessCreateSnodeRsp
(
SMnodeMsg
*
p
Rsp
);
static
int32_t
mndProcessDropSnodeRsp
(
SMnodeMsg
*
p
Msg
);
static
int32_t
mndProcessDropSnodeRsp
(
SMnodeMsg
*
p
Rsp
);
static
int32_t
mndGetSnodeMeta
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
);
static
int32_t
mndGetSnodeMeta
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
);
static
int32_t
mndRetrieveSnodes
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
int32_t
mndRetrieveSnodes
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
void
mndCancelGetNextSnode
(
SMnode
*
pMnode
,
void
*
pIter
);
static
void
mndCancelGetNextSnode
(
SMnode
*
pMnode
,
void
*
pIter
);
int32_t
mndInitSnode
(
SMnode
*
pMnode
)
{
int32_t
mndInitSnode
(
SMnode
*
pMnode
)
{
...
@@ -185,22 +185,22 @@ static int32_t mndSetCreateSnodeCommitLogs(STrans *pTrans, SSnodeObj *pObj) {
...
@@ -185,22 +185,22 @@ static int32_t mndSetCreateSnodeCommitLogs(STrans *pTrans, SSnodeObj *pObj) {
}
}
static
int32_t
mndSetCreateSnodeRedoActions
(
STrans
*
pTrans
,
SDnodeObj
*
pDnode
,
SSnodeObj
*
pObj
)
{
static
int32_t
mndSetCreateSnodeRedoActions
(
STrans
*
pTrans
,
SDnodeObj
*
pDnode
,
SSnodeObj
*
pObj
)
{
SDCreateSnodeReq
*
p
Msg
=
malloc
(
sizeof
(
SDCreateSnodeReq
));
SDCreateSnodeReq
*
p
Req
=
malloc
(
sizeof
(
SDCreateSnodeReq
));
if
(
p
Msg
==
NULL
)
{
if
(
p
Req
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
}
}
p
Msg
->
dnodeId
=
htonl
(
pDnode
->
id
);
p
Req
->
dnodeId
=
htonl
(
pDnode
->
id
);
STransAction
action
=
{
0
};
STransAction
action
=
{
0
};
action
.
epSet
=
mndGetDnodeEpset
(
pDnode
);
action
.
epSet
=
mndGetDnodeEpset
(
pDnode
);
action
.
pCont
=
p
Msg
;
action
.
pCont
=
p
Req
;
action
.
contLen
=
sizeof
(
SDCreateSnodeReq
);
action
.
contLen
=
sizeof
(
SDCreateSnodeReq
);
action
.
msgType
=
TDMT_DND_CREATE_SNODE
;
action
.
msgType
=
TDMT_DND_CREATE_SNODE
;
action
.
acceptableCode
=
TSDB_CODE_DND_SNODE_ALREADY_DEPLOYED
;
action
.
acceptableCode
=
TSDB_CODE_DND_SNODE_ALREADY_DEPLOYED
;
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
free
(
p
Msg
);
free
(
p
Req
);
return
-
1
;
return
-
1
;
}
}
...
@@ -208,29 +208,29 @@ static int32_t mndSetCreateSnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, S
...
@@ -208,29 +208,29 @@ static int32_t mndSetCreateSnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, S
}
}
static
int32_t
mndSetCreateSnodeUndoActions
(
STrans
*
pTrans
,
SDnodeObj
*
pDnode
,
SSnodeObj
*
pObj
)
{
static
int32_t
mndSetCreateSnodeUndoActions
(
STrans
*
pTrans
,
SDnodeObj
*
pDnode
,
SSnodeObj
*
pObj
)
{
SDDropSnodeReq
*
p
Msg
=
malloc
(
sizeof
(
SDDropSnodeReq
));
SDDropSnodeReq
*
p
Req
=
malloc
(
sizeof
(
SDDropSnodeReq
));
if
(
p
Msg
==
NULL
)
{
if
(
p
Req
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
}
}
p
Msg
->
dnodeId
=
htonl
(
pDnode
->
id
);
p
Req
->
dnodeId
=
htonl
(
pDnode
->
id
);
STransAction
action
=
{
0
};
STransAction
action
=
{
0
};
action
.
epSet
=
mndGetDnodeEpset
(
pDnode
);
action
.
epSet
=
mndGetDnodeEpset
(
pDnode
);
action
.
pCont
=
p
Msg
;
action
.
pCont
=
p
Req
;
action
.
contLen
=
sizeof
(
SDDropSnodeReq
);
action
.
contLen
=
sizeof
(
SDDropSnodeReq
);
action
.
msgType
=
TDMT_DND_DROP_SNODE
;
action
.
msgType
=
TDMT_DND_DROP_SNODE
;
action
.
acceptableCode
=
TSDB_CODE_DND_SNODE_NOT_DEPLOYED
;
action
.
acceptableCode
=
TSDB_CODE_DND_SNODE_NOT_DEPLOYED
;
if
(
mndTransAppendUndoAction
(
pTrans
,
&
action
)
!=
0
)
{
if
(
mndTransAppendUndoAction
(
pTrans
,
&
action
)
!=
0
)
{
free
(
p
Msg
);
free
(
p
Req
);
return
-
1
;
return
-
1
;
}
}
return
0
;
return
0
;
}
}
static
int32_t
mndCreateSnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
p
Msg
,
SDnodeObj
*
pDnode
,
SMCreateSnodeReq
*
pCreate
)
{
static
int32_t
mndCreateSnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
p
Req
,
SDnodeObj
*
pDnode
,
SMCreateSnodeReq
*
pCreate
)
{
int32_t
code
=
-
1
;
int32_t
code
=
-
1
;
SSnodeObj
snodeObj
=
{
0
};
SSnodeObj
snodeObj
=
{
0
};
...
@@ -238,7 +238,7 @@ static int32_t mndCreateSnode(SMnode *pMnode, SMnodeMsg *pMsg, SDnodeObj *pDnode
...
@@ -238,7 +238,7 @@ static int32_t mndCreateSnode(SMnode *pMnode, SMnodeMsg *pMsg, SDnodeObj *pDnode
snodeObj
.
createdTime
=
taosGetTimestampMs
();
snodeObj
.
createdTime
=
taosGetTimestampMs
();
snodeObj
.
updateTime
=
snodeObj
.
createdTime
;
snodeObj
.
updateTime
=
snodeObj
.
createdTime
;
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
&
p
Msg
->
rpcMsg
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
&
p
Req
->
rpcMsg
);
if
(
pTrans
==
NULL
)
goto
CREATE_SNODE_OVER
;
if
(
pTrans
==
NULL
)
goto
CREATE_SNODE_OVER
;
mDebug
(
"trans:%d, used to create snode:%d"
,
pTrans
->
id
,
pCreate
->
dnodeId
);
mDebug
(
"trans:%d, used to create snode:%d"
,
pTrans
->
id
,
pCreate
->
dnodeId
);
...
@@ -257,9 +257,9 @@ CREATE_SNODE_OVER:
...
@@ -257,9 +257,9 @@ CREATE_SNODE_OVER:
return
code
;
return
code
;
}
}
static
int32_t
mndProcessCreateSnodeReq
(
SMnodeMsg
*
p
Msg
)
{
static
int32_t
mndProcessCreateSnodeReq
(
SMnodeMsg
*
p
Req
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SMCreateSnodeReq
*
pCreate
=
p
Msg
->
rpcMsg
.
pCont
;
SMCreateSnodeReq
*
pCreate
=
p
Req
->
rpcMsg
.
pCont
;
pCreate
->
dnodeId
=
htonl
(
pCreate
->
dnodeId
);
pCreate
->
dnodeId
=
htonl
(
pCreate
->
dnodeId
);
...
@@ -283,7 +283,7 @@ static int32_t mndProcessCreateSnodeReq(SMnodeMsg *pMsg) {
...
@@ -283,7 +283,7 @@ static int32_t mndProcessCreateSnodeReq(SMnodeMsg *pMsg) {
return
-
1
;
return
-
1
;
}
}
int32_t
code
=
mndCreateSnode
(
pMnode
,
p
Msg
,
pDnode
,
pCreate
);
int32_t
code
=
mndCreateSnode
(
pMnode
,
p
Req
,
pDnode
,
pCreate
);
mndReleaseDnode
(
pMnode
,
pDnode
);
mndReleaseDnode
(
pMnode
,
pDnode
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
...
@@ -311,32 +311,32 @@ static int32_t mndSetDropSnodeCommitLogs(STrans *pTrans, SSnodeObj *pObj) {
...
@@ -311,32 +311,32 @@ static int32_t mndSetDropSnodeCommitLogs(STrans *pTrans, SSnodeObj *pObj) {
}
}
static
int32_t
mndSetDropSnodeRedoActions
(
STrans
*
pTrans
,
SDnodeObj
*
pDnode
,
SSnodeObj
*
pObj
)
{
static
int32_t
mndSetDropSnodeRedoActions
(
STrans
*
pTrans
,
SDnodeObj
*
pDnode
,
SSnodeObj
*
pObj
)
{
SDDropSnodeReq
*
p
Msg
=
malloc
(
sizeof
(
SDDropSnodeReq
));
SDDropSnodeReq
*
p
Req
=
malloc
(
sizeof
(
SDDropSnodeReq
));
if
(
p
Msg
==
NULL
)
{
if
(
p
Req
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
}
}
p
Msg
->
dnodeId
=
htonl
(
pDnode
->
id
);
p
Req
->
dnodeId
=
htonl
(
pDnode
->
id
);
STransAction
action
=
{
0
};
STransAction
action
=
{
0
};
action
.
epSet
=
mndGetDnodeEpset
(
pDnode
);
action
.
epSet
=
mndGetDnodeEpset
(
pDnode
);
action
.
pCont
=
p
Msg
;
action
.
pCont
=
p
Req
;
action
.
contLen
=
sizeof
(
SDDropSnodeReq
);
action
.
contLen
=
sizeof
(
SDDropSnodeReq
);
action
.
msgType
=
TDMT_DND_DROP_SNODE
;
action
.
msgType
=
TDMT_DND_DROP_SNODE
;
action
.
acceptableCode
=
TSDB_CODE_DND_SNODE_NOT_DEPLOYED
;
action
.
acceptableCode
=
TSDB_CODE_DND_SNODE_NOT_DEPLOYED
;
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
free
(
p
Msg
);
free
(
p
Req
);
return
-
1
;
return
-
1
;
}
}
return
0
;
return
0
;
}
}
static
int32_t
mndDropSnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
p
Msg
,
SSnodeObj
*
pObj
)
{
static
int32_t
mndDropSnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
p
Req
,
SSnodeObj
*
pObj
)
{
int32_t
code
=
-
1
;
int32_t
code
=
-
1
;
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
&
p
Msg
->
rpcMsg
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
&
p
Req
->
rpcMsg
);
if
(
pTrans
==
NULL
)
goto
DROP_SNODE_OVER
;
if
(
pTrans
==
NULL
)
goto
DROP_SNODE_OVER
;
mDebug
(
"trans:%d, used to drop snode:%d"
,
pTrans
->
id
,
pObj
->
id
);
mDebug
(
"trans:%d, used to drop snode:%d"
,
pTrans
->
id
,
pObj
->
id
);
...
@@ -353,9 +353,9 @@ DROP_SNODE_OVER:
...
@@ -353,9 +353,9 @@ DROP_SNODE_OVER:
return
code
;
return
code
;
}
}
static
int32_t
mndProcessDropSnodeReq
(
SMnodeMsg
*
p
Msg
)
{
static
int32_t
mndProcessDropSnodeReq
(
SMnodeMsg
*
p
Req
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SMDropSnodeReq
*
pDrop
=
p
Msg
->
rpcMsg
.
pCont
;
SMDropSnodeReq
*
pDrop
=
p
Req
->
rpcMsg
.
pCont
;
pDrop
->
dnodeId
=
htonl
(
pDrop
->
dnodeId
);
pDrop
->
dnodeId
=
htonl
(
pDrop
->
dnodeId
);
mDebug
(
"snode:%d, start to drop"
,
pDrop
->
dnodeId
);
mDebug
(
"snode:%d, start to drop"
,
pDrop
->
dnodeId
);
...
@@ -372,7 +372,7 @@ static int32_t mndProcessDropSnodeReq(SMnodeMsg *pMsg) {
...
@@ -372,7 +372,7 @@ static int32_t mndProcessDropSnodeReq(SMnodeMsg *pMsg) {
return
-
1
;
return
-
1
;
}
}
int32_t
code
=
mndDropSnode
(
pMnode
,
p
Msg
,
pObj
);
int32_t
code
=
mndDropSnode
(
pMnode
,
p
Req
,
pObj
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
sdbRelease
(
pMnode
->
pSdb
,
pObj
);
sdbRelease
(
pMnode
->
pSdb
,
pObj
);
mError
(
"snode:%d, failed to drop since %s"
,
pMnode
->
dnodeId
,
terrstr
());
mError
(
"snode:%d, failed to drop since %s"
,
pMnode
->
dnodeId
,
terrstr
());
...
@@ -383,18 +383,18 @@ static int32_t mndProcessDropSnodeReq(SMnodeMsg *pMsg) {
...
@@ -383,18 +383,18 @@ static int32_t mndProcessDropSnodeReq(SMnodeMsg *pMsg) {
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
}
static
int32_t
mndProcessCreateSnodeRsp
(
SMnodeMsg
*
p
Msg
)
{
static
int32_t
mndProcessCreateSnodeRsp
(
SMnodeMsg
*
p
Rsp
)
{
mndTransProcessRsp
(
p
Msg
);
mndTransProcessRsp
(
p
Rsp
);
return
0
;
return
0
;
}
}
static
int32_t
mndProcessDropSnodeRsp
(
SMnodeMsg
*
p
Msg
)
{
static
int32_t
mndProcessDropSnodeRsp
(
SMnodeMsg
*
p
Rsp
)
{
mndTransProcessRsp
(
p
Msg
);
mndTransProcessRsp
(
p
Rsp
);
return
0
;
return
0
;
}
}
static
int32_t
mndGetSnodeMeta
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
)
{
static
int32_t
mndGetSnodeMeta
(
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
;
...
@@ -433,8 +433,8 @@ static int32_t mndGetSnodeMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *
...
@@ -433,8 +433,8 @@ static int32_t mndGetSnodeMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *
return
0
;
return
0
;
}
}
static
int32_t
mndRetrieveSnodes
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
static
int32_t
mndRetrieveSnodes
(
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/mndSync.c
浏览文件 @
96f2aea2
...
@@ -54,7 +54,7 @@ static int32_t mndRestoreWal(SMnode *pMnode) {
...
@@ -54,7 +54,7 @@ static int32_t mndRestoreWal(SMnode *pMnode) {
int64_t
first
=
walGetFirstVer
(
pWal
);
int64_t
first
=
walGetFirstVer
(
pWal
);
int64_t
last
=
walGetLastVer
(
pWal
);
int64_t
last
=
walGetLastVer
(
pWal
);
mDebug
(
"
restore sdb wal start
, sdb ver:%"
PRId64
", wal first:%"
PRId64
" last:%"
PRId64
,
lastSdbVer
,
first
,
last
);
mDebug
(
"
start to restore sdb wal
, sdb ver:%"
PRId64
", wal first:%"
PRId64
" last:%"
PRId64
,
lastSdbVer
,
first
,
last
);
first
=
MAX
(
lastSdbVer
+
1
,
first
);
first
=
MAX
(
lastSdbVer
+
1
,
first
);
for
(
int64_t
ver
=
first
;
ver
>=
0
&&
ver
<=
last
;
++
ver
)
{
for
(
int64_t
ver
=
first
;
ver
>=
0
&&
ver
<=
last
;
++
ver
)
{
...
@@ -71,6 +71,7 @@ static int32_t mndRestoreWal(SMnode *pMnode) {
...
@@ -71,6 +71,7 @@ static int32_t mndRestoreWal(SMnode *pMnode) {
goto
WAL_RESTORE_OVER
;
goto
WAL_RESTORE_OVER
;
}
}
mTrace
(
"wal:%"
PRId64
", will be restored, content:%p"
,
ver
,
pHead
->
head
.
body
);
if
(
sdbWriteNotFree
(
pSdb
,
(
void
*
)
pHead
->
head
.
body
)
<
0
)
{
if
(
sdbWriteNotFree
(
pSdb
,
(
void
*
)
pHead
->
head
.
body
)
<
0
)
{
mError
(
"failed to read wal from sdb since %s, ver:%"
PRId64
,
terrstr
(),
ver
);
mError
(
"failed to read wal from sdb since %s, ver:%"
PRId64
,
terrstr
(),
ver
);
goto
WAL_RESTORE_OVER
;
goto
WAL_RESTORE_OVER
;
...
...
source/dnode/mnode/impl/src/mndTopic.c
浏览文件 @
96f2aea2
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
*/
*/
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "mndTopic.h"
#include "mndDb.h"
#include "mndDb.h"
#include "mndDnode.h"
#include "mndDnode.h"
#include "mndMnode.h"
#include "mndMnode.h"
...
@@ -27,18 +28,16 @@
...
@@ -27,18 +28,16 @@
#define MND_TOPIC_VER_NUMBER 1
#define MND_TOPIC_VER_NUMBER 1
#define MND_TOPIC_RESERVE_SIZE 64
#define MND_TOPIC_RESERVE_SIZE 64
static
SSdbRaw
*
mndTopicActionEncode
(
STopicObj
*
pTopic
);
static
int32_t
mndTopicActionInsert
(
SSdb
*
pSdb
,
SMqTopicObj
*
pTopic
);
static
SSdbRow
*
mndTopicActionDecode
(
SSdbRaw
*
pRaw
);
static
int32_t
mndTopicActionDelete
(
SSdb
*
pSdb
,
SMqTopicObj
*
pTopic
);
static
int32_t
mndTopicActionInsert
(
SSdb
*
pSdb
,
STopicObj
*
pTopic
);
static
int32_t
mndTopicActionUpdate
(
SSdb
*
pSdb
,
SMqTopicObj
*
pTopic
,
SMqTopicObj
*
pNewTopic
);
static
int32_t
mndTopicActionDelete
(
SSdb
*
pSdb
,
STopicObj
*
pTopic
);
static
int32_t
mndProcessCreateTopicMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndTopicActionUpdate
(
SSdb
*
pSdb
,
STopicObj
*
pTopic
,
STopicObj
*
pNewTopic
);
static
int32_t
mndProcessDropTopicMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessCreateTopicMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessDropTopicInRsp
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessDropTopicMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessTopicMetaMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessDropTopicInRsp
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndGetTopicMeta
(
SMnodeMsg
*
pMsg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
);
static
int32_t
mndProcessTopicMetaMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndRetrieveTopic
(
SMnodeMsg
*
pMsg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
int32_t
mndGetTopicMeta
(
SMnodeMsg
*
pMsg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
);
static
void
mndCancelGetNextTopic
(
SMnode
*
pMnode
,
void
*
pIter
);
static
int32_t
mndRetrieveTopic
(
SMnodeMsg
*
pMsg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
void
mndCancelGetNextTopic
(
SMnode
*
pMnode
,
void
*
pIter
);
int32_t
mndInitTopic
(
SMnode
*
pMnode
)
{
int32_t
mndInitTopic
(
SMnode
*
pMnode
)
{
SSdbTable
table
=
{.
sdbType
=
SDB_TOPIC
,
SSdbTable
table
=
{.
sdbType
=
SDB_TOPIC
,
...
@@ -58,45 +57,31 @@ int32_t mndInitTopic(SMnode *pMnode) {
...
@@ -58,45 +57,31 @@ int32_t mndInitTopic(SMnode *pMnode) {
void
mndCleanupTopic
(
SMnode
*
pMnode
)
{}
void
mndCleanupTopic
(
SMnode
*
pMnode
)
{}
static
SSdbRaw
*
mndTopicActionEncode
(
STopicObj
*
pTopic
)
{
SSdbRaw
*
mndTopicActionEncode
(
SMqTopicObj
*
pTopic
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
int32_t
size
=
sizeof
(
SMqTopicObj
)
+
MND_TOPIC_RESERVE_SIZE
;
int32_t
size
=
sizeof
(
STopicObj
)
+
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
TOPIC_ENCODE_OVER
;
if
(
pRaw
==
NULL
)
goto
WTF
;
int32_t
dataPos
=
0
;
int32_t
dataPos
=
0
;
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pTopic
->
name
,
TSDB_TABLE_FNAME_LEN
,
TOPIC_ENCODE_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pTopic
->
name
,
TSDB_TABLE_FNAME_LEN
,
WTF
);
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pTopic
->
db
,
TSDB_DB_FNAME_LEN
,
TOPIC_ENCODE_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pTopic
->
db
,
TSDB_DB_FNAME_LEN
,
WTF
);
SDB_SET_INT64
(
pRaw
,
dataPos
,
pTopic
->
createTime
,
TOPIC_ENCODE_OVER
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pTopic
->
createTime
,
WTF
);
SDB_SET_INT64
(
pRaw
,
dataPos
,
pTopic
->
updateTime
,
TOPIC_ENCODE_OVER
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pTopic
->
updateTime
,
WTF
);
SDB_SET_INT64
(
pRaw
,
dataPos
,
pTopic
->
uid
,
TOPIC_ENCODE_OVER
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pTopic
->
uid
,
WTF
);
SDB_SET_INT64
(
pRaw
,
dataPos
,
pTopic
->
dbUid
,
TOPIC_ENCODE_OVER
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pTopic
->
dbUid
,
WTF
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
pTopic
->
version
,
TOPIC_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pTopic
->
version
,
WTF
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
pTopic
->
execLen
,
TOPIC_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pTopic
->
sqlLen
,
WTF
);
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pTopic
->
executor
,
pTopic
->
execLen
,
TOPIC_ENCODE_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pTopic
->
sql
,
pTopic
->
sqlLen
,
WTF
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
pTopic
->
sqlLen
,
TOPIC_ENCODE_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pTopic
->
sql
,
pTopic
->
sqlLen
,
TOPIC_ENCODE_OVER
)
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
MND_TOPIC_RESERVE_SIZE
,
WTF
);
SDB_SET_DATALEN
(
pRaw
,
dataPos
,
WTF
);
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
MND_TOPIC_RESERVE_SIZE
,
TOPIC_ENCODE_OVER
)
SDB_SET_DATALEN
(
pRaw
,
dataPos
,
TOPIC_ENCODE_OVER
)
WTF:
terrno
=
0
;
TOPIC_ENCODE_OVER:
if
(
terrno
!=
0
)
{
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
;
}
}
static
SSdbRow
*
mndTopicActionDecode
(
SSdbRaw
*
pRaw
)
{
SSdbRow
*
mndTopicActionDecode
(
SSdbRaw
*
pRaw
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
int8_t
sver
=
0
;
int8_t
sver
=
0
;
if
(
sdbGetRawSoftVer
(
pRaw
,
&
sver
)
!=
0
)
goto
TOPIC_DECODE_OVER
;
if
(
sdbGetRawSoftVer
(
pRaw
,
&
sver
)
!=
0
)
goto
TOPIC_DECODE_OVER
;
...
@@ -105,25 +90,28 @@ static SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) {
...
@@ -105,25 +90,28 @@ static SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) {
goto
TOPIC_DECODE_OVER
;
goto
TOPIC_DECODE_OVER
;
}
}
int32_t
size
=
sizeof
(
STopicObj
)
+
TSDB_MAX_COLUMNS
*
sizeof
(
SSchema
);
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
;
STopicObj
*
pTopic
=
sdbGetRowObj
(
pRow
);
S
Mq
TopicObj
*
pTopic
=
sdbGetRowObj
(
pRow
);
if
(
pTopic
==
NULL
)
goto
TOPIC_DECODE_OVER
;
if
(
pTopic
==
NULL
)
goto
TOPIC_DECODE_OVER
;
int32_t
len
;
int32_t
dataPos
=
0
;
int32_t
dataPos
=
0
;
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pTopic
->
name
,
TSDB_TABLE_FNAME_LEN
,
TOPIC_DECODE_OVER
)
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pTopic
->
name
,
TSDB_TABLE_FNAME_LEN
,
TOPIC_DECODE_OVER
);
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pTopic
->
db
,
TSDB_DB_FNAME_LEN
,
TOPIC_DECODE_OVER
)
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pTopic
->
db
,
TSDB_DB_FNAME_LEN
,
TOPIC_DECODE_OVER
);
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pTopic
->
createTime
,
TOPIC_DECODE_OVER
)
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pTopic
->
createTime
,
TOPIC_DECODE_OVER
);
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pTopic
->
updateTime
,
TOPIC_DECODE_OVER
)
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pTopic
->
updateTime
,
TOPIC_DECODE_OVER
);
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pTopic
->
uid
,
TOPIC_DECODE_OVER
)
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pTopic
->
uid
,
TOPIC_DECODE_OVER
);
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pTopic
->
dbUid
,
TOPIC_DECODE_OVER
)
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pTopic
->
dbUid
,
TOPIC_DECODE_OVER
);
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pTopic
->
version
,
TOPIC_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pTopic
->
version
,
TOPIC_DECODE_OVER
);
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pTopic
->
execLen
,
TOPIC_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pTopic
->
sqlLen
,
TOPIC_DECODE_OVER
);
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pTopic
->
executor
,
pTopic
->
execLen
,
TOPIC_DECODE_OVER
)
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pTopic
->
sql
,
pTopic
->
sqlLen
,
TOPIC_DECODE_OVER
);
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pTopic
->
sqlLen
,
TOPIC_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
len
,
TOPIC_DECODE_OVER
);
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pTopic
->
sql
,
pTopic
->
sqlLen
,
TOPIC_DECODE_OVER
)
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pTopic
->
logicalPlan
,
len
,
TOPIC_DECODE_OVER
);
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
len
,
TOPIC_DECODE_OVER
);
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pTopic
->
physicalPlan
,
len
,
TOPIC_DECODE_OVER
);
SDB_GET_RESERVE
(
pRaw
,
dataPos
,
MND_TOPIC_RESERVE_SIZE
,
TOPIC_DECODE_OVER
)
SDB_GET_RESERVE
(
pRaw
,
dataPos
,
MND_TOPIC_RESERVE_SIZE
,
TOPIC_DECODE_OVER
)
...
@@ -140,18 +128,18 @@ TOPIC_DECODE_OVER:
...
@@ -140,18 +128,18 @@ TOPIC_DECODE_OVER:
return
pRow
;
return
pRow
;
}
}
static
int32_t
mndTopicActionInsert
(
SSdb
*
pSdb
,
STopicObj
*
pTopic
)
{
static
int32_t
mndTopicActionInsert
(
SSdb
*
pSdb
,
S
Mq
TopicObj
*
pTopic
)
{
mTrace
(
"topic:%s, perform insert action
, row:%p"
,
pTopic
->
name
,
pTopic
);
mTrace
(
"topic:%s, perform insert action
"
,
pTopic
->
name
);
return
0
;
return
0
;
}
}
static
int32_t
mndTopicActionDelete
(
SSdb
*
pSdb
,
STopicObj
*
pTopic
)
{
static
int32_t
mndTopicActionDelete
(
SSdb
*
pSdb
,
S
Mq
TopicObj
*
pTopic
)
{
mTrace
(
"topic:%s, perform delete action
, row:%p"
,
pTopic
->
name
,
pTopic
);
mTrace
(
"topic:%s, perform delete action
"
,
pTopic
->
name
);
return
0
;
return
0
;
}
}
static
int32_t
mndTopicActionUpdate
(
SSdb
*
pSdb
,
S
TopicObj
*
pOldTopic
,
S
TopicObj
*
pNewTopic
)
{
static
int32_t
mndTopicActionUpdate
(
SSdb
*
pSdb
,
S
MqTopicObj
*
pOldTopic
,
SMq
TopicObj
*
pNewTopic
)
{
mTrace
(
"topic:%s, perform update action
, old_row:%p new_row:%p"
,
pOldTopic
->
name
,
pOldTopic
,
pNewTopic
);
mTrace
(
"topic:%s, perform update action
"
,
pOldTopic
->
name
);
atomic_exchange_32
(
&
pOldTopic
->
updateTime
,
pNewTopic
->
updateTime
);
atomic_exchange_32
(
&
pOldTopic
->
updateTime
,
pNewTopic
->
updateTime
);
atomic_exchange_32
(
&
pOldTopic
->
version
,
pNewTopic
->
version
);
atomic_exchange_32
(
&
pOldTopic
->
version
,
pNewTopic
->
version
);
...
@@ -163,16 +151,16 @@ static int32_t mndTopicActionUpdate(SSdb *pSdb, STopicObj *pOldTopic, STopicObj
...
@@ -163,16 +151,16 @@ static int32_t mndTopicActionUpdate(SSdb *pSdb, STopicObj *pOldTopic, STopicObj
return
0
;
return
0
;
}
}
STopicObj
*
mndAcquireTopic
(
SMnode
*
pMnode
,
char
*
topicName
)
{
S
Mq
TopicObj
*
mndAcquireTopic
(
SMnode
*
pMnode
,
char
*
topicName
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
STopicObj
*
pTopic
=
sdbAcquire
(
pSdb
,
SDB_TOPIC
,
topicName
);
S
Mq
TopicObj
*
pTopic
=
sdbAcquire
(
pSdb
,
SDB_TOPIC
,
topicName
);
if
(
pTopic
==
NULL
)
{
if
(
pTopic
==
NULL
)
{
terrno
=
TSDB_CODE_MND_TOPIC_NOT_EXIST
;
terrno
=
TSDB_CODE_MND_TOPIC_NOT_EXIST
;
}
}
return
pTopic
;
return
pTopic
;
}
}
void
mndReleaseTopic
(
SMnode
*
pMnode
,
STopicObj
*
pTopic
)
{
void
mndReleaseTopic
(
SMnode
*
pMnode
,
S
Mq
TopicObj
*
pTopic
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
sdbRelease
(
pSdb
,
pTopic
);
sdbRelease
(
pSdb
,
pTopic
);
}
}
...
@@ -187,7 +175,7 @@ static SDbObj *mndAcquireDbByTopic(SMnode *pMnode, char *topicName) {
...
@@ -187,7 +175,7 @@ static SDbObj *mndAcquireDbByTopic(SMnode *pMnode, char *topicName) {
return
mndAcquireDb
(
pMnode
,
db
);
return
mndAcquireDb
(
pMnode
,
db
);
}
}
static
SDDropTopicMsg
*
mndBuildDropTopicMsg
(
SMnode
*
pMnode
,
SVgObj
*
pVgroup
,
STopicObj
*
pTopic
)
{
static
SDDropTopicMsg
*
mndBuildDropTopicMsg
(
SMnode
*
pMnode
,
SVgObj
*
pVgroup
,
S
Mq
TopicObj
*
pTopic
)
{
int32_t
contLen
=
sizeof
(
SDDropTopicMsg
);
int32_t
contLen
=
sizeof
(
SDDropTopicMsg
);
SDDropTopicMsg
*
pDrop
=
calloc
(
1
,
contLen
);
SDDropTopicMsg
*
pDrop
=
calloc
(
1
,
contLen
);
...
@@ -210,7 +198,7 @@ static int32_t mndCheckCreateTopicMsg(SCMCreateTopicReq *pCreate) {
...
@@ -210,7 +198,7 @@ static int32_t mndCheckCreateTopicMsg(SCMCreateTopicReq *pCreate) {
}
}
static
int32_t
mndCreateTopic
(
SMnode
*
pMnode
,
SMnodeMsg
*
pMsg
,
SCMCreateTopicReq
*
pCreate
,
SDbObj
*
pDb
)
{
static
int32_t
mndCreateTopic
(
SMnode
*
pMnode
,
SMnodeMsg
*
pMsg
,
SCMCreateTopicReq
*
pCreate
,
SDbObj
*
pDb
)
{
STopicObj
topicObj
=
{
0
};
S
Mq
TopicObj
topicObj
=
{
0
};
tstrncpy
(
topicObj
.
name
,
pCreate
->
name
,
TSDB_TABLE_FNAME_LEN
);
tstrncpy
(
topicObj
.
name
,
pCreate
->
name
,
TSDB_TABLE_FNAME_LEN
);
tstrncpy
(
topicObj
.
db
,
pDb
->
name
,
TSDB_DB_FNAME_LEN
);
tstrncpy
(
topicObj
.
db
,
pDb
->
name
,
TSDB_DB_FNAME_LEN
);
topicObj
.
createTime
=
taosGetTimestampMs
();
topicObj
.
createTime
=
taosGetTimestampMs
();
...
@@ -222,6 +210,7 @@ static int32_t mndCreateTopic(SMnode *pMnode, SMnodeMsg *pMsg, SCMCreateTopicReq
...
@@ -222,6 +210,7 @@ static int32_t mndCreateTopic(SMnode *pMnode, SMnodeMsg *pMsg, SCMCreateTopicReq
SSdbRaw
*
pTopicRaw
=
mndTopicActionEncode
(
&
topicObj
);
SSdbRaw
*
pTopicRaw
=
mndTopicActionEncode
(
&
topicObj
);
if
(
pTopicRaw
==
NULL
)
return
-
1
;
if
(
pTopicRaw
==
NULL
)
return
-
1
;
if
(
sdbSetRawStatus
(
pTopicRaw
,
SDB_STATUS_READY
)
!=
0
)
return
-
1
;
if
(
sdbSetRawStatus
(
pTopicRaw
,
SDB_STATUS_READY
)
!=
0
)
return
-
1
;
// TODO: replace with trans to support recovery
return
sdbWrite
(
pMnode
->
pSdb
,
pTopicRaw
);
return
sdbWrite
(
pMnode
->
pSdb
,
pTopicRaw
);
}
}
...
@@ -238,7 +227,7 @@ static int32_t mndProcessCreateTopicMsg(SMnodeMsg *pMsg) {
...
@@ -238,7 +227,7 @@ static int32_t mndProcessCreateTopicMsg(SMnodeMsg *pMsg) {
return
-
1
;
return
-
1
;
}
}
STopicObj
*
pTopic
=
mndAcquireTopic
(
pMnode
,
pCreate
->
name
);
S
Mq
TopicObj
*
pTopic
=
mndAcquireTopic
(
pMnode
,
pCreate
->
name
);
if
(
pTopic
!=
NULL
)
{
if
(
pTopic
!=
NULL
)
{
sdbRelease
(
pMnode
->
pSdb
,
pTopic
);
sdbRelease
(
pMnode
->
pSdb
,
pTopic
);
if
(
pCreate
->
igExists
)
{
if
(
pCreate
->
igExists
)
{
...
@@ -270,7 +259,7 @@ static int32_t mndProcessCreateTopicMsg(SMnodeMsg *pMsg) {
...
@@ -270,7 +259,7 @@ static int32_t mndProcessCreateTopicMsg(SMnodeMsg *pMsg) {
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
}
static
int32_t
mndDropTopic
(
SMnode
*
pMnode
,
SMnodeMsg
*
pMsg
,
STopicObj
*
pTopic
)
{
return
0
;
}
static
int32_t
mndDropTopic
(
SMnode
*
pMnode
,
SMnodeMsg
*
pMsg
,
S
Mq
TopicObj
*
pTopic
)
{
return
0
;
}
static
int32_t
mndProcessDropTopicMsg
(
SMnodeMsg
*
pMsg
)
{
static
int32_t
mndProcessDropTopicMsg
(
SMnodeMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SMnode
*
pMnode
=
pMsg
->
pMnode
;
...
@@ -278,7 +267,7 @@ static int32_t mndProcessDropTopicMsg(SMnodeMsg *pMsg) {
...
@@ -278,7 +267,7 @@ static int32_t mndProcessDropTopicMsg(SMnodeMsg *pMsg) {
mDebug
(
"topic:%s, start to drop"
,
pDrop
->
name
);
mDebug
(
"topic:%s, start to drop"
,
pDrop
->
name
);
STopicObj
*
pTopic
=
mndAcquireTopic
(
pMnode
,
pDrop
->
name
);
S
Mq
TopicObj
*
pTopic
=
mndAcquireTopic
(
pMnode
,
pDrop
->
name
);
if
(
pTopic
==
NULL
)
{
if
(
pTopic
==
NULL
)
{
if
(
pDrop
->
igNotExists
)
{
if
(
pDrop
->
igNotExists
)
{
mDebug
(
"topic:%s, not exist, ignore not exist is set"
,
pDrop
->
name
);
mDebug
(
"topic:%s, not exist, ignore not exist is set"
,
pDrop
->
name
);
...
@@ -384,13 +373,11 @@ static int32_t mndGetNumOfTopics(SMnode *pMnode, char *dbName, int32_t *pNumOfTo
...
@@ -384,13 +373,11 @@ static int32_t mndGetNumOfTopics(SMnode *pMnode, char *dbName, int32_t *pNumOfTo
int32_t
numOfTopics
=
0
;
int32_t
numOfTopics
=
0
;
void
*
pIter
=
NULL
;
void
*
pIter
=
NULL
;
while
(
1
)
{
while
(
1
)
{
STopicObj
*
pTopic
=
NULL
;
S
Mq
TopicObj
*
pTopic
=
NULL
;
pIter
=
sdbFetch
(
pSdb
,
SDB_TOPIC
,
pIter
,
(
void
**
)
&
pTopic
);
pIter
=
sdbFetch
(
pSdb
,
SDB_TOPIC
,
pIter
,
(
void
**
)
&
pTopic
);
if
(
pIter
==
NULL
)
break
;
if
(
pIter
==
NULL
)
break
;
if
(
strcmp
(
pTopic
->
db
,
dbName
)
==
0
)
{
numOfTopics
++
;
numOfTopics
++
;
}
sdbRelease
(
pSdb
,
pTopic
);
sdbRelease
(
pSdb
,
pTopic
);
}
}
...
@@ -463,13 +450,13 @@ static void mndExtractTableName(char *tableId, char *name) {
...
@@ -463,13 +450,13 @@ static void mndExtractTableName(char *tableId, char *name) {
}
}
static
int32_t
mndRetrieveTopic
(
SMnodeMsg
*
pMsg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
static
int32_t
mndRetrieveTopic
(
SMnodeMsg
*
pMsg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
numOfRows
=
0
;
int32_t
numOfRows
=
0
;
STopicObj
*
pTopic
=
NULL
;
S
Mq
TopicObj
*
pTopic
=
NULL
;
int32_t
cols
=
0
;
int32_t
cols
=
0
;
char
*
pWrite
;
char
*
pWrite
;
char
prefix
[
64
]
=
{
0
};
char
prefix
[
64
]
=
{
0
};
tstrncpy
(
prefix
,
pShow
->
db
,
64
);
tstrncpy
(
prefix
,
pShow
->
db
,
64
);
strcat
(
prefix
,
TS_PATH_DELIMITER
);
strcat
(
prefix
,
TS_PATH_DELIMITER
);
...
...
source/dnode/mnode/impl/src/mndTrans.c
浏览文件 @
96f2aea2
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
static
SSdbRaw
*
mndTransActionEncode
(
STrans
*
pTrans
);
static
SSdbRaw
*
mndTransActionEncode
(
STrans
*
pTrans
);
static
SSdbRow
*
mndTransActionDecode
(
SSdbRaw
*
pRaw
);
static
SSdbRow
*
mndTransActionDecode
(
SSdbRaw
*
pRaw
);
static
int32_t
mndTransActionInsert
(
SSdb
*
pSdb
,
STrans
*
pTrans
);
static
int32_t
mndTransActionInsert
(
SSdb
*
pSdb
,
STrans
*
pTrans
);
static
int32_t
mndTransActionUpdate
(
SSdb
*
pSdb
,
STrans
*
OldTrans
,
STrans
*
pOld
Trans
);
static
int32_t
mndTransActionUpdate
(
SSdb
*
pSdb
,
STrans
*
OldTrans
,
STrans
*
pOld
);
static
int32_t
mndTransActionDelete
(
SSdb
*
pSdb
,
STrans
*
pTrans
);
static
int32_t
mndTransActionDelete
(
SSdb
*
pSdb
,
STrans
*
pTrans
);
static
int32_t
mndTransAppendLog
(
SArray
*
pArray
,
SSdbRaw
*
pRaw
);
static
int32_t
mndTransAppendLog
(
SArray
*
pArray
,
SSdbRaw
*
pRaw
);
...
@@ -112,6 +112,7 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) {
...
@@ -112,6 +112,7 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) {
int32_t
dataPos
=
0
;
int32_t
dataPos
=
0
;
SDB_SET_INT32
(
pRaw
,
dataPos
,
pTrans
->
id
,
TRANS_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pTrans
->
id
,
TRANS_ENCODE_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pTrans
->
policy
,
TRANS_ENCODE_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pTrans
->
policy
,
TRANS_ENCODE_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pTrans
->
stage
,
TRANS_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
redoLogNum
,
TRANS_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
redoLogNum
,
TRANS_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
undoLogNum
,
TRANS_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
undoLogNum
,
TRANS_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
commitLogNum
,
TRANS_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
commitLogNum
,
TRANS_ENCODE_OVER
)
...
@@ -216,6 +217,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
...
@@ -216,6 +217,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pTrans
->
id
,
TRANS_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pTrans
->
id
,
TRANS_DECODE_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
(
int8_t
*
)
&
pTrans
->
policy
,
TRANS_DECODE_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
(
int8_t
*
)
&
pTrans
->
policy
,
TRANS_DECODE_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
(
int8_t
*
)
&
pTrans
->
stage
,
TRANS_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
redoLogNum
,
TRANS_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
redoLogNum
,
TRANS_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
undoLogNum
,
TRANS_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
undoLogNum
,
TRANS_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
commitLogNum
,
TRANS_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
commitLogNum
,
TRANS_DECODE_OVER
)
...
@@ -314,9 +316,12 @@ static int32_t mndTransActionDelete(SSdb *pSdb, STrans *pTrans) {
...
@@ -314,9 +316,12 @@ static int32_t mndTransActionDelete(SSdb *pSdb, STrans *pTrans) {
return
0
;
return
0
;
}
}
static
int32_t
mndTransActionUpdate
(
SSdb
*
pSdb
,
STrans
*
pOldTrans
,
STrans
*
pNewTrans
)
{
static
int32_t
mndTransActionUpdate
(
SSdb
*
pSdb
,
STrans
*
pOld
,
STrans
*
pNew
)
{
mTrace
(
"trans:%d, perform update action, old_row:%p new_row:%p"
,
pOldTrans
->
id
,
pOldTrans
,
pNewTrans
);
if
(
pNew
->
stage
==
TRN_STAGE_COMMIT
)
pNew
->
stage
=
TRN_STAGE_COMMIT_LOG
;
pOldTrans
->
stage
=
pNewTrans
->
stage
;
mTrace
(
"trans:%d, perform update action, old row:%p stage:%d, new row:%p stage:%d"
,
pOld
->
id
,
pOld
,
pOld
->
stage
,
pNew
,
pNew
->
stage
);
pOld
->
stage
=
pNew
->
stage
;
return
0
;
return
0
;
}
}
...
@@ -464,16 +469,16 @@ int32_t mndTransPrepare(SMnode *pMnode, STrans *pTrans) {
...
@@ -464,16 +469,16 @@ int32_t mndTransPrepare(SMnode *pMnode, STrans *pTrans) {
}
}
mDebug
(
"trans:%d, prepare finished"
,
pTrans
->
id
);
mDebug
(
"trans:%d, prepare finished"
,
pTrans
->
id
);
STrans
*
pNew
Trans
=
mndAcquireTrans
(
pMnode
,
pTrans
->
id
);
STrans
*
pNew
=
mndAcquireTrans
(
pMnode
,
pTrans
->
id
);
if
(
pNew
Trans
==
NULL
)
{
if
(
pNew
==
NULL
)
{
mError
(
"trans:%d, failed to read from sdb since %s"
,
pTrans
->
id
,
terrstr
());
mError
(
"trans:%d, failed to read from sdb since %s"
,
pTrans
->
id
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
pNew
Trans
->
rpcHandle
=
pTrans
->
rpcHandle
;
pNew
->
rpcHandle
=
pTrans
->
rpcHandle
;
pNew
Trans
->
rpcAHandle
=
pTrans
->
rpcAHandle
;
pNew
->
rpcAHandle
=
pTrans
->
rpcAHandle
;
mndTransExecute
(
pMnode
,
pNew
Trans
);
mndTransExecute
(
pMnode
,
pNew
);
mndReleaseTrans
(
pMnode
,
pNew
Trans
);
mndReleaseTrans
(
pMnode
,
pNew
);
return
0
;
return
0
;
}
}
...
@@ -645,7 +650,7 @@ static int32_t mndTransSendActionMsg(SMnode *pMnode, STrans *pTrans, SArray *pAr
...
@@ -645,7 +650,7 @@ static int32_t mndTransSendActionMsg(SMnode *pMnode, STrans *pTrans, SArray *pAr
pAction
->
msgReceived
=
0
;
pAction
->
msgReceived
=
0
;
pAction
->
errCode
=
0
;
pAction
->
errCode
=
0
;
}
else
{
}
else
{
mDebug
(
"trans:%d, action:%d not sen
t
since %s"
,
pTrans
->
id
,
action
,
terrstr
());
mDebug
(
"trans:%d, action:%d not sen
d
since %s"
,
pTrans
->
id
,
action
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
}
}
...
...
source/dnode/mnode/impl/src/mndUser.c
浏览文件 @
96f2aea2
...
@@ -16,7 +16,6 @@
...
@@ -16,7 +16,6 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "mndUser.h"
#include "mndUser.h"
#include "mndShow.h"
#include "mndShow.h"
#include "mndSync.h"
#include "mndTrans.h"
#include "mndTrans.h"
#include "tkey.h"
#include "tkey.h"
...
@@ -29,12 +28,12 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw);
...
@@ -29,12 +28,12 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw);
static
int32_t
mndUserActionInsert
(
SSdb
*
pSdb
,
SUserObj
*
pUser
);
static
int32_t
mndUserActionInsert
(
SSdb
*
pSdb
,
SUserObj
*
pUser
);
static
int32_t
mndUserActionDelete
(
SSdb
*
pSdb
,
SUserObj
*
pUser
);
static
int32_t
mndUserActionDelete
(
SSdb
*
pSdb
,
SUserObj
*
pUser
);
static
int32_t
mndUserActionUpdate
(
SSdb
*
pSdb
,
SUserObj
*
pOld
,
SUserObj
*
pNew
);
static
int32_t
mndUserActionUpdate
(
SSdb
*
pSdb
,
SUserObj
*
pOld
,
SUserObj
*
pNew
);
static
int32_t
mndCreateUser
(
SMnode
*
pMnode
,
char
*
acct
,
char
*
user
,
char
*
pass
,
SMnodeMsg
*
p
Msg
);
static
int32_t
mndCreateUser
(
SMnode
*
pMnode
,
char
*
acct
,
char
*
user
,
char
*
pass
,
SMnodeMsg
*
p
Req
);
static
int32_t
mndProcessCreateUserReq
(
SMnodeMsg
*
p
Msg
);
static
int32_t
mndProcessCreateUserReq
(
SMnodeMsg
*
p
Req
);
static
int32_t
mndProcessAlterUserReq
(
SMnodeMsg
*
p
Msg
);
static
int32_t
mndProcessAlterUserReq
(
SMnodeMsg
*
p
Req
);
static
int32_t
mndProcessDropUserReq
(
SMnodeMsg
*
p
Msg
);
static
int32_t
mndProcessDropUserReq
(
SMnodeMsg
*
p
Req
);
static
int32_t
mndGetUserMeta
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
);
static
int32_t
mndGetUserMeta
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
);
static
int32_t
mndRetrieveUsers
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
int32_t
mndRetrieveUsers
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
void
mndCancelGetNextUser
(
SMnode
*
pMnode
,
void
*
pIter
);
static
void
mndCancelGetNextUser
(
SMnode
*
pMnode
,
void
*
pIter
);
int32_t
mndInitUser
(
SMnode
*
pMnode
)
{
int32_t
mndInitUser
(
SMnode
*
pMnode
)
{
...
@@ -213,7 +212,7 @@ void mndReleaseUser(SMnode *pMnode, SUserObj *pUser) {
...
@@ -213,7 +212,7 @@ void mndReleaseUser(SMnode *pMnode, SUserObj *pUser) {
sdbRelease
(
pSdb
,
pUser
);
sdbRelease
(
pSdb
,
pUser
);
}
}
static
int32_t
mndCreateUser
(
SMnode
*
pMnode
,
char
*
acct
,
char
*
user
,
char
*
pass
,
SMnodeMsg
*
p
Msg
)
{
static
int32_t
mndCreateUser
(
SMnode
*
pMnode
,
char
*
acct
,
char
*
user
,
char
*
pass
,
SMnodeMsg
*
p
Req
)
{
SUserObj
userObj
=
{
0
};
SUserObj
userObj
=
{
0
};
tstrncpy
(
userObj
.
user
,
user
,
TSDB_USER_LEN
);
tstrncpy
(
userObj
.
user
,
user
,
TSDB_USER_LEN
);
tstrncpy
(
userObj
.
acct
,
acct
,
TSDB_USER_LEN
);
tstrncpy
(
userObj
.
acct
,
acct
,
TSDB_USER_LEN
);
...
@@ -222,7 +221,7 @@ static int32_t mndCreateUser(SMnode *pMnode, char *acct, char *user, char *pass,
...
@@ -222,7 +221,7 @@ static int32_t mndCreateUser(SMnode *pMnode, char *acct, char *user, char *pass,
userObj
.
updateTime
=
userObj
.
createdTime
;
userObj
.
updateTime
=
userObj
.
createdTime
;
userObj
.
superUser
=
0
;
userObj
.
superUser
=
0
;
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
(
"user:%s, failed to create since %s"
,
user
,
terrstr
());
mError
(
"user:%s, failed to create since %s"
,
user
,
terrstr
());
return
-
1
;
return
-
1
;
...
@@ -247,9 +246,9 @@ static int32_t mndCreateUser(SMnode *pMnode, char *acct, char *user, char *pass,
...
@@ -247,9 +246,9 @@ static int32_t mndCreateUser(SMnode *pMnode, char *acct, char *user, char *pass,
return
0
;
return
0
;
}
}
static
int32_t
mndProcessCreateUserReq
(
SMnodeMsg
*
p
Msg
)
{
static
int32_t
mndProcessCreateUserReq
(
SMnodeMsg
*
p
Req
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SCreateUserReq
*
pCreate
=
p
Msg
->
rpcMsg
.
pCont
;
SCreateUserReq
*
pCreate
=
p
Req
->
rpcMsg
.
pCont
;
mDebug
(
"user:%s, start to create"
,
pCreate
->
user
);
mDebug
(
"user:%s, start to create"
,
pCreate
->
user
);
...
@@ -273,14 +272,14 @@ static int32_t mndProcessCreateUserReq(SMnodeMsg *pMsg) {
...
@@ -273,14 +272,14 @@ static int32_t mndProcessCreateUserReq(SMnodeMsg *pMsg) {
return
-
1
;
return
-
1
;
}
}
SUserObj
*
pOperUser
=
mndAcquireUser
(
pMnode
,
p
Msg
->
user
);
SUserObj
*
pOperUser
=
mndAcquireUser
(
pMnode
,
p
Req
->
user
);
if
(
pOperUser
==
NULL
)
{
if
(
pOperUser
==
NULL
)
{
terrno
=
TSDB_CODE_MND_NO_USER_FROM_CONN
;
terrno
=
TSDB_CODE_MND_NO_USER_FROM_CONN
;
mError
(
"user:%s, failed to create since %s"
,
pCreate
->
user
,
terrstr
());
mError
(
"user:%s, failed to create since %s"
,
pCreate
->
user
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
int32_t
code
=
mndCreateUser
(
pMnode
,
pOperUser
->
acct
,
pCreate
->
user
,
pCreate
->
pass
,
p
Msg
);
int32_t
code
=
mndCreateUser
(
pMnode
,
pOperUser
->
acct
,
pCreate
->
user
,
pCreate
->
pass
,
p
Req
);
mndReleaseUser
(
pMnode
,
pOperUser
);
mndReleaseUser
(
pMnode
,
pOperUser
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
...
@@ -291,8 +290,8 @@ static int32_t mndProcessCreateUserReq(SMnodeMsg *pMsg) {
...
@@ -291,8 +290,8 @@ static int32_t mndProcessCreateUserReq(SMnodeMsg *pMsg) {
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
}
static
int32_t
mndUpdateUser
(
SMnode
*
pMnode
,
SUserObj
*
pOld
,
SUserObj
*
pNew
,
SMnodeMsg
*
p
Msg
)
{
static
int32_t
mndUpdateUser
(
SMnode
*
pMnode
,
SUserObj
*
pOld
,
SUserObj
*
pNew
,
SMnodeMsg
*
p
Req
)
{
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
(
"user:%s, failed to update since %s"
,
pOld
->
user
,
terrstr
());
mError
(
"user:%s, failed to update since %s"
,
pOld
->
user
,
terrstr
());
return
-
1
;
return
-
1
;
...
@@ -317,9 +316,9 @@ static int32_t mndUpdateUser(SMnode *pMnode, SUserObj *pOld, SUserObj *pNew, SMn
...
@@ -317,9 +316,9 @@ static int32_t mndUpdateUser(SMnode *pMnode, SUserObj *pOld, SUserObj *pNew, SMn
return
0
;
return
0
;
}
}
static
int32_t
mndProcessAlterUserReq
(
SMnodeMsg
*
p
Msg
)
{
static
int32_t
mndProcessAlterUserReq
(
SMnodeMsg
*
p
Req
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SAlterUserReq
*
pAlter
=
p
Msg
->
rpcMsg
.
pCont
;
SAlterUserReq
*
pAlter
=
p
Req
->
rpcMsg
.
pCont
;
mDebug
(
"user:%s, start to alter"
,
pAlter
->
user
);
mDebug
(
"user:%s, start to alter"
,
pAlter
->
user
);
...
@@ -342,7 +341,7 @@ static int32_t mndProcessAlterUserReq(SMnodeMsg *pMsg) {
...
@@ -342,7 +341,7 @@ static int32_t mndProcessAlterUserReq(SMnodeMsg *pMsg) {
return
-
1
;
return
-
1
;
}
}
SUserObj
*
pOperUser
=
mndAcquireUser
(
pMnode
,
p
Msg
->
user
);
SUserObj
*
pOperUser
=
mndAcquireUser
(
pMnode
,
p
Req
->
user
);
if
(
pOperUser
==
NULL
)
{
if
(
pOperUser
==
NULL
)
{
mndReleaseUser
(
pMnode
,
pUser
);
mndReleaseUser
(
pMnode
,
pUser
);
terrno
=
TSDB_CODE_MND_NO_USER_FROM_CONN
;
terrno
=
TSDB_CODE_MND_NO_USER_FROM_CONN
;
...
@@ -356,7 +355,7 @@ static int32_t mndProcessAlterUserReq(SMnodeMsg *pMsg) {
...
@@ -356,7 +355,7 @@ static int32_t mndProcessAlterUserReq(SMnodeMsg *pMsg) {
taosEncryptPass
((
uint8_t
*
)
pAlter
->
pass
,
strlen
(
pAlter
->
pass
),
pUser
->
pass
);
taosEncryptPass
((
uint8_t
*
)
pAlter
->
pass
,
strlen
(
pAlter
->
pass
),
pUser
->
pass
);
newUser
.
updateTime
=
taosGetTimestampMs
();
newUser
.
updateTime
=
taosGetTimestampMs
();
int32_t
code
=
mndUpdateUser
(
pMnode
,
pUser
,
&
newUser
,
p
Msg
);
int32_t
code
=
mndUpdateUser
(
pMnode
,
pUser
,
&
newUser
,
p
Req
);
mndReleaseUser
(
pMnode
,
pOperUser
);
mndReleaseUser
(
pMnode
,
pOperUser
);
mndReleaseUser
(
pMnode
,
pUser
);
mndReleaseUser
(
pMnode
,
pUser
);
...
@@ -368,8 +367,8 @@ static int32_t mndProcessAlterUserReq(SMnodeMsg *pMsg) {
...
@@ -368,8 +367,8 @@ static int32_t mndProcessAlterUserReq(SMnodeMsg *pMsg) {
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
}
static
int32_t
mndDropUser
(
SMnode
*
pMnode
,
SMnodeMsg
*
p
Msg
,
SUserObj
*
pUser
)
{
static
int32_t
mndDropUser
(
SMnode
*
pMnode
,
SMnodeMsg
*
p
Req
,
SUserObj
*
pUser
)
{
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
(
"user:%s, failed to drop since %s"
,
pUser
->
user
,
terrstr
());
mError
(
"user:%s, failed to drop since %s"
,
pUser
->
user
,
terrstr
());
return
-
1
;
return
-
1
;
...
@@ -394,9 +393,9 @@ static int32_t mndDropUser(SMnode *pMnode, SMnodeMsg *pMsg, SUserObj *pUser) {
...
@@ -394,9 +393,9 @@ static int32_t mndDropUser(SMnode *pMnode, SMnodeMsg *pMsg, SUserObj *pUser) {
return
0
;
return
0
;
}
}
static
int32_t
mndProcessDropUserReq
(
SMnodeMsg
*
p
Msg
)
{
static
int32_t
mndProcessDropUserReq
(
SMnodeMsg
*
p
Req
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SDropUserReq
*
pDrop
=
p
Msg
->
rpcMsg
.
pCont
;
SDropUserReq
*
pDrop
=
p
Req
->
rpcMsg
.
pCont
;
mDebug
(
"user:%s, start to drop"
,
pDrop
->
user
);
mDebug
(
"user:%s, start to drop"
,
pDrop
->
user
);
...
@@ -413,7 +412,7 @@ static int32_t mndProcessDropUserReq(SMnodeMsg *pMsg) {
...
@@ -413,7 +412,7 @@ static int32_t mndProcessDropUserReq(SMnodeMsg *pMsg) {
return
-
1
;
return
-
1
;
}
}
SUserObj
*
pOperUser
=
mndAcquireUser
(
pMnode
,
p
Msg
->
user
);
SUserObj
*
pOperUser
=
mndAcquireUser
(
pMnode
,
p
Req
->
user
);
if
(
pOperUser
==
NULL
)
{
if
(
pOperUser
==
NULL
)
{
mndReleaseUser
(
pMnode
,
pUser
);
mndReleaseUser
(
pMnode
,
pUser
);
terrno
=
TSDB_CODE_MND_NO_USER_FROM_CONN
;
terrno
=
TSDB_CODE_MND_NO_USER_FROM_CONN
;
...
@@ -421,7 +420,7 @@ static int32_t mndProcessDropUserReq(SMnodeMsg *pMsg) {
...
@@ -421,7 +420,7 @@ static int32_t mndProcessDropUserReq(SMnodeMsg *pMsg) {
return
-
1
;
return
-
1
;
}
}
int32_t
code
=
mndDropUser
(
pMnode
,
p
Msg
,
pUser
);
int32_t
code
=
mndDropUser
(
pMnode
,
p
Req
,
pUser
);
mndReleaseUser
(
pMnode
,
pOperUser
);
mndReleaseUser
(
pMnode
,
pOperUser
);
mndReleaseUser
(
pMnode
,
pUser
);
mndReleaseUser
(
pMnode
,
pUser
);
...
@@ -433,8 +432,8 @@ static int32_t mndProcessDropUserReq(SMnodeMsg *pMsg) {
...
@@ -433,8 +432,8 @@ static int32_t mndProcessDropUserReq(SMnodeMsg *pMsg) {
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
}
static
int32_t
mndGetUserMeta
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
)
{
static
int32_t
mndGetUserMeta
(
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
;
...
@@ -479,8 +478,8 @@ static int32_t mndGetUserMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *p
...
@@ -479,8 +478,8 @@ static int32_t mndGetUserMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *p
return
0
;
return
0
;
}
}
static
int32_t
mndRetrieveUsers
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
static
int32_t
mndRetrieveUsers
(
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
;
SUserObj
*
pUser
=
NULL
;
SUserObj
*
pUser
=
NULL
;
...
...
source/dnode/mnode/impl/test/CMakeLists.txt
浏览文件 @
96f2aea2
...
@@ -6,4 +6,4 @@ add_subdirectory(trans)
...
@@ -6,4 +6,4 @@ add_subdirectory(trans)
add_subdirectory
(
qnode
)
add_subdirectory
(
qnode
)
add_subdirectory
(
snode
)
add_subdirectory
(
snode
)
add_subdirectory
(
bnode
)
add_subdirectory
(
bnode
)
add_subdirectory
(
show
)
source/dnode/mnode/impl/test/acct/acct.cpp
浏览文件 @
96f2aea2
...
@@ -30,9 +30,9 @@ TEST_F(MndTestAcct, 01_Create_Acct) {
...
@@ -30,9 +30,9 @@ TEST_F(MndTestAcct, 01_Create_Acct) {
SCreateAcctReq
*
pReq
=
(
SCreateAcctReq
*
)
rpcMallocCont
(
contLen
);
SCreateAcctReq
*
pReq
=
(
SCreateAcctReq
*
)
rpcMallocCont
(
contLen
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_ACCT
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_ACCT
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_MSG_NOT_PROCESSED
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_MSG_NOT_PROCESSED
);
}
}
TEST_F
(
MndTestAcct
,
02
_Alter_Acct
)
{
TEST_F
(
MndTestAcct
,
02
_Alter_Acct
)
{
...
@@ -40,9 +40,9 @@ TEST_F(MndTestAcct, 02_Alter_Acct) {
...
@@ -40,9 +40,9 @@ TEST_F(MndTestAcct, 02_Alter_Acct) {
SAlterAcctReq
*
pReq
=
(
SAlterAcctReq
*
)
rpcMallocCont
(
contLen
);
SAlterAcctReq
*
pReq
=
(
SAlterAcctReq
*
)
rpcMallocCont
(
contLen
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_ALTER_ACCT
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_ALTER_ACCT
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_MSG_NOT_PROCESSED
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_MSG_NOT_PROCESSED
);
}
}
TEST_F
(
MndTestAcct
,
03
_Drop_Acct
)
{
TEST_F
(
MndTestAcct
,
03
_Drop_Acct
)
{
...
@@ -50,18 +50,18 @@ TEST_F(MndTestAcct, 03_Drop_Acct) {
...
@@ -50,18 +50,18 @@ TEST_F(MndTestAcct, 03_Drop_Acct) {
SDropAcctReq
*
pReq
=
(
SDropAcctReq
*
)
rpcMallocCont
(
contLen
);
SDropAcctReq
*
pReq
=
(
SDropAcctReq
*
)
rpcMallocCont
(
contLen
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_DROP_ACCT
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_DROP_ACCT
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_MSG_NOT_PROCESSED
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_MSG_NOT_PROCESSED
);
}
}
TEST_F
(
MndTestAcct
,
04
_Show_Acct
)
{
TEST_F
(
MndTestAcct
,
04
_Show_Acct
)
{
int32_t
contLen
=
sizeof
(
SShow
Msg
);
int32_t
contLen
=
sizeof
(
SShow
Req
);
SShow
Msg
*
pReq
=
(
SShowMsg
*
)
rpcMallocCont
(
contLen
);
SShow
Req
*
pReq
=
(
SShowReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
type
=
TSDB_MGMT_TABLE_ACCT
;
pReq
->
type
=
TSDB_MGMT_TABLE_ACCT
;
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_SHOW
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_SHOW
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_INVALID_MSG_TYPE
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_INVALID_MSG_TYPE
);
}
}
\ No newline at end of file
source/dnode/mnode/impl/test/bnode/bnode.cpp
浏览文件 @
96f2aea2
...
@@ -39,14 +39,14 @@ Testbase MndTestBnode::test;
...
@@ -39,14 +39,14 @@ Testbase MndTestBnode::test;
TestServer
MndTestBnode
::
server2
;
TestServer
MndTestBnode
::
server2
;
TEST_F
(
MndTestBnode
,
01
_Show_Bnode
)
{
TEST_F
(
MndTestBnode
,
01
_Show_Bnode
)
{
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_BNODE
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_BNODE
,
""
);
CHECK_META
(
"show bnodes"
,
3
);
CHECK_META
(
"show bnodes"
,
3
);
CHECK_SCHEMA
(
0
,
TSDB_DATA_TYPE_SMALLINT
,
2
,
"id"
);
CHECK_SCHEMA
(
0
,
TSDB_DATA_TYPE_SMALLINT
,
2
,
"id"
);
CHECK_SCHEMA
(
1
,
TSDB_DATA_TYPE_BINARY
,
TSDB_EP_LEN
+
VARSTR_HEADER_SIZE
,
"endpoint"
);
CHECK_SCHEMA
(
1
,
TSDB_DATA_TYPE_BINARY
,
TSDB_EP_LEN
+
VARSTR_HEADER_SIZE
,
"endpoint"
);
CHECK_SCHEMA
(
2
,
TSDB_DATA_TYPE_TIMESTAMP
,
8
,
"create_time"
);
CHECK_SCHEMA
(
2
,
TSDB_DATA_TYPE_TIMESTAMP
,
8
,
"create_time"
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
0
);
EXPECT_EQ
(
test
.
GetShowRows
(),
0
);
}
}
...
@@ -57,9 +57,9 @@ TEST_F(MndTestBnode, 02_Create_Bnode) {
...
@@ -57,9 +57,9 @@ TEST_F(MndTestBnode, 02_Create_Bnode) {
SMCreateBnodeReq
*
pReq
=
(
SMCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
SMCreateBnodeReq
*
pReq
=
(
SMCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_DNODE_NOT_EXIST
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_DNODE_NOT_EXIST
);
}
}
{
{
...
@@ -68,13 +68,13 @@ TEST_F(MndTestBnode, 02_Create_Bnode) {
...
@@ -68,13 +68,13 @@ TEST_F(MndTestBnode, 02_Create_Bnode) {
SMCreateBnodeReq
*
pReq
=
(
SMCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
SMCreateBnodeReq
*
pReq
=
(
SMCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_BNODE
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_BNODE
,
""
);
CHECK_META
(
"show bnodes"
,
3
);
CHECK_META
(
"show bnodes"
,
3
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckInt16
(
1
);
CheckInt16
(
1
);
...
@@ -88,9 +88,9 @@ TEST_F(MndTestBnode, 02_Create_Bnode) {
...
@@ -88,9 +88,9 @@ TEST_F(MndTestBnode, 02_Create_Bnode) {
SMCreateBnodeReq
*
pReq
=
(
SMCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
SMCreateBnodeReq
*
pReq
=
(
SMCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_BNODE_ALREADY_EXIST
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_BNODE_ALREADY_EXIST
);
}
}
}
}
...
@@ -102,13 +102,13 @@ TEST_F(MndTestBnode, 03_Drop_Bnode) {
...
@@ -102,13 +102,13 @@ TEST_F(MndTestBnode, 03_Drop_Bnode) {
strcpy
(
pReq
->
fqdn
,
"localhost"
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
pReq
->
port
=
htonl
(
9019
);
pReq
->
port
=
htonl
(
9019
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
taosMsleep
(
1300
);
taosMsleep
(
1300
);
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_DNODE
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_DNODE
,
""
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
}
}
...
@@ -118,12 +118,12 @@ TEST_F(MndTestBnode, 03_Drop_Bnode) {
...
@@ -118,12 +118,12 @@ TEST_F(MndTestBnode, 03_Drop_Bnode) {
SMCreateBnodeReq
*
pReq
=
(
SMCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
SMCreateBnodeReq
*
pReq
=
(
SMCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_BNODE
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_BNODE
,
""
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
CheckInt16
(
1
);
CheckInt16
(
1
);
...
@@ -140,12 +140,12 @@ TEST_F(MndTestBnode, 03_Drop_Bnode) {
...
@@ -140,12 +140,12 @@ TEST_F(MndTestBnode, 03_Drop_Bnode) {
SMDropBnodeReq
*
pReq
=
(
SMDropBnodeReq
*
)
rpcMallocCont
(
contLen
);
SMDropBnodeReq
*
pReq
=
(
SMDropBnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_DROP_BNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_DROP_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_BNODE
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_BNODE
,
""
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckInt16
(
1
);
CheckInt16
(
1
);
...
@@ -159,9 +159,9 @@ TEST_F(MndTestBnode, 03_Drop_Bnode) {
...
@@ -159,9 +159,9 @@ TEST_F(MndTestBnode, 03_Drop_Bnode) {
SMDropBnodeReq
*
pReq
=
(
SMDropBnodeReq
*
)
rpcMallocCont
(
contLen
);
SMDropBnodeReq
*
pReq
=
(
SMDropBnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_DROP_BNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_DROP_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_BNODE_NOT_EXIST
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_BNODE_NOT_EXIST
);
}
}
}
}
...
@@ -174,9 +174,9 @@ TEST_F(MndTestBnode, 03_Create_Bnode_Rollback) {
...
@@ -174,9 +174,9 @@ TEST_F(MndTestBnode, 03_Create_Bnode_Rollback) {
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
server2
.
Stop
();
server2
.
Stop
();
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_RPC_NETWORK_UNAVAIL
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_RPC_NETWORK_UNAVAIL
);
}
}
{
{
...
@@ -186,10 +186,9 @@ TEST_F(MndTestBnode, 03_Create_Bnode_Rollback) {
...
@@ -186,10 +186,9 @@ TEST_F(MndTestBnode, 03_Create_Bnode_Rollback) {
SMCreateBnodeReq
*
pReq
=
(
SMCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
SMCreateBnodeReq
*
pReq
=
(
SMCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
server2
.
Stop
();
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_SDB_OBJ_CREATING
);
ASSERT_EQ
(
pMsg
->
code
,
TSDB_CODE_SDB_OBJ_CREATING
);
}
}
{
{
...
@@ -199,10 +198,9 @@ TEST_F(MndTestBnode, 03_Create_Bnode_Rollback) {
...
@@ -199,10 +198,9 @@ TEST_F(MndTestBnode, 03_Create_Bnode_Rollback) {
SMDropBnodeReq
*
pReq
=
(
SMDropBnodeReq
*
)
rpcMallocCont
(
contLen
);
SMDropBnodeReq
*
pReq
=
(
SMDropBnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
server2
.
Stop
();
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_BNODE
,
pReq
,
contLen
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_DROP_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_SDB_OBJ_CREATING
);
ASSERT_EQ
(
pMsg
->
code
,
TSDB_CODE_SDB_OBJ_CREATING
);
}
}
{
{
...
@@ -211,7 +209,7 @@ TEST_F(MndTestBnode, 03_Create_Bnode_Rollback) {
...
@@ -211,7 +209,7 @@ TEST_F(MndTestBnode, 03_Create_Bnode_Rollback) {
taosMsleep
(
1000
);
taosMsleep
(
1000
);
int32_t
retry
=
0
;
int32_t
retry
=
0
;
int32_t
retryMax
=
1
0
;
int32_t
retryMax
=
2
0
;
for
(
retry
=
0
;
retry
<
retryMax
;
retry
++
)
{
for
(
retry
=
0
;
retry
<
retryMax
;
retry
++
)
{
int32_t
contLen
=
sizeof
(
SMCreateBnodeReq
);
int32_t
contLen
=
sizeof
(
SMCreateBnodeReq
);
...
@@ -219,9 +217,9 @@ TEST_F(MndTestBnode, 03_Create_Bnode_Rollback) {
...
@@ -219,9 +217,9 @@ TEST_F(MndTestBnode, 03_Create_Bnode_Rollback) {
SMCreateBnodeReq
*
pReq
=
(
SMCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
SMCreateBnodeReq
*
pReq
=
(
SMCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
if
(
p
Msg
->
code
==
0
)
break
;
if
(
p
Rsp
->
code
==
0
)
break
;
taosMsleep
(
1000
);
taosMsleep
(
1000
);
}
}
...
@@ -238,9 +236,9 @@ TEST_F(MndTestBnode, 04_Drop_Bnode_Rollback) {
...
@@ -238,9 +236,9 @@ TEST_F(MndTestBnode, 04_Drop_Bnode_Rollback) {
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
server2
.
Stop
();
server2
.
Stop
();
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_DROP_BNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_DROP_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_RPC_NETWORK_UNAVAIL
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_RPC_NETWORK_UNAVAIL
);
}
}
{
{
...
@@ -250,10 +248,9 @@ TEST_F(MndTestBnode, 04_Drop_Bnode_Rollback) {
...
@@ -250,10 +248,9 @@ TEST_F(MndTestBnode, 04_Drop_Bnode_Rollback) {
SMCreateBnodeReq
*
pReq
=
(
SMCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
SMCreateBnodeReq
*
pReq
=
(
SMCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
server2
.
Stop
();
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_SDB_OBJ_DROPPING
);
ASSERT_EQ
(
pMsg
->
code
,
TSDB_CODE_SDB_OBJ_DROPPING
);
}
}
{
{
...
@@ -263,10 +260,9 @@ TEST_F(MndTestBnode, 04_Drop_Bnode_Rollback) {
...
@@ -263,10 +260,9 @@ TEST_F(MndTestBnode, 04_Drop_Bnode_Rollback) {
SMDropBnodeReq
*
pReq
=
(
SMDropBnodeReq
*
)
rpcMallocCont
(
contLen
);
SMDropBnodeReq
*
pReq
=
(
SMDropBnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
server2
.
Stop
();
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_BNODE
,
pReq
,
contLen
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_DROP_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_SDB_OBJ_DROPPING
);
ASSERT_EQ
(
pMsg
->
code
,
TSDB_CODE_SDB_OBJ_DROPPING
);
}
}
{
{
...
@@ -275,7 +271,7 @@ TEST_F(MndTestBnode, 04_Drop_Bnode_Rollback) {
...
@@ -275,7 +271,7 @@ TEST_F(MndTestBnode, 04_Drop_Bnode_Rollback) {
taosMsleep
(
1000
);
taosMsleep
(
1000
);
int32_t
retry
=
0
;
int32_t
retry
=
0
;
int32_t
retryMax
=
1
0
;
int32_t
retryMax
=
2
0
;
for
(
retry
=
0
;
retry
<
retryMax
;
retry
++
)
{
for
(
retry
=
0
;
retry
<
retryMax
;
retry
++
)
{
int32_t
contLen
=
sizeof
(
SMCreateBnodeReq
);
int32_t
contLen
=
sizeof
(
SMCreateBnodeReq
);
...
@@ -283,9 +279,9 @@ TEST_F(MndTestBnode, 04_Drop_Bnode_Rollback) {
...
@@ -283,9 +279,9 @@ TEST_F(MndTestBnode, 04_Drop_Bnode_Rollback) {
SMCreateBnodeReq
*
pReq
=
(
SMCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
SMCreateBnodeReq
*
pReq
=
(
SMCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
if
(
p
Msg
->
code
==
0
)
break
;
if
(
p
Rsp
->
code
==
0
)
break
;
taosMsleep
(
1000
);
taosMsleep
(
1000
);
}
}
...
...
source/dnode/mnode/impl/test/qnode/qnode.cpp
浏览文件 @
96f2aea2
...
@@ -39,14 +39,14 @@ Testbase MndTestQnode::test;
...
@@ -39,14 +39,14 @@ Testbase MndTestQnode::test;
TestServer
MndTestQnode
::
server2
;
TestServer
MndTestQnode
::
server2
;
TEST_F
(
MndTestQnode
,
01
_Show_Qnode
)
{
TEST_F
(
MndTestQnode
,
01
_Show_Qnode
)
{
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_QNODE
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_QNODE
,
""
);
CHECK_META
(
"show qnodes"
,
3
);
CHECK_META
(
"show qnodes"
,
3
);
CHECK_SCHEMA
(
0
,
TSDB_DATA_TYPE_SMALLINT
,
2
,
"id"
);
CHECK_SCHEMA
(
0
,
TSDB_DATA_TYPE_SMALLINT
,
2
,
"id"
);
CHECK_SCHEMA
(
1
,
TSDB_DATA_TYPE_BINARY
,
TSDB_EP_LEN
+
VARSTR_HEADER_SIZE
,
"endpoint"
);
CHECK_SCHEMA
(
1
,
TSDB_DATA_TYPE_BINARY
,
TSDB_EP_LEN
+
VARSTR_HEADER_SIZE
,
"endpoint"
);
CHECK_SCHEMA
(
2
,
TSDB_DATA_TYPE_TIMESTAMP
,
8
,
"create_time"
);
CHECK_SCHEMA
(
2
,
TSDB_DATA_TYPE_TIMESTAMP
,
8
,
"create_time"
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
0
);
EXPECT_EQ
(
test
.
GetShowRows
(),
0
);
}
}
...
@@ -57,9 +57,9 @@ TEST_F(MndTestQnode, 02_Create_Qnode) {
...
@@ -57,9 +57,9 @@ TEST_F(MndTestQnode, 02_Create_Qnode) {
SMCreateQnodeReq
*
pReq
=
(
SMCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
SMCreateQnodeReq
*
pReq
=
(
SMCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_DNODE_NOT_EXIST
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_DNODE_NOT_EXIST
);
}
}
{
{
...
@@ -68,13 +68,13 @@ TEST_F(MndTestQnode, 02_Create_Qnode) {
...
@@ -68,13 +68,13 @@ TEST_F(MndTestQnode, 02_Create_Qnode) {
SMCreateQnodeReq
*
pReq
=
(
SMCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
SMCreateQnodeReq
*
pReq
=
(
SMCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_QNODE
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_QNODE
,
""
);
CHECK_META
(
"show qnodes"
,
3
);
CHECK_META
(
"show qnodes"
,
3
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckInt16
(
1
);
CheckInt16
(
1
);
...
@@ -88,9 +88,9 @@ TEST_F(MndTestQnode, 02_Create_Qnode) {
...
@@ -88,9 +88,9 @@ TEST_F(MndTestQnode, 02_Create_Qnode) {
SMCreateQnodeReq
*
pReq
=
(
SMCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
SMCreateQnodeReq
*
pReq
=
(
SMCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_QNODE_ALREADY_EXIST
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_QNODE_ALREADY_EXIST
);
}
}
}
}
...
@@ -102,13 +102,13 @@ TEST_F(MndTestQnode, 03_Drop_Qnode) {
...
@@ -102,13 +102,13 @@ TEST_F(MndTestQnode, 03_Drop_Qnode) {
strcpy
(
pReq
->
fqdn
,
"localhost"
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
pReq
->
port
=
htonl
(
9015
);
pReq
->
port
=
htonl
(
9015
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
taosMsleep
(
1300
);
taosMsleep
(
1300
);
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_DNODE
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_DNODE
,
""
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
}
}
...
@@ -118,12 +118,12 @@ TEST_F(MndTestQnode, 03_Drop_Qnode) {
...
@@ -118,12 +118,12 @@ TEST_F(MndTestQnode, 03_Drop_Qnode) {
SMCreateQnodeReq
*
pReq
=
(
SMCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
SMCreateQnodeReq
*
pReq
=
(
SMCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_QNODE
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_QNODE
,
""
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
CheckInt16
(
1
);
CheckInt16
(
1
);
...
@@ -140,12 +140,12 @@ TEST_F(MndTestQnode, 03_Drop_Qnode) {
...
@@ -140,12 +140,12 @@ TEST_F(MndTestQnode, 03_Drop_Qnode) {
SMDropQnodeReq
*
pReq
=
(
SMDropQnodeReq
*
)
rpcMallocCont
(
contLen
);
SMDropQnodeReq
*
pReq
=
(
SMDropQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_DROP_QNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_DROP_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_QNODE
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_QNODE
,
""
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckInt16
(
1
);
CheckInt16
(
1
);
...
@@ -159,9 +159,9 @@ TEST_F(MndTestQnode, 03_Drop_Qnode) {
...
@@ -159,9 +159,9 @@ TEST_F(MndTestQnode, 03_Drop_Qnode) {
SMDropQnodeReq
*
pReq
=
(
SMDropQnodeReq
*
)
rpcMallocCont
(
contLen
);
SMDropQnodeReq
*
pReq
=
(
SMDropQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_DROP_QNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_DROP_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_QNODE_NOT_EXIST
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_QNODE_NOT_EXIST
);
}
}
}
}
...
@@ -174,9 +174,9 @@ TEST_F(MndTestQnode, 03_Create_Qnode_Rollback) {
...
@@ -174,9 +174,9 @@ TEST_F(MndTestQnode, 03_Create_Qnode_Rollback) {
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
server2
.
Stop
();
server2
.
Stop
();
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_RPC_NETWORK_UNAVAIL
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_RPC_NETWORK_UNAVAIL
);
}
}
{
{
...
@@ -186,10 +186,9 @@ TEST_F(MndTestQnode, 03_Create_Qnode_Rollback) {
...
@@ -186,10 +186,9 @@ TEST_F(MndTestQnode, 03_Create_Qnode_Rollback) {
SMCreateQnodeReq
*
pReq
=
(
SMCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
SMCreateQnodeReq
*
pReq
=
(
SMCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
server2
.
Stop
();
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_SDB_OBJ_CREATING
);
ASSERT_EQ
(
pMsg
->
code
,
TSDB_CODE_SDB_OBJ_CREATING
);
}
}
{
{
...
@@ -199,10 +198,9 @@ TEST_F(MndTestQnode, 03_Create_Qnode_Rollback) {
...
@@ -199,10 +198,9 @@ TEST_F(MndTestQnode, 03_Create_Qnode_Rollback) {
SMDropQnodeReq
*
pReq
=
(
SMDropQnodeReq
*
)
rpcMallocCont
(
contLen
);
SMDropQnodeReq
*
pReq
=
(
SMDropQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
server2
.
Stop
();
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_QNODE
,
pReq
,
contLen
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_DROP_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_SDB_OBJ_CREATING
);
ASSERT_EQ
(
pMsg
->
code
,
TSDB_CODE_SDB_OBJ_CREATING
);
}
}
{
{
...
@@ -211,7 +209,7 @@ TEST_F(MndTestQnode, 03_Create_Qnode_Rollback) {
...
@@ -211,7 +209,7 @@ TEST_F(MndTestQnode, 03_Create_Qnode_Rollback) {
taosMsleep
(
1000
);
taosMsleep
(
1000
);
int32_t
retry
=
0
;
int32_t
retry
=
0
;
int32_t
retryMax
=
1
0
;
int32_t
retryMax
=
2
0
;
for
(
retry
=
0
;
retry
<
retryMax
;
retry
++
)
{
for
(
retry
=
0
;
retry
<
retryMax
;
retry
++
)
{
int32_t
contLen
=
sizeof
(
SMCreateQnodeReq
);
int32_t
contLen
=
sizeof
(
SMCreateQnodeReq
);
...
@@ -219,9 +217,9 @@ TEST_F(MndTestQnode, 03_Create_Qnode_Rollback) {
...
@@ -219,9 +217,9 @@ TEST_F(MndTestQnode, 03_Create_Qnode_Rollback) {
SMCreateQnodeReq
*
pReq
=
(
SMCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
SMCreateQnodeReq
*
pReq
=
(
SMCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
if
(
p
Msg
->
code
==
0
)
break
;
if
(
p
Rsp
->
code
==
0
)
break
;
taosMsleep
(
1000
);
taosMsleep
(
1000
);
}
}
...
@@ -238,9 +236,9 @@ TEST_F(MndTestQnode, 04_Drop_Qnode_Rollback) {
...
@@ -238,9 +236,9 @@ TEST_F(MndTestQnode, 04_Drop_Qnode_Rollback) {
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
server2
.
Stop
();
server2
.
Stop
();
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_DROP_QNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_DROP_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_RPC_NETWORK_UNAVAIL
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_RPC_NETWORK_UNAVAIL
);
}
}
{
{
...
@@ -250,10 +248,9 @@ TEST_F(MndTestQnode, 04_Drop_Qnode_Rollback) {
...
@@ -250,10 +248,9 @@ TEST_F(MndTestQnode, 04_Drop_Qnode_Rollback) {
SMCreateQnodeReq
*
pReq
=
(
SMCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
SMCreateQnodeReq
*
pReq
=
(
SMCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
server2
.
Stop
();
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_SDB_OBJ_DROPPING
);
ASSERT_EQ
(
pMsg
->
code
,
TSDB_CODE_SDB_OBJ_DROPPING
);
}
}
{
{
...
@@ -263,10 +260,9 @@ TEST_F(MndTestQnode, 04_Drop_Qnode_Rollback) {
...
@@ -263,10 +260,9 @@ TEST_F(MndTestQnode, 04_Drop_Qnode_Rollback) {
SMDropQnodeReq
*
pReq
=
(
SMDropQnodeReq
*
)
rpcMallocCont
(
contLen
);
SMDropQnodeReq
*
pReq
=
(
SMDropQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
server2
.
Stop
();
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_QNODE
,
pReq
,
contLen
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_DROP_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_SDB_OBJ_DROPPING
);
ASSERT_EQ
(
pMsg
->
code
,
TSDB_CODE_SDB_OBJ_DROPPING
);
}
}
{
{
...
@@ -275,7 +271,7 @@ TEST_F(MndTestQnode, 04_Drop_Qnode_Rollback) {
...
@@ -275,7 +271,7 @@ TEST_F(MndTestQnode, 04_Drop_Qnode_Rollback) {
taosMsleep
(
1000
);
taosMsleep
(
1000
);
int32_t
retry
=
0
;
int32_t
retry
=
0
;
int32_t
retryMax
=
1
0
;
int32_t
retryMax
=
2
0
;
for
(
retry
=
0
;
retry
<
retryMax
;
retry
++
)
{
for
(
retry
=
0
;
retry
<
retryMax
;
retry
++
)
{
int32_t
contLen
=
sizeof
(
SMCreateQnodeReq
);
int32_t
contLen
=
sizeof
(
SMCreateQnodeReq
);
...
@@ -283,9 +279,9 @@ TEST_F(MndTestQnode, 04_Drop_Qnode_Rollback) {
...
@@ -283,9 +279,9 @@ TEST_F(MndTestQnode, 04_Drop_Qnode_Rollback) {
SMCreateQnodeReq
*
pReq
=
(
SMCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
SMCreateQnodeReq
*
pReq
=
(
SMCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
if
(
p
Msg
->
code
==
0
)
break
;
if
(
p
Rsp
->
code
==
0
)
break
;
taosMsleep
(
1000
);
taosMsleep
(
1000
);
}
}
...
...
source/dnode/m
gmt
/impl/test/show/CMakeLists.txt
→
source/dnode/m
node
/impl/test/show/CMakeLists.txt
浏览文件 @
96f2aea2
aux_source_directory
(
. SHOW_SRC
)
aux_source_directory
(
. SHOW_SRC
)
add_executable
(
d
node_test_show
${
SHOW_SRC
}
)
add_executable
(
m
node_test_show
${
SHOW_SRC
}
)
target_link_libraries
(
target_link_libraries
(
d
node_test_show
m
node_test_show
PUBLIC sut
PUBLIC sut
)
)
add_test
(
add_test
(
NAME
d
node_test_show
NAME
m
node_test_show
COMMAND
d
node_test_show
COMMAND
m
node_test_show
)
)
source/dnode/m
gmt
/impl/test/show/show.cpp
→
source/dnode/m
node
/impl/test/show/show.cpp
浏览文件 @
96f2aea2
/**
/**
* @file show.cpp
* @file show.cpp
* @author slguan (slguan@taosdata.com)
* @author slguan (slguan@taosdata.com)
* @brief
DNODE module show-msg
tests
* @brief
MNODE module show
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
ndTestShow
:
public
::
testing
::
Test
{
class
M
ndTestShow
:
public
::
testing
::
Test
{
protected:
protected:
static
void
SetUpTestSuite
()
{
test
.
Init
(
"/tmp/
dnode_test_show"
,
9091
);
}
static
void
SetUpTestSuite
()
{
test
.
Init
(
"/tmp/
mnode_test_show"
,
9020
);
}
static
void
TearDownTestSuite
()
{
test
.
Cleanup
();
}
static
void
TearDownTestSuite
()
{
test
.
Cleanup
();
}
static
Testbase
test
;
static
Testbase
test
;
...
@@ -23,45 +23,45 @@ class DndTestShow : public ::testing::Test {
...
@@ -23,45 +23,45 @@ class DndTestShow : public ::testing::Test {
void
TearDown
()
override
{}
void
TearDown
()
override
{}
};
};
Testbase
D
ndTestShow
::
test
;
Testbase
M
ndTestShow
::
test
;
TEST_F
(
D
ndTestShow
,
01
_ShowMsg_InvalidMsgMax
)
{
TEST_F
(
M
ndTestShow
,
01
_ShowMsg_InvalidMsgMax
)
{
int32_t
contLen
=
sizeof
(
SShow
Msg
);
int32_t
contLen
=
sizeof
(
SShow
Req
);
SShow
Msg
*
pReq
=
(
SShowMsg
*
)
rpcMallocCont
(
contLen
);
SShow
Req
*
pReq
=
(
SShowReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
type
=
TSDB_MGMT_TABLE_MAX
;
pReq
->
type
=
TSDB_MGMT_TABLE_MAX
;
strcpy
(
pReq
->
db
,
""
);
strcpy
(
pReq
->
db
,
""
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_SHOW
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_SHOW
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_INVALID_MSG_TYPE
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_INVALID_MSG_TYPE
);
}
}
TEST_F
(
D
ndTestShow
,
02
_ShowMsg_InvalidMsgStart
)
{
TEST_F
(
M
ndTestShow
,
02
_ShowMsg_InvalidMsgStart
)
{
int32_t
contLen
=
sizeof
(
SShow
Msg
);
int32_t
contLen
=
sizeof
(
SShow
Req
);
SShow
Msg
*
pReq
=
(
SShowMsg
*
)
rpcMallocCont
(
sizeof
(
SShowMsg
));
SShow
Req
*
pReq
=
(
SShowReq
*
)
rpcMallocCont
(
sizeof
(
SShowReq
));
pReq
->
type
=
TSDB_MGMT_TABLE_START
;
pReq
->
type
=
TSDB_MGMT_TABLE_START
;
strcpy
(
pReq
->
db
,
""
);
strcpy
(
pReq
->
db
,
""
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_SHOW
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_SHOW
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_INVALID_MSG_TYPE
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_INVALID_MSG_TYPE
);
}
}
TEST_F
(
DndTestShow
,
02
_ShowMsg_Conn
)
{
TEST_F
(
MndTestShow
,
03
_ShowMsg_Conn
)
{
int32_t
contLen
=
sizeof
(
SConnectMsg
);
int32_t
contLen
=
sizeof
(
SConnectMsg
);
SConnectMsg
*
pReq
=
(
SConnectMsg
*
)
rpcMallocCont
(
contLen
);
SConnectMsg
*
pReq
=
(
SConnectMsg
*
)
rpcMallocCont
(
contLen
);
pReq
->
pid
=
htonl
(
1234
);
pReq
->
pid
=
htonl
(
1234
);
strcpy
(
pReq
->
app
,
"
d
node_test_show"
);
strcpy
(
pReq
->
app
,
"
m
node_test_show"
);
strcpy
(
pReq
->
db
,
""
);
strcpy
(
pReq
->
db
,
""
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CONNECT
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CONNECT
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_CONNS
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_CONNS
,
""
);
STableMetaMsg
*
pMeta
=
test
.
GetShowMeta
();
STableMetaMsg
*
pMeta
=
test
.
GetShowMeta
();
EXPECT_STREQ
(
pMeta
->
tbFname
,
"show connections"
);
EXPECT_STREQ
(
pMeta
->
tbFname
,
"show connections"
);
...
@@ -75,7 +75,7 @@ TEST_F(DndTestShow, 02_ShowMsg_Conn) {
...
@@ -75,7 +75,7 @@ TEST_F(DndTestShow, 02_ShowMsg_Conn) {
EXPECT_EQ
(
pMeta
->
tuid
,
0
);
EXPECT_EQ
(
pMeta
->
tuid
,
0
);
EXPECT_EQ
(
pMeta
->
suid
,
0
);
EXPECT_EQ
(
pMeta
->
suid
,
0
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
SRetrieveTableRsp
*
pRetrieveRsp
=
test
.
GetRetrieveRsp
();
SRetrieveTableRsp
*
pRetrieveRsp
=
test
.
GetRetrieveRsp
();
EXPECT_EQ
(
pRetrieveRsp
->
numOfRows
,
1
);
EXPECT_EQ
(
pRetrieveRsp
->
numOfRows
,
1
);
...
@@ -85,3 +85,18 @@ TEST_F(DndTestShow, 02_ShowMsg_Conn) {
...
@@ -85,3 +85,18 @@ TEST_F(DndTestShow, 02_ShowMsg_Conn) {
EXPECT_EQ
(
pRetrieveRsp
->
compressed
,
0
);
EXPECT_EQ
(
pRetrieveRsp
->
compressed
,
0
);
EXPECT_EQ
(
pRetrieveRsp
->
compLen
,
0
);
EXPECT_EQ
(
pRetrieveRsp
->
compLen
,
0
);
}
}
TEST_F
(
MndTestShow
,
04
_ShowMsg_Cluster
)
{
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_CLUSTER
,
""
);
CHECK_META
(
"show cluster"
,
3
);
CHECK_SCHEMA
(
0
,
TSDB_DATA_TYPE_BIGINT
,
8
,
"id"
);
CHECK_SCHEMA
(
1
,
TSDB_DATA_TYPE_BINARY
,
TSDB_CLUSTER_ID_LEN
+
VARSTR_HEADER_SIZE
,
"name"
);
CHECK_SCHEMA
(
2
,
TSDB_DATA_TYPE_TIMESTAMP
,
8
,
"create_time"
);
test
.
SendShowRetrieveReq
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
IgnoreInt64
();
IgnoreBinary
(
TSDB_CLUSTER_ID_LEN
);
CheckTimestamp
();
}
\ No newline at end of file
source/dnode/mnode/impl/test/snode/snode.cpp
浏览文件 @
96f2aea2
...
@@ -39,14 +39,14 @@ Testbase MndTestSnode::test;
...
@@ -39,14 +39,14 @@ Testbase MndTestSnode::test;
TestServer
MndTestSnode
::
server2
;
TestServer
MndTestSnode
::
server2
;
TEST_F
(
MndTestSnode
,
01
_Show_Snode
)
{
TEST_F
(
MndTestSnode
,
01
_Show_Snode
)
{
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_SNODE
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_SNODE
,
""
);
CHECK_META
(
"show snodes"
,
3
);
CHECK_META
(
"show snodes"
,
3
);
CHECK_SCHEMA
(
0
,
TSDB_DATA_TYPE_SMALLINT
,
2
,
"id"
);
CHECK_SCHEMA
(
0
,
TSDB_DATA_TYPE_SMALLINT
,
2
,
"id"
);
CHECK_SCHEMA
(
1
,
TSDB_DATA_TYPE_BINARY
,
TSDB_EP_LEN
+
VARSTR_HEADER_SIZE
,
"endpoint"
);
CHECK_SCHEMA
(
1
,
TSDB_DATA_TYPE_BINARY
,
TSDB_EP_LEN
+
VARSTR_HEADER_SIZE
,
"endpoint"
);
CHECK_SCHEMA
(
2
,
TSDB_DATA_TYPE_TIMESTAMP
,
8
,
"create_time"
);
CHECK_SCHEMA
(
2
,
TSDB_DATA_TYPE_TIMESTAMP
,
8
,
"create_time"
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
0
);
EXPECT_EQ
(
test
.
GetShowRows
(),
0
);
}
}
...
@@ -57,9 +57,9 @@ TEST_F(MndTestSnode, 02_Create_Snode) {
...
@@ -57,9 +57,9 @@ TEST_F(MndTestSnode, 02_Create_Snode) {
SMCreateSnodeReq
*
pReq
=
(
SMCreateSnodeReq
*
)
rpcMallocCont
(
contLen
);
SMCreateSnodeReq
*
pReq
=
(
SMCreateSnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_DNODE_NOT_EXIST
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_DNODE_NOT_EXIST
);
}
}
{
{
...
@@ -68,13 +68,13 @@ TEST_F(MndTestSnode, 02_Create_Snode) {
...
@@ -68,13 +68,13 @@ TEST_F(MndTestSnode, 02_Create_Snode) {
SMCreateSnodeReq
*
pReq
=
(
SMCreateSnodeReq
*
)
rpcMallocCont
(
contLen
);
SMCreateSnodeReq
*
pReq
=
(
SMCreateSnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_SNODE
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_SNODE
,
""
);
CHECK_META
(
"show snodes"
,
3
);
CHECK_META
(
"show snodes"
,
3
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckInt16
(
1
);
CheckInt16
(
1
);
...
@@ -88,9 +88,9 @@ TEST_F(MndTestSnode, 02_Create_Snode) {
...
@@ -88,9 +88,9 @@ TEST_F(MndTestSnode, 02_Create_Snode) {
SMCreateSnodeReq
*
pReq
=
(
SMCreateSnodeReq
*
)
rpcMallocCont
(
contLen
);
SMCreateSnodeReq
*
pReq
=
(
SMCreateSnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_SNODE_ALREADY_EXIST
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_SNODE_ALREADY_EXIST
);
}
}
}
}
...
@@ -102,13 +102,13 @@ TEST_F(MndTestSnode, 03_Drop_Snode) {
...
@@ -102,13 +102,13 @@ TEST_F(MndTestSnode, 03_Drop_Snode) {
strcpy
(
pReq
->
fqdn
,
"localhost"
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
pReq
->
port
=
htonl
(
9017
);
pReq
->
port
=
htonl
(
9017
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
taosMsleep
(
1300
);
taosMsleep
(
1300
);
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_DNODE
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_DNODE
,
""
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
}
}
...
@@ -118,12 +118,12 @@ TEST_F(MndTestSnode, 03_Drop_Snode) {
...
@@ -118,12 +118,12 @@ TEST_F(MndTestSnode, 03_Drop_Snode) {
SMCreateSnodeReq
*
pReq
=
(
SMCreateSnodeReq
*
)
rpcMallocCont
(
contLen
);
SMCreateSnodeReq
*
pReq
=
(
SMCreateSnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_SNODE
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_SNODE
,
""
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
CheckInt16
(
1
);
CheckInt16
(
1
);
...
@@ -140,12 +140,12 @@ TEST_F(MndTestSnode, 03_Drop_Snode) {
...
@@ -140,12 +140,12 @@ TEST_F(MndTestSnode, 03_Drop_Snode) {
SMDropSnodeReq
*
pReq
=
(
SMDropSnodeReq
*
)
rpcMallocCont
(
contLen
);
SMDropSnodeReq
*
pReq
=
(
SMDropSnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_DROP_SNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_DROP_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_SNODE
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_SNODE
,
""
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckInt16
(
1
);
CheckInt16
(
1
);
...
@@ -159,9 +159,9 @@ TEST_F(MndTestSnode, 03_Drop_Snode) {
...
@@ -159,9 +159,9 @@ TEST_F(MndTestSnode, 03_Drop_Snode) {
SMDropSnodeReq
*
pReq
=
(
SMDropSnodeReq
*
)
rpcMallocCont
(
contLen
);
SMDropSnodeReq
*
pReq
=
(
SMDropSnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_DROP_SNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_DROP_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_SNODE_NOT_EXIST
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_SNODE_NOT_EXIST
);
}
}
}
}
...
@@ -174,9 +174,9 @@ TEST_F(MndTestSnode, 03_Create_Snode_Rollback) {
...
@@ -174,9 +174,9 @@ TEST_F(MndTestSnode, 03_Create_Snode_Rollback) {
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
server2
.
Stop
();
server2
.
Stop
();
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_RPC_NETWORK_UNAVAIL
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_RPC_NETWORK_UNAVAIL
);
}
}
{
{
...
@@ -186,10 +186,9 @@ TEST_F(MndTestSnode, 03_Create_Snode_Rollback) {
...
@@ -186,10 +186,9 @@ TEST_F(MndTestSnode, 03_Create_Snode_Rollback) {
SMCreateSnodeReq
*
pReq
=
(
SMCreateSnodeReq
*
)
rpcMallocCont
(
contLen
);
SMCreateSnodeReq
*
pReq
=
(
SMCreateSnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
server2
.
Stop
();
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_SDB_OBJ_CREATING
);
ASSERT_EQ
(
pMsg
->
code
,
TSDB_CODE_SDB_OBJ_CREATING
);
}
}
{
{
...
@@ -199,10 +198,9 @@ TEST_F(MndTestSnode, 03_Create_Snode_Rollback) {
...
@@ -199,10 +198,9 @@ TEST_F(MndTestSnode, 03_Create_Snode_Rollback) {
SMDropSnodeReq
*
pReq
=
(
SMDropSnodeReq
*
)
rpcMallocCont
(
contLen
);
SMDropSnodeReq
*
pReq
=
(
SMDropSnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
server2
.
Stop
();
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_SNODE
,
pReq
,
contLen
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_DROP_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_SDB_OBJ_CREATING
);
ASSERT_EQ
(
pMsg
->
code
,
TSDB_CODE_SDB_OBJ_CREATING
);
}
}
{
{
...
@@ -211,7 +209,7 @@ TEST_F(MndTestSnode, 03_Create_Snode_Rollback) {
...
@@ -211,7 +209,7 @@ TEST_F(MndTestSnode, 03_Create_Snode_Rollback) {
taosMsleep
(
1000
);
taosMsleep
(
1000
);
int32_t
retry
=
0
;
int32_t
retry
=
0
;
int32_t
retryMax
=
1
0
;
int32_t
retryMax
=
2
0
;
for
(
retry
=
0
;
retry
<
retryMax
;
retry
++
)
{
for
(
retry
=
0
;
retry
<
retryMax
;
retry
++
)
{
int32_t
contLen
=
sizeof
(
SMCreateSnodeReq
);
int32_t
contLen
=
sizeof
(
SMCreateSnodeReq
);
...
@@ -219,9 +217,9 @@ TEST_F(MndTestSnode, 03_Create_Snode_Rollback) {
...
@@ -219,9 +217,9 @@ TEST_F(MndTestSnode, 03_Create_Snode_Rollback) {
SMCreateSnodeReq
*
pReq
=
(
SMCreateSnodeReq
*
)
rpcMallocCont
(
contLen
);
SMCreateSnodeReq
*
pReq
=
(
SMCreateSnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
if
(
p
Msg
->
code
==
0
)
break
;
if
(
p
Rsp
->
code
==
0
)
break
;
taosMsleep
(
1000
);
taosMsleep
(
1000
);
}
}
...
@@ -238,9 +236,9 @@ TEST_F(MndTestSnode, 04_Drop_Snode_Rollback) {
...
@@ -238,9 +236,9 @@ TEST_F(MndTestSnode, 04_Drop_Snode_Rollback) {
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
server2
.
Stop
();
server2
.
Stop
();
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_DROP_SNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_DROP_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_RPC_NETWORK_UNAVAIL
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_RPC_NETWORK_UNAVAIL
);
}
}
{
{
...
@@ -250,10 +248,9 @@ TEST_F(MndTestSnode, 04_Drop_Snode_Rollback) {
...
@@ -250,10 +248,9 @@ TEST_F(MndTestSnode, 04_Drop_Snode_Rollback) {
SMCreateSnodeReq
*
pReq
=
(
SMCreateSnodeReq
*
)
rpcMallocCont
(
contLen
);
SMCreateSnodeReq
*
pReq
=
(
SMCreateSnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
server2
.
Stop
();
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_SDB_OBJ_DROPPING
);
ASSERT_EQ
(
pMsg
->
code
,
TSDB_CODE_SDB_OBJ_DROPPING
);
}
}
{
{
...
@@ -263,10 +260,9 @@ TEST_F(MndTestSnode, 04_Drop_Snode_Rollback) {
...
@@ -263,10 +260,9 @@ TEST_F(MndTestSnode, 04_Drop_Snode_Rollback) {
SMDropSnodeReq
*
pReq
=
(
SMDropSnodeReq
*
)
rpcMallocCont
(
contLen
);
SMDropSnodeReq
*
pReq
=
(
SMDropSnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
server2
.
Stop
();
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_SNODE
,
pReq
,
contLen
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_DROP_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_SDB_OBJ_DROPPING
);
ASSERT_EQ
(
pMsg
->
code
,
TSDB_CODE_SDB_OBJ_DROPPING
);
}
}
{
{
...
@@ -275,7 +271,7 @@ TEST_F(MndTestSnode, 04_Drop_Snode_Rollback) {
...
@@ -275,7 +271,7 @@ TEST_F(MndTestSnode, 04_Drop_Snode_Rollback) {
taosMsleep
(
1000
);
taosMsleep
(
1000
);
int32_t
retry
=
0
;
int32_t
retry
=
0
;
int32_t
retryMax
=
1
0
;
int32_t
retryMax
=
2
0
;
for
(
retry
=
0
;
retry
<
retryMax
;
retry
++
)
{
for
(
retry
=
0
;
retry
<
retryMax
;
retry
++
)
{
int32_t
contLen
=
sizeof
(
SMCreateSnodeReq
);
int32_t
contLen
=
sizeof
(
SMCreateSnodeReq
);
...
@@ -283,9 +279,9 @@ TEST_F(MndTestSnode, 04_Drop_Snode_Rollback) {
...
@@ -283,9 +279,9 @@ TEST_F(MndTestSnode, 04_Drop_Snode_Rollback) {
SMCreateSnodeReq
*
pReq
=
(
SMCreateSnodeReq
*
)
rpcMallocCont
(
contLen
);
SMCreateSnodeReq
*
pReq
=
(
SMCreateSnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
if
(
p
Msg
->
code
==
0
)
break
;
if
(
p
Rsp
->
code
==
0
)
break
;
taosMsleep
(
1000
);
taosMsleep
(
1000
);
}
}
...
...
source/dnode/mnode/impl/test/trans/trans.cpp
浏览文件 @
96f2aea2
...
@@ -10,12 +10,21 @@
...
@@ -10,12 +10,21 @@
*/
*/
#include "sut.h"
#include "sut.h"
#include "os.h"
class
MndTestTrans
:
public
::
testing
::
Test
{
class
MndTestTrans
:
public
::
testing
::
Test
{
protected:
protected:
static
void
SetUpTestSuite
()
{
test
.
Init
(
"/tmp/mnode_test_trans"
,
9013
);
}
static
void
SetUpTestSuite
()
{
static
void
TearDownTestSuite
()
{
test
.
Cleanup
();
}
test
.
Init
(
"/tmp/mnode_test_trans"
,
9013
);
const
char
*
fqdn
=
"localhost"
;
const
char
*
firstEp
=
"localhost:9013"
;
server2
.
Start
(
"/tmp/mnode_test_trans2"
,
fqdn
,
9020
,
firstEp
);
}
static
void
TearDownTestSuite
()
{
server2
.
Stop
();
test
.
Cleanup
();
}
static
void
KillThenRestartServer
()
{
static
void
KillThenRestartServer
()
{
char
file
[
PATH_MAX
]
=
"/tmp/mnode_test_trans/mnode/data/sdb.data"
;
char
file
[
PATH_MAX
]
=
"/tmp/mnode_test_trans/mnode/data/sdb.data"
;
FileFd
fd
=
taosOpenFileRead
(
file
);
FileFd
fd
=
taosOpenFileRead
(
file
);
...
@@ -41,14 +50,16 @@ class MndTestTrans : public ::testing::Test {
...
@@ -41,14 +50,16 @@ class MndTestTrans : public ::testing::Test {
test
.
ServerStart
();
test
.
ServerStart
();
}
}
static
Testbase
test
;
static
Testbase
test
;
static
TestServer
server2
;
public:
public:
void
SetUp
()
override
{}
void
SetUp
()
override
{}
void
TearDown
()
override
{}
void
TearDown
()
override
{}
};
};
Testbase
MndTestTrans
::
test
;
Testbase
MndTestTrans
::
test
;
TestServer
MndTestTrans
::
server2
;
TEST_F
(
MndTestTrans
,
01
_Create_User_Crash
)
{
TEST_F
(
MndTestTrans
,
01
_Create_User_Crash
)
{
{
{
...
@@ -58,21 +69,21 @@ TEST_F(MndTestTrans, 01_Create_User_Crash) {
...
@@ -58,21 +69,21 @@ TEST_F(MndTestTrans, 01_Create_User_Crash) {
strcpy
(
pReq
->
user
,
"u1"
);
strcpy
(
pReq
->
user
,
"u1"
);
strcpy
(
pReq
->
pass
,
"p1"
);
strcpy
(
pReq
->
pass
,
"p1"
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
}
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_USER
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_USER
,
""
);
CHECK_META
(
"show users"
,
4
);
CHECK_META
(
"show users"
,
4
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
KillThenRestartServer
();
KillThenRestartServer
();
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_USER
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_USER
,
""
);
CHECK_META
(
"show users"
,
4
);
CHECK_META
(
"show users"
,
4
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
CheckBinary
(
"u1"
,
TSDB_USER_LEN
);
CheckBinary
(
"u1"
,
TSDB_USER_LEN
);
...
@@ -83,4 +94,98 @@ TEST_F(MndTestTrans, 01_Create_User_Crash) {
...
@@ -83,4 +94,98 @@ TEST_F(MndTestTrans, 01_Create_User_Crash) {
CheckTimestamp
();
CheckTimestamp
();
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
}
TEST_F
(
MndTestTrans
,
02
_Create_Qnode1_Crash
)
{
{
int32_t
contLen
=
sizeof
(
SMCreateQnodeReq
);
SMCreateQnodeReq
*
pReq
=
(
SMCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_QNODE
,
""
);
CHECK_META
(
"show qnodes"
,
3
);
test
.
SendShowRetrieveReq
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
}
KillThenRestartServer
();
{
int32_t
contLen
=
sizeof
(
SMCreateQnodeReq
);
SMCreateQnodeReq
*
pReq
=
(
SMCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_QNODE_ALREADY_EXIST
);
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_QNODE
,
""
);
CHECK_META
(
"show qnodes"
,
3
);
test
.
SendShowRetrieveReq
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
}
}
TEST_F
(
MndTestTrans
,
03
_Create_Qnode2_Crash
)
{
{
int32_t
contLen
=
sizeof
(
SCreateDnodeMsg
);
SCreateDnodeMsg
*
pReq
=
(
SCreateDnodeMsg
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
pReq
->
port
=
htonl
(
9020
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
taosMsleep
(
1300
);
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_DNODE
,
""
);
test
.
SendShowRetrieveReq
();
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
}
{
int32_t
contLen
=
sizeof
(
SMCreateQnodeReq
);
SMCreateQnodeReq
*
pReq
=
(
SMCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
server2
.
Stop
();
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_RPC_NETWORK_UNAVAIL
);
}
KillThenRestartServer
();
server2
.
DoStart
();
{
int32_t
retry
=
0
;
int32_t
retryMax
=
20
;
for
(
retry
=
0
;
retry
<
retryMax
;
retry
++
)
{
int32_t
contLen
=
sizeof
(
SMCreateQnodeReq
);
SMCreateQnodeReq
*
pReq
=
(
SMCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
if
(
pRsp
->
code
==
0
)
break
;
taosMsleep
(
1000
);
}
ASSERT_NE
(
retry
,
retryMax
);
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_QNODE
,
""
);
CHECK_META
(
"show qnodes"
,
3
);
test
.
SendShowRetrieveReq
();
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
}
}
}
\ No newline at end of file
source/dnode/mnode/impl/test/user/user.cpp
浏览文件 @
96f2aea2
...
@@ -26,7 +26,7 @@ class MndTestUser : public ::testing::Test {
...
@@ -26,7 +26,7 @@ class MndTestUser : public ::testing::Test {
Testbase
MndTestUser
::
test
;
Testbase
MndTestUser
::
test
;
TEST_F
(
MndTestUser
,
01
_Show_User
)
{
TEST_F
(
MndTestUser
,
01
_Show_User
)
{
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_USER
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_USER
,
""
);
CHECK_META
(
"show users"
,
4
);
CHECK_META
(
"show users"
,
4
);
CHECK_SCHEMA
(
0
,
TSDB_DATA_TYPE_BINARY
,
TSDB_USER_LEN
+
VARSTR_HEADER_SIZE
,
"name"
);
CHECK_SCHEMA
(
0
,
TSDB_DATA_TYPE_BINARY
,
TSDB_USER_LEN
+
VARSTR_HEADER_SIZE
,
"name"
);
...
@@ -34,7 +34,7 @@ TEST_F(MndTestUser, 01_Show_User) {
...
@@ -34,7 +34,7 @@ TEST_F(MndTestUser, 01_Show_User) {
CHECK_SCHEMA
(
2
,
TSDB_DATA_TYPE_TIMESTAMP
,
8
,
"create_time"
);
CHECK_SCHEMA
(
2
,
TSDB_DATA_TYPE_TIMESTAMP
,
8
,
"create_time"
);
CHECK_SCHEMA
(
3
,
TSDB_DATA_TYPE_BINARY
,
TSDB_USER_LEN
+
VARSTR_HEADER_SIZE
,
"account"
);
CHECK_SCHEMA
(
3
,
TSDB_DATA_TYPE_BINARY
,
TSDB_USER_LEN
+
VARSTR_HEADER_SIZE
,
"account"
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
...
@@ -51,9 +51,9 @@ TEST_F(MndTestUser, 02_Create_User) {
...
@@ -51,9 +51,9 @@ TEST_F(MndTestUser, 02_Create_User) {
strcpy
(
pReq
->
user
,
""
);
strcpy
(
pReq
->
user
,
""
);
strcpy
(
pReq
->
pass
,
"p1"
);
strcpy
(
pReq
->
pass
,
"p1"
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_INVALID_USER_FORMAT
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_INVALID_USER_FORMAT
);
}
}
{
{
...
@@ -63,9 +63,9 @@ TEST_F(MndTestUser, 02_Create_User) {
...
@@ -63,9 +63,9 @@ TEST_F(MndTestUser, 02_Create_User) {
strcpy
(
pReq
->
user
,
"u1"
);
strcpy
(
pReq
->
user
,
"u1"
);
strcpy
(
pReq
->
pass
,
""
);
strcpy
(
pReq
->
pass
,
""
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_INVALID_PASS_FORMAT
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_INVALID_PASS_FORMAT
);
}
}
{
{
...
@@ -75,9 +75,9 @@ TEST_F(MndTestUser, 02_Create_User) {
...
@@ -75,9 +75,9 @@ TEST_F(MndTestUser, 02_Create_User) {
strcpy
(
pReq
->
user
,
"root"
);
strcpy
(
pReq
->
user
,
"root"
);
strcpy
(
pReq
->
pass
,
"1"
);
strcpy
(
pReq
->
pass
,
"1"
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_USER_ALREADY_EXIST
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_USER_ALREADY_EXIST
);
}
}
{
{
...
@@ -87,15 +87,15 @@ TEST_F(MndTestUser, 02_Create_User) {
...
@@ -87,15 +87,15 @@ TEST_F(MndTestUser, 02_Create_User) {
strcpy
(
pReq
->
user
,
"u1"
);
strcpy
(
pReq
->
user
,
"u1"
);
strcpy
(
pReq
->
pass
,
"p1"
);
strcpy
(
pReq
->
pass
,
"p1"
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
}
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_USER
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_USER
,
""
);
CHECK_META
(
"show users"
,
4
);
CHECK_META
(
"show users"
,
4
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
}
}
...
@@ -107,9 +107,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
...
@@ -107,9 +107,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
strcpy
(
pReq
->
user
,
""
);
strcpy
(
pReq
->
user
,
""
);
strcpy
(
pReq
->
pass
,
"p1"
);
strcpy
(
pReq
->
pass
,
"p1"
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_INVALID_USER_FORMAT
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_INVALID_USER_FORMAT
);
}
}
{
{
...
@@ -119,9 +119,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
...
@@ -119,9 +119,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
strcpy
(
pReq
->
user
,
"u1"
);
strcpy
(
pReq
->
user
,
"u1"
);
strcpy
(
pReq
->
pass
,
""
);
strcpy
(
pReq
->
pass
,
""
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_INVALID_PASS_FORMAT
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_INVALID_PASS_FORMAT
);
}
}
{
{
...
@@ -131,9 +131,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
...
@@ -131,9 +131,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
strcpy
(
pReq
->
user
,
"u4"
);
strcpy
(
pReq
->
user
,
"u4"
);
strcpy
(
pReq
->
pass
,
"1"
);
strcpy
(
pReq
->
pass
,
"1"
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_USER_NOT_EXIST
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_USER_NOT_EXIST
);
}
}
{
{
...
@@ -143,9 +143,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
...
@@ -143,9 +143,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
strcpy
(
pReq
->
user
,
"u1"
);
strcpy
(
pReq
->
user
,
"u1"
);
strcpy
(
pReq
->
pass
,
"1"
);
strcpy
(
pReq
->
pass
,
"1"
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
}
}
}
...
@@ -156,9 +156,9 @@ TEST_F(MndTestUser, 04_Drop_User) {
...
@@ -156,9 +156,9 @@ TEST_F(MndTestUser, 04_Drop_User) {
SDropUserReq
*
pReq
=
(
SDropUserReq
*
)
rpcMallocCont
(
contLen
);
SDropUserReq
*
pReq
=
(
SDropUserReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
user
,
""
);
strcpy
(
pReq
->
user
,
""
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_DROP_USER
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_DROP_USER
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_INVALID_USER_FORMAT
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_INVALID_USER_FORMAT
);
}
}
{
{
...
@@ -167,9 +167,9 @@ TEST_F(MndTestUser, 04_Drop_User) {
...
@@ -167,9 +167,9 @@ TEST_F(MndTestUser, 04_Drop_User) {
SDropUserReq
*
pReq
=
(
SDropUserReq
*
)
rpcMallocCont
(
contLen
);
SDropUserReq
*
pReq
=
(
SDropUserReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
user
,
"u4"
);
strcpy
(
pReq
->
user
,
"u4"
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_DROP_USER
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_DROP_USER
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_USER_NOT_EXIST
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_USER_NOT_EXIST
);
}
}
{
{
...
@@ -178,15 +178,15 @@ TEST_F(MndTestUser, 04_Drop_User) {
...
@@ -178,15 +178,15 @@ TEST_F(MndTestUser, 04_Drop_User) {
SDropUserReq
*
pReq
=
(
SDropUserReq
*
)
rpcMallocCont
(
contLen
);
SDropUserReq
*
pReq
=
(
SDropUserReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
user
,
"u1"
);
strcpy
(
pReq
->
user
,
"u1"
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_DROP_USER
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_DROP_USER
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
}
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_USER
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_USER
,
""
);
CHECK_META
(
"show users"
,
4
);
CHECK_META
(
"show users"
,
4
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
}
}
...
@@ -198,9 +198,9 @@ TEST_F(MndTestUser, 05_Create_Drop_Alter_User) {
...
@@ -198,9 +198,9 @@ TEST_F(MndTestUser, 05_Create_Drop_Alter_User) {
strcpy
(
pReq
->
user
,
"u1"
);
strcpy
(
pReq
->
user
,
"u1"
);
strcpy
(
pReq
->
pass
,
"p1"
);
strcpy
(
pReq
->
pass
,
"p1"
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
}
{
{
...
@@ -210,15 +210,15 @@ TEST_F(MndTestUser, 05_Create_Drop_Alter_User) {
...
@@ -210,15 +210,15 @@ TEST_F(MndTestUser, 05_Create_Drop_Alter_User) {
strcpy
(
pReq
->
user
,
"u2"
);
strcpy
(
pReq
->
user
,
"u2"
);
strcpy
(
pReq
->
pass
,
"p2"
);
strcpy
(
pReq
->
pass
,
"p2"
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
}
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_USER
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_USER
,
""
);
CHECK_META
(
"show users"
,
4
);
CHECK_META
(
"show users"
,
4
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
3
);
EXPECT_EQ
(
test
.
GetShowRows
(),
3
);
CheckBinary
(
"u1"
,
TSDB_USER_LEN
);
CheckBinary
(
"u1"
,
TSDB_USER_LEN
);
...
@@ -241,15 +241,15 @@ TEST_F(MndTestUser, 05_Create_Drop_Alter_User) {
...
@@ -241,15 +241,15 @@ TEST_F(MndTestUser, 05_Create_Drop_Alter_User) {
strcpy
(
pReq
->
user
,
"u1"
);
strcpy
(
pReq
->
user
,
"u1"
);
strcpy
(
pReq
->
pass
,
"p2"
);
strcpy
(
pReq
->
pass
,
"p2"
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
}
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_USER
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_USER
,
""
);
CHECK_META
(
"show users"
,
4
);
CHECK_META
(
"show users"
,
4
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
3
);
EXPECT_EQ
(
test
.
GetShowRows
(),
3
);
CheckBinary
(
"u1"
,
TSDB_USER_LEN
);
CheckBinary
(
"u1"
,
TSDB_USER_LEN
);
...
@@ -271,15 +271,15 @@ TEST_F(MndTestUser, 05_Create_Drop_Alter_User) {
...
@@ -271,15 +271,15 @@ TEST_F(MndTestUser, 05_Create_Drop_Alter_User) {
SDropUserReq
*
pReq
=
(
SDropUserReq
*
)
rpcMallocCont
(
contLen
);
SDropUserReq
*
pReq
=
(
SDropUserReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
user
,
"u1"
);
strcpy
(
pReq
->
user
,
"u1"
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_DROP_USER
,
pReq
,
contLen
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_DROP_USER
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
}
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_USER
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_USER
,
""
);
CHECK_META
(
"show users"
,
4
);
CHECK_META
(
"show users"
,
4
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
...
@@ -294,10 +294,10 @@ TEST_F(MndTestUser, 05_Create_Drop_Alter_User) {
...
@@ -294,10 +294,10 @@ TEST_F(MndTestUser, 05_Create_Drop_Alter_User) {
// restart
// restart
test
.
Restart
();
test
.
Restart
();
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_USER
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_USER
,
""
);
CHECK_META
(
"show users"
,
4
);
CHECK_META
(
"show users"
,
4
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
...
...
source/libs/index/inc/index_cache.h
浏览文件 @
96f2aea2
...
@@ -40,11 +40,12 @@ typedef struct IndexCache {
...
@@ -40,11 +40,12 @@ typedef struct IndexCache {
SIndex
*
index
;
SIndex
*
index
;
char
*
colName
;
char
*
colName
;
int32_t
version
;
int32_t
version
;
int
32_t
nTer
m
;
int
64_t
occupiedMe
m
;
int8_t
type
;
int8_t
type
;
uint64_t
suid
;
uint64_t
suid
;
pthread_mutex_t
mtx
;
pthread_mutex_t
mtx
;
pthread_cond_t
finished
;
}
IndexCache
;
}
IndexCache
;
#define CACHE_VERSION(cache) atomic_load_32(&cache->version)
#define CACHE_VERSION(cache) atomic_load_32(&cache->version)
...
...
source/libs/index/src/index.c
浏览文件 @
96f2aea2
...
@@ -399,6 +399,8 @@ int indexFlushCacheTFile(SIndex* sIdx, void* cache) {
...
@@ -399,6 +399,8 @@ int indexFlushCacheTFile(SIndex* sIdx, void* cache) {
if
(
sIdx
==
NULL
)
{
return
-
1
;
}
if
(
sIdx
==
NULL
)
{
return
-
1
;
}
indexInfo
(
"suid %"
PRIu64
" merge cache into tindex"
,
sIdx
->
suid
);
indexInfo
(
"suid %"
PRIu64
" merge cache into tindex"
,
sIdx
->
suid
);
int64_t
st
=
taosGetTimestampUs
();
IndexCache
*
pCache
=
(
IndexCache
*
)
cache
;
IndexCache
*
pCache
=
(
IndexCache
*
)
cache
;
TFileReader
*
pReader
=
tfileGetReaderByCol
(
sIdx
->
tindex
,
pCache
->
suid
,
pCache
->
colName
);
TFileReader
*
pReader
=
tfileGetReaderByCol
(
sIdx
->
tindex
,
pCache
->
suid
,
pCache
->
colName
);
if
(
pReader
==
NULL
)
{
indexWarn
(
"empty tfile reader found"
);
}
if
(
pReader
==
NULL
)
{
indexWarn
(
"empty tfile reader found"
);
}
...
@@ -458,6 +460,7 @@ int indexFlushCacheTFile(SIndex* sIdx, void* cache) {
...
@@ -458,6 +460,7 @@ int indexFlushCacheTFile(SIndex* sIdx, void* cache) {
}
}
int
ret
=
indexGenTFile
(
sIdx
,
pCache
,
result
);
int
ret
=
indexGenTFile
(
sIdx
,
pCache
,
result
);
indexDestroyTempResult
(
result
);
indexDestroyTempResult
(
result
);
indexCacheDestroyImm
(
pCache
);
indexCacheDestroyImm
(
pCache
);
indexCacheIteratorDestroy
(
cacheIter
);
indexCacheIteratorDestroy
(
cacheIter
);
...
@@ -465,7 +468,14 @@ int indexFlushCacheTFile(SIndex* sIdx, void* cache) {
...
@@ -465,7 +468,14 @@ int indexFlushCacheTFile(SIndex* sIdx, void* cache) {
tfileReaderUnRef
(
pReader
);
tfileReaderUnRef
(
pReader
);
indexCacheUnRef
(
pCache
);
indexCacheUnRef
(
pCache
);
return
0
;
int64_t
cost
=
taosGetTimestampUs
()
-
st
;
if
(
ret
!=
0
)
{
indexError
(
"failed to merge, time cost: %"
PRId64
"ms"
,
cost
/
1000
);
}
else
{
indexInfo
(
"success to merge , time cost: %"
PRId64
"ms"
,
cost
/
1000
);
}
return
ret
;
}
}
void
iterateValueDestroy
(
IterateValue
*
value
,
bool
destroy
)
{
void
iterateValueDestroy
(
IterateValue
*
value
,
bool
destroy
)
{
if
(
destroy
)
{
if
(
destroy
)
{
...
@@ -506,7 +516,10 @@ static int indexGenTFile(SIndex* sIdx, IndexCache* cache, SArray* batch) {
...
@@ -506,7 +516,10 @@ static int indexGenTFile(SIndex* sIdx, IndexCache* cache, SArray* batch) {
pthread_mutex_unlock
(
&
sIdx
->
mtx
);
pthread_mutex_unlock
(
&
sIdx
->
mtx
);
return
ret
;
return
ret
;
END:
END:
tfileWriterClose
(
tw
);
if
(
tw
!=
NULL
)
{
writerCtxDestroy
(
tw
->
ctx
,
true
);
free
(
tw
);
}
return
-
1
;
return
-
1
;
}
}
...
...
source/libs/index/src/index_cache.c
浏览文件 @
96f2aea2
此差异已折叠。
点击以展开。
source/libs/index/src/index_tfile.c
浏览文件 @
96f2aea2
...
@@ -346,9 +346,6 @@ int indexTFilePut(void* tfile, SIndexTerm* term, uint64_t uid) {
...
@@ -346,9 +346,6 @@ int indexTFilePut(void* tfile, SIndexTerm* term, uint64_t uid) {
}
}
static
bool
tfileIteratorNext
(
Iterate
*
iiter
)
{
static
bool
tfileIteratorNext
(
Iterate
*
iiter
)
{
IterateValue
*
iv
=
&
iiter
->
val
;
IterateValue
*
iv
=
&
iiter
->
val
;
if
(
iv
->
colVal
!=
NULL
&&
iv
->
val
!=
NULL
)
{
// indexError("value in fst: colVal: %s, size: %d", iv->colVal, (int)taosArrayGetSize(iv->val));
}
iterateValueDestroy
(
iv
,
false
);
iterateValueDestroy
(
iv
,
false
);
char
*
colVal
=
NULL
;
char
*
colVal
=
NULL
;
...
...
source/libs/index/test/indexTests.cc
浏览文件 @
96f2aea2
此差异已折叠。
点击以展开。
source/libs/parser/inc/astToMsg.h
浏览文件 @
96f2aea2
此差异已折叠。
点击以展开。
source/libs/parser/src/astToMsg.c
浏览文件 @
96f2aea2
此差异已折叠。
点击以展开。
source/libs/parser/src/dCDAstProcess.c
浏览文件 @
96f2aea2
此差异已折叠。
点击以展开。
source/libs/scheduler/inc/schedulerInt.h
浏览文件 @
96f2aea2
此差异已折叠。
点击以展开。
source/libs/scheduler/src/scheduler.c
浏览文件 @
96f2aea2
此差异已折叠。
点击以展开。
source/libs/wal/src/walMeta.c
浏览文件 @
96f2aea2
此差异已折叠。
点击以展开。
source/libs/wal/src/walRead.c
浏览文件 @
96f2aea2
此差异已折叠。
点击以展开。
source/libs/wal/src/walSeek.c
浏览文件 @
96f2aea2
此差异已折叠。
点击以展开。
source/libs/wal/src/walWrite.c
浏览文件 @
96f2aea2
此差异已折叠。
点击以展开。
src/client/src/tscServer.c
浏览文件 @
96f2aea2
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录