Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
2c0f1e77
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1193
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看板
未验证
提交
2c0f1e77
编写于
2月 12, 2022
作者:
S
Shengliang Guan
提交者:
GitHub
2月 12, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #10223 from taosdata/feature/privilege
refact user msg decoder
上级
9b7f20a4
b8bda48a
变更
19
显示空白变更内容
内联
并排
Showing
19 changed file
with
1061 addition
and
596 deletion
+1061
-596
include/common/tmsg.h
include/common/tmsg.h
+29
-20
include/util/tdef.h
include/util/tdef.h
+1
-0
source/common/src/tmsg.c
source/common/src/tmsg.c
+257
-76
source/dnode/mnode/impl/inc/mndAuth.h
source/dnode/mnode/impl/inc/mndAuth.h
+4
-0
source/dnode/mnode/impl/src/mndAuth.c
source/dnode/mnode/impl/src/mndAuth.c
+14
-1
source/dnode/mnode/impl/src/mndBnode.c
source/dnode/mnode/impl/src/mndBnode.c
+74
-37
source/dnode/mnode/impl/src/mndDnode.c
source/dnode/mnode/impl/src/mndDnode.c
+73
-32
source/dnode/mnode/impl/src/mndQnode.c
source/dnode/mnode/impl/src/mndQnode.c
+73
-34
source/dnode/mnode/impl/src/mndSnode.c
source/dnode/mnode/impl/src/mndSnode.c
+73
-34
source/dnode/mnode/impl/src/mndUser.c
source/dnode/mnode/impl/src/mndUser.c
+6
-7
source/dnode/mnode/impl/test/bnode/bnode.cpp
source/dnode/mnode/impl/test/bnode/bnode.cpp
+76
-46
source/dnode/mnode/impl/test/dnode/dnode.cpp
source/dnode/mnode/impl/test/dnode/dnode.cpp
+68
-44
source/dnode/mnode/impl/test/mnode/mnode.cpp
source/dnode/mnode/impl/test/mnode/mnode.cpp
+6
-4
source/dnode/mnode/impl/test/qnode/qnode.cpp
source/dnode/mnode/impl/test/qnode/qnode.cpp
+76
-48
source/dnode/mnode/impl/test/snode/snode.cpp
source/dnode/mnode/impl/test/snode/snode.cpp
+76
-46
source/dnode/mnode/impl/test/trans/trans.cpp
source/dnode/mnode/impl/test/trans/trans.cpp
+28
-19
source/dnode/mnode/impl/test/user/user.cpp
source/dnode/mnode/impl/test/user/user.cpp
+59
-88
source/libs/parser/inc/astToMsg.h
source/libs/parser/inc/astToMsg.h
+2
-2
source/libs/parser/src/astToMsg.c
source/libs/parser/src/astToMsg.c
+66
-58
未找到文件。
include/common/tmsg.h
浏览文件 @
2c0f1e77
...
@@ -349,15 +349,15 @@ typedef struct {
...
@@ -349,15 +349,15 @@ typedef struct {
int64_t
maxStorage
;
// In unit of GB
int64_t
maxStorage
;
// In unit of GB
}
SCreateAcctReq
,
SAlterAcctReq
;
}
SCreateAcctReq
,
SAlterAcctReq
;
int32_t
tSerializeSCreateAcctReq
(
void
*
*
buf
,
SCreateAcctReq
*
pReq
);
int32_t
tSerializeSCreateAcctReq
(
void
*
buf
,
int32_t
bufLen
,
SCreateAcctReq
*
pReq
);
void
*
tDeserializeSCreateAcctReq
(
void
*
buf
,
SCreateAcctReq
*
pReq
);
int32_t
tDeserializeSCreateAcctReq
(
void
*
buf
,
int32_t
bufLen
,
SCreateAcctReq
*
pReq
);
typedef
struct
{
typedef
struct
{
char
user
[
TSDB_USER_LEN
];
char
user
[
TSDB_USER_LEN
];
}
SDropUserReq
,
SDropAcctReq
;
}
SDropUserReq
,
SDropAcctReq
;
int32_t
tSerializeSDropUserReq
(
void
*
*
buf
,
SDropUserReq
*
pReq
);
int32_t
tSerializeSDropUserReq
(
void
*
buf
,
int32_t
bufLen
,
SDropUserReq
*
pReq
);
void
*
tDeserializeSDropUserReq
(
void
*
buf
,
SDropUserReq
*
pReq
);
int32_t
tDeserializeSDropUserReq
(
void
*
buf
,
int32_t
bufLen
,
SDropUserReq
*
pReq
);
typedef
struct
{
typedef
struct
{
int8_t
createType
;
int8_t
createType
;
...
@@ -366,8 +366,8 @@ typedef struct {
...
@@ -366,8 +366,8 @@ typedef struct {
char
pass
[
TSDB_PASSWORD_LEN
];
char
pass
[
TSDB_PASSWORD_LEN
];
}
SCreateUserReq
;
}
SCreateUserReq
;
int32_t
tSerializeSCreateUserReq
(
void
*
*
buf
,
SCreateUserReq
*
pReq
);
int32_t
tSerializeSCreateUserReq
(
void
*
buf
,
int32_t
bufLen
,
SCreateUserReq
*
pReq
);
void
*
tDeserializeSCreateUserReq
(
void
*
buf
,
SCreateUserReq
*
pReq
);
int32_t
tDeserializeSCreateUserReq
(
void
*
buf
,
int32_t
bufLen
,
SCreateUserReq
*
pReq
);
typedef
struct
{
typedef
struct
{
int8_t
alterType
;
int8_t
alterType
;
...
@@ -377,15 +377,15 @@ typedef struct {
...
@@ -377,15 +377,15 @@ typedef struct {
char
dbname
[
TSDB_DB_FNAME_LEN
];
char
dbname
[
TSDB_DB_FNAME_LEN
];
}
SAlterUserReq
;
}
SAlterUserReq
;
int32_t
tSerializeSAlterUserReq
(
void
*
*
buf
,
SAlterUserReq
*
pReq
);
int32_t
tSerializeSAlterUserReq
(
void
*
buf
,
int32_t
bufLen
,
SAlterUserReq
*
pReq
);
void
*
tDeserializeSAlterUserReq
(
void
*
buf
,
SAlterUserReq
*
pReq
);
int32_t
tDeserializeSAlterUserReq
(
void
*
buf
,
int32_t
bufLen
,
SAlterUserReq
*
pReq
);
typedef
struct
{
typedef
struct
{
char
user
[
TSDB_USER_LEN
];
char
user
[
TSDB_USER_LEN
];
}
SGetUserAuthReq
;
}
SGetUserAuthReq
;
int32_t
tSerializeSGetUserAuthReq
(
void
*
*
buf
,
SGetUserAuthReq
*
pReq
);
int32_t
tSerializeSGetUserAuthReq
(
void
*
buf
,
int32_t
bufLen
,
SGetUserAuthReq
*
pReq
);
void
*
tDeserializeSGetUserAuthReq
(
void
*
buf
,
SGetUserAuthReq
*
pReq
);
int32_t
tDeserializeSGetUserAuthReq
(
void
*
buf
,
int32_t
bufLen
,
SGetUserAuthReq
*
pReq
);
typedef
struct
{
typedef
struct
{
char
user
[
TSDB_USER_LEN
];
char
user
[
TSDB_USER_LEN
];
...
@@ -394,8 +394,8 @@ typedef struct {
...
@@ -394,8 +394,8 @@ typedef struct {
SHashObj
*
writeDbs
;
SHashObj
*
writeDbs
;
}
SGetUserAuthRsp
;
}
SGetUserAuthRsp
;
int32_t
tSerializeSGetUserAuthRsp
(
void
*
*
buf
,
SGetUserAuthRsp
*
pReq
);
int32_t
tSerializeSGetUserAuthRsp
(
void
*
buf
,
int32_t
bufLen
,
SGetUserAuthRsp
*
pReq
);
void
*
tDeserializeSGetUserAuthRsp
(
void
*
buf
,
SGetUserAuthRsp
*
pReq
);
int32_t
tDeserializeSGetUserAuthRsp
(
void
*
buf
,
int32_t
bufLen
,
SGetUserAuthRsp
*
pReq
);
typedef
struct
{
typedef
struct
{
int16_t
colId
;
// column id
int16_t
colId
;
// column id
...
@@ -851,19 +851,32 @@ typedef struct {
...
@@ -851,19 +851,32 @@ typedef struct {
int32_t
port
;
int32_t
port
;
}
SCreateDnodeReq
;
}
SCreateDnodeReq
;
int32_t
tSerializeSCreateDnodeReq
(
void
*
buf
,
int32_t
bufLen
,
SCreateDnodeReq
*
pReq
);
int32_t
tDeserializeSCreateDnodeReq
(
void
*
buf
,
int32_t
bufLen
,
SCreateDnodeReq
*
pReq
);
typedef
struct
{
typedef
struct
{
int32_t
dnodeId
;
int32_t
dnodeId
;
}
SDropDnodeReq
;
}
SDropDnodeReq
;
int32_t
tSerializeSDropDnodeReq
(
void
*
buf
,
int32_t
bufLen
,
SDropDnodeReq
*
pReq
);
int32_t
tDeserializeSDropDnodeReq
(
void
*
buf
,
int32_t
bufLen
,
SDropDnodeReq
*
pReq
);
typedef
struct
{
typedef
struct
{
int32_t
dnodeId
;
int32_t
dnodeId
;
char
config
[
TSDB_DNODE_CONFIG_LEN
];
char
config
[
TSDB_DNODE_CONFIG_LEN
];
char
value
[
TSDB_DNODE_VALUE_LEN
];
}
SMCfgDnodeReq
,
SDCfgDnodeReq
;
}
SMCfgDnodeReq
,
SDCfgDnodeReq
;
int32_t
tSerializeSMCfgDnodeReq
(
void
*
buf
,
int32_t
bufLen
,
SMCfgDnodeReq
*
pReq
);
int32_t
tDeserializeSMCfgDnodeReq
(
void
*
buf
,
int32_t
bufLen
,
SMCfgDnodeReq
*
pReq
);
typedef
struct
{
typedef
struct
{
int32_t
dnodeId
;
int32_t
dnodeId
;
}
SMCreateMnodeReq
,
SMDropMnodeReq
,
SDDropMnodeReq
;
}
SMCreateMnodeReq
,
SMDropMnodeReq
,
SDDropMnodeReq
;
int32_t
tSerializeSMCreateDropMnodeReq
(
void
*
buf
,
int32_t
bufLen
,
SMCreateMnodeReq
*
pReq
);
int32_t
tDeserializeSMCreateDropMnodeReq
(
void
*
buf
,
int32_t
bufLen
,
SMCreateMnodeReq
*
pReq
);
typedef
struct
{
typedef
struct
{
int32_t
dnodeId
;
int32_t
dnodeId
;
int8_t
replica
;
int8_t
replica
;
...
@@ -872,15 +885,11 @@ typedef struct {
...
@@ -872,15 +885,11 @@ typedef struct {
typedef
struct
{
typedef
struct
{
int32_t
dnodeId
;
int32_t
dnodeId
;
}
SMCreateQnodeReq
,
SMDropQnodeReq
,
SDCreateQnodeReq
,
SDDropQnodeReq
;
}
SMCreateQnodeReq
,
SMDropQnodeReq
,
SDCreateQnodeReq
,
SDDropQnodeReq
,
SMCreateSnodeReq
,
SMDropSnodeReq
,
SDCreateSnodeReq
,
SDDropSnodeReq
,
SMCreateBnodeReq
,
SMDropBnodeReq
,
SDCreateBnodeReq
,
SDDropBnodeReq
;
typedef
struct
{
int32_t
tSerializeSMCreateDropQSBNodeReq
(
void
*
buf
,
int32_t
bufLen
,
SMCreateQnodeReq
*
pReq
);
int32_t
dnodeId
;
int32_t
tDeserializeSMCreateDropQSBNodeReq
(
void
*
buf
,
int32_t
bufLen
,
SMCreateQnodeReq
*
pReq
);
}
SMCreateSnodeReq
,
SMDropSnodeReq
,
SDCreateSnodeReq
,
SDDropSnodeReq
;
typedef
struct
{
int32_t
dnodeId
;
}
SMCreateBnodeReq
,
SMDropBnodeReq
,
SDCreateBnodeReq
,
SDDropBnodeReq
;
typedef
struct
{
typedef
struct
{
char
sql
[
TSDB_SHOW_SQL_LEN
];
char
sql
[
TSDB_SHOW_SQL_LEN
];
...
...
include/util/tdef.h
浏览文件 @
2c0f1e77
...
@@ -219,6 +219,7 @@ do { \
...
@@ -219,6 +219,7 @@ do { \
#define TSDB_ERROR_MSG_LEN 1024
#define TSDB_ERROR_MSG_LEN 1024
#define TSDB_DNODE_CONFIG_LEN 128
#define TSDB_DNODE_CONFIG_LEN 128
#define TSDB_DNODE_VALUE_LEN 256
#define TSDB_MQTT_HOSTNAME_LEN 64
#define TSDB_MQTT_HOSTNAME_LEN 64
#define TSDB_MQTT_PORT_LEN 8
#define TSDB_MQTT_PORT_LEN 8
...
...
source/common/src/tmsg.c
浏览文件 @
2c0f1e77
...
@@ -600,142 +600,323 @@ void *tDeserializeSStatusRsp(void *buf, SStatusRsp *pRsp) {
...
@@ -600,142 +600,323 @@ void *tDeserializeSStatusRsp(void *buf, SStatusRsp *pRsp) {
return
buf
;
return
buf
;
}
}
int32_t
tSerializeSCreateAcctReq
(
void
**
buf
,
SCreateAcctReq
*
pReq
)
{
int32_t
tSerializeSCreateAcctReq
(
void
*
buf
,
int32_t
bufLen
,
SCreateAcctReq
*
pReq
)
{
int32_t
tlen
=
0
;
SCoder
encoder
=
{
0
};
tlen
+=
taosEncodeString
(
buf
,
pReq
->
user
);
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_ENCODER
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
pass
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pReq
->
maxUsers
);
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
tlen
+=
taosEncodeFixedI32
(
buf
,
pReq
->
maxDbs
);
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
user
)
<
0
)
return
-
1
;
tlen
+=
taosEncodeFixedI32
(
buf
,
pReq
->
maxTimeSeries
);
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
pass
)
<
0
)
return
-
1
;
tlen
+=
taosEncodeFixedI32
(
buf
,
pReq
->
maxStreams
);
if
(
tEncodeI32
(
&
encoder
,
pReq
->
maxUsers
)
<
0
)
return
-
1
;
tlen
+=
taosEncodeFixedI32
(
buf
,
pReq
->
accessState
);
if
(
tEncodeI32
(
&
encoder
,
pReq
->
maxDbs
)
<
0
)
return
-
1
;
tlen
+=
taosEncodeFixedI64
(
buf
,
pReq
->
maxStorage
);
if
(
tEncodeI32
(
&
encoder
,
pReq
->
maxTimeSeries
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
maxStreams
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
accessState
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pReq
->
maxStorage
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
tCoderClear
(
&
encoder
);
return
tlen
;
return
tlen
;
}
}
void
*
tDeserializeSCreateAcctReq
(
void
*
buf
,
SCreateAcctReq
*
pReq
)
{
int32_t
tDeserializeSCreateAcctReq
(
void
*
buf
,
int32_t
bufLen
,
SCreateAcctReq
*
pReq
)
{
buf
=
taosDecodeStringTo
(
buf
,
pReq
->
user
);
SCoder
decoder
=
{
0
};
buf
=
taosDecodeStringTo
(
buf
,
pReq
->
pass
);
tCoderInit
(
&
decoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_DECODER
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pReq
->
maxUsers
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pReq
->
maxDbs
);
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
buf
=
taosDecodeFixedI32
(
buf
,
&
pReq
->
maxTimeSeries
);
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
user
)
<
0
)
return
-
1
;
buf
=
taosDecodeFixedI32
(
buf
,
&
pReq
->
maxStreams
);
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
pass
)
<
0
)
return
-
1
;
buf
=
taosDecodeFixedI32
(
buf
,
&
pReq
->
accessState
);
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
maxUsers
)
<
0
)
return
-
1
;
buf
=
taosDecodeFixedI64
(
buf
,
&
pReq
->
maxStorage
);
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
maxDbs
)
<
0
)
return
-
1
;
return
buf
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
maxTimeSeries
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
maxStreams
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
accessState
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
pReq
->
maxStorage
)
<
0
)
return
-
1
;
tEndDecode
(
&
decoder
);
tCoderClear
(
&
decoder
);
return
0
;
}
}
int32_t
tSerializeSDropUserReq
(
void
**
buf
,
SDropUserReq
*
pReq
)
{
int32_t
tSerializeSDropUserReq
(
void
*
buf
,
int32_t
bufLen
,
SDropUserReq
*
pReq
)
{
int32_t
tlen
=
0
;
SCoder
encoder
=
{
0
};
tlen
+=
taosEncodeString
(
buf
,
pReq
->
user
);
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_ENCODER
);
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
user
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
tCoderClear
(
&
encoder
);
return
tlen
;
return
tlen
;
}
}
void
*
tDeserializeSDropUserReq
(
void
*
buf
,
SDropUserReq
*
pReq
)
{
int32_t
tDeserializeSDropUserReq
(
void
*
buf
,
int32_t
bufLen
,
SDropUserReq
*
pReq
)
{
buf
=
taosDecodeStringTo
(
buf
,
pReq
->
user
);
SCoder
decoder
=
{
0
};
return
buf
;
tCoderInit
(
&
decoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_DECODER
);
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
user
)
<
0
)
return
-
1
;
tEndDecode
(
&
decoder
);
tCoderClear
(
&
decoder
);
return
0
;
}
}
int32_t
tSerializeSCreateUserReq
(
void
**
buf
,
SCreateUserReq
*
pReq
)
{
int32_t
tSerializeSCreateUserReq
(
void
*
buf
,
int32_t
bufLen
,
SCreateUserReq
*
pReq
)
{
int32_t
tlen
=
0
;
SCoder
encoder
=
{
0
};
tlen
+=
taosEncodeFixedI8
(
buf
,
pReq
->
createType
);
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_ENCODER
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pReq
->
superUser
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
user
);
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
tlen
+=
taosEncodeString
(
buf
,
pReq
->
pass
);
if
(
tEncodeI8
(
&
encoder
,
pReq
->
createType
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
superUser
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
user
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
pass
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
tCoderClear
(
&
encoder
);
return
tlen
;
return
tlen
;
}
}
void
*
tDeserializeSCreateUserReq
(
void
*
buf
,
SCreateUserReq
*
pReq
)
{
int32_t
tDeserializeSCreateUserReq
(
void
*
buf
,
int32_t
bufLen
,
SCreateUserReq
*
pReq
)
{
buf
=
taosDecodeFixedI8
(
buf
,
&
pReq
->
createType
);
SCoder
decoder
=
{
0
};
buf
=
taosDecodeFixedI8
(
buf
,
&
pReq
->
superUser
);
tCoderInit
(
&
decoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_DECODER
);
buf
=
taosDecodeStringTo
(
buf
,
pReq
->
user
);
buf
=
taosDecodeStringTo
(
buf
,
pReq
->
pass
);
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
return
buf
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
createType
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
superUser
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
user
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
pass
)
<
0
)
return
-
1
;
tEndDecode
(
&
decoder
);
tCoderClear
(
&
decoder
);
return
0
;
}
}
int32_t
tSerializeSAlterUserReq
(
void
**
buf
,
SAlterUserReq
*
pReq
)
{
int32_t
tSerializeSAlterUserReq
(
void
*
buf
,
int32_t
bufLen
,
SAlterUserReq
*
pReq
)
{
int32_t
tlen
=
0
;
SCoder
encoder
=
{
0
};
tlen
+=
taosEncodeFixedI8
(
buf
,
pReq
->
alterType
);
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_ENCODER
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
user
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
pass
);
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
tlen
+=
taosEncodeString
(
buf
,
pReq
->
dbname
);
if
(
tEncodeI8
(
&
encoder
,
pReq
->
alterType
)
<
0
)
return
-
1
;
tlen
+=
taosEncodeFixedI8
(
buf
,
pReq
->
superUser
);
if
(
tEncodeI8
(
&
encoder
,
pReq
->
superUser
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
user
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
pass
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
dbname
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
tCoderClear
(
&
encoder
);
return
tlen
;
return
tlen
;
}
}
void
*
tDeserializeSAlterUserReq
(
void
*
buf
,
SAlterUserReq
*
pReq
)
{
int32_t
tDeserializeSAlterUserReq
(
void
*
buf
,
int32_t
bufLen
,
SAlterUserReq
*
pReq
)
{
buf
=
taosDecodeFixedI8
(
buf
,
&
pReq
->
alterType
);
SCoder
decoder
=
{
0
};
buf
=
taosDecodeStringTo
(
buf
,
pReq
->
user
);
tCoderInit
(
&
decoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_DECODER
);
buf
=
taosDecodeStringTo
(
buf
,
pReq
->
pass
);
buf
=
taosDecodeStringTo
(
buf
,
pReq
->
dbname
);
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
buf
=
taosDecodeFixedI8
(
buf
,
&
pReq
->
superUser
);
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
alterType
)
<
0
)
return
-
1
;
return
buf
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
superUser
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
user
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
pass
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
dbname
)
<
0
)
return
-
1
;
tEndDecode
(
&
decoder
);
tCoderClear
(
&
decoder
);
return
0
;
}
}
int32_t
tSerializeSGetUserAuthReq
(
void
**
buf
,
SGetUserAuthReq
*
pReq
)
{
int32_t
tSerializeSGetUserAuthReq
(
void
*
buf
,
int32_t
bufLen
,
SGetUserAuthReq
*
pReq
)
{
int32_t
tlen
=
0
;
SCoder
encoder
=
{
0
};
tlen
+=
taosEncodeString
(
buf
,
pReq
->
user
);
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_ENCODER
);
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
user
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
tCoderClear
(
&
encoder
);
return
tlen
;
return
tlen
;
}
}
void
*
tDeserializeSGetUserAuthReq
(
void
*
buf
,
SGetUserAuthReq
*
pReq
)
{
int32_t
tDeserializeSGetUserAuthReq
(
void
*
buf
,
int32_t
bufLen
,
SGetUserAuthReq
*
pReq
)
{
buf
=
taosDecodeStringTo
(
buf
,
pReq
->
user
);
SCoder
decoder
=
{
0
};
return
buf
;
tCoderInit
(
&
decoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_DECODER
);
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
user
)
<
0
)
return
-
1
;
tEndDecode
(
&
decoder
);
tCoderClear
(
&
decoder
);
return
0
;
}
}
int32_t
tSerializeSGetUserAuthRsp
(
void
**
buf
,
SGetUserAuthRsp
*
pReq
)
{
int32_t
tSerializeSGetUserAuthRsp
(
void
*
buf
,
int32_t
bufLen
,
SGetUserAuthRsp
*
pReq
)
{
int32_t
tlen
=
0
;
SCoder
encoder
=
{
0
};
tlen
+=
taosEncodeString
(
buf
,
pReq
->
user
);
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_ENCODER
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pReq
->
superAuth
);
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
user
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
superAuth
)
<
0
)
return
-
1
;
int32_t
numOfReadDbs
=
taosHashGetSize
(
pReq
->
readDbs
);
int32_t
numOfReadDbs
=
taosHashGetSize
(
pReq
->
readDbs
);
int32_t
numOfWriteDbs
=
taosHashGetSize
(
pReq
->
writeDbs
);
int32_t
numOfWriteDbs
=
taosHashGetSize
(
pReq
->
writeDbs
);
tlen
+=
taosEncodeFixedI32
(
buf
,
numOfReadDbs
)
;
if
(
tEncodeI32
(
&
encoder
,
numOfReadDbs
)
<
0
)
return
-
1
;
tlen
+=
taosEncodeFixedI32
(
buf
,
numOfWriteDbs
)
;
if
(
tEncodeI32
(
&
encoder
,
numOfWriteDbs
)
<
0
)
return
-
1
;
char
*
db
=
taosHashIterate
(
pReq
->
readDbs
,
NULL
);
char
*
db
=
taosHashIterate
(
pReq
->
readDbs
,
NULL
);
while
(
db
!=
NULL
)
{
while
(
db
!=
NULL
)
{
tlen
+=
taosEncodeString
(
buf
,
db
)
;
if
(
tEncodeCStr
(
&
encoder
,
db
)
<
0
)
return
-
1
;
db
=
taosHashIterate
(
pReq
->
readDbs
,
db
);
db
=
taosHashIterate
(
pReq
->
readDbs
,
db
);
}
}
db
=
taosHashIterate
(
pReq
->
writeDbs
,
NULL
);
db
=
taosHashIterate
(
pReq
->
writeDbs
,
NULL
);
while
(
db
!=
NULL
)
{
while
(
db
!=
NULL
)
{
tlen
+=
taosEncodeString
(
buf
,
db
)
;
if
(
tEncodeCStr
(
&
encoder
,
db
)
<
0
)
return
-
1
;
db
=
taosHashIterate
(
pReq
->
writeDbs
,
db
);
db
=
taosHashIterate
(
pReq
->
writeDbs
,
db
);
}
}
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
tCoderClear
(
&
encoder
);
return
tlen
;
return
tlen
;
}
}
void
*
tDeserializeSGetUserAuthRsp
(
void
*
buf
,
SGetUserAuthRsp
*
pReq
)
{
int32_t
tDeserializeSGetUserAuthRsp
(
void
*
buf
,
int32_t
bufLen
,
SGetUserAuthRsp
*
pReq
)
{
buf
=
taosDecodeStringTo
(
buf
,
pReq
->
user
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pReq
->
superAuth
);
pReq
->
readDbs
=
taosHashInit
(
4
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
false
);
pReq
->
readDbs
=
taosHashInit
(
4
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
false
);
pReq
->
writeDbs
=
taosHashInit
(
4
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
false
);
pReq
->
writeDbs
=
taosHashInit
(
4
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
false
);
if
(
pReq
->
readDbs
==
NULL
||
pReq
->
writeDbs
==
NULL
)
{
if
(
pReq
->
readDbs
==
NULL
||
pReq
->
writeDbs
==
NULL
)
{
return
NULL
;
return
-
1
;
}
}
SCoder
decoder
=
{
0
};
tCoderInit
(
&
decoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_DECODER
);
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
user
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
superAuth
)
<
0
)
return
-
1
;
int32_t
numOfReadDbs
=
0
;
int32_t
numOfReadDbs
=
0
;
int32_t
numOfWriteDbs
=
0
;
int32_t
numOfWriteDbs
=
0
;
buf
=
taosDecodeFixedI32
(
buf
,
&
numOfReadDbs
)
;
if
(
tDecodeI32
(
&
decoder
,
&
numOfReadDbs
)
<
0
)
return
-
1
;
buf
=
taosDecodeFixedI32
(
buf
,
&
numOfWriteDbs
)
;
if
(
tDecodeI32
(
&
decoder
,
&
numOfWriteDbs
)
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
numOfReadDbs
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfReadDbs
;
++
i
)
{
char
db
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
char
db
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
buf
=
taosDecodeStringTo
(
buf
,
db
)
;
if
(
tDecodeCStrTo
(
&
decoder
,
db
)
<
0
)
return
-
1
;
int32_t
len
=
strlen
(
db
)
+
1
;
int32_t
len
=
strlen
(
db
)
+
1
;
taosHashPut
(
pReq
->
readDbs
,
db
,
len
,
db
,
len
);
taosHashPut
(
pReq
->
readDbs
,
db
,
len
,
db
,
len
);
}
}
for
(
int32_t
i
=
0
;
i
<
numOfWriteDbs
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfWriteDbs
;
++
i
)
{
char
db
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
char
db
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
buf
=
taosDecodeStringTo
(
buf
,
db
)
;
if
(
tDecodeCStrTo
(
&
decoder
,
db
)
<
0
)
return
-
1
;
int32_t
len
=
strlen
(
db
)
+
1
;
int32_t
len
=
strlen
(
db
)
+
1
;
taosHashPut
(
pReq
->
writeDbs
,
db
,
len
,
db
,
len
);
taosHashPut
(
pReq
->
writeDbs
,
db
,
len
,
db
,
len
);
}
}
return
buf
;
tEndDecode
(
&
decoder
);
tCoderClear
(
&
decoder
);
return
0
;
}
int32_t
tSerializeSMCreateDropQSBNodeReq
(
void
*
buf
,
int32_t
bufLen
,
SMCreateQnodeReq
*
pReq
)
{
SCoder
encoder
=
{
0
};
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_ENCODER
);
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
dnodeId
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
tCoderClear
(
&
encoder
);
return
tlen
;
}
int32_t
tDeserializeSMCreateDropQSBNodeReq
(
void
*
buf
,
int32_t
bufLen
,
SMCreateQnodeReq
*
pReq
)
{
SCoder
decoder
=
{
0
};
tCoderInit
(
&
decoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_DECODER
);
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
dnodeId
)
<
0
)
return
-
1
;
tEndDecode
(
&
decoder
);
tCoderClear
(
&
decoder
);
return
0
;
}
int32_t
tSerializeSDropDnodeReq
(
void
*
buf
,
int32_t
bufLen
,
SDropDnodeReq
*
pReq
)
{
return
tSerializeSMCreateDropQSBNodeReq
(
buf
,
bufLen
,
(
SMCreateQnodeReq
*
)
pReq
);
}
int32_t
tDeserializeSDropDnodeReq
(
void
*
buf
,
int32_t
bufLen
,
SDropDnodeReq
*
pReq
)
{
return
tDeserializeSMCreateDropQSBNodeReq
(
buf
,
bufLen
,
(
SMCreateQnodeReq
*
)
pReq
);
}
int32_t
tSerializeSMCreateDropMnodeReq
(
void
*
buf
,
int32_t
bufLen
,
SMCreateMnodeReq
*
pReq
)
{
return
tSerializeSMCreateDropQSBNodeReq
(
buf
,
bufLen
,
(
SMCreateQnodeReq
*
)
pReq
);
}
int32_t
tDeserializeSMCreateDropMnodeReq
(
void
*
buf
,
int32_t
bufLen
,
SMCreateMnodeReq
*
pReq
)
{
return
tDeserializeSMCreateDropQSBNodeReq
(
buf
,
bufLen
,
(
SMCreateQnodeReq
*
)
pReq
);
}
int32_t
tSerializeSMCfgDnodeReq
(
void
*
buf
,
int32_t
bufLen
,
SMCfgDnodeReq
*
pReq
)
{
SCoder
encoder
=
{
0
};
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_ENCODER
);
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
dnodeId
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
config
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
value
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
tCoderClear
(
&
encoder
);
return
tlen
;
}
int32_t
tDeserializeSMCfgDnodeReq
(
void
*
buf
,
int32_t
bufLen
,
SMCfgDnodeReq
*
pReq
)
{
SCoder
decoder
=
{
0
};
tCoderInit
(
&
decoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_DECODER
);
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
dnodeId
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
config
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
value
)
<
0
)
return
-
1
;
tEndDecode
(
&
decoder
);
tCoderClear
(
&
decoder
);
return
0
;
}
int32_t
tSerializeSCreateDnodeReq
(
void
*
buf
,
int32_t
bufLen
,
SCreateDnodeReq
*
pReq
)
{
SCoder
encoder
=
{
0
};
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_ENCODER
);
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
fqdn
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
port
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
tCoderClear
(
&
encoder
);
return
tlen
;
}
int32_t
tDeserializeSCreateDnodeReq
(
void
*
buf
,
int32_t
bufLen
,
SCreateDnodeReq
*
pReq
)
{
SCoder
decoder
=
{
0
};
tCoderInit
(
&
decoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_DECODER
);
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
fqdn
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
port
)
<
0
)
return
-
1
;
tEndDecode
(
&
decoder
);
tCoderClear
(
&
decoder
);
return
0
;
}
}
source/dnode/mnode/impl/inc/mndAuth.h
浏览文件 @
2c0f1e77
...
@@ -29,6 +29,10 @@ int32_t mndCheckCreateUserAuth(SUserObj *pOperUser);
...
@@ -29,6 +29,10 @@ int32_t mndCheckCreateUserAuth(SUserObj *pOperUser);
int32_t
mndCheckAlterUserAuth
(
SUserObj
*
pOperUser
,
SUserObj
*
pUser
,
SDbObj
*
pDb
,
SAlterUserReq
*
pAlter
);
int32_t
mndCheckAlterUserAuth
(
SUserObj
*
pOperUser
,
SUserObj
*
pUser
,
SDbObj
*
pDb
,
SAlterUserReq
*
pAlter
);
int32_t
mndCheckDropUserAuth
(
SUserObj
*
pOperUser
);
int32_t
mndCheckDropUserAuth
(
SUserObj
*
pOperUser
);
int32_t
mndCheckCreateNodeAuth
(
SUserObj
*
pOperUser
);
int32_t
mndCheckDropNodeAuth
(
SUserObj
*
pOperUser
);
int32_t
mndCheckAlterNodeAuth
(
SUserObj
*
pOperUser
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/dnode/mnode/impl/src/mndAuth.c
浏览文件 @
2c0f1e77
...
@@ -110,3 +110,16 @@ int32_t mndCheckDropUserAuth(SUserObj *pOperUser) {
...
@@ -110,3 +110,16 @@ int32_t mndCheckDropUserAuth(SUserObj *pOperUser) {
terrno
=
TSDB_CODE_MND_NO_RIGHTS
;
terrno
=
TSDB_CODE_MND_NO_RIGHTS
;
return
-
1
;
return
-
1
;
}
}
int32_t
mndCheckCreateNodeAuth
(
SUserObj
*
pOperUser
)
{
if
(
pOperUser
->
superUser
)
{
return
0
;
}
terrno
=
TSDB_CODE_MND_NO_RIGHTS
;
return
-
1
;
}
int32_t
mndCheckDropNodeAuth
(
SUserObj
*
pOperUser
)
{
return
mndCheckCreateNodeAuth
(
pOperUser
);
}
int32_t
mndCheckAlterNodeAuth
(
SUserObj
*
pOperUser
)
{
return
mndCheckCreateNodeAuth
(
pOperUser
);
}
source/dnode/mnode/impl/src/mndBnode.c
浏览文件 @
2c0f1e77
...
@@ -15,9 +15,11 @@
...
@@ -15,9 +15,11 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "mndBnode.h"
#include "mndBnode.h"
#include "mndAuth.h"
#include "mndDnode.h"
#include "mndDnode.h"
#include "mndShow.h"
#include "mndShow.h"
#include "mndTrans.h"
#include "mndTrans.h"
#include "mndUser.h"
#define TSDB_BNODE_VER_NUMBER 1
#define TSDB_BNODE_VER_NUMBER 1
#define TSDB_BNODE_RESERVE_SIZE 64
#define TSDB_BNODE_RESERVE_SIZE 64
...
@@ -258,39 +260,56 @@ CREATE_BNODE_OVER:
...
@@ -258,39 +260,56 @@ CREATE_BNODE_OVER:
static
int32_t
mndProcessCreateBnodeReq
(
SMnodeMsg
*
pReq
)
{
static
int32_t
mndProcessCreateBnodeReq
(
SMnodeMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
pMnode
;
SMnode
*
pMnode
=
pReq
->
pMnode
;
SMCreateBnodeReq
*
pCreate
=
pReq
->
rpcMsg
.
pCont
;
int32_t
code
=
-
1
;
SBnodeObj
*
pObj
=
NULL
;
SDnodeObj
*
pDnode
=
NULL
;
SUserObj
*
pUser
=
NULL
;
SMCreateBnodeReq
createReq
=
{
0
};
pCreate
->
dnodeId
=
htonl
(
pCreate
->
dnodeId
);
if
(
tDeserializeSMCreateDropQSBNodeReq
(
pReq
->
rpcMsg
.
pCont
,
pReq
->
rpcMsg
.
contLen
,
&
createReq
)
!=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
goto
CREATE_BNODE_OVER
;
}
mDebug
(
"bnode:%d, start to create"
,
pCreate
->
dnodeId
);
mDebug
(
"bnode:%d, start to create"
,
createReq
.
dnodeId
);
SBnodeObj
*
pObj
=
mndAcquireBnode
(
pMnode
,
pCreate
->
dnodeId
);
pObj
=
mndAcquireBnode
(
pMnode
,
createReq
.
dnodeId
);
if
(
pObj
!=
NULL
)
{
if
(
pObj
!=
NULL
)
{
mError
(
"bnode:%d, bnode already exist"
,
pObj
->
id
);
terrno
=
TSDB_CODE_MND_BNODE_ALREADY_EXIST
;
terrno
=
TSDB_CODE_MND_BNODE_ALREADY_EXIST
;
mndReleaseBnode
(
pMnode
,
pObj
);
goto
CREATE_BNODE_OVER
;
return
-
1
;
}
else
if
(
terrno
!=
TSDB_CODE_MND_BNODE_NOT_EXIST
)
{
}
else
if
(
terrno
!=
TSDB_CODE_MND_BNODE_NOT_EXIST
)
{
mError
(
"bnode:%d, failed to create bnode since %s"
,
pCreate
->
dnodeId
,
terrstr
());
goto
CREATE_BNODE_OVER
;
return
-
1
;
}
}
SDnodeObj
*
pDnode
=
mndAcquireDnode
(
pMnode
,
pCreate
->
dnodeId
);
pDnode
=
mndAcquireDnode
(
pMnode
,
createReq
.
dnodeId
);
if
(
pDnode
==
NULL
)
{
if
(
pDnode
==
NULL
)
{
mError
(
"bnode:%d, dnode not exist"
,
pCreate
->
dnodeId
);
terrno
=
TSDB_CODE_MND_DNODE_NOT_EXIST
;
terrno
=
TSDB_CODE_MND_DNODE_NOT_EXIST
;
return
-
1
;
goto
CREATE_BNODE_OVER
;
}
}
int32_t
code
=
mndCreateBnode
(
pMnode
,
pReq
,
pDnode
,
pCreate
);
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
user
);
mndReleaseDnode
(
pMnode
,
pDnode
);
if
(
pUser
==
NULL
)
{
terrno
=
TSDB_CODE_MND_NO_USER_FROM_CONN
;
goto
CREATE_BNODE_OVER
;
}
if
(
code
!=
0
)
{
if
(
mndCheckDropNodeAuth
(
pUser
))
{
mError
(
"bnode:%d, failed to create since %s"
,
pCreate
->
dnodeId
,
terrstr
());
goto
CREATE_BNODE_OVER
;
return
-
1
;
}
code
=
mndCreateBnode
(
pMnode
,
pReq
,
pDnode
,
&
createReq
);
if
(
code
==
0
)
code
=
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
CREATE_BNODE_OVER:
if
(
code
!=
0
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
mError
(
"bnode:%d, failed to create since %s"
,
createReq
.
dnodeId
,
terrstr
());
}
}
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
mndReleaseBnode
(
pMnode
,
pObj
);
mndReleaseDnode
(
pMnode
,
pDnode
);
mndReleaseUser
(
pMnode
,
pUser
);
return
code
;
}
}
static
int32_t
mndSetDropBnodeRedoLogs
(
STrans
*
pTrans
,
SBnodeObj
*
pObj
)
{
static
int32_t
mndSetDropBnodeRedoLogs
(
STrans
*
pTrans
,
SBnodeObj
*
pObj
)
{
...
@@ -353,32 +372,50 @@ DROP_BNODE_OVER:
...
@@ -353,32 +372,50 @@ DROP_BNODE_OVER:
static
int32_t
mndProcessDropBnodeReq
(
SMnodeMsg
*
pReq
)
{
static
int32_t
mndProcessDropBnodeReq
(
SMnodeMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
pMnode
;
SMnode
*
pMnode
=
pReq
->
pMnode
;
SMDropBnodeReq
*
pDrop
=
pReq
->
rpcMsg
.
pCont
;
int32_t
code
=
-
1
;
pDrop
->
dnodeId
=
htonl
(
pDrop
->
dnodeId
);
SUserObj
*
pUser
=
NULL
;
SBnodeObj
*
pObj
=
NULL
;
SMDropBnodeReq
dropReq
=
{
0
};
if
(
tDeserializeSMCreateDropQSBNodeReq
(
pReq
->
rpcMsg
.
pCont
,
pReq
->
rpcMsg
.
contLen
,
&
dropReq
)
!=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
goto
DROP_BNODE_OVER
;
}
mDebug
(
"bnode:%d, start to drop"
,
pDrop
->
dnodeId
);
mDebug
(
"bnode:%d, start to drop"
,
dropReq
.
dnodeId
);
if
(
pDrop
->
dnodeId
<=
0
)
{
if
(
dropReq
.
dnodeId
<=
0
)
{
terrno
=
TSDB_CODE_SDB_APP_ERROR
;
terrno
=
TSDB_CODE_SDB_APP_ERROR
;
mError
(
"bnode:%d, failed to drop since %s"
,
pDrop
->
dnodeId
,
terrstr
());
goto
DROP_BNODE_OVER
;
return
-
1
;
}
}
SBnodeObj
*
pObj
=
mndAcquireBnode
(
pMnode
,
pDrop
->
dnodeId
);
pObj
=
mndAcquireBnode
(
pMnode
,
dropReq
.
dnodeId
);
if
(
pObj
==
NULL
)
{
if
(
pObj
==
NULL
)
{
mError
(
"bnode:%d, failed to drop since %s"
,
pDrop
->
dnodeId
,
terrstr
());
goto
DROP_BNODE_OVER
;
return
-
1
;
}
}
int32_t
code
=
mndDropBnode
(
pMnode
,
pReq
,
pObj
);
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
user
);
if
(
code
!=
0
)
{
if
(
pUser
==
NULL
)
{
sdbRelease
(
pMnode
->
pSdb
,
pObj
);
terrno
=
TSDB_CODE_MND_NO_USER_FROM_CONN
;
mError
(
"bnode:%d, failed to drop since %s"
,
pMnode
->
dnodeId
,
terrstr
());
goto
DROP_BNODE_OVER
;
return
-
1
;
}
}
sdbRelease
(
pMnode
->
pSdb
,
pObj
);
if
(
mndCheckCreateNodeAuth
(
pUser
))
{
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
goto
DROP_BNODE_OVER
;
}
code
=
mndDropBnode
(
pMnode
,
pReq
,
pObj
);
if
(
code
==
0
)
code
=
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
DROP_BNODE_OVER:
if
(
code
!=
0
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
mError
(
"bnode:%d, failed to drop since %s"
,
dropReq
.
dnodeId
,
terrstr
());
}
mndReleaseBnode
(
pMnode
,
pObj
);
mndReleaseUser
(
pMnode
,
pUser
);
return
code
;
}
}
static
int32_t
mndProcessCreateBnodeRsp
(
SMnodeMsg
*
pRsp
)
{
static
int32_t
mndProcessCreateBnodeRsp
(
SMnodeMsg
*
pRsp
)
{
...
...
source/dnode/mnode/impl/src/mndDnode.c
浏览文件 @
2c0f1e77
...
@@ -15,9 +15,11 @@
...
@@ -15,9 +15,11 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "mndDnode.h"
#include "mndDnode.h"
#include "mndAuth.h"
#include "mndMnode.h"
#include "mndMnode.h"
#include "mndShow.h"
#include "mndShow.h"
#include "mndTrans.h"
#include "mndTrans.h"
#include "mndUser.h"
#include "mndVgroup.h"
#include "mndVgroup.h"
#define TSDB_DNODE_VER_NUMBER 1
#define TSDB_DNODE_VER_NUMBER 1
...
@@ -354,7 +356,8 @@ static int32_t mndProcessStatusReq(SMnodeMsg *pReq) {
...
@@ -354,7 +356,8 @@ static int32_t mndProcessStatusReq(SMnodeMsg *pReq) {
if
(
pDnode
!=
NULL
)
{
if
(
pDnode
!=
NULL
)
{
pDnode
->
offlineReason
=
DND_REASON_VERSION_NOT_MATCH
;
pDnode
->
offlineReason
=
DND_REASON_VERSION_NOT_MATCH
;
}
}
mError
(
"dnode:%d, status msg version:%d not match cluster:%d"
,
statusReq
.
dnodeId
,
statusReq
.
sver
,
pMnode
->
cfg
.
sver
);
mError
(
"dnode:%d, status msg version:%d not match cluster:%d"
,
statusReq
.
dnodeId
,
statusReq
.
sver
,
pMnode
->
cfg
.
sver
);
terrno
=
TSDB_CODE_MND_INVALID_MSG_VERSION
;
terrno
=
TSDB_CODE_MND_INVALID_MSG_VERSION
;
goto
PROCESS_STATUS_MSG_OVER
;
goto
PROCESS_STATUS_MSG_OVER
;
}
}
...
@@ -462,34 +465,53 @@ static int32_t mndCreateDnode(SMnode *pMnode, SMnodeMsg *pReq, SCreateDnodeReq *
...
@@ -462,34 +465,53 @@ static int32_t mndCreateDnode(SMnode *pMnode, SMnodeMsg *pReq, SCreateDnodeReq *
static
int32_t
mndProcessCreateDnodeReq
(
SMnodeMsg
*
pReq
)
{
static
int32_t
mndProcessCreateDnodeReq
(
SMnodeMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
pMnode
;
SMnode
*
pMnode
=
pReq
->
pMnode
;
SCreateDnodeReq
*
pCreate
=
pReq
->
rpcMsg
.
pCont
;
int32_t
code
=
-
1
;
pCreate
->
port
=
htonl
(
pCreate
->
port
);
SUserObj
*
pUser
=
NULL
;
mDebug
(
"dnode:%s:%d, start to create"
,
pCreate
->
fqdn
,
pCreate
->
port
);
SDnodeObj
*
pDnode
=
NULL
;
SCreateDnodeReq
createReq
=
{
0
};
if
(
tDeserializeSCreateDnodeReq
(
pReq
->
rpcMsg
.
pCont
,
pReq
->
rpcMsg
.
contLen
,
&
createReq
)
!=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
goto
CREATE_DNODE_OVER
;
}
if
(
pCreate
->
fqdn
[
0
]
==
0
||
pCreate
->
port
<=
0
||
pCreate
->
port
>
UINT16_MAX
)
{
mDebug
(
"dnode:%s:%d, start to create"
,
createReq
.
fqdn
,
createReq
.
port
);
if
(
createReq
.
fqdn
[
0
]
==
0
||
createReq
.
port
<=
0
||
createReq
.
port
>
UINT16_MAX
)
{
terrno
=
TSDB_CODE_MND_INVALID_DNODE_EP
;
terrno
=
TSDB_CODE_MND_INVALID_DNODE_EP
;
mError
(
"dnode:%s:%d, failed to create since %s"
,
pCreate
->
fqdn
,
pCreate
->
port
,
terrstr
());
goto
CREATE_DNODE_OVER
;
return
-
1
;
}
}
char
ep
[
TSDB_EP_LEN
];
char
ep
[
TSDB_EP_LEN
];
snprintf
(
ep
,
TSDB_EP_LEN
,
"%s:%d"
,
pCreate
->
fqdn
,
pCreate
->
port
);
snprintf
(
ep
,
TSDB_EP_LEN
,
"%s:%d"
,
createReq
.
fqdn
,
createReq
.
port
);
SDnodeObj
*
pDnode
=
mndAcquireDnodeByEp
(
pMnode
,
ep
);
pDnode
=
mndAcquireDnodeByEp
(
pMnode
,
ep
);
if
(
pDnode
!=
NULL
)
{
if
(
pDnode
!=
NULL
)
{
mError
(
"dnode:%d, already exist, %s:%u"
,
pDnode
->
id
,
pCreate
->
fqdn
,
pCreate
->
port
);
mndReleaseDnode
(
pMnode
,
pDnode
);
terrno
=
TSDB_CODE_MND_DNODE_ALREADY_EXIST
;
terrno
=
TSDB_CODE_MND_DNODE_ALREADY_EXIST
;
return
-
1
;
goto
CREATE_DNODE_OVER
;
}
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
user
);
if
(
pUser
==
NULL
)
{
terrno
=
TSDB_CODE_MND_NO_USER_FROM_CONN
;
goto
CREATE_DNODE_OVER
;
}
}
int32_t
code
=
mndCreateDnode
(
pMnode
,
pReq
,
pCreate
);
if
(
mndCheckDropNodeAuth
(
pUser
))
{
goto
CREATE_DNODE_OVER
;
}
if
(
code
!=
0
)
{
code
=
mndCreateDnode
(
pMnode
,
pReq
,
&
createReq
);
mError
(
"dnode:%s:%d, failed to create since %s"
,
pCreate
->
fqdn
,
pCreate
->
port
,
terrstr
());
if
(
code
==
0
)
code
=
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
CREATE_DNODE_OVER:
if
(
code
!=
0
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
mError
(
"dnode:%s:%d, failed to create since %s"
,
createReq
.
fqdn
,
createReq
.
port
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
mndReleaseDnode
(
pMnode
,
pDnode
);
mndReleaseUser
(
pMnode
,
pUser
);
return
code
;
}
}
static
int32_t
mndDropDnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
pReq
,
SDnodeObj
*
pDnode
)
{
static
int32_t
mndDropDnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
pReq
,
SDnodeObj
*
pDnode
)
{
...
@@ -520,33 +542,52 @@ static int32_t mndDropDnode(SMnode *pMnode, SMnodeMsg *pReq, SDnodeObj *pDnode)
...
@@ -520,33 +542,52 @@ static int32_t mndDropDnode(SMnode *pMnode, SMnodeMsg *pReq, SDnodeObj *pDnode)
static
int32_t
mndProcessDropDnodeReq
(
SMnodeMsg
*
pReq
)
{
static
int32_t
mndProcessDropDnodeReq
(
SMnodeMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
pMnode
;
SMnode
*
pMnode
=
pReq
->
pMnode
;
SDropDnodeReq
*
pDrop
=
pReq
->
rpcMsg
.
pCont
;
int32_t
code
=
-
1
;
pDrop
->
dnodeId
=
htonl
(
pDrop
->
dnodeId
);
SUserObj
*
pUser
=
NULL
;
SDnodeObj
*
pDnode
=
NULL
;
SDropDnodeReq
dropReq
=
{
0
};
if
(
tDeserializeSDropDnodeReq
(
pReq
->
rpcMsg
.
pCont
,
pReq
->
rpcMsg
.
contLen
,
&
dropReq
)
!=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
goto
DROP_DNODE_OVER
;
}
mDebug
(
"dnode:%d, start to drop"
,
pDrop
->
dnodeId
);
mDebug
(
"dnode:%d, start to drop"
,
dropReq
.
dnodeId
);
if
(
pDrop
->
dnodeId
<=
0
)
{
if
(
dropReq
.
dnodeId
<=
0
)
{
terrno
=
TSDB_CODE_MND_INVALID_DNODE_ID
;
terrno
=
TSDB_CODE_MND_INVALID_DNODE_ID
;
mError
(
"dnode:%d, failed to drop since %s"
,
pDrop
->
dnodeId
,
terrstr
());
goto
DROP_DNODE_OVER
;
return
-
1
;
}
}
SDnodeObj
*
pDnode
=
mndAcquireDnode
(
pMnode
,
pDrop
->
dnodeId
);
pDnode
=
mndAcquireDnode
(
pMnode
,
dropReq
.
dnodeId
);
if
(
pDnode
==
NULL
)
{
if
(
pDnode
==
NULL
)
{
terrno
=
TSDB_CODE_MND_DNODE_NOT_EXIST
;
terrno
=
TSDB_CODE_MND_DNODE_NOT_EXIST
;
mError
(
"dnode:%d, failed to drop since %s"
,
pDrop
->
dnodeId
,
terrstr
());
goto
DROP_DNODE_OVER
;
return
-
1
;
}
}
int32_t
code
=
mndDropDnode
(
pMnode
,
pReq
,
pDnode
);
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
user
);
if
(
code
!=
0
)
{
if
(
pUser
==
NULL
)
{
mndReleaseDnode
(
pMnode
,
pDnode
);
terrno
=
TSDB_CODE_MND_NO_USER_FROM_CONN
;
mError
(
"dnode:%d, failed to drop since %s"
,
pDrop
->
dnodeId
,
terrstr
());
goto
DROP_DNODE_OVER
;
}
if
(
mndCheckCreateNodeAuth
(
pUser
))
{
goto
DROP_DNODE_OVER
;
}
code
=
mndDropDnode
(
pMnode
,
pReq
,
pDnode
);
if
(
code
==
0
)
code
=
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
DROP_DNODE_OVER:
if
(
code
!=
0
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
mError
(
"dnode:%d, failed to drop since %s"
,
dropReq
.
dnodeId
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
mndReleaseDnode
(
pMnode
,
pDnode
);
mndReleaseDnode
(
pMnode
,
pDnode
);
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
mndReleaseUser
(
pMnode
,
pUser
);
return
code
;
}
}
static
int32_t
mndProcessConfigDnodeReq
(
SMnodeMsg
*
pReq
)
{
static
int32_t
mndProcessConfigDnodeReq
(
SMnodeMsg
*
pReq
)
{
...
...
source/dnode/mnode/impl/src/mndQnode.c
浏览文件 @
2c0f1e77
...
@@ -15,9 +15,11 @@
...
@@ -15,9 +15,11 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "mndQnode.h"
#include "mndQnode.h"
#include "mndAuth.h"
#include "mndDnode.h"
#include "mndDnode.h"
#include "mndShow.h"
#include "mndShow.h"
#include "mndTrans.h"
#include "mndTrans.h"
#include "mndUser.h"
#define TSDB_QNODE_VER_NUMBER 1
#define TSDB_QNODE_VER_NUMBER 1
#define TSDB_QNODE_RESERVE_SIZE 64
#define TSDB_QNODE_RESERVE_SIZE 64
...
@@ -258,39 +260,57 @@ CREATE_QNODE_OVER:
...
@@ -258,39 +260,57 @@ CREATE_QNODE_OVER:
static
int32_t
mndProcessCreateQnodeReq
(
SMnodeMsg
*
pReq
)
{
static
int32_t
mndProcessCreateQnodeReq
(
SMnodeMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
pMnode
;
SMnode
*
pMnode
=
pReq
->
pMnode
;
SMCreateQnodeReq
*
pCreate
=
pReq
->
rpcMsg
.
pCont
;
int32_t
code
=
-
1
;
SQnodeObj
*
pObj
=
NULL
;
SDnodeObj
*
pDnode
=
NULL
;
SUserObj
*
pUser
=
NULL
;
SMCreateQnodeReq
createReq
=
{
0
};
pCreate
->
dnodeId
=
htonl
(
pCreate
->
dnodeId
);
if
(
tDeserializeSMCreateDropQSBNodeReq
(
pReq
->
rpcMsg
.
pCont
,
pReq
->
rpcMsg
.
contLen
,
&
createReq
)
!=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
goto
CREATE_QNODE_OVER
;
}
mDebug
(
"qnode:%d, start to create"
,
pCreate
->
dnodeId
);
mDebug
(
"qnode:%d, start to create"
,
createReq
.
dnodeId
);
SQnodeObj
*
pObj
=
mndAcquireQnode
(
pMnode
,
pCreate
->
dnodeId
);
pObj
=
mndAcquireQnode
(
pMnode
,
createReq
.
dnodeId
);
if
(
pObj
!=
NULL
)
{
if
(
pObj
!=
NULL
)
{
mError
(
"qnode:%d, qnode already exist"
,
pObj
->
id
);
terrno
=
TSDB_CODE_MND_QNODE_ALREADY_EXIST
;
terrno
=
TSDB_CODE_MND_QNODE_ALREADY_EXIST
;
mndReleaseQnode
(
pMnode
,
pObj
);
goto
CREATE_QNODE_OVER
;
return
-
1
;
}
else
if
(
terrno
!=
TSDB_CODE_MND_QNODE_NOT_EXIST
)
{
}
else
if
(
terrno
!=
TSDB_CODE_MND_QNODE_NOT_EXIST
)
{
mError
(
"qnode:%d, failed to create qnode since %s"
,
pCreate
->
dnodeId
,
terrstr
());
goto
CREATE_QNODE_OVER
;
return
-
1
;
}
}
SDnodeObj
*
pDnode
=
mndAcquireDnode
(
pMnode
,
pCreate
->
dnodeId
);
pDnode
=
mndAcquireDnode
(
pMnode
,
createReq
.
dnodeId
);
if
(
pDnode
==
NULL
)
{
if
(
pDnode
==
NULL
)
{
mError
(
"qnode:%d, dnode not exist"
,
pCreate
->
dnodeId
);
terrno
=
TSDB_CODE_MND_DNODE_NOT_EXIST
;
terrno
=
TSDB_CODE_MND_DNODE_NOT_EXIST
;
return
-
1
;
goto
CREATE_QNODE_OVER
;
}
}
int32_t
code
=
mndCreateQnode
(
pMnode
,
pReq
,
pDnode
,
pCreate
);
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
user
);
mndReleaseDnode
(
pMnode
,
pDnode
);
if
(
pUser
==
NULL
)
{
terrno
=
TSDB_CODE_MND_NO_USER_FROM_CONN
;
goto
CREATE_QNODE_OVER
;
}
if
(
mndCheckDropNodeAuth
(
pUser
))
{
goto
CREATE_QNODE_OVER
;
}
code
=
mndCreateQnode
(
pMnode
,
pReq
,
pDnode
,
&
createReq
);
if
(
code
==
0
)
code
=
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
if
(
code
!=
0
)
{
CREATE_QNODE_OVER:
mError
(
"qnode:%d, failed to create since %s"
,
pCreate
->
dnodeId
,
terrstr
());
if
(
code
!=
0
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
mError
(
"qnode:%d, failed to create since %s"
,
createReq
.
dnodeId
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
mndReleaseQnode
(
pMnode
,
pObj
);
mndReleaseDnode
(
pMnode
,
pDnode
);
mndReleaseUser
(
pMnode
,
pUser
);
return
code
;
}
}
static
int32_t
mndSetDropQnodeRedoLogs
(
STrans
*
pTrans
,
SQnodeObj
*
pObj
)
{
static
int32_t
mndSetDropQnodeRedoLogs
(
STrans
*
pTrans
,
SQnodeObj
*
pObj
)
{
...
@@ -353,32 +373,51 @@ DROP_QNODE_OVER:
...
@@ -353,32 +373,51 @@ DROP_QNODE_OVER:
static
int32_t
mndProcessDropQnodeReq
(
SMnodeMsg
*
pReq
)
{
static
int32_t
mndProcessDropQnodeReq
(
SMnodeMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
pMnode
;
SMnode
*
pMnode
=
pReq
->
pMnode
;
SMDropQnodeReq
*
pDrop
=
pReq
->
rpcMsg
.
pCont
;
int32_t
code
=
-
1
;
pDrop
->
dnodeId
=
htonl
(
pDrop
->
dnodeId
);
SUserObj
*
pUser
=
NULL
;
SQnodeObj
*
pObj
=
NULL
;
SMDropQnodeReq
dropReq
=
{
0
};
if
(
tDeserializeSMCreateDropQSBNodeReq
(
pReq
->
rpcMsg
.
pCont
,
pReq
->
rpcMsg
.
contLen
,
&
dropReq
)
!=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
goto
DROP_QNODE_OVER
;
}
mDebug
(
"qnode:%d, start to drop"
,
pDrop
->
dnodeId
);
mDebug
(
"qnode:%d, start to drop"
,
dropReq
.
dnodeId
);
if
(
pDrop
->
dnodeId
<=
0
)
{
if
(
dropReq
.
dnodeId
<=
0
)
{
terrno
=
TSDB_CODE_SDB_APP_ERROR
;
terrno
=
TSDB_CODE_SDB_APP_ERROR
;
mError
(
"qnode:%d, failed to drop since %s"
,
pDrop
->
dnodeId
,
terrstr
());
goto
DROP_QNODE_OVER
;
return
-
1
;
}
}
SQnodeObj
*
pObj
=
mndAcquireQnode
(
pMnode
,
pDrop
->
dnodeId
);
pObj
=
mndAcquireQnode
(
pMnode
,
dropReq
.
dnodeId
);
if
(
pObj
==
NULL
)
{
if
(
pObj
==
NULL
)
{
mError
(
"qnode:%d, failed to drop since %s"
,
pDrop
->
dnodeId
,
terrstr
());
goto
DROP_QNODE_OVER
;
return
-
1
;
}
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
user
);
if
(
pUser
==
NULL
)
{
terrno
=
TSDB_CODE_MND_NO_USER_FROM_CONN
;
goto
DROP_QNODE_OVER
;
}
if
(
mndCheckCreateNodeAuth
(
pUser
))
{
goto
DROP_QNODE_OVER
;
}
}
int32_t
code
=
mndDropQnode
(
pMnode
,
pReq
,
pObj
);
code
=
mndDropQnode
(
pMnode
,
pReq
,
pObj
);
if
(
code
!=
0
)
{
if
(
code
==
0
)
code
=
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
sdbRelease
(
pMnode
->
pSdb
,
pObj
);
DROP_QNODE_OVER:
if
(
code
!=
0
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
mError
(
"qnode:%d, failed to drop since %s"
,
pMnode
->
dnodeId
,
terrstr
());
mError
(
"qnode:%d, failed to drop since %s"
,
pMnode
->
dnodeId
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
sdbRelease
(
pMnode
->
pSdb
,
pObj
);
mndReleaseQnode
(
pMnode
,
pObj
);
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
mndReleaseUser
(
pMnode
,
pUser
);
return
code
;
}
}
static
int32_t
mndProcessCreateQnodeRsp
(
SMnodeMsg
*
pRsp
)
{
static
int32_t
mndProcessCreateQnodeRsp
(
SMnodeMsg
*
pRsp
)
{
...
...
source/dnode/mnode/impl/src/mndSnode.c
浏览文件 @
2c0f1e77
...
@@ -15,9 +15,11 @@
...
@@ -15,9 +15,11 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "mndSnode.h"
#include "mndSnode.h"
#include "mndAuth.h"
#include "mndDnode.h"
#include "mndDnode.h"
#include "mndShow.h"
#include "mndShow.h"
#include "mndTrans.h"
#include "mndTrans.h"
#include "mndUser.h"
#define TSDB_SNODE_VER_NUMBER 1
#define TSDB_SNODE_VER_NUMBER 1
#define TSDB_SNODE_RESERVE_SIZE 64
#define TSDB_SNODE_RESERVE_SIZE 64
...
@@ -259,39 +261,57 @@ CREATE_SNODE_OVER:
...
@@ -259,39 +261,57 @@ CREATE_SNODE_OVER:
static
int32_t
mndProcessCreateSnodeReq
(
SMnodeMsg
*
pReq
)
{
static
int32_t
mndProcessCreateSnodeReq
(
SMnodeMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
pMnode
;
SMnode
*
pMnode
=
pReq
->
pMnode
;
SMCreateSnodeReq
*
pCreate
=
pReq
->
rpcMsg
.
pCont
;
int32_t
code
=
-
1
;
SSnodeObj
*
pObj
=
NULL
;
SDnodeObj
*
pDnode
=
NULL
;
SUserObj
*
pUser
=
NULL
;
SMCreateSnodeReq
createReq
=
{
0
};
pCreate
->
dnodeId
=
htonl
(
pCreate
->
dnodeId
);
if
(
tDeserializeSMCreateDropQSBNodeReq
(
pReq
->
rpcMsg
.
pCont
,
pReq
->
rpcMsg
.
contLen
,
&
createReq
)
!=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
goto
CREATE_SNODE_OVER
;
}
mDebug
(
"snode:%d, start to create"
,
pCreate
->
dnodeId
);
mDebug
(
"snode:%d, start to create"
,
createReq
.
dnodeId
);
SSnodeObj
*
pObj
=
mndAcquireSnode
(
pMnode
,
pCreate
->
dnodeId
);
pObj
=
mndAcquireSnode
(
pMnode
,
createReq
.
dnodeId
);
if
(
pObj
!=
NULL
)
{
if
(
pObj
!=
NULL
)
{
mError
(
"snode:%d, snode already exist"
,
pObj
->
id
);
terrno
=
TSDB_CODE_MND_SNODE_ALREADY_EXIST
;
terrno
=
TSDB_CODE_MND_SNODE_ALREADY_EXIST
;
mndReleaseSnode
(
pMnode
,
pObj
);
goto
CREATE_SNODE_OVER
;
return
-
1
;
}
else
if
(
terrno
!=
TSDB_CODE_MND_SNODE_NOT_EXIST
)
{
}
else
if
(
terrno
!=
TSDB_CODE_MND_SNODE_NOT_EXIST
)
{
mError
(
"snode:%d, failed to create snode since %s"
,
pCreate
->
dnodeId
,
terrstr
());
goto
CREATE_SNODE_OVER
;
return
-
1
;
}
}
SDnodeObj
*
pDnode
=
mndAcquireDnode
(
pMnode
,
pCreate
->
dnodeId
);
pDnode
=
mndAcquireDnode
(
pMnode
,
createReq
.
dnodeId
);
if
(
pDnode
==
NULL
)
{
if
(
pDnode
==
NULL
)
{
mError
(
"snode:%d, dnode not exist"
,
pCreate
->
dnodeId
);
terrno
=
TSDB_CODE_MND_DNODE_NOT_EXIST
;
terrno
=
TSDB_CODE_MND_DNODE_NOT_EXIST
;
return
-
1
;
goto
CREATE_SNODE_OVER
;
}
}
int32_t
code
=
mndCreateSnode
(
pMnode
,
pReq
,
pDnode
,
pCreate
);
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
user
);
mndReleaseDnode
(
pMnode
,
pDnode
);
if
(
pUser
==
NULL
)
{
terrno
=
TSDB_CODE_MND_NO_USER_FROM_CONN
;
goto
CREATE_SNODE_OVER
;
}
if
(
mndCheckDropNodeAuth
(
pUser
))
{
goto
CREATE_SNODE_OVER
;
}
code
=
mndCreateSnode
(
pMnode
,
pReq
,
pDnode
,
&
createReq
);
if
(
code
==
0
)
code
=
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
if
(
code
!=
0
)
{
CREATE_SNODE_OVER:
mError
(
"snode:%d, failed to create since %s"
,
pCreate
->
dnodeId
,
terrstr
());
if
(
code
!=
0
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
mError
(
"snode:%d, failed to create since %s"
,
createReq
.
dnodeId
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
mndReleaseSnode
(
pMnode
,
pObj
);
mndReleaseDnode
(
pMnode
,
pDnode
);
mndReleaseUser
(
pMnode
,
pUser
);
return
code
;
}
}
static
int32_t
mndSetDropSnodeRedoLogs
(
STrans
*
pTrans
,
SSnodeObj
*
pObj
)
{
static
int32_t
mndSetDropSnodeRedoLogs
(
STrans
*
pTrans
,
SSnodeObj
*
pObj
)
{
...
@@ -355,32 +375,51 @@ DROP_SNODE_OVER:
...
@@ -355,32 +375,51 @@ DROP_SNODE_OVER:
static
int32_t
mndProcessDropSnodeReq
(
SMnodeMsg
*
pReq
)
{
static
int32_t
mndProcessDropSnodeReq
(
SMnodeMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
pMnode
;
SMnode
*
pMnode
=
pReq
->
pMnode
;
SMDropSnodeReq
*
pDrop
=
pReq
->
rpcMsg
.
pCont
;
int32_t
code
=
-
1
;
pDrop
->
dnodeId
=
htonl
(
pDrop
->
dnodeId
);
SUserObj
*
pUser
=
NULL
;
SSnodeObj
*
pObj
=
NULL
;
SMDropSnodeReq
dropReq
=
{
0
};
if
(
tDeserializeSMCreateDropQSBNodeReq
(
pReq
->
rpcMsg
.
pCont
,
pReq
->
rpcMsg
.
contLen
,
&
dropReq
)
!=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
goto
DROP_SNODE_OVER
;
}
mDebug
(
"snode:%d, start to drop"
,
pDrop
->
dnodeId
);
mDebug
(
"snode:%d, start to drop"
,
dropReq
.
dnodeId
);
if
(
pDrop
->
dnodeId
<=
0
)
{
if
(
dropReq
.
dnodeId
<=
0
)
{
terrno
=
TSDB_CODE_SDB_APP_ERROR
;
terrno
=
TSDB_CODE_SDB_APP_ERROR
;
mError
(
"snode:%d, failed to drop since %s"
,
pDrop
->
dnodeId
,
terrstr
());
goto
DROP_SNODE_OVER
;
return
-
1
;
}
}
SSnodeObj
*
pObj
=
mndAcquireSnode
(
pMnode
,
pDrop
->
dnodeId
);
pObj
=
mndAcquireSnode
(
pMnode
,
dropReq
.
dnodeId
);
if
(
pObj
==
NULL
)
{
if
(
pObj
==
NULL
)
{
mError
(
"snode:%d, failed to drop since %s"
,
pDrop
->
dnodeId
,
terrstr
());
goto
DROP_SNODE_OVER
;
return
-
1
;
}
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
user
);
if
(
pUser
==
NULL
)
{
terrno
=
TSDB_CODE_MND_NO_USER_FROM_CONN
;
goto
DROP_SNODE_OVER
;
}
if
(
mndCheckCreateNodeAuth
(
pUser
))
{
goto
DROP_SNODE_OVER
;
}
}
int32_t
code
=
mndDropSnode
(
pMnode
,
pReq
,
pObj
);
code
=
mndDropSnode
(
pMnode
,
pReq
,
pObj
);
if
(
code
!=
0
)
{
if
(
code
==
0
)
code
=
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
sdbRelease
(
pMnode
->
pSdb
,
pObj
);
DROP_SNODE_OVER:
if
(
code
!=
0
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
mError
(
"snode:%d, failed to drop since %s"
,
pMnode
->
dnodeId
,
terrstr
());
mError
(
"snode:%d, failed to drop since %s"
,
pMnode
->
dnodeId
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
sdbRelease
(
pMnode
->
pSdb
,
pObj
);
mndReleaseSnode
(
pMnode
,
pObj
);
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
mndReleaseUser
(
pMnode
,
pUser
);
return
code
;
}
}
static
int32_t
mndProcessCreateSnodeRsp
(
SMnodeMsg
*
pRsp
)
{
static
int32_t
mndProcessCreateSnodeRsp
(
SMnodeMsg
*
pRsp
)
{
...
...
source/dnode/mnode/impl/src/mndUser.c
浏览文件 @
2c0f1e77
...
@@ -302,7 +302,7 @@ static int32_t mndProcessCreateUserReq(SMnodeMsg *pReq) {
...
@@ -302,7 +302,7 @@ static int32_t mndProcessCreateUserReq(SMnodeMsg *pReq) {
SUserObj
*
pOperUser
=
NULL
;
SUserObj
*
pOperUser
=
NULL
;
SCreateUserReq
createReq
=
{
0
};
SCreateUserReq
createReq
=
{
0
};
if
(
tDeserializeSCreateUserReq
(
pReq
->
rpcMsg
.
pCont
,
&
createReq
)
==
NULL
)
goto
CREATE_USER_OVER
;
if
(
tDeserializeSCreateUserReq
(
pReq
->
rpcMsg
.
pCont
,
pReq
->
rpcMsg
.
contLen
,
&
createReq
)
!=
0
)
goto
CREATE_USER_OVER
;
mDebug
(
"user:%s, start to create"
,
createReq
.
user
);
mDebug
(
"user:%s, start to create"
,
createReq
.
user
);
...
@@ -402,7 +402,7 @@ static int32_t mndProcessAlterUserReq(SMnodeMsg *pReq) {
...
@@ -402,7 +402,7 @@ static int32_t mndProcessAlterUserReq(SMnodeMsg *pReq) {
SUserObj
newUser
=
{
0
};
SUserObj
newUser
=
{
0
};
SAlterUserReq
alterReq
=
{
0
};
SAlterUserReq
alterReq
=
{
0
};
if
(
tDeserializeSAlterUserReq
(
pReq
->
rpcMsg
.
pCont
,
&
alterReq
)
==
NULL
)
goto
ALTER_USER_OVER
;
if
(
tDeserializeSAlterUserReq
(
pReq
->
rpcMsg
.
pCont
,
pReq
->
rpcMsg
.
contLen
,
&
alterReq
)
!=
0
)
goto
ALTER_USER_OVER
;
mDebug
(
"user:%s, start to alter"
,
alterReq
.
user
);
mDebug
(
"user:%s, start to alter"
,
alterReq
.
user
);
...
@@ -537,7 +537,7 @@ static int32_t mndProcessDropUserReq(SMnodeMsg *pReq) {
...
@@ -537,7 +537,7 @@ static int32_t mndProcessDropUserReq(SMnodeMsg *pReq) {
SUserObj
*
pOperUser
=
NULL
;
SUserObj
*
pOperUser
=
NULL
;
SDropUserReq
dropReq
=
{
0
};
SDropUserReq
dropReq
=
{
0
};
if
(
tDeserializeSDropUserReq
(
pReq
->
rpcMsg
.
pCont
,
&
dropReq
)
==
NULL
)
goto
DROP_USER_OVER
;
if
(
tDeserializeSDropUserReq
(
pReq
->
rpcMsg
.
pCont
,
pReq
->
rpcMsg
.
contLen
,
&
dropReq
)
!=
0
)
goto
DROP_USER_OVER
;
mDebug
(
"user:%s, start to drop"
,
dropReq
.
user
);
mDebug
(
"user:%s, start to drop"
,
dropReq
.
user
);
...
@@ -583,7 +583,7 @@ static int32_t mndProcessGetUserAuthReq(SMnodeMsg *pReq) {
...
@@ -583,7 +583,7 @@ static int32_t mndProcessGetUserAuthReq(SMnodeMsg *pReq) {
SGetUserAuthReq
authReq
=
{
0
};
SGetUserAuthReq
authReq
=
{
0
};
SGetUserAuthRsp
authRsp
=
{
0
};
SGetUserAuthRsp
authRsp
=
{
0
};
if
(
tDeserializeSGetUserAuthReq
(
pReq
->
rpcMsg
.
pCont
,
&
authReq
)
==
NULL
)
goto
GET_AUTH_OVER
;
if
(
tDeserializeSGetUserAuthReq
(
pReq
->
rpcMsg
.
pCont
,
pReq
->
rpcMsg
.
contLen
,
&
authReq
)
!=
0
)
goto
GET_AUTH_OVER
;
mTrace
(
"user:%s, start to get auth"
,
authReq
.
user
);
mTrace
(
"user:%s, start to get auth"
,
authReq
.
user
);
...
@@ -614,15 +614,14 @@ static int32_t mndProcessGetUserAuthReq(SMnodeMsg *pReq) {
...
@@ -614,15 +614,14 @@ static int32_t mndProcessGetUserAuthReq(SMnodeMsg *pReq) {
sdbRelease
(
pSdb
,
pDb
);
sdbRelease
(
pSdb
,
pDb
);
}
}
int32_t
contLen
=
tSerializeSGetUserAuthRsp
(
NULL
,
&
authRsp
);
int32_t
contLen
=
tSerializeSGetUserAuthRsp
(
NULL
,
0
,
&
authRsp
);
void
*
pRsp
=
rpcMallocCont
(
contLen
);
void
*
pRsp
=
rpcMallocCont
(
contLen
);
if
(
pRsp
==
NULL
)
{
if
(
pRsp
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
GET_AUTH_OVER
;
goto
GET_AUTH_OVER
;
}
}
void
*
pBuf
=
pRsp
;
tSerializeSGetUserAuthRsp
(
pRsp
,
contLen
,
&
authRsp
);
tSerializeSGetUserAuthRsp
(
&
pBuf
,
&
authRsp
);
pReq
->
pCont
=
pRsp
;
pReq
->
pCont
=
pRsp
;
pReq
->
contLen
=
contLen
;
pReq
->
contLen
=
contLen
;
...
...
source/dnode/mnode/impl/test/bnode/bnode.cpp
浏览文件 @
2c0f1e77
...
@@ -52,10 +52,12 @@ TEST_F(MndTestBnode, 01_Show_Bnode) {
...
@@ -52,10 +52,12 @@ TEST_F(MndTestBnode, 01_Show_Bnode) {
TEST_F
(
MndTestBnode
,
02
_Create_Bnode
)
{
TEST_F
(
MndTestBnode
,
02
_Create_Bnode
)
{
{
{
int32_t
contLen
=
sizeof
(
SMCreateBnodeReq
);
SMCreateBnodeReq
createReq
=
{
0
};
createReq
.
dnodeId
=
2
;
SMCreateBnodeReq
*
pReq
=
(
SMCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSMCreateDropQSBNodeReq
(
NULL
,
0
,
&
createReq
);
pReq
->
dnodeId
=
htonl
(
2
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSMCreateDropQSBNodeReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -63,10 +65,12 @@ TEST_F(MndTestBnode, 02_Create_Bnode) {
...
@@ -63,10 +65,12 @@ TEST_F(MndTestBnode, 02_Create_Bnode) {
}
}
{
{
int32_t
contLen
=
sizeof
(
SMCreateBnodeReq
);
SMCreateBnodeReq
createReq
=
{
0
};
createReq
.
dnodeId
=
1
;
SMCreateBnodeReq
*
pReq
=
(
SMCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSMCreateDropQSBNodeReq
(
NULL
,
0
,
&
createReq
);
pReq
->
dnodeId
=
htonl
(
1
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSMCreateDropQSBNodeReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -83,10 +87,12 @@ TEST_F(MndTestBnode, 02_Create_Bnode) {
...
@@ -83,10 +87,12 @@ TEST_F(MndTestBnode, 02_Create_Bnode) {
}
}
{
{
int32_t
contLen
=
sizeof
(
SMCreateBnodeReq
);
SMCreateBnodeReq
createReq
=
{
0
};
createReq
.
dnodeId
=
1
;
SMCreateBnodeReq
*
pReq
=
(
SMCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSMCreateDropQSBNodeReq
(
NULL
,
0
,
&
createReq
);
pReq
->
dnodeId
=
htonl
(
1
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSMCreateDropQSBNodeReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -96,11 +102,13 @@ TEST_F(MndTestBnode, 02_Create_Bnode) {
...
@@ -96,11 +102,13 @@ TEST_F(MndTestBnode, 02_Create_Bnode) {
TEST_F
(
MndTestBnode
,
03
_Drop_Bnode
)
{
TEST_F
(
MndTestBnode
,
03
_Drop_Bnode
)
{
{
{
int32_t
contLen
=
sizeof
(
SCreateDnodeReq
);
SCreateDnodeReq
createReq
=
{
0
};
strcpy
(
createReq
.
fqdn
,
"localhost"
);
createReq
.
port
=
9019
;
SCreateDnodeReq
*
pReq
=
(
SCreateDnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSCreateDnodeReq
(
NULL
,
0
,
&
createReq
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
pReq
->
port
=
htonl
(
9019
);
tSerializeSCreateDnodeReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -113,10 +121,12 @@ TEST_F(MndTestBnode, 03_Drop_Bnode) {
...
@@ -113,10 +121,12 @@ TEST_F(MndTestBnode, 03_Drop_Bnode) {
}
}
{
{
int32_t
contLen
=
sizeof
(
SMCreateBnodeReq
);
SMCreateBnodeReq
createReq
=
{
0
};
createReq
.
dnodeId
=
2
;
SMCreateBnodeReq
*
pReq
=
(
SMCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSMCreateDropQSBNodeReq
(
NULL
,
0
,
&
createReq
);
pReq
->
dnodeId
=
htonl
(
2
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSMCreateDropQSBNodeReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -135,10 +145,12 @@ TEST_F(MndTestBnode, 03_Drop_Bnode) {
...
@@ -135,10 +145,12 @@ TEST_F(MndTestBnode, 03_Drop_Bnode) {
}
}
{
{
int32_t
contLen
=
sizeof
(
SMDropBnodeReq
);
SMDropBnodeReq
dropReq
=
{
0
};
dropReq
.
dnodeId
=
2
;
SMDropBnodeReq
*
pReq
=
(
SMDropBnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSMCreateDropQSBNodeReq
(
NULL
,
0
,
&
dropReq
);
pReq
->
dnodeId
=
htonl
(
2
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSMCreateDropQSBNodeReq
(
pReq
,
contLen
,
&
dropReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_BNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -154,10 +166,12 @@ TEST_F(MndTestBnode, 03_Drop_Bnode) {
...
@@ -154,10 +166,12 @@ TEST_F(MndTestBnode, 03_Drop_Bnode) {
}
}
{
{
int32_t
contLen
=
sizeof
(
SMDropBnodeReq
);
SMDropBnodeReq
dropReq
=
{
0
};
dropReq
.
dnodeId
=
2
;
SMDropBnodeReq
*
pReq
=
(
SMDropBnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSMCreateDropQSBNodeReq
(
NULL
,
0
,
&
dropReq
);
pReq
->
dnodeId
=
htonl
(
2
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSMCreateDropQSBNodeReq
(
pReq
,
contLen
,
&
dropReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_BNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -168,10 +182,12 @@ TEST_F(MndTestBnode, 03_Drop_Bnode) {
...
@@ -168,10 +182,12 @@ TEST_F(MndTestBnode, 03_Drop_Bnode) {
TEST_F
(
MndTestBnode
,
03
_Create_Bnode_Rollback
)
{
TEST_F
(
MndTestBnode
,
03
_Create_Bnode_Rollback
)
{
{
{
// send message first, then dnode2 crash, result is returned, and rollback is started
// send message first, then dnode2 crash, result is returned, and rollback is started
int32_t
contLen
=
sizeof
(
SMCreateBnodeReq
);
SMCreateBnodeReq
createReq
=
{
0
};
createReq
.
dnodeId
=
2
;
SMCreateBnodeReq
*
pReq
=
(
SMCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSMCreateDropQSBNodeReq
(
NULL
,
0
,
&
createReq
);
pReq
->
dnodeId
=
htonl
(
2
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSMCreateDropQSBNodeReq
(
pReq
,
contLen
,
&
createReq
);
server2
.
Stop
();
server2
.
Stop
();
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
...
@@ -181,10 +197,12 @@ TEST_F(MndTestBnode, 03_Create_Bnode_Rollback) {
...
@@ -181,10 +197,12 @@ TEST_F(MndTestBnode, 03_Create_Bnode_Rollback) {
{
{
// continue send message, bnode is creating
// continue send message, bnode is creating
int32_t
contLen
=
sizeof
(
SMCreateBnodeReq
);
SMCreateBnodeReq
createReq
=
{
0
};
createReq
.
dnodeId
=
2
;
SMCreateBnodeReq
*
pReq
=
(
SMCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSMCreateDropQSBNodeReq
(
NULL
,
0
,
&
createReq
);
pReq
->
dnodeId
=
htonl
(
2
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSMCreateDropQSBNodeReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -193,10 +211,12 @@ TEST_F(MndTestBnode, 03_Create_Bnode_Rollback) {
...
@@ -193,10 +211,12 @@ TEST_F(MndTestBnode, 03_Create_Bnode_Rollback) {
{
{
// continue send message, bnode is creating
// continue send message, bnode is creating
int32_t
contLen
=
sizeof
(
SMDropBnodeReq
);
SMDropBnodeReq
dropReq
=
{
0
};
dropReq
.
dnodeId
=
2
;
SMDropBnodeReq
*
pReq
=
(
SMDropBnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSMCreateDropQSBNodeReq
(
NULL
,
0
,
&
dropReq
);
pReq
->
dnodeId
=
htonl
(
2
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSMCreateDropQSBNodeReq
(
pReq
,
contLen
,
&
dropReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_BNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -212,10 +232,12 @@ TEST_F(MndTestBnode, 03_Create_Bnode_Rollback) {
...
@@ -212,10 +232,12 @@ TEST_F(MndTestBnode, 03_Create_Bnode_Rollback) {
int32_t
retryMax
=
20
;
int32_t
retryMax
=
20
;
for
(
retry
=
0
;
retry
<
retryMax
;
retry
++
)
{
for
(
retry
=
0
;
retry
<
retryMax
;
retry
++
)
{
int32_t
contLen
=
sizeof
(
SMCreateBnodeReq
);
SMCreateBnodeReq
createReq
=
{
0
};
createReq
.
dnodeId
=
2
;
SMCreateBnodeReq
*
pReq
=
(
SMCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSMCreateDropQSBNodeReq
(
NULL
,
0
,
&
createReq
);
pReq
->
dnodeId
=
htonl
(
2
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSMCreateDropQSBNodeReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -230,10 +252,12 @@ TEST_F(MndTestBnode, 03_Create_Bnode_Rollback) {
...
@@ -230,10 +252,12 @@ TEST_F(MndTestBnode, 03_Create_Bnode_Rollback) {
TEST_F
(
MndTestBnode
,
04
_Drop_Bnode_Rollback
)
{
TEST_F
(
MndTestBnode
,
04
_Drop_Bnode_Rollback
)
{
{
{
// send message first, then dnode2 crash, result is returned, and rollback is started
// send message first, then dnode2 crash, result is returned, and rollback is started
int32_t
contLen
=
sizeof
(
SMDropBnodeReq
);
SMDropBnodeReq
dropReq
=
{
0
};
dropReq
.
dnodeId
=
2
;
SMDropBnodeReq
*
pReq
=
(
SMDropBnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSMCreateDropQSBNodeReq
(
NULL
,
0
,
&
dropReq
);
pReq
->
dnodeId
=
htonl
(
2
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSMCreateDropQSBNodeReq
(
pReq
,
contLen
,
&
dropReq
);
server2
.
Stop
();
server2
.
Stop
();
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_BNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_BNODE
,
pReq
,
contLen
);
...
@@ -243,10 +267,12 @@ TEST_F(MndTestBnode, 04_Drop_Bnode_Rollback) {
...
@@ -243,10 +267,12 @@ TEST_F(MndTestBnode, 04_Drop_Bnode_Rollback) {
{
{
// continue send message, bnode is dropping
// continue send message, bnode is dropping
int32_t
contLen
=
sizeof
(
SMCreateBnodeReq
);
SMCreateBnodeReq
createReq
=
{
0
};
createReq
.
dnodeId
=
2
;
SMCreateBnodeReq
*
pReq
=
(
SMCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSMCreateDropQSBNodeReq
(
NULL
,
0
,
&
createReq
);
pReq
->
dnodeId
=
htonl
(
2
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSMCreateDropQSBNodeReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -255,10 +281,12 @@ TEST_F(MndTestBnode, 04_Drop_Bnode_Rollback) {
...
@@ -255,10 +281,12 @@ TEST_F(MndTestBnode, 04_Drop_Bnode_Rollback) {
{
{
// continue send message, bnode is dropping
// continue send message, bnode is dropping
int32_t
contLen
=
sizeof
(
SMDropBnodeReq
);
SMDropBnodeReq
dropReq
=
{
0
};
dropReq
.
dnodeId
=
2
;
SMDropBnodeReq
*
pReq
=
(
SMDropBnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSMCreateDropQSBNodeReq
(
NULL
,
0
,
&
dropReq
);
pReq
->
dnodeId
=
htonl
(
2
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSMCreateDropQSBNodeReq
(
pReq
,
contLen
,
&
dropReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_BNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -274,10 +302,12 @@ TEST_F(MndTestBnode, 04_Drop_Bnode_Rollback) {
...
@@ -274,10 +302,12 @@ TEST_F(MndTestBnode, 04_Drop_Bnode_Rollback) {
int32_t
retryMax
=
20
;
int32_t
retryMax
=
20
;
for
(
retry
=
0
;
retry
<
retryMax
;
retry
++
)
{
for
(
retry
=
0
;
retry
<
retryMax
;
retry
++
)
{
int32_t
contLen
=
sizeof
(
SMCreateBnodeReq
);
SMCreateBnodeReq
createReq
=
{
0
};
createReq
.
dnodeId
=
2
;
SMCreateBnodeReq
*
pReq
=
(
SMCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSMCreateDropQSBNodeReq
(
NULL
,
0
,
&
createReq
);
pReq
->
dnodeId
=
htonl
(
2
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSMCreateDropQSBNodeReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
...
source/dnode/mnode/impl/test/dnode/dnode.cpp
浏览文件 @
2c0f1e77
...
@@ -88,11 +88,13 @@ TEST_F(MndTestDnode, 02_ConfigDnode) {
...
@@ -88,11 +88,13 @@ TEST_F(MndTestDnode, 02_ConfigDnode) {
TEST_F
(
MndTestDnode
,
03
_Create_Dnode
)
{
TEST_F
(
MndTestDnode
,
03
_Create_Dnode
)
{
{
{
int32_t
contLen
=
sizeof
(
SCreateDnodeReq
);
SCreateDnodeReq
createReq
=
{
0
};
strcpy
(
createReq
.
fqdn
,
""
);
createReq
.
port
=
9024
;
SCreateDnodeReq
*
pReq
=
(
SCreateDnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSCreateDnodeReq
(
NULL
,
0
,
&
createReq
);
strcpy
(
pReq
->
fqdn
,
""
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
pReq
->
port
=
htonl
(
9024
);
tSerializeSCreateDnodeReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -100,11 +102,13 @@ TEST_F(MndTestDnode, 03_Create_Dnode) {
...
@@ -100,11 +102,13 @@ TEST_F(MndTestDnode, 03_Create_Dnode) {
}
}
{
{
int32_t
contLen
=
sizeof
(
SCreateDnodeReq
);
SCreateDnodeReq
createReq
=
{
0
};
strcpy
(
createReq
.
fqdn
,
"localhost"
);
createReq
.
port
=
-
1
;
SCreateDnodeReq
*
pReq
=
(
SCreateDnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSCreateDnodeReq
(
NULL
,
0
,
&
createReq
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
pReq
->
port
=
htonl
(
-
1
);
tSerializeSCreateDnodeReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -112,11 +116,13 @@ TEST_F(MndTestDnode, 03_Create_Dnode) {
...
@@ -112,11 +116,13 @@ TEST_F(MndTestDnode, 03_Create_Dnode) {
}
}
{
{
int32_t
contLen
=
sizeof
(
SCreateDnodeReq
);
SCreateDnodeReq
createReq
=
{
0
};
strcpy
(
createReq
.
fqdn
,
"localhost"
);
createReq
.
port
=
123456
;
SCreateDnodeReq
*
pReq
=
(
SCreateDnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSCreateDnodeReq
(
NULL
,
0
,
&
createReq
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
pReq
->
port
=
htonl
(
123456
);
tSerializeSCreateDnodeReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -124,11 +130,13 @@ TEST_F(MndTestDnode, 03_Create_Dnode) {
...
@@ -124,11 +130,13 @@ TEST_F(MndTestDnode, 03_Create_Dnode) {
}
}
{
{
int32_t
contLen
=
sizeof
(
SCreateDnodeReq
);
SCreateDnodeReq
createReq
=
{
0
};
strcpy
(
createReq
.
fqdn
,
"localhost"
);
createReq
.
port
=
9024
;
SCreateDnodeReq
*
pReq
=
(
SCreateDnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSCreateDnodeReq
(
NULL
,
0
,
&
createReq
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
pReq
->
port
=
htonl
(
9024
);
tSerializeSCreateDnodeReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -136,11 +144,13 @@ TEST_F(MndTestDnode, 03_Create_Dnode) {
...
@@ -136,11 +144,13 @@ TEST_F(MndTestDnode, 03_Create_Dnode) {
}
}
{
{
int32_t
contLen
=
sizeof
(
SCreateDnodeReq
);
SCreateDnodeReq
createReq
=
{
0
};
strcpy
(
createReq
.
fqdn
,
"localhost"
);
createReq
.
port
=
9024
;
SCreateDnodeReq
*
pReq
=
(
SCreateDnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSCreateDnodeReq
(
NULL
,
0
,
&
createReq
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
pReq
->
port
=
htonl
(
9024
);
tSerializeSCreateDnodeReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -172,10 +182,12 @@ TEST_F(MndTestDnode, 03_Create_Dnode) {
...
@@ -172,10 +182,12 @@ TEST_F(MndTestDnode, 03_Create_Dnode) {
TEST_F
(
MndTestDnode
,
04
_Drop_Dnode
)
{
TEST_F
(
MndTestDnode
,
04
_Drop_Dnode
)
{
{
{
int32_t
contLen
=
sizeof
(
SDropDnodeReq
);
SDropDnodeReq
dropReq
=
{
0
};
dropReq
.
dnodeId
=
-
3
;
SDropDnodeReq
*
pReq
=
(
SDropDnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSDropDnodeReq
(
NULL
,
0
,
&
dropReq
);
pReq
->
dnodeId
=
htonl
(
-
3
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSDropDnodeReq
(
pReq
,
contLen
,
&
dropReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_DNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -183,10 +195,12 @@ TEST_F(MndTestDnode, 04_Drop_Dnode) {
...
@@ -183,10 +195,12 @@ TEST_F(MndTestDnode, 04_Drop_Dnode) {
}
}
{
{
int32_t
contLen
=
sizeof
(
SDropDnodeReq
);
SDropDnodeReq
dropReq
=
{
0
};
dropReq
.
dnodeId
=
5
;
SDropDnodeReq
*
pReq
=
(
SDropDnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSDropDnodeReq
(
NULL
,
0
,
&
dropReq
);
pReq
->
dnodeId
=
htonl
(
5
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSDropDnodeReq
(
pReq
,
contLen
,
&
dropReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_DNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -194,10 +208,12 @@ TEST_F(MndTestDnode, 04_Drop_Dnode) {
...
@@ -194,10 +208,12 @@ TEST_F(MndTestDnode, 04_Drop_Dnode) {
}
}
{
{
int32_t
contLen
=
sizeof
(
SDropDnodeReq
);
SDropDnodeReq
dropReq
=
{
0
};
dropReq
.
dnodeId
=
2
;
SDropDnodeReq
*
pReq
=
(
SDropDnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSDropDnodeReq
(
NULL
,
0
,
&
dropReq
);
pReq
->
dnodeId
=
htonl
(
2
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSDropDnodeReq
(
pReq
,
contLen
,
&
dropReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_DNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -205,10 +221,12 @@ TEST_F(MndTestDnode, 04_Drop_Dnode) {
...
@@ -205,10 +221,12 @@ TEST_F(MndTestDnode, 04_Drop_Dnode) {
}
}
{
{
int32_t
contLen
=
sizeof
(
SDropDnodeReq
);
SDropDnodeReq
dropReq
=
{
0
};
dropReq
.
dnodeId
=
2
;
SDropDnodeReq
*
pReq
=
(
SDropDnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSDropDnodeReq
(
NULL
,
0
,
&
dropReq
);
pReq
->
dnodeId
=
htonl
(
2
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSDropDnodeReq
(
pReq
,
contLen
,
&
dropReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_DNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -235,11 +253,13 @@ TEST_F(MndTestDnode, 04_Drop_Dnode) {
...
@@ -235,11 +253,13 @@ TEST_F(MndTestDnode, 04_Drop_Dnode) {
TEST_F
(
MndTestDnode
,
05
_Create_Drop_Restart_Dnode
)
{
TEST_F
(
MndTestDnode
,
05
_Create_Drop_Restart_Dnode
)
{
{
{
int32_t
contLen
=
sizeof
(
SCreateDnodeReq
);
SCreateDnodeReq
createReq
=
{
0
};
strcpy
(
createReq
.
fqdn
,
"localhost"
);
createReq
.
port
=
9025
;
SCreateDnodeReq
*
pReq
=
(
SCreateDnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSCreateDnodeReq
(
NULL
,
0
,
&
createReq
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
pReq
->
port
=
htonl
(
9025
);
tSerializeSCreateDnodeReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -247,11 +267,13 @@ TEST_F(MndTestDnode, 05_Create_Drop_Restart_Dnode) {
...
@@ -247,11 +267,13 @@ TEST_F(MndTestDnode, 05_Create_Drop_Restart_Dnode) {
}
}
{
{
int32_t
contLen
=
sizeof
(
SCreateDnodeReq
);
SCreateDnodeReq
createReq
=
{
0
};
strcpy
(
createReq
.
fqdn
,
"localhost"
);
createReq
.
port
=
9026
;
SCreateDnodeReq
*
pReq
=
(
SCreateDnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSCreateDnodeReq
(
NULL
,
0
,
&
createReq
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
pReq
->
port
=
htonl
(
9026
);
tSerializeSCreateDnodeReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -259,11 +281,13 @@ TEST_F(MndTestDnode, 05_Create_Drop_Restart_Dnode) {
...
@@ -259,11 +281,13 @@ TEST_F(MndTestDnode, 05_Create_Drop_Restart_Dnode) {
}
}
{
{
int32_t
contLen
=
sizeof
(
SCreateDnodeReq
);
SCreateDnodeReq
createReq
=
{
0
};
strcpy
(
createReq
.
fqdn
,
"localhost"
);
createReq
.
port
=
9027
;
SCreateDnodeReq
*
pReq
=
(
SCreateDnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSCreateDnodeReq
(
NULL
,
0
,
&
createReq
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
pReq
->
port
=
htonl
(
9027
);
tSerializeSCreateDnodeReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
...
source/dnode/mnode/impl/test/mnode/mnode.cpp
浏览文件 @
2c0f1e77
...
@@ -87,11 +87,13 @@ TEST_F(MndTestMnode, 03_Create_Mnode_Invalid_Id) {
...
@@ -87,11 +87,13 @@ TEST_F(MndTestMnode, 03_Create_Mnode_Invalid_Id) {
TEST_F
(
MndTestMnode
,
04
_Create_Mnode
)
{
TEST_F
(
MndTestMnode
,
04
_Create_Mnode
)
{
{
{
// create dnode
// create dnode
int32_t
contLen
=
sizeof
(
SCreateDnodeReq
);
SCreateDnodeReq
createReq
=
{
0
};
strcpy
(
createReq
.
fqdn
,
"localhost"
);
createReq
.
port
=
9029
;
SCreateDnodeReq
*
pReq
=
(
SCreateDnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSCreateDnodeReq
(
NULL
,
0
,
&
createReq
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
pReq
->
port
=
htonl
(
9029
);
tSerializeSCreateDnodeReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
...
source/dnode/mnode/impl/test/qnode/qnode.cpp
浏览文件 @
2c0f1e77
...
@@ -52,10 +52,12 @@ TEST_F(MndTestQnode, 01_Show_Qnode) {
...
@@ -52,10 +52,12 @@ TEST_F(MndTestQnode, 01_Show_Qnode) {
TEST_F
(
MndTestQnode
,
02
_Create_Qnode
)
{
TEST_F
(
MndTestQnode
,
02
_Create_Qnode
)
{
{
{
int32_t
contLen
=
sizeof
(
SMCreateQnodeReq
);
SMCreateQnodeReq
createReq
=
{
0
};
createReq
.
dnodeId
=
2
;
SMCreateQnodeReq
*
pReq
=
(
SMCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSMCreateDropQSBNodeReq
(
NULL
,
0
,
&
createReq
);
pReq
->
dnodeId
=
htonl
(
2
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSMCreateDropQSBNodeReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -63,10 +65,12 @@ TEST_F(MndTestQnode, 02_Create_Qnode) {
...
@@ -63,10 +65,12 @@ TEST_F(MndTestQnode, 02_Create_Qnode) {
}
}
{
{
int32_t
contLen
=
sizeof
(
SMCreateQnodeReq
);
SMCreateQnodeReq
createReq
=
{
0
};
createReq
.
dnodeId
=
1
;
SMCreateQnodeReq
*
pReq
=
(
SMCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSMCreateDropQSBNodeReq
(
NULL
,
0
,
&
createReq
);
pReq
->
dnodeId
=
htonl
(
1
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSMCreateDropQSBNodeReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -83,10 +87,12 @@ TEST_F(MndTestQnode, 02_Create_Qnode) {
...
@@ -83,10 +87,12 @@ TEST_F(MndTestQnode, 02_Create_Qnode) {
}
}
{
{
int32_t
contLen
=
sizeof
(
SMCreateQnodeReq
);
SMCreateQnodeReq
createReq
=
{
0
};
createReq
.
dnodeId
=
1
;
SMCreateQnodeReq
*
pReq
=
(
SMCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSMCreateDropQSBNodeReq
(
NULL
,
0
,
&
createReq
);
pReq
->
dnodeId
=
htonl
(
1
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSMCreateDropQSBNodeReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -96,11 +102,13 @@ TEST_F(MndTestQnode, 02_Create_Qnode) {
...
@@ -96,11 +102,13 @@ TEST_F(MndTestQnode, 02_Create_Qnode) {
TEST_F
(
MndTestQnode
,
03
_Drop_Qnode
)
{
TEST_F
(
MndTestQnode
,
03
_Drop_Qnode
)
{
{
{
int32_t
contLen
=
sizeof
(
SCreateDnodeReq
);
SCreateDnodeReq
createReq
=
{
0
};
strcpy
(
createReq
.
fqdn
,
"localhost"
);
createReq
.
port
=
9015
;
SCreateDnodeReq
*
pReq
=
(
SCreateDnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSCreateDnodeReq
(
NULL
,
0
,
&
createReq
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
pReq
->
port
=
htonl
(
9015
);
tSerializeSCreateDnodeReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -113,10 +121,12 @@ TEST_F(MndTestQnode, 03_Drop_Qnode) {
...
@@ -113,10 +121,12 @@ TEST_F(MndTestQnode, 03_Drop_Qnode) {
}
}
{
{
int32_t
contLen
=
sizeof
(
SMCreateQnodeReq
);
SMCreateQnodeReq
createReq
=
{
0
};
createReq
.
dnodeId
=
2
;
SMCreateQnodeReq
*
pReq
=
(
SMCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSMCreateDropQSBNodeReq
(
NULL
,
0
,
&
createReq
);
pReq
->
dnodeId
=
htonl
(
2
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSMCreateDropQSBNodeReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -135,10 +145,12 @@ TEST_F(MndTestQnode, 03_Drop_Qnode) {
...
@@ -135,10 +145,12 @@ TEST_F(MndTestQnode, 03_Drop_Qnode) {
}
}
{
{
int32_t
contLen
=
sizeof
(
SMDropQnodeReq
);
SMDropQnodeReq
dropReq
=
{
0
};
dropReq
.
dnodeId
=
2
;
SMDropQnodeReq
*
pReq
=
(
SMDropQnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSMCreateDropQSBNodeReq
(
NULL
,
0
,
&
dropReq
);
pReq
->
dnodeId
=
htonl
(
2
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSMCreateDropQSBNodeReq
(
pReq
,
contLen
,
&
dropReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_QNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -154,10 +166,12 @@ TEST_F(MndTestQnode, 03_Drop_Qnode) {
...
@@ -154,10 +166,12 @@ TEST_F(MndTestQnode, 03_Drop_Qnode) {
}
}
{
{
int32_t
contLen
=
sizeof
(
SMDropQnodeReq
);
SMDropQnodeReq
dropReq
=
{
0
};
dropReq
.
dnodeId
=
2
;
SMDropQnodeReq
*
pReq
=
(
SMDropQnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSMCreateDropQSBNodeReq
(
NULL
,
0
,
&
dropReq
);
pReq
->
dnodeId
=
htonl
(
2
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSMCreateDropQSBNodeReq
(
pReq
,
contLen
,
&
dropReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_QNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -168,10 +182,12 @@ TEST_F(MndTestQnode, 03_Drop_Qnode) {
...
@@ -168,10 +182,12 @@ TEST_F(MndTestQnode, 03_Drop_Qnode) {
TEST_F
(
MndTestQnode
,
03
_Create_Qnode_Rollback
)
{
TEST_F
(
MndTestQnode
,
03
_Create_Qnode_Rollback
)
{
{
{
// send message first, then dnode2 crash, result is returned, and rollback is started
// send message first, then dnode2 crash, result is returned, and rollback is started
int32_t
contLen
=
sizeof
(
SMCreateQnodeReq
);
SMCreateQnodeReq
createReq
=
{
0
};
createReq
.
dnodeId
=
2
;
SMCreateQnodeReq
*
pReq
=
(
SMCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSMCreateDropQSBNodeReq
(
NULL
,
0
,
&
createReq
);
pReq
->
dnodeId
=
htonl
(
2
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSMCreateDropQSBNodeReq
(
pReq
,
contLen
,
&
createReq
);
server2
.
Stop
();
server2
.
Stop
();
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
...
@@ -181,10 +197,12 @@ TEST_F(MndTestQnode, 03_Create_Qnode_Rollback) {
...
@@ -181,10 +197,12 @@ TEST_F(MndTestQnode, 03_Create_Qnode_Rollback) {
{
{
// continue send message, qnode is creating
// continue send message, qnode is creating
int32_t
contLen
=
sizeof
(
SMCreateQnodeReq
);
SMCreateQnodeReq
createReq
=
{
0
};
createReq
.
dnodeId
=
2
;
SMCreateQnodeReq
*
pReq
=
(
SMCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSMCreateDropQSBNodeReq
(
NULL
,
0
,
&
createReq
);
pReq
->
dnodeId
=
htonl
(
2
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSMCreateDropQSBNodeReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -193,10 +211,12 @@ TEST_F(MndTestQnode, 03_Create_Qnode_Rollback) {
...
@@ -193,10 +211,12 @@ TEST_F(MndTestQnode, 03_Create_Qnode_Rollback) {
{
{
// continue send message, qnode is creating
// continue send message, qnode is creating
int32_t
contLen
=
sizeof
(
SMDropQnodeReq
);
SMDropQnodeReq
dropReq
=
{
0
};
dropReq
.
dnodeId
=
2
;
SMDropQnodeReq
*
pReq
=
(
SMDropQnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSMCreateDropQSBNodeReq
(
NULL
,
0
,
&
dropReq
);
pReq
->
dnodeId
=
htonl
(
2
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSMCreateDropQSBNodeReq
(
pReq
,
contLen
,
&
dropReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_QNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -212,10 +232,12 @@ TEST_F(MndTestQnode, 03_Create_Qnode_Rollback) {
...
@@ -212,10 +232,12 @@ TEST_F(MndTestQnode, 03_Create_Qnode_Rollback) {
int32_t
retryMax
=
20
;
int32_t
retryMax
=
20
;
for
(
retry
=
0
;
retry
<
retryMax
;
retry
++
)
{
for
(
retry
=
0
;
retry
<
retryMax
;
retry
++
)
{
int32_t
contLen
=
sizeof
(
SMCreateQnodeReq
);
SMCreateQnodeReq
createReq
=
{
0
};
createReq
.
dnodeId
=
2
;
SMCreateQnodeReq
*
pReq
=
(
SMCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSMCreateDropQSBNodeReq
(
NULL
,
0
,
&
createReq
);
pReq
->
dnodeId
=
htonl
(
2
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSMCreateDropQSBNodeReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -230,10 +252,12 @@ TEST_F(MndTestQnode, 03_Create_Qnode_Rollback) {
...
@@ -230,10 +252,12 @@ TEST_F(MndTestQnode, 03_Create_Qnode_Rollback) {
TEST_F
(
MndTestQnode
,
04
_Drop_Qnode_Rollback
)
{
TEST_F
(
MndTestQnode
,
04
_Drop_Qnode_Rollback
)
{
{
{
// send message first, then dnode2 crash, result is returned, and rollback is started
// send message first, then dnode2 crash, result is returned, and rollback is started
int32_t
contLen
=
sizeof
(
SMDropQnodeReq
);
SMDropQnodeReq
dropReq
=
{
0
};
dropReq
.
dnodeId
=
2
;
SMDropQnodeReq
*
pReq
=
(
SMDropQnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSMCreateDropQSBNodeReq
(
NULL
,
0
,
&
dropReq
);
pReq
->
dnodeId
=
htonl
(
2
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSMCreateDropQSBNodeReq
(
pReq
,
contLen
,
&
dropReq
);
server2
.
Stop
();
server2
.
Stop
();
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_QNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_QNODE
,
pReq
,
contLen
);
...
@@ -243,11 +267,12 @@ TEST_F(MndTestQnode, 04_Drop_Qnode_Rollback) {
...
@@ -243,11 +267,12 @@ TEST_F(MndTestQnode, 04_Drop_Qnode_Rollback) {
{
{
// continue send message, qnode is dropping
// continue send message, qnode is dropping
int32_t
contLen
=
sizeof
(
SMCreateQnodeReq
);
SMCreateQnodeReq
createReq
=
{
0
};
createReq
.
dnodeId
=
2
;
SMCreateQnodeReq
*
pReq
=
(
SMCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
int32_t
contLen
=
tSerializeSMCreateDropQSBNodeReq
(
NULL
,
0
,
&
createReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSMCreateDropQSBNodeReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_SDB_OBJ_DROPPING
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_SDB_OBJ_DROPPING
);
...
@@ -255,10 +280,12 @@ TEST_F(MndTestQnode, 04_Drop_Qnode_Rollback) {
...
@@ -255,10 +280,12 @@ TEST_F(MndTestQnode, 04_Drop_Qnode_Rollback) {
{
{
// continue send message, qnode is dropping
// continue send message, qnode is dropping
int32_t
contLen
=
sizeof
(
SMDropQnodeReq
);
SMDropQnodeReq
dropReq
=
{
0
};
dropReq
.
dnodeId
=
2
;
SMDropQnodeReq
*
pReq
=
(
SMDropQnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSMCreateDropQSBNodeReq
(
NULL
,
0
,
&
dropReq
);
pReq
->
dnodeId
=
htonl
(
2
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSMCreateDropQSBNodeReq
(
pReq
,
contLen
,
&
dropReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_QNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -274,11 +301,12 @@ TEST_F(MndTestQnode, 04_Drop_Qnode_Rollback) {
...
@@ -274,11 +301,12 @@ TEST_F(MndTestQnode, 04_Drop_Qnode_Rollback) {
int32_t
retryMax
=
20
;
int32_t
retryMax
=
20
;
for
(
retry
=
0
;
retry
<
retryMax
;
retry
++
)
{
for
(
retry
=
0
;
retry
<
retryMax
;
retry
++
)
{
int32_t
contLen
=
sizeof
(
SMCreateQnodeReq
);
SMCreateQnodeReq
createReq
=
{
0
};
createReq
.
dnodeId
=
2
;
SMCreateQnodeReq
*
pReq
=
(
SMCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
int32_t
contLen
=
tSerializeSMCreateDropQSBNodeReq
(
NULL
,
0
,
&
createReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSMCreateDropQSBNodeReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
if
(
pRsp
->
code
==
0
)
break
;
if
(
pRsp
->
code
==
0
)
break
;
...
...
source/dnode/mnode/impl/test/snode/snode.cpp
浏览文件 @
2c0f1e77
...
@@ -52,10 +52,12 @@ TEST_F(MndTestSnode, 01_Show_Snode) {
...
@@ -52,10 +52,12 @@ TEST_F(MndTestSnode, 01_Show_Snode) {
TEST_F
(
MndTestSnode
,
02
_Create_Snode
)
{
TEST_F
(
MndTestSnode
,
02
_Create_Snode
)
{
{
{
int32_t
contLen
=
sizeof
(
SMCreateSnodeReq
);
SMCreateSnodeReq
createReq
=
{
0
};
createReq
.
dnodeId
=
2
;
SMCreateSnodeReq
*
pReq
=
(
SMCreateSnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSMCreateDropQSBNodeReq
(
NULL
,
0
,
&
createReq
);
pReq
->
dnodeId
=
htonl
(
2
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSMCreateDropQSBNodeReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -63,10 +65,12 @@ TEST_F(MndTestSnode, 02_Create_Snode) {
...
@@ -63,10 +65,12 @@ TEST_F(MndTestSnode, 02_Create_Snode) {
}
}
{
{
int32_t
contLen
=
sizeof
(
SMCreateSnodeReq
);
SMCreateSnodeReq
createReq
=
{
0
};
createReq
.
dnodeId
=
1
;
SMCreateSnodeReq
*
pReq
=
(
SMCreateSnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSMCreateDropQSBNodeReq
(
NULL
,
0
,
&
createReq
);
pReq
->
dnodeId
=
htonl
(
1
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSMCreateDropQSBNodeReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -83,10 +87,12 @@ TEST_F(MndTestSnode, 02_Create_Snode) {
...
@@ -83,10 +87,12 @@ TEST_F(MndTestSnode, 02_Create_Snode) {
}
}
{
{
int32_t
contLen
=
sizeof
(
SMCreateSnodeReq
);
SMCreateSnodeReq
createReq
=
{
0
};
createReq
.
dnodeId
=
1
;
SMCreateSnodeReq
*
pReq
=
(
SMCreateSnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSMCreateDropQSBNodeReq
(
NULL
,
0
,
&
createReq
);
pReq
->
dnodeId
=
htonl
(
1
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSMCreateDropQSBNodeReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -96,11 +102,13 @@ TEST_F(MndTestSnode, 02_Create_Snode) {
...
@@ -96,11 +102,13 @@ TEST_F(MndTestSnode, 02_Create_Snode) {
TEST_F
(
MndTestSnode
,
03
_Drop_Snode
)
{
TEST_F
(
MndTestSnode
,
03
_Drop_Snode
)
{
{
{
int32_t
contLen
=
sizeof
(
SCreateDnodeReq
);
SCreateDnodeReq
createReq
=
{
0
};
strcpy
(
createReq
.
fqdn
,
"localhost"
);
createReq
.
port
=
9017
;
SCreateDnodeReq
*
pReq
=
(
SCreateDnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSCreateDnodeReq
(
NULL
,
0
,
&
createReq
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
pReq
->
port
=
htonl
(
9017
);
tSerializeSCreateDnodeReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -113,10 +121,12 @@ TEST_F(MndTestSnode, 03_Drop_Snode) {
...
@@ -113,10 +121,12 @@ TEST_F(MndTestSnode, 03_Drop_Snode) {
}
}
{
{
int32_t
contLen
=
sizeof
(
SMCreateSnodeReq
);
SMCreateSnodeReq
createReq
=
{
0
};
createReq
.
dnodeId
=
2
;
SMCreateSnodeReq
*
pReq
=
(
SMCreateSnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSMCreateDropQSBNodeReq
(
NULL
,
0
,
&
createReq
);
pReq
->
dnodeId
=
htonl
(
2
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSMCreateDropQSBNodeReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -135,10 +145,12 @@ TEST_F(MndTestSnode, 03_Drop_Snode) {
...
@@ -135,10 +145,12 @@ TEST_F(MndTestSnode, 03_Drop_Snode) {
}
}
{
{
int32_t
contLen
=
sizeof
(
SMDropSnodeReq
);
SMDropSnodeReq
dropReq
=
{
0
};
dropReq
.
dnodeId
=
2
;
SMDropSnodeReq
*
pReq
=
(
SMDropSnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSMCreateDropQSBNodeReq
(
NULL
,
0
,
&
dropReq
);
pReq
->
dnodeId
=
htonl
(
2
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSMCreateDropQSBNodeReq
(
pReq
,
contLen
,
&
dropReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_SNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -154,10 +166,12 @@ TEST_F(MndTestSnode, 03_Drop_Snode) {
...
@@ -154,10 +166,12 @@ TEST_F(MndTestSnode, 03_Drop_Snode) {
}
}
{
{
int32_t
contLen
=
sizeof
(
SMDropSnodeReq
);
SMDropSnodeReq
dropReq
=
{
0
};
dropReq
.
dnodeId
=
2
;
SMDropSnodeReq
*
pReq
=
(
SMDropSnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSMCreateDropQSBNodeReq
(
NULL
,
0
,
&
dropReq
);
pReq
->
dnodeId
=
htonl
(
2
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSMCreateDropQSBNodeReq
(
pReq
,
contLen
,
&
dropReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_SNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -168,10 +182,12 @@ TEST_F(MndTestSnode, 03_Drop_Snode) {
...
@@ -168,10 +182,12 @@ TEST_F(MndTestSnode, 03_Drop_Snode) {
TEST_F
(
MndTestSnode
,
03
_Create_Snode_Rollback
)
{
TEST_F
(
MndTestSnode
,
03
_Create_Snode_Rollback
)
{
{
{
// send message first, then dnode2 crash, result is returned, and rollback is started
// send message first, then dnode2 crash, result is returned, and rollback is started
int32_t
contLen
=
sizeof
(
SMCreateSnodeReq
);
SMCreateSnodeReq
createReq
=
{
0
};
createReq
.
dnodeId
=
2
;
SMCreateSnodeReq
*
pReq
=
(
SMCreateSnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSMCreateDropQSBNodeReq
(
NULL
,
0
,
&
createReq
);
pReq
->
dnodeId
=
htonl
(
2
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSMCreateDropQSBNodeReq
(
pReq
,
contLen
,
&
createReq
);
server2
.
Stop
();
server2
.
Stop
();
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
...
@@ -181,10 +197,12 @@ TEST_F(MndTestSnode, 03_Create_Snode_Rollback) {
...
@@ -181,10 +197,12 @@ TEST_F(MndTestSnode, 03_Create_Snode_Rollback) {
{
{
// continue send message, snode is creating
// continue send message, snode is creating
int32_t
contLen
=
sizeof
(
SMCreateSnodeReq
);
SMCreateSnodeReq
createReq
=
{
0
};
createReq
.
dnodeId
=
2
;
SMCreateSnodeReq
*
pReq
=
(
SMCreateSnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSMCreateDropQSBNodeReq
(
NULL
,
0
,
&
createReq
);
pReq
->
dnodeId
=
htonl
(
2
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSMCreateDropQSBNodeReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -193,10 +211,12 @@ TEST_F(MndTestSnode, 03_Create_Snode_Rollback) {
...
@@ -193,10 +211,12 @@ TEST_F(MndTestSnode, 03_Create_Snode_Rollback) {
{
{
// continue send message, snode is creating
// continue send message, snode is creating
int32_t
contLen
=
sizeof
(
SMDropSnodeReq
);
SMDropSnodeReq
dropReq
=
{
0
};
dropReq
.
dnodeId
=
2
;
SMDropSnodeReq
*
pReq
=
(
SMDropSnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSMCreateDropQSBNodeReq
(
NULL
,
0
,
&
dropReq
);
pReq
->
dnodeId
=
htonl
(
2
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSMCreateDropQSBNodeReq
(
pReq
,
contLen
,
&
dropReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_SNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -212,10 +232,12 @@ TEST_F(MndTestSnode, 03_Create_Snode_Rollback) {
...
@@ -212,10 +232,12 @@ TEST_F(MndTestSnode, 03_Create_Snode_Rollback) {
int32_t
retryMax
=
20
;
int32_t
retryMax
=
20
;
for
(
retry
=
0
;
retry
<
retryMax
;
retry
++
)
{
for
(
retry
=
0
;
retry
<
retryMax
;
retry
++
)
{
int32_t
contLen
=
sizeof
(
SMCreateSnodeReq
);
SMCreateSnodeReq
createReq
=
{
0
};
createReq
.
dnodeId
=
2
;
SMCreateSnodeReq
*
pReq
=
(
SMCreateSnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSMCreateDropQSBNodeReq
(
NULL
,
0
,
&
createReq
);
pReq
->
dnodeId
=
htonl
(
2
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSMCreateDropQSBNodeReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -230,10 +252,12 @@ TEST_F(MndTestSnode, 03_Create_Snode_Rollback) {
...
@@ -230,10 +252,12 @@ TEST_F(MndTestSnode, 03_Create_Snode_Rollback) {
TEST_F
(
MndTestSnode
,
04
_Drop_Snode_Rollback
)
{
TEST_F
(
MndTestSnode
,
04
_Drop_Snode_Rollback
)
{
{
{
// send message first, then dnode2 crash, result is returned, and rollback is started
// send message first, then dnode2 crash, result is returned, and rollback is started
int32_t
contLen
=
sizeof
(
SMDropSnodeReq
);
SMDropSnodeReq
dropReq
=
{
0
};
dropReq
.
dnodeId
=
2
;
SMDropSnodeReq
*
pReq
=
(
SMDropSnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSMCreateDropQSBNodeReq
(
NULL
,
0
,
&
dropReq
);
pReq
->
dnodeId
=
htonl
(
2
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSMCreateDropQSBNodeReq
(
pReq
,
contLen
,
&
dropReq
);
server2
.
Stop
();
server2
.
Stop
();
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_SNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_SNODE
,
pReq
,
contLen
);
...
@@ -243,10 +267,12 @@ TEST_F(MndTestSnode, 04_Drop_Snode_Rollback) {
...
@@ -243,10 +267,12 @@ TEST_F(MndTestSnode, 04_Drop_Snode_Rollback) {
{
{
// continue send message, snode is dropping
// continue send message, snode is dropping
int32_t
contLen
=
sizeof
(
SMCreateSnodeReq
);
SMCreateSnodeReq
createReq
=
{
0
};
createReq
.
dnodeId
=
2
;
SMCreateSnodeReq
*
pReq
=
(
SMCreateSnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSMCreateDropQSBNodeReq
(
NULL
,
0
,
&
createReq
);
pReq
->
dnodeId
=
htonl
(
2
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSMCreateDropQSBNodeReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -255,10 +281,12 @@ TEST_F(MndTestSnode, 04_Drop_Snode_Rollback) {
...
@@ -255,10 +281,12 @@ TEST_F(MndTestSnode, 04_Drop_Snode_Rollback) {
{
{
// continue send message, snode is dropping
// continue send message, snode is dropping
int32_t
contLen
=
sizeof
(
SMDropSnodeReq
);
SMDropSnodeReq
dropReq
=
{
0
};
dropReq
.
dnodeId
=
2
;
SMDropSnodeReq
*
pReq
=
(
SMDropSnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSMCreateDropQSBNodeReq
(
NULL
,
0
,
&
dropReq
);
pReq
->
dnodeId
=
htonl
(
2
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSMCreateDropQSBNodeReq
(
pReq
,
contLen
,
&
dropReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_SNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -274,10 +302,12 @@ TEST_F(MndTestSnode, 04_Drop_Snode_Rollback) {
...
@@ -274,10 +302,12 @@ TEST_F(MndTestSnode, 04_Drop_Snode_Rollback) {
int32_t
retryMax
=
20
;
int32_t
retryMax
=
20
;
for
(
retry
=
0
;
retry
<
retryMax
;
retry
++
)
{
for
(
retry
=
0
;
retry
<
retryMax
;
retry
++
)
{
int32_t
contLen
=
sizeof
(
SMCreateSnodeReq
);
SMCreateSnodeReq
createReq
=
{
0
};
createReq
.
dnodeId
=
2
;
SMCreateSnodeReq
*
pReq
=
(
SMCreateSnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSMCreateDropQSBNodeReq
(
NULL
,
0
,
&
createReq
);
pReq
->
dnodeId
=
htonl
(
2
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSMCreateDropQSBNodeReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
...
source/dnode/mnode/impl/test/trans/trans.cpp
浏览文件 @
2c0f1e77
...
@@ -67,10 +67,9 @@ TEST_F(MndTestTrans, 01_Create_User_Crash) {
...
@@ -67,10 +67,9 @@ TEST_F(MndTestTrans, 01_Create_User_Crash) {
strcpy
(
createReq
.
user
,
"u1"
);
strcpy
(
createReq
.
user
,
"u1"
);
strcpy
(
createReq
.
pass
,
"p1"
);
strcpy
(
createReq
.
pass
,
"p1"
);
int32_t
contLen
=
tSerializeSCreateUserReq
(
NULL
,
&
createReq
);
int32_t
contLen
=
tSerializeSCreateUserReq
(
NULL
,
0
,
&
createReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pBuf
=
pReq
;
tSerializeSCreateUserReq
(
pReq
,
contLen
,
&
createReq
);
tSerializeSCreateUserReq
(
&
pBuf
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -101,10 +100,12 @@ TEST_F(MndTestTrans, 01_Create_User_Crash) {
...
@@ -101,10 +100,12 @@ TEST_F(MndTestTrans, 01_Create_User_Crash) {
TEST_F
(
MndTestTrans
,
02
_Create_Qnode1_Crash
)
{
TEST_F
(
MndTestTrans
,
02
_Create_Qnode1_Crash
)
{
{
{
int32_t
contLen
=
sizeof
(
SMCreateQnodeReq
);
SMCreateQnodeReq
createReq
=
{
0
};
createReq
.
dnodeId
=
1
;
SMCreateQnodeReq
*
pReq
=
(
SMCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSMCreateDropQSBNodeReq
(
NULL
,
0
,
&
createReq
);
pReq
->
dnodeId
=
htonl
(
1
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSMCreateDropQSBNodeReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -118,10 +119,12 @@ TEST_F(MndTestTrans, 02_Create_Qnode1_Crash) {
...
@@ -118,10 +119,12 @@ TEST_F(MndTestTrans, 02_Create_Qnode1_Crash) {
KillThenRestartServer
();
KillThenRestartServer
();
{
{
int32_t
contLen
=
sizeof
(
SMCreateQnodeReq
);
SMCreateQnodeReq
createReq
=
{
0
};
createReq
.
dnodeId
=
1
;
SMCreateQnodeReq
*
pReq
=
(
SMCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSMCreateDropQSBNodeReq
(
NULL
,
0
,
&
createReq
);
pReq
->
dnodeId
=
htonl
(
1
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSMCreateDropQSBNodeReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -136,11 +139,13 @@ TEST_F(MndTestTrans, 02_Create_Qnode1_Crash) {
...
@@ -136,11 +139,13 @@ TEST_F(MndTestTrans, 02_Create_Qnode1_Crash) {
TEST_F
(
MndTestTrans
,
03
_Create_Qnode2_Crash
)
{
TEST_F
(
MndTestTrans
,
03
_Create_Qnode2_Crash
)
{
{
{
int32_t
contLen
=
sizeof
(
SCreateDnodeReq
);
SCreateDnodeReq
createReq
=
{
0
};
strcpy
(
createReq
.
fqdn
,
"localhost"
);
createReq
.
port
=
9020
;
SCreateDnodeReq
*
pReq
=
(
SCreateDnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSCreateDnodeReq
(
NULL
,
0
,
&
createReq
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
pReq
->
port
=
htonl
(
9020
);
tSerializeSCreateDnodeReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -153,10 +158,12 @@ TEST_F(MndTestTrans, 03_Create_Qnode2_Crash) {
...
@@ -153,10 +158,12 @@ TEST_F(MndTestTrans, 03_Create_Qnode2_Crash) {
}
}
{
{
int32_t
contLen
=
sizeof
(
SMCreateQnodeReq
);
SMCreateQnodeReq
createReq
=
{
0
};
createReq
.
dnodeId
=
2
;
SMCreateQnodeReq
*
pReq
=
(
SMCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSMCreateDropQSBNodeReq
(
NULL
,
0
,
&
createReq
);
pReq
->
dnodeId
=
htonl
(
2
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSMCreateDropQSBNodeReq
(
pReq
,
contLen
,
&
createReq
);
server2
.
Stop
();
server2
.
Stop
();
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
...
@@ -173,10 +180,12 @@ TEST_F(MndTestTrans, 03_Create_Qnode2_Crash) {
...
@@ -173,10 +180,12 @@ TEST_F(MndTestTrans, 03_Create_Qnode2_Crash) {
int32_t
retryMax
=
20
;
int32_t
retryMax
=
20
;
for
(
retry
=
0
;
retry
<
retryMax
;
retry
++
)
{
for
(
retry
=
0
;
retry
<
retryMax
;
retry
++
)
{
int32_t
contLen
=
sizeof
(
SMCreateQnodeReq
);
SMCreateQnodeReq
createReq
=
{
0
};
createReq
.
dnodeId
=
2
;
SMCreateQnodeReq
*
pReq
=
(
SMCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
int32_t
contLen
=
tSerializeSMCreateDropQSBNodeReq
(
NULL
,
0
,
&
createReq
);
pReq
->
dnodeId
=
htonl
(
2
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSMCreateDropQSBNodeReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
...
source/dnode/mnode/impl/test/user/user.cpp
浏览文件 @
2c0f1e77
...
@@ -49,10 +49,9 @@ TEST_F(MndTestUser, 02_Create_User) {
...
@@ -49,10 +49,9 @@ TEST_F(MndTestUser, 02_Create_User) {
strcpy
(
createReq
.
user
,
""
);
strcpy
(
createReq
.
user
,
""
);
strcpy
(
createReq
.
pass
,
"p1"
);
strcpy
(
createReq
.
pass
,
"p1"
);
int32_t
contLen
=
tSerializeSCreateUserReq
(
NULL
,
&
createReq
);
int32_t
contLen
=
tSerializeSCreateUserReq
(
NULL
,
0
,
&
createReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pBuf
=
pReq
;
tSerializeSCreateUserReq
(
pReq
,
contLen
,
&
createReq
);
tSerializeSCreateUserReq
(
&
pBuf
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -64,10 +63,9 @@ TEST_F(MndTestUser, 02_Create_User) {
...
@@ -64,10 +63,9 @@ TEST_F(MndTestUser, 02_Create_User) {
strcpy
(
createReq
.
user
,
"u1"
);
strcpy
(
createReq
.
user
,
"u1"
);
strcpy
(
createReq
.
pass
,
""
);
strcpy
(
createReq
.
pass
,
""
);
int32_t
contLen
=
tSerializeSCreateUserReq
(
NULL
,
&
createReq
);
int32_t
contLen
=
tSerializeSCreateUserReq
(
NULL
,
0
,
&
createReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pBuf
=
pReq
;
tSerializeSCreateUserReq
(
pReq
,
contLen
,
&
createReq
);
tSerializeSCreateUserReq
(
&
pBuf
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -79,10 +77,9 @@ TEST_F(MndTestUser, 02_Create_User) {
...
@@ -79,10 +77,9 @@ TEST_F(MndTestUser, 02_Create_User) {
strcpy
(
createReq
.
user
,
"root"
);
strcpy
(
createReq
.
user
,
"root"
);
strcpy
(
createReq
.
pass
,
"1"
);
strcpy
(
createReq
.
pass
,
"1"
);
int32_t
contLen
=
tSerializeSCreateUserReq
(
NULL
,
&
createReq
);
int32_t
contLen
=
tSerializeSCreateUserReq
(
NULL
,
0
,
&
createReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pBuf
=
pReq
;
tSerializeSCreateUserReq
(
pReq
,
contLen
,
&
createReq
);
tSerializeSCreateUserReq
(
&
pBuf
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -94,10 +91,9 @@ TEST_F(MndTestUser, 02_Create_User) {
...
@@ -94,10 +91,9 @@ TEST_F(MndTestUser, 02_Create_User) {
strcpy
(
createReq
.
user
,
"u1"
);
strcpy
(
createReq
.
user
,
"u1"
);
strcpy
(
createReq
.
pass
,
"p1"
);
strcpy
(
createReq
.
pass
,
"p1"
);
int32_t
contLen
=
tSerializeSCreateUserReq
(
NULL
,
&
createReq
);
int32_t
contLen
=
tSerializeSCreateUserReq
(
NULL
,
0
,
&
createReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pBuf
=
pReq
;
tSerializeSCreateUserReq
(
pReq
,
contLen
,
&
createReq
);
tSerializeSCreateUserReq
(
&
pBuf
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -121,10 +117,9 @@ TEST_F(MndTestUser, 02_Create_User) {
...
@@ -121,10 +117,9 @@ TEST_F(MndTestUser, 02_Create_User) {
SDropUserReq
dropReq
=
{
0
};
SDropUserReq
dropReq
=
{
0
};
strcpy
(
dropReq
.
user
,
"u1"
);
strcpy
(
dropReq
.
user
,
"u1"
);
int32_t
contLen
=
tSerializeSDropUserReq
(
NULL
,
&
dropReq
);
int32_t
contLen
=
tSerializeSDropUserReq
(
NULL
,
0
,
&
dropReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pBuf
=
pReq
;
tSerializeSDropUserReq
(
pReq
,
contLen
,
&
dropReq
);
tSerializeSDropUserReq
(
&
pBuf
,
&
dropReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_USER
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -141,10 +136,9 @@ TEST_F(MndTestUser, 02_Create_User) {
...
@@ -141,10 +136,9 @@ TEST_F(MndTestUser, 02_Create_User) {
strcpy
(
createReq
.
pass
,
"p1"
);
strcpy
(
createReq
.
pass
,
"p1"
);
createReq
.
superUser
=
1
;
createReq
.
superUser
=
1
;
int32_t
contLen
=
tSerializeSCreateUserReq
(
NULL
,
&
createReq
);
int32_t
contLen
=
tSerializeSCreateUserReq
(
NULL
,
0
,
&
createReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pBuf
=
pReq
;
tSerializeSCreateUserReq
(
pReq
,
contLen
,
&
createReq
);
tSerializeSCreateUserReq
(
&
pBuf
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -168,10 +162,9 @@ TEST_F(MndTestUser, 02_Create_User) {
...
@@ -168,10 +162,9 @@ TEST_F(MndTestUser, 02_Create_User) {
SDropUserReq
dropReq
=
{
0
};
SDropUserReq
dropReq
=
{
0
};
strcpy
(
dropReq
.
user
,
"u2"
);
strcpy
(
dropReq
.
user
,
"u2"
);
int32_t
contLen
=
tSerializeSDropUserReq
(
NULL
,
&
dropReq
);
int32_t
contLen
=
tSerializeSDropUserReq
(
NULL
,
0
,
&
dropReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pBuf
=
pReq
;
tSerializeSDropUserReq
(
pReq
,
contLen
,
&
dropReq
);
tSerializeSDropUserReq
(
&
pBuf
,
&
dropReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_USER
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -190,10 +183,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
...
@@ -190,10 +183,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
strcpy
(
createReq
.
pass
,
"p1"
);
strcpy
(
createReq
.
pass
,
"p1"
);
createReq
.
superUser
=
1
;
createReq
.
superUser
=
1
;
int32_t
contLen
=
tSerializeSCreateUserReq
(
NULL
,
&
createReq
);
int32_t
contLen
=
tSerializeSCreateUserReq
(
NULL
,
0
,
&
createReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pBuf
=
pReq
;
tSerializeSCreateUserReq
(
pReq
,
contLen
,
&
createReq
);
tSerializeSCreateUserReq
(
&
pBuf
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -210,10 +202,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
...
@@ -210,10 +202,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
strcpy
(
alterReq
.
user
,
""
);
strcpy
(
alterReq
.
user
,
""
);
strcpy
(
alterReq
.
pass
,
"p1"
);
strcpy
(
alterReq
.
pass
,
"p1"
);
int32_t
contLen
=
tSerializeSAlterUserReq
(
NULL
,
&
alterReq
);
int32_t
contLen
=
tSerializeSAlterUserReq
(
NULL
,
0
,
&
alterReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pBuf
=
pReq
;
tSerializeSAlterUserReq
(
pReq
,
contLen
,
&
alterReq
);
tSerializeSAlterUserReq
(
&
pBuf
,
&
alterReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -226,10 +217,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
...
@@ -226,10 +217,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
strcpy
(
alterReq
.
user
,
"u3"
);
strcpy
(
alterReq
.
user
,
"u3"
);
strcpy
(
alterReq
.
pass
,
""
);
strcpy
(
alterReq
.
pass
,
""
);
int32_t
contLen
=
tSerializeSAlterUserReq
(
NULL
,
&
alterReq
);
int32_t
contLen
=
tSerializeSAlterUserReq
(
NULL
,
0
,
&
alterReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pBuf
=
pReq
;
tSerializeSAlterUserReq
(
pReq
,
contLen
,
&
alterReq
);
tSerializeSAlterUserReq
(
&
pBuf
,
&
alterReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -242,10 +232,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
...
@@ -242,10 +232,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
strcpy
(
alterReq
.
user
,
"u4"
);
strcpy
(
alterReq
.
user
,
"u4"
);
strcpy
(
alterReq
.
pass
,
"1"
);
strcpy
(
alterReq
.
pass
,
"1"
);
int32_t
contLen
=
tSerializeSAlterUserReq
(
NULL
,
&
alterReq
);
int32_t
contLen
=
tSerializeSAlterUserReq
(
NULL
,
0
,
&
alterReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pBuf
=
pReq
;
tSerializeSAlterUserReq
(
pReq
,
contLen
,
&
alterReq
);
tSerializeSAlterUserReq
(
&
pBuf
,
&
alterReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -258,10 +247,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
...
@@ -258,10 +247,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
strcpy
(
alterReq
.
user
,
"u3"
);
strcpy
(
alterReq
.
user
,
"u3"
);
strcpy
(
alterReq
.
pass
,
"1"
);
strcpy
(
alterReq
.
pass
,
"1"
);
int32_t
contLen
=
tSerializeSAlterUserReq
(
NULL
,
&
alterReq
);
int32_t
contLen
=
tSerializeSAlterUserReq
(
NULL
,
0
,
&
alterReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pBuf
=
pReq
;
tSerializeSAlterUserReq
(
pReq
,
contLen
,
&
alterReq
);
tSerializeSAlterUserReq
(
&
pBuf
,
&
alterReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -275,10 +263,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
...
@@ -275,10 +263,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
strcpy
(
alterReq
.
pass
,
"1"
);
strcpy
(
alterReq
.
pass
,
"1"
);
alterReq
.
superUser
=
1
;
alterReq
.
superUser
=
1
;
int32_t
contLen
=
tSerializeSAlterUserReq
(
NULL
,
&
alterReq
);
int32_t
contLen
=
tSerializeSAlterUserReq
(
NULL
,
0
,
&
alterReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pBuf
=
pReq
;
tSerializeSAlterUserReq
(
pReq
,
contLen
,
&
alterReq
);
tSerializeSAlterUserReq
(
&
pBuf
,
&
alterReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -291,10 +278,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
...
@@ -291,10 +278,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
strcpy
(
alterReq
.
user
,
"u3"
);
strcpy
(
alterReq
.
user
,
"u3"
);
strcpy
(
alterReq
.
pass
,
"1"
);
strcpy
(
alterReq
.
pass
,
"1"
);
int32_t
contLen
=
tSerializeSAlterUserReq
(
NULL
,
&
alterReq
);
int32_t
contLen
=
tSerializeSAlterUserReq
(
NULL
,
0
,
&
alterReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pBuf
=
pReq
;
tSerializeSAlterUserReq
(
pReq
,
contLen
,
&
alterReq
);
tSerializeSAlterUserReq
(
&
pBuf
,
&
alterReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -307,10 +293,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
...
@@ -307,10 +293,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
strcpy
(
alterReq
.
user
,
"u3"
);
strcpy
(
alterReq
.
user
,
"u3"
);
strcpy
(
alterReq
.
pass
,
"1"
);
strcpy
(
alterReq
.
pass
,
"1"
);
int32_t
contLen
=
tSerializeSAlterUserReq
(
NULL
,
&
alterReq
);
int32_t
contLen
=
tSerializeSAlterUserReq
(
NULL
,
0
,
&
alterReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pBuf
=
pReq
;
tSerializeSAlterUserReq
(
pReq
,
contLen
,
&
alterReq
);
tSerializeSAlterUserReq
(
&
pBuf
,
&
alterReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -324,10 +309,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
...
@@ -324,10 +309,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
strcpy
(
alterReq
.
pass
,
"1"
);
strcpy
(
alterReq
.
pass
,
"1"
);
strcpy
(
alterReq
.
dbname
,
"d1"
);
strcpy
(
alterReq
.
dbname
,
"d1"
);
int32_t
contLen
=
tSerializeSAlterUserReq
(
NULL
,
&
alterReq
);
int32_t
contLen
=
tSerializeSAlterUserReq
(
NULL
,
0
,
&
alterReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pBuf
=
pReq
;
tSerializeSAlterUserReq
(
pReq
,
contLen
,
&
alterReq
);
tSerializeSAlterUserReq
(
&
pBuf
,
&
alterReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -371,10 +355,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
...
@@ -371,10 +355,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
strcpy
(
alterReq
.
pass
,
"1"
);
strcpy
(
alterReq
.
pass
,
"1"
);
strcpy
(
alterReq
.
dbname
,
"1.d2"
);
strcpy
(
alterReq
.
dbname
,
"1.d2"
);
int32_t
contLen
=
tSerializeSAlterUserReq
(
NULL
,
&
alterReq
);
int32_t
contLen
=
tSerializeSAlterUserReq
(
NULL
,
0
,
&
alterReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pBuf
=
pReq
;
tSerializeSAlterUserReq
(
pReq
,
contLen
,
&
alterReq
);
tSerializeSAlterUserReq
(
&
pBuf
,
&
alterReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -388,10 +371,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
...
@@ -388,10 +371,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
strcpy
(
alterReq
.
pass
,
"1"
);
strcpy
(
alterReq
.
pass
,
"1"
);
strcpy
(
alterReq
.
dbname
,
"1.d2"
);
strcpy
(
alterReq
.
dbname
,
"1.d2"
);
int32_t
contLen
=
tSerializeSAlterUserReq
(
NULL
,
&
alterReq
);
int32_t
contLen
=
tSerializeSAlterUserReq
(
NULL
,
0
,
&
alterReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pBuf
=
pReq
;
tSerializeSAlterUserReq
(
pReq
,
contLen
,
&
alterReq
);
tSerializeSAlterUserReq
(
&
pBuf
,
&
alterReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -401,17 +383,16 @@ TEST_F(MndTestUser, 03_Alter_User) {
...
@@ -401,17 +383,16 @@ TEST_F(MndTestUser, 03_Alter_User) {
{
{
SGetUserAuthReq
authReq
=
{
0
};
SGetUserAuthReq
authReq
=
{
0
};
strcpy
(
authReq
.
user
,
"u3"
);
strcpy
(
authReq
.
user
,
"u3"
);
int32_t
contLen
=
tSerializeSGetUserAuthReq
(
NULL
,
&
authReq
);
int32_t
contLen
=
tSerializeSGetUserAuthReq
(
NULL
,
0
,
&
authReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pBuf
=
pReq
;
tSerializeSGetUserAuthReq
(
pReq
,
contLen
,
&
authReq
);
tSerializeSGetUserAuthReq
(
&
pBuf
,
&
authReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_GET_USER_AUTH
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_GET_USER_AUTH
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
SGetUserAuthRsp
authRsp
=
{
0
};
SGetUserAuthRsp
authRsp
=
{
0
};
tDeserializeSGetUserAuthRsp
(
pRsp
->
pCont
,
&
authRsp
);
tDeserializeSGetUserAuthRsp
(
pRsp
->
pCont
,
pRsp
->
contLen
,
&
authRsp
);
EXPECT_STREQ
(
authRsp
.
user
,
"u3"
);
EXPECT_STREQ
(
authRsp
.
user
,
"u3"
);
EXPECT_EQ
(
authRsp
.
superAuth
,
1
);
EXPECT_EQ
(
authRsp
.
superAuth
,
1
);
int32_t
numOfReadDbs
=
taosHashGetSize
(
authRsp
.
readDbs
);
int32_t
numOfReadDbs
=
taosHashGetSize
(
authRsp
.
readDbs
);
...
@@ -433,10 +414,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
...
@@ -433,10 +414,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
strcpy
(
alterReq
.
pass
,
"1"
);
strcpy
(
alterReq
.
pass
,
"1"
);
strcpy
(
alterReq
.
dbname
,
"1.d2"
);
strcpy
(
alterReq
.
dbname
,
"1.d2"
);
int32_t
contLen
=
tSerializeSAlterUserReq
(
NULL
,
&
alterReq
);
int32_t
contLen
=
tSerializeSAlterUserReq
(
NULL
,
0
,
&
alterReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pBuf
=
pReq
;
tSerializeSAlterUserReq
(
pReq
,
contLen
,
&
alterReq
);
tSerializeSAlterUserReq
(
&
pBuf
,
&
alterReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -447,10 +427,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
...
@@ -447,10 +427,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
SDropUserReq
dropReq
=
{
0
};
SDropUserReq
dropReq
=
{
0
};
strcpy
(
dropReq
.
user
,
"u3"
);
strcpy
(
dropReq
.
user
,
"u3"
);
int32_t
contLen
=
tSerializeSDropUserReq
(
NULL
,
&
dropReq
);
int32_t
contLen
=
tSerializeSDropUserReq
(
NULL
,
0
,
&
dropReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pBuf
=
pReq
;
tSerializeSDropUserReq
(
pReq
,
contLen
,
&
dropReq
);
tSerializeSDropUserReq
(
&
pBuf
,
&
dropReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_USER
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -467,10 +446,9 @@ TEST_F(MndTestUser, 05_Drop_User) {
...
@@ -467,10 +446,9 @@ TEST_F(MndTestUser, 05_Drop_User) {
SDropUserReq
dropReq
=
{
0
};
SDropUserReq
dropReq
=
{
0
};
strcpy
(
dropReq
.
user
,
""
);
strcpy
(
dropReq
.
user
,
""
);
int32_t
contLen
=
tSerializeSDropUserReq
(
NULL
,
&
dropReq
);
int32_t
contLen
=
tSerializeSDropUserReq
(
NULL
,
0
,
&
dropReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pBuf
=
pReq
;
tSerializeSDropUserReq
(
pReq
,
contLen
,
&
dropReq
);
tSerializeSDropUserReq
(
&
pBuf
,
&
dropReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_USER
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -481,10 +459,9 @@ TEST_F(MndTestUser, 05_Drop_User) {
...
@@ -481,10 +459,9 @@ TEST_F(MndTestUser, 05_Drop_User) {
SDropUserReq
dropReq
=
{
0
};
SDropUserReq
dropReq
=
{
0
};
strcpy
(
dropReq
.
user
,
"u4"
);
strcpy
(
dropReq
.
user
,
"u4"
);
int32_t
contLen
=
tSerializeSDropUserReq
(
NULL
,
&
dropReq
);
int32_t
contLen
=
tSerializeSDropUserReq
(
NULL
,
0
,
&
dropReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pBuf
=
pReq
;
tSerializeSDropUserReq
(
pReq
,
contLen
,
&
dropReq
);
tSerializeSDropUserReq
(
&
pBuf
,
&
dropReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_USER
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -496,10 +473,9 @@ TEST_F(MndTestUser, 05_Drop_User) {
...
@@ -496,10 +473,9 @@ TEST_F(MndTestUser, 05_Drop_User) {
strcpy
(
createReq
.
user
,
"u1"
);
strcpy
(
createReq
.
user
,
"u1"
);
strcpy
(
createReq
.
pass
,
"p1"
);
strcpy
(
createReq
.
pass
,
"p1"
);
int32_t
contLen
=
tSerializeSCreateUserReq
(
NULL
,
&
createReq
);
int32_t
contLen
=
tSerializeSCreateUserReq
(
NULL
,
0
,
&
createReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pBuf
=
pReq
;
tSerializeSCreateUserReq
(
pReq
,
contLen
,
&
createReq
);
tSerializeSCreateUserReq
(
&
pBuf
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -510,10 +486,9 @@ TEST_F(MndTestUser, 05_Drop_User) {
...
@@ -510,10 +486,9 @@ TEST_F(MndTestUser, 05_Drop_User) {
SDropUserReq
dropReq
=
{
0
};
SDropUserReq
dropReq
=
{
0
};
strcpy
(
dropReq
.
user
,
"u1"
);
strcpy
(
dropReq
.
user
,
"u1"
);
int32_t
contLen
=
tSerializeSDropUserReq
(
NULL
,
&
dropReq
);
int32_t
contLen
=
tSerializeSDropUserReq
(
NULL
,
0
,
&
dropReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pBuf
=
pReq
;
tSerializeSDropUserReq
(
pReq
,
contLen
,
&
dropReq
);
tSerializeSDropUserReq
(
&
pBuf
,
&
dropReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_USER
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -533,10 +508,9 @@ TEST_F(MndTestUser, 06_Create_Drop_Alter_User) {
...
@@ -533,10 +508,9 @@ TEST_F(MndTestUser, 06_Create_Drop_Alter_User) {
strcpy
(
createReq
.
user
,
"u1"
);
strcpy
(
createReq
.
user
,
"u1"
);
strcpy
(
createReq
.
pass
,
"p1"
);
strcpy
(
createReq
.
pass
,
"p1"
);
int32_t
contLen
=
tSerializeSCreateUserReq
(
NULL
,
&
createReq
);
int32_t
contLen
=
tSerializeSCreateUserReq
(
NULL
,
0
,
&
createReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pBuf
=
pReq
;
tSerializeSCreateUserReq
(
pReq
,
contLen
,
&
createReq
);
tSerializeSCreateUserReq
(
&
pBuf
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -548,10 +522,9 @@ TEST_F(MndTestUser, 06_Create_Drop_Alter_User) {
...
@@ -548,10 +522,9 @@ TEST_F(MndTestUser, 06_Create_Drop_Alter_User) {
strcpy
(
createReq
.
user
,
"u2"
);
strcpy
(
createReq
.
user
,
"u2"
);
strcpy
(
createReq
.
pass
,
"p2"
);
strcpy
(
createReq
.
pass
,
"p2"
);
int32_t
contLen
=
tSerializeSCreateUserReq
(
NULL
,
&
createReq
);
int32_t
contLen
=
tSerializeSCreateUserReq
(
NULL
,
0
,
&
createReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pBuf
=
pReq
;
tSerializeSCreateUserReq
(
pReq
,
contLen
,
&
createReq
);
tSerializeSCreateUserReq
(
&
pBuf
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -583,10 +556,9 @@ TEST_F(MndTestUser, 06_Create_Drop_Alter_User) {
...
@@ -583,10 +556,9 @@ TEST_F(MndTestUser, 06_Create_Drop_Alter_User) {
strcpy
(
alterReq
.
user
,
"u1"
);
strcpy
(
alterReq
.
user
,
"u1"
);
strcpy
(
alterReq
.
pass
,
"p2"
);
strcpy
(
alterReq
.
pass
,
"p2"
);
int32_t
contLen
=
tSerializeSAlterUserReq
(
NULL
,
&
alterReq
);
int32_t
contLen
=
tSerializeSAlterUserReq
(
NULL
,
0
,
&
alterReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pBuf
=
pReq
;
tSerializeSAlterUserReq
(
pReq
,
contLen
,
&
alterReq
);
tSerializeSAlterUserReq
(
&
pBuf
,
&
alterReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -616,10 +588,9 @@ TEST_F(MndTestUser, 06_Create_Drop_Alter_User) {
...
@@ -616,10 +588,9 @@ TEST_F(MndTestUser, 06_Create_Drop_Alter_User) {
SDropUserReq
dropReq
=
{
0
};
SDropUserReq
dropReq
=
{
0
};
strcpy
(
dropReq
.
user
,
"u1"
);
strcpy
(
dropReq
.
user
,
"u1"
);
int32_t
contLen
=
tSerializeSDropUserReq
(
NULL
,
&
dropReq
);
int32_t
contLen
=
tSerializeSDropUserReq
(
NULL
,
0
,
&
dropReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pBuf
=
pReq
;
tSerializeSDropUserReq
(
pReq
,
contLen
,
&
dropReq
);
tSerializeSDropUserReq
(
&
pBuf
,
&
dropReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_USER
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
...
source/libs/parser/inc/astToMsg.h
浏览文件 @
2c0f1e77
...
@@ -12,7 +12,7 @@ SShowReq* buildShowMsg(SShowInfo* pShowInfo, SParseContext* pParseCtx, SMsgBuf*
...
@@ -12,7 +12,7 @@ SShowReq* buildShowMsg(SShowInfo* pShowInfo, SParseContext* pParseCtx, SMsgBuf*
SCreateDbReq
*
buildCreateDbMsg
(
SCreateDbInfo
*
pCreateDbInfo
,
SParseContext
*
pCtx
,
SMsgBuf
*
pMsgBuf
);
SCreateDbReq
*
buildCreateDbMsg
(
SCreateDbInfo
*
pCreateDbInfo
,
SParseContext
*
pCtx
,
SMsgBuf
*
pMsgBuf
);
char
*
buildCreateStbReq
(
SCreateTableSql
*
pCreateTableSql
,
int32_t
*
len
,
SParseContext
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
);
char
*
buildCreateStbReq
(
SCreateTableSql
*
pCreateTableSql
,
int32_t
*
len
,
SParseContext
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
);
char
*
buildDropStableReq
(
SSqlInfo
*
pInfo
,
int32_t
*
len
,
SParseContext
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
);
char
*
buildDropStableReq
(
SSqlInfo
*
pInfo
,
int32_t
*
len
,
SParseContext
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
);
SCreateDnodeReq
*
buildCreateDnodeMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
len
,
SMsgBuf
*
pMsgBuf
);
char
*
buildCreateDnodeMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
len
,
SMsgBuf
*
pMsgBuf
);
SDropDnodeReq
*
buildDropDnodeMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
len
,
SMsgBuf
*
pMsgBuf
);
char
*
buildDropDnodeMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
len
,
SMsgBuf
*
pMsgBuf
);
#endif // TDENGINE_ASTTOMSG_H
#endif // TDENGINE_ASTTOMSG_H
source/libs/parser/src/astToMsg.c
浏览文件 @
2c0f1e77
#include "parserInt.h"
#include "astGenerator.h"
#include "astGenerator.h"
#include "parserInt.h"
#include "parserUtil.h"
#include "parserUtil.h"
char
*
buildUserManipulationMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
outputLen
,
int64_t
id
,
char
*
msgBuf
,
int32_t
msgLen
)
{
char
*
buildUserManipulationMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
outputLen
,
int64_t
id
,
char
*
msgBuf
,
int32_t
msgLen
)
{
...
@@ -16,15 +16,14 @@ char* buildUserManipulationMsg(SSqlInfo* pInfo, int32_t* outputLen, int64_t id,
...
@@ -16,15 +16,14 @@ char* buildUserManipulationMsg(SSqlInfo* pInfo, int32_t* outputLen, int64_t id,
strncpy
(
createReq
.
pass
,
pUser
->
passwd
.
z
,
pUser
->
passwd
.
n
);
strncpy
(
createReq
.
pass
,
pUser
->
passwd
.
z
,
pUser
->
passwd
.
n
);
}
}
int32_t
tlen
=
tSerializeSCreateUserReq
(
NULL
,
&
createReq
);
int32_t
tlen
=
tSerializeSCreateUserReq
(
NULL
,
0
,
&
createReq
);
void
*
pReq
=
malloc
(
tlen
);
void
*
pReq
=
malloc
(
tlen
);
if
(
pReq
==
NULL
)
{
if
(
pReq
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
return
NULL
;
}
}
void
*
pBuf
=
pReq
;
tSerializeSCreateUserReq
(
pReq
,
tlen
,
&
createReq
);
tSerializeSCreateUserReq
(
&
pBuf
,
&
createReq
);
*
outputLen
=
tlen
;
*
outputLen
=
tlen
;
return
pReq
;
return
pReq
;
}
}
...
@@ -63,15 +62,14 @@ char* buildAcctManipulationMsg(SSqlInfo* pInfo, int32_t* outputLen, int64_t id,
...
@@ -63,15 +62,14 @@ char* buildAcctManipulationMsg(SSqlInfo* pInfo, int32_t* outputLen, int64_t id,
}
}
}
}
int32_t
tlen
=
tSerializeSCreateAcctReq
(
NULL
,
&
createReq
);
int32_t
tlen
=
tSerializeSCreateAcctReq
(
NULL
,
0
,
&
createReq
);
void
*
pReq
=
malloc
(
tlen
);
void
*
pReq
=
malloc
(
tlen
);
if
(
pReq
==
NULL
)
{
if
(
pReq
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
return
NULL
;
}
}
void
*
pBuf
=
pReq
;
tSerializeSCreateAcctReq
(
pReq
,
tlen
,
&
createReq
);
tSerializeSCreateAcctReq
(
&
pBuf
,
&
createReq
);
*
outputLen
=
tlen
;
*
outputLen
=
tlen
;
return
pReq
;
return
pReq
;
}
}
...
@@ -86,20 +84,19 @@ char* buildDropUserMsg(SSqlInfo* pInfo, int32_t* msgLen, int64_t id, char* msgBu
...
@@ -86,20 +84,19 @@ char* buildDropUserMsg(SSqlInfo* pInfo, int32_t* msgLen, int64_t id, char* msgBu
strncpy
(
dropReq
.
user
,
pName
->
z
,
pName
->
n
);
strncpy
(
dropReq
.
user
,
pName
->
z
,
pName
->
n
);
int32_t
tlen
=
tSerializeSDropUserReq
(
NULL
,
&
dropReq
);
int32_t
tlen
=
tSerializeSDropUserReq
(
NULL
,
0
,
&
dropReq
);
void
*
pReq
=
malloc
(
tlen
);
void
*
pReq
=
malloc
(
tlen
);
if
(
pReq
==
NULL
)
{
if
(
pReq
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
return
NULL
;
}
}
void
*
pBuf
=
pReq
;
tSerializeSDropUserReq
(
pReq
,
tlen
,
&
dropReq
);
tSerializeSDropUserReq
(
&
pBuf
,
&
dropReq
);
*
msgLen
=
tlen
;
*
msgLen
=
tlen
;
return
pReq
;
return
pReq
;
}
}
SShowReq
*
buildShowMsg
(
SShowInfo
*
pShowInfo
,
SParseContext
*
pCtx
,
SMsgBuf
*
pMsgBuf
)
{
SShowReq
*
buildShowMsg
(
SShowInfo
*
pShowInfo
,
SParseContext
*
pCtx
,
SMsgBuf
*
pMsgBuf
)
{
SShowReq
*
pShowMsg
=
calloc
(
1
,
sizeof
(
SShowReq
));
SShowReq
*
pShowMsg
=
calloc
(
1
,
sizeof
(
SShowReq
));
if
(
pShowMsg
==
NULL
)
{
if
(
pShowMsg
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
...
@@ -158,27 +155,27 @@ static int32_t setKeepOption(SCreateDbReq* pMsg, const SCreateDbInfo* pCreateDb,
...
@@ -158,27 +155,27 @@ static int32_t setKeepOption(SCreateDbReq* pMsg, const SCreateDbInfo* pCreateDb,
if
(
pKeep
!=
NULL
)
{
if
(
pKeep
!=
NULL
)
{
size_t
s
=
taosArrayGetSize
(
pKeep
);
size_t
s
=
taosArrayGetSize
(
pKeep
);
#ifdef _STORAGE
#ifdef _STORAGE
if
(
s
>=
4
||
s
<=
0
)
{
if
(
s
>=
4
||
s
<=
0
)
{
#else
#else
if
(
s
!=
1
)
{
if
(
s
!=
1
)
{
#endif
#endif
return
buildInvalidOperationMsg
(
pMsgBuf
,
msg1
);
return
buildInvalidOperationMsg
(
pMsgBuf
,
msg1
);
}
}
// tListI* p0 = taosArrayGet(pKeep, 0);
// tListI* p0 = taosArrayGet(pKeep, 0);
// tVariantListItem* p1 = (s > 1) ? taosArrayGet(pKeep, 1) : p0;
// tVariantListItem* p1 = (s > 1) ? taosArrayGet(pKeep, 1) : p0;
// tVariantListItem* p2 = (s > 2) ? taosArrayGet(pKeep, 2) : p1;
// tVariantListItem* p2 = (s > 2) ? taosArrayGet(pKeep, 2) : p1;
//
//
// if ((int32_t)p0->pVar.i64 <= 0 || (int32_t)p1->pVar.i64 <= 0 || (int32_t)p2->pVar.i64 <= 0) {
// if ((int32_t)p0->pVar.i64 <= 0 || (int32_t)p1->pVar.i64 <= 0 || (int32_t)p2->pVar.i64 <= 0) {
// return buildInvalidOperationMsg(pMsgBuf, msg2);
// return buildInvalidOperationMsg(pMsgBuf, msg2);
// }
// }
// if (!(((int32_t)p0->pVar.i64 <= (int32_t)p1->pVar.i64) && ((int32_t)p1->pVar.i64 <= (int32_t)p2->pVar.i64))) {
// if (!(((int32_t)p0->pVar.i64 <= (int32_t)p1->pVar.i64) && ((int32_t)p1->pVar.i64 <= (int32_t)p2->pVar.i64))) {
// return buildInvalidOperationMsg(pMsgBuf, msg3);
// return buildInvalidOperationMsg(pMsgBuf, msg3);
// }
// }
//
//
// pMsg->daysToKeep0 = htonl((int32_t)p0->pVar.i64);
// pMsg->daysToKeep0 = htonl((int32_t)p0->pVar.i64);
// pMsg->daysToKeep1 = htonl((int32_t)p1->pVar.i64);
// pMsg->daysToKeep1 = htonl((int32_t)p1->pVar.i64);
// pMsg->daysToKeep2 = htonl((int32_t)p2->pVar.i64);
// pMsg->daysToKeep2 = htonl((int32_t)p2->pVar.i64);
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -189,7 +186,7 @@ static int32_t setTimePrecision(SCreateDbReq* pMsg, const SCreateDbInfo* pCreate
...
@@ -189,7 +186,7 @@ static int32_t setTimePrecision(SCreateDbReq* pMsg, const SCreateDbInfo* pCreate
pMsg
->
precision
=
TSDB_TIME_PRECISION_MILLI
;
// millisecond by default
pMsg
->
precision
=
TSDB_TIME_PRECISION_MILLI
;
// millisecond by default
SToken
*
pToken
=
(
SToken
*
)
&
pCreateDbInfo
->
precision
;
SToken
*
pToken
=
(
SToken
*
)
&
pCreateDbInfo
->
precision
;
if
(
pToken
->
n
>
0
)
{
if
(
pToken
->
n
>
0
)
{
pToken
->
n
=
strdequote
(
pToken
->
z
);
pToken
->
n
=
strdequote
(
pToken
->
z
);
...
@@ -219,7 +216,7 @@ static void doSetDbOptions(SCreateDbReq* pMsg, const SCreateDbInfo* pCreateDb) {
...
@@ -219,7 +216,7 @@ static void doSetDbOptions(SCreateDbReq* pMsg, const SCreateDbInfo* pCreateDb) {
pMsg
->
minRows
=
htonl
(
pCreateDb
->
minRowsPerBlock
);
pMsg
->
minRows
=
htonl
(
pCreateDb
->
minRowsPerBlock
);
pMsg
->
maxRows
=
htonl
(
pCreateDb
->
maxRowsPerBlock
);
pMsg
->
maxRows
=
htonl
(
pCreateDb
->
maxRowsPerBlock
);
pMsg
->
fsyncPeriod
=
htonl
(
pCreateDb
->
fsyncPeriod
);
pMsg
->
fsyncPeriod
=
htonl
(
pCreateDb
->
fsyncPeriod
);
pMsg
->
compression
=
(
int8_t
)
pCreateDb
->
compressionLevel
;
pMsg
->
compression
=
(
int8_t
)
pCreateDb
->
compressionLevel
;
pMsg
->
walLevel
=
(
char
)
pCreateDb
->
walLevel
;
pMsg
->
walLevel
=
(
char
)
pCreateDb
->
walLevel
;
pMsg
->
replications
=
pCreateDb
->
replica
;
pMsg
->
replications
=
pCreateDb
->
replica
;
pMsg
->
quorum
=
pCreateDb
->
quorum
;
pMsg
->
quorum
=
pCreateDb
->
quorum
;
...
@@ -243,7 +240,7 @@ int32_t setDbOptions(SCreateDbReq* pCreateDbMsg, const SCreateDbInfo* pCreateDbS
...
@@ -243,7 +240,7 @@ int32_t setDbOptions(SCreateDbReq* pCreateDbMsg, const SCreateDbInfo* pCreateDbS
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
SCreateDbReq
*
buildCreateDbMsg
(
SCreateDbInfo
*
pCreateDbInfo
,
SParseContext
*
pCtx
,
SMsgBuf
*
pMsgBuf
)
{
SCreateDbReq
*
buildCreateDbMsg
(
SCreateDbInfo
*
pCreateDbInfo
,
SParseContext
*
pCtx
,
SMsgBuf
*
pMsgBuf
)
{
SCreateDbReq
*
pCreateMsg
=
calloc
(
1
,
sizeof
(
SCreateDbReq
));
SCreateDbReq
*
pCreateMsg
=
calloc
(
1
,
sizeof
(
SCreateDbReq
));
if
(
setDbOptions
(
pCreateMsg
,
pCreateDbInfo
,
pMsgBuf
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
setDbOptions
(
pCreateMsg
,
pCreateDbInfo
,
pMsgBuf
)
!=
TSDB_CODE_SUCCESS
)
{
tfree
(
pCreateMsg
);
tfree
(
pCreateMsg
);
...
@@ -323,7 +320,7 @@ char* buildDropStableReq(SSqlInfo* pInfo, int32_t* len, SParseContext* pParseCtx
...
@@ -323,7 +320,7 @@ char* buildDropStableReq(SSqlInfo* pInfo, int32_t* len, SParseContext* pParseCtx
return
pReq
;
return
pReq
;
}
}
SCreateDnodeReq
*
buildCreateDnodeMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
len
,
SMsgBuf
*
pMsgBuf
)
{
char
*
buildCreateDnodeMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
len
,
SMsgBuf
*
pMsgBuf
)
{
const
char
*
msg1
=
"invalid host name (name too long, maximum length 128)"
;
const
char
*
msg1
=
"invalid host name (name too long, maximum length 128)"
;
const
char
*
msg2
=
"dnode name can not be string"
;
const
char
*
msg2
=
"dnode name can not be string"
;
const
char
*
msg3
=
"port should be an integer that is less than 65535 and greater than 0"
;
const
char
*
msg3
=
"port should be an integer that is less than 65535 and greater than 0"
;
...
@@ -355,33 +352,44 @@ SCreateDnodeReq *buildCreateDnodeMsg(SSqlInfo* pInfo, int32_t* len, SMsgBuf* pMs
...
@@ -355,33 +352,44 @@ SCreateDnodeReq *buildCreateDnodeMsg(SSqlInfo* pInfo, int32_t* len, SMsgBuf* pMs
return
NULL
;
return
NULL
;
}
}
SCreateDnodeReq
*
pCreate
=
(
SCreateDnodeReq
*
)
calloc
(
1
,
sizeof
(
SCreateDnodeReq
));
SCreateDnodeReq
createReq
=
{
0
};
if
(
pCreate
==
NULL
)
{
buildInvalidOperationMsg
(
pMsgBuf
,
msg4
);
strncpy
(
createReq
.
fqdn
,
id
->
z
,
id
->
n
);
createReq
.
port
=
val
;
int32_t
tlen
=
tSerializeSCreateDnodeReq
(
NULL
,
0
,
&
createReq
);
void
*
pReq
=
malloc
(
tlen
);
if
(
pReq
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
return
NULL
;
}
}
strncpy
(
pCreate
->
fqdn
,
id
->
z
,
id
->
n
);
tSerializeSCreateDnodeReq
(
pReq
,
tlen
,
&
createReq
);
pCreate
->
port
=
htonl
(
val
);
*
len
=
tlen
;
return
pReq
;
*
len
=
sizeof
(
SCreateDnodeReq
);
return
pCreate
;
}
}
SDropDnodeReq
*
buildDropDnodeMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
len
,
SMsgBuf
*
pMsgBuf
)
{
char
*
buildDropDnodeMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
len
,
SMsgBuf
*
pMsgBuf
)
{
SDropDnodeReq
dropReq
=
{
0
};
SToken
*
pzName
=
taosArrayGet
(
pInfo
->
pMiscInfo
->
a
,
0
);
SToken
*
pzName
=
taosArrayGet
(
pInfo
->
pMiscInfo
->
a
,
0
);
char
*
end
=
NULL
;
char
*
end
=
NULL
;
SDropDnodeReq
*
pDrop
=
(
SDropDnodeReq
*
)
calloc
(
1
,
sizeof
(
SDropDnodeReq
));
dropReq
.
dnodeId
=
strtoll
(
pzName
->
z
,
&
end
,
10
);
pDrop
->
dnodeId
=
strtoll
(
pzName
->
z
,
&
end
,
10
);
pDrop
->
dnodeId
=
htonl
(
pDrop
->
dnodeId
);
*
len
=
sizeof
(
SDropDnodeReq
);
if
(
end
-
pzName
->
z
!=
pzName
->
n
)
{
if
(
end
-
pzName
->
z
!=
pzName
->
n
)
{
buildInvalidOperationMsg
(
pMsgBuf
,
"invalid dnode id"
);
buildInvalidOperationMsg
(
pMsgBuf
,
"invalid dnode id"
);
tfree
(
pDrop
);
return
NULL
;
return
NULL
;
}
}
return
pDrop
;
int32_t
tlen
=
tSerializeSDropDnodeReq
(
NULL
,
0
,
&
dropReq
);
void
*
pReq
=
malloc
(
tlen
);
if
(
pReq
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
}
tSerializeSDropDnodeReq
(
pReq
,
tlen
,
&
dropReq
);
*
len
=
tlen
;
return
pReq
;
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录