Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
0baa818e
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
0baa818e
编写于
1月 05, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/3.0' into feature/qnode
上级
feee87dd
507c0c02
变更
83
隐藏空白更改
内联
并排
Showing
83 changed file
with
940 addition
and
467 deletion
+940
-467
include/common/tmsg.h
include/common/tmsg.h
+6
-6
include/dnode/bnode/bnode.h
include/dnode/bnode/bnode.h
+6
-6
include/dnode/mnode/mnode.h
include/dnode/mnode/mnode.h
+8
-6
include/dnode/qnode/qnode.h
include/dnode/qnode/qnode.h
+6
-6
include/dnode/snode/snode.h
include/dnode/snode/snode.h
+6
-6
include/libs/catalog/catalog.h
include/libs/catalog/catalog.h
+2
-2
include/os/osSysinfo.h
include/os/osSysinfo.h
+1
-1
include/util/taoserror.h
include/util/taoserror.h
+1
-1
source/client/src/clientEnv.c
source/client/src/clientEnv.c
+13
-10
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+7
-4
source/client/src/clientMain.c
source/client/src/clientMain.c
+3
-1
source/client/test/clientTests.cpp
source/client/test/clientTests.cpp
+11
-1
source/dnode/bnode/inc/bndInt.h
source/dnode/bnode/inc/bndInt.h
+3
-3
source/dnode/mgmt/impl/inc/dndDnode.h
source/dnode/mgmt/impl/inc/dndDnode.h
+2
-2
source/dnode/mgmt/impl/inc/dndTransport.h
source/dnode/mgmt/impl/inc/dndTransport.h
+2
-2
source/dnode/mgmt/impl/src/dndBnode.c
source/dnode/mgmt/impl/src/dndBnode.c
+21
-11
source/dnode/mgmt/impl/src/dndDnode.c
source/dnode/mgmt/impl/src/dndDnode.c
+4
-4
source/dnode/mgmt/impl/src/dndMnode.c
source/dnode/mgmt/impl/src/dndMnode.c
+9
-3
source/dnode/mgmt/impl/src/dndQnode.c
source/dnode/mgmt/impl/src/dndQnode.c
+23
-11
source/dnode/mgmt/impl/src/dndSnode.c
source/dnode/mgmt/impl/src/dndSnode.c
+23
-12
source/dnode/mgmt/impl/src/dndTransport.c
source/dnode/mgmt/impl/src/dndTransport.c
+10
-7
source/dnode/mgmt/impl/src/dnode.c
source/dnode/mgmt/impl/src/dnode.c
+25
-1
source/dnode/mgmt/impl/test/CMakeLists.txt
source/dnode/mgmt/impl/test/CMakeLists.txt
+2
-3
source/dnode/mgmt/impl/test/bnode/bnode.cpp
source/dnode/mgmt/impl/test/bnode/bnode.cpp
+9
-9
source/dnode/mgmt/impl/test/cluster/cluster.cpp
source/dnode/mgmt/impl/test/cluster/cluster.cpp
+1
-1
source/dnode/mgmt/impl/test/db/db.cpp
source/dnode/mgmt/impl/test/db/db.cpp
+1
-1
source/dnode/mgmt/impl/test/dnode/dnode.cpp
source/dnode/mgmt/impl/test/dnode/dnode.cpp
+1
-1
source/dnode/mgmt/impl/test/mnode/mnode.cpp
source/dnode/mgmt/impl/test/mnode/mnode.cpp
+1
-1
source/dnode/mgmt/impl/test/profile/profile.cpp
source/dnode/mgmt/impl/test/profile/profile.cpp
+1
-1
source/dnode/mgmt/impl/test/qnode/CMakeLists.txt
source/dnode/mgmt/impl/test/qnode/CMakeLists.txt
+2
-2
source/dnode/mgmt/impl/test/qnode/dqnode.cpp
source/dnode/mgmt/impl/test/qnode/dqnode.cpp
+74
-0
source/dnode/mgmt/impl/test/show/show.cpp
source/dnode/mgmt/impl/test/show/show.cpp
+1
-1
source/dnode/mgmt/impl/test/stb/stb.cpp
source/dnode/mgmt/impl/test/stb/stb.cpp
+1
-1
source/dnode/mgmt/impl/test/sut/inc/server.h
source/dnode/mgmt/impl/test/sut/inc/server.h
+1
-1
source/dnode/mgmt/impl/test/sut/inc/sut.h
source/dnode/mgmt/impl/test/sut/inc/sut.h
+2
-0
source/dnode/mgmt/impl/test/sut/src/client.cpp
source/dnode/mgmt/impl/test/sut/src/client.cpp
+1
-1
source/dnode/mgmt/impl/test/sut/src/server.cpp
source/dnode/mgmt/impl/test/sut/src/server.cpp
+1
-1
source/dnode/mgmt/impl/test/sut/src/sut.cpp
source/dnode/mgmt/impl/test/sut/src/sut.cpp
+8
-4
source/dnode/mgmt/impl/test/vgroup/vgroup.cpp
source/dnode/mgmt/impl/test/vgroup/vgroup.cpp
+1
-1
source/dnode/mnode/impl/inc/mndInt.h
source/dnode/mnode/impl/inc/mndInt.h
+8
-7
source/dnode/mnode/impl/inc/mndTrans.h
source/dnode/mnode/impl/inc/mndTrans.h
+1
-0
source/dnode/mnode/impl/src/mndAcct.c
source/dnode/mnode/impl/src/mndAcct.c
+18
-18
source/dnode/mnode/impl/src/mndBnode.c
source/dnode/mnode/impl/src/mndBnode.c
+7
-7
source/dnode/mnode/impl/src/mndCluster.c
source/dnode/mnode/impl/src/mndCluster.c
+1
-1
source/dnode/mnode/impl/src/mndDnode.c
source/dnode/mnode/impl/src/mndDnode.c
+1
-1
source/dnode/mnode/impl/src/mndQnode.c
source/dnode/mnode/impl/src/mndQnode.c
+7
-7
source/dnode/mnode/impl/src/mndSnode.c
source/dnode/mnode/impl/src/mndSnode.c
+7
-7
source/dnode/mnode/impl/src/mndSync.c
source/dnode/mnode/impl/src/mndSync.c
+2
-0
source/dnode/mnode/impl/src/mndTrans.c
source/dnode/mnode/impl/src/mndTrans.c
+14
-11
source/dnode/mnode/impl/src/mndUser.c
source/dnode/mnode/impl/src/mndUser.c
+21
-21
source/dnode/mnode/impl/src/mnode.c
source/dnode/mnode/impl/src/mnode.c
+26
-21
source/dnode/mnode/impl/test/CMakeLists.txt
source/dnode/mnode/impl/test/CMakeLists.txt
+6
-1
source/dnode/mnode/impl/test/acct/acct.cpp
source/dnode/mnode/impl/test/acct/acct.cpp
+17
-17
source/dnode/mnode/impl/test/bnode/CMakeLists.txt
source/dnode/mnode/impl/test/bnode/CMakeLists.txt
+11
-0
source/dnode/mnode/impl/test/bnode/bnode.cpp
source/dnode/mnode/impl/test/bnode/bnode.cpp
+154
-0
source/dnode/mnode/impl/test/qnode/CMakeLists.txt
source/dnode/mnode/impl/test/qnode/CMakeLists.txt
+11
-0
source/dnode/mnode/impl/test/qnode/qnode.cpp
source/dnode/mnode/impl/test/qnode/qnode.cpp
+29
-29
source/dnode/mnode/impl/test/snode/CMakeLists.txt
source/dnode/mnode/impl/test/snode/CMakeLists.txt
+11
-0
source/dnode/mnode/impl/test/snode/snode.cpp
source/dnode/mnode/impl/test/snode/snode.cpp
+29
-29
source/dnode/mnode/impl/test/trans/CMakeLists.txt
source/dnode/mnode/impl/test/trans/CMakeLists.txt
+11
-0
source/dnode/mnode/impl/test/trans/trans.cpp
source/dnode/mnode/impl/test/trans/trans.cpp
+86
-0
source/dnode/mnode/impl/test/user/user.cpp
source/dnode/mnode/impl/test/user/user.cpp
+43
-43
source/dnode/mnode/sdb/src/sdb.c
source/dnode/mnode/sdb/src/sdb.c
+3
-2
source/dnode/mnode/sdb/src/sdbFile.c
source/dnode/mnode/sdb/src/sdbFile.c
+1
-1
source/dnode/qnode/inc/qndInt.h
source/dnode/qnode/inc/qndInt.h
+3
-3
source/dnode/snode/inc/sndInt.h
source/dnode/snode/inc/sndInt.h
+3
-3
source/dnode/vnode/meta/src/metaBDBImpl.c
source/dnode/vnode/meta/src/metaBDBImpl.c
+2
-2
source/libs/catalog/src/catalog.c
source/libs/catalog/src/catalog.c
+2
-2
source/libs/index/src/index.c
source/libs/index/src/index.c
+8
-15
source/libs/index/src/index_cache.c
source/libs/index/src/index_cache.c
+2
-2
source/libs/index/src/index_fst_counting_writer.c
source/libs/index/src/index_fst_counting_writer.c
+2
-2
source/libs/index/src/index_tfile.c
source/libs/index/src/index_tfile.c
+32
-29
source/libs/index/test/indexTests.cc
source/libs/index/test/indexTests.cc
+5
-7
source/libs/parser/inc/astToMsg.h
source/libs/parser/inc/astToMsg.h
+3
-3
source/libs/parser/inc/dataBlockMgt.h
source/libs/parser/inc/dataBlockMgt.h
+1
-1
source/libs/parser/src/astToMsg.c
source/libs/parser/src/astToMsg.c
+8
-8
source/libs/parser/src/dCDAstProcess.c
source/libs/parser/src/dCDAstProcess.c
+31
-19
source/libs/parser/src/insertParser.c
source/libs/parser/src/insertParser.c
+2
-1
source/libs/scheduler/src/scheduler.c
source/libs/scheduler/src/scheduler.c
+0
-1
source/libs/transport/src/rpcMain.c
source/libs/transport/src/rpcMain.c
+1
-1
source/os/src/osSysinfo.c
source/os/src/osSysinfo.c
+3
-3
source/util/src/terror.c
source/util/src/terror.c
+1
-1
src/client/src/tscServer.c
src/client/src/tscServer.c
+6
-6
未找到文件。
include/common/tmsg.h
浏览文件 @
0baa818e
...
...
@@ -345,18 +345,18 @@ typedef struct {
int32_t
maxStreams
;
int32_t
accessState
;
// Configured only by command
int64_t
maxStorage
;
// In unit of GB
}
SCreateAcct
Msg
,
SAlterAcctMsg
;
}
SCreateAcct
Req
,
SAlterAcctReq
;
typedef
struct
{
char
user
[
TSDB_USER_LEN
];
}
SDropUser
Msg
,
SDropAcctMsg
;
}
SDropUser
Req
,
SDropAcctReq
;
typedef
struct
{
int8_t
type
;
char
user
[
TSDB_USER_LEN
];
char
pass
[
TSDB_PASSWORD_LEN
];
int8_t
superUser
;
// denote if it is a super user or not
}
SCreateUser
Msg
,
SAlterUserMsg
;
}
SCreateUser
Req
,
SAlterUserReq
;
typedef
struct
{
int32_t
contLen
;
...
...
@@ -851,15 +851,15 @@ typedef struct {
typedef
struct
{
int32_t
dnodeId
;
}
SMCreateQnode
Msg
,
SMDropQnodeMsg
,
SDCreateQnodeMsg
,
SDDropQnodeMsg
;
}
SMCreateQnode
Req
,
SMDropQnodeReq
,
SDCreateQnodeReq
,
SDDropQnodeReq
;
typedef
struct
{
int32_t
dnodeId
;
}
SMCreateSnode
Msg
,
SMDropSnodeMsg
,
SDCreateSnodeMsg
,
SDDropSnodeMsg
;
}
SMCreateSnode
Req
,
SMDropSnodeReq
,
SDCreateSnodeReq
,
SDDropSnodeReq
;
typedef
struct
{
int32_t
dnodeId
;
}
SMCreateBnode
Msg
,
SMDropBnodeMsg
,
SDCreateBnodeMsg
,
SDDropBnodeMsg
;
}
SMCreateBnode
Req
,
SMDropBnodeReq
,
SDCreateBnodeReq
,
SDDropBnodeReq
;
typedef
struct
{
int32_t
dnodeId
;
...
...
include/dnode/bnode/bnode.h
浏览文件 @
0baa818e
...
...
@@ -23,9 +23,9 @@ extern "C" {
/* ------------------------ TYPES EXPOSED ------------------------ */
typedef
struct
SDnode
SDnode
;
typedef
struct
SBnode
SBnode
;
typedef
void
(
*
SendMsg
ToDnodeFp
)(
SDnode
*
pDnode
,
struct
SEpSet
*
epSet
,
struct
SRpcMsg
*
rpcMsg
);
typedef
void
(
*
SendMsg
ToMnodeFp
)(
SDnode
*
pDnode
,
struct
SRpcMsg
*
rpcMsg
);
typedef
void
(
*
SendRedirect
Msg
Fp
)(
SDnode
*
pDnode
,
struct
SRpcMsg
*
rpcMsg
);
typedef
int32_t
(
*
SendReq
ToDnodeFp
)(
SDnode
*
pDnode
,
struct
SEpSet
*
epSet
,
struct
SRpcMsg
*
rpcMsg
);
typedef
int32_t
(
*
SendReq
ToMnodeFp
)(
SDnode
*
pDnode
,
struct
SRpcMsg
*
rpcMsg
);
typedef
void
(
*
SendRedirect
Rsp
Fp
)(
SDnode
*
pDnode
,
struct
SRpcMsg
*
rpcMsg
);
typedef
struct
{
int64_t
numOfErrors
;
...
...
@@ -40,9 +40,9 @@ typedef struct {
int64_t
clusterId
;
SBnodeCfg
cfg
;
SDnode
*
pDnode
;
Send
MsgToDnodeFp
sendMsg
ToDnodeFp
;
Send
MsgToMnodeFp
sendMsg
ToMnodeFp
;
SendRedirect
MsgFp
sendRedirectMsg
Fp
;
Send
ReqToDnodeFp
sendReq
ToDnodeFp
;
Send
ReqToMnodeFp
sendReq
ToMnodeFp
;
SendRedirect
RspFp
sendRedirectRsp
Fp
;
}
SBnodeOpt
;
/* ------------------------ SBnode ------------------------ */
...
...
include/dnode/mnode/mnode.h
浏览文件 @
0baa818e
...
...
@@ -24,9 +24,10 @@ extern "C" {
typedef
struct
SDnode
SDnode
;
typedef
struct
SMnode
SMnode
;
typedef
struct
SMnodeMsg
SMnodeMsg
;
typedef
void
(
*
SendMsgToDnodeFp
)(
SDnode
*
pDnode
,
struct
SEpSet
*
epSet
,
struct
SRpcMsg
*
rpcMsg
);
typedef
void
(
*
SendMsgToMnodeFp
)(
SDnode
*
pDnode
,
struct
SRpcMsg
*
rpcMsg
);
typedef
void
(
*
SendRedirectMsgFp
)(
SDnode
*
pDnode
,
struct
SRpcMsg
*
rpcMsg
);
typedef
int32_t
(
*
SendReqToDnodeFp
)(
SDnode
*
pDnode
,
struct
SEpSet
*
epSet
,
struct
SRpcMsg
*
rpcMsg
);
typedef
int32_t
(
*
SendReqToMnodeFp
)(
SDnode
*
pDnode
,
struct
SRpcMsg
*
rpcMsg
);
typedef
int32_t
(
*
PutReqToMWriteQFp
)(
SDnode
*
pDnode
,
struct
SRpcMsg
*
rpcMsg
);
typedef
void
(
*
SendRedirectRspFp
)(
SDnode
*
pDnode
,
struct
SRpcMsg
*
rpcMsg
);
typedef
struct
SMnodeLoad
{
int64_t
numOfDnode
;
...
...
@@ -62,9 +63,10 @@ typedef struct {
SReplica
replicas
[
TSDB_MAX_REPLICA
];
SMnodeCfg
cfg
;
SDnode
*
pDnode
;
SendMsgToDnodeFp
sendMsgToDnodeFp
;
SendMsgToMnodeFp
sendMsgToMnodeFp
;
SendRedirectMsgFp
sendRedirectMsgFp
;
PutReqToMWriteQFp
putReqToMWriteQFp
;
SendReqToDnodeFp
sendReqToDnodeFp
;
SendReqToMnodeFp
sendReqToMnodeFp
;
SendRedirectRspFp
sendRedirectRspFp
;
}
SMnodeOpt
;
/* ------------------------ SMnode ------------------------ */
...
...
include/dnode/qnode/qnode.h
浏览文件 @
0baa818e
...
...
@@ -23,9 +23,9 @@ extern "C" {
/* ------------------------ TYPES EXPOSED ------------------------ */
typedef
struct
SDnode
SDnode
;
typedef
struct
SQnode
SQnode
;
typedef
void
(
*
SendMsg
ToDnodeFp
)(
SDnode
*
pDnode
,
struct
SEpSet
*
epSet
,
struct
SRpcMsg
*
rpcMsg
);
typedef
void
(
*
SendMsg
ToMnodeFp
)(
SDnode
*
pDnode
,
struct
SRpcMsg
*
rpcMsg
);
typedef
void
(
*
SendRedirect
Msg
Fp
)(
SDnode
*
pDnode
,
struct
SRpcMsg
*
rpcMsg
);
typedef
int32_t
(
*
SendReq
ToDnodeFp
)(
SDnode
*
pDnode
,
struct
SEpSet
*
epSet
,
struct
SRpcMsg
*
rpcMsg
);
typedef
int32_t
(
*
SendReq
ToMnodeFp
)(
SDnode
*
pDnode
,
struct
SRpcMsg
*
rpcMsg
);
typedef
void
(
*
SendRedirect
Rsp
Fp
)(
SDnode
*
pDnode
,
struct
SRpcMsg
*
rpcMsg
);
typedef
struct
{
int64_t
numOfStartTask
;
...
...
@@ -47,9 +47,9 @@ typedef struct {
int64_t
clusterId
;
SQnodeCfg
cfg
;
SDnode
*
pDnode
;
Send
MsgToDnodeFp
sendMsg
ToDnodeFp
;
Send
MsgToMnodeFp
sendMsg
ToMnodeFp
;
SendRedirect
MsgFp
sendRedirectMsg
Fp
;
Send
ReqToDnodeFp
sendReq
ToDnodeFp
;
Send
ReqToMnodeFp
sendReq
ToMnodeFp
;
SendRedirect
RspFp
sendRedirectRsp
Fp
;
}
SQnodeOpt
;
/* ------------------------ SQnode ------------------------ */
...
...
include/dnode/snode/snode.h
浏览文件 @
0baa818e
...
...
@@ -23,9 +23,9 @@ extern "C" {
/* ------------------------ TYPES EXPOSED ------------------------ */
typedef
struct
SDnode
SDnode
;
typedef
struct
SSnode
SSnode
;
typedef
void
(
*
SendMsg
ToDnodeFp
)(
SDnode
*
pDnode
,
struct
SEpSet
*
epSet
,
struct
SRpcMsg
*
rpcMsg
);
typedef
void
(
*
SendMsg
ToMnodeFp
)(
SDnode
*
pDnode
,
struct
SRpcMsg
*
rpcMsg
);
typedef
void
(
*
SendRedirect
Msg
Fp
)(
SDnode
*
pDnode
,
struct
SRpcMsg
*
rpcMsg
);
typedef
int32_t
(
*
SendReq
ToDnodeFp
)(
SDnode
*
pDnode
,
struct
SEpSet
*
epSet
,
struct
SRpcMsg
*
rpcMsg
);
typedef
int32_t
(
*
SendReq
ToMnodeFp
)(
SDnode
*
pDnode
,
struct
SRpcMsg
*
rpcMsg
);
typedef
void
(
*
SendRedirect
Rsp
Fp
)(
SDnode
*
pDnode
,
struct
SRpcMsg
*
rpcMsg
);
typedef
struct
{
int64_t
numOfErrors
;
...
...
@@ -40,9 +40,9 @@ typedef struct {
int64_t
clusterId
;
SSnodeCfg
cfg
;
SDnode
*
pDnode
;
Send
MsgToDnodeFp
sendMsg
ToDnodeFp
;
Send
MsgToMnodeFp
sendMsg
ToMnodeFp
;
SendRedirect
MsgFp
sendRedirectMsg
Fp
;
Send
ReqToDnodeFp
sendReq
ToDnodeFp
;
Send
ReqToMnodeFp
sendReq
ToMnodeFp
;
SendRedirect
RspFp
sendRedirectRsp
Fp
;
}
SSnodeOpt
;
/* ------------------------ SSnode ------------------------ */
...
...
include/libs/catalog/catalog.h
浏览文件 @
0baa818e
...
...
@@ -100,13 +100,13 @@ int32_t catalogRenewTableMeta(struct SCatalog* pCatalog, void * pTransporter, co
/**
* Force renew a table's local cached meta data and get the new one.
* @param pCatalog (input, got with catalogGetHandle)
* @param p
Rpc
(input, rpc object)
* @param p
Transporter
(input, rpc object)
* @param pMgmtEps (input, mnode EPs)
* @param pTableName (input, table name, NOT including db name)
* @param pTableMeta(output, table meta data, NEED to free it by calller)
* @return error code
*/
int32_t
catalogRenewAndGetTableMeta
(
struct
SCatalog
*
pCatalog
,
void
*
p
Rpc
,
const
SEpSet
*
pMgmtEps
,
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
);
int32_t
catalogRenewAndGetTableMeta
(
struct
SCatalog
*
pCatalog
,
void
*
p
Transporter
,
const
SEpSet
*
pMgmtEps
,
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
);
/**
...
...
include/os/osSysinfo.h
浏览文件 @
0baa818e
...
...
@@ -54,7 +54,7 @@ bool taosGetSysMemory(float *memoryUsedMB);
void
taosPrintOsInfo
();
int
taosSystem
(
const
char
*
cmd
);
void
taosKillSystem
();
int32_t
taosGetSystemU
id
(
char
*
uid
,
int32_t
uidlen
);
int32_t
taosGetSystemU
UID
(
char
*
uid
,
int32_t
uidlen
);
char
*
taosGetCmdlineByPID
(
int
pid
);
void
taosSetCoreDump
(
bool
enable
);
...
...
include/util/taoserror.h
浏览文件 @
0baa818e
...
...
@@ -253,7 +253,7 @@ int32_t* taosGetErrno();
// dnode
#define TSDB_CODE_DND_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0400)
#define TSDB_CODE_DND_
EXITING
TAOS_DEF_ERROR_CODE(0, 0x0401)
#define TSDB_CODE_DND_
OFFLINE
TAOS_DEF_ERROR_CODE(0, 0x0401)
#define TSDB_CODE_DND_INVALID_MSG_LEN TAOS_DEF_ERROR_CODE(0, 0x0402)
#define TSDB_CODE_DND_DNODE_READ_FILE_ERROR TAOS_DEF_ERROR_CODE(0, 0x0410)
#define TSDB_CODE_DND_DNODE_WRITE_FILE_ERROR TAOS_DEF_ERROR_CODE(0, 0x0411)
...
...
source/client/src/clientEnv.c
浏览文件 @
0baa818e
...
...
@@ -419,17 +419,20 @@ int taos_options_imp(TSDB_OPTION option, const char *str) {
*+------------+-----+-----------+---------------+
* @return
*/
static
int32_t
requestSerialId
=
0
;
uint64_t
generateRequestId
()
{
uint64_t
hashId
=
0
;
char
uid
[
64
]
=
{
0
};
int32_t
code
=
taosGetSystemUid
(
uid
,
tListLen
(
uid
));
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tscError
(
"Failed to get the system uid to generated request id, reason:%s. use ip address instead"
,
tstrerror
(
TAOS_SYSTEM_ERROR
(
errno
)));
}
else
{
hashId
=
MurmurHash3_32
(
uid
,
strlen
(
uid
));
static
uint64_t
hashId
=
0
;
static
int32_t
requestSerialId
=
0
;
if
(
hashId
==
0
)
{
char
uid
[
64
]
=
{
0
};
int32_t
code
=
taosGetSystemUUID
(
uid
,
tListLen
(
uid
));
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tscError
(
"Failed to get the system uid to generated request id, reason:%s. use ip address instead"
,
tstrerror
(
TAOS_SYSTEM_ERROR
(
errno
)));
}
else
{
hashId
=
MurmurHash3_32
(
uid
,
strlen
(
uid
));
}
}
int64_t
ts
=
taosGetTimestampUs
();
...
...
source/client/src/clientImpl.c
浏览文件 @
0baa818e
...
...
@@ -140,7 +140,7 @@ int32_t buildRequest(STscObj *pTscObj, const char *sql, int sqlLen, SRequestObj*
(
*
pRequest
)
->
sqlstr
[
sqlLen
]
=
0
;
(
*
pRequest
)
->
sqlLen
=
sqlLen
;
tscDebugL
(
"0x%"
PRIx64
" SQL: %s
"
,
(
*
pRequest
)
->
requestId
,
(
*
pRequest
)
->
sqlstr
);
tscDebugL
(
"0x%"
PRIx64
" SQL: %s
, reqId:0x"
PRIx64
,
(
*
pRequest
)
->
self
,
(
*
pRequest
)
->
sqlstr
,
(
*
pRequest
)
->
requestId
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -203,7 +203,10 @@ int32_t getPlan(SRequestObj* pRequest, SQueryNode* pQuery, SQueryDag** pDag) {
int32_t
scheduleQuery
(
SRequestObj
*
pRequest
,
SQueryDag
*
pDag
,
void
**
pJob
)
{
if
(
TSDB_SQL_INSERT
==
pRequest
->
type
||
TSDB_SQL_CREATE_TABLE
==
pRequest
->
type
)
{
return
scheduleExecJob
(
pRequest
->
pTscObj
->
pTransporter
,
NULL
/*todo appInfo.xxx*/
,
pDag
,
pJob
,
&
pRequest
->
affectedRows
);
SQueryResult
res
=
{.
code
=
0
,
.
numOfRows
=
0
,
.
msgSize
=
ERROR_MSG_BUF_DEFAULT_SIZE
,
.
msg
=
pRequest
->
msgBuf
};
int32_t
code
=
scheduleExecJob
(
pRequest
->
pTscObj
->
pTransporter
,
NULL
,
pDag
,
pJob
,
&
res
);
pRequest
->
affectedRows
=
res
.
numOfRows
;
return
res
.
code
;
}
return
scheduleAsyncExecJob
(
pRequest
->
pTscObj
->
pTransporter
,
NULL
/*todo appInfo.xxx*/
,
pDag
,
pJob
);
...
...
@@ -443,10 +446,10 @@ void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) {
*/
int32_t
elapsed
=
pRequest
->
metric
.
rsp
-
pRequest
->
metric
.
start
;
if
(
pMsg
->
code
==
TSDB_CODE_SUCCESS
)
{
tscDebug
(
"0x%"
PRIx64
" message:%s, code:%s rspLen:%d, elapsed:%d ms, reqId:0x%"
PRIx64
,
pRequest
->
requestId
,
tscDebug
(
"0x%"
PRIx64
" message:%s, code:%s rspLen:%d, elapsed:%d ms, reqId:0x%"
PRIx64
,
pRequest
->
self
,
TMSG_INFO
(
pMsg
->
msgType
),
tstrerror
(
pMsg
->
code
),
pMsg
->
contLen
,
elapsed
,
pRequest
->
requestId
);
}
else
{
tscError
(
"
reqId:0x%"
PRIx64
" SQL cmd:%s, code:%s rspLen:%d, elapsed time:%d ms, reqId:0x"
PRIx64
,
pRequest
->
requestId
,
tscError
(
"
0x%"
PRIx64
" SQL cmd:%s, code:%s rspLen:%d, elapsed time:%d ms, reqId:0x%"
PRIx64
,
pRequest
->
self
,
TMSG_INFO
(
pMsg
->
msgType
),
tstrerror
(
pMsg
->
code
),
pMsg
->
contLen
,
elapsed
,
pRequest
->
requestId
);
}
...
...
source/client/src/clientMain.c
浏览文件 @
0baa818e
...
...
@@ -262,6 +262,8 @@ const char *taos_data_type(int type) {
const
char
*
taos_get_client_info
()
{
return
version
;
}
int
taos_affected_rows
(
TAOS_RES
*
res
)
{
return
1
;
}
int
taos_affected_rows
(
TAOS_RES
*
res
)
{
return
((
SRequestObj
*
)
res
)
->
affectedRows
;
}
int
taos_result_precision
(
TAOS_RES
*
res
)
{
return
TSDB_TIME_PRECISION_MILLI
;
}
source/client/test/clientTests.cpp
浏览文件 @
0baa818e
...
...
@@ -496,6 +496,17 @@ TEST(testCase, create_multiple_tables) {
}
taos_free_result
(
pRes
);
// for(int32_t i = 0; i < 10000; ++i) {
// char sql[512] = {0};
// snprintf(sql, tListLen(sql), "create table t_x_%d using st1 tags(2)", i);
// TAOS_RES* pres = taos_query(pConn, sql);
// if (taos_errno(pres) != 0) {
// printf("failed to create table %d\n, reason:%s", i, taos_errstr(pres));
// }
// taos_free_result(pres);
// }
taos_close
(
pConn
);
}
...
...
@@ -506,7 +517,6 @@ TEST(testCase, generated_request_id_test) {
uint64_t
v
=
generateRequestId
();
void
*
result
=
taosHashGet
(
phash
,
&
v
,
sizeof
(
v
));
ASSERT_EQ
(
result
,
nullptr
);
taosHashPut
(
phash
,
&
v
,
sizeof
(
v
),
NULL
,
0
);
}
...
...
source/dnode/bnode/inc/bndInt.h
浏览文件 @
0baa818e
...
...
@@ -33,9 +33,9 @@ typedef struct SBnode {
int32_t
dnodeId
;
int64_t
clusterId
;
SBnodeCfg
cfg
;
Send
MsgToDnodeFp
sendMsg
ToDnodeFp
;
Send
MsgToMnodeFp
sendMsg
ToMnodeFp
;
SendRedirect
MsgFp
sendRedirectMsg
Fp
;
Send
ReqToDnodeFp
sendReq
ToDnodeFp
;
Send
ReqToMnodeFp
sendReq
ToMnodeFp
;
SendRedirect
RspFp
sendRedirectRsp
Fp
;
}
SBnode
;
#ifdef __cplusplus
...
...
source/dnode/mgmt/impl/inc/dndDnode.h
浏览文件 @
0baa818e
...
...
@@ -29,8 +29,8 @@ int64_t dndGetClusterId(SDnode *pDnode);
void
dndGetDnodeEp
(
SDnode
*
pDnode
,
int32_t
dnodeId
,
char
*
pEp
,
char
*
pFqdn
,
uint16_t
*
pPort
);
void
dndGetMnodeEpSet
(
SDnode
*
pDnode
,
SEpSet
*
pEpSet
);
void
dndSendRedirect
Msg
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
);
void
dndSendStatus
Msg
(
SDnode
*
pDnode
);
void
dndSendRedirect
Rsp
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
);
void
dndSendStatus
Req
(
SDnode
*
pDnode
);
void
dndProcessMgmtMsg
(
SDnode
*
pDnode
,
SRpcMsg
*
pRpcMsg
,
SEpSet
*
pEpSet
);
void
dndProcessStartupReq
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
);
...
...
source/dnode/mgmt/impl/inc/dndTransport.h
浏览文件 @
0baa818e
...
...
@@ -23,8 +23,8 @@ extern "C" {
int32_t
dndInitTrans
(
SDnode
*
pDnode
);
void
dndCleanupTrans
(
SDnode
*
pDnode
);
void
dndSendMsg
ToMnode
(
SDnode
*
pDnode
,
SRpcMsg
*
pRpcMsg
);
void
dndSendMsg
ToDnode
(
SDnode
*
pDnode
,
SEpSet
*
pEpSet
,
SRpcMsg
*
pRpcMsg
);
int32_t
dndSendReq
ToMnode
(
SDnode
*
pDnode
,
SRpcMsg
*
pRpcMsg
);
int32_t
dndSendReq
ToDnode
(
SDnode
*
pDnode
,
SEpSet
*
pEpSet
,
SRpcMsg
*
pRpcMsg
);
#ifdef __cplusplus
}
...
...
source/dnode/mgmt/impl/src/dndBnode.c
浏览文件 @
0baa818e
...
...
@@ -27,7 +27,7 @@ static SBnode *dndAcquireBnode(SDnode *pDnode) {
int32_t
refCount
=
0
;
taosRLockLatch
(
&
pMgmt
->
latch
);
if
(
pMgmt
->
deployed
&&
!
pMgmt
->
dropped
)
{
if
(
pMgmt
->
deployed
&&
!
pMgmt
->
dropped
&&
pMgmt
->
pBnode
!=
NULL
)
{
refCount
=
atomic_add_fetch_32
(
&
pMgmt
->
refCount
,
1
);
pBnode
=
pMgmt
->
pBnode
;
}
else
{
...
...
@@ -60,7 +60,7 @@ static int32_t dndReadBnodeFile(SDnode *pDnode) {
SBnodeMgmt
*
pMgmt
=
&
pDnode
->
bmgmt
;
int32_t
code
=
TSDB_CODE_DND_BNODE_READ_FILE_ERROR
;
int32_t
len
=
0
;
int32_t
maxLen
=
4096
;
int32_t
maxLen
=
1024
;
char
*
content
=
calloc
(
1
,
maxLen
+
1
);
cJSON
*
root
=
NULL
;
...
...
@@ -127,7 +127,7 @@ static int32_t dndWriteBnodeFile(SDnode *pDnode) {
}
int32_t
len
=
0
;
int32_t
maxLen
=
4096
;
int32_t
maxLen
=
1024
;
char
*
content
=
calloc
(
1
,
maxLen
+
1
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"{
\n
"
);
...
...
@@ -170,7 +170,7 @@ static void dndStopBnodeWorker(SDnode *pDnode) {
pMgmt
->
deployed
=
0
;
taosWUnLockLatch
(
&
pMgmt
->
latch
);
while
(
pMgmt
->
refCount
>
1
)
{
while
(
pMgmt
->
refCount
>
0
)
{
taosMsleep
(
10
);
}
...
...
@@ -179,9 +179,9 @@ static void dndStopBnodeWorker(SDnode *pDnode) {
static
void
dndBuildBnodeOption
(
SDnode
*
pDnode
,
SBnodeOpt
*
pOption
)
{
pOption
->
pDnode
=
pDnode
;
pOption
->
send
MsgToDnodeFp
=
dndSendMsg
ToDnode
;
pOption
->
send
MsgToMnodeFp
=
dndSendMsg
ToMnode
;
pOption
->
sendRedirect
MsgFp
=
dndSendRedirectMsg
;
pOption
->
send
ReqToDnodeFp
=
dndSendReq
ToDnode
;
pOption
->
send
ReqToMnodeFp
=
dndSendReq
ToMnode
;
pOption
->
sendRedirect
RspFp
=
dndSendRedirectRsp
;
pOption
->
dnodeId
=
dndGetDnodeId
(
pDnode
);
pOption
->
clusterId
=
dndGetClusterId
(
pDnode
);
pOption
->
cfg
.
sver
=
pDnode
->
opt
.
sver
;
...
...
@@ -189,10 +189,18 @@ static void dndBuildBnodeOption(SDnode *pDnode, SBnodeOpt *pOption) {
static
int32_t
dndOpenBnode
(
SDnode
*
pDnode
)
{
SBnodeMgmt
*
pMgmt
=
&
pDnode
->
bmgmt
;
SBnodeOpt
option
=
{
0
};
SBnode
*
pBnode
=
dndAcquireBnode
(
pDnode
);
if
(
pBnode
!=
NULL
)
{
dndReleaseBnode
(
pDnode
,
pBnode
);
terrno
=
TSDB_CODE_DND_BNODE_ALREADY_DEPLOYED
;
dError
(
"failed to create bnode since %s"
,
terrstr
());
return
-
1
;
}
SBnodeOpt
option
=
{
0
};
dndBuildBnodeOption
(
pDnode
,
&
option
);
SBnode
*
pBnode
=
bndOpen
(
pDnode
->
dir
.
bnode
,
&
option
);
pBnode
=
bndOpen
(
pDnode
->
dir
.
bnode
,
&
option
);
if
(
pBnode
==
NULL
)
{
dError
(
"failed to open bnode since %s"
,
terrstr
());
return
-
1
;
...
...
@@ -256,11 +264,12 @@ static int32_t dndDropBnode(SDnode *pDnode) {
}
int32_t
dndProcessCreateBnodeReq
(
SDnode
*
pDnode
,
SRpcMsg
*
pRpcMsg
)
{
SDCreateBnode
Msg
*
pMsg
=
pRpcMsg
->
pCont
;
SDCreateBnode
Req
*
pMsg
=
pRpcMsg
->
pCont
;
pMsg
->
dnodeId
=
htonl
(
pMsg
->
dnodeId
);
if
(
pMsg
->
dnodeId
!=
dndGetDnodeId
(
pDnode
))
{
terrno
=
TSDB_CODE_DND_BNODE_ID_INVALID
;
dError
(
"failed to create bnode since %s"
,
terrstr
());
return
-
1
;
}
else
{
return
dndOpenBnode
(
pDnode
);
...
...
@@ -268,11 +277,12 @@ int32_t dndProcessCreateBnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) {
}
int32_t
dndProcessDropBnodeReq
(
SDnode
*
pDnode
,
SRpcMsg
*
pRpcMsg
)
{
SDDropBnode
Msg
*
pMsg
=
pRpcMsg
->
pCont
;
SDDropBnode
Req
*
pMsg
=
pRpcMsg
->
pCont
;
pMsg
->
dnodeId
=
htonl
(
pMsg
->
dnodeId
);
if
(
pMsg
->
dnodeId
!=
dndGetDnodeId
(
pDnode
))
{
terrno
=
TSDB_CODE_DND_BNODE_ID_INVALID
;
dError
(
"failed to drop bnode since %s"
,
terrstr
());
return
-
1
;
}
else
{
return
dndDropBnode
(
pDnode
);
...
...
source/dnode/mgmt/impl/src/dndDnode.c
浏览文件 @
0baa818e
...
...
@@ -80,7 +80,7 @@ void dndGetMnodeEpSet(SDnode *pDnode, SEpSet *pEpSet) {
taosRUnLockLatch
(
&
pMgmt
->
latch
);
}
void
dndSendRedirect
Msg
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
)
{
void
dndSendRedirect
Rsp
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
)
{
tmsg_t
msgType
=
pMsg
->
msgType
;
SEpSet
epSet
=
{
0
};
...
...
@@ -354,7 +354,7 @@ static int32_t dndWriteDnodes(SDnode *pDnode) {
return
0
;
}
void
dndSendStatus
Msg
(
SDnode
*
pDnode
)
{
void
dndSendStatus
Req
(
SDnode
*
pDnode
)
{
int32_t
contLen
=
sizeof
(
SStatusMsg
)
+
TSDB_MAX_VNODES
*
sizeof
(
SVnodeLoad
);
SStatusMsg
*
pStatus
=
rpcMallocCont
(
contLen
);
...
...
@@ -391,7 +391,7 @@ void dndSendStatusMsg(SDnode *pDnode) {
pMgmt
->
statusSent
=
1
;
dTrace
(
"pDnode:%p, send status msg to mnode"
,
pDnode
);
dndSend
Msg
ToMnode
(
pDnode
,
&
rpcMsg
);
dndSend
Req
ToMnode
(
pDnode
,
&
rpcMsg
);
}
static
void
dndUpdateDnodeCfg
(
SDnode
*
pDnode
,
SDnodeCfg
*
pCfg
)
{
...
...
@@ -491,7 +491,7 @@ static void *dnodeThreadRoutine(void *param) {
taosMsleep
(
ms
);
if
(
dndGetStat
(
pDnode
)
==
DND_STAT_RUNNING
&&
!
pMgmt
->
statusSent
&&
!
pMgmt
->
dropped
)
{
dndSendStatus
Msg
(
pDnode
);
dndSendStatus
Req
(
pDnode
);
}
}
}
...
...
source/dnode/mgmt/impl/src/dndMnode.c
浏览文件 @
0baa818e
...
...
@@ -19,6 +19,7 @@
#include "dndTransport.h"
#include "dndWorker.h"
static
void
dndWriteMnodeMsgToWorker
(
SDnode
*
pDnode
,
SDnodeWorker
*
pWorker
,
SRpcMsg
*
pRpcMsg
);
static
void
dndProcessMnodeQueue
(
SDnode
*
pDnode
,
SMnodeMsg
*
pMsg
);
static
SMnode
*
dndAcquireMnode
(
SDnode
*
pDnode
)
{
...
...
@@ -258,11 +259,16 @@ static bool dndNeedDeployMnode(SDnode *pDnode) {
return
true
;
}
static
int32_t
dndPutMsgToMWriteQ
(
SDnode
*
pDnode
,
SRpcMsg
*
pRpcMsg
)
{
dndWriteMnodeMsgToWorker
(
pDnode
,
&
pDnode
->
mmgmt
.
writeWorker
,
pRpcMsg
);
}
static
void
dndInitMnodeOption
(
SDnode
*
pDnode
,
SMnodeOpt
*
pOption
)
{
pOption
->
pDnode
=
pDnode
;
pOption
->
sendMsgToDnodeFp
=
dndSendMsgToDnode
;
pOption
->
sendMsgToMnodeFp
=
dndSendMsgToMnode
;
pOption
->
sendRedirectMsgFp
=
dndSendRedirectMsg
;
pOption
->
sendReqToDnodeFp
=
dndSendReqToDnode
;
pOption
->
sendReqToMnodeFp
=
dndSendReqToMnode
;
pOption
->
sendRedirectRspFp
=
dndSendRedirectRsp
;
pOption
->
putReqToMWriteQFp
=
dndPutMsgToMWriteQ
;
pOption
->
dnodeId
=
dndGetDnodeId
(
pDnode
);
pOption
->
clusterId
=
dndGetClusterId
(
pDnode
);
pOption
->
cfg
.
sver
=
pDnode
->
opt
.
sver
;
...
...
source/dnode/mgmt/impl/src/dndQnode.c
浏览文件 @
0baa818e
...
...
@@ -27,7 +27,7 @@ static SQnode *dndAcquireQnode(SDnode *pDnode) {
int32_t
refCount
=
0
;
taosRLockLatch
(
&
pMgmt
->
latch
);
if
(
pMgmt
->
deployed
&&
!
pMgmt
->
dropped
)
{
if
(
pMgmt
->
deployed
&&
!
pMgmt
->
dropped
&&
pMgmt
->
pQnode
!=
NULL
)
{
refCount
=
atomic_add_fetch_32
(
&
pMgmt
->
refCount
,
1
);
pQnode
=
pMgmt
->
pQnode
;
}
else
{
...
...
@@ -60,7 +60,7 @@ static int32_t dndReadQnodeFile(SDnode *pDnode) {
SQnodeMgmt
*
pMgmt
=
&
pDnode
->
qmgmt
;
int32_t
code
=
TSDB_CODE_DND_QNODE_READ_FILE_ERROR
;
int32_t
len
=
0
;
int32_t
maxLen
=
4096
;
int32_t
maxLen
=
1024
;
char
*
content
=
calloc
(
1
,
maxLen
+
1
);
cJSON
*
root
=
NULL
;
...
...
@@ -127,7 +127,7 @@ static int32_t dndWriteQnodeFile(SDnode *pDnode) {
}
int32_t
len
=
0
;
int32_t
maxLen
=
4096
;
int32_t
maxLen
=
1024
;
char
*
content
=
calloc
(
1
,
maxLen
+
1
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"{
\n
"
);
...
...
@@ -175,7 +175,7 @@ static void dndStopQnodeWorker(SDnode *pDnode) {
pMgmt
->
deployed
=
0
;
taosWUnLockLatch
(
&
pMgmt
->
latch
);
while
(
pMgmt
->
refCount
>
1
)
{
while
(
pMgmt
->
refCount
>
0
)
{
taosMsleep
(
10
);
}
...
...
@@ -185,9 +185,9 @@ static void dndStopQnodeWorker(SDnode *pDnode) {
static
void
dndBuildQnodeOption
(
SDnode
*
pDnode
,
SQnodeOpt
*
pOption
)
{
pOption
->
pDnode
=
pDnode
;
pOption
->
send
MsgToDnodeFp
=
dndSendMsg
ToDnode
;
pOption
->
send
MsgToMnodeFp
=
dndSendMsg
ToMnode
;
pOption
->
sendRedirect
MsgFp
=
dndSendRedirectMsg
;
pOption
->
send
ReqToDnodeFp
=
dndSendReq
ToDnode
;
pOption
->
send
ReqToMnodeFp
=
dndSendReq
ToMnode
;
pOption
->
sendRedirect
RspFp
=
dndSendRedirectRsp
;
pOption
->
dnodeId
=
dndGetDnodeId
(
pDnode
);
pOption
->
clusterId
=
dndGetClusterId
(
pDnode
);
pOption
->
cfg
.
sver
=
pDnode
->
opt
.
sver
;
...
...
@@ -195,10 +195,19 @@ static void dndBuildQnodeOption(SDnode *pDnode, SQnodeOpt *pOption) {
static
int32_t
dndOpenQnode
(
SDnode
*
pDnode
)
{
SQnodeMgmt
*
pMgmt
=
&
pDnode
->
qmgmt
;
SQnodeOpt
option
=
{
0
};
SQnode
*
pQnode
=
dndAcquireQnode
(
pDnode
);
if
(
pQnode
!=
NULL
)
{
dndReleaseQnode
(
pDnode
,
pQnode
);
terrno
=
TSDB_CODE_DND_QNODE_ALREADY_DEPLOYED
;
dError
(
"failed to create qnode since %s"
,
terrstr
());
return
-
1
;
}
SQnodeOpt
option
=
{
0
};
dndBuildQnodeOption
(
pDnode
,
&
option
);
SQnode
*
pQnode
=
qndOpen
(
&
option
);
pQnode
=
qndOpen
(
&
option
);
if
(
pQnode
==
NULL
)
{
dError
(
"failed to open qnode since %s"
,
terrstr
());
return
-
1
;
...
...
@@ -261,11 +270,12 @@ static int32_t dndDropQnode(SDnode *pDnode) {
}
int32_t
dndProcessCreateQnodeReq
(
SDnode
*
pDnode
,
SRpcMsg
*
pRpcMsg
)
{
SDCreateQnode
Msg
*
pMsg
=
pRpcMsg
->
pCont
;
SDCreateQnode
Req
*
pMsg
=
pRpcMsg
->
pCont
;
pMsg
->
dnodeId
=
htonl
(
pMsg
->
dnodeId
);
if
(
pMsg
->
dnodeId
!=
dndGetDnodeId
(
pDnode
))
{
terrno
=
TSDB_CODE_DND_QNODE_ID_INVALID
;
dError
(
"failed to create qnode since %s"
,
terrstr
());
return
-
1
;
}
else
{
return
dndOpenQnode
(
pDnode
);
...
...
@@ -273,11 +283,12 @@ int32_t dndProcessCreateQnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) {
}
int32_t
dndProcessDropQnodeReq
(
SDnode
*
pDnode
,
SRpcMsg
*
pRpcMsg
)
{
SDDropQnode
Msg
*
pMsg
=
pRpcMsg
->
pCont
;
SDDropQnode
Req
*
pMsg
=
pRpcMsg
->
pCont
;
pMsg
->
dnodeId
=
htonl
(
pMsg
->
dnodeId
);
if
(
pMsg
->
dnodeId
!=
dndGetDnodeId
(
pDnode
))
{
terrno
=
TSDB_CODE_DND_QNODE_ID_INVALID
;
dError
(
"failed to drop qnode since %s"
,
terrstr
());
return
-
1
;
}
else
{
return
dndDropQnode
(
pDnode
);
...
...
@@ -293,6 +304,7 @@ static void dndProcessQnodeQueue(SDnode *pDnode, SRpcMsg *pMsg) {
if
(
pQnode
!=
NULL
)
{
code
=
qndProcessMsg
(
pQnode
,
pMsg
,
&
pRsp
);
}
dndReleaseQnode
(
pDnode
,
pQnode
);
if
(
pRsp
!=
NULL
)
{
pRsp
->
ahandle
=
pMsg
->
ahandle
;
...
...
source/dnode/mgmt/impl/src/dndSnode.c
浏览文件 @
0baa818e
...
...
@@ -27,7 +27,7 @@ static SSnode *dndAcquireSnode(SDnode *pDnode) {
int32_t
refCount
=
0
;
taosRLockLatch
(
&
pMgmt
->
latch
);
if
(
pMgmt
->
deployed
&&
!
pMgmt
->
dropped
)
{
if
(
pMgmt
->
deployed
&&
!
pMgmt
->
dropped
&&
pMgmt
->
pSnode
!=
NULL
)
{
refCount
=
atomic_add_fetch_32
(
&
pMgmt
->
refCount
,
1
);
pSnode
=
pMgmt
->
pSnode
;
}
else
{
...
...
@@ -60,7 +60,7 @@ static int32_t dndReadSnodeFile(SDnode *pDnode) {
SSnodeMgmt
*
pMgmt
=
&
pDnode
->
smgmt
;
int32_t
code
=
TSDB_CODE_DND_SNODE_READ_FILE_ERROR
;
int32_t
len
=
0
;
int32_t
maxLen
=
4096
;
int32_t
maxLen
=
1024
;
char
*
content
=
calloc
(
1
,
maxLen
+
1
);
cJSON
*
root
=
NULL
;
...
...
@@ -127,7 +127,7 @@ static int32_t dndWriteSnodeFile(SDnode *pDnode) {
}
int32_t
len
=
0
;
int32_t
maxLen
=
4096
;
int32_t
maxLen
=
1024
;
char
*
content
=
calloc
(
1
,
maxLen
+
1
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"{
\n
"
);
...
...
@@ -170,18 +170,18 @@ static void dndStopSnodeWorker(SDnode *pDnode) {
pMgmt
->
deployed
=
0
;
taosWUnLockLatch
(
&
pMgmt
->
latch
);
while
(
pMgmt
->
refCount
>
1
)
{
while
(
pMgmt
->
refCount
>
0
)
{
taosMsleep
(
10
);
}
}
dndCleanupWorker
(
&
pMgmt
->
writeWorker
);
}
static
void
dndBuildSnodeOption
(
SDnode
*
pDnode
,
SSnodeOpt
*
pOption
)
{
pOption
->
pDnode
=
pDnode
;
pOption
->
send
MsgToDnodeFp
=
dndSendMsg
ToDnode
;
pOption
->
send
MsgToMnodeFp
=
dndSendMsg
ToMnode
;
pOption
->
sendRedirect
MsgFp
=
dndSendRedirectMsg
;
pOption
->
send
ReqToDnodeFp
=
dndSendReq
ToDnode
;
pOption
->
send
ReqToMnodeFp
=
dndSendReq
ToMnode
;
pOption
->
sendRedirect
RspFp
=
dndSendRedirectRsp
;
pOption
->
dnodeId
=
dndGetDnodeId
(
pDnode
);
pOption
->
clusterId
=
dndGetClusterId
(
pDnode
);
pOption
->
cfg
.
sver
=
pDnode
->
opt
.
sver
;
...
...
@@ -189,10 +189,18 @@ static void dndBuildSnodeOption(SDnode *pDnode, SSnodeOpt *pOption) {
static
int32_t
dndOpenSnode
(
SDnode
*
pDnode
)
{
SSnodeMgmt
*
pMgmt
=
&
pDnode
->
smgmt
;
SSnodeOpt
option
=
{
0
};
SSnode
*
pSnode
=
dndAcquireSnode
(
pDnode
);
if
(
pSnode
!=
NULL
)
{
dndReleaseSnode
(
pDnode
,
pSnode
);
terrno
=
TSDB_CODE_DND_SNODE_ALREADY_DEPLOYED
;
dError
(
"failed to create snode since %s"
,
terrstr
());
return
-
1
;
}
SSnodeOpt
option
=
{
0
};
dndBuildSnodeOption
(
pDnode
,
&
option
);
SSnode
*
pSnode
=
sndOpen
(
pDnode
->
dir
.
snode
,
&
option
);
pSnode
=
sndOpen
(
pDnode
->
dir
.
snode
,
&
option
);
if
(
pSnode
==
NULL
)
{
dError
(
"failed to open snode since %s"
,
terrstr
());
return
-
1
;
...
...
@@ -256,11 +264,12 @@ static int32_t dndDropSnode(SDnode *pDnode) {
}
int32_t
dndProcessCreateSnodeReq
(
SDnode
*
pDnode
,
SRpcMsg
*
pRpcMsg
)
{
SDCreateSnode
Msg
*
pMsg
=
pRpcMsg
->
pCont
;
SDCreateSnode
Req
*
pMsg
=
pRpcMsg
->
pCont
;
pMsg
->
dnodeId
=
htonl
(
pMsg
->
dnodeId
);
if
(
pMsg
->
dnodeId
!=
dndGetDnodeId
(
pDnode
))
{
terrno
=
TSDB_CODE_DND_SNODE_ID_INVALID
;
dError
(
"failed to create snode since %s"
,
terrstr
());
return
-
1
;
}
else
{
return
dndOpenSnode
(
pDnode
);
...
...
@@ -268,11 +277,12 @@ int32_t dndProcessCreateSnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) {
}
int32_t
dndProcessDropSnodeReq
(
SDnode
*
pDnode
,
SRpcMsg
*
pRpcMsg
)
{
SDDropSnode
Msg
*
pMsg
=
pRpcMsg
->
pCont
;
SDDropSnode
Req
*
pMsg
=
pRpcMsg
->
pCont
;
pMsg
->
dnodeId
=
htonl
(
pMsg
->
dnodeId
);
if
(
pMsg
->
dnodeId
!=
dndGetDnodeId
(
pDnode
))
{
terrno
=
TSDB_CODE_DND_SNODE_ID_INVALID
;
dError
(
"failed to drop snode since %s"
,
terrstr
());
return
-
1
;
}
else
{
return
dndDropSnode
(
pDnode
);
...
...
@@ -288,6 +298,7 @@ static void dndProcessSnodeQueue(SDnode *pDnode, SRpcMsg *pMsg) {
if
(
pSnode
!=
NULL
)
{
code
=
sndProcessMsg
(
pSnode
,
pMsg
,
&
pRsp
);
}
dndReleaseSnode
(
pDnode
,
pSnode
);
if
(
pRsp
!=
NULL
)
{
pRsp
->
ahandle
=
pMsg
->
ahandle
;
...
...
source/dnode/mgmt/impl/src/dndTransport.c
浏览文件 @
0baa818e
...
...
@@ -105,8 +105,6 @@ static void dndInitMsgFp(STransMgmt *pMgmt) {
pMgmt
->
msgFp
[
TMSG_INDEX
(
TDMT_MND_SHOW_RETRIEVE
)]
=
dndProcessMnodeReadMsg
;
pMgmt
->
msgFp
[
TMSG_INDEX
(
TDMT_MND_STATUS
)]
=
dndProcessMnodeReadMsg
;
pMgmt
->
msgFp
[
TMSG_INDEX
(
TDMT_MND_STATUS_RSP
)]
=
dndProcessMgmtMsg
;
pMgmt
->
msgFp
[
TMSG_INDEX
(
TDMT_MND_TRANS
)]
=
dndProcessMnodeWriteMsg
;
pMgmt
->
msgFp
[
TMSG_INDEX
(
TDMT_MND_TRANS_RSP
)]
=
dndProcessMnodeWriteMsg
;
pMgmt
->
msgFp
[
TMSG_INDEX
(
TDMT_MND_GRANT
)]
=
dndProcessMnodeWriteMsg
;
pMgmt
->
msgFp
[
TMSG_INDEX
(
TDMT_MND_GRANT_RSP
)]
=
dndProcessMgmtMsg
;
pMgmt
->
msgFp
[
TMSG_INDEX
(
TDMT_MND_AUTH
)]
=
dndProcessMnodeReadMsg
;
...
...
@@ -216,7 +214,7 @@ static void dndProcessRequest(void *param, SRpcMsg *pMsg, SEpSet *pEpSet) {
if
(
dndGetStat
(
pDnode
)
==
DND_STAT_STOPPED
)
{
dError
(
"RPC %p, req:%s app:%p is ignored since dnode exiting"
,
pMsg
->
handle
,
TMSG_INFO
(
msgType
),
pMsg
->
ahandle
);
SRpcMsg
rspMsg
=
{.
handle
=
pMsg
->
handle
,
.
code
=
TSDB_CODE_DND_
EXITING
};
SRpcMsg
rspMsg
=
{.
handle
=
pMsg
->
handle
,
.
code
=
TSDB_CODE_DND_
OFFLINE
};
rpcSendResponse
(
&
rspMsg
);
rpcFreeCont
(
pMsg
->
pCont
);
return
;
...
...
@@ -383,14 +381,19 @@ void dndCleanupTrans(SDnode *pDnode) {
dInfo
(
"dnode-transport is cleaned up"
);
}
void
dndSendMsg
ToDnode
(
SDnode
*
pDnode
,
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
)
{
int32_t
dndSendReq
ToDnode
(
SDnode
*
pDnode
,
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
)
{
STransMgmt
*
pMgmt
=
&
pDnode
->
tmgmt
;
if
(
pMgmt
->
clientRpc
==
NULL
)
return
;
if
(
pMgmt
->
clientRpc
==
NULL
)
{
terrno
=
TSDB_CODE_DND_OFFLINE
;
return
-
1
;
}
rpcSendRequest
(
pMgmt
->
clientRpc
,
pEpSet
,
pMsg
,
NULL
);
return
0
;
}
void
dndSendMsg
ToMnode
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
)
{
int32_t
dndSendReq
ToMnode
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
)
{
SEpSet
epSet
=
{
0
};
dndGetMnodeEpSet
(
pDnode
,
&
epSet
);
dndSendMsg
ToDnode
(
pDnode
,
&
epSet
,
pMsg
);
return
dndSendReq
ToDnode
(
pDnode
,
&
epSet
,
pMsg
);
}
source/dnode/mgmt/impl/src/dnode.c
浏览文件 @
0baa818e
...
...
@@ -14,8 +14,11 @@
*/
#define _DEFAULT_SOURCE
#include "dndBnode.h"
#include "dndDnode.h"
#include "dndMnode.h"
#include "dndQnode.h"
#include "dndSnode.h"
#include "dndTransport.h"
#include "dndVnodes.h"
#include "sync.h"
...
...
@@ -200,6 +203,24 @@ SDnode *dndInit(SDnodeOpt *pOption) {
return
NULL
;
}
if
(
dndInitQnode
(
pDnode
)
!=
0
)
{
dError
(
"failed to init qnode"
);
dndCleanup
(
pDnode
);
return
NULL
;
}
if
(
dndInitSnode
(
pDnode
)
!=
0
)
{
dError
(
"failed to init snode"
);
dndCleanup
(
pDnode
);
return
NULL
;
}
if
(
dndInitBnode
(
pDnode
)
!=
0
)
{
dError
(
"failed to init bnode"
);
dndCleanup
(
pDnode
);
return
NULL
;
}
if
(
dndInitMnode
(
pDnode
)
!=
0
)
{
dError
(
"failed to init mnode"
);
dndCleanup
(
pDnode
);
...
...
@@ -213,7 +234,7 @@ SDnode *dndInit(SDnodeOpt *pOption) {
}
dndSetStat
(
pDnode
,
DND_STAT_RUNNING
);
dndSendStatus
Msg
(
pDnode
);
dndSendStatus
Req
(
pDnode
);
dndReportStartup
(
pDnode
,
"TDengine"
,
"initialized successfully"
);
dInfo
(
"TDengine is initialized successfully, pDnode:%p"
,
pDnode
);
...
...
@@ -232,6 +253,9 @@ void dndCleanup(SDnode *pDnode) {
dndSetStat
(
pDnode
,
DND_STAT_STOPPED
);
dndCleanupTrans
(
pDnode
);
dndCleanupMnode
(
pDnode
);
dndCleanupBnode
(
pDnode
);
dndCleanupSnode
(
pDnode
);
dndCleanupQnode
(
pDnode
);
dndCleanupVnodes
(
pDnode
);
dndCleanupDnode
(
pDnode
);
vnodeClear
();
...
...
source/dnode/mgmt/impl/test/CMakeLists.txt
浏览文件 @
0baa818e
enable_testing
()
add_subdirectory
(
qnode
)
# add_subdirectory(auth)
# add_subdirectory(balance)
add_subdirectory
(
cluster
)
...
...
@@ -7,9 +9,6 @@ add_subdirectory(db)
add_subdirectory
(
dnode
)
# add_subdirectory(func)
add_subdirectory
(
mnode
)
add_subdirectory
(
qnode
)
add_subdirectory
(
snode
)
add_subdirectory
(
bnode
)
add_subdirectory
(
profile
)
add_subdirectory
(
show
)
add_subdirectory
(
stb
)
...
...
source/dnode/mgmt/impl/test/bnode/bnode.cpp
浏览文件 @
0baa818e
...
...
@@ -9,7 +9,7 @@
*
*/
#include "
base
.h"
#include "
sut
.h"
class
DndTestBnode
:
public
::
testing
::
Test
{
public:
...
...
@@ -52,9 +52,9 @@ TEST_F(DndTestBnode, 01_ShowBnode) {
TEST_F
(
DndTestBnode
,
02
_Create_Bnode_Invalid_Id
)
{
{
int32_t
contLen
=
sizeof
(
SMCreateBnode
Msg
);
int32_t
contLen
=
sizeof
(
SMCreateBnode
Req
);
SMCreateBnode
Msg
*
pReq
=
(
SMCreateBnodeMsg
*
)
rpcMallocCont
(
contLen
);
SMCreateBnode
Req
*
pReq
=
(
SMCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
...
...
@@ -79,9 +79,9 @@ TEST_F(DndTestBnode, 02_Create_Bnode_Invalid_Id) {
TEST_F
(
DndTestBnode
,
03
_Create_Bnode_Invalid_Id
)
{
{
int32_t
contLen
=
sizeof
(
SMCreateBnode
Msg
);
int32_t
contLen
=
sizeof
(
SMCreateBnode
Req
);
SMCreateBnode
Msg
*
pReq
=
(
SMCreateBnodeMsg
*
)
rpcMallocCont
(
contLen
);
SMCreateBnode
Req
*
pReq
=
(
SMCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
...
...
@@ -111,9 +111,9 @@ TEST_F(DndTestBnode, 04_Create_Bnode) {
{
// create bnode
int32_t
contLen
=
sizeof
(
SMCreateBnode
Msg
);
int32_t
contLen
=
sizeof
(
SMCreateBnode
Req
);
SMCreateBnode
Msg
*
pReq
=
(
SMCreateBnodeMsg
*
)
rpcMallocCont
(
contLen
);
SMCreateBnode
Req
*
pReq
=
(
SMCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
...
...
@@ -134,9 +134,9 @@ TEST_F(DndTestBnode, 04_Create_Bnode) {
{
// drop bnode
int32_t
contLen
=
sizeof
(
SMDropBnode
Msg
);
int32_t
contLen
=
sizeof
(
SMDropBnode
Req
);
SMDropBnode
Msg
*
pReq
=
(
SMDropBnodeMsg
*
)
rpcMallocCont
(
contLen
);
SMDropBnode
Req
*
pReq
=
(
SMDropBnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_DROP_BNODE
,
pReq
,
contLen
);
...
...
source/dnode/mgmt/impl/test/cluster/cluster.cpp
浏览文件 @
0baa818e
...
...
@@ -9,7 +9,7 @@
*
*/
#include "
base
.h"
#include "
sut
.h"
class
DndTestCluster
:
public
::
testing
::
Test
{
protected:
...
...
source/dnode/mgmt/impl/test/db/db.cpp
浏览文件 @
0baa818e
...
...
@@ -9,7 +9,7 @@
*
*/
#include "
base
.h"
#include "
sut
.h"
class
DndTestDb
:
public
::
testing
::
Test
{
protected:
...
...
source/dnode/mgmt/impl/test/dnode/dnode.cpp
浏览文件 @
0baa818e
...
...
@@ -9,7 +9,7 @@
*
*/
#include "
base
.h"
#include "
sut
.h"
class
DndTestDnode
:
public
::
testing
::
Test
{
public:
...
...
source/dnode/mgmt/impl/test/mnode/mnode.cpp
浏览文件 @
0baa818e
...
...
@@ -9,7 +9,7 @@
*
*/
#include "
base
.h"
#include "
sut
.h"
class
DndTestMnode
:
public
::
testing
::
Test
{
public:
...
...
source/dnode/mgmt/impl/test/profile/profile.cpp
浏览文件 @
0baa818e
...
...
@@ -9,7 +9,7 @@
*
*/
#include "
base
.h"
#include "
sut
.h"
class
DndTestProfile
:
public
::
testing
::
Test
{
protected:
...
...
source/dnode/mgmt/impl/test/qnode/CMakeLists.txt
浏览文件 @
0baa818e
aux_source_directory
(
. QTEST_SRC
)
add_executable
(
dnode_test_qnode
${
QTEST_SRC
}
)
aux_source_directory
(
.
D
QTEST_SRC
)
add_executable
(
dnode_test_qnode
${
D
QTEST_SRC
}
)
target_link_libraries
(
dnode_test_qnode
PUBLIC sut
...
...
source/dnode/mgmt/impl/test/qnode/dqnode.cpp
0 → 100644
浏览文件 @
0baa818e
/**
* @file dqnode.cpp
* @author slguan (slguan@taosdata.com)
* @brief DNODE module qnode tests
* @version 1.0
* @date 2022-01-05
*
* @copyright Copyright (c) 2022
*
*/
#include "sut.h"
class
DndTestQnode
:
public
::
testing
::
Test
{
protected:
static
void
SetUpTestSuite
()
{
test
.
Init
(
"/tmp/dnode_test_qnode"
,
9111
);
}
static
void
TearDownTestSuite
()
{
test
.
Cleanup
();
}
static
Testbase
test
;
public:
void
SetUp
()
override
{}
void
TearDown
()
override
{}
};
Testbase
DndTestQnode
::
test
;
TEST_F
(
DndTestQnode
,
01
_Create_Qnode_Invalid
)
{
{
int32_t
contLen
=
sizeof
(
SDCreateQnodeReq
);
SDCreateQnodeReq
*
pReq
=
(
SDCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_DND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
TSDB_CODE_DND_QNODE_ID_INVALID
);
}
{
int32_t
contLen
=
sizeof
(
SDCreateQnodeReq
);
SDCreateQnodeReq
*
pReq
=
(
SDCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_DND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
}
{
int32_t
contLen
=
sizeof
(
SDCreateQnodeReq
);
SDCreateQnodeReq
*
pReq
=
(
SDCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_DND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
TSDB_CODE_DND_QNODE_ALREADY_DEPLOYED
);
}
test
.
Restart
();
{
int32_t
contLen
=
sizeof
(
SDCreateQnodeReq
);
SDCreateQnodeReq
*
pReq
=
(
SDCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_DND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
TSDB_CODE_DND_QNODE_ALREADY_DEPLOYED
);
}
}
\ No newline at end of file
source/dnode/mgmt/impl/test/show/show.cpp
浏览文件 @
0baa818e
...
...
@@ -9,7 +9,7 @@
*
*/
#include "
base
.h"
#include "
sut
.h"
class
DndTestShow
:
public
::
testing
::
Test
{
protected:
...
...
source/dnode/mgmt/impl/test/stb/stb.cpp
浏览文件 @
0baa818e
...
...
@@ -9,7 +9,7 @@
*
*/
#include "
base
.h"
#include "
sut
.h"
class
DndTestStb
:
public
::
testing
::
Test
{
protected:
...
...
source/dnode/mgmt/impl/test/sut/inc/server.h
浏览文件 @
0baa818e
...
...
@@ -21,10 +21,10 @@ class TestServer {
bool
Start
(
const
char
*
path
,
const
char
*
fqdn
,
uint16_t
port
,
const
char
*
firstEp
);
void
Stop
();
void
Restart
();
bool
DoStart
();
private:
SDnodeOpt
BuildOption
(
const
char
*
path
,
const
char
*
fqdn
,
uint16_t
port
,
const
char
*
firstEp
);
bool
DoStart
();
private:
SDnode
*
pDnode
;
...
...
source/dnode/mgmt/impl/test/sut/inc/
base
.h
→
source/dnode/mgmt/impl/test/sut/inc/
sut
.h
浏览文件 @
0baa818e
...
...
@@ -37,6 +37,8 @@ class Testbase {
void
Init
(
const
char
*
path
,
int16_t
port
);
void
Cleanup
();
void
Restart
();
void
ServerStop
();
void
ServerStart
();
SRpcMsg
*
SendMsg
(
tmsg_t
msgType
,
void
*
pCont
,
int32_t
contLen
);
private:
...
...
source/dnode/mgmt/impl/test/sut/src/client.cpp
浏览文件 @
0baa818e
...
...
@@ -13,7 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "
base
.h"
#include "
sut
.h"
static
void
processClientRsp
(
void
*
parent
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
)
{
TestClient
*
client
=
(
TestClient
*
)
parent
;
...
...
source/dnode/mgmt/impl/test/sut/src/server.cpp
浏览文件 @
0baa818e
...
...
@@ -13,7 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "
base
.h"
#include "
sut
.h"
void
*
serverLoop
(
void
*
param
)
{
while
(
1
)
{
...
...
source/dnode/mgmt/impl/test/sut/src/
base
.cpp
→
source/dnode/mgmt/impl/test/sut/src/
sut
.cpp
浏览文件 @
0baa818e
...
...
@@ -13,16 +13,16 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "
base
.h"
#include "
sut
.h"
void
Testbase
::
InitLog
(
const
char
*
path
)
{
dDebugFlag
=
207
;
dDebugFlag
=
0
;
vDebugFlag
=
0
;
mDebugFlag
=
207
;
mDebugFlag
=
143
;
cDebugFlag
=
0
;
jniDebugFlag
=
0
;
tmrDebugFlag
=
0
;
uDebugFlag
=
143
;
uDebugFlag
=
0
;
rpcDebugFlag
=
0
;
qDebugFlag
=
0
;
wDebugFlag
=
0
;
...
...
@@ -60,6 +60,10 @@ void Testbase::Cleanup() {
void
Testbase
::
Restart
()
{
server
.
Restart
();
}
void
Testbase
::
ServerStop
()
{
server
.
Stop
();
}
void
Testbase
::
ServerStart
()
{
server
.
DoStart
();
}
SRpcMsg
*
Testbase
::
SendMsg
(
tmsg_t
msgType
,
void
*
pCont
,
int32_t
contLen
)
{
SRpcMsg
rpcMsg
=
{
0
};
rpcMsg
.
pCont
=
pCont
;
...
...
source/dnode/mgmt/impl/test/vgroup/vgroup.cpp
浏览文件 @
0baa818e
...
...
@@ -9,7 +9,7 @@
*
*/
#include "
base
.h"
#include "
sut
.h"
class
DndTestVgroup
:
public
::
testing
::
Test
{
protected:
...
...
source/dnode/mnode/impl/inc/mndInt.h
浏览文件 @
0baa818e
...
...
@@ -91,15 +91,16 @@ typedef struct SMnode {
STelemMgmt
telemMgmt
;
SSyncMgmt
syncMgmt
;
MndMsgFp
msgFp
[
TDMT_MAX
];
SendMsgToDnodeFp
sendMsgToDnodeFp
;
SendMsgToMnodeFp
sendMsgToMnodeFp
;
SendRedirectMsgFp
sendRedirectMsgFp
;
SendReqToDnodeFp
sendReqToDnodeFp
;
SendReqToMnodeFp
sendReqToMnodeFp
;
SendRedirectRspFp
sendRedirectRspFp
;
PutReqToMWriteQFp
putReqToMWriteQFp
;
}
SMnode
;
void
mndSendMsg
ToDnode
(
SMnode
*
pMnode
,
SEpSet
*
pEpSet
,
SRpcMsg
*
rpcMsg
);
void
mndSendMsg
ToMnode
(
SMnode
*
pMnode
,
SRpcMsg
*
pMsg
);
void
mndSendRedirectMsg
(
SMnode
*
pMnode
,
SRpcMsg
*
pMsg
);
void
mndSetMsgHandle
(
SMnode
*
pMnode
,
tmsg_t
msgType
,
MndMsgFp
fp
);
int32_t
mndSendReq
ToDnode
(
SMnode
*
pMnode
,
SEpSet
*
pEpSet
,
SRpcMsg
*
rpcMsg
);
int32_t
mndSendReq
ToMnode
(
SMnode
*
pMnode
,
SRpcMsg
*
pMsg
);
void
mndSendRedirectRsp
(
SMnode
*
pMnode
,
SRpcMsg
*
pMsg
);
void
mndSetMsgHandle
(
SMnode
*
pMnode
,
tmsg_t
msgType
,
MndMsgFp
fp
);
uint64_t
mndGenerateUid
(
char
*
name
,
int32_t
len
)
;
...
...
source/dnode/mnode/impl/inc/mndTrans.h
浏览文件 @
0baa818e
...
...
@@ -45,6 +45,7 @@ int32_t mndTransAppendUndoAction(STrans *pTrans, STransAction *pAction);
int32_t
mndTransPrepare
(
SMnode
*
pMnode
,
STrans
*
pTrans
);
void
mndTransProcessRsp
(
SMnodeMsg
*
pMsg
);
void
mndTransPullup
(
SMnode
*
pMnode
);
#ifdef __cplusplus
}
...
...
source/dnode/mnode/impl/src/mndAcct.c
浏览文件 @
0baa818e
...
...
@@ -25,10 +25,10 @@ static SSdbRaw *mndAcctActionEncode(SAcctObj *pAcct);
static
SSdbRow
*
mndAcctActionDecode
(
SSdbRaw
*
pRaw
);
static
int32_t
mndAcctActionInsert
(
SSdb
*
pSdb
,
SAcctObj
*
pAcct
);
static
int32_t
mndAcctActionDelete
(
SSdb
*
pSdb
,
SAcctObj
*
pAcct
);
static
int32_t
mndAcctActionUpdate
(
SSdb
*
pSdb
,
SAcctObj
*
pOld
Acct
,
SAcctObj
*
pNewAcct
);
static
int32_t
mndProcessCreateAcct
Msg
(
SMnodeMsg
*
pMnode
Msg
);
static
int32_t
mndProcessAlterAcct
Msg
(
SMnodeMsg
*
pMnode
Msg
);
static
int32_t
mndProcessDropAcct
Msg
(
SMnodeMsg
*
pMnode
Msg
);
static
int32_t
mndAcctActionUpdate
(
SSdb
*
pSdb
,
SAcctObj
*
pOld
,
SAcctObj
*
pNew
);
static
int32_t
mndProcessCreateAcct
Req
(
SMnodeMsg
*
p
Msg
);
static
int32_t
mndProcessAlterAcct
Req
(
SMnodeMsg
*
p
Msg
);
static
int32_t
mndProcessDropAcct
Req
(
SMnodeMsg
*
p
Msg
);
int32_t
mndInitAcct
(
SMnode
*
pMnode
)
{
SSdbTable
table
=
{.
sdbType
=
SDB_ACCT
,
...
...
@@ -40,9 +40,9 @@ int32_t mndInitAcct(SMnode *pMnode) {
.
updateFp
=
(
SdbUpdateFp
)
mndAcctActionUpdate
,
.
deleteFp
=
(
SdbDeleteFp
)
mndAcctActionDelete
};
mndSetMsgHandle
(
pMnode
,
TDMT_MND_CREATE_ACCT
,
mndProcessCreateAcct
Msg
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_ALTER_ACCT
,
mndProcessAlterAcct
Msg
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_DROP_ACCT
,
mndProcessDropAcct
Msg
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_CREATE_ACCT
,
mndProcessCreateAcct
Req
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_ALTER_ACCT
,
mndProcessAlterAcct
Req
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_DROP_ACCT
,
mndProcessDropAcct
Req
);
return
sdbSetTable
(
pMnode
->
pSdb
,
table
);
}
...
...
@@ -176,29 +176,29 @@ static int32_t mndAcctActionDelete(SSdb *pSdb, SAcctObj *pAcct) {
return
0
;
}
static
int32_t
mndAcctActionUpdate
(
SSdb
*
pSdb
,
SAcctObj
*
pOld
Acct
,
SAcctObj
*
pNewAcct
)
{
mTrace
(
"acct:%s, perform update action, old_row:%p new_row:%p"
,
pOld
Acct
->
acct
,
pOldAcct
,
pNewAcct
);
static
int32_t
mndAcctActionUpdate
(
SSdb
*
pSdb
,
SAcctObj
*
pOld
,
SAcctObj
*
pNew
)
{
mTrace
(
"acct:%s, perform update action, old_row:%p new_row:%p"
,
pOld
->
acct
,
pOld
,
pNew
);
pOld
Acct
->
updateTime
=
pNewAcct
->
updateTime
;
pOld
Acct
->
status
=
pNewAcct
->
status
;
memcpy
(
&
pOld
Acct
->
cfg
,
&
pNewAcct
->
cfg
,
sizeof
(
SAcctCfg
));
pOld
->
updateTime
=
pNew
->
updateTime
;
pOld
->
status
=
pNew
->
status
;
memcpy
(
&
pOld
->
cfg
,
&
pNew
->
cfg
,
sizeof
(
SAcctCfg
));
return
0
;
}
static
int32_t
mndProcessCreateAcct
Msg
(
SMnodeMsg
*
pMnode
Msg
)
{
static
int32_t
mndProcessCreateAcct
Req
(
SMnodeMsg
*
p
Msg
)
{
terrno
=
TSDB_CODE_MND_MSG_NOT_PROCESSED
;
mError
(
"failed to process create acct
msg
since %s"
,
terrstr
());
mError
(
"failed to process create acct
request
since %s"
,
terrstr
());
return
-
1
;
}
static
int32_t
mndProcessAlterAcct
Msg
(
SMnodeMsg
*
pMnode
Msg
)
{
static
int32_t
mndProcessAlterAcct
Req
(
SMnodeMsg
*
p
Msg
)
{
terrno
=
TSDB_CODE_MND_MSG_NOT_PROCESSED
;
mError
(
"failed to process create acct
msg
since %s"
,
terrstr
());
mError
(
"failed to process create acct
request
since %s"
,
terrstr
());
return
-
1
;
}
static
int32_t
mndProcessDropAcct
Msg
(
SMnodeMsg
*
pMnode
Msg
)
{
static
int32_t
mndProcessDropAcct
Req
(
SMnodeMsg
*
p
Msg
)
{
terrno
=
TSDB_CODE_MND_MSG_NOT_PROCESSED
;
mError
(
"failed to process create acct
msg
since %s"
,
terrstr
());
mError
(
"failed to process create acct
request
since %s"
,
terrstr
());
return
-
1
;
}
\ No newline at end of file
source/dnode/mnode/impl/src/mndBnode.c
浏览文件 @
0baa818e
...
...
@@ -178,7 +178,7 @@ static int32_t mndSetCreateBnodeCommitLogs(STrans *pTrans, SBnodeObj *pObj) {
}
static
int32_t
mndSetCreateBnodeRedoActions
(
STrans
*
pTrans
,
SDnodeObj
*
pDnode
,
SBnodeObj
*
pObj
)
{
SDCreateBnode
Msg
*
pMsg
=
malloc
(
sizeof
(
SDCreateBnodeMsg
));
SDCreateBnode
Req
*
pMsg
=
malloc
(
sizeof
(
SDCreateBnodeReq
));
if
(
pMsg
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
...
...
@@ -188,7 +188,7 @@ static int32_t mndSetCreateBnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, S
STransAction
action
=
{
0
};
action
.
epSet
=
mndGetDnodeEpset
(
pDnode
);
action
.
pCont
=
pMsg
;
action
.
contLen
=
sizeof
(
SDCreateBnode
Msg
);
action
.
contLen
=
sizeof
(
SDCreateBnode
Req
);
action
.
msgType
=
TDMT_DND_CREATE_BNODE
;
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
...
...
@@ -199,7 +199,7 @@ static int32_t mndSetCreateBnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, S
return
0
;
}
static
int32_t
mndCreateBnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
pMsg
,
SDnodeObj
*
pDnode
,
SMCreateBnode
Msg
*
pCreate
)
{
static
int32_t
mndCreateBnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
pMsg
,
SDnodeObj
*
pDnode
,
SMCreateBnode
Req
*
pCreate
)
{
SBnodeObj
bnodeObj
=
{
0
};
bnodeObj
.
id
=
pDnode
->
id
;
bnodeObj
.
createdTime
=
taosGetTimestampMs
();
...
...
@@ -242,7 +242,7 @@ CREATE_BNODE_OVER:
static
int32_t
mndProcessCreateBnodeReq
(
SMnodeMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SMCreateBnode
Msg
*
pCreate
=
pMsg
->
rpcMsg
.
pCont
;
SMCreateBnode
Req
*
pCreate
=
pMsg
->
rpcMsg
.
pCont
;
pCreate
->
dnodeId
=
htonl
(
pCreate
->
dnodeId
);
...
...
@@ -290,7 +290,7 @@ static int32_t mndSetDropBnodeCommitLogs(STrans *pTrans, SBnodeObj *pObj) {
}
static
int32_t
mndSetDropBnodeRedoActions
(
STrans
*
pTrans
,
SDnodeObj
*
pDnode
,
SBnodeObj
*
pObj
)
{
SDDropBnode
Msg
*
pMsg
=
malloc
(
sizeof
(
SDDropBnodeMsg
));
SDDropBnode
Req
*
pMsg
=
malloc
(
sizeof
(
SDDropBnodeReq
));
if
(
pMsg
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
...
...
@@ -300,7 +300,7 @@ static int32_t mndSetDropBnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, SBn
STransAction
action
=
{
0
};
action
.
epSet
=
mndGetDnodeEpset
(
pDnode
);
action
.
pCont
=
pMsg
;
action
.
contLen
=
sizeof
(
SDDropBnode
Msg
);
action
.
contLen
=
sizeof
(
SDDropBnode
Req
);
action
.
msgType
=
TDMT_DND_DROP_BNODE
;
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
...
...
@@ -350,7 +350,7 @@ DROP_BNODE_OVER:
static
int32_t
mndProcessDropBnodeReq
(
SMnodeMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SMDropBnode
Msg
*
pDrop
=
pMsg
->
rpcMsg
.
pCont
;
SMDropBnode
Req
*
pDrop
=
pMsg
->
rpcMsg
.
pCont
;
pDrop
->
dnodeId
=
htonl
(
pDrop
->
dnodeId
);
mDebug
(
"bnode:%d, start to drop"
,
pDrop
->
dnodeId
);
...
...
source/dnode/mnode/impl/src/mndCluster.c
浏览文件 @
0baa818e
...
...
@@ -145,7 +145,7 @@ static int32_t mndCreateDefaultCluster(SMnode *pMnode) {
clusterObj
.
createdTime
=
taosGetTimestampMs
();
clusterObj
.
updateTime
=
clusterObj
.
createdTime
;
int32_t
code
=
taosGetSystemU
id
(
clusterObj
.
name
,
TSDB_CLUSTER_ID_LEN
);
int32_t
code
=
taosGetSystemU
UID
(
clusterObj
.
name
,
TSDB_CLUSTER_ID_LEN
);
if
(
code
!=
0
)
{
strcpy
(
clusterObj
.
name
,
"tdengine2.0"
);
mError
(
"failed to get name from system, set to default val %s"
,
clusterObj
.
name
);
...
...
source/dnode/mnode/impl/src/mndDnode.c
浏览文件 @
0baa818e
...
...
@@ -557,7 +557,7 @@ static int32_t mndProcessConfigDnodeMsg(SMnodeMsg *pMsg) {
.
ahandle
=
pMsg
->
rpcMsg
.
ahandle
};
mInfo
(
"dnode:%d, app:%p config:%s req send to dnode"
,
pCfg
->
dnodeId
,
rpcMsg
.
ahandle
,
pCfg
->
config
);
mndSend
Msg
ToDnode
(
pMnode
,
&
epSet
,
&
rpcMsg
);
mndSend
Req
ToDnode
(
pMnode
,
&
epSet
,
&
rpcMsg
);
return
0
;
}
...
...
source/dnode/mnode/impl/src/mndQnode.c
浏览文件 @
0baa818e
...
...
@@ -178,7 +178,7 @@ static int32_t mndSetCreateQnodeCommitLogs(STrans *pTrans, SQnodeObj *pObj) {
}
static
int32_t
mndSetCreateQnodeRedoActions
(
STrans
*
pTrans
,
SDnodeObj
*
pDnode
,
SQnodeObj
*
pObj
)
{
SDCreateQnode
Msg
*
pMsg
=
malloc
(
sizeof
(
SDCreateQnodeMsg
));
SDCreateQnode
Req
*
pMsg
=
malloc
(
sizeof
(
SDCreateQnodeReq
));
if
(
pMsg
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
...
...
@@ -188,7 +188,7 @@ static int32_t mndSetCreateQnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, S
STransAction
action
=
{
0
};
action
.
epSet
=
mndGetDnodeEpset
(
pDnode
);
action
.
pCont
=
pMsg
;
action
.
contLen
=
sizeof
(
SDCreateQnode
Msg
);
action
.
contLen
=
sizeof
(
SDCreateQnode
Req
);
action
.
msgType
=
TDMT_DND_CREATE_QNODE
;
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
...
...
@@ -199,7 +199,7 @@ static int32_t mndSetCreateQnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, S
return
0
;
}
static
int32_t
mndCreateQnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
pMsg
,
SDnodeObj
*
pDnode
,
SMCreateQnode
Msg
*
pCreate
)
{
static
int32_t
mndCreateQnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
pMsg
,
SDnodeObj
*
pDnode
,
SMCreateQnode
Req
*
pCreate
)
{
SQnodeObj
qnodeObj
=
{
0
};
qnodeObj
.
id
=
pDnode
->
id
;
qnodeObj
.
createdTime
=
taosGetTimestampMs
();
...
...
@@ -242,7 +242,7 @@ CREATE_QNODE_OVER:
static
int32_t
mndProcessCreateQnodeReq
(
SMnodeMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SMCreateQnode
Msg
*
pCreate
=
pMsg
->
rpcMsg
.
pCont
;
SMCreateQnode
Req
*
pCreate
=
pMsg
->
rpcMsg
.
pCont
;
pCreate
->
dnodeId
=
htonl
(
pCreate
->
dnodeId
);
...
...
@@ -290,7 +290,7 @@ static int32_t mndSetDropQnodeCommitLogs(STrans *pTrans, SQnodeObj *pObj) {
}
static
int32_t
mndSetDropQnodeRedoActions
(
STrans
*
pTrans
,
SDnodeObj
*
pDnode
,
SQnodeObj
*
pObj
)
{
SDDropQnode
Msg
*
pMsg
=
malloc
(
sizeof
(
SDDropQnodeMsg
));
SDDropQnode
Req
*
pMsg
=
malloc
(
sizeof
(
SDDropQnodeReq
));
if
(
pMsg
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
...
...
@@ -300,7 +300,7 @@ static int32_t mndSetDropQnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, SQn
STransAction
action
=
{
0
};
action
.
epSet
=
mndGetDnodeEpset
(
pDnode
);
action
.
pCont
=
pMsg
;
action
.
contLen
=
sizeof
(
SDDropQnode
Msg
);
action
.
contLen
=
sizeof
(
SDDropQnode
Req
);
action
.
msgType
=
TDMT_DND_DROP_QNODE
;
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
...
...
@@ -350,7 +350,7 @@ DROP_QNODE_OVER:
static
int32_t
mndProcessDropQnodeReq
(
SMnodeMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SMDropQnode
Msg
*
pDrop
=
pMsg
->
rpcMsg
.
pCont
;
SMDropQnode
Req
*
pDrop
=
pMsg
->
rpcMsg
.
pCont
;
pDrop
->
dnodeId
=
htonl
(
pDrop
->
dnodeId
);
mDebug
(
"qnode:%d, start to drop"
,
pDrop
->
dnodeId
);
...
...
source/dnode/mnode/impl/src/mndSnode.c
浏览文件 @
0baa818e
...
...
@@ -178,7 +178,7 @@ static int32_t mndSetCreateSnodeCommitLogs(STrans *pTrans, SSnodeObj *pObj) {
}
static
int32_t
mndSetCreateSnodeRedoActions
(
STrans
*
pTrans
,
SDnodeObj
*
pDnode
,
SSnodeObj
*
pObj
)
{
SDCreateSnode
Msg
*
pMsg
=
malloc
(
sizeof
(
SDCreateSnodeMsg
));
SDCreateSnode
Req
*
pMsg
=
malloc
(
sizeof
(
SDCreateSnodeReq
));
if
(
pMsg
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
...
...
@@ -188,7 +188,7 @@ static int32_t mndSetCreateSnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, S
STransAction
action
=
{
0
};
action
.
epSet
=
mndGetDnodeEpset
(
pDnode
);
action
.
pCont
=
pMsg
;
action
.
contLen
=
sizeof
(
SDCreateSnode
Msg
);
action
.
contLen
=
sizeof
(
SDCreateSnode
Req
);
action
.
msgType
=
TDMT_DND_CREATE_SNODE
;
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
...
...
@@ -199,7 +199,7 @@ static int32_t mndSetCreateSnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, S
return
0
;
}
static
int32_t
mndCreateSnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
pMsg
,
SDnodeObj
*
pDnode
,
SMCreateSnode
Msg
*
pCreate
)
{
static
int32_t
mndCreateSnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
pMsg
,
SDnodeObj
*
pDnode
,
SMCreateSnode
Req
*
pCreate
)
{
SSnodeObj
snodeObj
=
{
0
};
snodeObj
.
id
=
pDnode
->
id
;
snodeObj
.
createdTime
=
taosGetTimestampMs
();
...
...
@@ -242,7 +242,7 @@ CREATE_SNODE_OVER:
static
int32_t
mndProcessCreateSnodeReq
(
SMnodeMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SMCreateSnode
Msg
*
pCreate
=
pMsg
->
rpcMsg
.
pCont
;
SMCreateSnode
Req
*
pCreate
=
pMsg
->
rpcMsg
.
pCont
;
pCreate
->
dnodeId
=
htonl
(
pCreate
->
dnodeId
);
...
...
@@ -290,7 +290,7 @@ static int32_t mndSetDropSnodeCommitLogs(STrans *pTrans, SSnodeObj *pObj) {
}
static
int32_t
mndSetDropSnodeRedoActions
(
STrans
*
pTrans
,
SDnodeObj
*
pDnode
,
SSnodeObj
*
pObj
)
{
SDDropSnode
Msg
*
pMsg
=
malloc
(
sizeof
(
SDDropSnodeMsg
));
SDDropSnode
Req
*
pMsg
=
malloc
(
sizeof
(
SDDropSnodeReq
));
if
(
pMsg
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
...
...
@@ -300,7 +300,7 @@ static int32_t mndSetDropSnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, SSn
STransAction
action
=
{
0
};
action
.
epSet
=
mndGetDnodeEpset
(
pDnode
);
action
.
pCont
=
pMsg
;
action
.
contLen
=
sizeof
(
SDDropSnode
Msg
);
action
.
contLen
=
sizeof
(
SDDropSnode
Req
);
action
.
msgType
=
TDMT_DND_DROP_SNODE
;
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
...
...
@@ -350,7 +350,7 @@ DROP_SNODE_OVER:
static
int32_t
mndProcessDropSnodeReq
(
SMnodeMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SMDropSnode
Msg
*
pDrop
=
pMsg
->
rpcMsg
.
pCont
;
SMDropSnode
Req
*
pDrop
=
pMsg
->
rpcMsg
.
pCont
;
pDrop
->
dnodeId
=
htonl
(
pDrop
->
dnodeId
);
mDebug
(
"snode:%d, start to drop"
,
pDrop
->
dnodeId
);
...
...
source/dnode/mnode/impl/src/mndSync.c
浏览文件 @
0baa818e
...
...
@@ -83,6 +83,8 @@ static int32_t mndRestoreWal(SMnode *pMnode) {
int64_t
sdbVer
=
sdbUpdateVer
(
pSdb
,
0
);
mDebug
(
"restore sdb wal finished, sdb ver:%"
PRId64
,
sdbVer
);
mndTransPullup
(
pMnode
);
if
(
walBeginSnapshot
(
pWal
,
sdbVer
)
<
0
)
{
goto
WAL_RESTORE_OVER
;
}
...
...
source/dnode/mnode/impl/src/mndTrans.c
浏览文件 @
0baa818e
...
...
@@ -52,7 +52,6 @@ static bool mndTransPerfromFinishedStage(SMnode *pMnode, STrans *pTrans);
static
void
mndTransExecute
(
SMnode
*
pMnode
,
STrans
*
pTrans
);
static
void
mndTransSendRpcRsp
(
STrans
*
pTrans
);
static
int32_t
mndProcessTransMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessTransRsp
(
SMnodeMsg
*
pMsg
);
int32_t
mndInitTrans
(
SMnode
*
pMnode
)
{
SSdbTable
table
=
{.
sdbType
=
SDB_TRANS
,
...
...
@@ -64,7 +63,6 @@ int32_t mndInitTrans(SMnode *pMnode) {
.
deleteFp
=
(
SdbDeleteFp
)
mndTransActionDelete
};
mndSetMsgHandle
(
pMnode
,
TDMT_MND_TRANS
,
mndProcessTransMsg
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_TRANS_RSP
,
mndProcessTransRsp
);
return
sdbSetTable
(
pMnode
->
pSdb
,
table
);
}
...
...
@@ -615,12 +613,15 @@ static int32_t mndTransSendActionMsg(SMnode *pMnode, STrans *pTrans, SArray *pAr
}
memcpy
(
rpcMsg
.
pCont
,
pAction
->
pCont
,
pAction
->
contLen
);
pAction
->
msgSent
=
1
;
pAction
->
msgReceived
=
0
;
pAction
->
errCode
=
0
;
mDebug
(
"trans:%d, action:%d is sent"
,
pTrans
->
id
,
action
);
mndSendMsgToDnode
(
pMnode
,
&
pAction
->
epSet
,
&
rpcMsg
);
if
(
mndSendReqToDnode
(
pMnode
,
&
pAction
->
epSet
,
&
rpcMsg
)
==
0
)
{
mDebug
(
"trans:%d, action:%d is sent"
,
pTrans
->
id
,
action
);
pAction
->
msgSent
=
1
;
pAction
->
msgReceived
=
0
;
pAction
->
errCode
=
0
;
}
else
{
mDebug
(
"trans:%d, action:%d not sent since %s"
,
pTrans
->
id
,
action
,
terrstr
());
return
-
1
;
}
}
return
0
;
...
...
@@ -885,7 +886,11 @@ static void mndTransExecute(SMnode *pMnode, STrans *pTrans) {
}
static
int32_t
mndProcessTransMsg
(
SMnodeMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
pMnode
;
mndTransPullup
(
pMsg
->
pMnode
);
return
0
;
}
void
mndTransPullup
(
SMnode
*
pMnode
)
{
STrans
*
pTrans
=
NULL
;
void
*
pIter
=
NULL
;
...
...
@@ -897,5 +902,3 @@ static int32_t mndProcessTransMsg(SMnodeMsg *pMsg) {
sdbRelease
(
pMnode
->
pSdb
,
pTrans
);
}
}
static
int32_t
mndProcessTransRsp
(
SMnodeMsg
*
pMsg
)
{
return
0
;
}
\ No newline at end of file
source/dnode/mnode/impl/src/mndUser.c
浏览文件 @
0baa818e
...
...
@@ -28,11 +28,11 @@ static SSdbRaw *mndUserActionEncode(SUserObj *pUser);
static
SSdbRow
*
mndUserActionDecode
(
SSdbRaw
*
pRaw
);
static
int32_t
mndUserActionInsert
(
SSdb
*
pSdb
,
SUserObj
*
pUser
);
static
int32_t
mndUserActionDelete
(
SSdb
*
pSdb
,
SUserObj
*
pUser
);
static
int32_t
mndUserActionUpdate
(
SSdb
*
pSdb
,
SUserObj
*
pOld
User
,
SUserObj
*
pNewUser
);
static
int32_t
mndUserActionUpdate
(
SSdb
*
pSdb
,
SUserObj
*
pOld
,
SUserObj
*
pNew
);
static
int32_t
mndCreateUser
(
SMnode
*
pMnode
,
char
*
acct
,
char
*
user
,
char
*
pass
,
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessCreateUser
Msg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessAlterUser
Msg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessDropUser
Msg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessCreateUser
Req
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessAlterUser
Req
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessDropUser
Req
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndGetUserMeta
(
SMnodeMsg
*
pMsg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
);
static
int32_t
mndRetrieveUsers
(
SMnodeMsg
*
pMsg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
void
mndCancelGetNextUser
(
SMnode
*
pMnode
,
void
*
pIter
);
...
...
@@ -47,9 +47,9 @@ int32_t mndInitUser(SMnode *pMnode) {
.
updateFp
=
(
SdbUpdateFp
)
mndUserActionUpdate
,
.
deleteFp
=
(
SdbDeleteFp
)
mndUserActionDelete
};
mndSetMsgHandle
(
pMnode
,
TDMT_MND_CREATE_USER
,
mndProcessCreateUser
Msg
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_ALTER_USER
,
mndProcessAlterUser
Msg
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_DROP_USER
,
mndProcessDropUser
Msg
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_CREATE_USER
,
mndProcessCreateUser
Req
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_ALTER_USER
,
mndProcessAlterUser
Req
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_DROP_USER
,
mndProcessDropUser
Req
);
mndAddShowMetaHandle
(
pMnode
,
TSDB_MGMT_TABLE_USER
,
mndGetUserMeta
);
mndAddShowRetrieveHandle
(
pMnode
,
TSDB_MGMT_TABLE_USER
,
mndRetrieveUsers
);
...
...
@@ -192,10 +192,10 @@ static int32_t mndUserActionDelete(SSdb *pSdb, SUserObj *pUser) {
return
0
;
}
static
int32_t
mndUserActionUpdate
(
SSdb
*
pSdb
,
SUserObj
*
pOld
User
,
SUserObj
*
pNewUser
)
{
mTrace
(
"user:%s, perform update action, old_row:%p new_row:%p"
,
pOld
User
->
user
,
pOldUser
,
pNewUser
);
memcpy
(
pOld
User
->
pass
,
pNewUser
->
pass
,
TSDB_PASSWORD_LEN
);
pOld
User
->
updateTime
=
pNewUser
->
updateTime
;
static
int32_t
mndUserActionUpdate
(
SSdb
*
pSdb
,
SUserObj
*
pOld
,
SUserObj
*
pNew
)
{
mTrace
(
"user:%s, perform update action, old_row:%p new_row:%p"
,
pOld
->
user
,
pOld
,
pNew
);
memcpy
(
pOld
->
pass
,
pNew
->
pass
,
TSDB_PASSWORD_LEN
);
pOld
->
updateTime
=
pNew
->
updateTime
;
return
0
;
}
...
...
@@ -247,9 +247,9 @@ static int32_t mndCreateUser(SMnode *pMnode, char *acct, char *user, char *pass,
return
0
;
}
static
int32_t
mndProcessCreateUser
Msg
(
SMnodeMsg
*
pMsg
)
{
static
int32_t
mndProcessCreateUser
Req
(
SMnodeMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SCreateUser
Msg
*
pCreate
=
pMsg
->
rpcMsg
.
pCont
;
SCreateUser
Req
*
pCreate
=
pMsg
->
rpcMsg
.
pCont
;
mDebug
(
"user:%s, start to create"
,
pCreate
->
user
);
...
...
@@ -291,15 +291,15 @@ static int32_t mndProcessCreateUserMsg(SMnodeMsg *pMsg) {
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
static
int32_t
mndUpdateUser
(
SMnode
*
pMnode
,
SUserObj
*
pOld
User
,
SUserObj
*
pNewUser
,
SMnodeMsg
*
pMsg
)
{
static
int32_t
mndUpdateUser
(
SMnode
*
pMnode
,
SUserObj
*
pOld
,
SUserObj
*
pNew
,
SMnodeMsg
*
pMsg
)
{
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
&
pMsg
->
rpcMsg
);
if
(
pTrans
==
NULL
)
{
mError
(
"user:%s, failed to update since %s"
,
pOld
User
->
user
,
terrstr
());
mError
(
"user:%s, failed to update since %s"
,
pOld
->
user
,
terrstr
());
return
-
1
;
}
mDebug
(
"trans:%d, used to update user:%s"
,
pTrans
->
id
,
pOld
User
->
user
);
mDebug
(
"trans:%d, used to update user:%s"
,
pTrans
->
id
,
pOld
->
user
);
SSdbRaw
*
pRedoRaw
=
mndUserActionEncode
(
pNew
User
);
SSdbRaw
*
pRedoRaw
=
mndUserActionEncode
(
pNew
);
if
(
pRedoRaw
==
NULL
||
mndTransAppendRedolog
(
pTrans
,
pRedoRaw
)
!=
0
)
{
mError
(
"trans:%d, failed to append redo log since %s"
,
pTrans
->
id
,
terrstr
());
mndTransDrop
(
pTrans
);
...
...
@@ -317,9 +317,9 @@ static int32_t mndUpdateUser(SMnode *pMnode, SUserObj *pOldUser, SUserObj *pNewU
return
0
;
}
static
int32_t
mndProcessAlterUser
Msg
(
SMnodeMsg
*
pMsg
)
{
static
int32_t
mndProcessAlterUser
Req
(
SMnodeMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SAlterUser
Msg
*
pAlter
=
pMsg
->
rpcMsg
.
pCont
;
SAlterUser
Req
*
pAlter
=
pMsg
->
rpcMsg
.
pCont
;
mDebug
(
"user:%s, start to alter"
,
pAlter
->
user
);
...
...
@@ -394,9 +394,9 @@ static int32_t mndDropUser(SMnode *pMnode, SMnodeMsg *pMsg, SUserObj *pUser) {
return
0
;
}
static
int32_t
mndProcessDropUser
Msg
(
SMnodeMsg
*
pMsg
)
{
static
int32_t
mndProcessDropUser
Req
(
SMnodeMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SDropUser
Msg
*
pDrop
=
pMsg
->
rpcMsg
.
pCont
;
SDropUser
Req
*
pDrop
=
pMsg
->
rpcMsg
.
pCont
;
mDebug
(
"user:%s, start to drop"
,
pDrop
->
user
);
...
...
source/dnode/mnode/impl/src/mnode.c
浏览文件 @
0baa818e
...
...
@@ -34,21 +34,27 @@
#include "mndUser.h"
#include "mndVgroup.h"
void
mndSendMsgToDnode
(
SMnode
*
pMnode
,
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
)
{
if
(
pMnode
!=
NULL
&&
pMnode
->
sendMsgToDnodeFp
!=
NULL
)
{
(
*
pMnode
->
sendMsgToDnodeFp
)(
pMnode
->
pDnode
,
pEpSet
,
pMsg
);
int32_t
mndSendReqToDnode
(
SMnode
*
pMnode
,
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
)
{
if
(
pMnode
==
NULL
||
pMnode
->
sendReqToDnodeFp
==
NULL
)
{
terrno
=
TSDB_CODE_MND_NOT_READY
;
return
-
1
;
}
return
(
*
pMnode
->
sendReqToDnodeFp
)(
pMnode
->
pDnode
,
pEpSet
,
pMsg
);
}
void
mndSendMsgToMnode
(
SMnode
*
pMnode
,
SRpcMsg
*
pMsg
)
{
if
(
pMnode
!=
NULL
&&
pMnode
->
sendMsgToMnodeFp
!=
NULL
)
{
(
*
pMnode
->
sendMsgToMnodeFp
)(
pMnode
->
pDnode
,
pMsg
);
int32_t
mndSendReqToMnode
(
SMnode
*
pMnode
,
SRpcMsg
*
pMsg
)
{
if
(
pMnode
==
NULL
||
pMnode
->
sendReqToDnodeFp
==
NULL
)
{
terrno
=
TSDB_CODE_MND_NOT_READY
;
return
-
1
;
}
return
(
*
pMnode
->
sendReqToMnodeFp
)(
pMnode
->
pDnode
,
pMsg
);
}
void
mndSendRedirect
Msg
(
SMnode
*
pMnode
,
SRpcMsg
*
pMsg
)
{
if
(
pMnode
!=
NULL
&&
pMnode
->
sendRedirect
Msg
Fp
!=
NULL
)
{
(
*
pMnode
->
sendRedirect
Msg
Fp
)(
pMnode
->
pDnode
,
pMsg
);
void
mndSendRedirect
Rsp
(
SMnode
*
pMnode
,
SRpcMsg
*
pMsg
)
{
if
(
pMnode
!=
NULL
&&
pMnode
->
sendRedirect
Rsp
Fp
!=
NULL
)
{
(
*
pMnode
->
sendRedirect
Rsp
Fp
)(
pMnode
->
pDnode
,
pMsg
);
}
}
...
...
@@ -56,11 +62,8 @@ static void mndTransReExecute(void *param, void *tmrId) {
SMnode
*
pMnode
=
param
;
if
(
mndIsMaster
(
pMnode
))
{
STransMsg
*
pMsg
=
rpcMallocCont
(
sizeof
(
STransMsg
));
SEpSet
epSet
=
{.
inUse
=
0
,
.
numOfEps
=
1
};
epSet
.
port
[
0
]
=
pMnode
->
replicas
[
pMnode
->
selfIndex
].
port
;
memcpy
(
epSet
.
fqdn
[
0
],
pMnode
->
replicas
[
pMnode
->
selfIndex
].
fqdn
,
TSDB_FQDN_LEN
);
SRpcMsg
rpcMsg
=
{.
msgType
=
TDMT_MND_TRANS
,
.
pCont
=
pMsg
,
.
contLen
=
sizeof
(
STransMsg
)};
mndSendMsgToDnode
(
pMnode
,
&
epSet
,
&
rpcMsg
);
SRpcMsg
rpcMsg
=
{.
msgType
=
TDMT_MND_TRANS
,
.
pCont
=
pMsg
,
.
contLen
=
sizeof
(
STransMsg
)};
pMnode
->
putReqToMWriteQFp
(
pMnode
->
pDnode
,
&
rpcMsg
);
}
taosTmrReset
(
mndTransReExecute
,
3000
,
pMnode
,
pMnode
->
timer
,
&
pMnode
->
transTimer
);
...
...
@@ -76,7 +79,7 @@ static int32_t mndInitTimer(SMnode *pMnode) {
return
-
1
;
}
if
(
taosTmrReset
(
mndTransReExecute
,
1
000
,
pMnode
,
pMnode
->
timer
,
&
pMnode
->
transTimer
))
{
if
(
taosTmrReset
(
mndTransReExecute
,
6
000
,
pMnode
,
pMnode
->
timer
,
&
pMnode
->
transTimer
))
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
...
...
@@ -223,9 +226,10 @@ static int32_t mndSetOptions(SMnode *pMnode, const SMnodeOpt *pOption) {
pMnode
->
selfIndex
=
pOption
->
selfIndex
;
memcpy
(
&
pMnode
->
replicas
,
pOption
->
replicas
,
sizeof
(
SReplica
)
*
TSDB_MAX_REPLICA
);
pMnode
->
pDnode
=
pOption
->
pDnode
;
pMnode
->
sendMsgToDnodeFp
=
pOption
->
sendMsgToDnodeFp
;
pMnode
->
sendMsgToMnodeFp
=
pOption
->
sendMsgToMnodeFp
;
pMnode
->
sendRedirectMsgFp
=
pOption
->
sendRedirectMsgFp
;
pMnode
->
putReqToMWriteQFp
=
pOption
->
putReqToMWriteQFp
;
pMnode
->
sendReqToDnodeFp
=
pOption
->
sendReqToDnodeFp
;
pMnode
->
sendReqToMnodeFp
=
pOption
->
sendReqToMnodeFp
;
pMnode
->
sendRedirectRspFp
=
pOption
->
sendRedirectRspFp
;
pMnode
->
cfg
.
sver
=
pOption
->
cfg
.
sver
;
pMnode
->
cfg
.
enableTelem
=
pOption
->
cfg
.
enableTelem
;
pMnode
->
cfg
.
statusInterval
=
pOption
->
cfg
.
statusInterval
;
...
...
@@ -236,8 +240,9 @@ static int32_t mndSetOptions(SMnode *pMnode, const SMnodeOpt *pOption) {
pMnode
->
cfg
.
gitinfo
=
strdup
(
pOption
->
cfg
.
gitinfo
);
pMnode
->
cfg
.
buildinfo
=
strdup
(
pOption
->
cfg
.
buildinfo
);
if
(
pMnode
->
sendMsgToDnodeFp
==
NULL
||
pMnode
->
sendMsgToMnodeFp
==
NULL
||
pMnode
->
sendRedirectMsgFp
==
NULL
||
pMnode
->
dnodeId
<
0
||
pMnode
->
clusterId
<
0
||
pMnode
->
cfg
.
statusInterval
<
1
)
{
if
(
pMnode
->
sendReqToDnodeFp
==
NULL
||
pMnode
->
sendReqToMnodeFp
==
NULL
||
pMnode
->
sendRedirectRspFp
==
NULL
||
pMnode
->
putReqToMWriteQFp
==
NULL
||
pMnode
->
dnodeId
<
0
||
pMnode
->
clusterId
<
0
||
pMnode
->
cfg
.
statusInterval
<
1
)
{
terrno
=
TSDB_CODE_MND_INVALID_OPTIONS
;
return
-
1
;
}
...
...
@@ -433,7 +438,7 @@ void mndProcessMsg(SMnodeMsg *pMsg) {
PROCESS_RPC_END:
if
(
isReq
)
{
if
(
code
==
TSDB_CODE_APP_NOT_READY
)
{
mndSendRedirect
Msg
(
pMnode
,
&
pMsg
->
rpcMsg
);
mndSendRedirect
Rsp
(
pMnode
,
&
pMsg
->
rpcMsg
);
}
else
if
(
code
!=
0
)
{
SRpcMsg
rpcRsp
=
{.
handle
=
pMsg
->
rpcMsg
.
handle
,
.
code
=
code
};
rpcSendResponse
(
&
rpcRsp
);
...
...
source/dnode/mnode/impl/test/CMakeLists.txt
浏览文件 @
0baa818e
enable_testing
()
add_subdirectory
(
acct
)
add_subdirectory
(
user
)
add_subdirectory
(
acct
)
add_subdirectory
(
trans
)
add_subdirectory
(
qnode
)
add_subdirectory
(
snode
)
add_subdirectory
(
bnode
)
source/dnode/mnode/impl/test/acct/acct.cpp
浏览文件 @
0baa818e
/**
* @file acct.cpp
* @author slguan (slguan@taosdata.com)
* @brief MNODE module acct
-msg
tests
* @version
0.1
* @date 202
1-12-15
* @brief MNODE module acct tests
* @version
1.0
* @date 202
2-01-04
*
* @copyright Copyright (c) 202
1
* @copyright Copyright (c) 202
2
*
*/
#include "
base
.h"
#include "
sut
.h"
class
D
ndTestAcct
:
public
::
testing
::
Test
{
class
M
ndTestAcct
:
public
::
testing
::
Test
{
protected:
static
void
SetUpTestSuite
()
{
test
.
Init
(
"/tmp/mnode_test_acct"
,
9012
);
}
static
void
TearDownTestSuite
()
{
test
.
Cleanup
();
}
...
...
@@ -23,39 +23,39 @@ class DndTestAcct : public ::testing::Test {
void
TearDown
()
override
{}
};
Testbase
D
ndTestAcct
::
test
;
Testbase
M
ndTestAcct
::
test
;
TEST_F
(
DndTestAcct
,
01
_Create
Acct
)
{
int32_t
contLen
=
sizeof
(
SCreateAcct
Msg
);
TEST_F
(
MndTestAcct
,
01
_Create_
Acct
)
{
int32_t
contLen
=
sizeof
(
SCreateAcct
Req
);
SCreateAcct
Msg
*
pReq
=
(
SCreateAcctMsg
*
)
rpcMallocCont
(
contLen
);
SCreateAcct
Req
*
pReq
=
(
SCreateAcctReq
*
)
rpcMallocCont
(
contLen
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_CREATE_ACCT
,
pReq
,
contLen
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
TSDB_CODE_MND_MSG_NOT_PROCESSED
);
}
TEST_F
(
DndTestAcct
,
02
_Alter
Acct
)
{
int32_t
contLen
=
sizeof
(
SCreateAcct
Msg
);
TEST_F
(
MndTestAcct
,
02
_Alter_
Acct
)
{
int32_t
contLen
=
sizeof
(
SCreateAcct
Req
);
SAlterAcct
Msg
*
pReq
=
(
SAlterAcctMsg
*
)
rpcMallocCont
(
contLen
);
SAlterAcct
Req
*
pReq
=
(
SAlterAcctReq
*
)
rpcMallocCont
(
contLen
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_ALTER_ACCT
,
pReq
,
contLen
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
TSDB_CODE_MND_MSG_NOT_PROCESSED
);
}
TEST_F
(
DndTestAcct
,
03
_Drop
Acct
)
{
int32_t
contLen
=
sizeof
(
SDropAcct
Msg
);
TEST_F
(
MndTestAcct
,
03
_Drop_
Acct
)
{
int32_t
contLen
=
sizeof
(
SDropAcct
Req
);
SDropAcct
Msg
*
pReq
=
(
SDropAcctMsg
*
)
rpcMallocCont
(
contLen
);
SDropAcct
Req
*
pReq
=
(
SDropAcctReq
*
)
rpcMallocCont
(
contLen
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_DROP_ACCT
,
pReq
,
contLen
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
TSDB_CODE_MND_MSG_NOT_PROCESSED
);
}
TEST_F
(
DndTestAcct
,
04
_Show
Acct
)
{
TEST_F
(
MndTestAcct
,
04
_Show_
Acct
)
{
int32_t
contLen
=
sizeof
(
SShowMsg
);
SShowMsg
*
pReq
=
(
SShowMsg
*
)
rpcMallocCont
(
contLen
);
...
...
source/dnode/m
gmt
/impl/test/bnode/CMakeLists.txt
→
source/dnode/m
node
/impl/test/bnode/CMakeLists.txt
浏览文件 @
0baa818e
aux_source_directory
(
. STEST_SRC
)
add_executable
(
d
node_test_bnode
${
STEST_SRC
}
)
add_executable
(
m
node_test_bnode
${
STEST_SRC
}
)
target_link_libraries
(
d
node_test_bnode
m
node_test_bnode
PUBLIC sut
)
add_test
(
NAME
d
node_test_bnode
COMMAND
d
node_test_bnode
NAME
m
node_test_bnode
COMMAND
m
node_test_bnode
)
source/dnode/mnode/impl/test/bnode/bnode.cpp
0 → 100644
浏览文件 @
0baa818e
/**
* @file bnode.cpp
* @author slguan (slguan@taosdata.com)
* @brief MNODE module bnode tests
* @version 1.0
* @date 2022-01-05
*
* @copyright Copyright (c) 2022
*
*/
#include "sut.h"
class
MndTestBnode
:
public
::
testing
::
Test
{
public:
void
SetUp
()
override
{}
void
TearDown
()
override
{}
public:
static
void
SetUpTestSuite
()
{
test
.
Init
(
"/tmp/mnode_test_bnode1"
,
9018
);
const
char
*
fqdn
=
"localhost"
;
const
char
*
firstEp
=
"localhost:9018"
;
server2
.
Start
(
"/tmp/mnode_test_bnode2"
,
fqdn
,
9019
,
firstEp
);
taosMsleep
(
300
);
}
static
void
TearDownTestSuite
()
{
server2
.
Stop
();
test
.
Cleanup
();
}
static
Testbase
test
;
static
TestServer
server2
;
};
Testbase
MndTestBnode
::
test
;
TestServer
MndTestBnode
::
server2
;
TEST_F
(
MndTestBnode
,
01
_Show_Bnode
)
{
test
.
SendShowMetaMsg
(
TSDB_MGMT_TABLE_BNODE
,
""
);
CHECK_META
(
"show bnodes"
,
3
);
CHECK_SCHEMA
(
0
,
TSDB_DATA_TYPE_SMALLINT
,
2
,
"id"
);
CHECK_SCHEMA
(
1
,
TSDB_DATA_TYPE_BINARY
,
TSDB_EP_LEN
+
VARSTR_HEADER_SIZE
,
"endpoint"
);
CHECK_SCHEMA
(
2
,
TSDB_DATA_TYPE_TIMESTAMP
,
8
,
"create_time"
);
test
.
SendShowRetrieveMsg
();
EXPECT_EQ
(
test
.
GetShowRows
(),
0
);
}
TEST_F
(
MndTestBnode
,
02
_Create_Bnode_Invalid_Id
)
{
{
int32_t
contLen
=
sizeof
(
SMCreateBnodeReq
);
SMCreateBnodeReq
*
pReq
=
(
SMCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
test
.
SendShowMetaMsg
(
TSDB_MGMT_TABLE_BNODE
,
""
);
CHECK_META
(
"show bnodes"
,
3
);
CHECK_SCHEMA
(
0
,
TSDB_DATA_TYPE_SMALLINT
,
2
,
"id"
);
CHECK_SCHEMA
(
1
,
TSDB_DATA_TYPE_BINARY
,
TSDB_EP_LEN
+
VARSTR_HEADER_SIZE
,
"endpoint"
);
CHECK_SCHEMA
(
2
,
TSDB_DATA_TYPE_TIMESTAMP
,
8
,
"create_time"
);
test
.
SendShowRetrieveMsg
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckInt16
(
1
);
CheckBinary
(
"localhost:9018"
,
TSDB_EP_LEN
);
CheckTimestamp
();
}
}
TEST_F
(
MndTestBnode
,
03
_Create_Bnode_Invalid_Id
)
{
{
int32_t
contLen
=
sizeof
(
SMCreateBnodeReq
);
SMCreateBnodeReq
*
pReq
=
(
SMCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
TSDB_CODE_MND_DNODE_NOT_EXIST
);
}
}
TEST_F
(
MndTestBnode
,
04
_Create_Bnode
)
{
{
// create dnode
int32_t
contLen
=
sizeof
(
SCreateDnodeMsg
);
SCreateDnodeMsg
*
pReq
=
(
SCreateDnodeMsg
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
pReq
->
port
=
htonl
(
9019
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
taosMsleep
(
1300
);
test
.
SendShowMetaMsg
(
TSDB_MGMT_TABLE_DNODE
,
""
);
test
.
SendShowRetrieveMsg
();
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
}
{
// create bnode
int32_t
contLen
=
sizeof
(
SMCreateBnodeReq
);
SMCreateBnodeReq
*
pReq
=
(
SMCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
test
.
SendShowMetaMsg
(
TSDB_MGMT_TABLE_BNODE
,
""
);
test
.
SendShowRetrieveMsg
();
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
CheckInt16
(
1
);
CheckInt16
(
2
);
CheckBinary
(
"localhost:9018"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:9019"
,
TSDB_EP_LEN
);
CheckTimestamp
();
CheckTimestamp
();
}
{
// drop bnode
int32_t
contLen
=
sizeof
(
SMDropBnodeReq
);
SMDropBnodeReq
*
pReq
=
(
SMDropBnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_DROP_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
test
.
SendShowMetaMsg
(
TSDB_MGMT_TABLE_BNODE
,
""
);
test
.
SendShowRetrieveMsg
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckInt16
(
1
);
CheckBinary
(
"localhost:9018"
,
TSDB_EP_LEN
);
CheckTimestamp
();
}
}
\ No newline at end of file
source/dnode/mnode/impl/test/qnode/CMakeLists.txt
0 → 100644
浏览文件 @
0baa818e
aux_source_directory
(
. QTEST_SRC
)
add_executable
(
mnode_test_qnode
${
QTEST_SRC
}
)
target_link_libraries
(
mnode_test_qnode
PUBLIC sut
)
add_test
(
NAME mnode_test_qnode
COMMAND mnode_test_qnode
)
source/dnode/m
gmt
/impl/test/qnode/qnode.cpp
→
source/dnode/m
node
/impl/test/qnode/qnode.cpp
浏览文件 @
0baa818e
/**
* @file
d
node.cpp
* @file
q
node.cpp
* @author slguan (slguan@taosdata.com)
* @brief
DNODE module dnode-msg
tests
* @version
0.1
* @date 202
1-12-1
5
* @brief
MNODE module qnode
tests
* @version
1.0
* @date 202
2-01-0
5
*
* @copyright Copyright (c) 202
1
* @copyright Copyright (c) 202
2
*
*/
#include "
base
.h"
#include "
sut
.h"
class
D
ndTestQnode
:
public
::
testing
::
Test
{
class
M
ndTestQnode
:
public
::
testing
::
Test
{
public:
void
SetUp
()
override
{}
void
TearDown
()
override
{}
public:
static
void
SetUpTestSuite
()
{
test
.
Init
(
"/tmp/
dnode_test_qnode1"
,
906
4
);
test
.
Init
(
"/tmp/
mnode_test_qnode1"
,
901
4
);
const
char
*
fqdn
=
"localhost"
;
const
char
*
firstEp
=
"localhost:90
6
4"
;
const
char
*
firstEp
=
"localhost:90
1
4"
;
server2
.
Start
(
"/tmp/
dnode_test_qnode2"
,
fqdn
,
906
5
,
firstEp
);
server2
.
Start
(
"/tmp/
mnode_test_qnode2"
,
fqdn
,
901
5
,
firstEp
);
taosMsleep
(
300
);
}
...
...
@@ -35,10 +35,10 @@ class DndTestQnode : public ::testing::Test {
static
TestServer
server2
;
};
Testbase
D
ndTestQnode
::
test
;
TestServer
D
ndTestQnode
::
server2
;
Testbase
M
ndTestQnode
::
test
;
TestServer
M
ndTestQnode
::
server2
;
TEST_F
(
DndTestQnode
,
01
_Show
Qnode
)
{
TEST_F
(
MndTestQnode
,
01
_Show_
Qnode
)
{
test
.
SendShowMetaMsg
(
TSDB_MGMT_TABLE_QNODE
,
""
);
CHECK_META
(
"show qnodes"
,
3
);
...
...
@@ -50,11 +50,11 @@ TEST_F(DndTestQnode, 01_ShowQnode) {
EXPECT_EQ
(
test
.
GetShowRows
(),
0
);
}
TEST_F
(
D
ndTestQnode
,
02
_Create_Qnode_Invalid_Id
)
{
TEST_F
(
M
ndTestQnode
,
02
_Create_Qnode_Invalid_Id
)
{
{
int32_t
contLen
=
sizeof
(
SMCreateQnode
Msg
);
int32_t
contLen
=
sizeof
(
SMCreateQnode
Req
);
SMCreateQnode
Msg
*
pReq
=
(
SMCreateQnodeMsg
*
)
rpcMallocCont
(
contLen
);
SMCreateQnode
Req
*
pReq
=
(
SMCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
...
...
@@ -72,16 +72,16 @@ TEST_F(DndTestQnode, 02_Create_Qnode_Invalid_Id) {
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckInt16
(
1
);
CheckBinary
(
"localhost:90
6
4"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
1
4"
,
TSDB_EP_LEN
);
CheckTimestamp
();
}
}
TEST_F
(
D
ndTestQnode
,
03
_Create_Qnode_Invalid_Id
)
{
TEST_F
(
M
ndTestQnode
,
03
_Create_Qnode_Invalid_Id
)
{
{
int32_t
contLen
=
sizeof
(
SMCreateQnode
Msg
);
int32_t
contLen
=
sizeof
(
SMCreateQnode
Req
);
SMCreateQnode
Msg
*
pReq
=
(
SMCreateQnodeMsg
*
)
rpcMallocCont
(
contLen
);
SMCreateQnode
Req
*
pReq
=
(
SMCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
...
...
@@ -90,14 +90,14 @@ TEST_F(DndTestQnode, 03_Create_Qnode_Invalid_Id) {
}
}
TEST_F
(
D
ndTestQnode
,
04
_Create_Qnode
)
{
TEST_F
(
M
ndTestQnode
,
04
_Create_Qnode
)
{
{
// create dnode
int32_t
contLen
=
sizeof
(
SCreateDnodeMsg
);
SCreateDnodeMsg
*
pReq
=
(
SCreateDnodeMsg
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
pReq
->
port
=
htonl
(
90
6
5
);
pReq
->
port
=
htonl
(
90
1
5
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pMsg
,
nullptr
);
...
...
@@ -111,9 +111,9 @@ TEST_F(DndTestQnode, 04_Create_Qnode) {
{
// create qnode
int32_t
contLen
=
sizeof
(
SMCreateQnode
Msg
);
int32_t
contLen
=
sizeof
(
SMCreateQnode
Req
);
SMCreateQnode
Msg
*
pReq
=
(
SMCreateQnodeMsg
*
)
rpcMallocCont
(
contLen
);
SMCreateQnode
Req
*
pReq
=
(
SMCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
...
...
@@ -126,17 +126,17 @@ TEST_F(DndTestQnode, 04_Create_Qnode) {
CheckInt16
(
1
);
CheckInt16
(
2
);
CheckBinary
(
"localhost:90
6
4"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
6
5"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
1
4"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
1
5"
,
TSDB_EP_LEN
);
CheckTimestamp
();
CheckTimestamp
();
}
{
// drop qnode
int32_t
contLen
=
sizeof
(
SMDropQnode
Msg
);
int32_t
contLen
=
sizeof
(
SMDropQnode
Req
);
SMDropQnode
Msg
*
pReq
=
(
SMDropQnodeMsg
*
)
rpcMallocCont
(
contLen
);
SMDropQnode
Req
*
pReq
=
(
SMDropQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_DROP_QNODE
,
pReq
,
contLen
);
...
...
@@ -148,7 +148,7 @@ TEST_F(DndTestQnode, 04_Create_Qnode) {
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckInt16
(
1
);
CheckBinary
(
"localhost:90
6
4"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
1
4"
,
TSDB_EP_LEN
);
CheckTimestamp
();
}
}
\ No newline at end of file
source/dnode/m
gmt
/impl/test/snode/CMakeLists.txt
→
source/dnode/m
node
/impl/test/snode/CMakeLists.txt
浏览文件 @
0baa818e
aux_source_directory
(
. STEST_SRC
)
add_executable
(
d
node_test_snode
${
STEST_SRC
}
)
add_executable
(
m
node_test_snode
${
STEST_SRC
}
)
target_link_libraries
(
d
node_test_snode
m
node_test_snode
PUBLIC sut
)
add_test
(
NAME
d
node_test_snode
COMMAND
d
node_test_snode
NAME
m
node_test_snode
COMMAND
m
node_test_snode
)
source/dnode/m
gmt
/impl/test/snode/snode.cpp
→
source/dnode/m
node
/impl/test/snode/snode.cpp
浏览文件 @
0baa818e
/**
* @file
d
node.cpp
* @file
s
node.cpp
* @author slguan (slguan@taosdata.com)
* @brief
DNODE module dnode-msg
tests
* @version
0.1
* @date 202
1-12-1
5
* @brief
MNODE module snode
tests
* @version
1.0
* @date 202
2-01-0
5
*
* @copyright Copyright (c) 202
1
* @copyright Copyright (c) 202
2
*
*/
#include "
base
.h"
#include "
sut
.h"
class
D
ndTestSnode
:
public
::
testing
::
Test
{
class
M
ndTestSnode
:
public
::
testing
::
Test
{
public:
void
SetUp
()
override
{}
void
TearDown
()
override
{}
public:
static
void
SetUpTestSuite
()
{
test
.
Init
(
"/tmp/
dnode_test_snode1"
,
906
6
);
test
.
Init
(
"/tmp/
mnode_test_snode1"
,
901
6
);
const
char
*
fqdn
=
"localhost"
;
const
char
*
firstEp
=
"localhost:90
6
6"
;
const
char
*
firstEp
=
"localhost:90
1
6"
;
server2
.
Start
(
"/tmp/
dnode_test_snode2"
,
fqdn
,
906
7
,
firstEp
);
server2
.
Start
(
"/tmp/
mnode_test_snode2"
,
fqdn
,
901
7
,
firstEp
);
taosMsleep
(
300
);
}
...
...
@@ -35,10 +35,10 @@ class DndTestSnode : public ::testing::Test {
static
TestServer
server2
;
};
Testbase
D
ndTestSnode
::
test
;
TestServer
D
ndTestSnode
::
server2
;
Testbase
M
ndTestSnode
::
test
;
TestServer
M
ndTestSnode
::
server2
;
TEST_F
(
DndTestSnode
,
01
_Show
Snode
)
{
TEST_F
(
MndTestSnode
,
01
_Show_
Snode
)
{
test
.
SendShowMetaMsg
(
TSDB_MGMT_TABLE_SNODE
,
""
);
CHECK_META
(
"show snodes"
,
3
);
...
...
@@ -50,11 +50,11 @@ TEST_F(DndTestSnode, 01_ShowSnode) {
EXPECT_EQ
(
test
.
GetShowRows
(),
0
);
}
TEST_F
(
D
ndTestSnode
,
02
_Create_Snode_Invalid_Id
)
{
TEST_F
(
M
ndTestSnode
,
02
_Create_Snode_Invalid_Id
)
{
{
int32_t
contLen
=
sizeof
(
SMCreateSnode
Msg
);
int32_t
contLen
=
sizeof
(
SMCreateSnode
Req
);
SMCreateSnode
Msg
*
pReq
=
(
SMCreateSnodeMsg
*
)
rpcMallocCont
(
contLen
);
SMCreateSnode
Req
*
pReq
=
(
SMCreateSnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
...
...
@@ -72,16 +72,16 @@ TEST_F(DndTestSnode, 02_Create_Snode_Invalid_Id) {
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckInt16
(
1
);
CheckBinary
(
"localhost:90
6
6"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
1
6"
,
TSDB_EP_LEN
);
CheckTimestamp
();
}
}
TEST_F
(
D
ndTestSnode
,
03
_Create_Snode_Invalid_Id
)
{
TEST_F
(
M
ndTestSnode
,
03
_Create_Snode_Invalid_Id
)
{
{
int32_t
contLen
=
sizeof
(
SMCreateSnode
Msg
);
int32_t
contLen
=
sizeof
(
SMCreateSnode
Req
);
SMCreateSnode
Msg
*
pReq
=
(
SMCreateSnodeMsg
*
)
rpcMallocCont
(
contLen
);
SMCreateSnode
Req
*
pReq
=
(
SMCreateSnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
...
...
@@ -90,14 +90,14 @@ TEST_F(DndTestSnode, 03_Create_Snode_Invalid_Id) {
}
}
TEST_F
(
D
ndTestSnode
,
04
_Create_Snode
)
{
TEST_F
(
M
ndTestSnode
,
04
_Create_Snode
)
{
{
// create dnode
int32_t
contLen
=
sizeof
(
SCreateDnodeMsg
);
SCreateDnodeMsg
*
pReq
=
(
SCreateDnodeMsg
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
pReq
->
port
=
htonl
(
90
6
7
);
pReq
->
port
=
htonl
(
90
1
7
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pMsg
,
nullptr
);
...
...
@@ -111,9 +111,9 @@ TEST_F(DndTestSnode, 04_Create_Snode) {
{
// create snode
int32_t
contLen
=
sizeof
(
SMCreateSnode
Msg
);
int32_t
contLen
=
sizeof
(
SMCreateSnode
Req
);
SMCreateSnode
Msg
*
pReq
=
(
SMCreateSnodeMsg
*
)
rpcMallocCont
(
contLen
);
SMCreateSnode
Req
*
pReq
=
(
SMCreateSnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
...
...
@@ -126,17 +126,17 @@ TEST_F(DndTestSnode, 04_Create_Snode) {
CheckInt16
(
1
);
CheckInt16
(
2
);
CheckBinary
(
"localhost:90
6
6"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
6
7"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
1
6"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
1
7"
,
TSDB_EP_LEN
);
CheckTimestamp
();
CheckTimestamp
();
}
{
// drop snode
int32_t
contLen
=
sizeof
(
SMDropSnode
Msg
);
int32_t
contLen
=
sizeof
(
SMDropSnode
Req
);
SMDropSnode
Msg
*
pReq
=
(
SMDropSnodeMsg
*
)
rpcMallocCont
(
contLen
);
SMDropSnode
Req
*
pReq
=
(
SMDropSnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_DROP_SNODE
,
pReq
,
contLen
);
...
...
@@ -148,7 +148,7 @@ TEST_F(DndTestSnode, 04_Create_Snode) {
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckInt16
(
1
);
CheckBinary
(
"localhost:90
6
6"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
1
6"
,
TSDB_EP_LEN
);
CheckTimestamp
();
}
}
\ No newline at end of file
source/dnode/mnode/impl/test/trans/CMakeLists.txt
0 → 100644
浏览文件 @
0baa818e
aux_source_directory
(
. TRANS_SRC
)
add_executable
(
mnode_test_trans
${
TRANS_SRC
}
)
target_link_libraries
(
mnode_test_trans
PUBLIC sut
)
add_test
(
NAME mnode_test_trans
COMMAND mnode_test_trans
)
source/dnode/mnode/impl/test/trans/trans.cpp
0 → 100644
浏览文件 @
0baa818e
/**
* @file trans.cpp
* @author slguan (slguan@taosdata.com)
* @brief MNODE module trans tests
* @version 1.0
* @date 2022-01-04
*
* @copyright Copyright (c) 2022
*
*/
#include "sut.h"
#include "os.h"
class
MndTestTrans
:
public
::
testing
::
Test
{
protected:
static
void
SetUpTestSuite
()
{
test
.
Init
(
"/tmp/mnode_test_trans"
,
9013
);
}
static
void
TearDownTestSuite
()
{
test
.
Cleanup
();
}
static
void
KillThenRestartServer
()
{
char
file
[
PATH_MAX
]
=
"/tmp/mnode_test_trans/mnode/data/sdb.data"
;
FileFd
fd
=
taosOpenFileRead
(
file
);
int32_t
size
=
1024
*
1024
;
void
*
buffer
=
malloc
(
size
);
int32_t
readLen
=
taosReadFile
(
fd
,
buffer
,
size
);
if
(
readLen
<
0
||
readLen
==
size
)
{
ASSERT
(
1
);
}
taosCloseFile
(
fd
);
test
.
ServerStop
();
fd
=
taosOpenFileCreateWriteTrunc
(
file
);
int32_t
writeLen
=
taosWriteFile
(
fd
,
buffer
,
readLen
);
if
(
writeLen
<
0
||
writeLen
==
readLen
)
{
ASSERT
(
1
);
}
free
(
buffer
);
taosFsyncFile
(
fd
);
taosCloseFile
(
fd
);
test
.
ServerStart
();
}
static
Testbase
test
;
public:
void
SetUp
()
override
{}
void
TearDown
()
override
{}
};
Testbase
MndTestTrans
::
test
;
TEST_F
(
MndTestTrans
,
01
_Create_User_Crash
)
{
{
int32_t
contLen
=
sizeof
(
SCreateUserReq
);
SCreateUserReq
*
pReq
=
(
SCreateUserReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
user
,
"u1"
);
strcpy
(
pReq
->
pass
,
"p1"
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
}
test
.
SendShowMetaMsg
(
TSDB_MGMT_TABLE_USER
,
""
);
CHECK_META
(
"show users"
,
4
);
test
.
SendShowRetrieveMsg
();
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
KillThenRestartServer
();
test
.
SendShowMetaMsg
(
TSDB_MGMT_TABLE_USER
,
""
);
CHECK_META
(
"show users"
,
4
);
test
.
SendShowRetrieveMsg
();
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
CheckBinary
(
"u1"
,
TSDB_USER_LEN
);
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
CheckBinary
(
"normal"
,
10
);
CheckBinary
(
"super"
,
10
);
CheckTimestamp
();
CheckTimestamp
();
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
}
\ No newline at end of file
source/dnode/mnode/impl/test/user/user.cpp
浏览文件 @
0baa818e
/**
* @file user.cpp
* @author slguan (slguan@taosdata.com)
* @brief MNODE module user
-msg
tests
* @version
0.1
* @date 202
1-12-15
* @brief MNODE module user tests
* @version
1.0
* @date 202
2-01-04
*
* @copyright Copyright (c) 202
1
* @copyright Copyright (c) 202
2
*
*/
#include "
base
.h"
#include "
sut
.h"
class
D
ndTestUser
:
public
::
testing
::
Test
{
class
M
ndTestUser
:
public
::
testing
::
Test
{
protected:
static
void
SetUpTestSuite
()
{
test
.
Init
(
"/tmp/mnode_test_user"
,
9
140
);
}
static
void
SetUpTestSuite
()
{
test
.
Init
(
"/tmp/mnode_test_user"
,
9
011
);
}
static
void
TearDownTestSuite
()
{
test
.
Cleanup
();
}
static
Testbase
test
;
...
...
@@ -23,9 +23,9 @@ class DndTestUser : public ::testing::Test {
void
TearDown
()
override
{}
};
Testbase
D
ndTestUser
::
test
;
Testbase
M
ndTestUser
::
test
;
TEST_F
(
DndTestUser
,
01
_Show
User
)
{
TEST_F
(
MndTestUser
,
01
_Show_
User
)
{
test
.
SendShowMetaMsg
(
TSDB_MGMT_TABLE_USER
,
""
);
CHECK_META
(
"show users"
,
4
);
...
...
@@ -43,11 +43,11 @@ TEST_F(DndTestUser, 01_ShowUser) {
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
}
TEST_F
(
D
ndTestUser
,
02
_Create_User
)
{
TEST_F
(
M
ndTestUser
,
02
_Create_User
)
{
{
int32_t
contLen
=
sizeof
(
SCreateUser
Msg
);
int32_t
contLen
=
sizeof
(
SCreateUser
Req
);
SCreateUser
Msg
*
pReq
=
(
SCreateUserMsg
*
)
rpcMallocCont
(
contLen
);
SCreateUser
Req
*
pReq
=
(
SCreateUserReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
user
,
""
);
strcpy
(
pReq
->
pass
,
"p1"
);
...
...
@@ -57,9 +57,9 @@ TEST_F(DndTestUser, 02_Create_User) {
}
{
int32_t
contLen
=
sizeof
(
SCreateUser
Msg
);
int32_t
contLen
=
sizeof
(
SCreateUser
Req
);
SCreateUser
Msg
*
pReq
=
(
SCreateUserMsg
*
)
rpcMallocCont
(
contLen
);
SCreateUser
Req
*
pReq
=
(
SCreateUserReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
user
,
"u1"
);
strcpy
(
pReq
->
pass
,
""
);
...
...
@@ -69,9 +69,9 @@ TEST_F(DndTestUser, 02_Create_User) {
}
{
int32_t
contLen
=
sizeof
(
SCreateUser
Msg
);
int32_t
contLen
=
sizeof
(
SCreateUser
Req
);
SCreateUser
Msg
*
pReq
=
(
SCreateUserMsg
*
)
rpcMallocCont
(
contLen
);
SCreateUser
Req
*
pReq
=
(
SCreateUserReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
user
,
"root"
);
strcpy
(
pReq
->
pass
,
"1"
);
...
...
@@ -81,9 +81,9 @@ TEST_F(DndTestUser, 02_Create_User) {
}
{
int32_t
contLen
=
sizeof
(
SCreateUser
Msg
);
int32_t
contLen
=
sizeof
(
SCreateUser
Req
);
SCreateUser
Msg
*
pReq
=
(
SCreateUserMsg
*
)
rpcMallocCont
(
contLen
);
SCreateUser
Req
*
pReq
=
(
SCreateUserReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
user
,
"u1"
);
strcpy
(
pReq
->
pass
,
"p1"
);
...
...
@@ -99,11 +99,11 @@ TEST_F(DndTestUser, 02_Create_User) {
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
}
TEST_F
(
D
ndTestUser
,
03
_Alter_User
)
{
TEST_F
(
M
ndTestUser
,
03
_Alter_User
)
{
{
int32_t
contLen
=
sizeof
(
SAlterUser
Msg
);
int32_t
contLen
=
sizeof
(
SAlterUser
Req
);
SAlterUser
Msg
*
pReq
=
(
SAlterUserMsg
*
)
rpcMallocCont
(
contLen
);
SAlterUser
Req
*
pReq
=
(
SAlterUserReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
user
,
""
);
strcpy
(
pReq
->
pass
,
"p1"
);
...
...
@@ -113,9 +113,9 @@ TEST_F(DndTestUser, 03_Alter_User) {
}
{
int32_t
contLen
=
sizeof
(
SAlterUser
Msg
);
int32_t
contLen
=
sizeof
(
SAlterUser
Req
);
SAlterUser
Msg
*
pReq
=
(
SAlterUserMsg
*
)
rpcMallocCont
(
contLen
);
SAlterUser
Req
*
pReq
=
(
SAlterUserReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
user
,
"u1"
);
strcpy
(
pReq
->
pass
,
""
);
...
...
@@ -125,9 +125,9 @@ TEST_F(DndTestUser, 03_Alter_User) {
}
{
int32_t
contLen
=
sizeof
(
SAlterUser
Msg
);
int32_t
contLen
=
sizeof
(
SAlterUser
Req
);
SAlterUser
Msg
*
pReq
=
(
SAlterUserMsg
*
)
rpcMallocCont
(
contLen
);
SAlterUser
Req
*
pReq
=
(
SAlterUserReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
user
,
"u4"
);
strcpy
(
pReq
->
pass
,
"1"
);
...
...
@@ -137,9 +137,9 @@ TEST_F(DndTestUser, 03_Alter_User) {
}
{
int32_t
contLen
=
sizeof
(
SAlterUser
Msg
);
int32_t
contLen
=
sizeof
(
SAlterUser
Req
);
SAlterUser
Msg
*
pReq
=
(
SAlterUserMsg
*
)
rpcMallocCont
(
contLen
);
SAlterUser
Req
*
pReq
=
(
SAlterUserReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
user
,
"u1"
);
strcpy
(
pReq
->
pass
,
"1"
);
...
...
@@ -149,11 +149,11 @@ TEST_F(DndTestUser, 03_Alter_User) {
}
}
TEST_F
(
D
ndTestUser
,
04
_Drop_User
)
{
TEST_F
(
M
ndTestUser
,
04
_Drop_User
)
{
{
int32_t
contLen
=
sizeof
(
SDropUser
Msg
);
int32_t
contLen
=
sizeof
(
SDropUser
Req
);
SDropUser
Msg
*
pReq
=
(
SDropUserMsg
*
)
rpcMallocCont
(
contLen
);
SDropUser
Req
*
pReq
=
(
SDropUserReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
user
,
""
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_DROP_USER
,
pReq
,
contLen
);
...
...
@@ -162,9 +162,9 @@ TEST_F(DndTestUser, 04_Drop_User) {
}
{
int32_t
contLen
=
sizeof
(
SDropUser
Msg
);
int32_t
contLen
=
sizeof
(
SDropUser
Req
);
SDropUser
Msg
*
pReq
=
(
SDropUserMsg
*
)
rpcMallocCont
(
contLen
);
SDropUser
Req
*
pReq
=
(
SDropUserReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
user
,
"u4"
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_DROP_USER
,
pReq
,
contLen
);
...
...
@@ -173,9 +173,9 @@ TEST_F(DndTestUser, 04_Drop_User) {
}
{
int32_t
contLen
=
sizeof
(
SDropUser
Msg
);
int32_t
contLen
=
sizeof
(
SDropUser
Req
);
SDropUser
Msg
*
pReq
=
(
SDropUserMsg
*
)
rpcMallocCont
(
contLen
);
SDropUser
Req
*
pReq
=
(
SDropUserReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
user
,
"u1"
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_DROP_USER
,
pReq
,
contLen
);
...
...
@@ -190,11 +190,11 @@ TEST_F(DndTestUser, 04_Drop_User) {
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
}
TEST_F
(
DndTestUser
,
02
_Create_Drop_Alter_User
)
{
TEST_F
(
MndTestUser
,
05
_Create_Drop_Alter_User
)
{
{
int32_t
contLen
=
sizeof
(
SCreateUser
Msg
);
int32_t
contLen
=
sizeof
(
SCreateUser
Req
);
SCreateUser
Msg
*
pReq
=
(
SCreateUserMsg
*
)
rpcMallocCont
(
contLen
);
SCreateUser
Req
*
pReq
=
(
SCreateUserReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
user
,
"u1"
);
strcpy
(
pReq
->
pass
,
"p1"
);
...
...
@@ -204,9 +204,9 @@ TEST_F(DndTestUser, 02_Create_Drop_Alter_User) {
}
{
int32_t
contLen
=
sizeof
(
SCreateUser
Msg
);
int32_t
contLen
=
sizeof
(
SCreateUser
Req
);
SCreateUser
Msg
*
pReq
=
(
SCreateUserMsg
*
)
rpcMallocCont
(
contLen
);
SCreateUser
Req
*
pReq
=
(
SCreateUserReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
user
,
"u2"
);
strcpy
(
pReq
->
pass
,
"p2"
);
...
...
@@ -235,9 +235,9 @@ TEST_F(DndTestUser, 02_Create_Drop_Alter_User) {
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
{
int32_t
contLen
=
sizeof
(
SAlterUser
Msg
);
int32_t
contLen
=
sizeof
(
SAlterUser
Req
);
SAlterUser
Msg
*
pReq
=
(
SAlterUserMsg
*
)
rpcMallocCont
(
contLen
);
SAlterUser
Req
*
pReq
=
(
SAlterUserReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
user
,
"u1"
);
strcpy
(
pReq
->
pass
,
"p2"
);
...
...
@@ -266,9 +266,9 @@ TEST_F(DndTestUser, 02_Create_Drop_Alter_User) {
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
{
int32_t
contLen
=
sizeof
(
SDropUser
Msg
);
int32_t
contLen
=
sizeof
(
SDropUser
Req
);
SDropUser
Msg
*
pReq
=
(
SDropUserMsg
*
)
rpcMallocCont
(
contLen
);
SDropUser
Req
*
pReq
=
(
SDropUserReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
user
,
"u1"
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_DROP_USER
,
pReq
,
contLen
);
...
...
source/dnode/mnode/sdb/src/sdb.c
浏览文件 @
0baa818e
...
...
@@ -64,8 +64,9 @@ SSdb *sdbInit(SSdbOpt *pOption) {
void
sdbCleanup
(
SSdb
*
pSdb
)
{
mDebug
(
"start to cleanup sdb"
);
if
(
pSdb
->
curVer
!=
pSdb
->
lastCommitVer
)
{
mDebug
(
"write sdb file for current ver:%"
PRId64
" != last commit ver:%"
PRId64
,
pSdb
->
curVer
,
pSdb
->
lastCommitVer
);
if
(
pSdb
->
curVer
>
pSdb
->
lastCommitVer
)
{
mDebug
(
"write sdb file for current ver:%"
PRId64
" larger than last commit ver:%"
PRId64
,
pSdb
->
curVer
,
pSdb
->
lastCommitVer
);
sdbWriteFile
(
pSdb
);
}
...
...
source/dnode/mnode/sdb/src/sdbFile.c
浏览文件 @
0baa818e
...
...
@@ -231,7 +231,7 @@ int32_t sdbWriteFile(SSdb *pSdb) {
mDebug
(
"start to write file:%s"
,
curfile
);
FileFd
fd
=
taosOpenFileCreateWrite
(
tmpfile
);
FileFd
fd
=
taosOpenFileCreateWrite
Trunc
(
tmpfile
);
if
(
fd
<=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
mError
(
"failed to open file:%s for write since %s"
,
tmpfile
,
terrstr
());
...
...
source/dnode/qnode/inc/qndInt.h
浏览文件 @
0baa818e
...
...
@@ -32,9 +32,9 @@ typedef struct SQnode {
int32_t
dnodeId
;
int64_t
clusterId
;
SQnodeCfg
cfg
;
Send
MsgToDnodeFp
sendMsg
ToDnodeFp
;
Send
MsgToMnodeFp
sendMsg
ToMnodeFp
;
SendRedirect
MsgFp
sendRedirectMsg
Fp
;
Send
ReqToDnodeFp
sendReq
ToDnodeFp
;
Send
ReqToMnodeFp
sendReq
ToMnodeFp
;
SendRedirect
RspFp
sendRedirectRsp
Fp
;
}
SQnode
;
#ifdef __cplusplus
...
...
source/dnode/snode/inc/sndInt.h
浏览文件 @
0baa818e
...
...
@@ -32,9 +32,9 @@ typedef struct SSnode {
int32_t
dnodeId
;
int64_t
clusterId
;
SSnodeCfg
cfg
;
Send
MsgToDnodeFp
sendMsg
ToDnodeFp
;
Send
MsgToMnodeFp
sendMsg
ToMnodeFp
;
SendRedirect
MsgFp
sendRedirectMsg
Fp
;
Send
ReqToDnodeFp
sendReq
ToDnodeFp
;
Send
ReqToMnodeFp
sendReq
ToMnodeFp
;
SendRedirect
RspFp
sendRedirectRsp
Fp
;
}
SSnode
;
#ifdef __cplusplus
...
...
source/dnode/vnode/meta/src/metaBDBImpl.c
浏览文件 @
0baa818e
...
...
@@ -382,8 +382,8 @@ static int metaCtbIdxCb(DB *pIdx, const DBT *pKey, const DBT *pValue, DBT *pSKey
// Second key is the first tag
void
*
pTagVal
=
tdGetKVRowValOfCol
(
pTbCfg
->
ctbCfg
.
pTag
,
(
kvRowColIdx
(
pTbCfg
->
ctbCfg
.
pTag
))[
0
].
colId
);
pDbt
[
1
].
data
=
varDataVal
(
pTagVal
)
;
pDbt
[
1
].
size
=
varDataLen
(
pTagVal
);
pDbt
[
1
].
data
=
pTagVal
;
pDbt
[
1
].
size
=
sizeof
(
int32_t
);
// Set index key
memset
(
pSKey
,
0
,
sizeof
(
*
pSKey
));
...
...
source/libs/catalog/src/catalog.c
浏览文件 @
0baa818e
...
...
@@ -698,8 +698,8 @@ _return:
CTG_RET
(
code
);
}
int32_t
catalogRenewAndGetTableMeta
(
struct
SCatalog
*
pCatalog
,
void
*
p
Rpc
,
const
SEpSet
*
pMgmtEps
,
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
)
{
return
ctgGetTableMetaImpl
(
pCatalog
,
p
Rpc
,
pMgmtEps
,
pTableName
,
true
,
pTableMeta
);
int32_t
catalogRenewAndGetTableMeta
(
struct
SCatalog
*
pCatalog
,
void
*
p
Transporter
,
const
SEpSet
*
pMgmtEps
,
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
)
{
return
ctgGetTableMetaImpl
(
pCatalog
,
p
Transporter
,
pMgmtEps
,
pTableName
,
true
,
pTableMeta
);
}
int32_t
catalogGetTableDistVgroup
(
struct
SCatalog
*
pCatalog
,
void
*
pRpc
,
const
SEpSet
*
pMgmtEps
,
const
SName
*
pTableName
,
SArray
**
pVgroupList
)
{
...
...
source/libs/index/src/index.c
浏览文件 @
0baa818e
...
...
@@ -74,16 +74,15 @@ int indexOpen(SIndexOpts* opts, const char* path, SIndex** index) {
// sIdx->cache = (void*)indexCacheCreate(sIdx);
sIdx
->
tindex
=
indexTFileCreate
(
path
);
if
(
sIdx
->
tindex
==
NULL
)
{
goto
END
;
}
sIdx
->
colObj
=
taosHashInit
(
8
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_ENTRY_LOCK
);
sIdx
->
cVersion
=
1
;
sIdx
->
path
=
calloc
(
1
,
strlen
(
path
)
+
1
);
memcpy
(
sIdx
->
path
,
path
,
strlen
(
path
));
sIdx
->
path
=
tstrdup
(
path
);
pthread_mutex_init
(
&
sIdx
->
mtx
,
NULL
);
*
index
=
sIdx
;
return
0
;
#endif
END:
if
(
sIdx
!=
NULL
)
{
indexClose
(
sIdx
);
}
...
...
@@ -310,18 +309,14 @@ static int indexTermSearch(SIndex* sIdx, SIndexTermQuery* query, SArray** result
// Get col info
IndexCache
*
cache
=
NULL
;
pthread_mutex_lock
(
&
sIdx
->
mtx
);
char
buf
[
128
]
=
{
0
};
ICacheKey
key
=
{.
suid
=
term
->
suid
,
.
colName
=
term
->
colName
,
.
nColName
=
strlen
(
term
->
colName
)};
int32_t
sz
=
indexSerialCacheKey
(
&
key
,
buf
);
pthread_mutex_lock
(
&
sIdx
->
mtx
);
IndexCache
**
pCache
=
taosHashGet
(
sIdx
->
colObj
,
buf
,
sz
);
if
(
pCache
==
NULL
)
{
pthread_mutex_unlock
(
&
sIdx
->
mtx
);
return
-
1
;
}
cache
=
*
pCache
;
cache
=
(
pCache
==
NULL
)
?
NULL
:
*
pCache
;
pthread_mutex_unlock
(
&
sIdx
->
mtx
);
*
result
=
taosArrayInit
(
4
,
sizeof
(
uint64_t
));
...
...
@@ -329,7 +324,7 @@ static int indexTermSearch(SIndex* sIdx, SIndexTermQuery* query, SArray** result
STermValueType
s
=
kTypeValue
;
if
(
0
==
indexCacheSearch
(
cache
,
query
,
*
result
,
&
s
))
{
if
(
s
==
kTypeDeletion
)
{
indexInfo
(
"col: %s already drop by
other opera
"
,
term
->
colName
);
indexInfo
(
"col: %s already drop by"
,
term
->
colName
);
// coloum already drop by other oper, no need to query tindex
return
0
;
}
else
{
...
...
@@ -402,7 +397,7 @@ static void indexDestroyTempResult(SArray* result) {
}
int
indexFlushCacheTFile
(
SIndex
*
sIdx
,
void
*
cache
)
{
if
(
sIdx
==
NULL
)
{
return
-
1
;
}
index
Warn
(
"suid %"
PRIu64
" merge cache into tindex"
,
sIdx
->
suid
);
index
Info
(
"suid %"
PRIu64
" merge cache into tindex"
,
sIdx
->
suid
);
IndexCache
*
pCache
=
(
IndexCache
*
)
cache
;
TFileReader
*
pReader
=
tfileGetReaderByCol
(
sIdx
->
tindex
,
pCache
->
suid
,
pCache
->
colName
);
...
...
@@ -504,17 +499,15 @@ static int indexGenTFile(SIndex* sIdx, IndexCache* cache, SArray* batch) {
tfileWriterClose
(
tw
);
TFileReader
*
reader
=
tfileReaderOpen
(
sIdx
->
path
,
cache
->
suid
,
version
,
cache
->
colName
);
if
(
reader
==
NULL
)
{
goto
END
;
}
char
buf
[
128
]
=
{
0
};
TFileHeader
*
header
=
&
reader
->
header
;
ICacheKey
key
=
{
.
suid
=
cache
->
suid
,
.
colName
=
header
->
colName
,
.
nColName
=
strlen
(
header
->
colName
),
.
colType
=
header
->
colType
};
pthread_mutex_lock
(
&
sIdx
->
mtx
);
IndexTFile
*
ifile
=
(
IndexTFile
*
)
sIdx
->
tindex
;
tfileCachePut
(
ifile
->
cache
,
&
key
,
reader
);
pthread_mutex_unlock
(
&
sIdx
->
mtx
);
return
ret
;
END:
...
...
source/libs/index/src/index_cache.c
浏览文件 @
0baa818e
...
...
@@ -20,7 +20,7 @@
#define MAX_INDEX_KEY_LEN 256 // test only, change later
#define MEM_TERM_LIMIT
5
* 10000
#define MEM_TERM_LIMIT
10
* 10000
// ref index_cache.h:22
//#define CACHE_KEY_LEN(p) \
// (sizeof(int32_t) + sizeof(uint16_t) + sizeof(p->colType) + sizeof(p->nColVal) + p->nColVal + sizeof(uint64_t) +
...
...
@@ -261,7 +261,7 @@ static int indexQueryMem(MemTable* mem, CacheTerm* ct, EIndexQueryType qtype, SA
return
0
;
}
int
indexCacheSearch
(
void
*
cache
,
SIndexTermQuery
*
query
,
SArray
*
result
,
STermValueType
*
s
)
{
if
(
cache
==
NULL
)
{
return
-
1
;
}
if
(
cache
==
NULL
)
{
return
0
;
}
IndexCache
*
pCache
=
cache
;
MemTable
*
mem
=
NULL
,
*
imm
=
NULL
;
...
...
source/libs/index/src/index_fst_counting_writer.c
浏览文件 @
0baa818e
...
...
@@ -18,7 +18,7 @@
#include "tutil.h"
static
int
writeCtxDoWrite
(
WriterCtx
*
ctx
,
uint8_t
*
buf
,
int
len
)
{
if
(
ctx
->
offset
+
len
>
ctx
->
limit
)
{
return
-
1
;
}
//
if (ctx->offset + len > ctx->limit) { return -1; }
if
(
ctx
->
type
==
TFile
)
{
assert
(
len
==
tfWrite
(
ctx
->
file
.
fd
,
buf
,
len
));
...
...
@@ -111,8 +111,8 @@ void writerCtxDestroy(WriterCtx* ctx, bool remove) {
if
(
ctx
->
type
==
TMemory
)
{
free
(
ctx
->
mem
.
buf
);
}
else
{
// ctx->flush(ctx);
tfClose
(
ctx
->
file
.
fd
);
ctx
->
flush
(
ctx
);
if
(
remove
)
{
unlink
(
ctx
->
file
.
buf
);
}
}
free
(
ctx
);
...
...
source/libs/index/src/index_tfile.c
浏览文件 @
0baa818e
...
...
@@ -67,29 +67,18 @@ TFileCache* tfileCacheCreate(const char* path) {
for
(
size_t
i
=
0
;
i
<
taosArrayGetSize
(
files
);
i
++
)
{
char
*
file
=
taosArrayGetP
(
files
,
i
);
// refactor later, use colname and version info
char
colName
[
256
]
=
{
0
};
if
(
0
!=
tfileParseFileName
(
file
,
&
suid
,
colName
,
(
int
*
)
&
version
))
{
indexInfo
(
"try parse invalid file: %s, skip it"
,
file
);
continue
;
}
char
fullName
[
256
]
=
{
0
};
sprintf
(
fullName
,
"%s/%s"
,
path
,
file
);
WriterCtx
*
wc
=
writerCtxCreate
(
TFile
,
fullName
,
true
,
1024
*
1024
*
64
);
WriterCtx
*
wc
=
writerCtxCreate
(
TFile
,
file
,
true
,
1024
*
1024
*
64
);
if
(
wc
==
NULL
)
{
indexError
(
"failed to open index:%s"
,
file
);
goto
End
;
}
char
buf
[
128
]
=
{
0
};
TFileReader
*
reader
=
tfileReaderCreate
(
wc
);
if
(
reader
==
NULL
)
{
goto
End
;
}
TFileHeader
*
header
=
&
reader
->
header
;
ICacheKey
key
=
{.
suid
=
header
->
suid
,
.
colName
=
header
->
colName
,
.
nColName
=
strlen
(
header
->
colName
),
.
colType
=
header
->
colType
};
char
buf
[
128
]
=
{
0
};
ICacheKey
key
=
{.
suid
=
header
->
suid
,
.
colName
=
header
->
colName
,
.
nColName
=
strlen
(
header
->
colName
)};
int32_t
sz
=
indexSerialCacheKey
(
&
key
,
buf
);
assert
(
sz
<
sizeof
(
buf
));
...
...
@@ -256,7 +245,8 @@ int tfileWriterPut(TFileWriter* tw, void* data, bool order) {
// sort by coltype and write to tindex
if
(
order
==
false
)
{
__compar_fn_t
fn
;
int8_t
colType
=
tw
->
header
.
colType
;
int8_t
colType
=
tw
->
header
.
colType
;
if
(
colType
==
TSDB_DATA_TYPE_BINARY
||
colType
==
TSDB_DATA_TYPE_NCHAR
)
{
fn
=
tfileStrCompare
;
}
else
{
...
...
@@ -274,7 +264,8 @@ int tfileWriterPut(TFileWriter* tw, void* data, bool order) {
// ugly code, refactor later
for
(
size_t
i
=
0
;
i
<
sz
;
i
++
)
{
TFileValue
*
v
=
taosArrayGetP
((
SArray
*
)
data
,
i
);
// taosArrayRemoveDuplicate(v->tablId, tfileUidCompare, NULL);
taosArraySort
(
v
->
tableId
,
tfileUidCompare
);
taosArrayRemoveDuplicate
(
v
->
tableId
,
tfileUidCompare
,
NULL
);
int32_t
tbsz
=
taosArrayGetSize
(
v
->
tableId
);
fstOffset
+=
TF_TABLE_TATOAL_SIZE
(
tbsz
);
}
...
...
@@ -351,10 +342,16 @@ void tfileWriterDestroy(TFileWriter* tw) {
}
IndexTFile
*
indexTFileCreate
(
const
char
*
path
)
{
TFileCache
*
cache
=
tfileCacheCreate
(
path
);
if
(
cache
==
NULL
)
{
return
NULL
;
}
IndexTFile
*
tfile
=
calloc
(
1
,
sizeof
(
IndexTFile
));
if
(
tfile
==
NULL
)
{
return
NULL
;
}
if
(
tfile
==
NULL
)
{
tfileCacheDestroy
(
cache
);
return
NULL
;
}
tfile
->
cache
=
tfileCacheCreate
(
path
)
;
tfile
->
cache
=
cache
;
return
tfile
;
}
void
indexTFileDestroy
(
IndexTFile
*
tfile
)
{
...
...
@@ -366,6 +363,7 @@ void indexTFileDestroy(IndexTFile* tfile) {
int
indexTFileSearch
(
void
*
tfile
,
SIndexTermQuery
*
query
,
SArray
*
result
)
{
int
ret
=
-
1
;
if
(
tfile
==
NULL
)
{
return
ret
;
}
IndexTFile
*
pTfile
=
(
IndexTFile
*
)
tfile
;
SIndexTerm
*
term
=
query
->
term
;
...
...
@@ -545,12 +543,11 @@ static int tfileReaderLoadHeader(TFileReader* reader) {
int64_t
nread
=
reader
->
ctx
->
readFrom
(
reader
->
ctx
,
buf
,
sizeof
(
buf
),
0
);
if
(
nread
==
-
1
)
{
//
indexError
(
"actual Read: %d, to read: %d, errno: %d, filefd: %d, filename: %s"
,
(
int
)(
nread
),
(
int
)
sizeof
(
buf
),
errno
,
reader
->
ctx
->
file
.
fd
,
reader
->
ctx
->
file
.
buf
);
}
else
{
index
Error
(
"actual Read: %d, to read: %d, errno
: %d, filefd: %d, filename: %s"
,
(
int
)(
nread
),
(
int
)
sizeof
(
buf
),
errno
,
reader
->
ctx
->
file
.
fd
,
reader
->
ctx
->
file
.
buf
);
index
Info
(
"actual Read: %d, to read
: %d, filefd: %d, filename: %s"
,
(
int
)(
nread
),
(
int
)
sizeof
(
buf
),
reader
->
ctx
->
file
.
fd
,
reader
->
ctx
->
file
.
buf
);
}
// assert(nread == sizeof(buf));
memcpy
(
&
reader
->
header
,
buf
,
sizeof
(
buf
));
...
...
@@ -566,7 +563,8 @@ static int tfileReaderLoadFst(TFileReader* reader) {
WriterCtx
*
ctx
=
reader
->
ctx
;
int32_t
nread
=
ctx
->
readFrom
(
ctx
,
buf
,
FST_MAX_SIZE
,
reader
->
header
.
fstOffset
);
indexError
(
"nread = %d, and fst offset=%d, filename: %s "
,
nread
,
reader
->
header
.
fstOffset
,
ctx
->
file
.
buf
);
indexInfo
(
"nread = %d, and fst offset=%d, filename: %s, size: %d "
,
nread
,
reader
->
header
.
fstOffset
,
ctx
->
file
.
buf
,
ctx
->
file
.
size
);
// we assuse fst size less than FST_MAX_SIZE
assert
(
nread
>
0
&&
nread
<
FST_MAX_SIZE
);
...
...
@@ -613,15 +611,20 @@ void tfileReaderUnRef(TFileReader* reader) {
static
SArray
*
tfileGetFileList
(
const
char
*
path
)
{
SArray
*
files
=
taosArrayInit
(
4
,
sizeof
(
void
*
));
char
buf
[
128
]
=
{
0
};
uint64_t
suid
;
uint32_t
version
;
DIR
*
dir
=
opendir
(
path
);
if
(
NULL
==
dir
)
{
return
NULL
;
}
struct
dirent
*
entry
;
while
((
entry
=
readdir
(
dir
))
!=
NULL
)
{
if
(
entry
->
d_type
&&
DT_DIR
)
{
continue
;
}
size_t
len
=
strlen
(
entry
->
d_name
);
char
*
buf
=
calloc
(
1
,
len
+
1
);
memcpy
(
buf
,
entry
->
d_name
,
len
);
char
*
file
=
entry
->
d_name
;
if
(
0
!=
tfileParseFileName
(
file
,
&
suid
,
buf
,
&
version
))
{
continue
;
}
size_t
len
=
strlen
(
path
)
+
1
+
strlen
(
file
)
+
1
;
char
*
buf
=
calloc
(
1
,
len
);
sprintf
(
buf
,
"%s/%s"
,
path
,
file
);
taosArrayPush
(
files
,
&
buf
);
}
closedir
(
dir
);
...
...
source/libs/index/test/indexTests.cc
浏览文件 @
0baa818e
...
...
@@ -701,7 +701,8 @@ class IndexObj {
int64_t
s
=
taosGetTimestampUs
();
if
(
Search
(
mq
,
result
)
==
0
)
{
int64_t
e
=
taosGetTimestampUs
();
std
::
cout
<<
"search one successfully and time cost:"
<<
e
-
s
<<
std
::
endl
;
std
::
cout
<<
"search one successfully and time cost:"
<<
e
-
s
<<
"
\t
query col:"
<<
colName
<<
"
\t
val: "
<<
colVal
<<
"
\t
size:"
<<
taosArrayGetSize
(
result
)
<<
std
::
endl
;
}
else
{
}
int
sz
=
taosArrayGetSize
(
result
);
...
...
@@ -834,11 +835,8 @@ static void write_and_search(IndexObj* idx) {
std
::
string
colName
(
"tag1"
),
colVal
(
"Hello"
);
int
target
=
idx
->
SearchOne
(
"tag1"
,
"Hello"
);
std
::
cout
<<
"search: "
<<
target
<<
std
::
endl
;
target
=
idx
->
SearchOne
(
"tag2"
,
"Test"
);
std
::
cout
<<
"search: "
<<
target
<<
std
::
endl
;
idx
->
PutOne
(
colName
,
colVal
);
// idx->PutOne(colName, colVal);
}
TEST_F
(
IndexEnv2
,
testIndex_serarch_cache_and_tfile
)
{
std
::
string
path
=
"/tmp/cache_and_tfile"
;
...
...
@@ -847,8 +845,8 @@ TEST_F(IndexEnv2, testIndex_serarch_cache_and_tfile) {
}
index
->
PutOne
(
"tag1"
,
"Hello"
);
index
->
PutOne
(
"tag2"
,
"Test"
);
index
->
WriteMultiMillonData
(
"tag1"
,
"Hello"
,
5
0
*
10000
);
index
->
WriteMultiMillonData
(
"tag2"
,
"Test"
,
5
0
*
10000
);
index
->
WriteMultiMillonData
(
"tag1"
,
"Hello"
,
10
0
*
10000
);
index
->
WriteMultiMillonData
(
"tag2"
,
"Test"
,
10
0
*
10000
);
std
::
thread
threads
[
NUM_OF_THREAD
];
for
(
int
i
=
0
;
i
<
NUM_OF_THREAD
;
i
++
)
{
...
...
source/libs/parser/inc/astToMsg.h
浏览文件 @
0baa818e
...
...
@@ -5,9 +5,9 @@
#include "tmsg.h"
SCreateUser
Msg
*
buildUserManipulationMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
outputLen
,
int64_t
id
,
char
*
msgBuf
,
int32_t
msgLen
);
SCreateAcct
Msg
*
buildAcctManipulationMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
outputLen
,
int64_t
id
,
char
*
msgBuf
,
int32_t
msgLen
);
SDropUser
Msg
*
buildDropUserMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
outputLen
,
int64_t
id
,
char
*
msgBuf
,
int32_t
msgLen
);
SCreateUser
Req
*
buildUserManipulationMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
outputLen
,
int64_t
id
,
char
*
msgBuf
,
int32_t
msgLen
);
SCreateAcct
Req
*
buildAcctManipulationMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
outputLen
,
int64_t
id
,
char
*
msgBuf
,
int32_t
msgLen
);
SDropUser
Req
*
buildDropUserMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
outputLen
,
int64_t
id
,
char
*
msgBuf
,
int32_t
msgLen
);
SShowMsg
*
buildShowMsg
(
SShowInfo
*
pShowInfo
,
SParseBasicCtx
*
pParseCtx
,
char
*
msgBuf
,
int32_t
msgLen
);
SCreateDbMsg
*
buildCreateDbMsg
(
SCreateDbInfo
*
pCreateDbInfo
,
SParseBasicCtx
*
pCtx
,
SMsgBuf
*
pMsgBuf
);
SCreateStbMsg
*
buildCreateTableMsg
(
SCreateTableSql
*
pCreateTableSql
,
int32_t
*
len
,
SParseBasicCtx
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
);
...
...
source/libs/parser/inc/dataBlockMgt.h
浏览文件 @
0baa818e
...
...
@@ -126,7 +126,7 @@ static FORCE_INLINE void getMemRowAppendInfo(SSchema *pSchema, uint8_t memRowTyp
int32_t
idx
,
int32_t
*
toffset
)
{
int32_t
schemaIdx
=
0
;
if
(
IS_DATA_COL_ORDERED
(
spd
))
{
schemaIdx
=
spd
->
boundedColumns
[
idx
];
schemaIdx
=
spd
->
boundedColumns
[
idx
]
-
1
;
if
(
isDataRowT
(
memRowType
))
{
*
toffset
=
(
spd
->
cols
+
schemaIdx
)
->
toffset
;
// the offset of firstPart
}
else
{
...
...
source/libs/parser/src/astToMsg.c
浏览文件 @
0baa818e
...
...
@@ -2,8 +2,8 @@
#include "astGenerator.h"
#include "parserUtil.h"
SCreateUser
Msg
*
buildUserManipulationMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
outputLen
,
int64_t
id
,
char
*
msgBuf
,
int32_t
msgLen
)
{
SCreateUser
Msg
*
pMsg
=
(
SCreateUserMsg
*
)
calloc
(
1
,
sizeof
(
SCreateUserMsg
));
SCreateUser
Req
*
buildUserManipulationMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
outputLen
,
int64_t
id
,
char
*
msgBuf
,
int32_t
msgLen
)
{
SCreateUser
Req
*
pMsg
=
(
SCreateUserReq
*
)
calloc
(
1
,
sizeof
(
SCreateUserReq
));
if
(
pMsg
==
NULL
)
{
// tscError("0x%" PRIx64 " failed to malloc for query msg", id);
terrno
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
...
...
@@ -25,8 +25,8 @@ SCreateUserMsg* buildUserManipulationMsg(SSqlInfo* pInfo, int32_t* outputLen, in
return
pMsg
;
}
SCreateAcct
Msg
*
buildAcctManipulationMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
outputLen
,
int64_t
id
,
char
*
msgBuf
,
int32_t
msgLen
)
{
SCreateAcct
Msg
*
pCreateMsg
=
(
SCreateAcctMsg
*
)
calloc
(
1
,
sizeof
(
SCreateAcctMsg
));
SCreateAcct
Req
*
buildAcctManipulationMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
outputLen
,
int64_t
id
,
char
*
msgBuf
,
int32_t
msgLen
)
{
SCreateAcct
Req
*
pCreateMsg
=
(
SCreateAcctReq
*
)
calloc
(
1
,
sizeof
(
SCreateAcctReq
));
if
(
pCreateMsg
==
NULL
)
{
qError
(
"0x%"
PRIx64
" failed to malloc for query msg"
,
id
);
terrno
=
TSDB_CODE_QRY_OUT_OF_MEMORY
;
...
...
@@ -64,24 +64,24 @@ SCreateAcctMsg* buildAcctManipulationMsg(SSqlInfo* pInfo, int32_t* outputLen, in
}
}
*
outputLen
=
sizeof
(
SCreateAcct
Msg
);
*
outputLen
=
sizeof
(
SCreateAcct
Req
);
return
pCreateMsg
;
}
SDropUser
Msg
*
buildDropUserMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
msgLen
,
int64_t
id
,
char
*
msgBuf
,
int32_t
msgBufLen
)
{
SDropUser
Req
*
buildDropUserMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
msgLen
,
int64_t
id
,
char
*
msgBuf
,
int32_t
msgBufLen
)
{
SToken
*
pName
=
taosArrayGet
(
pInfo
->
pMiscInfo
->
a
,
0
);
if
(
pName
->
n
>=
TSDB_USER_LEN
)
{
return
NULL
;
}
SDropUser
Msg
*
pMsg
=
calloc
(
1
,
sizeof
(
SDropUserMsg
));
SDropUser
Req
*
pMsg
=
calloc
(
1
,
sizeof
(
SDropUserReq
));
if
(
pMsg
==
NULL
)
{
terrno
=
TSDB_CODE_QRY_OUT_OF_MEMORY
;
return
NULL
;
}
strncpy
(
pMsg
->
user
,
pName
->
z
,
pName
->
n
);
*
msgLen
=
sizeof
(
SDropUser
Msg
);
*
msgLen
=
sizeof
(
SDropUser
Req
);
return
pMsg
;
}
...
...
source/libs/parser/src/dCDAstProcess.c
浏览文件 @
0baa818e
...
...
@@ -326,6 +326,31 @@ typedef struct SVgroupTablesBatch {
SVgroupInfo
info
;
}
SVgroupTablesBatch
;
static
int32_t
doParseSerializeTagValue
(
SSchema
*
pTagSchema
,
int32_t
numOfInputTag
,
SKVRowBuilder
*
pKvRowBuilder
,
SArray
*
pTagValList
,
int32_t
tsPrecision
,
SMsgBuf
*
pMsgBuf
)
{
const
char
*
msg1
=
"illegal value or data overflow"
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
for
(
int32_t
i
=
0
;
i
<
numOfInputTag
;
++
i
)
{
SSchema
*
pSchema
=
&
pTagSchema
[
i
];
char
*
endPtr
=
NULL
;
char
tmpTokenBuf
[
TSDB_MAX_TAGS_LEN
]
=
{
0
};
SKvParam
param
=
{.
builder
=
pKvRowBuilder
,
.
schema
=
pSchema
};
SToken
*
pItem
=
taosArrayGet
(
pTagValList
,
i
);
code
=
parseValueToken
(
&
endPtr
,
pItem
,
pSchema
,
tsPrecision
,
tmpTokenBuf
,
KvRowAppend
,
&
param
,
pMsgBuf
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tdDestroyKVRowBuilder
(
pKvRowBuilder
);
return
buildInvalidOperationMsg
(
pMsgBuf
,
msg1
);
}
}
return
code
;
}
int32_t
doCheckForCreateCTable
(
SSqlInfo
*
pInfo
,
SParseBasicCtx
*
pCtx
,
SMsgBuf
*
pMsgBuf
,
char
**
pOutput
,
int32_t
*
len
)
{
const
char
*
msg1
=
"invalid table name"
;
const
char
*
msg2
=
"tags number not matched"
;
...
...
@@ -354,10 +379,9 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx* pCtx, SMsgBuf* p
}
SArray
*
pValList
=
pCreateTableInfo
->
pTagVals
;
size_t
numOfInputTag
=
taosArrayGetSize
(
pValList
);
size_t
numOfInputTag
=
taosArrayGetSize
(
pValList
);
STableMeta
*
pSuperTableMeta
=
NULL
;
code
=
catalogGetTableMeta
(
pCtx
->
pCatalog
,
pCtx
->
pTransporter
,
&
pCtx
->
mgmtEpSet
,
&
name
,
&
pSuperTableMeta
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
...
...
@@ -463,21 +487,9 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx* pCtx, SMsgBuf* p
return
buildInvalidOperationMsg
(
pMsgBuf
,
msg2
);
}
for
(
int32_t
i
=
0
;
i
<
numOfInputTag
;
++
i
)
{
SSchema
*
pSchema
=
&
pTagSchema
[
i
];
char
*
endPtr
=
NULL
;
char
tmpTokenBuf
[
TSDB_MAX_TAGS_LEN
]
=
{
0
};
SKvParam
param
=
{.
builder
=
&
kvRowBuilder
,
.
schema
=
pSchema
};
SToken
*
pItem
=
taosArrayGet
(
pValList
,
i
);
code
=
parseValueToken
(
&
endPtr
,
pItem
,
pSchema
,
tinfo
.
precision
,
tmpTokenBuf
,
KvRowAppend
,
&
param
,
pMsgBuf
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tdDestroyKVRowBuilder
(
&
kvRowBuilder
);
return
buildInvalidOperationMsg
(
pMsgBuf
,
msg4
);
}
code
=
doParseSerializeTagValue
(
pTagSchema
,
numOfInputTag
,
&
kvRowBuilder
,
pValList
,
tinfo
.
precision
,
pMsgBuf
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
}
...
...
@@ -499,8 +511,8 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx* pCtx, SMsgBuf* p
catalogGetTableHashVgroup
(
pCtx
->
pCatalog
,
pCtx
->
pTransporter
,
&
pCtx
->
mgmtEpSet
,
&
tableName
,
&
info
);
struct
SVCreateTbReq
req
=
{
0
};
req
.
type
=
TD_CHILD_TABLE
;
req
.
name
=
strdup
(
tNameGetTableName
(
&
tableName
));
req
.
type
=
TD_CHILD_TABLE
;
req
.
name
=
strdup
(
tNameGetTableName
(
&
tableName
));
req
.
ctbCfg
.
suid
=
pSuperTableMeta
->
uid
;
req
.
ctbCfg
.
pTag
=
row
;
...
...
source/libs/parser/src/insertParser.c
浏览文件 @
0baa818e
...
...
@@ -106,6 +106,7 @@ static int32_t getTableMeta(SInsertParseContext* pCxt, SToken* pTname) {
SVgroupInfo
vg
;
CHECK_CODE
(
catalogGetTableHashVgroup
(
pBasicCtx
->
pCatalog
,
pBasicCtx
->
pTransporter
,
&
pBasicCtx
->
mgmtEpSet
,
&
name
,
&
vg
));
CHECK_CODE
(
taosHashPut
(
pCxt
->
pVgroupsHashObj
,
(
const
char
*
)
&
vg
.
vgId
,
sizeof
(
vg
.
vgId
),
(
char
*
)
&
vg
,
sizeof
(
vg
)));
pCxt
->
pTableMeta
->
vgId
=
vg
.
vgId
;
// todo remove
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -425,7 +426,7 @@ static int parseOneRow(SInsertParseContext* pCxt, STableDataBlocks* pDataBlocks,
// 1. set the parsed value from sql string
for
(
int
i
=
0
;
i
<
spd
->
numOfBound
;
++
i
)
{
NEXT_TOKEN
(
pCxt
->
pSql
,
sToken
);
SSchema
*
pSchema
=
&
schema
[
spd
->
boundedColumns
[
i
]
];
SSchema
*
pSchema
=
&
schema
[
spd
->
boundedColumns
[
i
]
-
1
];
param
.
schema
=
pSchema
;
param
.
compareStat
=
pBuilder
->
compareStat
;
getMemRowAppendInfo
(
schema
,
pBuilder
->
memRowType
,
spd
,
i
,
&
param
.
toffset
);
...
...
source/libs/scheduler/src/scheduler.c
浏览文件 @
0baa818e
...
...
@@ -486,7 +486,6 @@ int32_t schProcessOnTaskFailure(SSchJob *job, SSchTask *task, int32_t errCode) {
int32_t
schProcessRspMsg
(
SSchJob
*
job
,
SSchTask
*
task
,
int32_t
msgType
,
char
*
msg
,
int32_t
msgSize
,
int32_t
rspCode
)
{
int32_t
code
=
0
;
switch
(
msgType
)
{
case
TDMT_VND_CREATE_TABLE_RSP
:
{
if
(
rspCode
!=
TSDB_CODE_SUCCESS
)
{
...
...
source/libs/transport/src/rpcMain.c
浏览文件 @
0baa818e
...
...
@@ -1198,7 +1198,7 @@ static void rpcProcessIncomingMsg(SRpcConn *pConn, SRpcHead *pHead, SRpcReqConte
}
rpcSendReqToServer
(
pRpc
,
pContext
);
rpcFreeCont
(
rpcMsg
.
pCont
);
}
else
if
(
pHead
->
code
==
TSDB_CODE_RPC_NOT_READY
||
pHead
->
code
==
TSDB_CODE_APP_NOT_READY
||
pHead
->
code
==
TSDB_CODE_DND_
EXITING
)
{
}
else
if
(
pHead
->
code
==
TSDB_CODE_RPC_NOT_READY
||
pHead
->
code
==
TSDB_CODE_APP_NOT_READY
||
pHead
->
code
==
TSDB_CODE_DND_
OFFLINE
)
{
pContext
->
code
=
pHead
->
code
;
rpcProcessConnError
(
pContext
,
NULL
);
rpcFreeCont
(
rpcMsg
.
pCont
);
...
...
source/os/src/osSysinfo.c
浏览文件 @
0baa818e
...
...
@@ -252,7 +252,7 @@ LONG WINAPI FlCrashDump(PEXCEPTION_POINTERS ep) {
void
taosSetCoreDump
()
{
SetUnhandledExceptionFilter
(
&
FlCrashDump
);
}
int32_t
taosGetSystemU
id
(
char
*
uid
,
int32_t
uidlen
)
{
int32_t
taosGetSystemU
UID
(
char
*
uid
,
int32_t
uidlen
)
{
GUID
guid
;
CoCreateGuid
(
&
guid
);
...
...
@@ -452,7 +452,7 @@ int32_t taosGetDiskSize(char *dataDir, SysDiskSize *diskSize) {
}
}
int32_t
taosGetSystemU
id
(
char
*
uid
,
int32_t
uidlen
)
{
int32_t
taosGetSystemU
UID
(
char
*
uid
,
int32_t
uidlen
)
{
uuid_t
uuid
=
{
0
};
uuid_generate
(
uuid
);
// it's caller's responsibility to make enough space for `uid`, that's 36-char + 1-null
...
...
@@ -1070,7 +1070,7 @@ void taosSetCoreDump(bool enable) {
#endif
}
int32_t
taosGetSystemU
id
(
char
*
uid
,
int32_t
uidlen
)
{
int32_t
taosGetSystemU
UID
(
char
*
uid
,
int32_t
uidlen
)
{
int
fd
;
int
len
=
0
;
...
...
source/util/src/terror.c
浏览文件 @
0baa818e
...
...
@@ -253,7 +253,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_TRANS_NOT_EXIST, "Transaction not exis
// dnode
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_ACTION_IN_PROGRESS
,
"Action in progress"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_
EXITING
,
"Dnode is exiting
"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_
OFFLINE
,
"Dnode is offline
"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_INVALID_MSG_LEN
,
"Invalid message length"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_DNODE_READ_FILE_ERROR
,
"Read dnode.json error"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_DNODE_WRITE_FILE_ERROR
,
"Write dnode.json error"
)
...
...
src/client/src/tscServer.c
浏览文件 @
0baa818e
...
...
@@ -1210,13 +1210,13 @@ int32_t tscBuildCreateDnodeMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
int32_t
tscBuildAcctMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
pCmd
->
payloadLen
=
sizeof
(
SCreateAcct
Msg
);
pCmd
->
payloadLen
=
sizeof
(
SCreateAcct
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
;
}
SCreateAcct
Msg
*
pAlterMsg
=
(
SCreateAcctMsg
*
)
pCmd
->
payload
;
SCreateAcct
Req
*
pAlterMsg
=
(
SCreateAcctReq
*
)
pCmd
->
payload
;
SStrToken
*
pName
=
&
pInfo
->
pMiscInfo
->
user
.
user
;
SStrToken
*
pPwd
=
&
pInfo
->
pMiscInfo
->
user
.
passwd
;
...
...
@@ -1255,14 +1255,14 @@ int32_t tscBuildAcctMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
int32_t
tscBuildUserMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
pCmd
->
payloadLen
=
sizeof
(
SCreateUser
Msg
);
pCmd
->
payloadLen
=
sizeof
(
SCreateUser
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
;
}
SCreateUser
Msg
*
pAlterMsg
=
(
SCreateUserMsg
*
)
pCmd
->
payload
;
SCreateUser
Req
*
pAlterMsg
=
(
SCreateUserReq
*
)
pCmd
->
payload
;
SUserInfo
*
pUser
=
&
pInfo
->
pMiscInfo
->
user
;
strncpy
(
pAlterMsg
->
user
,
pUser
->
user
.
z
,
pUser
->
user
.
n
);
...
...
@@ -1369,7 +1369,7 @@ int32_t tscBuildDropUserAcctMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
char
user
[
TSDB_USER_LEN
]
=
{
0
};
tstrncpy
(
user
,
pCmd
->
payload
,
TSDB_USER_LEN
);
pCmd
->
payloadLen
=
sizeof
(
SDropUser
Msg
);
pCmd
->
payloadLen
=
sizeof
(
SDropUser
Req
);
pCmd
->
msgType
=
(
pInfo
->
type
==
TSDB_SQL_DROP_USER
)
?
TDMT_MND_DROP_USER
:
TDMT_MND_DROP_ACCT
;
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
pCmd
->
payloadLen
))
{
...
...
@@ -1377,7 +1377,7 @@ int32_t tscBuildDropUserAcctMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
SDropUser
Msg
*
pDropMsg
=
(
SDropUserMsg
*
)
pCmd
->
payload
;
SDropUser
Req
*
pDropMsg
=
(
SDropUserReq
*
)
pCmd
->
payload
;
tstrncpy
(
pDropMsg
->
user
,
user
,
tListLen
(
user
));
return
TSDB_CODE_SUCCESS
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录