Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c5decfec
TDengine
项目概览
taosdata
/
TDengine
接近 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
c5decfec
编写于
1月 04, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test for dqnode
上级
268c3343
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
103 addition
and
39 deletion
+103
-39
source/dnode/mgmt/impl/src/dndBnode.c
source/dnode/mgmt/impl/src/dndBnode.c
+14
-4
source/dnode/mgmt/impl/src/dndQnode.c
source/dnode/mgmt/impl/src/dndQnode.c
+16
-4
source/dnode/mgmt/impl/src/dndSnode.c
source/dnode/mgmt/impl/src/dndSnode.c
+16
-5
source/dnode/mgmt/impl/src/dnode.c
source/dnode/mgmt/impl/src/dnode.c
+24
-0
source/dnode/mgmt/impl/test/qnode/dqnode.cpp
source/dnode/mgmt/impl/test/qnode/dqnode.cpp
+33
-26
未找到文件。
source/dnode/mgmt/impl/src/dndBnode.c
浏览文件 @
c5decfec
...
...
@@ -27,7 +27,7 @@ static SBnode *dndAcquireBnode(SDnode *pDnode) {
int32_t
refCount
=
0
;
taosRLockLatch
(
&
pMgmt
->
latch
);
if
(
pMgmt
->
deployed
&&
!
pMgmt
->
dropped
)
{
if
(
pMgmt
->
deployed
&&
!
pMgmt
->
dropped
&&
pMgmt
->
pBnode
!=
NULL
)
{
refCount
=
atomic_add_fetch_32
(
&
pMgmt
->
refCount
,
1
);
pBnode
=
pMgmt
->
pBnode
;
}
else
{
...
...
@@ -170,7 +170,7 @@ static void dndStopBnodeWorker(SDnode *pDnode) {
pMgmt
->
deployed
=
0
;
taosWUnLockLatch
(
&
pMgmt
->
latch
);
while
(
pMgmt
->
refCount
>
1
)
{
while
(
pMgmt
->
refCount
>
0
)
{
taosMsleep
(
10
);
}
...
...
@@ -189,10 +189,18 @@ static void dndBuildBnodeOption(SDnode *pDnode, SBnodeOpt *pOption) {
static
int32_t
dndOpenBnode
(
SDnode
*
pDnode
)
{
SBnodeMgmt
*
pMgmt
=
&
pDnode
->
bmgmt
;
SBnodeOpt
option
=
{
0
};
SBnode
*
pBnode
=
dndAcquireBnode
(
pDnode
);
if
(
pBnode
!=
NULL
)
{
dndReleaseBnode
(
pDnode
,
pBnode
);
terrno
=
TSDB_CODE_DND_BNODE_ALREADY_DEPLOYED
;
dError
(
"failed to create bnode since %s"
,
terrstr
());
return
-
1
;
}
SBnodeOpt
option
=
{
0
};
dndBuildBnodeOption
(
pDnode
,
&
option
);
SBnode
*
pBnode
=
bndOpen
(
pDnode
->
dir
.
bnode
,
&
option
);
pBnode
=
bndOpen
(
pDnode
->
dir
.
bnode
,
&
option
);
if
(
pBnode
==
NULL
)
{
dError
(
"failed to open bnode since %s"
,
terrstr
());
return
-
1
;
...
...
@@ -261,6 +269,7 @@ int32_t dndProcessCreateBnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) {
if
(
pMsg
->
dnodeId
!=
dndGetDnodeId
(
pDnode
))
{
terrno
=
TSDB_CODE_DND_BNODE_ID_INVALID
;
dError
(
"failed to create bnode since %s"
,
terrstr
());
return
-
1
;
}
else
{
return
dndOpenBnode
(
pDnode
);
...
...
@@ -273,6 +282,7 @@ int32_t dndProcessDropBnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) {
if
(
pMsg
->
dnodeId
!=
dndGetDnodeId
(
pDnode
))
{
terrno
=
TSDB_CODE_DND_BNODE_ID_INVALID
;
dError
(
"failed to drop bnode since %s"
,
terrstr
());
return
-
1
;
}
else
{
return
dndDropBnode
(
pDnode
);
...
...
source/dnode/mgmt/impl/src/dndQnode.c
浏览文件 @
c5decfec
...
...
@@ -27,7 +27,7 @@ static SQnode *dndAcquireQnode(SDnode *pDnode) {
int32_t
refCount
=
0
;
taosRLockLatch
(
&
pMgmt
->
latch
);
if
(
pMgmt
->
deployed
&&
!
pMgmt
->
dropped
)
{
if
(
pMgmt
->
deployed
&&
!
pMgmt
->
dropped
&&
pMgmt
->
pQnode
!=
NULL
)
{
refCount
=
atomic_add_fetch_32
(
&
pMgmt
->
refCount
,
1
);
pQnode
=
pMgmt
->
pQnode
;
}
else
{
...
...
@@ -175,7 +175,7 @@ static void dndStopQnodeWorker(SDnode *pDnode) {
pMgmt
->
deployed
=
0
;
taosWUnLockLatch
(
&
pMgmt
->
latch
);
while
(
pMgmt
->
refCount
>
1
)
{
while
(
pMgmt
->
refCount
>
0
)
{
taosMsleep
(
10
);
}
...
...
@@ -195,10 +195,19 @@ static void dndBuildQnodeOption(SDnode *pDnode, SQnodeOpt *pOption) {
static
int32_t
dndOpenQnode
(
SDnode
*
pDnode
)
{
SQnodeMgmt
*
pMgmt
=
&
pDnode
->
qmgmt
;
SQnodeOpt
option
=
{
0
};
SQnode
*
pQnode
=
dndAcquireQnode
(
pDnode
);
if
(
pQnode
!=
NULL
)
{
dndReleaseQnode
(
pDnode
,
pQnode
);
terrno
=
TSDB_CODE_DND_QNODE_ALREADY_DEPLOYED
;
dError
(
"failed to create qnode since %s"
,
terrstr
());
return
-
1
;
}
SQnodeOpt
option
=
{
0
};
dndBuildQnodeOption
(
pDnode
,
&
option
);
SQnode
*
pQnode
=
qndOpen
(
&
option
);
pQnode
=
qndOpen
(
&
option
);
if
(
pQnode
==
NULL
)
{
dError
(
"failed to open qnode since %s"
,
terrstr
());
return
-
1
;
...
...
@@ -266,6 +275,7 @@ int32_t dndProcessCreateQnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) {
if
(
pMsg
->
dnodeId
!=
dndGetDnodeId
(
pDnode
))
{
terrno
=
TSDB_CODE_DND_QNODE_ID_INVALID
;
dError
(
"failed to create qnode since %s"
,
terrstr
());
return
-
1
;
}
else
{
return
dndOpenQnode
(
pDnode
);
...
...
@@ -278,6 +288,7 @@ int32_t dndProcessDropQnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) {
if
(
pMsg
->
dnodeId
!=
dndGetDnodeId
(
pDnode
))
{
terrno
=
TSDB_CODE_DND_QNODE_ID_INVALID
;
dError
(
"failed to drop qnode since %s"
,
terrstr
());
return
-
1
;
}
else
{
return
dndDropQnode
(
pDnode
);
...
...
@@ -293,6 +304,7 @@ static void dndProcessQnodeQueue(SDnode *pDnode, SRpcMsg *pMsg) {
if
(
pQnode
!=
NULL
)
{
code
=
qndProcessMsg
(
pQnode
,
pMsg
,
&
pRsp
);
}
dndReleaseQnode
(
pDnode
,
pQnode
);
if
(
pRsp
!=
NULL
)
{
pRsp
->
ahandle
=
pMsg
->
ahandle
;
...
...
source/dnode/mgmt/impl/src/dndSnode.c
浏览文件 @
c5decfec
...
...
@@ -27,7 +27,7 @@ static SSnode *dndAcquireSnode(SDnode *pDnode) {
int32_t
refCount
=
0
;
taosRLockLatch
(
&
pMgmt
->
latch
);
if
(
pMgmt
->
deployed
&&
!
pMgmt
->
dropped
)
{
if
(
pMgmt
->
deployed
&&
!
pMgmt
->
dropped
&&
pMgmt
->
pSnode
!=
NULL
)
{
refCount
=
atomic_add_fetch_32
(
&
pMgmt
->
refCount
,
1
);
pSnode
=
pMgmt
->
pSnode
;
}
else
{
...
...
@@ -170,9 +170,9 @@ static void dndStopSnodeWorker(SDnode *pDnode) {
pMgmt
->
deployed
=
0
;
taosWUnLockLatch
(
&
pMgmt
->
latch
);
while
(
pMgmt
->
refCount
>
1
)
{
while
(
pMgmt
->
refCount
>
0
)
{
taosMsleep
(
10
);
}
}
dndCleanupWorker
(
&
pMgmt
->
writeWorker
);
}
...
...
@@ -189,10 +189,18 @@ static void dndBuildSnodeOption(SDnode *pDnode, SSnodeOpt *pOption) {
static
int32_t
dndOpenSnode
(
SDnode
*
pDnode
)
{
SSnodeMgmt
*
pMgmt
=
&
pDnode
->
smgmt
;
SSnodeOpt
option
=
{
0
};
SSnode
*
pSnode
=
dndAcquireSnode
(
pDnode
);
if
(
pSnode
!=
NULL
)
{
dndReleaseSnode
(
pDnode
,
pSnode
);
terrno
=
TSDB_CODE_DND_SNODE_ALREADY_DEPLOYED
;
dError
(
"failed to create snode since %s"
,
terrstr
());
return
-
1
;
}
SSnodeOpt
option
=
{
0
};
dndBuildSnodeOption
(
pDnode
,
&
option
);
SSnode
*
pSnode
=
sndOpen
(
pDnode
->
dir
.
snode
,
&
option
);
pSnode
=
sndOpen
(
pDnode
->
dir
.
snode
,
&
option
);
if
(
pSnode
==
NULL
)
{
dError
(
"failed to open snode since %s"
,
terrstr
());
return
-
1
;
...
...
@@ -261,6 +269,7 @@ int32_t dndProcessCreateSnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) {
if
(
pMsg
->
dnodeId
!=
dndGetDnodeId
(
pDnode
))
{
terrno
=
TSDB_CODE_DND_SNODE_ID_INVALID
;
dError
(
"failed to create snode since %s"
,
terrstr
());
return
-
1
;
}
else
{
return
dndOpenSnode
(
pDnode
);
...
...
@@ -273,6 +282,7 @@ int32_t dndProcessDropSnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) {
if
(
pMsg
->
dnodeId
!=
dndGetDnodeId
(
pDnode
))
{
terrno
=
TSDB_CODE_DND_SNODE_ID_INVALID
;
dError
(
"failed to drop snode since %s"
,
terrstr
());
return
-
1
;
}
else
{
return
dndDropSnode
(
pDnode
);
...
...
@@ -288,6 +298,7 @@ static void dndProcessSnodeQueue(SDnode *pDnode, SRpcMsg *pMsg) {
if
(
pSnode
!=
NULL
)
{
code
=
sndProcessMsg
(
pSnode
,
pMsg
,
&
pRsp
);
}
dndReleaseSnode
(
pDnode
,
pSnode
);
if
(
pRsp
!=
NULL
)
{
pRsp
->
ahandle
=
pMsg
->
ahandle
;
...
...
source/dnode/mgmt/impl/src/dnode.c
浏览文件 @
c5decfec
...
...
@@ -14,8 +14,11 @@
*/
#define _DEFAULT_SOURCE
#include "dndBnode.h"
#include "dndDnode.h"
#include "dndMnode.h"
#include "dndQnode.h"
#include "dndSnode.h"
#include "dndTransport.h"
#include "dndVnodes.h"
#include "sync.h"
...
...
@@ -200,6 +203,24 @@ SDnode *dndInit(SDnodeOpt *pOption) {
return
NULL
;
}
if
(
dndInitQnode
(
pDnode
)
!=
0
)
{
dError
(
"failed to init qnode"
);
dndCleanup
(
pDnode
);
return
NULL
;
}
if
(
dndInitSnode
(
pDnode
)
!=
0
)
{
dError
(
"failed to init snode"
);
dndCleanup
(
pDnode
);
return
NULL
;
}
if
(
dndInitBnode
(
pDnode
)
!=
0
)
{
dError
(
"failed to init bnode"
);
dndCleanup
(
pDnode
);
return
NULL
;
}
if
(
dndInitMnode
(
pDnode
)
!=
0
)
{
dError
(
"failed to init mnode"
);
dndCleanup
(
pDnode
);
...
...
@@ -232,6 +253,9 @@ void dndCleanup(SDnode *pDnode) {
dndSetStat
(
pDnode
,
DND_STAT_STOPPED
);
dndCleanupTrans
(
pDnode
);
dndCleanupMnode
(
pDnode
);
dndCleanupBnode
(
pDnode
);
dndCleanupSnode
(
pDnode
);
dndCleanupQnode
(
pDnode
);
dndCleanupVnodes
(
pDnode
);
dndCleanupDnode
(
pDnode
);
vnodeClear
();
...
...
source/dnode/mgmt/impl/test/qnode/dqnode.cpp
浏览文件 @
c5decfec
...
...
@@ -25,43 +25,50 @@ class DndTestQnode : public ::testing::Test {
Testbase
DndTestQnode
::
test
;
TEST_F
(
DndTestQnode
,
0
4
_Drop_User
)
{
TEST_F
(
DndTestQnode
,
0
1
_Create_Qnode_Invalid
)
{
{
int32_t
contLen
=
sizeof
(
SD
ropUser
Req
);
int32_t
contLen
=
sizeof
(
SD
CreateQnode
Req
);
SD
ropUserReq
*
pReq
=
(
SDropUser
Req
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
user
,
""
);
SD
CreateQnodeReq
*
pReq
=
(
SDCreateQnode
Req
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_
MND_DROP_USER
,
pReq
,
contLen
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_
DND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
TSDB_CODE_
MND_INVALID_USER_FORMAT
);
ASSERT_EQ
(
pMsg
->
code
,
TSDB_CODE_
DND_QNODE_ID_INVALID
);
}
//
{
// int32_t contLen = sizeof(SDropUser
Req);
{
int32_t
contLen
=
sizeof
(
SDCreateQnode
Req
);
// SDropUserReq* pReq = (SDropUser
Req*)rpcMallocCont(contLen);
// strcpy(pReq->user, "u4"
);
SDCreateQnodeReq
*
pReq
=
(
SDCreateQnode
Req
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
// SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_USER
, pReq, contLen);
//
ASSERT_NE(pMsg, nullptr);
// ASSERT_EQ(pMsg->code, TSDB_CODE_MND_USER_NOT_EXIST
);
//
}
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_DND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
}
//
{
// int32_t contLen = sizeof(SDropUser
Req);
{
int32_t
contLen
=
sizeof
(
SDCreateQnode
Req
);
// SDropUserReq* pReq = (SDropUser
Req*)rpcMallocCont(contLen);
// strcpy(pReq->user, "u1"
);
SDCreateQnodeReq
*
pReq
=
(
SDCreateQnode
Req
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
// SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_USER
, pReq, contLen);
//
ASSERT_NE(pMsg, nullptr);
// ASSERT_EQ(pMsg->code, 0
);
//
}
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_DND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
TSDB_CODE_DND_QNODE_ALREADY_DEPLOYED
);
}
// test.SendShowMetaMsg(TSDB_MGMT_TABLE_USER, "");
// CHECK_META("show users", 4);
test
.
Restart
();
// test.SendShowRetrieveMsg();
// EXPECT_EQ(test.GetShowRows(), 1);
{
int32_t
contLen
=
sizeof
(
SDCreateQnodeReq
);
SDCreateQnodeReq
*
pReq
=
(
SDCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_DND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
TSDB_CODE_DND_QNODE_ALREADY_DEPLOYED
);
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录