Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
61136183
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看板
未验证
提交
61136183
编写于
1月 06, 2022
作者:
S
Shengliang Guan
提交者:
GitHub
1月 06, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #9656 from taosdata/feature/dnode3
add batch for create_table
上级
ddacf755
767418e3
变更
41
隐藏空白更改
内联
并排
Showing
41 changed file
with
824 addition
and
424 deletion
+824
-424
include/common/tmsg.h
include/common/tmsg.h
+10
-13
include/dnode/mnode/sdb/sdb.h
include/dnode/mnode/sdb/sdb.h
+9
-0
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+2
-2
source/dnode/mgmt/impl/inc/dndInt.h
source/dnode/mgmt/impl/inc/dndInt.h
+14
-14
source/dnode/mgmt/impl/inc/dndMgmt.h
source/dnode/mgmt/impl/inc/dndMgmt.h
+0
-0
source/dnode/mgmt/impl/src/dndBnode.c
source/dnode/mgmt/impl/src/dndBnode.c
+1
-1
source/dnode/mgmt/impl/src/dndMgmt.c
source/dnode/mgmt/impl/src/dndMgmt.c
+49
-94
source/dnode/mgmt/impl/src/dndMnode.c
source/dnode/mgmt/impl/src/dndMnode.c
+1
-1
source/dnode/mgmt/impl/src/dndQnode.c
source/dnode/mgmt/impl/src/dndQnode.c
+1
-1
source/dnode/mgmt/impl/src/dndSnode.c
source/dnode/mgmt/impl/src/dndSnode.c
+1
-1
source/dnode/mgmt/impl/src/dndTransport.c
source/dnode/mgmt/impl/src/dndTransport.c
+1
-1
source/dnode/mgmt/impl/src/dndVnodes.c
source/dnode/mgmt/impl/src/dndVnodes.c
+1
-1
source/dnode/mgmt/impl/src/dndWorker.c
source/dnode/mgmt/impl/src/dndWorker.c
+3
-1
source/dnode/mgmt/impl/src/dnode.c
source/dnode/mgmt/impl/src/dnode.c
+1
-1
source/dnode/mgmt/impl/test/CMakeLists.txt
source/dnode/mgmt/impl/test/CMakeLists.txt
+1
-10
source/dnode/mgmt/impl/test/mnode/CMakeLists.txt
source/dnode/mgmt/impl/test/mnode/CMakeLists.txt
+2
-2
source/dnode/mgmt/impl/test/mnode/qmnode.cpp
source/dnode/mgmt/impl/test/mnode/qmnode.cpp
+26
-0
source/dnode/mnode/impl/src/mndDnode.c
source/dnode/mnode/impl/src/mndDnode.c
+75
-59
source/dnode/mnode/impl/src/mndProfile.c
source/dnode/mnode/impl/src/mndProfile.c
+69
-69
source/dnode/mnode/impl/src/mndShow.c
source/dnode/mnode/impl/src/mndShow.c
+5
-5
source/dnode/mnode/impl/test/CMakeLists.txt
source/dnode/mnode/impl/test/CMakeLists.txt
+3
-0
source/dnode/mnode/impl/test/bnode/bnode.cpp
source/dnode/mnode/impl/test/bnode/bnode.cpp
+2
-2
source/dnode/mnode/impl/test/dnode/CMakeLists.txt
source/dnode/mnode/impl/test/dnode/CMakeLists.txt
+11
-0
source/dnode/mnode/impl/test/dnode/dnode.cpp
source/dnode/mnode/impl/test/dnode/dnode.cpp
+350
-0
source/dnode/mnode/impl/test/mnode/CMakeLists.txt
source/dnode/mnode/impl/test/mnode/CMakeLists.txt
+11
-0
source/dnode/mnode/impl/test/mnode/mnode.cpp
source/dnode/mnode/impl/test/mnode/mnode.cpp
+48
-48
source/dnode/mnode/impl/test/profile/CMakeLists.txt
source/dnode/mnode/impl/test/profile/CMakeLists.txt
+11
-0
source/dnode/mnode/impl/test/profile/profile.cpp
source/dnode/mnode/impl/test/profile/profile.cpp
+48
-48
source/dnode/mnode/impl/test/qnode/qnode.cpp
source/dnode/mnode/impl/test/qnode/qnode.cpp
+2
-2
source/dnode/mnode/impl/test/show/show.cpp
source/dnode/mnode/impl/test/show/show.cpp
+3
-3
source/dnode/mnode/impl/test/snode/snode.cpp
source/dnode/mnode/impl/test/snode/snode.cpp
+2
-2
source/dnode/mnode/impl/test/trans/trans.cpp
source/dnode/mnode/impl/test/trans/trans.cpp
+2
-2
source/dnode/mnode/sdb/src/sdbHash.c
source/dnode/mnode/sdb/src/sdbHash.c
+9
-0
source/libs/parser/inc/astToMsg.h
source/libs/parser/inc/astToMsg.h
+2
-2
source/libs/parser/src/astToMsg.c
source/libs/parser/src/astToMsg.c
+6
-6
source/libs/parser/src/astValidate.c
source/libs/parser/src/astValidate.c
+1
-1
src/client/src/tscProfile.c
src/client/src/tscProfile.c
+2
-2
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+1
-1
src/client/src/tscServer.c
src/client/src/tscServer.c
+10
-10
tests/script/general/table/basic1.sim
tests/script/general/table/basic1.sim
+8
-1
tests/test/c/create_table.c
tests/test/c/create_table.c
+20
-18
未找到文件。
include/common/tmsg.h
浏览文件 @
61136183
...
...
@@ -302,7 +302,7 @@ typedef struct {
char
app
[
TSDB_APP_NAME_LEN
];
char
db
[
TSDB_DB_NAME_LEN
];
int64_t
startTime
;
}
SConnect
Msg
;
}
SConnect
Req
;
typedef
struct
SEpSet
{
int8_t
inUse
;
...
...
@@ -650,6 +650,7 @@ typedef struct {
int32_t
sver
;
int32_t
dnodeId
;
int64_t
clusterId
;
int64_t
dver
;
int64_t
rebootTime
;
int64_t
updateTime
;
int32_t
numOfCores
;
...
...
@@ -657,7 +658,7 @@ typedef struct {
char
dnodeEp
[
TSDB_EP_LEN
];
SClusterCfg
clusterCfg
;
SVnodeLoads
vnodeLoads
;
}
SStatus
Msg
;
}
SStatus
Req
;
typedef
struct
{
int32_t
reserved
;
...
...
@@ -682,6 +683,7 @@ typedef struct {
}
SDnodeEps
;
typedef
struct
{
int64_t
dver
;
SDnodeCfg
dnodeCfg
;
SDnodeEps
dnodeEps
;
}
SStatusRsp
;
...
...
@@ -833,16 +835,16 @@ typedef struct SShowRsp {
typedef
struct
{
char
fqdn
[
TSDB_FQDN_LEN
];
// end point, hostname:port
int32_t
port
;
}
SCreateDnode
Msg
;
}
SCreateDnode
Req
;
typedef
struct
{
int32_t
dnodeId
;
}
SDropDnode
Msg
;
}
SDropDnode
Req
;
typedef
struct
{
int32_t
dnodeId
;
char
config
[
TSDB_DNODE_CONFIG_LEN
];
}
S
CfgDnodeMsg
;
}
S
MCfgDnodeReq
,
SDCfgDnodeReq
;
typedef
struct
{
int32_t
dnodeId
;
...
...
@@ -898,7 +900,7 @@ typedef struct {
int32_t
numOfStreams
;
char
app
[
TSDB_APP_NAME_LEN
];
char
pData
[];
}
SHeartBeat
Msg
;
}
SHeartBeat
Req
;
typedef
struct
{
int32_t
connId
;
...
...
@@ -911,19 +913,14 @@ typedef struct {
SEpSet
epSet
;
}
SHeartBeatRsp
;
typedef
struct
{
int32_t
connId
;
int32_t
streamId
;
}
SKillStreamMsg
;
typedef
struct
{
int32_t
connId
;
int32_t
queryId
;
}
SKillQuery
Msg
;
}
SKillQuery
Req
;
typedef
struct
{
int32_t
connId
;
}
SKillConn
Msg
;
}
SKillConn
Req
;
typedef
struct
{
char
user
[
TSDB_USER_LEN
];
...
...
include/dnode/mnode/sdb/sdb.h
浏览文件 @
61136183
...
...
@@ -281,6 +281,15 @@ int32_t sdbGetSize(SSdb *pSdb, ESdbType type);
*/
int32_t
sdbGetMaxId
(
SSdb
*
pSdb
,
ESdbType
type
);
/**
* @brief Get the version of the table
*
* @param pSdb The sdb object.
* @param pIter The type of the table.
* @return int32_t The version of the table
*/
int64_t
sdbGetTableVer
(
SSdb
*
pSdb
,
ESdbType
type
);
/**
* @brief Update the version of sdb
*
...
...
source/client/src/clientImpl.c
浏览文件 @
61136183
...
...
@@ -395,13 +395,13 @@ static SMsgSendInfo* buildConnectMsg(SRequestObj *pRequest) {
}
pMsgSendInfo
->
msgType
=
TDMT_MND_CONNECT
;
pMsgSendInfo
->
msgInfo
.
len
=
sizeof
(
SConnect
Msg
);
pMsgSendInfo
->
msgInfo
.
len
=
sizeof
(
SConnect
Req
);
pMsgSendInfo
->
requestObjRefId
=
pRequest
->
self
;
pMsgSendInfo
->
requestId
=
pRequest
->
requestId
;
pMsgSendInfo
->
fp
=
handleRequestRspFp
[
TMSG_INDEX
(
pMsgSendInfo
->
msgType
)];
pMsgSendInfo
->
param
=
pRequest
;
SConnect
Msg
*
pConnect
=
calloc
(
1
,
sizeof
(
SConnectMsg
));
SConnect
Req
*
pConnect
=
calloc
(
1
,
sizeof
(
SConnectReq
));
if
(
pConnect
==
NULL
)
{
tfree
(
pMsgSendInfo
);
terrno
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
...
...
source/dnode/mgmt/impl/inc/dndInt.h
浏览文件 @
61136183
...
...
@@ -80,20 +80,20 @@ typedef struct {
}
SDnodeDir
;
typedef
struct
{
int32_t
dnodeId
;
int32_t
dropped
;
int64_t
clusterId
;
int64_t
rebootTime
;
int64_t
update
Time
;
int
8_t
statusSent
;
SEpSet
mnodeEpSe
t
;
char
*
file
;
SHashObj
*
dnodeHash
;
S
DnodeEps
*
dnodeEps
;
pthread_t
*
threadId
;
SRWLatch
latch
;
S
TaosQueue
*
pMgmtQ
;
S
WorkerPool
mgmtPool
;
int32_t
dnodeId
;
int32_t
dropped
;
int64_t
clusterId
;
int64_t
dver
;
int64_t
reboot
Time
;
int
64_t
updateTime
;
int8_t
statusSen
t
;
SEpSet
mnodeEpSet
;
char
*
file
;
S
HashObj
*
dnodeHash
;
SDnodeEps
*
dnodeEps
;
pthread_t
*
threadId
;
S
RWLatch
latch
;
S
DnodeWorker
mgmtWorker
;
}
SDnodeMgmt
;
typedef
struct
{
...
...
source/dnode/mgmt/impl/inc/dnd
Dnode
.h
→
source/dnode/mgmt/impl/inc/dnd
Mgmt
.h
浏览文件 @
61136183
文件已移动
source/dnode/mgmt/impl/src/dndBnode.c
浏览文件 @
61136183
...
...
@@ -15,7 +15,7 @@
#define _DEFAULT_SOURCE
#include "dndBnode.h"
#include "dnd
Dnode
.h"
#include "dnd
Mgmt
.h"
#include "dndTransport.h"
#include "dndWorker.h"
...
...
source/dnode/mgmt/impl/src/dnd
Dnode
.c
→
source/dnode/mgmt/impl/src/dnd
Mgmt
.c
浏览文件 @
61136183
...
...
@@ -14,28 +14,25 @@
*/
#define _DEFAULT_SOURCE
#include "dnd
Dnode
.h"
#include "dnd
Mgmt
.h"
#include "dndBnode.h"
#include "dndMnode.h"
#include "dndQnode.h"
#include "dndSnode.h"
#include "dndTransport.h"
#include "dndVnodes.h"
#include "dndWorker.h"
static
int32_t
dndInitMgmtWorker
(
SDnode
*
pDnode
);
static
void
dndCleanupMgmtWorker
(
SDnode
*
pDnode
);
static
int32_t
dndAllocMgmtQueue
(
SDnode
*
pDnode
);
static
void
dndFreeMgmtQueue
(
SDnode
*
pDnode
);
static
void
dndProcessMgmtQueue
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
);
static
void
dndProcessMgmtQueue
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
);
static
int32_t
dndReadDnodes
(
SDnode
*
pDnode
);
static
int32_t
dndWriteDnodes
(
SDnode
*
pDnode
);
static
void
*
dnodeThreadRoutine
(
void
*
param
);
static
int32_t
dndProcessConfigDnodeReq
(
SDnode
*
pDnode
,
SRpcMsg
*
p
Msg
);
static
void
dndProcessStatusRsp
(
SDnode
*
pDnode
,
SRpcMsg
*
p
Msg
);
static
void
dndProcessAuthRsp
(
SDnode
*
pDnode
,
SRpcMsg
*
p
Msg
);
static
void
dndProcessGrantRsp
(
SDnode
*
pDnode
,
SRpcMsg
*
p
Msg
);
static
int32_t
dndProcessConfigDnodeReq
(
SDnode
*
pDnode
,
SRpcMsg
*
p
Req
);
static
void
dndProcessStatusRsp
(
SDnode
*
pDnode
,
SRpcMsg
*
p
Rsp
);
static
void
dndProcessAuthRsp
(
SDnode
*
pDnode
,
SRpcMsg
*
p
Rsp
);
static
void
dndProcessGrantRsp
(
SDnode
*
pDnode
,
SRpcMsg
*
p
Rsp
);
int32_t
dndGetDnodeId
(
SDnode
*
pDnode
)
{
SDnodeMgmt
*
pMgmt
=
&
pDnode
->
dmgmt
;
...
...
@@ -80,13 +77,13 @@ void dndGetMnodeEpSet(SDnode *pDnode, SEpSet *pEpSet) {
taosRUnLockLatch
(
&
pMgmt
->
latch
);
}
void
dndSendRedirectRsp
(
SDnode
*
pDnode
,
SRpcMsg
*
p
Msg
)
{
tmsg_t
msgType
=
p
Msg
->
msgType
;
void
dndSendRedirectRsp
(
SDnode
*
pDnode
,
SRpcMsg
*
p
Req
)
{
tmsg_t
msgType
=
p
Req
->
msgType
;
SEpSet
epSet
=
{
0
};
dndGetMnodeEpSet
(
pDnode
,
&
epSet
);
dDebug
(
"RPC %p,
msg:%s is redirected, num:%d use:%d"
,
pMsg
->
handle
,
TMSG_INFO
(
msgType
),
epSet
.
numOfEps
,
epSet
.
inUse
);
dDebug
(
"RPC %p,
req:%s is redirected, num:%d use:%d"
,
pReq
->
handle
,
TMSG_INFO
(
msgType
),
epSet
.
numOfEps
,
epSet
.
inUse
);
for
(
int32_t
i
=
0
;
i
<
epSet
.
numOfEps
;
++
i
)
{
dDebug
(
"mnode index:%d %s:%u"
,
i
,
epSet
.
fqdn
[
i
],
epSet
.
port
[
i
]);
if
(
strcmp
(
epSet
.
fqdn
[
i
],
pDnode
->
opt
.
localFqdn
)
==
0
&&
epSet
.
port
[
i
]
==
pDnode
->
opt
.
serverPort
)
{
...
...
@@ -96,7 +93,7 @@ void dndSendRedirectRsp(SDnode *pDnode, SRpcMsg *pMsg) {
epSet
.
port
[
i
]
=
htons
(
epSet
.
port
[
i
]);
}
rpcSendRedirectRsp
(
p
Msg
->
handle
,
&
epSet
);
rpcSendRedirectRsp
(
p
Req
->
handle
,
&
epSet
);
}
static
void
dndUpdateMnodeEpSet
(
SDnode
*
pDnode
,
SEpSet
*
pEpSet
)
{
...
...
@@ -350,14 +347,14 @@ static int32_t dndWriteDnodes(SDnode *pDnode) {
terrno
=
0
;
pMgmt
->
updateTime
=
taosGetTimestampMs
();
d
Info
(
"successed to write %s"
,
pMgmt
->
file
);
d
Debug
(
"successed to write %s"
,
pMgmt
->
file
);
return
0
;
}
void
dndSendStatusReq
(
SDnode
*
pDnode
)
{
int32_t
contLen
=
sizeof
(
SStatus
Msg
)
+
TSDB_MAX_VNODES
*
sizeof
(
SVnodeLoad
);
int32_t
contLen
=
sizeof
(
SStatus
Req
)
+
TSDB_MAX_VNODES
*
sizeof
(
SVnodeLoad
);
SStatus
Msg
*
pStatus
=
rpcMallocCont
(
contLen
);
SStatus
Req
*
pStatus
=
rpcMallocCont
(
contLen
);
if
(
pStatus
==
NULL
)
{
dError
(
"failed to malloc status message"
);
return
;
...
...
@@ -366,6 +363,7 @@ void dndSendStatusReq(SDnode *pDnode) {
SDnodeMgmt
*
pMgmt
=
&
pDnode
->
dmgmt
;
taosRLockLatch
(
&
pMgmt
->
latch
);
pStatus
->
sver
=
htonl
(
pDnode
->
opt
.
sver
);
pStatus
->
dver
=
htobe64
(
pMgmt
->
dver
);
pStatus
->
dnodeId
=
htonl
(
pMgmt
->
dnodeId
);
pStatus
->
clusterId
=
htobe64
(
pMgmt
->
clusterId
);
pStatus
->
rebootTime
=
htobe64
(
pMgmt
->
rebootTime
);
...
...
@@ -385,12 +383,12 @@ void dndSendStatusReq(SDnode *pDnode) {
taosRUnLockLatch
(
&
pMgmt
->
latch
);
dndGetVnodeLoads
(
pDnode
,
&
pStatus
->
vnodeLoads
);
contLen
=
sizeof
(
SStatus
Msg
)
+
pStatus
->
vnodeLoads
.
num
*
sizeof
(
SVnodeLoad
);
contLen
=
sizeof
(
SStatus
Req
)
+
pStatus
->
vnodeLoads
.
num
*
sizeof
(
SVnodeLoad
);
SRpcMsg
rpcMsg
=
{.
pCont
=
pStatus
,
.
contLen
=
contLen
,
.
msgType
=
TDMT_MND_STATUS
,
.
ahandle
=
(
void
*
)
9527
};
pMgmt
->
statusSent
=
1
;
dTrace
(
"pDnode:%p, send status
msg
to mnode"
,
pDnode
);
dTrace
(
"pDnode:%p, send status
req
to mnode"
,
pDnode
);
dndSendReqToMnode
(
pDnode
,
&
rpcMsg
);
}
...
...
@@ -426,12 +424,12 @@ static void dndUpdateDnodeEps(SDnode *pDnode, SDnodeEps *pDnodeEps) {
taosWUnLockLatch
(
&
pMgmt
->
latch
);
}
static
void
dndProcessStatusRsp
(
SDnode
*
pDnode
,
SRpcMsg
*
p
Msg
)
{
static
void
dndProcessStatusRsp
(
SDnode
*
pDnode
,
SRpcMsg
*
p
Rsp
)
{
SDnodeMgmt
*
pMgmt
=
&
pDnode
->
dmgmt
;
if
(
p
Msg
->
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
p
Rsp
->
code
!=
TSDB_CODE_SUCCESS
)
{
pMgmt
->
statusSent
=
0
;
if
(
p
Msg
->
code
==
TSDB_CODE_MND_DNODE_NOT_EXIST
&&
!
pMgmt
->
dropped
&&
pMgmt
->
dnodeId
>
0
)
{
if
(
p
Rsp
->
code
==
TSDB_CODE_MND_DNODE_NOT_EXIST
&&
!
pMgmt
->
dropped
&&
pMgmt
->
dnodeId
>
0
)
{
dInfo
(
"dnode:%d, set to dropped since not exist in mnode"
,
pMgmt
->
dnodeId
);
pMgmt
->
dropped
=
1
;
dndWriteDnodes
(
pDnode
);
...
...
@@ -439,14 +437,16 @@ static void dndProcessStatusRsp(SDnode *pDnode, SRpcMsg *pMsg) {
return
;
}
SStatusRsp
*
pRsp
=
pMsg
->
pCont
;
if
(
pMsg
->
pCont
!=
NULL
&&
pMsg
->
contLen
!=
0
)
{
SDnodeCfg
*
pCfg
=
&
pRsp
->
dnodeCfg
;
if
(
pRsp
->
pCont
!=
NULL
&&
pRsp
->
contLen
!=
0
)
{
SStatusRsp
*
pStatus
=
pRsp
->
pCont
;
pMgmt
->
dver
=
htobe64
(
pStatus
->
dver
);
SDnodeCfg
*
pCfg
=
&
pStatus
->
dnodeCfg
;
pCfg
->
dnodeId
=
htonl
(
pCfg
->
dnodeId
);
pCfg
->
clusterId
=
htobe64
(
pCfg
->
clusterId
);
dndUpdateDnodeCfg
(
pDnode
,
pCfg
);
SDnodeEps
*
pDnodeEps
=
&
p
Rsp
->
dnodeEps
;
SDnodeEps
*
pDnodeEps
=
&
p
Status
->
dnodeEps
;
pDnodeEps
->
num
=
htonl
(
pDnodeEps
->
num
);
for
(
int32_t
i
=
0
;
i
<
pDnodeEps
->
num
;
++
i
)
{
pDnodeEps
->
eps
[
i
].
id
=
htonl
(
pDnodeEps
->
eps
[
i
].
id
);
...
...
@@ -458,26 +458,27 @@ static void dndProcessStatusRsp(SDnode *pDnode, SRpcMsg *pMsg) {
pMgmt
->
statusSent
=
0
;
}
static
void
dndProcessAuthRsp
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
)
{
assert
(
1
);
}
static
void
dndProcessGrantRsp
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
)
{
assert
(
1
);
}
static
void
dndProcessAuthRsp
(
SDnode
*
pDnode
,
SRpcMsg
*
pReq
)
{
dError
(
"auth rsp is received, but not supported yet"
);
}
static
int32_t
dndProcessConfigDnodeReq
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
)
{
dError
(
"
config msg
is received, but not supported yet"
);
SCfgDnodeMsg
*
pCfg
=
pMsg
->
pCont
;
static
void
dndProcessGrantRsp
(
SDnode
*
pDnode
,
SRpcMsg
*
pReq
)
{
dError
(
"
grant rsp
is received, but not supported yet"
);
}
static
int32_t
dndProcessConfigDnodeReq
(
SDnode
*
pDnode
,
SRpcMsg
*
pReq
)
{
dError
(
"config req is received, but not supported yet"
);
SDCfgDnodeReq
*
pCfg
=
pReq
->
pCont
;
return
TSDB_CODE_OPS_NOT_SUPPORT
;
}
void
dndProcessStartupReq
(
SDnode
*
pDnode
,
SRpcMsg
*
p
Msg
)
{
dDebug
(
"startup
msg
is received"
);
void
dndProcessStartupReq
(
SDnode
*
pDnode
,
SRpcMsg
*
p
Req
)
{
dDebug
(
"startup
req
is received"
);
SStartupMsg
*
pStartup
=
rpcMallocCont
(
sizeof
(
SStartupMsg
));
dndGetStartup
(
pDnode
,
pStartup
);
dDebug
(
"startup
msg
is sent, step:%s desc:%s finished:%d"
,
pStartup
->
name
,
pStartup
->
desc
,
pStartup
->
finished
);
dDebug
(
"startup
req
is sent, step:%s desc:%s finished:%d"
,
pStartup
->
name
,
pStartup
->
desc
,
pStartup
->
finished
);
SRpcMsg
rpcRsp
=
{.
handle
=
p
Msg
->
handle
,
.
pCont
=
pStartup
,
.
contLen
=
sizeof
(
SStartupMsg
)};
SRpcMsg
rpcRsp
=
{.
handle
=
p
Req
->
handle
,
.
pCont
=
pStartup
,
.
contLen
=
sizeof
(
SStartupMsg
)};
rpcSendResponse
(
&
rpcRsp
);
}
...
...
@@ -530,13 +531,8 @@ int32_t dndInitDnode(SDnode *pDnode) {
return
-
1
;
}
if
(
dndInitMgmtWorker
(
pDnode
)
!=
0
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
if
(
dndAllocMgmtQueue
(
pDnode
)
!=
0
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
if
(
dndInitWorker
(
pDnode
,
&
pMgmt
->
mgmtWorker
,
DND_WORKER_SINGLE
,
"dnode-mgmt"
,
1
,
1
,
dndProcessMgmtQueue
)
!=
0
)
{
dError
(
"failed to start dnode mgmt worker since %s"
,
terrstr
());
return
-
1
;
}
...
...
@@ -547,15 +543,14 @@ int32_t dndInitDnode(SDnode *pDnode) {
return
-
1
;
}
dInfo
(
"dnode-
dnode
is initialized"
);
dInfo
(
"dnode-
mgmt
is initialized"
);
return
0
;
}
void
dndCleanupDnode
(
SDnode
*
pDnode
)
{
SDnodeMgmt
*
pMgmt
=
&
pDnode
->
dmgmt
;
dndCleanupMgmtWorker
(
pDnode
);
dndFreeMgmtQueue
(
pDnode
);
dndCleanupWorker
(
&
pMgmt
->
mgmtWorker
);
if
(
pMgmt
->
threadId
!=
NULL
)
{
taosDestoryThread
(
pMgmt
->
threadId
);
...
...
@@ -580,62 +575,22 @@ void dndCleanupDnode(SDnode *pDnode) {
}
taosWUnLockLatch
(
&
pMgmt
->
latch
);
dInfo
(
"dnode-dnode is cleaned up"
);
}
static
int32_t
dndInitMgmtWorker
(
SDnode
*
pDnode
)
{
SDnodeMgmt
*
pMgmt
=
&
pDnode
->
dmgmt
;
SWorkerPool
*
pPool
=
&
pMgmt
->
mgmtPool
;
pPool
->
name
=
"dnode-mgmt"
;
pPool
->
min
=
1
;
pPool
->
max
=
1
;
if
(
tWorkerInit
(
pPool
)
!=
0
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
dDebug
(
"dnode mgmt worker is initialized"
);
return
0
;
dInfo
(
"dnode-mgmt is cleaned up"
);
}
static
void
dndCleanupMgmtWorker
(
SDnode
*
pDnode
)
{
void
dndProcessMgmtMsg
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
)
{
SDnodeMgmt
*
pMgmt
=
&
pDnode
->
dmgmt
;
tWorkerCleanup
(
&
pMgmt
->
mgmtPool
);
dDebug
(
"dnode mgmt worker is closed"
);
}
static
int32_t
dndAllocMgmtQueue
(
SDnode
*
pDnode
)
{
SDnodeMgmt
*
pMgmt
=
&
pDnode
->
dmgmt
;
pMgmt
->
pMgmtQ
=
tWorkerAllocQueue
(
&
pMgmt
->
mgmtPool
,
pDnode
,
(
FProcessItem
)
dndProcessMgmtQueue
);
if
(
pMgmt
->
pMgmtQ
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
return
0
;
}
static
void
dndFreeMgmtQueue
(
SDnode
*
pDnode
)
{
SDnodeMgmt
*
pMgmt
=
&
pDnode
->
dmgmt
;
tWorkerFreeQueue
(
&
pMgmt
->
mgmtPool
,
pMgmt
->
pMgmtQ
);
pMgmt
->
pMgmtQ
=
NULL
;
}
void
dndProcessMgmtMsg
(
SDnode
*
pDnode
,
SRpcMsg
*
pRpcMsg
,
SEpSet
*
pEpSet
)
{
SDnodeMgmt
*
pMgmt
=
&
pDnode
->
dmgmt
;
if
(
pEpSet
&&
pEpSet
->
numOfEps
>
0
&&
pRpcMsg
->
msgType
==
TDMT_MND_STATUS_RSP
)
{
if
(
pEpSet
&&
pEpSet
->
numOfEps
>
0
&&
pMsg
->
msgType
==
TDMT_MND_STATUS_RSP
)
{
dndUpdateMnodeEpSet
(
pDnode
,
pEpSet
);
}
SRpcMsg
*
pMsg
=
taosAllocateQitem
(
sizeof
(
SRpcMsg
));
if
(
pMsg
!=
NULL
)
*
pMsg
=
*
pRpcMsg
;
if
(
pMsg
==
NULL
||
taosWriteQitem
(
pMgmt
->
pMgmtQ
,
pMsg
)
!=
0
)
{
if
(
pRpcMsg
->
msgType
&
1u
)
{
SRpcMsg
rsp
=
{.
handle
=
pRpcMsg
->
handle
,
.
code
=
TSDB_CODE_OUT_OF_MEMORY
};
if
(
dndWriteMsgToWorker
(
&
pMgmt
->
mgmtWorker
,
pMsg
,
sizeof
(
SRpcMsg
))
!=
0
)
{
if
(
pMsg
->
msgType
&
1u
)
{
SRpcMsg
rsp
=
{.
handle
=
pMsg
->
handle
,
.
code
=
TSDB_CODE_OUT_OF_MEMORY
};
rpcSendResponse
(
&
rsp
);
}
rpcFreeCont
(
p
Rpc
Msg
->
pCont
);
rpcFreeCont
(
pMsg
->
pCont
);
taosFreeQitem
(
pMsg
);
}
}
...
...
@@ -704,7 +659,7 @@ static void dndProcessMgmtQueue(SDnode *pDnode, SRpcMsg *pMsg) {
default:
terrno
=
TSDB_CODE_MSG_NOT_PROCESSED
;
code
=
-
1
;
dError
(
"RPC %p, dnode
req
:%s not processed"
,
pMsg
->
handle
,
TMSG_INFO
(
pMsg
->
msgType
));
dError
(
"RPC %p, dnode
msg
:%s not processed"
,
pMsg
->
handle
,
TMSG_INFO
(
pMsg
->
msgType
));
break
;
}
...
...
source/dnode/mgmt/impl/src/dndMnode.c
浏览文件 @
61136183
...
...
@@ -15,7 +15,7 @@
#define _DEFAULT_SOURCE
#include "dndMnode.h"
#include "dnd
Dnode
.h"
#include "dnd
Mgmt
.h"
#include "dndTransport.h"
#include "dndWorker.h"
...
...
source/dnode/mgmt/impl/src/dndQnode.c
浏览文件 @
61136183
...
...
@@ -15,7 +15,7 @@
#define _DEFAULT_SOURCE
#include "dndQnode.h"
#include "dnd
Dnode
.h"
#include "dnd
Mgmt
.h"
#include "dndTransport.h"
#include "dndWorker.h"
...
...
source/dnode/mgmt/impl/src/dndSnode.c
浏览文件 @
61136183
...
...
@@ -15,7 +15,7 @@
#define _DEFAULT_SOURCE
#include "dndSnode.h"
#include "dnd
Dnode
.h"
#include "dnd
Mgmt
.h"
#include "dndTransport.h"
#include "dndWorker.h"
...
...
source/dnode/mgmt/impl/src/dndTransport.c
浏览文件 @
61136183
...
...
@@ -21,7 +21,7 @@
#define _DEFAULT_SOURCE
#include "dndTransport.h"
#include "dnd
Dnode
.h"
#include "dnd
Mgmt
.h"
#include "dndMnode.h"
#include "dndVnodes.h"
...
...
source/dnode/mgmt/impl/src/dndVnodes.c
浏览文件 @
61136183
...
...
@@ -388,7 +388,7 @@ static int32_t dndWriteVnodesToFile(SDnode *pDnode) {
free
(
pVnodes
);
}
d
Info
(
"successed to write %s"
,
file
);
d
Debug
(
"successed to write %s"
,
real
file
);
return
taosRenameFile
(
file
,
realfile
);
}
...
...
source/dnode/mgmt/impl/src/dndWorker.c
浏览文件 @
61136183
...
...
@@ -101,7 +101,9 @@ int32_t dndWriteMsgToWorker(SDnodeWorker *pWorker, void *pCont, int32_t contLen)
}
if
(
taosWriteQitem
(
pWorker
->
queue
,
pMsg
)
!=
0
)
{
taosFreeQitem
(
pMsg
);
if
(
contLen
!=
0
)
{
taosFreeQitem
(
pMsg
);
}
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
...
...
source/dnode/mgmt/impl/src/dnode.c
浏览文件 @
61136183
...
...
@@ -15,7 +15,7 @@
#define _DEFAULT_SOURCE
#include "dndBnode.h"
#include "dnd
Dnode
.h"
#include "dnd
Mgmt
.h"
#include "dndMnode.h"
#include "dndQnode.h"
#include "dndSnode.h"
...
...
source/dnode/mgmt/impl/test/CMakeLists.txt
浏览文件 @
61136183
...
...
@@ -3,18 +3,9 @@ enable_testing()
add_subdirectory
(
qnode
)
add_subdirectory
(
bnode
)
add_subdirectory
(
snode
)
# add_subdirectory(auth)
# add_subdirectory(balance)
add_subdirectory
(
db
)
add_subdirectory
(
dnode
)
# add_subdirectory(func)
add_subdirectory
(
mnode
)
add_subdirectory
(
profile
)
add_subdirectory
(
db
)
add_subdirectory
(
stb
)
# add_subdirectory(sync)
# add_subdirectory(telem)
# add_subdirectory(trans)
add_subdirectory
(
vgroup
)
add_subdirectory
(
sut
)
source/dnode/mgmt/impl/test/mnode/CMakeLists.txt
浏览文件 @
61136183
aux_source_directory
(
. MTEST_SRC
)
add_executable
(
dnode_test_mnode
${
MTEST_SRC
}
)
aux_source_directory
(
.
D
MTEST_SRC
)
add_executable
(
dnode_test_mnode
${
D
MTEST_SRC
}
)
target_link_libraries
(
dnode_test_mnode
PUBLIC sut
...
...
source/dnode/mgmt/impl/test/mnode/qmnode.cpp
0 → 100644
浏览文件 @
61136183
/**
* @file dmnode.cpp
* @author slguan (slguan@taosdata.com)
* @brief DNODE module mnode tests
* @version 1.0
* @date 2022-01-07
*
* @copyright Copyright (c) 2022
*
*/
#include "sut.h"
class
DndTestMnode
:
public
::
testing
::
Test
{
protected:
static
void
SetUpTestSuite
()
{
test
.
Init
(
"/tmp/dnode_test_mnode"
,
9113
);
}
static
void
TearDownTestSuite
()
{
test
.
Cleanup
();
}
static
Testbase
test
;
public:
void
SetUp
()
override
{}
void
TearDown
()
override
{}
};
Testbase
DndTestMnode
::
test
;
source/dnode/mnode/impl/src/mndDnode.c
浏览文件 @
61136183
...
...
@@ -45,19 +45,19 @@ static SSdbRaw *mndDnodeActionEncode(SDnodeObj *pDnode);
static
SSdbRow
*
mndDnodeActionDecode
(
SSdbRaw
*
pRaw
);
static
int32_t
mndDnodeActionInsert
(
SSdb
*
pSdb
,
SDnodeObj
*
pDnode
);
static
int32_t
mndDnodeActionDelete
(
SSdb
*
pSdb
,
SDnodeObj
*
pDnode
);
static
int32_t
mndDnodeActionUpdate
(
SSdb
*
pSdb
,
SDnodeObj
*
pOld
Dnode
,
SDnodeObj
*
pNewDnode
);
static
int32_t
mndDnodeActionUpdate
(
SSdb
*
pSdb
,
SDnodeObj
*
pOld
,
SDnodeObj
*
pNew
);
static
int32_t
mndProcessCreateDnode
Msg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessDropDnode
Msg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessConfigDnode
Msg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessConfigDnodeRsp
(
SMnodeMsg
*
p
Msg
);
static
int32_t
mndProcessStatus
Msg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessCreateDnode
Req
(
SMnodeMsg
*
pReq
);
static
int32_t
mndProcessDropDnode
Req
(
SMnodeMsg
*
pReq
);
static
int32_t
mndProcessConfigDnode
Req
(
SMnodeMsg
*
pReq
);
static
int32_t
mndProcessConfigDnodeRsp
(
SMnodeMsg
*
p
Rsp
);
static
int32_t
mndProcessStatus
Req
(
SMnodeMsg
*
pReq
);
static
int32_t
mndGetConfigMeta
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
);
static
int32_t
mndRetrieveConfigs
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
int32_t
mndGetConfigMeta
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
);
static
int32_t
mndRetrieveConfigs
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
void
mndCancelGetNextConfig
(
SMnode
*
pMnode
,
void
*
pIter
);
static
int32_t
mndGetDnodeMeta
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
);
static
int32_t
mndRetrieveDnodes
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
int32_t
mndGetDnodeMeta
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
);
static
int32_t
mndRetrieveDnodes
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
void
mndCancelGetNextDnode
(
SMnode
*
pMnode
,
void
*
pIter
);
int32_t
mndInitDnode
(
SMnode
*
pMnode
)
{
...
...
@@ -70,11 +70,11 @@ int32_t mndInitDnode(SMnode *pMnode) {
.
updateFp
=
(
SdbUpdateFp
)
mndDnodeActionUpdate
,
.
deleteFp
=
(
SdbDeleteFp
)
mndDnodeActionDelete
};
mndSetMsgHandle
(
pMnode
,
TDMT_MND_CREATE_DNODE
,
mndProcessCreateDnode
Msg
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_DROP_DNODE
,
mndProcessDropDnode
Msg
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_CONFIG_DNODE
,
mndProcessConfigDnode
Msg
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_CREATE_DNODE
,
mndProcessCreateDnode
Req
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_DROP_DNODE
,
mndProcessDropDnode
Req
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_CONFIG_DNODE
,
mndProcessConfigDnode
Req
);
mndSetMsgHandle
(
pMnode
,
TDMT_DND_CONFIG_DNODE_RSP
,
mndProcessConfigDnodeRsp
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_STATUS
,
mndProcessStatus
Msg
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_STATUS
,
mndProcessStatus
Req
);
mndAddShowMetaHandle
(
pMnode
,
TSDB_MGMT_TABLE_VARIABLES
,
mndGetConfigMeta
);
mndAddShowRetrieveHandle
(
pMnode
,
TSDB_MGMT_TABLE_VARIABLES
,
mndRetrieveConfigs
);
...
...
@@ -182,9 +182,9 @@ static int32_t mndDnodeActionDelete(SSdb *pSdb, SDnodeObj *pDnode) {
return
0
;
}
static
int32_t
mndDnodeActionUpdate
(
SSdb
*
pSdb
,
SDnodeObj
*
pOld
Dnode
,
SDnodeObj
*
pNewDnode
)
{
mTrace
(
"dnode:%d, perform update action, old_row:%p new_row:%p"
,
pOld
Dnode
->
id
,
pOldDnode
,
pNewDnode
);
pOld
Dnode
->
updateTime
=
pNewDnode
->
updateTime
;
static
int32_t
mndDnodeActionUpdate
(
SSdb
*
pSdb
,
SDnodeObj
*
pOld
,
SDnodeObj
*
pNew
)
{
mTrace
(
"dnode:%d, perform update action, old_row:%p new_row:%p"
,
pOld
->
id
,
pOld
,
pNew
);
pOld
->
updateTime
=
pNew
->
updateTime
;
return
0
;
}
...
...
@@ -244,22 +244,22 @@ bool mndIsDnodeOnline(SMnode *pMnode, SDnodeObj *pDnode, int64_t curMs) {
return
true
;
}
static
void
mndGetDnodeData
(
SMnode
*
pMnode
,
SDnodeEps
*
pEps
,
int32_t
numOf
Eps
)
{
static
void
mndGetDnodeData
(
SMnode
*
pMnode
,
SDnodeEps
*
pEps
,
int32_t
max
Eps
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
i
=
0
;
int32_t
numOfEps
=
0
;
void
*
pIter
=
NULL
;
while
(
1
)
{
SDnodeObj
*
pDnode
=
NULL
;
pIter
=
sdbFetch
(
pSdb
,
SDB_DNODE
,
pIter
,
(
void
**
)
&
pDnode
);
if
(
pIter
==
NULL
)
break
;
if
(
i
>=
numOf
Eps
)
{
if
(
numOfEps
>=
max
Eps
)
{
sdbCancelFetch
(
pSdb
,
pIter
);
sdbRelease
(
pSdb
,
pDnode
);
break
;
}
SDnodeEp
*
pEp
=
&
pEps
->
eps
[
i
];
SDnodeEp
*
pEp
=
&
pEps
->
eps
[
numOfEps
];
pEp
->
id
=
htonl
(
pDnode
->
id
);
pEp
->
port
=
htons
(
pDnode
->
port
);
memcpy
(
pEp
->
fqdn
,
pDnode
->
fqdn
,
TSDB_FQDN_LEN
);
...
...
@@ -267,11 +267,11 @@ static void mndGetDnodeData(SMnode *pMnode, SDnodeEps *pEps, int32_t numOfEps) {
if
(
mndIsMnode
(
pMnode
,
pDnode
->
id
))
{
pEp
->
isMnode
=
1
;
}
i
++
;
numOfEps
++
;
sdbRelease
(
pSdb
,
pDnode
);
}
pEps
->
num
=
htonl
(
i
);
pEps
->
num
=
htonl
(
numOfEps
);
}
static
int32_t
mndCheckClusterCfgPara
(
SMnode
*
pMnode
,
const
SClusterCfg
*
pCfg
)
{
...
...
@@ -299,8 +299,9 @@ static int32_t mndCheckClusterCfgPara(SMnode *pMnode, const SClusterCfg *pCfg) {
return
0
;
}
static
void
mndParseStatusMsg
(
SStatus
Msg
*
pStatus
)
{
static
void
mndParseStatusMsg
(
SStatus
Req
*
pStatus
)
{
pStatus
->
sver
=
htonl
(
pStatus
->
sver
);
pStatus
->
dver
=
htobe64
(
pStatus
->
dver
);
pStatus
->
dnodeId
=
htonl
(
pStatus
->
dnodeId
);
pStatus
->
clusterId
=
htobe64
(
pStatus
->
clusterId
);
pStatus
->
rebootTime
=
htobe64
(
pStatus
->
rebootTime
);
...
...
@@ -309,11 +310,19 @@ static void mndParseStatusMsg(SStatusMsg *pStatus) {
pStatus
->
numOfSupportVnodes
=
htonl
(
pStatus
->
numOfSupportVnodes
);
pStatus
->
clusterCfg
.
statusInterval
=
htonl
(
pStatus
->
clusterCfg
.
statusInterval
);
pStatus
->
clusterCfg
.
checkTime
=
htobe64
(
pStatus
->
clusterCfg
.
checkTime
);
for
(
int32_t
v
=
0
;
v
<
pStatus
->
vnodeLoads
.
num
;
++
v
)
{
SVnodeLoad
*
pVload
=
&
pStatus
->
vnodeLoads
.
data
[
v
];
pVload
->
vgId
=
htonl
(
pVload
->
vgId
);
pVload
->
totalStorage
=
htobe64
(
pVload
->
totalStorage
);
pVload
->
compStorage
=
htobe64
(
pVload
->
compStorage
);
pVload
->
pointsWritten
=
htobe64
(
pVload
->
pointsWritten
);
pVload
->
tablesNum
=
htobe64
(
pVload
->
tablesNum
);
}
}
static
int32_t
mndProcessStatus
Msg
(
SMnodeMsg
*
pMsg
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
SStatus
Msg
*
pStatus
=
pMsg
->
rpcMsg
.
pCont
;
static
int32_t
mndProcessStatus
Req
(
SMnodeMsg
*
pReq
)
{
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SStatus
Req
*
pStatus
=
pReq
->
rpcMsg
.
pCont
;
SDnodeObj
*
pDnode
=
NULL
;
int32_t
code
=
-
1
;
...
...
@@ -341,9 +350,11 @@ static int32_t mndProcessStatusMsg(SMnodeMsg *pMsg) {
int64_t
curMs
=
taosGetTimestampMs
();
bool
online
=
mndIsDnodeOnline
(
pMnode
,
pDnode
,
curMs
);
bool
needCheckCfg
=
!
(
online
&&
pDnode
->
rebootTime
==
pStatus
->
rebootTime
);
bool
dnodeChanged
=
(
pStatus
->
dver
!=
sdbGetTableVer
(
pMnode
->
pSdb
,
SDB_DNODE
));
bool
reboot
=
(
pDnode
->
rebootTime
!=
pStatus
->
rebootTime
);
bool
needCheck
=
!
online
||
dnodeChanged
||
reboot
;
if
(
needCheck
Cfg
)
{
if
(
needCheck
)
{
if
(
pStatus
->
sver
!=
pMnode
->
cfg
.
sver
)
{
if
(
pDnode
!=
NULL
)
{
pDnode
->
offlineReason
=
DND_REASON_VERSION_NOT_MATCH
;
...
...
@@ -379,7 +390,11 @@ static int32_t mndProcessStatusMsg(SMnodeMsg *pMsg) {
goto
PROCESS_STATUS_MSG_OVER
;
}
mInfo
(
"dnode:%d, from offline to online"
,
pDnode
->
id
);
if
(
!
online
)
{
mInfo
(
"dnode:%d, from offline to online"
,
pDnode
->
id
);
}
else
{
mDebug
(
"dnode:%d, send dnode eps"
,
pDnode
->
id
);
}
pDnode
->
rebootTime
=
pStatus
->
rebootTime
;
pDnode
->
numOfCores
=
pStatus
->
numOfCores
;
...
...
@@ -393,12 +408,13 @@ static int32_t mndProcessStatusMsg(SMnodeMsg *pMsg) {
goto
PROCESS_STATUS_MSG_OVER
;
}
pRsp
->
dver
=
htobe64
(
sdbGetTableVer
(
pMnode
->
pSdb
,
SDB_DNODE
));
pRsp
->
dnodeCfg
.
dnodeId
=
htonl
(
pDnode
->
id
);
pRsp
->
dnodeCfg
.
clusterId
=
htobe64
(
pMnode
->
clusterId
);
mndGetDnodeData
(
pMnode
,
&
pRsp
->
dnodeEps
,
numOfEps
);
p
Msg
->
contLen
=
contLen
;
p
Msg
->
pCont
=
pRsp
;
p
Req
->
contLen
=
contLen
;
p
Req
->
pCont
=
pRsp
;
}
pDnode
->
lastAccessTime
=
curMs
;
...
...
@@ -409,7 +425,7 @@ PROCESS_STATUS_MSG_OVER:
return
code
;
}
static
int32_t
mndCreateDnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
p
Msg
,
SCreateDnodeMsg
*
pCreate
)
{
static
int32_t
mndCreateDnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
p
Req
,
SCreateDnodeReq
*
pCreate
)
{
SDnodeObj
dnodeObj
=
{
0
};
dnodeObj
.
id
=
sdbGetMaxId
(
pMnode
->
pSdb
,
SDB_DNODE
);
dnodeObj
.
createdTime
=
taosGetTimestampMs
();
...
...
@@ -418,7 +434,7 @@ static int32_t mndCreateDnode(SMnode *pMnode, SMnodeMsg *pMsg, SCreateDnodeMsg *
memcpy
(
dnodeObj
.
fqdn
,
pCreate
->
fqdn
,
TSDB_FQDN_LEN
);
snprintf
(
dnodeObj
.
ep
,
TSDB_EP_LEN
,
"%s:%u"
,
dnodeObj
.
fqdn
,
dnodeObj
.
port
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
&
p
Msg
->
rpcMsg
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
&
p
Req
->
rpcMsg
);
if
(
pTrans
==
NULL
)
{
mError
(
"dnode:%s, failed to create since %s"
,
dnodeObj
.
ep
,
terrstr
());
return
-
1
;
...
...
@@ -443,9 +459,9 @@ static int32_t mndCreateDnode(SMnode *pMnode, SMnodeMsg *pMsg, SCreateDnodeMsg *
return
0
;
}
static
int32_t
mndProcessCreateDnode
Msg
(
SMnodeMsg
*
pMsg
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
SCreateDnode
Msg
*
pCreate
=
pMsg
->
rpcMsg
.
pCont
;
static
int32_t
mndProcessCreateDnode
Req
(
SMnodeMsg
*
pReq
)
{
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SCreateDnode
Req
*
pCreate
=
pReq
->
rpcMsg
.
pCont
;
pCreate
->
port
=
htonl
(
pCreate
->
port
);
mDebug
(
"dnode:%s:%d, start to create"
,
pCreate
->
fqdn
,
pCreate
->
port
);
...
...
@@ -465,7 +481,7 @@ static int32_t mndProcessCreateDnodeMsg(SMnodeMsg *pMsg) {
return
-
1
;
}
int32_t
code
=
mndCreateDnode
(
pMnode
,
p
Msg
,
pCreate
);
int32_t
code
=
mndCreateDnode
(
pMnode
,
p
Req
,
pCreate
);
if
(
code
!=
0
)
{
mError
(
"dnode:%s:%d, failed to create since %s"
,
pCreate
->
fqdn
,
pCreate
->
port
,
terrstr
());
...
...
@@ -475,8 +491,8 @@ static int32_t mndProcessCreateDnodeMsg(SMnodeMsg *pMsg) {
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
static
int32_t
mndDropDnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
p
Msg
,
SDnodeObj
*
pDnode
)
{
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
&
p
Msg
->
rpcMsg
);
static
int32_t
mndDropDnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
p
Req
,
SDnodeObj
*
pDnode
)
{
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
&
p
Req
->
rpcMsg
);
if
(
pTrans
==
NULL
)
{
mError
(
"dnode:%d, failed to drop since %s"
,
pDnode
->
id
,
terrstr
());
return
-
1
;
...
...
@@ -501,9 +517,9 @@ static int32_t mndDropDnode(SMnode *pMnode, SMnodeMsg *pMsg, SDnodeObj *pDnode)
return
0
;
}
static
int32_t
mndProcessDropDnode
Msg
(
SMnodeMsg
*
pMsg
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
SDropDnode
Msg
*
pDrop
=
pMsg
->
rpcMsg
.
pCont
;
static
int32_t
mndProcessDropDnode
Req
(
SMnodeMsg
*
pReq
)
{
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SDropDnode
Req
*
pDrop
=
pReq
->
rpcMsg
.
pCont
;
pDrop
->
dnodeId
=
htonl
(
pDrop
->
dnodeId
);
mDebug
(
"dnode:%d, start to drop"
,
pDrop
->
dnodeId
);
...
...
@@ -521,7 +537,7 @@ static int32_t mndProcessDropDnodeMsg(SMnodeMsg *pMsg) {
return
-
1
;
}
int32_t
code
=
mndDropDnode
(
pMnode
,
p
Msg
,
pDnode
);
int32_t
code
=
mndDropDnode
(
pMnode
,
p
Req
,
pDnode
);
if
(
code
!=
0
)
{
mndReleaseDnode
(
pMnode
,
pDnode
);
mError
(
"dnode:%d, failed to drop since %s"
,
pDrop
->
dnodeId
,
terrstr
());
...
...
@@ -532,9 +548,9 @@ static int32_t mndProcessDropDnodeMsg(SMnodeMsg *pMsg) {
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
static
int32_t
mndProcessConfigDnode
Msg
(
SMnodeMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
pMnode
;
S
CfgDnodeMsg
*
pCfg
=
pMsg
->
rpcMsg
.
pCont
;
static
int32_t
mndProcessConfigDnode
Req
(
SMnodeMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
pMnode
;
S
MCfgDnodeReq
*
pCfg
=
pReq
->
rpcMsg
.
pCont
;
pCfg
->
dnodeId
=
htonl
(
pCfg
->
dnodeId
);
SDnodeObj
*
pDnode
=
mndAcquireDnode
(
pMnode
,
pCfg
->
dnodeId
);
...
...
@@ -547,14 +563,14 @@ static int32_t mndProcessConfigDnodeMsg(SMnodeMsg *pMsg) {
SEpSet
epSet
=
mndGetDnodeEpset
(
pDnode
);
mndReleaseDnode
(
pMnode
,
pDnode
);
S
CfgDnodeMsg
*
pCfgDnode
=
rpcMallocCont
(
sizeof
(
SCfgDnodeMsg
));
S
DCfgDnodeReq
*
pCfgDnode
=
rpcMallocCont
(
sizeof
(
SDCfgDnodeReq
));
pCfgDnode
->
dnodeId
=
htonl
(
pCfg
->
dnodeId
);
memcpy
(
pCfgDnode
->
config
,
pCfg
->
config
,
TSDB_DNODE_CONFIG_LEN
);
SRpcMsg
rpcMsg
=
{.
msgType
=
TDMT_DND_CONFIG_DNODE
,
.
pCont
=
pCfgDnode
,
.
contLen
=
sizeof
(
S
CfgDnodeMsg
),
.
ahandle
=
p
Msg
->
rpcMsg
.
ahandle
};
.
contLen
=
sizeof
(
S
DCfgDnodeReq
),
.
ahandle
=
p
Req
->
rpcMsg
.
ahandle
};
mInfo
(
"dnode:%d, app:%p config:%s req send to dnode"
,
pCfg
->
dnodeId
,
rpcMsg
.
ahandle
,
pCfg
->
config
);
mndSendReqToDnode
(
pMnode
,
&
epSet
,
&
rpcMsg
);
...
...
@@ -562,11 +578,11 @@ static int32_t mndProcessConfigDnodeMsg(SMnodeMsg *pMsg) {
return
0
;
}
static
int32_t
mndProcessConfigDnodeRsp
(
SMnodeMsg
*
p
Msg
)
{
mInfo
(
"app:%p config rsp from dnode"
,
p
Msg
->
rpcMsg
.
ahandle
);
static
int32_t
mndProcessConfigDnodeRsp
(
SMnodeMsg
*
p
Rsp
)
{
mInfo
(
"app:%p config rsp from dnode"
,
p
Rsp
->
rpcMsg
.
ahandle
);
}
static
int32_t
mndGetConfigMeta
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
)
{
static
int32_t
mndGetConfigMeta
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
)
{
int32_t
cols
=
0
;
SSchema
*
pSchema
=
pMeta
->
pSchema
;
...
...
@@ -597,8 +613,8 @@ static int32_t mndGetConfigMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg
return
0
;
}
static
int32_t
mndRetrieveConfigs
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
static
int32_t
mndRetrieveConfigs
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
SMnode
*
pMnode
=
p
Req
->
pMnode
;
int32_t
numOfRows
=
0
;
char
*
cfgOpts
[
TSDB_CONFIG_NUMBER
]
=
{
0
};
char
cfgVals
[
TSDB_CONFIG_NUMBER
][
TSDB_CONIIG_VALUE_LEN
+
1
]
=
{
0
};
...
...
@@ -640,8 +656,8 @@ static int32_t mndRetrieveConfigs(SMnodeMsg *pMsg, SShowObj *pShow, char *data,
static
void
mndCancelGetNextConfig
(
SMnode
*
pMnode
,
void
*
pIter
)
{}
static
int32_t
mndGetDnodeMeta
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
static
int32_t
mndGetDnodeMeta
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
)
{
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
cols
=
0
;
...
...
@@ -704,8 +720,8 @@ static int32_t mndGetDnodeMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *
return
0
;
}
static
int32_t
mndRetrieveDnodes
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
static
int32_t
mndRetrieveDnodes
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
numOfRows
=
0
;
int32_t
cols
=
0
;
...
...
source/dnode/mnode/impl/src/mndProfile.c
浏览文件 @
61136183
...
...
@@ -47,14 +47,14 @@ static SConnObj *mndAcquireConn(SMnode *pMnode, int32_t connId);
static
void
mndReleaseConn
(
SMnode
*
pMnode
,
SConnObj
*
pConn
);
static
void
*
mndGetNextConn
(
SMnode
*
pMnode
,
void
*
pIter
,
SConnObj
**
pConn
);
static
void
mndCancelGetNextConn
(
SMnode
*
pMnode
,
void
*
pIter
);
static
int32_t
mndProcessHeartBeat
Msg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessConnect
Msg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessKillQuery
Msg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessKillConn
ectionMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndGetConnsMeta
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
);
static
int32_t
mndRetrieveConns
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
int32_t
mndGetQueryMeta
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
);
static
int32_t
mndRetrieveQueries
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
int32_t
mndProcessHeartBeat
Req
(
SMnodeMsg
*
pReq
);
static
int32_t
mndProcessConnect
Req
(
SMnodeMsg
*
pReq
);
static
int32_t
mndProcessKillQuery
Req
(
SMnodeMsg
*
pReq
);
static
int32_t
mndProcessKillConn
Req
(
SMnodeMsg
*
pReq
);
static
int32_t
mndGetConnsMeta
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
);
static
int32_t
mndRetrieveConns
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
int32_t
mndGetQueryMeta
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
);
static
int32_t
mndRetrieveQueries
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
void
mndCancelGetNextQuery
(
SMnode
*
pMnode
,
void
*
pIter
);
int32_t
mndInitProfile
(
SMnode
*
pMnode
)
{
...
...
@@ -68,10 +68,10 @@ int32_t mndInitProfile(SMnode *pMnode) {
return
-
1
;
}
mndSetMsgHandle
(
pMnode
,
TDMT_MND_HEARTBEAT
,
mndProcessHeartBeat
Msg
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_CONNECT
,
mndProcessConnect
Msg
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_KILL_QUERY
,
mndProcessKillQuery
Msg
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_KILL_CONN
,
mndProcessKillConn
ectionMsg
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_HEARTBEAT
,
mndProcessHeartBeat
Req
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_CONNECT
,
mndProcessConnect
Req
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_KILL_QUERY
,
mndProcessKillQuery
Req
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_KILL_CONN
,
mndProcessKillConn
Req
);
mndAddShowMetaHandle
(
pMnode
,
TSDB_MGMT_TABLE_CONNS
,
mndGetConnsMeta
);
mndAddShowRetrieveHandle
(
pMnode
,
TSDB_MGMT_TABLE_CONNS
,
mndRetrieveConns
);
...
...
@@ -178,35 +178,35 @@ static void mndCancelGetNextConn(SMnode *pMnode, void *pIter) {
taosHashCancelIterate
(
pMgmt
->
cache
->
pHashTable
,
pIter
);
}
static
int32_t
mndProcessConnect
Msg
(
SMnodeMsg
*
pMsg
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
SConnect
Msg
*
pReq
=
pMsg
->
rpcMsg
.
pCont
;
p
Req
->
pid
=
htonl
(
p
Req
->
pid
);
p
Req
->
startTime
=
htobe64
(
p
Req
->
startTime
);
static
int32_t
mndProcessConnect
Req
(
SMnodeMsg
*
pReq
)
{
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SConnect
Req
*
pConnReq
=
pReq
->
rpcMsg
.
pCont
;
p
ConnReq
->
pid
=
htonl
(
pConn
Req
->
pid
);
p
ConnReq
->
startTime
=
htobe64
(
pConn
Req
->
startTime
);
SRpcConnInfo
info
=
{
0
};
if
(
rpcGetConnInfo
(
p
Msg
->
rpcMsg
.
handle
,
&
info
)
!=
0
)
{
mError
(
"user:%s, failed to login while get connection info since %s"
,
p
Msg
->
user
,
terrstr
());
if
(
rpcGetConnInfo
(
p
Req
->
rpcMsg
.
handle
,
&
info
)
!=
0
)
{
mError
(
"user:%s, failed to login while get connection info since %s"
,
p
Req
->
user
,
terrstr
());
return
-
1
;
}
char
ip
[
30
];
taosIp2String
(
info
.
clientIp
,
ip
);
if
(
pReq
->
db
[
0
])
{
snprintf
(
p
Msg
->
db
,
TSDB_DB_FNAME_LEN
,
"%d%s%s"
,
pMsg
->
acctId
,
TS_PATH_DELIMITER
,
p
Req
->
db
);
SDbObj
*
pDb
=
mndAcquireDb
(
pMnode
,
p
Msg
->
db
);
if
(
p
Conn
Req
->
db
[
0
])
{
snprintf
(
p
Req
->
db
,
TSDB_DB_FNAME_LEN
,
"%d%s%s"
,
pReq
->
acctId
,
TS_PATH_DELIMITER
,
pConn
Req
->
db
);
SDbObj
*
pDb
=
mndAcquireDb
(
pMnode
,
p
Req
->
db
);
if
(
pDb
==
NULL
)
{
terrno
=
TSDB_CODE_MND_INVALID_DB
;
mError
(
"user:%s, failed to login from %s while use db:%s since %s"
,
p
Msg
->
user
,
ip
,
p
Req
->
db
,
terrstr
());
mError
(
"user:%s, failed to login from %s while use db:%s since %s"
,
p
Req
->
user
,
ip
,
pConn
Req
->
db
,
terrstr
());
return
-
1
;
}
mndReleaseDb
(
pMnode
,
pDb
);
}
SConnObj
*
pConn
=
mndCreateConn
(
pMnode
,
&
info
,
p
Req
->
pid
,
pReq
->
app
,
p
Req
->
startTime
);
SConnObj
*
pConn
=
mndCreateConn
(
pMnode
,
&
info
,
p
ConnReq
->
pid
,
pConnReq
->
app
,
pConn
Req
->
startTime
);
if
(
pConn
==
NULL
)
{
mError
(
"user:%s, failed to login from %s while create connection since %s"
,
p
Msg
->
user
,
ip
,
terrstr
());
mError
(
"user:%s, failed to login from %s while create connection since %s"
,
p
Req
->
user
,
ip
,
terrstr
());
return
-
1
;
}
...
...
@@ -214,11 +214,11 @@ static int32_t mndProcessConnectMsg(SMnodeMsg *pMsg) {
if
(
pRsp
==
NULL
)
{
mndReleaseConn
(
pMnode
,
pConn
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
mError
(
"user:%s, failed to login from %s while create rsp since %s"
,
p
Msg
->
user
,
ip
,
terrstr
());
mError
(
"user:%s, failed to login from %s while create rsp since %s"
,
p
Req
->
user
,
ip
,
terrstr
());
return
-
1
;
}
SUserObj
*
pUser
=
mndAcquireUser
(
pMnode
,
p
Msg
->
user
);
SUserObj
*
pUser
=
mndAcquireUser
(
pMnode
,
p
Req
->
user
);
if
(
pUser
!=
NULL
)
{
pRsp
->
acctId
=
htonl
(
pUser
->
acctId
);
pRsp
->
superUser
=
pUser
->
superUser
;
...
...
@@ -230,16 +230,16 @@ static int32_t mndProcessConnectMsg(SMnodeMsg *pMsg) {
mndGetMnodeEpSet
(
pMnode
,
&
pRsp
->
epSet
);
mndReleaseConn
(
pMnode
,
pConn
);
p
Msg
->
contLen
=
sizeof
(
SConnectRsp
);
p
Msg
->
pCont
=
pRsp
;
p
Req
->
contLen
=
sizeof
(
SConnectRsp
);
p
Req
->
pCont
=
pRsp
;
mDebug
(
"user:%s, login from %s, conn:%d, app:%s"
,
info
.
user
,
ip
,
pConn
->
id
,
pReq
->
app
);
mDebug
(
"user:%s, login from %s, conn:%d, app:%s"
,
info
.
user
,
ip
,
pConn
->
id
,
p
Conn
Req
->
app
);
return
0
;
}
static
int32_t
mndSaveQueryStreamList
(
SConnObj
*
pConn
,
SHeartBeat
Msg
*
pMsg
)
{
static
int32_t
mndSaveQueryStreamList
(
SConnObj
*
pConn
,
SHeartBeat
Req
*
pReq
)
{
pConn
->
numOfQueries
=
0
;
int32_t
numOfQueries
=
htonl
(
p
Msg
->
numOfQueries
);
int32_t
numOfQueries
=
htonl
(
p
Req
->
numOfQueries
);
if
(
numOfQueries
>
0
)
{
if
(
pConn
->
pQueries
==
NULL
)
{
...
...
@@ -250,38 +250,38 @@ static int32_t mndSaveQueryStreamList(SConnObj *pConn, SHeartBeatMsg *pMsg) {
int32_t
saveSize
=
pConn
->
numOfQueries
*
sizeof
(
SQueryDesc
);
if
(
saveSize
>
0
&&
pConn
->
pQueries
!=
NULL
)
{
memcpy
(
pConn
->
pQueries
,
p
Msg
->
pData
,
saveSize
);
memcpy
(
pConn
->
pQueries
,
p
Req
->
pData
,
saveSize
);
}
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mndProcessHeartBeat
Msg
(
SMnodeMsg
*
pMsg
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
static
int32_t
mndProcessHeartBeat
Req
(
SMnodeMsg
*
pReq
)
{
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
SHeartBeat
Msg
*
pReq
=
pMsg
->
rpcMsg
.
pCont
;
p
Req
->
connId
=
htonl
(
pReq
->
connId
);
p
Req
->
pid
=
htonl
(
pReq
->
pid
);
SHeartBeat
Req
*
pHeartbeat
=
pReq
->
rpcMsg
.
pCont
;
p
Heartbeat
->
connId
=
htonl
(
pHeartbeat
->
connId
);
p
Heartbeat
->
pid
=
htonl
(
pHeartbeat
->
pid
);
SRpcConnInfo
info
=
{
0
};
if
(
rpcGetConnInfo
(
p
Msg
->
rpcMsg
.
handle
,
&
info
)
!=
0
)
{
mError
(
"user:%s, connId:%d failed to process hb since %s"
,
p
Msg
->
user
,
pReq
->
connId
,
terrstr
());
if
(
rpcGetConnInfo
(
p
Req
->
rpcMsg
.
handle
,
&
info
)
!=
0
)
{
mError
(
"user:%s, connId:%d failed to process hb since %s"
,
p
Req
->
user
,
pHeartbeat
->
connId
,
terrstr
());
return
-
1
;
}
SConnObj
*
pConn
=
mndAcquireConn
(
pMnode
,
p
Req
->
connId
);
SConnObj
*
pConn
=
mndAcquireConn
(
pMnode
,
p
Heartbeat
->
connId
);
if
(
pConn
==
NULL
)
{
pConn
=
mndCreateConn
(
pMnode
,
&
info
,
p
Req
->
pid
,
pReq
->
app
,
0
);
pConn
=
mndCreateConn
(
pMnode
,
&
info
,
p
Heartbeat
->
pid
,
pHeartbeat
->
app
,
0
);
if
(
pConn
==
NULL
)
{
mError
(
"user:%s, conn:%d is freed and failed to create new
conn since %s"
,
pMsg
->
user
,
pReq
->
connId
,
terrstr
());
mError
(
"user:%s, conn:%d is freed and failed to create new
since %s"
,
pReq
->
user
,
pHeartbeat
->
connId
,
terrstr
());
return
-
1
;
}
else
{
mDebug
(
"user:%s, conn:%d is freed and create a new conn:%d"
,
p
Msg
->
user
,
pReq
->
connId
,
pConn
->
id
);
mDebug
(
"user:%s, conn:%d is freed and create a new conn:%d"
,
p
Req
->
user
,
pHeartbeat
->
connId
,
pConn
->
id
);
}
}
else
if
(
pConn
->
killed
)
{
mError
(
"user:%s, conn:%d is already killed"
,
p
Msg
->
user
,
pConn
->
id
);
mError
(
"user:%s, conn:%d is already killed"
,
p
Req
->
user
,
pConn
->
id
);
terrno
=
TSDB_CODE_MND_INVALID_CONNECTION
;
return
-
1
;
}
else
{
...
...
@@ -304,11 +304,11 @@ static int32_t mndProcessHeartBeatMsg(SMnodeMsg *pMsg) {
if
(
pRsp
==
NULL
)
{
mndReleaseConn
(
pMnode
,
pConn
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
mError
(
"user:%s, conn:%d failed to process hb while
create rsp since %s"
,
pMsg
->
user
,
pReq
->
connId
,
terrstr
());
mError
(
"user:%s, conn:%d failed to process hb while
since %s"
,
pReq
->
user
,
pHeartbeat
->
connId
,
terrstr
());
return
-
1
;
}
mndSaveQueryStreamList
(
pConn
,
p
Req
);
mndSaveQueryStreamList
(
pConn
,
p
Heartbeat
);
if
(
pConn
->
killed
!=
0
)
{
pRsp
->
killConnection
=
1
;
}
...
...
@@ -324,16 +324,16 @@ static int32_t mndProcessHeartBeatMsg(SMnodeMsg *pMsg) {
mndGetMnodeEpSet
(
pMnode
,
&
pRsp
->
epSet
);
mndReleaseConn
(
pMnode
,
pConn
);
p
Msg
->
contLen
=
sizeof
(
SConnectRsp
);
p
Msg
->
pCont
=
pRsp
;
p
Req
->
contLen
=
sizeof
(
SConnectRsp
);
p
Req
->
pCont
=
pRsp
;
return
0
;
}
static
int32_t
mndProcessKillQuery
Msg
(
SMnodeMsg
*
pMsg
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
static
int32_t
mndProcessKillQuery
Req
(
SMnodeMsg
*
pReq
)
{
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
SUserObj
*
pUser
=
mndAcquireUser
(
pMnode
,
p
Msg
->
user
);
SUserObj
*
pUser
=
mndAcquireUser
(
pMnode
,
p
Req
->
user
);
if
(
pUser
==
NULL
)
return
0
;
if
(
!
pUser
->
superUser
)
{
mndReleaseUser
(
pMnode
,
pUser
);
...
...
@@ -342,7 +342,7 @@ static int32_t mndProcessKillQueryMsg(SMnodeMsg *pMsg) {
}
mndReleaseUser
(
pMnode
,
pUser
);
SKillQuery
Msg
*
pKill
=
pMsg
->
rpcMsg
.
pCont
;
SKillQuery
Req
*
pKill
=
pReq
->
rpcMsg
.
pCont
;
int32_t
connId
=
htonl
(
pKill
->
connId
);
int32_t
queryId
=
htonl
(
pKill
->
queryId
);
mInfo
(
"kill query msg is received, queryId:%d"
,
pKill
->
queryId
);
...
...
@@ -353,18 +353,18 @@ static int32_t mndProcessKillQueryMsg(SMnodeMsg *pMsg) {
terrno
=
TSDB_CODE_MND_INVALID_CONN_ID
;
return
-
1
;
}
else
{
mInfo
(
"connId:%d, queryId:%d is killed by user:%s"
,
connId
,
queryId
,
p
Msg
->
user
);
mInfo
(
"connId:%d, queryId:%d is killed by user:%s"
,
connId
,
queryId
,
p
Req
->
user
);
pConn
->
queryId
=
queryId
;
taosCacheRelease
(
pMgmt
->
cache
,
(
void
**
)
&
pConn
,
false
);
return
0
;
}
}
static
int32_t
mndProcessKillConn
ectionMsg
(
SMnodeMsg
*
pMsg
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
static
int32_t
mndProcessKillConn
Req
(
SMnodeMsg
*
pReq
)
{
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
SUserObj
*
pUser
=
mndAcquireUser
(
pMnode
,
p
Msg
->
user
);
SUserObj
*
pUser
=
mndAcquireUser
(
pMnode
,
p
Req
->
user
);
if
(
pUser
==
NULL
)
return
0
;
if
(
!
pUser
->
superUser
)
{
mndReleaseUser
(
pMnode
,
pUser
);
...
...
@@ -373,7 +373,7 @@ static int32_t mndProcessKillConnectionMsg(SMnodeMsg *pMsg) {
}
mndReleaseUser
(
pMnode
,
pUser
);
SKillConn
Msg
*
pKill
=
pMsg
->
rpcMsg
.
pCont
;
SKillConn
Req
*
pKill
=
pReq
->
rpcMsg
.
pCont
;
int32_t
connId
=
htonl
(
pKill
->
connId
);
SConnObj
*
pConn
=
taosCacheAcquireByKey
(
pMgmt
->
cache
,
&
connId
,
sizeof
(
int32_t
));
...
...
@@ -382,18 +382,18 @@ static int32_t mndProcessKillConnectionMsg(SMnodeMsg *pMsg) {
terrno
=
TSDB_CODE_MND_INVALID_CONN_ID
;
return
-
1
;
}
else
{
mInfo
(
"connId:%d, is killed by user:%s"
,
connId
,
p
Msg
->
user
);
mInfo
(
"connId:%d, is killed by user:%s"
,
connId
,
p
Req
->
user
);
pConn
->
killed
=
1
;
taosCacheRelease
(
pMgmt
->
cache
,
(
void
**
)
&
pConn
,
false
);
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
mndGetConnsMeta
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
static
int32_t
mndGetConnsMeta
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
)
{
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
SUserObj
*
pUser
=
mndAcquireUser
(
pMnode
,
p
Msg
->
user
);
SUserObj
*
pUser
=
mndAcquireUser
(
pMnode
,
p
Req
->
user
);
if
(
pUser
==
NULL
)
return
0
;
if
(
!
pUser
->
superUser
)
{
mndReleaseUser
(
pMnode
,
pUser
);
...
...
@@ -464,8 +464,8 @@ static int32_t mndGetConnsMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *
return
0
;
}
static
int32_t
mndRetrieveConns
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
static
int32_t
mndRetrieveConns
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
SMnode
*
pMnode
=
p
Req
->
pMnode
;
int32_t
numOfRows
=
0
;
SConnObj
*
pConn
=
NULL
;
int32_t
cols
=
0
;
...
...
@@ -518,11 +518,11 @@ static int32_t mndRetrieveConns(SMnodeMsg *pMsg, SShowObj *pShow, char *data, in
return
numOfRows
;
}
static
int32_t
mndGetQueryMeta
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
static
int32_t
mndGetQueryMeta
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
)
{
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
SUserObj
*
pUser
=
mndAcquireUser
(
pMnode
,
p
Msg
->
user
);
SUserObj
*
pUser
=
mndAcquireUser
(
pMnode
,
p
Req
->
user
);
if
(
pUser
==
NULL
)
return
0
;
if
(
!
pUser
->
superUser
)
{
mndReleaseUser
(
pMnode
,
pUser
);
...
...
@@ -633,8 +633,8 @@ static int32_t mndGetQueryMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *
return
0
;
}
static
int32_t
mndRetrieveQueries
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
static
int32_t
mndRetrieveQueries
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
SMnode
*
pMnode
=
p
Req
->
pMnode
;
int32_t
numOfRows
=
0
;
SConnObj
*
pConn
=
NULL
;
int32_t
cols
=
0
;
...
...
source/dnode/mnode/impl/src/mndShow.c
浏览文件 @
61136183
...
...
@@ -124,20 +124,20 @@ static int32_t mndProcessShowReq(SMnodeMsg *pReq) {
if
(
type
<=
TSDB_MGMT_TABLE_START
||
type
>=
TSDB_MGMT_TABLE_MAX
)
{
terrno
=
TSDB_CODE_MND_INVALID_MSG_TYPE
;
mError
(
"failed to process show
msg
since %s"
,
terrstr
());
mError
(
"failed to process show
-meta req
since %s"
,
terrstr
());
return
-
1
;
}
ShowMetaFp
metaFp
=
pMgmt
->
metaFps
[
type
];
if
(
metaFp
==
NULL
)
{
terrno
=
TSDB_CODE_MND_INVALID_MSG_TYPE
;
mError
(
"failed to process show-meta
msg
:%s since %s"
,
mndShowStr
(
type
),
terrstr
());
mError
(
"failed to process show-meta
req
:%s since %s"
,
mndShowStr
(
type
),
terrstr
());
return
-
1
;
}
SShowObj
*
pShow
=
mndCreateShowObj
(
pMnode
,
pShowReq
);
if
(
pShow
==
NULL
)
{
mError
(
"failed to process show-meta
msg
:%s since %s"
,
mndShowStr
(
type
),
terrstr
());
mError
(
"failed to process show-meta
req
:%s since %s"
,
mndShowStr
(
type
),
terrstr
());
return
-
1
;
}
...
...
@@ -146,7 +146,7 @@ static int32_t mndProcessShowReq(SMnodeMsg *pReq) {
if
(
pRsp
==
NULL
)
{
mndReleaseShowObj
(
pShow
,
true
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
mError
(
"show:0x%"
PRIx64
", failed to process show-meta
msg
:%s since malloc rsp error"
,
pShow
->
id
,
mError
(
"show:0x%"
PRIx64
", failed to process show-meta
req
:%s since malloc rsp error"
,
pShow
->
id
,
mndShowStr
(
type
));
return
-
1
;
}
...
...
@@ -181,7 +181,7 @@ static int32_t mndProcessRetrieveReq(SMnodeMsg *pReq) {
SShowObj
*
pShow
=
mndAcquireShowObj
(
pMnode
,
showId
);
if
(
pShow
==
NULL
)
{
terrno
=
TSDB_CODE_MND_INVALID_SHOWOBJ
;
mError
(
"failed to process show-retrieve
msg
:%p since %s"
,
pShow
,
terrstr
());
mError
(
"failed to process show-retrieve
req
:%p since %s"
,
pShow
,
terrstr
());
return
-
1
;
}
...
...
source/dnode/mnode/impl/test/CMakeLists.txt
浏览文件 @
61136183
...
...
@@ -7,3 +7,6 @@ add_subdirectory(qnode)
add_subdirectory
(
snode
)
add_subdirectory
(
bnode
)
add_subdirectory
(
show
)
add_subdirectory
(
profile
)
add_subdirectory
(
dnode
)
add_subdirectory
(
mnode
)
source/dnode/mnode/impl/test/bnode/bnode.cpp
浏览文件 @
61136183
...
...
@@ -96,9 +96,9 @@ TEST_F(MndTestBnode, 02_Create_Bnode) {
TEST_F
(
MndTestBnode
,
03
_Drop_Bnode
)
{
{
int32_t
contLen
=
sizeof
(
SCreateDnode
Msg
);
int32_t
contLen
=
sizeof
(
SCreateDnode
Req
);
SCreateDnode
Msg
*
pReq
=
(
SCreateDnodeMsg
*
)
rpcMallocCont
(
contLen
);
SCreateDnode
Req
*
pReq
=
(
SCreateDnodeReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
pReq
->
port
=
htonl
(
9019
);
...
...
source/dnode/m
gmt
/impl/test/dnode/CMakeLists.txt
→
source/dnode/m
node
/impl/test/dnode/CMakeLists.txt
浏览文件 @
61136183
aux_source_directory
(
. DTEST_SRC
)
add_executable
(
d
node_test_dnode
${
DTEST_SRC
}
)
add_executable
(
m
node_test_dnode
${
DTEST_SRC
}
)
target_link_libraries
(
d
node_test_dnode
m
node_test_dnode
PUBLIC sut
)
add_test
(
NAME
d
node_test_dnode
COMMAND
d
node_test_dnode
NAME
m
node_test_dnode
COMMAND
m
node_test_dnode
)
source/dnode/m
gmt
/impl/test/dnode/dnode.cpp
→
source/dnode/m
node
/impl/test/dnode/dnode.cpp
浏览文件 @
61136183
/**
* @file dnode.cpp
* @author slguan (slguan@taosdata.com)
* @brief
DNODE module dnode-msg
tests
* @version
0.1
* @date 202
1-12-15
* @brief
MNODE module dnode
tests
* @version
1.0
* @date 202
2-01-06
*
* @copyright Copyright (c) 202
1
* @copyright Copyright (c) 202
2
*
*/
#include "sut.h"
class
D
ndTestDnode
:
public
::
testing
::
Test
{
class
M
ndTestDnode
:
public
::
testing
::
Test
{
public:
void
SetUp
()
override
{}
void
TearDown
()
override
{}
public:
static
void
SetUpTestSuite
()
{
test
.
Init
(
"/tmp/dnode_test_dnode1"
,
90
41
);
test
.
Init
(
"/tmp/dnode_test_dnode1"
,
90
23
);
const
char
*
fqdn
=
"localhost"
;
const
char
*
firstEp
=
"localhost:90
41
"
;
const
char
*
firstEp
=
"localhost:90
23
"
;
server2
.
Start
(
"/tmp/dnode_test_dnode2"
,
fqdn
,
90
42
,
firstEp
);
server3
.
Start
(
"/tmp/dnode_test_dnode3"
,
fqdn
,
90
43
,
firstEp
);
server4
.
Start
(
"/tmp/dnode_test_dnode4"
,
fqdn
,
90
44
,
firstEp
);
server5
.
Start
(
"/tmp/dnode_test_dnode5"
,
fqdn
,
90
45
,
firstEp
);
server2
.
Start
(
"/tmp/dnode_test_dnode2"
,
fqdn
,
90
24
,
firstEp
);
server3
.
Start
(
"/tmp/dnode_test_dnode3"
,
fqdn
,
90
25
,
firstEp
);
server4
.
Start
(
"/tmp/dnode_test_dnode4"
,
fqdn
,
90
26
,
firstEp
);
server5
.
Start
(
"/tmp/dnode_test_dnode5"
,
fqdn
,
90
27
,
firstEp
);
taosMsleep
(
300
);
}
...
...
@@ -44,13 +44,13 @@ class DndTestDnode : public ::testing::Test {
static
TestServer
server5
;
};
Testbase
D
ndTestDnode
::
test
;
TestServer
D
ndTestDnode
::
server2
;
TestServer
D
ndTestDnode
::
server3
;
TestServer
D
ndTestDnode
::
server4
;
TestServer
D
ndTestDnode
::
server5
;
Testbase
M
ndTestDnode
::
test
;
TestServer
M
ndTestDnode
::
server2
;
TestServer
M
ndTestDnode
::
server3
;
TestServer
M
ndTestDnode
::
server4
;
TestServer
M
ndTestDnode
::
server5
;
TEST_F
(
D
ndTestDnode
,
01
_ShowDnode
)
{
TEST_F
(
M
ndTestDnode
,
01
_ShowDnode
)
{
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_DNODE
,
""
);
CHECK_META
(
"show dnodes"
,
7
);
...
...
@@ -66,7 +66,7 @@ TEST_F(DndTestDnode, 01_ShowDnode) {
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckInt16
(
1
);
CheckBinary
(
"localhost:90
41
"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
23
"
,
TSDB_EP_LEN
);
CheckInt16
(
0
);
CheckInt16
(
16
);
CheckBinary
(
"ready"
,
10
);
...
...
@@ -74,10 +74,10 @@ TEST_F(DndTestDnode, 01_ShowDnode) {
CheckBinary
(
""
,
24
);
}
TEST_F
(
D
ndTestDnode
,
02
_ConfigDnode
)
{
int32_t
contLen
=
sizeof
(
S
CfgDnodeMsg
);
TEST_F
(
M
ndTestDnode
,
02
_ConfigDnode
)
{
int32_t
contLen
=
sizeof
(
S
MCfgDnodeReq
);
S
CfgDnodeMsg
*
pReq
=
(
SCfgDnodeMsg
*
)
rpcMallocCont
(
contLen
);
S
MCfgDnodeReq
*
pReq
=
(
SMCfgDnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
strcpy
(
pReq
->
config
,
"ddebugflag 131"
);
...
...
@@ -86,19 +86,67 @@ TEST_F(DndTestDnode, 02_ConfigDnode) {
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
TEST_F
(
DndTestDnode
,
03
_Create_Drop_Restart
_Dnode
)
{
TEST_F
(
MndTestDnode
,
03
_Create
_Dnode
)
{
{
int32_t
contLen
=
sizeof
(
SCreateDnode
Msg
);
int32_t
contLen
=
sizeof
(
SCreateDnode
Req
);
SCreateDnodeMsg
*
pReq
=
(
SCreateDnodeMsg
*
)
rpcMallocCont
(
contLen
);
SCreateDnodeReq
*
pReq
=
(
SCreateDnodeReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
fqdn
,
""
);
pReq
->
port
=
htonl
(
9024
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_DNODE_EP
);
}
{
int32_t
contLen
=
sizeof
(
SCreateDnodeReq
);
SCreateDnodeReq
*
pReq
=
(
SCreateDnodeReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
pReq
->
port
=
htonl
(
-
1
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_DNODE_EP
);
}
{
int32_t
contLen
=
sizeof
(
SCreateDnodeReq
);
SCreateDnodeReq
*
pReq
=
(
SCreateDnodeReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
pReq
->
port
=
htonl
(
123456
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_DNODE_EP
);
}
{
int32_t
contLen
=
sizeof
(
SCreateDnodeReq
);
SCreateDnodeReq
*
pReq
=
(
SCreateDnodeReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
pReq
->
port
=
htonl
(
90
42
);
pReq
->
port
=
htonl
(
90
24
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
{
int32_t
contLen
=
sizeof
(
SCreateDnodeReq
);
SCreateDnodeReq
*
pReq
=
(
SCreateDnodeReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
pReq
->
port
=
htonl
(
9024
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_DNODE_ALREADY_EXIST
);
}
taosMsleep
(
1300
);
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_DNODE
,
""
);
...
...
@@ -108,8 +156,8 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
CheckInt16
(
1
);
CheckInt16
(
2
);
CheckBinary
(
"localhost:90
41
"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
42
"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
23
"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
24
"
,
TSDB_EP_LEN
);
CheckInt16
(
0
);
CheckInt16
(
0
);
CheckInt16
(
16
);
...
...
@@ -120,11 +168,35 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
CheckTimestamp
();
CheckBinary
(
""
,
24
);
CheckBinary
(
""
,
24
);
}
TEST_F
(
MndTestDnode
,
04
_Drop_Dnode
)
{
{
int32_t
contLen
=
sizeof
(
SDropDnodeReq
);
SDropDnodeReq
*
pReq
=
(
SDropDnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
-
3
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_DNODE_ID
);
}
{
int32_t
contLen
=
sizeof
(
SDropDnodeReq
);
SDropDnodeReq
*
pReq
=
(
SDropDnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
5
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_DNODE_NOT_EXIST
);
}
{
int32_t
contLen
=
sizeof
(
SDropDnode
Msg
);
int32_t
contLen
=
sizeof
(
SDropDnode
Req
);
SDropDnode
Msg
*
pReq
=
(
SDropDnodeMsg
*
)
rpcMallocCont
(
contLen
);
SDropDnode
Req
*
pReq
=
(
SDropDnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_DNODE
,
pReq
,
contLen
);
...
...
@@ -132,25 +204,42 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
{
int32_t
contLen
=
sizeof
(
SDropDnodeReq
);
SDropDnodeReq
*
pReq
=
(
SDropDnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_DNODE_NOT_EXIST
);
}
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_DNODE
,
""
);
CHECK_META
(
"show dnodes"
,
7
);
test
.
SendShowRetrieveReq
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckInt16
(
1
);
CheckBinary
(
"localhost:90
41
"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
23
"
,
TSDB_EP_LEN
);
CheckInt16
(
0
);
CheckInt16
(
16
);
CheckBinary
(
"ready"
,
10
);
CheckTimestamp
();
CheckBinary
(
""
,
24
);
taosMsleep
(
2000
);
server2
.
Stop
();
server2
.
DoStart
();
}
TEST_F
(
MndTestDnode
,
05
_Create_Drop_Restart_Dnode
)
{
{
int32_t
contLen
=
sizeof
(
SCreateDnode
Msg
);
int32_t
contLen
=
sizeof
(
SCreateDnode
Req
);
SCreateDnode
Msg
*
pReq
=
(
SCreateDnodeMsg
*
)
rpcMallocCont
(
contLen
);
SCreateDnode
Req
*
pReq
=
(
SCreateDnodeReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
pReq
->
port
=
htonl
(
90
43
);
pReq
->
port
=
htonl
(
90
25
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
...
@@ -158,11 +247,11 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
}
{
int32_t
contLen
=
sizeof
(
SCreateDnode
Msg
);
int32_t
contLen
=
sizeof
(
SCreateDnode
Req
);
SCreateDnode
Msg
*
pReq
=
(
SCreateDnodeMsg
*
)
rpcMallocCont
(
contLen
);
SCreateDnode
Req
*
pReq
=
(
SCreateDnodeReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
pReq
->
port
=
htonl
(
90
44
);
pReq
->
port
=
htonl
(
90
26
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
...
@@ -170,11 +259,11 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
}
{
int32_t
contLen
=
sizeof
(
SCreateDnode
Msg
);
int32_t
contLen
=
sizeof
(
SCreateDnode
Req
);
SCreateDnode
Msg
*
pReq
=
(
SCreateDnodeMsg
*
)
rpcMallocCont
(
contLen
);
SCreateDnode
Req
*
pReq
=
(
SCreateDnodeReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
pReq
->
port
=
htonl
(
90
45
);
pReq
->
port
=
htonl
(
90
27
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
...
@@ -191,10 +280,10 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
CheckInt16
(
3
);
CheckInt16
(
4
);
CheckInt16
(
5
);
CheckBinary
(
"localhost:90
41
"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
43
"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
44
"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
45
"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
23
"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
25
"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
26
"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
27
"
,
TSDB_EP_LEN
);
CheckInt16
(
0
);
CheckInt16
(
0
);
CheckInt16
(
0
);
...
...
@@ -234,10 +323,10 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
CheckInt16
(
3
);
CheckInt16
(
4
);
CheckInt16
(
5
);
CheckBinary
(
"localhost:90
41
"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
43
"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
44
"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
45
"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
23
"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
25
"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
26
"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
27
"
,
TSDB_EP_LEN
);
CheckInt16
(
0
);
CheckInt16
(
0
);
CheckInt16
(
0
);
...
...
source/dnode/mnode/impl/test/mnode/CMakeLists.txt
0 → 100644
浏览文件 @
61136183
aux_source_directory
(
. MTEST_SRC
)
add_executable
(
mnode_test_mnode
${
MTEST_SRC
}
)
target_link_libraries
(
mnode_test_mnode
PUBLIC sut
)
add_test
(
NAME mnode_test_mnode
COMMAND mnode_test_mnode
)
source/dnode/m
gmt
/impl/test/mnode/mnode.cpp
→
source/dnode/m
node
/impl/test/mnode/mnode.cpp
浏览文件 @
61136183
/**
* @file
d
node.cpp
* @file
m
node.cpp
* @author slguan (slguan@taosdata.com)
* @brief
DNODE module dnode-msg
tests
* @version
0.1
* @date 202
1-12-15
* @brief
MNODE module mnode
tests
* @version
1.0
* @date 202
2-01-07
*
* @copyright Copyright (c) 202
1
* @copyright Copyright (c) 202
2
*
*/
#include "sut.h"
class
D
ndTestMnode
:
public
::
testing
::
Test
{
class
M
ndTestMnode
:
public
::
testing
::
Test
{
public:
void
SetUp
()
override
{}
void
TearDown
()
override
{}
public:
static
void
SetUpTestSuite
()
{
test
.
Init
(
"/tmp/
dnode_test_mnode1"
,
906
1
);
test
.
Init
(
"/tmp/
mnode_test_mnode1"
,
903
1
);
const
char
*
fqdn
=
"localhost"
;
const
char
*
firstEp
=
"localhost:90
6
1"
;
const
char
*
firstEp
=
"localhost:90
3
1"
;
server2
.
Start
(
"/tmp/
dnode_test_mnode2"
,
fqdn
,
906
2
,
firstEp
);
server3
.
Start
(
"/tmp/
dnode_test_mnode3"
,
fqdn
,
906
3
,
firstEp
);
server4
.
Start
(
"/tmp/
dnode_test_mnode4"
,
fqdn
,
906
4
,
firstEp
);
server5
.
Start
(
"/tmp/
dnode_test_mnode5"
,
fqdn
,
906
5
,
firstEp
);
server2
.
Start
(
"/tmp/
mnode_test_mnode2"
,
fqdn
,
903
2
,
firstEp
);
server3
.
Start
(
"/tmp/
mnode_test_mnode3"
,
fqdn
,
903
3
,
firstEp
);
server4
.
Start
(
"/tmp/
mnode_test_mnode4"
,
fqdn
,
903
4
,
firstEp
);
server5
.
Start
(
"/tmp/
mnode_test_mnode5"
,
fqdn
,
903
5
,
firstEp
);
taosMsleep
(
300
);
}
...
...
@@ -44,13 +44,13 @@ class DndTestMnode : public ::testing::Test {
static
TestServer
server5
;
};
Testbase
D
ndTestMnode
::
test
;
TestServer
D
ndTestMnode
::
server2
;
TestServer
D
ndTestMnode
::
server3
;
TestServer
D
ndTestMnode
::
server4
;
TestServer
D
ndTestMnode
::
server5
;
Testbase
M
ndTestMnode
::
test
;
TestServer
M
ndTestMnode
::
server2
;
TestServer
M
ndTestMnode
::
server3
;
TestServer
M
ndTestMnode
::
server4
;
TestServer
M
ndTestMnode
::
server5
;
TEST_F
(
D
ndTestMnode
,
01
_ShowDnode
)
{
TEST_F
(
M
ndTestMnode
,
01
_ShowDnode
)
{
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_MNODE
,
""
);
CHECK_META
(
"show mnodes"
,
5
);
...
...
@@ -64,13 +64,13 @@ TEST_F(DndTestMnode, 01_ShowDnode) {
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckInt16
(
1
);
CheckBinary
(
"localhost:90
6
1"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
3
1"
,
TSDB_EP_LEN
);
CheckBinary
(
"master"
,
12
);
CheckInt64
(
0
);
CheckTimestamp
();
}
TEST_F
(
D
ndTestMnode
,
02
_Create_Mnode_Invalid_Id
)
{
TEST_F
(
M
ndTestMnode
,
02
_Create_Mnode_Invalid_Id
)
{
{
int32_t
contLen
=
sizeof
(
SMCreateMnodeMsg
);
...
...
@@ -83,7 +83,7 @@ TEST_F(DndTestMnode, 02_Create_Mnode_Invalid_Id) {
}
}
TEST_F
(
D
ndTestMnode
,
03
_Create_Mnode_Invalid_Id
)
{
TEST_F
(
M
ndTestMnode
,
03
_Create_Mnode_Invalid_Id
)
{
{
int32_t
contLen
=
sizeof
(
SMCreateMnodeMsg
);
...
...
@@ -96,14 +96,14 @@ TEST_F(DndTestMnode, 03_Create_Mnode_Invalid_Id) {
}
}
TEST_F
(
D
ndTestMnode
,
04
_Create_Mnode
)
{
TEST_F
(
M
ndTestMnode
,
04
_Create_Mnode
)
{
{
// create dnode
int32_t
contLen
=
sizeof
(
SCreateDnode
Msg
);
int32_t
contLen
=
sizeof
(
SCreateDnode
Req
);
SCreateDnode
Msg
*
pReq
=
(
SCreateDnodeMsg
*
)
rpcMallocCont
(
contLen
);
SCreateDnode
Req
*
pReq
=
(
SCreateDnodeReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
pReq
->
port
=
htonl
(
90
6
2
);
pReq
->
port
=
htonl
(
90
3
2
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
...
@@ -132,8 +132,8 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
CheckInt16
(
1
);
CheckInt16
(
2
);
CheckBinary
(
"localhost:90
6
1"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
6
2"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
3
1"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
3
2"
,
TSDB_EP_LEN
);
CheckBinary
(
"master"
,
12
);
CheckBinary
(
"slave"
,
12
);
CheckInt64
(
0
);
...
...
@@ -158,16 +158,16 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckInt16
(
1
);
CheckBinary
(
"localhost:90
6
1"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
3
1"
,
TSDB_EP_LEN
);
CheckBinary
(
"master"
,
12
);
CheckInt64
(
0
);
CheckTimestamp
();
}
}
// {
// int32_t contLen = sizeof(SDropDnode
Msg
);
// int32_t contLen = sizeof(SDropDnode
Req
);
// SDropDnode
Msg* pReq = (SDropDnodeMsg
*)rpcMallocCont(contLen);
// SDropDnode
Req* pReq = (SDropDnodeReq
*)rpcMallocCont(contLen);
// pReq->dnodeId = htonl(2);
// SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_DNODE, pReq, contLen);
...
...
@@ -181,7 +181,7 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
// EXPECT_EQ(test.GetShowRows(), 1);
// CheckInt16(1);
// CheckBinary("localhost:90
6
1", TSDB_EP_LEN);
// CheckBinary("localhost:90
3
1", TSDB_EP_LEN);
// CheckInt16(0);
// CheckInt16(1);
// CheckBinary("ready", 10);
...
...
@@ -189,10 +189,10 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
// CheckBinary("", 24);
// {
// int32_t contLen = sizeof(SCreateDnode
Msg
);
// int32_t contLen = sizeof(SCreateDnode
Req
);
// SCreateDnode
Msg* pReq = (SCreateDnodeMsg
*)rpcMallocCont(contLen);
// strcpy(pReq->ep, "localhost:90
6
3");
// SCreateDnode
Req* pReq = (SCreateDnodeReq
*)rpcMallocCont(contLen);
// strcpy(pReq->ep, "localhost:90
3
3");
// SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
// ASSERT_NE(pRsp, nullptr);
...
...
@@ -200,10 +200,10 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
// }
// {
// int32_t contLen = sizeof(SCreateDnode
Msg
);
// int32_t contLen = sizeof(SCreateDnode
Req
);
// SCreateDnode
Msg* pReq = (SCreateDnodeMsg
*)rpcMallocCont(contLen);
// strcpy(pReq->ep, "localhost:90
6
4");
// SCreateDnode
Req* pReq = (SCreateDnodeReq
*)rpcMallocCont(contLen);
// strcpy(pReq->ep, "localhost:90
3
4");
// SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
// ASSERT_NE(pRsp, nullptr);
...
...
@@ -211,10 +211,10 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
// }
// {
// int32_t contLen = sizeof(SCreateDnode
Msg
);
// int32_t contLen = sizeof(SCreateDnode
Req
);
// SCreateDnode
Msg* pReq = (SCreateDnodeMsg
*)rpcMallocCont(contLen);
// strcpy(pReq->ep, "localhost:90
6
5");
// SCreateDnode
Req* pReq = (SCreateDnodeReq
*)rpcMallocCont(contLen);
// strcpy(pReq->ep, "localhost:90
3
5");
// SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
// ASSERT_NE(pRsp, nullptr);
...
...
@@ -231,10 +231,10 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
// CheckInt16(3);
// CheckInt16(4);
// CheckInt16(5);
// CheckBinary("localhost:90
6
1", TSDB_EP_LEN);
// CheckBinary("localhost:90
6
3", TSDB_EP_LEN);
// CheckBinary("localhost:90
6
4", TSDB_EP_LEN);
// CheckBinary("localhost:90
6
5", TSDB_EP_LEN);
// CheckBinary("localhost:90
3
1", TSDB_EP_LEN);
// CheckBinary("localhost:90
3
3", TSDB_EP_LEN);
// CheckBinary("localhost:90
3
4", TSDB_EP_LEN);
// CheckBinary("localhost:90
3
5", TSDB_EP_LEN);
// CheckInt16(0);
// CheckInt16(0);
// CheckInt16(0);
...
...
@@ -274,10 +274,10 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
// CheckInt16(3);
// CheckInt16(4);
// CheckInt16(5);
// CheckBinary("localhost:90
6
1", TSDB_EP_LEN);
// CheckBinary("localhost:90
6
3", TSDB_EP_LEN);
// CheckBinary("localhost:90
6
4", TSDB_EP_LEN);
// CheckBinary("localhost:90
6
5", TSDB_EP_LEN);
// CheckBinary("localhost:90
3
1", TSDB_EP_LEN);
// CheckBinary("localhost:90
3
3", TSDB_EP_LEN);
// CheckBinary("localhost:90
3
4", TSDB_EP_LEN);
// CheckBinary("localhost:90
3
5", TSDB_EP_LEN);
// CheckInt16(0);
// CheckInt16(0);
// CheckInt16(0);
...
...
source/dnode/m
gmt
/impl/test/profile/CMakeLists.txt
→
source/dnode/m
node
/impl/test/profile/CMakeLists.txt
浏览文件 @
61136183
aux_source_directory
(
. PROFILE_SRC
)
add_executable
(
d
node_test_profile
${
PROFILE_SRC
}
)
add_executable
(
m
node_test_profile
${
PROFILE_SRC
}
)
target_link_libraries
(
d
node_test_profile
m
node_test_profile
PUBLIC sut
)
add_test
(
NAME
d
node_test_profile
COMMAND
d
node_test_profile
NAME
m
node_test_profile
COMMAND
m
node_test_profile
)
source/dnode/m
gmt
/impl/test/profile/profile.cpp
→
source/dnode/m
node
/impl/test/profile/profile.cpp
浏览文件 @
61136183
/**
* @file profile.cpp
* @author slguan (slguan@taosdata.com)
* @brief
DNODE module profile-msg
tests
* @version
0.1
* @date 202
1-12-15
* @brief
MNODE module profile
tests
* @version
1.0
* @date 202
2-01-06
*
* @copyright Copyright (c) 202
1
* @copyright Copyright (c) 202
2
*
*/
#include "sut.h"
class
D
ndTestProfile
:
public
::
testing
::
Test
{
class
M
ndTestProfile
:
public
::
testing
::
Test
{
protected:
static
void
SetUpTestSuite
()
{
test
.
Init
(
"/tmp/
dnode_test_profile"
,
9080
);
}
static
void
SetUpTestSuite
()
{
test
.
Init
(
"/tmp/
mnode_test_profile"
,
9022
);
}
static
void
TearDownTestSuite
()
{
test
.
Cleanup
();
}
static
Testbase
test
;
...
...
@@ -24,15 +24,15 @@ class DndTestProfile : public ::testing::Test {
void
TearDown
()
override
{}
};
Testbase
D
ndTestProfile
::
test
;
int32_t
D
ndTestProfile
::
connId
;
Testbase
M
ndTestProfile
::
test
;
int32_t
M
ndTestProfile
::
connId
;
TEST_F
(
D
ndTestProfile
,
01
_ConnectMsg
)
{
int32_t
contLen
=
sizeof
(
SConnect
Msg
);
TEST_F
(
M
ndTestProfile
,
01
_ConnectMsg
)
{
int32_t
contLen
=
sizeof
(
SConnect
Req
);
SConnect
Msg
*
pReq
=
(
SConnectMsg
*
)
rpcMallocCont
(
contLen
);
SConnect
Req
*
pReq
=
(
SConnectReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
pid
=
htonl
(
1234
);
strcpy
(
pReq
->
app
,
"
d
node_test_profile"
);
strcpy
(
pReq
->
app
,
"
m
node_test_profile"
);
strcpy
(
pReq
->
db
,
""
);
SRpcMsg
*
pMsg
=
test
.
SendReq
(
TDMT_MND_CONNECT
,
pReq
,
contLen
);
...
...
@@ -53,18 +53,18 @@ TEST_F(DndTestProfile, 01_ConnectMsg) {
EXPECT_EQ
(
pRsp
->
epSet
.
inUse
,
0
);
EXPECT_EQ
(
pRsp
->
epSet
.
numOfEps
,
1
);
EXPECT_EQ
(
pRsp
->
epSet
.
port
[
0
],
90
80
);
EXPECT_EQ
(
pRsp
->
epSet
.
port
[
0
],
90
22
);
EXPECT_STREQ
(
pRsp
->
epSet
.
fqdn
[
0
],
"localhost"
);
connId
=
pRsp
->
connId
;
}
TEST_F
(
D
ndTestProfile
,
02
_ConnectMsg_InvalidDB
)
{
int32_t
contLen
=
sizeof
(
SConnect
Msg
);
TEST_F
(
M
ndTestProfile
,
02
_ConnectMsg_InvalidDB
)
{
int32_t
contLen
=
sizeof
(
SConnect
Req
);
SConnect
Msg
*
pReq
=
(
SConnectMsg
*
)
rpcMallocCont
(
contLen
);
SConnect
Req
*
pReq
=
(
SConnectReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
pid
=
htonl
(
1234
);
strcpy
(
pReq
->
app
,
"
d
node_test_profile"
);
strcpy
(
pReq
->
app
,
"
m
node_test_profile"
);
strcpy
(
pReq
->
db
,
"invalid_db"
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CONNECT
,
pReq
,
contLen
);
...
...
@@ -73,7 +73,7 @@ TEST_F(DndTestProfile, 02_ConnectMsg_InvalidDB) {
ASSERT_EQ
(
pRsp
->
contLen
,
0
);
}
TEST_F
(
D
ndTestProfile
,
03
_ConnectMsg_Show
)
{
TEST_F
(
M
ndTestProfile
,
03
_ConnectMsg_Show
)
{
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_CONNS
,
""
);
CHECK_META
(
"show connections"
,
7
);
CHECK_SCHEMA
(
0
,
TSDB_DATA_TYPE_INT
,
4
,
"connId"
);
...
...
@@ -88,22 +88,22 @@ TEST_F(DndTestProfile, 03_ConnectMsg_Show) {
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckInt32
(
1
);
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
CheckBinary
(
"
d
node_test_profile"
,
TSDB_APP_NAME_LEN
);
CheckBinary
(
"
m
node_test_profile"
,
TSDB_APP_NAME_LEN
);
CheckInt32
(
1234
);
IgnoreBinary
(
TSDB_IPv4ADDR_LEN
+
6
);
CheckTimestamp
();
CheckTimestamp
();
}
TEST_F
(
D
ndTestProfile
,
04
_HeartBeatMsg
)
{
int32_t
contLen
=
sizeof
(
SHeartBeat
Msg
);
TEST_F
(
M
ndTestProfile
,
04
_HeartBeatMsg
)
{
int32_t
contLen
=
sizeof
(
SHeartBeat
Req
);
SHeartBeat
Msg
*
pReq
=
(
SHeartBeatMsg
*
)
rpcMallocCont
(
contLen
);
SHeartBeat
Req
*
pReq
=
(
SHeartBeatReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
connId
=
htonl
(
connId
);
pReq
->
pid
=
htonl
(
1234
);
pReq
->
numOfQueries
=
htonl
(
0
);
pReq
->
numOfStreams
=
htonl
(
0
);
strcpy
(
pReq
->
app
,
"
d
node_test_profile"
);
strcpy
(
pReq
->
app
,
"
m
node_test_profile"
);
SRpcMsg
*
pMsg
=
test
.
SendReq
(
TDMT_MND_HEARTBEAT
,
pReq
,
contLen
);
ASSERT_NE
(
pMsg
,
nullptr
);
...
...
@@ -127,15 +127,15 @@ TEST_F(DndTestProfile, 04_HeartBeatMsg) {
EXPECT_EQ
(
pRsp
->
epSet
.
inUse
,
0
);
EXPECT_EQ
(
pRsp
->
epSet
.
numOfEps
,
1
);
EXPECT_EQ
(
pRsp
->
epSet
.
port
[
0
],
90
80
);
EXPECT_EQ
(
pRsp
->
epSet
.
port
[
0
],
90
22
);
EXPECT_STREQ
(
pRsp
->
epSet
.
fqdn
[
0
],
"localhost"
);
}
TEST_F
(
D
ndTestProfile
,
05
_KillConnMsg
)
{
TEST_F
(
M
ndTestProfile
,
05
_KillConnMsg
)
{
{
int32_t
contLen
=
sizeof
(
SKillConn
Msg
);
int32_t
contLen
=
sizeof
(
SKillConn
Req
);
SKillConn
Msg
*
pReq
=
(
SKillConnMsg
*
)
rpcMallocCont
(
contLen
);
SKillConn
Req
*
pReq
=
(
SKillConnReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
connId
=
htonl
(
connId
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_KILL_CONN
,
pReq
,
contLen
);
...
...
@@ -144,14 +144,14 @@ TEST_F(DndTestProfile, 05_KillConnMsg) {
}
{
int32_t
contLen
=
sizeof
(
SHeartBeat
Msg
);
int32_t
contLen
=
sizeof
(
SHeartBeat
Req
);
SHeartBeat
Msg
*
pReq
=
(
SHeartBeatMsg
*
)
rpcMallocCont
(
contLen
);
SHeartBeat
Req
*
pReq
=
(
SHeartBeatReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
connId
=
htonl
(
connId
);
pReq
->
pid
=
htonl
(
1234
);
pReq
->
numOfQueries
=
htonl
(
0
);
pReq
->
numOfStreams
=
htonl
(
0
);
strcpy
(
pReq
->
app
,
"
d
node_test_profile"
);
strcpy
(
pReq
->
app
,
"
m
node_test_profile"
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_HEARTBEAT
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
...
@@ -160,11 +160,11 @@ TEST_F(DndTestProfile, 05_KillConnMsg) {
}
{
int32_t
contLen
=
sizeof
(
SConnect
Msg
);
int32_t
contLen
=
sizeof
(
SConnect
Req
);
SConnect
Msg
*
pReq
=
(
SConnectMsg
*
)
rpcMallocCont
(
contLen
);
SConnect
Req
*
pReq
=
(
SConnectReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
pid
=
htonl
(
1234
);
strcpy
(
pReq
->
app
,
"
d
node_test_profile"
);
strcpy
(
pReq
->
app
,
"
m
node_test_profile"
);
strcpy
(
pReq
->
db
,
""
);
SRpcMsg
*
pMsg
=
test
.
SendReq
(
TDMT_MND_CONNECT
,
pReq
,
contLen
);
...
...
@@ -185,17 +185,17 @@ TEST_F(DndTestProfile, 05_KillConnMsg) {
EXPECT_EQ
(
pRsp
->
epSet
.
inUse
,
0
);
EXPECT_EQ
(
pRsp
->
epSet
.
numOfEps
,
1
);
EXPECT_EQ
(
pRsp
->
epSet
.
port
[
0
],
90
80
);
EXPECT_EQ
(
pRsp
->
epSet
.
port
[
0
],
90
22
);
EXPECT_STREQ
(
pRsp
->
epSet
.
fqdn
[
0
],
"localhost"
);
connId
=
pRsp
->
connId
;
}
}
TEST_F
(
D
ndTestProfile
,
06
_KillConnMsg_InvalidConn
)
{
int32_t
contLen
=
sizeof
(
SKillConn
Msg
);
TEST_F
(
M
ndTestProfile
,
06
_KillConnMsg_InvalidConn
)
{
int32_t
contLen
=
sizeof
(
SKillConn
Req
);
SKillConn
Msg
*
pReq
=
(
SKillConnMsg
*
)
rpcMallocCont
(
contLen
);
SKillConn
Req
*
pReq
=
(
SKillConnReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
connId
=
htonl
(
2345
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_KILL_CONN
,
pReq
,
contLen
);
...
...
@@ -203,11 +203,11 @@ TEST_F(DndTestProfile, 06_KillConnMsg_InvalidConn) {
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_CONN_ID
);
}
TEST_F
(
D
ndTestProfile
,
07
_KillQueryMsg
)
{
TEST_F
(
M
ndTestProfile
,
07
_KillQueryMsg
)
{
{
int32_t
contLen
=
sizeof
(
SKillQuery
Msg
);
int32_t
contLen
=
sizeof
(
SKillQuery
Req
);
SKillQuery
Msg
*
pReq
=
(
SKillQueryMsg
*
)
rpcMallocCont
(
contLen
);
SKillQuery
Req
*
pReq
=
(
SKillQueryReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
connId
=
htonl
(
connId
);
pReq
->
queryId
=
htonl
(
1234
);
...
...
@@ -218,14 +218,14 @@ TEST_F(DndTestProfile, 07_KillQueryMsg) {
}
{
int32_t
contLen
=
sizeof
(
SHeartBeat
Msg
);
int32_t
contLen
=
sizeof
(
SHeartBeat
Req
);
SHeartBeat
Msg
*
pReq
=
(
SHeartBeatMsg
*
)
rpcMallocCont
(
contLen
);
SHeartBeat
Req
*
pReq
=
(
SHeartBeatReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
connId
=
htonl
(
connId
);
pReq
->
pid
=
htonl
(
1234
);
pReq
->
numOfQueries
=
htonl
(
0
);
pReq
->
numOfStreams
=
htonl
(
0
);
strcpy
(
pReq
->
app
,
"
d
node_test_profile"
);
strcpy
(
pReq
->
app
,
"
m
node_test_profile"
);
SRpcMsg
*
pMsg
=
test
.
SendReq
(
TDMT_MND_HEARTBEAT
,
pReq
,
contLen
);
ASSERT_NE
(
pMsg
,
nullptr
);
...
...
@@ -249,15 +249,15 @@ TEST_F(DndTestProfile, 07_KillQueryMsg) {
EXPECT_EQ
(
pRsp
->
epSet
.
inUse
,
0
);
EXPECT_EQ
(
pRsp
->
epSet
.
numOfEps
,
1
);
EXPECT_EQ
(
pRsp
->
epSet
.
port
[
0
],
90
80
);
EXPECT_EQ
(
pRsp
->
epSet
.
port
[
0
],
90
22
);
EXPECT_STREQ
(
pRsp
->
epSet
.
fqdn
[
0
],
"localhost"
);
}
}
TEST_F
(
D
ndTestProfile
,
08
_KillQueryMsg_InvalidConn
)
{
int32_t
contLen
=
sizeof
(
SKillQuery
Msg
);
TEST_F
(
M
ndTestProfile
,
08
_KillQueryMsg_InvalidConn
)
{
int32_t
contLen
=
sizeof
(
SKillQuery
Req
);
SKillQuery
Msg
*
pReq
=
(
SKillQueryMsg
*
)
rpcMallocCont
(
contLen
);
SKillQuery
Req
*
pReq
=
(
SKillQueryReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
connId
=
htonl
(
2345
);
pReq
->
queryId
=
htonl
(
1234
);
...
...
@@ -266,7 +266,7 @@ TEST_F(DndTestProfile, 08_KillQueryMsg_InvalidConn) {
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_CONN_ID
);
}
TEST_F
(
D
ndTestProfile
,
09
_KillQueryMsg
)
{
TEST_F
(
M
ndTestProfile
,
09
_KillQueryMsg
)
{
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_QUERIES
,
""
);
CHECK_META
(
"show queries"
,
14
);
...
...
source/dnode/mnode/impl/test/qnode/qnode.cpp
浏览文件 @
61136183
...
...
@@ -96,9 +96,9 @@ TEST_F(MndTestQnode, 02_Create_Qnode) {
TEST_F
(
MndTestQnode
,
03
_Drop_Qnode
)
{
{
int32_t
contLen
=
sizeof
(
SCreateDnode
Msg
);
int32_t
contLen
=
sizeof
(
SCreateDnode
Req
);
SCreateDnode
Msg
*
pReq
=
(
SCreateDnodeMsg
*
)
rpcMallocCont
(
contLen
);
SCreateDnode
Req
*
pReq
=
(
SCreateDnodeReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
pReq
->
port
=
htonl
(
9015
);
...
...
source/dnode/mnode/impl/test/show/show.cpp
浏览文件 @
61136183
...
...
@@ -13,7 +13,7 @@
class
MndTestShow
:
public
::
testing
::
Test
{
protected:
static
void
SetUpTestSuite
()
{
test
.
Init
(
"/tmp/mnode_test_show"
,
902
0
);
}
static
void
SetUpTestSuite
()
{
test
.
Init
(
"/tmp/mnode_test_show"
,
902
1
);
}
static
void
TearDownTestSuite
()
{
test
.
Cleanup
();
}
static
Testbase
test
;
...
...
@@ -50,9 +50,9 @@ TEST_F(MndTestShow, 02_ShowMsg_InvalidMsgStart) {
}
TEST_F
(
MndTestShow
,
03
_ShowMsg_Conn
)
{
int32_t
contLen
=
sizeof
(
SConnect
Msg
);
int32_t
contLen
=
sizeof
(
SConnect
Req
);
SConnect
Msg
*
pReq
=
(
SConnectMsg
*
)
rpcMallocCont
(
contLen
);
SConnect
Req
*
pReq
=
(
SConnectReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
pid
=
htonl
(
1234
);
strcpy
(
pReq
->
app
,
"mnode_test_show"
);
strcpy
(
pReq
->
db
,
""
);
...
...
source/dnode/mnode/impl/test/snode/snode.cpp
浏览文件 @
61136183
...
...
@@ -96,9 +96,9 @@ TEST_F(MndTestSnode, 02_Create_Snode) {
TEST_F
(
MndTestSnode
,
03
_Drop_Snode
)
{
{
int32_t
contLen
=
sizeof
(
SCreateDnode
Msg
);
int32_t
contLen
=
sizeof
(
SCreateDnode
Req
);
SCreateDnode
Msg
*
pReq
=
(
SCreateDnodeMsg
*
)
rpcMallocCont
(
contLen
);
SCreateDnode
Req
*
pReq
=
(
SCreateDnodeReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
pReq
->
port
=
htonl
(
9017
);
...
...
source/dnode/mnode/impl/test/trans/trans.cpp
浏览文件 @
61136183
...
...
@@ -133,9 +133,9 @@ TEST_F(MndTestTrans, 02_Create_Qnode1_Crash) {
TEST_F
(
MndTestTrans
,
03
_Create_Qnode2_Crash
)
{
{
int32_t
contLen
=
sizeof
(
SCreateDnode
Msg
);
int32_t
contLen
=
sizeof
(
SCreateDnode
Req
);
SCreateDnode
Msg
*
pReq
=
(
SCreateDnodeMsg
*
)
rpcMallocCont
(
contLen
);
SCreateDnode
Req
*
pReq
=
(
SCreateDnodeReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
pReq
->
port
=
htonl
(
9020
);
...
...
source/dnode/mnode/sdb/src/sdbHash.c
浏览文件 @
61136183
...
...
@@ -429,3 +429,12 @@ int32_t sdbGetMaxId(SSdb *pSdb, ESdbType type) {
maxId
=
MAX
(
maxId
,
pSdb
->
maxId
[
type
]);
return
maxId
+
1
;
}
int64_t
sdbGetTableVer
(
SSdb
*
pSdb
,
ESdbType
type
)
{
if
(
type
>=
SDB_MAX
||
type
<
0
)
{
terrno
=
TSDB_CODE_SDB_INVALID_TABLE_TYPE
;
return
-
1
;
}
return
pSdb
->
tableVer
[
type
];
}
source/libs/parser/inc/astToMsg.h
浏览文件 @
61136183
...
...
@@ -12,7 +12,7 @@ SShowReq* buildShowMsg(SShowInfo* pShowInfo, SParseBasicCtx* pParseCtx, char* ms
SCreateDbMsg
*
buildCreateDbMsg
(
SCreateDbInfo
*
pCreateDbInfo
,
SParseBasicCtx
*
pCtx
,
SMsgBuf
*
pMsgBuf
);
SCreateStbMsg
*
buildCreateStbMsg
(
SCreateTableSql
*
pCreateTableSql
,
int32_t
*
len
,
SParseBasicCtx
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
);
SDropStbMsg
*
buildDropStableMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
len
,
SParseBasicCtx
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
);
SCreateDnode
Msg
*
buildCreateDnodeMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
len
,
SMsgBuf
*
pMsgBuf
);
SDropDnode
Msg
*
buildDropDnodeMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
len
,
SMsgBuf
*
pMsgBuf
);
SCreateDnode
Req
*
buildCreateDnodeMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
len
,
SMsgBuf
*
pMsgBuf
);
SDropDnode
Req
*
buildDropDnodeMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
len
,
SMsgBuf
*
pMsgBuf
);
#endif // TDENGINE_ASTTOMSG_H
source/libs/parser/src/astToMsg.c
浏览文件 @
61136183
...
...
@@ -335,7 +335,7 @@ SDropStbMsg* buildDropStableMsg(SSqlInfo* pInfo, int32_t* len, SParseBasicCtx* p
return
pDropTableMsg
;
}
SCreateDnode
Msg
*
buildCreateDnodeMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
len
,
SMsgBuf
*
pMsgBuf
)
{
SCreateDnode
Req
*
buildCreateDnodeMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
len
,
SMsgBuf
*
pMsgBuf
)
{
const
char
*
msg1
=
"invalid host name (name too long, maximum length 128)"
;
const
char
*
msg2
=
"dnode name can not be string"
;
const
char
*
msg3
=
"port should be an integer that is less than 65535 and greater than 0"
;
...
...
@@ -367,7 +367,7 @@ SCreateDnodeMsg *buildCreateDnodeMsg(SSqlInfo* pInfo, int32_t* len, SMsgBuf* pMs
return
NULL
;
}
SCreateDnode
Msg
*
pCreate
=
(
SCreateDnodeMsg
*
)
calloc
(
1
,
sizeof
(
SCreateDnodeMsg
));
SCreateDnode
Req
*
pCreate
=
(
SCreateDnodeReq
*
)
calloc
(
1
,
sizeof
(
SCreateDnodeReq
));
if
(
pCreate
==
NULL
)
{
buildInvalidOperationMsg
(
pMsgBuf
,
msg4
);
return
NULL
;
...
...
@@ -376,18 +376,18 @@ SCreateDnodeMsg *buildCreateDnodeMsg(SSqlInfo* pInfo, int32_t* len, SMsgBuf* pMs
strncpy
(
pCreate
->
fqdn
,
id
->
z
,
id
->
n
);
pCreate
->
port
=
htonl
(
val
);
*
len
=
sizeof
(
SCreateDnode
Msg
);
*
len
=
sizeof
(
SCreateDnode
Req
);
return
pCreate
;
}
SDropDnode
Msg
*
buildDropDnodeMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
len
,
SMsgBuf
*
pMsgBuf
)
{
SDropDnode
Req
*
buildDropDnodeMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
len
,
SMsgBuf
*
pMsgBuf
)
{
SToken
*
pzName
=
taosArrayGet
(
pInfo
->
pMiscInfo
->
a
,
0
);
char
*
end
=
NULL
;
SDropDnode
Msg
*
pDrop
=
(
SDropDnodeMsg
*
)
calloc
(
1
,
sizeof
(
SDropDnodeMsg
));
SDropDnode
Req
*
pDrop
=
(
SDropDnodeReq
*
)
calloc
(
1
,
sizeof
(
SDropDnodeReq
));
pDrop
->
dnodeId
=
strtoll
(
pzName
->
z
,
&
end
,
10
);
pDrop
->
dnodeId
=
htonl
(
pDrop
->
dnodeId
);
*
len
=
sizeof
(
SDropDnode
Msg
);
*
len
=
sizeof
(
SDropDnode
Req
);
if
(
end
-
pzName
->
z
!=
pzName
->
n
)
{
buildInvalidOperationMsg
(
pMsgBuf
,
"invalid dnode id"
);
...
...
source/libs/parser/src/astValidate.c
浏览文件 @
61136183
...
...
@@ -3819,7 +3819,7 @@ int32_t qParserValidateSqlNode(struct SCatalog* pCatalog, SSqlInfo* pInfo, SQuer
char* pMsg = pCmd->payload;
S
CfgDnodeMsg* pCfg = (SCfgDnodeMsg
*)pMsg;
S
MCfgDnodeReq* pCfg = (SMCfgDnodeReq
*)pMsg;
SToken* t0 = taosArrayGet(pMiscInfo->a, 0);
SToken* t1 = taosArrayGet(pMiscInfo->a, 1);
...
...
src/client/src/tscProfile.c
浏览文件 @
61136183
...
...
@@ -226,7 +226,7 @@ void tscKillStream(STscObj *pObj, uint32_t killId) {
}
int
tscBuildQueryStreamDesc
(
void
*
pMsg
,
STscObj
*
pObj
)
{
SHeartBeat
Msg
*
pHeartbeat
=
pMsg
;
SHeartBeat
Req
*
pHeartbeat
=
pMsg
;
int
allocedQueriesNum
=
pHeartbeat
->
numOfQueries
;
int
allocedStreamsNum
=
pHeartbeat
->
numOfStreams
;
...
...
@@ -327,7 +327,7 @@ int tscBuildQueryStreamDesc(void *pMsg, STscObj *pObj) {
}
int32_t
msgLen
=
pHeartbeat
->
numOfQueries
*
sizeof
(
SQueryDesc
)
+
pHeartbeat
->
numOfStreams
*
sizeof
(
SStreamDesc
)
+
sizeof
(
SHeartBeat
Msg
);
sizeof
(
SHeartBeat
Req
);
pHeartbeat
->
connId
=
htonl
(
pObj
->
connId
);
pHeartbeat
->
numOfQueries
=
htonl
(
pHeartbeat
->
numOfQueries
);
pHeartbeat
->
numOfStreams
=
htonl
(
pHeartbeat
->
numOfStreams
);
...
...
src/client/src/tscSQLParser.c
浏览文件 @
61136183
...
...
@@ -776,7 +776,7 @@ int32_t tscValidateSqlInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
char
*
pMsg
=
pCmd
->
payload
;
S
CfgDnodeMsg
*
pCfg
=
(
SCfgDnodeMsg
*
)
pMsg
;
S
MCfgDnodeReq
*
pCfg
=
(
SMCfgDnodeReq
*
)
pMsg
;
SStrToken
*
t0
=
taosArrayGet
(
pMiscInfo
->
a
,
0
);
SStrToken
*
t1
=
taosArrayGet
(
pMiscInfo
->
a
,
1
);
...
...
src/client/src/tscServer.c
浏览文件 @
61136183
...
...
@@ -1192,13 +1192,13 @@ int32_t tscBuildCreateFuncMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
int32_t
tscBuildCreateDnodeMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
pCmd
->
payloadLen
=
sizeof
(
SCreateDnode
Msg
);
pCmd
->
payloadLen
=
sizeof
(
SCreateDnode
Req
);
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
pCmd
->
payloadLen
))
{
tscError
(
"0x%"
PRIx64
" failed to malloc for query msg"
,
pSql
->
self
);
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
SCreateDnode
Msg
*
pCreate
=
(
SCreateDnodeMsg
*
)
pCmd
->
payload
;
SCreateDnode
Req
*
pCreate
=
(
SCreateDnodeReq
*
)
pCmd
->
payload
;
SStrToken
*
t0
=
taosArrayGet
(
pInfo
->
pMiscInfo
->
a
,
0
);
strncpy
(
pCreate
->
ep
,
t0
->
z
,
t0
->
n
);
...
...
@@ -1287,7 +1287,7 @@ int32_t tscBuildUserMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
int32_t
tscBuildCfgDnodeMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
pCmd
->
payloadLen
=
sizeof
(
S
CfgDnodeMsg
);
pCmd
->
payloadLen
=
sizeof
(
S
MCfgDnodeReq
);
pCmd
->
msgType
=
TDMT_MND_CONFIG_DNODE
;
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -1350,13 +1350,13 @@ int32_t tscBuildDropDnodeMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
char
dnodeEp
[
TSDB_EP_LEN
]
=
{
0
};
tstrncpy
(
dnodeEp
,
pCmd
->
payload
,
TSDB_EP_LEN
);
pCmd
->
payloadLen
=
sizeof
(
SDropDnode
Msg
);
pCmd
->
payloadLen
=
sizeof
(
SDropDnode
Req
);
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
pCmd
->
payloadLen
))
{
tscError
(
"0x%"
PRIx64
" failed to malloc for query msg"
,
pSql
->
self
);
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
SDropDnode
Msg
*
pDrop
=
(
SDropDnodeMsg
*
)
pCmd
->
payload
;
SDropDnode
Req
*
pDrop
=
(
SDropDnodeReq
*
)
pCmd
->
payload
;
tstrncpy
(
pDrop
->
ep
,
dnodeEp
,
tListLen
(
pDrop
->
ep
));
pCmd
->
msgType
=
TDMT_MND_DROP_DNODE
;
...
...
@@ -1469,7 +1469,7 @@ int32_t tscBuildShowMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
int32_t
tscBuildKillMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
pCmd
->
payloadLen
=
sizeof
(
SKillQuery
Msg
);
pCmd
->
payloadLen
=
sizeof
(
SKillQuery
Req
);
switch
(
pCmd
->
command
)
{
case
TSDB_SQL_KILL_QUERY
:
...
...
@@ -1862,14 +1862,14 @@ int tscBuildConnectMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
STscObj
*
pObj
=
pSql
->
pTscObj
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
pCmd
->
msgType
=
TDMT_MND_CONNECT
;
pCmd
->
payloadLen
=
sizeof
(
SConnect
Msg
);
pCmd
->
payloadLen
=
sizeof
(
SConnect
Req
);
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
pCmd
->
payloadLen
))
{
tscError
(
"0x%"
PRIx64
" failed to malloc for query msg"
,
pSql
->
self
);
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
SConnect
Msg
*
pConnect
=
(
SConnectMsg
*
)
pCmd
->
payload
;
SConnect
Req
*
pConnect
=
(
SConnectReq
*
)
pCmd
->
payload
;
// TODO refactor full_name
char
*
db
;
// ugly code to move the space
...
...
@@ -1974,7 +1974,7 @@ int tscBuildHeartBeatMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
numOfStreams
++
;
}
int
size
=
numOfQueries
*
sizeof
(
SQueryDesc
)
+
numOfStreams
*
sizeof
(
SStreamDesc
)
+
sizeof
(
SHeartBeat
Msg
)
+
100
;
int
size
=
numOfQueries
*
sizeof
(
SQueryDesc
)
+
numOfStreams
*
sizeof
(
SStreamDesc
)
+
sizeof
(
SHeartBeat
Req
)
+
100
;
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
size
))
{
pthread_mutex_unlock
(
&
pObj
->
mutex
);
tscError
(
"0x%"
PRIx64
" failed to create heartbeat msg"
,
pSql
->
self
);
...
...
@@ -1982,7 +1982,7 @@ int tscBuildHeartBeatMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
}
// TODO the expired hb and client can not be identified by server till now.
SHeartBeat
Msg
*
pHeartbeat
=
(
SHeartBeatMsg
*
)
pCmd
->
payload
;
SHeartBeat
Req
*
pHeartbeat
=
(
SHeartBeatReq
*
)
pCmd
->
payload
;
tstrncpy
(
pHeartbeat
->
clientVer
,
version
,
tListLen
(
pHeartbeat
->
clientVer
));
pHeartbeat
->
numOfQueries
=
numOfQueries
;
...
...
tests/script/general/table/basic1.sim
浏览文件 @
61136183
...
...
@@ -44,13 +44,20 @@ print $data10 $data11 $data12
print =============== create child table
sql create table c1 using st tags(1)
sql create table c2 using st tags(2)
sql create table c2 using st tags(2)
sql show tables
if $rows != 2 then
return -1
endi
sql create table c3 using st tags(3) c4 using st tags(4) c5 using st tags(5) c6 using st tags(6) c7 using st tags(7)
sql show tables
if $rows != 7 then
return -1
endi
print $data00 $data01 $data02
print $data10 $data11 $data22
print $data20 $data11 $data22
...
...
tests/test/c/create_table.c
浏览文件 @
61136183
...
...
@@ -15,25 +15,20 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "taos.h"
#include "taosdef.h"
#include "taoserror.h"
#include "thash.h"
#include "tutil.h"
#include "ulog.h"
#define MAX_RANDOM_POINTS 20000
#define GREEN "\033[1;32m"
#define NC "\033[0m"
char
dbName
[
32
]
=
"db"
;
char
stbName
[
64
]
=
"st"
;
int32_t
numOfThreads
=
2
;
int32_t
numOfThreads
=
1
;
int32_t
numOfTables
=
10000
;
int32_t
createTable
=
1
;
int32_t
insertData
=
0
;
int32_t
batchNum
=
1
;
int32_t
batchNum
=
1
0
;
int32_t
numOfVgroups
=
2
;
typedef
struct
{
...
...
@@ -47,11 +42,11 @@ typedef struct {
pthread_t
thread
;
}
SThreadInfo
;
void
parseArgument
(
int
argc
,
char
*
argv
[]);
void
parseArgument
(
int
32_t
argc
,
char
*
argv
[]);
void
*
threadFunc
(
void
*
param
);
void
createDbAndStb
();
int
main
(
in
t
argc
,
char
*
argv
[])
{
int
32_t
main
(
int32_
t
argc
,
char
*
argv
[])
{
parseArgument
(
argc
,
argv
);
createDbAndStb
();
...
...
@@ -64,7 +59,7 @@ int main(int argc, char *argv[]) {
int32_t
numOfTablesPerThread
=
numOfTables
/
numOfThreads
;
numOfTables
=
numOfTablesPerThread
*
numOfThreads
;
for
(
int
i
=
0
;
i
<
numOfThreads
;
++
i
)
{
for
(
int
32_t
i
=
0
;
i
<
numOfThreads
;
++
i
)
{
pInfo
[
i
].
tableBeginIndex
=
i
*
numOfTablesPerThread
;
pInfo
[
i
].
tableEndIndex
=
(
i
+
1
)
*
numOfTablesPerThread
;
pInfo
[
i
].
threadIndex
=
i
;
...
...
@@ -74,17 +69,17 @@ int main(int argc, char *argv[]) {
}
taosMsleep
(
300
);
for
(
int
i
=
0
;
i
<
numOfThreads
;
i
++
)
{
for
(
int
32_t
i
=
0
;
i
<
numOfThreads
;
i
++
)
{
pthread_join
(
pInfo
[
i
].
thread
,
NULL
);
}
float
createTableSpeed
=
0
;
for
(
int
i
=
0
;
i
<
numOfThreads
;
++
i
)
{
for
(
int
32_t
i
=
0
;
i
<
numOfThreads
;
++
i
)
{
createTableSpeed
+=
pInfo
[
i
].
createTableSpeed
;
}
float
insertDataSpeed
=
0
;
for
(
int
i
=
0
;
i
<
numOfThreads
;
++
i
)
{
for
(
int
32_t
i
=
0
;
i
<
numOfThreads
;
++
i
)
{
insertDataSpeed
+=
pInfo
[
i
].
insertDataSpeed
;
}
...
...
@@ -137,8 +132,8 @@ void createDbAndStb() {
void
*
threadFunc
(
void
*
param
)
{
SThreadInfo
*
pInfo
=
(
SThreadInfo
*
)
param
;
char
qstr
[
65000
]
;
int
code
;
char
*
qstr
=
malloc
(
2000
*
1000
)
;
int
32_t
code
=
0
;
TAOS
*
con
=
taos_connect
(
NULL
,
"root"
,
"taosdata"
,
NULL
,
0
);
if
(
con
==
NULL
)
{
...
...
@@ -153,7 +148,13 @@ void *threadFunc(void *param) {
if
(
createTable
)
{
int64_t
startMs
=
taosGetTimestampMs
();
for
(
int32_t
t
=
pInfo
->
tableBeginIndex
;
t
<
pInfo
->
tableEndIndex
;
++
t
)
{
sprintf
(
qstr
,
"create table t%d using %s tags(%d)"
,
t
,
stbName
,
t
);
int32_t
batch
=
(
pInfo
->
tableEndIndex
-
t
);
batch
=
MIN
(
batch
,
batchNum
);
int32_t
len
=
sprintf
(
qstr
,
"create table"
);
for
(
int32_t
i
=
0
;
i
<
batch
;
++
i
)
{
len
+=
sprintf
(
qstr
+
len
,
" t%d using %s tags(%d)"
,
t
+
i
,
stbName
,
t
+
i
);
}
TAOS_RES
*
pSql
=
taos_query
(
con
,
qstr
);
code
=
taos_errno
(
pSql
);
if
(
code
!=
0
)
{
...
...
@@ -189,6 +190,7 @@ void *threadFunc(void *param) {
}
taos_close
(
con
);
free
(
qstr
);
return
0
;
}
...
...
@@ -218,8 +220,8 @@ void printHelp() {
exit
(
EXIT_SUCCESS
);
}
void
parseArgument
(
int
argc
,
char
*
argv
[])
{
for
(
int
i
=
1
;
i
<
argc
;
i
++
)
{
void
parseArgument
(
int
32_t
argc
,
char
*
argv
[])
{
for
(
int
32_t
i
=
1
;
i
<
argc
;
i
++
)
{
if
(
strcmp
(
argv
[
i
],
"-h"
)
==
0
||
strcmp
(
argv
[
i
],
"--help"
)
==
0
)
{
printHelp
();
exit
(
0
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录