Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
4e8ebdef
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
4e8ebdef
编写于
3月 24, 2022
作者:
C
Cary Xu
浏览文件
操作
浏览文件
下载
差异文件
support drop sma in tsdb
上级
6bd84f7f
af560c84
变更
60
显示空白变更内容
内联
并排
Showing
60 changed file
with
2366 addition
and
637 deletion
+2366
-637
cmake/stub_CMakeLists.txt.in
cmake/stub_CMakeLists.txt.in
+10
-10
example/src/tstream.c
example/src/tstream.c
+4
-2
include/common/taosdef.h
include/common/taosdef.h
+3
-0
include/common/tmsg.h
include/common/tmsg.h
+29
-16
include/common/tmsgdef.h
include/common/tmsgdef.h
+1
-0
include/libs/sync/sync.h
include/libs/sync/sync.h
+16
-8
include/libs/transport/rpcHead.h
include/libs/transport/rpcHead.h
+0
-0
include/os/osSocket.h
include/os/osSocket.h
+36
-3
source/common/src/tglobal.c
source/common/src/tglobal.c
+4
-1
source/common/src/tmsg.c
source/common/src/tmsg.c
+26
-20
source/dnode/mgmt/mnode/src/mmMsg.c
source/dnode/mgmt/mnode/src/mmMsg.c
+2
-0
source/dnode/mgmt/vnode/src/vmMsg.c
source/dnode/mgmt/vnode/src/vmMsg.c
+1
-0
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+1
-1
source/dnode/mnode/impl/src/mndDef.c
source/dnode/mnode/impl/src/mndDef.c
+21
-0
source/dnode/mnode/impl/src/mndScheduler.c
source/dnode/mnode/impl/src/mndScheduler.c
+38
-15
source/dnode/mnode/impl/src/mndStream.c
source/dnode/mnode/impl/src/mndStream.c
+81
-5
source/dnode/mnode/impl/src/mndTopic.c
source/dnode/mnode/impl/src/mndTopic.c
+1
-1
source/dnode/vnode/src/inc/tqInt.h
source/dnode/vnode/src/inc/tqInt.h
+1
-0
source/dnode/vnode/src/inc/tsdbSma.h
source/dnode/vnode/src/inc/tsdbSma.h
+0
-2
source/dnode/vnode/src/inc/vnd.h
source/dnode/vnode/src/inc/vnd.h
+4
-9
source/dnode/vnode/src/tq/tq.c
source/dnode/vnode/src/tq/tq.c
+80
-41
source/dnode/vnode/src/tq/tqRead.c
source/dnode/vnode/src/tq/tqRead.c
+44
-1
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+23
-40
source/dnode/vnode/src/tsdb/tsdbSma.c
source/dnode/vnode/src/tsdb/tsdbSma.c
+15
-4
source/dnode/vnode/src/vnd/vnodeMain.c
source/dnode/vnode/src/vnd/vnodeMain.c
+3
-2
source/dnode/vnode/src/vnd/vnodeQuery.c
source/dnode/vnode/src/vnd/vnodeQuery.c
+2
-2
source/dnode/vnode/src/vnd/vnodeWrite.c
source/dnode/vnode/src/vnd/vnodeWrite.c
+6
-6
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+11
-1
source/libs/executor/src/executor.c
source/libs/executor/src/executor.c
+1
-1
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+159
-54
source/libs/sync/inc/syncRaftLog.h
source/libs/sync/inc/syncRaftLog.h
+7
-0
source/libs/sync/src/syncAppendEntries.c
source/libs/sync/src/syncAppendEntries.c
+92
-101
source/libs/sync/src/syncAppendEntriesReply.c
source/libs/sync/src/syncAppendEntriesReply.c
+6
-0
source/libs/sync/src/syncCommit.c
source/libs/sync/src/syncCommit.c
+8
-1
source/libs/sync/src/syncIO.c
source/libs/sync/src/syncIO.c
+0
-7
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+23
-19
source/libs/sync/src/syncMessage.c
source/libs/sync/src/syncMessage.c
+6
-6
source/libs/sync/src/syncRaftLog.c
source/libs/sync/src/syncRaftLog.c
+55
-0
source/libs/sync/src/syncReplication.c
source/libs/sync/src/syncReplication.c
+6
-0
source/libs/sync/test/CMakeLists.txt
source/libs/sync/test/CMakeLists.txt
+56
-0
source/libs/sync/test/syncElectTest3.cpp
source/libs/sync/test/syncElectTest3.cpp
+138
-0
source/libs/sync/test/syncLogStoreCheck.cpp
source/libs/sync/test/syncLogStoreCheck.cpp
+105
-0
source/libs/sync/test/syncReplicateLoadTest.cpp
source/libs/sync/test/syncReplicateLoadTest.cpp
+188
-0
source/libs/sync/test/syncReplicateTest.cpp
source/libs/sync/test/syncReplicateTest.cpp
+19
-9
source/libs/sync/test/syncReplicateTest2.cpp
source/libs/sync/test/syncReplicateTest2.cpp
+203
-0
source/libs/sync/test/syncWriteTest.cpp
source/libs/sync/test/syncWriteTest.cpp
+19
-9
source/os/src/osSocket.c
source/os/src/osSocket.c
+0
-11
source/util/src/terror.c
source/util/src/terror.c
+1
-0
tests/script/jenkins/basic.txt
tests/script/jenkins/basic.txt
+5
-3
tests/script/tsim/insert/basic0.sim
tests/script/tsim/insert/basic0.sim
+187
-87
tests/script/tsim/insert/null.sim
tests/script/tsim/insert/null.sim
+195
-77
tests/script/tsim/query/interval-offset.sim
tests/script/tsim/query/interval-offset.sim
+1
-1
tests/script/tsim/table/basic1.sim
tests/script/tsim/table/basic1.sim
+43
-4
tests/script/tsim/testCaseSuite.sim
tests/script/tsim/testCaseSuite.sim
+8
-4
tools/CMakeLists.txt
tools/CMakeLists.txt
+1
-0
tools/shell/CMakeLists.txt
tools/shell/CMakeLists.txt
+1
-3
tools/shell/inc/syncMsg.h
tools/shell/inc/syncMsg.h
+141
-0
tools/shell/inc/tsync.h
tools/shell/inc/tsync.h
+127
-0
tools/shell/src/shellMain.c
tools/shell/src/shellMain.c
+15
-3
tools/shell/src/tnettest.c
tools/shell/src/tnettest.c
+87
-47
未找到文件。
cmake/stub_CMakeLists.txt.in
浏览文件 @
4e8ebdef
# stub
# stub
ExternalProject_Add(stub
#
ExternalProject_Add(stub
GIT_REPOSITORY https://github.com/coolxv/cpp-stub.git
#
GIT_REPOSITORY https://github.com/coolxv/cpp-stub.git
GIT_SUBMODULES "src"
#
GIT_SUBMODULES "src"
SOURCE_DIR "${CMAKE_CONTRIB_DIR}/cpp-stub"
#
SOURCE_DIR "${CMAKE_CONTRIB_DIR}/cpp-stub"
BINARY_DIR "${CMAKE_CONTRIB_DIR}/cpp-stub/src"
#
BINARY_DIR "${CMAKE_CONTRIB_DIR}/cpp-stub/src"
CONFIGURE_COMMAND ""
#
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
#
BUILD_COMMAND ""
INSTALL_COMMAND ""
#
INSTALL_COMMAND ""
TEST_COMMAND ""
#
TEST_COMMAND ""
)
#
)
example/src/tstream.c
浏览文件 @
4e8ebdef
...
@@ -63,7 +63,7 @@ int32_t init_env() {
...
@@ -63,7 +63,7 @@ int32_t init_env() {
}
}
int32_t
create_stream
()
{
int32_t
create_stream
()
{
printf
(
"create
topic
\n
"
);
printf
(
"create
stream
\n
"
);
TAOS_RES
*
pRes
;
TAOS_RES
*
pRes
;
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
if
(
pConn
==
NULL
)
{
if
(
pConn
==
NULL
)
{
...
@@ -77,7 +77,9 @@ int32_t create_stream() {
...
@@ -77,7 +77,9 @@ int32_t create_stream() {
}
}
taos_free_result
(
pRes
);
taos_free_result
(
pRes
);
const
char
*
sql
=
"select ts,k from tu1"
;
/*const char* sql = "select min(k), max(k), sum(k) from tu1";*/
const
char
*
sql
=
"select min(k), max(k), sum(k) as sum_of_k from st1"
;
/*const char* sql = "select sum(k) from tu1 interval(10m)";*/
pRes
=
tmq_create_stream
(
pConn
,
"stream1"
,
"out1"
,
sql
);
pRes
=
tmq_create_stream
(
pConn
,
"stream1"
,
"out1"
,
sql
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to create stream out1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
printf
(
"failed to create stream out1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
...
...
include/common/taosdef.h
浏览文件 @
4e8ebdef
...
@@ -69,6 +69,7 @@ typedef enum {
...
@@ -69,6 +69,7 @@ typedef enum {
TSDB_SMA_STAT_DROPPED
=
2
,
// sma dropped
TSDB_SMA_STAT_DROPPED
=
2
,
// sma dropped
}
ETsdbSmaStat
;
// bit operation
}
ETsdbSmaStat
;
// bit operation
typedef
enum
{
typedef
enum
{
TSDB_SMA_TYPE_BLOCK
=
0
,
// Block-wise SMA
TSDB_SMA_TYPE_BLOCK
=
0
,
// Block-wise SMA
TSDB_SMA_TYPE_TIME_RANGE
=
1
,
// Time-range-wise SMA
TSDB_SMA_TYPE_TIME_RANGE
=
1
,
// Time-range-wise SMA
...
@@ -77,6 +78,8 @@ typedef enum {
...
@@ -77,6 +78,8 @@ typedef enum {
extern
char
*
qtypeStr
[];
extern
char
*
qtypeStr
[];
#define TSDB_PORT_DNODEDNODE 5
#define TSDB_PORT_SYNC 10
#define TSDB_PORT_HTTP 11
#define TSDB_PORT_HTTP 11
#ifdef __cplusplus
#ifdef __cplusplus
...
...
include/common/tmsg.h
浏览文件 @
4e8ebdef
...
@@ -23,8 +23,8 @@
...
@@ -23,8 +23,8 @@
#include "tencode.h"
#include "tencode.h"
#include "thash.h"
#include "thash.h"
#include "tlist.h"
#include "tlist.h"
#include "trow.h"
#include "tname.h"
#include "tname.h"
#include "trow.h"
#include "tuuid.h"
#include "tuuid.h"
#ifdef __cplusplus
#ifdef __cplusplus
...
@@ -472,10 +472,9 @@ typedef struct {
...
@@ -472,10 +472,9 @@ typedef struct {
int32_t
code
;
int32_t
code
;
}
SQueryTableRsp
;
}
SQueryTableRsp
;
int32_t
tSerializeSQueryTableRsp
(
void
*
buf
,
int32_t
bufLen
,
SQueryTableRsp
*
pRsp
);
int32_t
tSerializeSQueryTableRsp
(
void
*
buf
,
int32_t
bufLen
,
SQueryTableRsp
*
pRsp
);
int32_t
tDeserializeSQueryTableRsp
(
void
*
buf
,
int32_t
bufLen
,
SQueryTableRsp
*
pRsp
);
int32_t
tDeserializeSQueryTableRsp
(
void
*
buf
,
int32_t
bufLen
,
SQueryTableRsp
*
pRsp
);
typedef
struct
{
typedef
struct
{
char
db
[
TSDB_DB_FNAME_LEN
];
char
db
[
TSDB_DB_FNAME_LEN
];
...
@@ -1428,9 +1427,8 @@ typedef struct {
...
@@ -1428,9 +1427,8 @@ typedef struct {
SArray
*
rspList
;
// SArray<SVCreateTbRsp>
SArray
*
rspList
;
// SArray<SVCreateTbRsp>
}
SVCreateTbBatchRsp
;
}
SVCreateTbBatchRsp
;
int32_t
tSerializeSVCreateTbBatchRsp
(
void
*
buf
,
int32_t
bufLen
,
SVCreateTbBatchRsp
*
pRsp
);
int32_t
tSerializeSVCreateTbBatchRsp
(
void
*
buf
,
int32_t
bufLen
,
SVCreateTbBatchRsp
*
pRsp
);
int32_t
tDeserializeSVCreateTbBatchRsp
(
void
*
buf
,
int32_t
bufLen
,
SVCreateTbBatchRsp
*
pRsp
);
int32_t
tDeserializeSVCreateTbBatchRsp
(
void
*
buf
,
int32_t
bufLen
,
SVCreateTbBatchRsp
*
pRsp
);
typedef
struct
{
typedef
struct
{
int64_t
ver
;
int64_t
ver
;
...
@@ -2312,6 +2310,11 @@ enum {
...
@@ -2312,6 +2310,11 @@ enum {
STREAM_TASK_STATUS__STOP
,
STREAM_TASK_STATUS__STOP
,
};
};
enum
{
STREAM_NEXT_OP_DST__VND
=
1
,
STREAM_NEXT_OP_DST__SND
,
};
typedef
struct
{
typedef
struct
{
void
*
inputHandle
;
void
*
inputHandle
;
void
*
executor
;
void
*
executor
;
...
@@ -2326,6 +2329,7 @@ typedef struct {
...
@@ -2326,6 +2329,7 @@ typedef struct {
int8_t
pipeSink
;
int8_t
pipeSink
;
int8_t
numOfRunners
;
int8_t
numOfRunners
;
int8_t
parallelizable
;
int8_t
parallelizable
;
int8_t
nextOpDst
;
// vnode or snode
SEpSet
NextOpEp
;
SEpSet
NextOpEp
;
char
*
qmsg
;
char
*
qmsg
;
// not applied to encoder and decoder
// not applied to encoder and decoder
...
@@ -2341,6 +2345,8 @@ static FORCE_INLINE SStreamTask* streamTaskNew(int64_t streamId, int32_t level)
...
@@ -2341,6 +2345,8 @@ static FORCE_INLINE SStreamTask* streamTaskNew(int64_t streamId, int32_t level)
return
NULL
;
return
NULL
;
}
}
pTask
->
taskId
=
tGenIdPI32
();
pTask
->
taskId
=
tGenIdPI32
();
pTask
->
streamId
=
streamId
;
pTask
->
level
=
level
;
pTask
->
status
=
STREAM_TASK_STATUS__RUNNING
;
pTask
->
status
=
STREAM_TASK_STATUS__RUNNING
;
pTask
->
qmsg
=
NULL
;
pTask
->
qmsg
=
NULL
;
return
pTask
;
return
pTask
;
...
@@ -2368,6 +2374,13 @@ typedef struct {
...
@@ -2368,6 +2374,13 @@ typedef struct {
int32_t
reserved
;
int32_t
reserved
;
}
SStreamTaskExecRsp
;
}
SStreamTaskExecRsp
;
typedef
struct
{
SMsgHead
head
;
int64_t
streamId
;
int64_t
version
;
SArray
*
res
;
// SArray<SSDataBlock>
}
SStreamSmaSinkReq
;
#pragma pack(pop)
#pragma pack(pop)
#ifdef __cplusplus
#ifdef __cplusplus
...
...
include/common/tmsgdef.h
浏览文件 @
4e8ebdef
...
@@ -191,6 +191,7 @@ enum {
...
@@ -191,6 +191,7 @@ enum {
TD_DEF_MSG_TYPE
(
TDMT_VND_CONSUME
,
"vnode-consume"
,
SMqCVConsumeReq
,
SMqCVConsumeRsp
)
TD_DEF_MSG_TYPE
(
TDMT_VND_CONSUME
,
"vnode-consume"
,
SMqCVConsumeReq
,
SMqCVConsumeRsp
)
TD_DEF_MSG_TYPE
(
TDMT_VND_TASK_DEPLOY
,
"vnode-task-deploy"
,
SStreamTaskDeployReq
,
SStreamTaskDeployRsp
)
TD_DEF_MSG_TYPE
(
TDMT_VND_TASK_DEPLOY
,
"vnode-task-deploy"
,
SStreamTaskDeployReq
,
SStreamTaskDeployRsp
)
TD_DEF_MSG_TYPE
(
TDMT_VND_TASK_EXEC
,
"vnode-task-exec"
,
SStreamTaskExecReq
,
SStreamTaskExecRsp
)
TD_DEF_MSG_TYPE
(
TDMT_VND_TASK_EXEC
,
"vnode-task-exec"
,
SStreamTaskExecReq
,
SStreamTaskExecRsp
)
TD_DEF_MSG_TYPE
(
TDMT_VND_STREAM_TRIGGER
,
"vnode-stream-trigger"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_CREATE_SMA
,
"vnode-create-sma"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_CREATE_SMA
,
"vnode-create-sma"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_CANCEL_SMA
,
"vnode-cancel-sma"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_CANCEL_SMA
,
"vnode-cancel-sma"
,
NULL
,
NULL
)
...
...
include/libs/sync/sync.h
浏览文件 @
4e8ebdef
...
@@ -35,6 +35,7 @@ typedef enum {
...
@@ -35,6 +35,7 @@ typedef enum {
TAOS_SYNC_STATE_FOLLOWER
=
100
,
TAOS_SYNC_STATE_FOLLOWER
=
100
,
TAOS_SYNC_STATE_CANDIDATE
=
101
,
TAOS_SYNC_STATE_CANDIDATE
=
101
,
TAOS_SYNC_STATE_LEADER
=
102
,
TAOS_SYNC_STATE_LEADER
=
102
,
TAOS_SYNC_STATE_ERROR
=
103
,
}
ESyncState
;
}
ESyncState
;
typedef
struct
SSyncBuffer
{
typedef
struct
SSyncBuffer
{
...
@@ -68,17 +69,20 @@ typedef struct SSnapshot {
...
@@ -68,17 +69,20 @@ typedef struct SSnapshot {
typedef
struct
SSyncFSM
{
typedef
struct
SSyncFSM
{
void
*
data
;
void
*
data
;
// when value in p
Buf
finish a raft flow, FpCommitCb is called, code indicates the result
// when value in p
Msg
finish a raft flow, FpCommitCb is called, code indicates the result
// user can do something according to the code and isWeak. for example, write data into tsdb
// user can do something according to the code and isWeak. for example, write data into tsdb
void
(
*
FpCommitCb
)(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pBuf
,
SyncIndex
index
,
bool
isWeak
,
int32_t
code
);
void
(
*
FpCommitCb
)(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SyncIndex
index
,
bool
isWeak
,
int32_t
code
,
ESyncState
state
);
// when value in p
Buf
has been written into local log store, FpPreCommitCb is called, code indicates the result
// when value in p
Msg
has been written into local log store, FpPreCommitCb is called, code indicates the result
// user can do something according to the code and isWeak. for example, write data into tsdb
// user can do something according to the code and isWeak. for example, write data into tsdb
void
(
*
FpPreCommitCb
)(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pBuf
,
SyncIndex
index
,
bool
isWeak
,
int32_t
code
);
void
(
*
FpPreCommitCb
)(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SyncIndex
index
,
bool
isWeak
,
int32_t
code
,
ESyncState
state
);
// when log entry is updated by a new one, FpRollBackCb is called
// when log entry is updated by a new one, FpRollBackCb is called
// user can do something to roll back. for example, delete data from tsdb, or just ignore it
// user can do something to roll back. for example, delete data from tsdb, or just ignore it
void
(
*
FpRollBackCb
)(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pBuf
,
SyncIndex
index
,
bool
isWeak
,
int32_t
code
);
void
(
*
FpRollBackCb
)(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SyncIndex
index
,
bool
isWeak
,
int32_t
code
,
ESyncState
state
);
// user should implement this function, use "data" to take snapshot into "snapshot"
// user should implement this function, use "data" to take snapshot into "snapshot"
int32_t
(
*
FpTakeSnapshot
)(
SSnapshot
*
snapshot
);
int32_t
(
*
FpTakeSnapshot
)(
SSnapshot
*
snapshot
);
...
@@ -157,10 +161,14 @@ void syncCleanUp();
...
@@ -157,10 +161,14 @@ void syncCleanUp();
int64_t
syncStart
(
const
SSyncInfo
*
pSyncInfo
);
int64_t
syncStart
(
const
SSyncInfo
*
pSyncInfo
);
void
syncStop
(
int64_t
rid
);
void
syncStop
(
int64_t
rid
);
int32_t
syncReconfig
(
int64_t
rid
,
const
SSyncCfg
*
pSyncCfg
);
int32_t
syncReconfig
(
int64_t
rid
,
const
SSyncCfg
*
pSyncCfg
);
int32_t
syncPropose
(
int64_t
rid
,
const
SRpcMsg
*
pMsg
,
bool
isWeak
);
// use this function
int32_t
syncPropose
(
int64_t
rid
,
const
SRpcMsg
*
pMsg
,
bool
isWeak
);
int32_t
syncForwardToPeer
(
int64_t
rid
,
const
SRpcMsg
*
pMsg
,
bool
isWeak
);
// just for compatibility
ESyncState
syncGetMyRole
(
int64_t
rid
);
ESyncState
syncGetMyRole
(
int64_t
rid
);
void
syncGetNodesRole
(
int64_t
rid
,
SNodesRole
*
pNodeRole
);
// propose with sequence number, to implement linearizable semantics
int32_t
syncPropose2
(
int64_t
rid
,
const
SRpcMsg
*
pMsg
,
bool
isWeak
,
uint64_t
seqNum
);
// for compatibility, the same as syncPropose
int32_t
syncForwardToPeer
(
int64_t
rid
,
const
SRpcMsg
*
pMsg
,
bool
isWeak
);
extern
int32_t
sDebugFlag
;
extern
int32_t
sDebugFlag
;
...
...
source/libs/transport/inc
/rpcHead.h
→
include/libs/transport
/rpcHead.h
浏览文件 @
4e8ebdef
文件已移动
include/os/osSocket.h
浏览文件 @
4e8ebdef
...
@@ -51,10 +51,31 @@
...
@@ -51,10 +51,31 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
#if
(defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32))
#if
defined(WINDOWS)
#define htobe64 htonll
#define htobe64 htonll
#endif
#endif
#if defined(WINDOWS)
#define TAOS_EPOLL_WAIT_TIME 100
typedef
SOCKET
eventfd_t
;
#define eventfd(a, b) -1
typedef
SOCKET
EpollFd
;
#define EpollClose(pollFd) epoll_close(pollFd)
#ifndef EPOLLWAKEUP
#define EPOLLWAKEUP (1u << 29)
#endif
#elif defined(_TD_DARWIN_64)
#define TAOS_EPOLL_WAIT_TIME 500
typedef
int32_t
SOCKET
;
typedef
SOCKET
EpollFd
;
#define EpollClose(pollFd) epoll_close(pollFd)
#else
#define TAOS_EPOLL_WAIT_TIME 500
typedef
int32_t
SOCKET
;
typedef
SOCKET
EpollFd
;
#define EpollClose(pollFd) taosCloseSocket(pollFd)
#endif
#if defined(_TD_DARWIN_64)
#if defined(_TD_DARWIN_64)
// #define htobe64 htonll
// #define htobe64 htonll
...
@@ -83,6 +104,17 @@ extern "C" {
...
@@ -83,6 +104,17 @@ extern "C" {
#define TAOS_EPOLL_WAIT_TIME 500
#define TAOS_EPOLL_WAIT_TIME 500
typedef
int32_t
SocketFd
;
typedef
SocketFd
EpollFd
;
typedef
struct
TdSocket
{
#if SOCKET_WITH_LOCK
TdThreadRwlock
rwlock
;
#endif
int
refId
;
SocketFd
fd
;
}
*
TdSocketPtr
,
TdSocket
;
typedef
struct
TdSocketServer
*
TdSocketServerPtr
;
typedef
struct
TdSocketServer
*
TdSocketServerPtr
;
typedef
struct
TdSocket
*
TdSocketPtr
;
typedef
struct
TdSocket
*
TdSocketPtr
;
typedef
struct
TdEpoll
*
TdEpollPtr
;
typedef
struct
TdEpoll
*
TdEpollPtr
;
...
@@ -91,6 +123,7 @@ int32_t taosSendto(TdSocketPtr pSocket, void * msg, int len, unsigned int flags,
...
@@ -91,6 +123,7 @@ int32_t taosSendto(TdSocketPtr pSocket, void * msg, int len, unsigned int flags,
int32_t
taosWriteSocket
(
TdSocketPtr
pSocket
,
void
*
msg
,
int
len
);
int32_t
taosWriteSocket
(
TdSocketPtr
pSocket
,
void
*
msg
,
int
len
);
int32_t
taosReadSocket
(
TdSocketPtr
pSocket
,
void
*
msg
,
int
len
);
int32_t
taosReadSocket
(
TdSocketPtr
pSocket
,
void
*
msg
,
int
len
);
int32_t
taosReadFromSocket
(
TdSocketPtr
pSocket
,
void
*
buf
,
int32_t
len
,
int32_t
flags
,
struct
sockaddr
*
destAddr
,
socklen_t
*
addrLen
);
int32_t
taosReadFromSocket
(
TdSocketPtr
pSocket
,
void
*
buf
,
int32_t
len
,
int32_t
flags
,
struct
sockaddr
*
destAddr
,
socklen_t
*
addrLen
);
int32_t
taosCloseSocketNoCheck1
(
SocketFd
fd
);
int32_t
taosCloseSocket
(
TdSocketPtr
*
ppSocket
);
int32_t
taosCloseSocket
(
TdSocketPtr
*
ppSocket
);
int32_t
taosCloseSocketServer
(
TdSocketServerPtr
*
ppSocketServer
);
int32_t
taosCloseSocketServer
(
TdSocketServerPtr
*
ppSocketServer
);
int32_t
taosShutDownSocketRD
(
TdSocketPtr
pSocket
);
int32_t
taosShutDownSocketRD
(
TdSocketPtr
pSocket
);
...
...
source/common/src/tglobal.c
浏览文件 @
4e8ebdef
...
@@ -132,6 +132,9 @@ bool tsdbForceKeepFile = false;
...
@@ -132,6 +132,9 @@ bool tsdbForceKeepFile = false;
int32_t
tsDiskCfgNum
=
0
;
int32_t
tsDiskCfgNum
=
0
;
SDiskCfg
tsDiskCfg
[
TFS_MAX_DISKS
]
=
{
0
};
SDiskCfg
tsDiskCfg
[
TFS_MAX_DISKS
]
=
{
0
};
// stream scheduler
bool
tsStreamSchedV
=
true
;
/*
/*
* minimum scale for whole system, millisecond by default
* minimum scale for whole system, millisecond by default
* for TSDB_TIME_PRECISION_MILLI: 86400000L
* for TSDB_TIME_PRECISION_MILLI: 86400000L
...
...
source/common/src/tmsg.c
浏览文件 @
4e8ebdef
...
@@ -318,7 +318,7 @@ int32_t tSerializeSVCreateTbReq(void **buf, SVCreateTbReq *pReq) {
...
@@ -318,7 +318,7 @@ int32_t tSerializeSVCreateTbReq(void **buf, SVCreateTbReq *pReq) {
tlen
+=
taosEncodeFixedU32
(
buf
,
(
uint32_t
)
param
->
xFilesFactor
);
tlen
+=
taosEncodeFixedU32
(
buf
,
(
uint32_t
)
param
->
xFilesFactor
);
tlen
+=
taosEncodeFixedI8
(
buf
,
param
->
delayUnit
);
tlen
+=
taosEncodeFixedI8
(
buf
,
param
->
delayUnit
);
tlen
+=
taosEncodeFixedI8
(
buf
,
param
->
nFuncIds
);
tlen
+=
taosEncodeFixedI8
(
buf
,
param
->
nFuncIds
);
for
(
int8_t
i
=
0
;
i
<
param
->
nFuncIds
;
++
i
)
{
for
(
int8_t
i
=
0
;
i
<
param
->
nFuncIds
;
++
i
)
{
tlen
+=
taosEncodeFixedI32
(
buf
,
param
->
pFuncIds
[
i
]);
tlen
+=
taosEncodeFixedI32
(
buf
,
param
->
pFuncIds
[
i
]);
}
}
tlen
+=
taosEncodeFixedI64
(
buf
,
param
->
delay
);
tlen
+=
taosEncodeFixedI64
(
buf
,
param
->
delay
);
...
@@ -345,7 +345,7 @@ int32_t tSerializeSVCreateTbReq(void **buf, SVCreateTbReq *pReq) {
...
@@ -345,7 +345,7 @@ int32_t tSerializeSVCreateTbReq(void **buf, SVCreateTbReq *pReq) {
tlen
+=
taosEncodeFixedU32
(
buf
,
(
uint32_t
)
param
->
xFilesFactor
);
tlen
+=
taosEncodeFixedU32
(
buf
,
(
uint32_t
)
param
->
xFilesFactor
);
tlen
+=
taosEncodeFixedI8
(
buf
,
param
->
delayUnit
);
tlen
+=
taosEncodeFixedI8
(
buf
,
param
->
delayUnit
);
tlen
+=
taosEncodeFixedI8
(
buf
,
param
->
nFuncIds
);
tlen
+=
taosEncodeFixedI8
(
buf
,
param
->
nFuncIds
);
for
(
int8_t
i
=
0
;
i
<
param
->
nFuncIds
;
++
i
)
{
for
(
int8_t
i
=
0
;
i
<
param
->
nFuncIds
;
++
i
)
{
tlen
+=
taosEncodeFixedI32
(
buf
,
param
->
pFuncIds
[
i
]);
tlen
+=
taosEncodeFixedI32
(
buf
,
param
->
pFuncIds
[
i
]);
}
}
tlen
+=
taosEncodeFixedI64
(
buf
,
param
->
delay
);
tlen
+=
taosEncodeFixedI64
(
buf
,
param
->
delay
);
...
@@ -385,7 +385,7 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
...
@@ -385,7 +385,7 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
buf
=
taosDecodeStringTo
(
buf
,
pReq
->
stbCfg
.
pTagSchema
[
i
].
name
);
buf
=
taosDecodeStringTo
(
buf
,
pReq
->
stbCfg
.
pTagSchema
[
i
].
name
);
}
}
buf
=
taosDecodeFixedI16
(
buf
,
&
(
pReq
->
stbCfg
.
nBSmaCols
));
buf
=
taosDecodeFixedI16
(
buf
,
&
(
pReq
->
stbCfg
.
nBSmaCols
));
if
(
pReq
->
stbCfg
.
nBSmaCols
>
0
)
{
if
(
pReq
->
stbCfg
.
nBSmaCols
>
0
)
{
pReq
->
stbCfg
.
pBSmaCols
=
(
col_id_t
*
)
malloc
(
pReq
->
stbCfg
.
nBSmaCols
*
sizeof
(
col_id_t
));
pReq
->
stbCfg
.
pBSmaCols
=
(
col_id_t
*
)
malloc
(
pReq
->
stbCfg
.
nBSmaCols
*
sizeof
(
col_id_t
));
for
(
col_id_t
i
=
0
;
i
<
pReq
->
stbCfg
.
nBSmaCols
;
++
i
)
{
for
(
col_id_t
i
=
0
;
i
<
pReq
->
stbCfg
.
nBSmaCols
;
++
i
)
{
buf
=
taosDecodeFixedI16
(
buf
,
pReq
->
stbCfg
.
pBSmaCols
+
i
);
buf
=
taosDecodeFixedI16
(
buf
,
pReq
->
stbCfg
.
pBSmaCols
+
i
);
...
@@ -393,14 +393,14 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
...
@@ -393,14 +393,14 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
}
else
{
}
else
{
pReq
->
stbCfg
.
pBSmaCols
=
NULL
;
pReq
->
stbCfg
.
pBSmaCols
=
NULL
;
}
}
if
(
pReq
->
rollup
)
{
if
(
pReq
->
rollup
)
{
pReq
->
stbCfg
.
pRSmaParam
=
(
SRSmaParam
*
)
malloc
(
sizeof
(
SRSmaParam
));
pReq
->
stbCfg
.
pRSmaParam
=
(
SRSmaParam
*
)
malloc
(
sizeof
(
SRSmaParam
));
SRSmaParam
*
param
=
pReq
->
stbCfg
.
pRSmaParam
;
SRSmaParam
*
param
=
pReq
->
stbCfg
.
pRSmaParam
;
buf
=
taosDecodeFixedU32
(
buf
,
(
uint32_t
*
)
&
param
->
xFilesFactor
);
buf
=
taosDecodeFixedU32
(
buf
,
(
uint32_t
*
)
&
param
->
xFilesFactor
);
buf
=
taosDecodeFixedI8
(
buf
,
&
param
->
delayUnit
);
buf
=
taosDecodeFixedI8
(
buf
,
&
param
->
delayUnit
);
buf
=
taosDecodeFixedI8
(
buf
,
&
param
->
nFuncIds
);
buf
=
taosDecodeFixedI8
(
buf
,
&
param
->
nFuncIds
);
if
(
param
->
nFuncIds
>
0
)
{
if
(
param
->
nFuncIds
>
0
)
{
for
(
int8_t
i
=
0
;
i
<
param
->
nFuncIds
;
++
i
)
{
for
(
int8_t
i
=
0
;
i
<
param
->
nFuncIds
;
++
i
)
{
buf
=
taosDecodeFixedI32
(
buf
,
param
->
pFuncIds
+
i
);
buf
=
taosDecodeFixedI32
(
buf
,
param
->
pFuncIds
+
i
);
}
}
}
else
{
}
else
{
...
@@ -439,8 +439,8 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
...
@@ -439,8 +439,8 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
buf
=
taosDecodeFixedU32
(
buf
,
(
uint32_t
*
)
&
param
->
xFilesFactor
);
buf
=
taosDecodeFixedU32
(
buf
,
(
uint32_t
*
)
&
param
->
xFilesFactor
);
buf
=
taosDecodeFixedI8
(
buf
,
&
param
->
delayUnit
);
buf
=
taosDecodeFixedI8
(
buf
,
&
param
->
delayUnit
);
buf
=
taosDecodeFixedI8
(
buf
,
&
param
->
nFuncIds
);
buf
=
taosDecodeFixedI8
(
buf
,
&
param
->
nFuncIds
);
if
(
param
->
nFuncIds
>
0
)
{
if
(
param
->
nFuncIds
>
0
)
{
for
(
int8_t
i
=
0
;
i
<
param
->
nFuncIds
;
++
i
)
{
for
(
int8_t
i
=
0
;
i
<
param
->
nFuncIds
;
++
i
)
{
buf
=
taosDecodeFixedI32
(
buf
,
param
->
pFuncIds
+
i
);
buf
=
taosDecodeFixedI32
(
buf
,
param
->
pFuncIds
+
i
);
}
}
}
else
{
}
else
{
...
@@ -2775,7 +2775,6 @@ int32_t tDeserializeSVCreateTbBatchRsp(void *buf, int32_t bufLen, SVCreateTbBatc
...
@@ -2775,7 +2775,6 @@ int32_t tDeserializeSVCreateTbBatchRsp(void *buf, int32_t bufLen, SVCreateTbBatc
return
0
;
return
0
;
}
}
int32_t
tSerializeSVCreateTSmaReq
(
void
**
buf
,
SVCreateTSmaReq
*
pReq
)
{
int32_t
tSerializeSVCreateTSmaReq
(
void
**
buf
,
SVCreateTSmaReq
*
pReq
)
{
int32_t
tlen
=
0
;
int32_t
tlen
=
0
;
...
@@ -2824,7 +2823,8 @@ int32_t tSerializeSCMCreateStreamReq(void *buf, int32_t bufLen, const SCMCreateS
...
@@ -2824,7 +2823,8 @@ int32_t tSerializeSCMCreateStreamReq(void *buf, int32_t bufLen, const SCMCreateS
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
name
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
name
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
outputTbName
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
outputTbName
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
igExists
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
igExists
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
sql
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
sqlLen
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
astLen
)
<
0
)
return
-
1
;
if
(
sqlLen
>
0
&&
tEncodeCStr
(
&
encoder
,
pReq
->
sql
)
<
0
)
return
-
1
;
if
(
sqlLen
>
0
&&
tEncodeCStr
(
&
encoder
,
pReq
->
sql
)
<
0
)
return
-
1
;
if
(
astLen
>
0
&&
tEncodeCStr
(
&
encoder
,
pReq
->
ast
)
<
0
)
return
-
1
;
if
(
astLen
>
0
&&
tEncodeCStr
(
&
encoder
,
pReq
->
ast
)
<
0
)
return
-
1
;
...
@@ -2872,30 +2872,36 @@ void tFreeSCMCreateStreamReq(SCMCreateStreamReq *pReq) {
...
@@ -2872,30 +2872,36 @@ void tFreeSCMCreateStreamReq(SCMCreateStreamReq *pReq) {
}
}
int32_t
tEncodeSStreamTask
(
SCoder
*
pEncoder
,
const
SStreamTask
*
pTask
)
{
int32_t
tEncodeSStreamTask
(
SCoder
*
pEncoder
,
const
SStreamTask
*
pTask
)
{
if
(
tStartEncode
(
pEncoder
)
<
0
)
return
-
1
;
/*if (tStartEncode(pEncoder) < 0) return -1;*/
if
(
tEncodeI64
(
pEncoder
,
pTask
->
streamId
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pEncoder
,
pTask
->
streamId
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
pTask
->
taskId
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
pTask
->
taskId
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
pTask
->
level
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
pTask
->
level
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pTask
->
status
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pTask
->
status
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pTask
->
pipeSource
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pTask
->
pipeSink
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pTask
->
pipeSink
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pTask
->
parallelizable
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pTask
->
nextOpDst
)
<
0
)
return
-
1
;
// if (tEncodeI8(pEncoder, pTask->numOfRunners) < 0) return -1;
// if (tEncodeI8(pEncoder, pTask->numOfRunners) < 0) return -1;
if
(
tEncodeSEpSet
(
pEncoder
,
&
pTask
->
NextOpEp
)
<
0
)
return
-
1
;
if
(
tEncodeSEpSet
(
pEncoder
,
&
pTask
->
NextOpEp
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
pEncoder
,
pTask
->
qmsg
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
pEncoder
,
pTask
->
qmsg
)
<
0
)
return
-
1
;
tEndEncode
(
pEncoder
);
/*tEndEncode(pEncoder);*/
return
pEncoder
->
pos
;
return
pEncoder
->
pos
;
}
}
int32_t
tDecodeSStreamTask
(
SCoder
*
pDecoder
,
SStreamTask
*
pTask
)
{
int32_t
tDecodeSStreamTask
(
SCoder
*
pDecoder
,
SStreamTask
*
pTask
)
{
if
(
tStartDecode
(
pDecoder
)
<
0
)
return
-
1
;
/*if (tStartDecode(pDecoder) < 0) return -1;*/
if
(
tDecodeI64
(
pDecoder
,
&
pTask
->
streamId
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pDecoder
,
&
pTask
->
streamId
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
pTask
->
taskId
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
pTask
->
taskId
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
pTask
->
level
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
pTask
->
level
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pTask
->
status
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pTask
->
status
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pTask
->
pipeSource
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pTask
->
pipeSink
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pTask
->
pipeSink
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pTask
->
parallelizable
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pTask
->
nextOpDst
)
<
0
)
return
-
1
;
// if (tDecodeI8(pDecoder, &pTask->numOfRunners) < 0) return -1;
// if (tDecodeI8(pDecoder, &pTask->numOfRunners) < 0) return -1;
if
(
tDecodeSEpSet
(
pDecoder
,
&
pTask
->
NextOpEp
)
<
0
)
return
-
1
;
if
(
tDecodeSEpSet
(
pDecoder
,
&
pTask
->
NextOpEp
)
<
0
)
return
-
1
;
if
(
tDecodeCStrAlloc
(
pDecoder
,
&
pTask
->
qmsg
)
<
0
)
return
-
1
;
if
(
tDecodeCStrAlloc
(
pDecoder
,
&
pTask
->
qmsg
)
<
0
)
return
-
1
;
tEndDecode
(
pDecoder
);
/*tEndDecode(pDecoder);*/
return
0
;
return
0
;
}
}
...
...
source/dnode/mgmt/mnode/src/mmMsg.c
浏览文件 @
4e8ebdef
...
@@ -142,6 +142,8 @@ void mmInitMsgHandles(SMgmtWrapper *pWrapper) {
...
@@ -142,6 +142,8 @@ void mmInitMsgHandles(SMgmtWrapper *pWrapper) {
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_SUBSCRIBE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_SUBSCRIBE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_MQ_COMMIT_OFFSET
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_MQ_COMMIT_OFFSET
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_GET_SUB_EP
,
(
NodeMsgFp
)
mmProcessReadMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_GET_SUB_EP
,
(
NodeMsgFp
)
mmProcessReadMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_STREAM
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_TASK_DEPLOY_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
// Requests handled by VNODE
// Requests handled by VNODE
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_SET_CONN_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_SET_CONN_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
...
...
source/dnode/mgmt/vnode/src/vmMsg.c
浏览文件 @
4e8ebdef
...
@@ -277,6 +277,7 @@ void vmInitMsgHandles(SMgmtWrapper *pWrapper) {
...
@@ -277,6 +277,7 @@ void vmInitMsgHandles(SMgmtWrapper *pWrapper) {
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_TASK_DEPLOY
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_TASK_DEPLOY
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_QUERY_HEARTBEAT
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_QUERY_HEARTBEAT
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_TASK_EXEC
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_TASK_EXEC
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_STREAM_TRIGGER
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_VNODE
,
(
NodeMsgFp
)
vmProcessMgmtMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_VNODE
,
(
NodeMsgFp
)
vmProcessMgmtMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_ALTER_VNODE
,
(
NodeMsgFp
)
vmProcessMgmtMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_ALTER_VNODE
,
(
NodeMsgFp
)
vmProcessMgmtMsg
,
0
);
...
...
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
4e8ebdef
...
@@ -697,12 +697,12 @@ typedef struct {
...
@@ -697,12 +697,12 @@ typedef struct {
char
*
logicalPlan
;
char
*
logicalPlan
;
char
*
physicalPlan
;
char
*
physicalPlan
;
SArray
*
tasks
;
// SArray<SArray<SStreamTask>>
SArray
*
tasks
;
// SArray<SArray<SStreamTask>>
SArray
*
outputName
;
}
SStreamObj
;
}
SStreamObj
;
int32_t
tEncodeSStreamObj
(
SCoder
*
pEncoder
,
const
SStreamObj
*
pObj
);
int32_t
tEncodeSStreamObj
(
SCoder
*
pEncoder
,
const
SStreamObj
*
pObj
);
int32_t
tDecodeSStreamObj
(
SCoder
*
pDecoder
,
SStreamObj
*
pObj
);
int32_t
tDecodeSStreamObj
(
SCoder
*
pDecoder
,
SStreamObj
*
pObj
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/dnode/mnode/impl/src/mndDef.c
浏览文件 @
4e8ebdef
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
#include "mndDef.h"
#include "mndDef.h"
int32_t
tEncodeSStreamObj
(
SCoder
*
pEncoder
,
const
SStreamObj
*
pObj
)
{
int32_t
tEncodeSStreamObj
(
SCoder
*
pEncoder
,
const
SStreamObj
*
pObj
)
{
int32_t
outputNameSz
=
0
;
if
(
tEncodeCStr
(
pEncoder
,
pObj
->
name
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
pEncoder
,
pObj
->
name
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
pEncoder
,
pObj
->
db
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
pEncoder
,
pObj
->
db
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pEncoder
,
pObj
->
createTime
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pEncoder
,
pObj
->
createTime
)
<
0
)
return
-
1
;
...
@@ -43,6 +44,15 @@ int32_t tEncodeSStreamObj(SCoder *pEncoder, const SStreamObj *pObj) {
...
@@ -43,6 +44,15 @@ int32_t tEncodeSStreamObj(SCoder *pEncoder, const SStreamObj *pObj) {
}
else
{
}
else
{
tEncodeI32
(
pEncoder
,
0
);
tEncodeI32
(
pEncoder
,
0
);
}
}
if
(
pObj
->
outputName
!=
NULL
)
{
outputNameSz
=
taosArrayGetSize
(
pObj
->
outputName
);
}
if
(
tEncodeI32
(
pEncoder
,
outputNameSz
)
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
outputNameSz
;
i
++
)
{
char
*
name
=
taosArrayGetP
(
pObj
->
outputName
,
i
);
if
(
tEncodeCStr
(
pEncoder
,
name
)
<
0
)
return
-
1
;
}
return
pEncoder
->
pos
;
return
pEncoder
->
pos
;
}
}
...
@@ -76,5 +86,16 @@ int32_t tDecodeSStreamObj(SCoder *pDecoder, SStreamObj *pObj) {
...
@@ -76,5 +86,16 @@ int32_t tDecodeSStreamObj(SCoder *pDecoder, SStreamObj *pObj) {
}
else
{
}
else
{
pObj
->
tasks
=
NULL
;
pObj
->
tasks
=
NULL
;
}
}
int32_t
outputNameSz
;
if
(
tDecodeI32
(
pDecoder
,
&
outputNameSz
)
<
0
)
return
-
1
;
pObj
->
outputName
=
taosArrayInit
(
outputNameSz
,
sizeof
(
void
*
));
if
(
pObj
->
outputName
==
NULL
)
{
return
-
1
;
}
for
(
int32_t
i
=
0
;
i
<
outputNameSz
;
i
++
)
{
char
*
name
;
if
(
tDecodeCStrAlloc
(
pDecoder
,
&
name
)
<
0
)
return
-
1
;
taosArrayPush
(
pObj
->
outputName
,
&
name
);
}
return
0
;
return
0
;
}
}
source/dnode/mnode/impl/src/mndScheduler.c
浏览文件 @
4e8ebdef
...
@@ -32,20 +32,23 @@
...
@@ -32,20 +32,23 @@
#include "tname.h"
#include "tname.h"
#include "tuuid.h"
#include "tuuid.h"
int32_t
mndPersistTaskDeployReq
(
STrans
*
pTrans
,
SStreamTask
*
pTask
,
const
SEpSet
*
pEpSet
,
tmsg_t
type
)
{
extern
bool
tsStreamSchedV
;
int32_t
mndPersistTaskDeployReq
(
STrans
*
pTrans
,
SStreamTask
*
pTask
,
const
SEpSet
*
pEpSet
,
tmsg_t
type
,
int32_t
nodeId
)
{
SCoder
encoder
;
SCoder
encoder
;
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
NULL
,
0
,
TD_ENCODER
);
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
NULL
,
0
,
TD_ENCODER
);
tEncodeSStreamTask
(
&
encoder
,
pTask
);
tEncodeSStreamTask
(
&
encoder
,
pTask
);
int32_t
tlen
=
sizeof
(
SMsgHead
)
+
encoder
.
pos
;
int32_t
size
=
encoder
.
pos
;
int32_t
tlen
=
sizeof
(
SMsgHead
)
+
size
;
tCoderClear
(
&
encoder
);
tCoderClear
(
&
encoder
);
void
*
buf
=
malloc
(
tlen
);
void
*
buf
=
malloc
(
tlen
);
if
(
buf
==
NULL
)
{
if
(
buf
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
}
}
((
SMsgHead
*
)
buf
)
->
streamTaskId
=
pTask
->
taskId
;
((
SMsgHead
*
)
buf
)
->
streamTaskId
=
htonl
(
nodeId
)
;
void
*
abuf
=
POINTER_SHIFT
(
buf
,
sizeof
(
SMsgHead
));
void
*
abuf
=
POINTER_SHIFT
(
buf
,
sizeof
(
SMsgHead
));
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
abuf
,
tlen
,
TD_ENCODER
);
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
abuf
,
size
,
TD_ENCODER
);
tEncodeSStreamTask
(
&
encoder
,
pTask
);
tEncodeSStreamTask
(
&
encoder
,
pTask
);
tCoderClear
(
&
encoder
);
tCoderClear
(
&
encoder
);
...
@@ -70,7 +73,7 @@ int32_t mndAssignTaskToVg(SMnode* pMnode, STrans* pTrans, SStreamTask* pTask, SS
...
@@ -70,7 +73,7 @@ int32_t mndAssignTaskToVg(SMnode* pMnode, STrans* pTrans, SStreamTask* pTask, SS
terrno
=
TSDB_CODE_QRY_INVALID_INPUT
;
terrno
=
TSDB_CODE_QRY_INVALID_INPUT
;
return
-
1
;
return
-
1
;
}
}
mndPersistTaskDeployReq
(
pTrans
,
pTask
,
&
plan
->
execNode
.
epSet
,
TDMT_VND_TASK_DEPLOY
);
mndPersistTaskDeployReq
(
pTrans
,
pTask
,
&
plan
->
execNode
.
epSet
,
TDMT_VND_TASK_DEPLOY
,
pVgroup
->
vgId
);
return
0
;
return
0
;
}
}
...
@@ -90,7 +93,7 @@ int32_t mndAssignTaskToSnode(SMnode* pMnode, STrans* pTrans, SStreamTask* pTask,
...
@@ -90,7 +93,7 @@ int32_t mndAssignTaskToSnode(SMnode* pMnode, STrans* pTrans, SStreamTask* pTask,
terrno
=
TSDB_CODE_QRY_INVALID_INPUT
;
terrno
=
TSDB_CODE_QRY_INVALID_INPUT
;
return
-
1
;
return
-
1
;
}
}
mndPersistTaskDeployReq
(
pTrans
,
pTask
,
&
plan
->
execNode
.
epSet
,
TDMT_SND_TASK_DEPLOY
);
mndPersistTaskDeployReq
(
pTrans
,
pTask
,
&
plan
->
execNode
.
epSet
,
TDMT_SND_TASK_DEPLOY
,
0
);
return
0
;
return
0
;
}
}
...
@@ -106,6 +109,7 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
...
@@ -106,6 +109,7 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
int32_t
totLevel
=
LIST_LENGTH
(
pPlan
->
pSubplans
);
int32_t
totLevel
=
LIST_LENGTH
(
pPlan
->
pSubplans
);
pStream
->
tasks
=
taosArrayInit
(
totLevel
,
sizeof
(
SArray
));
pStream
->
tasks
=
taosArrayInit
(
totLevel
,
sizeof
(
SArray
));
int32_t
lastUsedVgId
=
0
;
for
(
int32_t
level
=
0
;
level
<
totLevel
;
level
++
)
{
for
(
int32_t
level
=
0
;
level
<
totLevel
;
level
++
)
{
SArray
*
taskOneLevel
=
taosArrayInit
(
0
,
sizeof
(
SStreamTask
));
SArray
*
taskOneLevel
=
taosArrayInit
(
0
,
sizeof
(
SStreamTask
));
...
@@ -113,9 +117,9 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
...
@@ -113,9 +117,9 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
int32_t
opNum
=
LIST_LENGTH
(
inner
->
pNodeList
);
int32_t
opNum
=
LIST_LENGTH
(
inner
->
pNodeList
);
ASSERT
(
opNum
==
1
);
ASSERT
(
opNum
==
1
);
SSubplan
*
plan
=
nodesListGetNode
(
inner
->
pNodeList
,
level
);
SSubplan
*
plan
=
nodesListGetNode
(
inner
->
pNodeList
,
0
);
if
(
level
==
0
)
{
if
(
level
==
0
)
{
ASSERT
(
plan
->
t
ype
==
SUBPLAN_TYPE_SCAN
);
ASSERT
(
plan
->
subplanT
ype
==
SUBPLAN_TYPE_SCAN
);
void
*
pIter
=
NULL
;
void
*
pIter
=
NULL
;
while
(
1
)
{
while
(
1
)
{
pIter
=
sdbFetch
(
pSdb
,
SDB_VGROUP
,
pIter
,
(
void
**
)
&
pVgroup
);
pIter
=
sdbFetch
(
pSdb
,
SDB_VGROUP
,
pIter
,
(
void
**
)
&
pVgroup
);
...
@@ -125,11 +129,14 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
...
@@ -125,11 +129,14 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
continue
;
continue
;
}
}
lastUsedVgId
=
pVgroup
->
vgId
;
pStream
->
vgNum
++
;
pStream
->
vgNum
++
;
// send to vnode
// send to vnode
SStreamTask
*
pTask
=
streamTaskNew
(
pStream
->
uid
,
level
);
SStreamTask
*
pTask
=
streamTaskNew
(
pStream
->
uid
,
level
);
pTask
->
pipeSource
=
1
;
pTask
->
pipeSink
=
level
==
totLevel
-
1
?
1
:
0
;
pTask
->
pipeSink
=
level
==
totLevel
-
1
?
1
:
0
;
pTask
->
parallelizable
=
1
;
// TODO: set to
// TODO: set to
if
(
mndAssignTaskToVg
(
pMnode
,
pTrans
,
pTask
,
plan
,
pVgroup
)
<
0
)
{
if
(
mndAssignTaskToVg
(
pMnode
,
pTrans
,
pTask
,
plan
,
pVgroup
)
<
0
)
{
sdbRelease
(
pSdb
,
pVgroup
);
sdbRelease
(
pSdb
,
pVgroup
);
...
@@ -140,7 +147,21 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
...
@@ -140,7 +147,21 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
}
}
}
else
{
}
else
{
SStreamTask
*
pTask
=
streamTaskNew
(
pStream
->
uid
,
level
);
SStreamTask
*
pTask
=
streamTaskNew
(
pStream
->
uid
,
level
);
pTask
->
pipeSource
=
0
;
pTask
->
pipeSink
=
level
==
totLevel
-
1
?
1
:
0
;
pTask
->
pipeSink
=
level
==
totLevel
-
1
?
1
:
0
;
pTask
->
parallelizable
=
plan
->
subplanType
==
SUBPLAN_TYPE_SCAN
;
pTask
->
nextOpDst
=
STREAM_NEXT_OP_DST__VND
;
if
(
tsStreamSchedV
)
{
ASSERT
(
lastUsedVgId
!=
0
);
SVgObj
*
pVg
=
mndAcquireVgroup
(
pMnode
,
lastUsedVgId
);
if
(
mndAssignTaskToVg
(
pMnode
,
pTrans
,
pTask
,
plan
,
pVg
)
<
0
)
{
sdbRelease
(
pSdb
,
pVg
);
qDestroyQueryPlan
(
pPlan
);
return
-
1
;
}
sdbRelease
(
pSdb
,
pVg
);
}
else
{
SSnodeObj
*
pSnode
=
mndSchedFetchSnode
(
pMnode
);
SSnodeObj
*
pSnode
=
mndSchedFetchSnode
(
pMnode
);
if
(
pSnode
!=
NULL
)
{
if
(
pSnode
!=
NULL
)
{
if
(
mndAssignTaskToSnode
(
pMnode
,
pTrans
,
pTask
,
plan
,
pSnode
)
<
0
)
{
if
(
mndAssignTaskToSnode
(
pMnode
,
pTrans
,
pTask
,
plan
,
pSnode
)
<
0
)
{
...
@@ -153,6 +174,8 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
...
@@ -153,6 +174,8 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
// TODO: assign to one vg
// TODO: assign to one vg
ASSERT
(
0
);
ASSERT
(
0
);
}
}
}
taosArrayPush
(
taskOneLevel
,
pTask
);
taosArrayPush
(
taskOneLevel
,
pTask
);
}
}
taosArrayPush
(
pStream
->
tasks
,
taskOneLevel
);
taosArrayPush
(
pStream
->
tasks
,
taskOneLevel
);
...
...
source/dnode/mnode/impl/src/mndStream.c
浏览文件 @
4e8ebdef
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
#include "mndScheduler.h"
#include "mndScheduler.h"
#include "mndShow.h"
#include "mndShow.h"
#include "mndStb.h"
#include "mndStb.h"
#include "mndTopic.h"
#include "mndTrans.h"
#include "mndTrans.h"
#include "mndUser.h"
#include "mndUser.h"
#include "mndVgroup.h"
#include "mndVgroup.h"
...
@@ -33,6 +34,7 @@ static int32_t mndStreamActionInsert(SSdb *pSdb, SStreamObj *pStream);
...
@@ -33,6 +34,7 @@ static int32_t mndStreamActionInsert(SSdb *pSdb, SStreamObj *pStream);
static
int32_t
mndStreamActionDelete
(
SSdb
*
pSdb
,
SStreamObj
*
pStream
);
static
int32_t
mndStreamActionDelete
(
SSdb
*
pSdb
,
SStreamObj
*
pStream
);
static
int32_t
mndStreamActionUpdate
(
SSdb
*
pSdb
,
SStreamObj
*
pStream
,
SStreamObj
*
pNewStream
);
static
int32_t
mndStreamActionUpdate
(
SSdb
*
pSdb
,
SStreamObj
*
pStream
,
SStreamObj
*
pNewStream
);
static
int32_t
mndProcessCreateStreamReq
(
SNodeMsg
*
pReq
);
static
int32_t
mndProcessCreateStreamReq
(
SNodeMsg
*
pReq
);
static
int32_t
mndProcessTaskDeployInternalRsp
(
SNodeMsg
*
pRsp
);
/*static int32_t mndProcessDropStreamReq(SNodeMsg *pReq);*/
/*static int32_t mndProcessDropStreamReq(SNodeMsg *pReq);*/
/*static int32_t mndProcessDropStreamInRsp(SNodeMsg *pRsp);*/
/*static int32_t mndProcessDropStreamInRsp(SNodeMsg *pRsp);*/
static
int32_t
mndProcessStreamMetaReq
(
SNodeMsg
*
pReq
);
static
int32_t
mndProcessStreamMetaReq
(
SNodeMsg
*
pReq
);
...
@@ -50,6 +52,8 @@ int32_t mndInitStream(SMnode *pMnode) {
...
@@ -50,6 +52,8 @@ int32_t mndInitStream(SMnode *pMnode) {
.
deleteFp
=
(
SdbDeleteFp
)
mndStreamActionDelete
};
.
deleteFp
=
(
SdbDeleteFp
)
mndStreamActionDelete
};
mndSetMsgHandle
(
pMnode
,
TDMT_MND_CREATE_STREAM
,
mndProcessCreateStreamReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_CREATE_STREAM
,
mndProcessCreateStreamReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_VND_TASK_DEPLOY_RSP
,
mndProcessTaskDeployInternalRsp
);
mndSetMsgHandle
(
pMnode
,
TDMT_SND_TASK_DEPLOY_RSP
,
mndProcessTaskDeployInternalRsp
);
/*mndSetMsgHandle(pMnode, TDMT_MND_DROP_STREAM, mndProcessDropStreamReq);*/
/*mndSetMsgHandle(pMnode, TDMT_MND_DROP_STREAM, mndProcessDropStreamReq);*/
/*mndSetMsgHandle(pMnode, TDMT_MND_DROP_STREAM_RSP, mndProcessDropStreamInRsp);*/
/*mndSetMsgHandle(pMnode, TDMT_MND_DROP_STREAM_RSP, mndProcessDropStreamInRsp);*/
...
@@ -68,7 +72,7 @@ SSdbRaw *mndStreamActionEncode(SStreamObj *pStream) {
...
@@ -68,7 +72,7 @@ SSdbRaw *mndStreamActionEncode(SStreamObj *pStream) {
SCoder
encoder
;
SCoder
encoder
;
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
NULL
,
0
,
TD_ENCODER
);
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
NULL
,
0
,
TD_ENCODER
);
if
(
tEncodeSStreamObj
(
NULL
,
pStream
)
<
0
)
{
if
(
tEncodeSStreamObj
(
&
encoder
,
pStream
)
<
0
)
{
tCoderClear
(
&
encoder
);
tCoderClear
(
&
encoder
);
goto
STREAM_ENCODE_OVER
;
goto
STREAM_ENCODE_OVER
;
}
}
...
@@ -83,7 +87,7 @@ SSdbRaw *mndStreamActionEncode(SStreamObj *pStream) {
...
@@ -83,7 +87,7 @@ SSdbRaw *mndStreamActionEncode(SStreamObj *pStream) {
if
(
buf
==
NULL
)
goto
STREAM_ENCODE_OVER
;
if
(
buf
==
NULL
)
goto
STREAM_ENCODE_OVER
;
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
buf
,
tlen
,
TD_ENCODER
);
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
buf
,
tlen
,
TD_ENCODER
);
if
(
tEncodeSStreamObj
(
NULL
,
pStream
)
<
0
)
{
if
(
tEncodeSStreamObj
(
&
encoder
,
pStream
)
<
0
)
{
tCoderClear
(
&
encoder
);
tCoderClear
(
&
encoder
);
goto
STREAM_ENCODE_OVER
;
goto
STREAM_ENCODE_OVER
;
}
}
...
@@ -135,7 +139,7 @@ SSdbRow *mndStreamActionDecode(SSdbRaw *pRaw) {
...
@@ -135,7 +139,7 @@ SSdbRow *mndStreamActionDecode(SSdbRaw *pRaw) {
SDB_GET_BINARY
(
pRaw
,
dataPos
,
buf
,
tlen
,
STREAM_DECODE_OVER
);
SDB_GET_BINARY
(
pRaw
,
dataPos
,
buf
,
tlen
,
STREAM_DECODE_OVER
);
SCoder
decoder
;
SCoder
decoder
;
tCoderInit
(
&
decoder
,
TD_LITTLE_ENDIAN
,
NULL
,
0
,
TD_DECODER
);
tCoderInit
(
&
decoder
,
TD_LITTLE_ENDIAN
,
buf
,
tlen
+
1
,
TD_DECODER
);
if
(
tDecodeSStreamObj
(
&
decoder
,
pStream
)
<
0
)
{
if
(
tDecodeSStreamObj
(
&
decoder
,
pStream
)
<
0
)
{
goto
STREAM_DECODE_OVER
;
goto
STREAM_DECODE_OVER
;
}
}
...
@@ -191,6 +195,11 @@ void mndReleaseStream(SMnode *pMnode, SStreamObj *pStream) {
...
@@ -191,6 +195,11 @@ void mndReleaseStream(SMnode *pMnode, SStreamObj *pStream) {
sdbRelease
(
pSdb
,
pStream
);
sdbRelease
(
pSdb
,
pStream
);
}
}
static
int32_t
mndProcessTaskDeployInternalRsp
(
SNodeMsg
*
pRsp
)
{
mndTransProcessRsp
(
pRsp
);
return
0
;
}
static
SDbObj
*
mndAcquireDbByStream
(
SMnode
*
pMnode
,
char
*
streamName
)
{
static
SDbObj
*
mndAcquireDbByStream
(
SMnode
*
pMnode
,
char
*
streamName
)
{
SName
name
=
{
0
};
SName
name
=
{
0
};
tNameFromString
(
&
name
,
streamName
,
T_NAME_ACCT
|
T_NAME_DB
|
T_NAME_TABLE
);
tNameFromString
(
&
name
,
streamName
,
T_NAME_ACCT
|
T_NAME_DB
|
T_NAME_TABLE
);
...
@@ -209,6 +218,55 @@ static int32_t mndCheckCreateStreamReq(SCMCreateStreamReq *pCreate) {
...
@@ -209,6 +218,55 @@ static int32_t mndCheckCreateStreamReq(SCMCreateStreamReq *pCreate) {
return
0
;
return
0
;
}
}
static
SArray
*
mndExtractNamesFromAst
(
const
SNode
*
pAst
)
{
if
(
pAst
->
type
!=
QUERY_NODE_SELECT_STMT
)
return
NULL
;
SArray
*
names
=
taosArrayInit
(
0
,
sizeof
(
void
*
));
if
(
names
==
NULL
)
{
return
NULL
;
}
SSelectStmt
*
pSelect
=
(
SSelectStmt
*
)
pAst
;
SNodeList
*
pNodes
=
pSelect
->
pProjectionList
;
SListCell
*
pCell
=
pNodes
->
pHead
;
while
(
pCell
!=
NULL
)
{
if
(
pCell
->
pNode
->
type
!=
QUERY_NODE_FUNCTION
)
{
continue
;
}
SFunctionNode
*
pFunction
=
(
SFunctionNode
*
)
pCell
->
pNode
;
char
*
name
=
strdup
(
pFunction
->
node
.
aliasName
);
taosArrayPush
(
names
,
&
name
);
pCell
=
pCell
->
pNext
;
}
return
names
;
}
static
int32_t
mndStreamGetPlanString
(
const
SCMCreateStreamReq
*
pCreate
,
char
**
pStr
)
{
if
(
NULL
==
pCreate
->
ast
)
{
return
TSDB_CODE_SUCCESS
;
}
SNode
*
pAst
=
NULL
;
int32_t
code
=
nodesStringToNode
(
pCreate
->
ast
,
&
pAst
);
SQueryPlan
*
pPlan
=
NULL
;
if
(
TSDB_CODE_SUCCESS
==
code
)
{
SPlanContext
cxt
=
{
.
pAstRoot
=
pAst
,
.
topicQuery
=
false
,
.
streamQuery
=
true
,
};
code
=
qCreateQueryPlan
(
&
cxt
,
&
pPlan
,
NULL
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodesNodeToString
(
pPlan
,
false
,
pStr
,
NULL
);
}
nodesDestroyNode
(
pAst
);
nodesDestroyNode
(
pPlan
);
terrno
=
code
;
return
code
;
}
static
int32_t
mndCreateStream
(
SMnode
*
pMnode
,
SNodeMsg
*
pReq
,
SCMCreateStreamReq
*
pCreate
,
SDbObj
*
pDb
)
{
static
int32_t
mndCreateStream
(
SMnode
*
pMnode
,
SNodeMsg
*
pReq
,
SCMCreateStreamReq
*
pCreate
,
SDbObj
*
pDb
)
{
mDebug
(
"stream:%s to create"
,
pCreate
->
name
);
mDebug
(
"stream:%s to create"
,
pCreate
->
name
);
SStreamObj
streamObj
=
{
0
};
SStreamObj
streamObj
=
{
0
};
...
@@ -220,8 +278,26 @@ static int32_t mndCreateStream(SMnode *pMnode, SNodeMsg *pReq, SCMCreateStreamRe
...
@@ -220,8 +278,26 @@ static int32_t mndCreateStream(SMnode *pMnode, SNodeMsg *pReq, SCMCreateStreamRe
streamObj
.
dbUid
=
pDb
->
uid
;
streamObj
.
dbUid
=
pDb
->
uid
;
streamObj
.
version
=
1
;
streamObj
.
version
=
1
;
streamObj
.
sql
=
pCreate
->
sql
;
streamObj
.
sql
=
pCreate
->
sql
;
streamObj
.
physicalPlan
=
""
;
/*streamObj.physicalPlan = "";*/
streamObj
.
logicalPlan
=
""
;
streamObj
.
logicalPlan
=
"not implemented"
;
SNode
*
pAst
=
NULL
;
if
(
nodesStringToNode
(
pCreate
->
ast
,
&
pAst
)
<
0
)
{
return
-
1
;
}
SArray
*
names
=
mndExtractNamesFromAst
(
pAst
);
printf
(
"|"
);
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
names
);
i
++
)
{
printf
(
" %15s |"
,
(
char
*
)
taosArrayGetP
(
names
,
i
));
}
printf
(
"
\n
=======================================================
\n
"
);
streamObj
.
outputName
=
names
;
if
(
TSDB_CODE_SUCCESS
!=
mndStreamGetPlanString
(
pCreate
,
&
streamObj
.
physicalPlan
))
{
mError
(
"topic:%s, failed to get plan since %s"
,
pCreate
->
name
,
terrstr
());
return
-
1
;
}
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_TYPE_CREATE_STREAM
,
&
pReq
->
rpcMsg
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_TYPE_CREATE_STREAM
,
&
pReq
->
rpcMsg
);
if
(
pTrans
==
NULL
)
{
if
(
pTrans
==
NULL
)
{
...
...
source/dnode/mnode/impl/src/mndTopic.c
浏览文件 @
4e8ebdef
...
@@ -236,7 +236,7 @@ static int32_t mndCheckCreateTopicReq(SCMCreateTopicReq *pCreate) {
...
@@ -236,7 +236,7 @@ static int32_t mndCheckCreateTopicReq(SCMCreateTopicReq *pCreate) {
return
0
;
return
0
;
}
}
static
int32_t
mndGetPlanString
(
SCMCreateTopicReq
*
pCreate
,
char
**
pStr
)
{
static
int32_t
mndGetPlanString
(
const
SCMCreateTopicReq
*
pCreate
,
char
**
pStr
)
{
if
(
NULL
==
pCreate
->
ast
)
{
if
(
NULL
==
pCreate
->
ast
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
...
source/dnode/vnode/src/inc/tqInt.h
浏览文件 @
4e8ebdef
...
@@ -167,6 +167,7 @@ struct STQ {
...
@@ -167,6 +167,7 @@ struct STQ {
STqMetaStore
*
tqMeta
;
STqMetaStore
*
tqMeta
;
STqPushMgr
*
tqPushMgr
;
STqPushMgr
*
tqPushMgr
;
SHashObj
*
pStreamTasks
;
SHashObj
*
pStreamTasks
;
SVnode
*
pVnode
;
SWal
*
pWal
;
SWal
*
pWal
;
SMeta
*
pVnodeMeta
;
SMeta
*
pVnodeMeta
;
};
};
...
...
source/dnode/vnode/src/inc/tsdbSma.h
浏览文件 @
4e8ebdef
...
@@ -77,6 +77,4 @@ static FORCE_INLINE int tsdbUnLockSma(SSmaEnv *pEnv) {
...
@@ -77,6 +77,4 @@ static FORCE_INLINE int tsdbUnLockSma(SSmaEnv *pEnv) {
return
0
;
return
0
;
}
}
#endif
/* _TD_TSDB_SMA_H_ */
#endif
/* _TD_TSDB_SMA_H_ */
\ No newline at end of file
source/dnode/vnode/src/inc/vnd.h
浏览文件 @
4e8ebdef
...
@@ -82,12 +82,6 @@ struct SVnode {
...
@@ -82,12 +82,6 @@ struct SVnode {
int
vnodeScheduleTask
(
SVnodeTask
*
task
);
int
vnodeScheduleTask
(
SVnodeTask
*
task
);
int32_t
vnodePutToVQueryQ
(
SVnode
*
pVnode
,
struct
SRpcMsg
*
pReq
);
int32_t
vnodePutToVFetchQ
(
SVnode
*
pVnode
,
struct
SRpcMsg
*
pReq
);
int32_t
vnodeSendReq
(
SVnode
*
pVnode
,
struct
SEpSet
*
epSet
,
struct
SRpcMsg
*
pReq
);
int32_t
vnodeSendMnodeReq
(
SVnode
*
pVnode
,
struct
SRpcMsg
*
pReq
);
void
vnodeSendRsp
(
SVnode
*
pVnode
,
struct
SEpSet
*
epSet
,
struct
SRpcMsg
*
pRsp
);
#define vFatal(...) \
#define vFatal(...) \
do { \
do { \
if (vDebugFlag & DEBUG_FATAL) { \
if (vDebugFlag & DEBUG_FATAL) { \
...
@@ -177,19 +171,20 @@ int tqInit();
...
@@ -177,19 +171,20 @@ int tqInit();
void
tqCleanUp
();
void
tqCleanUp
();
// open in each vnode
// open in each vnode
STQ
*
tqOpen
(
const
char
*
path
,
SWal
*
pWal
,
SMeta
*
pMeta
,
STqCfg
*
tqConfig
,
SMemAllocatorFactory
*
allocFac
);
STQ
*
tqOpen
(
const
char
*
path
,
SVnode
*
pVnode
,
SWal
*
pWal
,
SMeta
*
pMeta
,
STqCfg
*
tqConfig
,
SMemAllocatorFactory
*
allocFac
);
void
tqClose
(
STQ
*
);
void
tqClose
(
STQ
*
);
// required by vnode
// required by vnode
int
tqPushMsg
(
STQ
*
,
void
*
msg
,
tmsg_t
msgType
,
int64_t
version
);
int
tqPushMsg
(
STQ
*
,
void
*
msg
,
int32_t
msgLen
,
tmsg_t
msgType
,
int64_t
version
);
int
tqCommit
(
STQ
*
);
int
tqCommit
(
STQ
*
);
int32_t
tqProcessPollReq
(
STQ
*
pTq
,
SRpcMsg
*
pMsg
);
int32_t
tqProcessPollReq
(
STQ
*
pTq
,
SRpcMsg
*
pMsg
);
int32_t
tqProcessSetConnReq
(
STQ
*
pTq
,
char
*
msg
);
int32_t
tqProcessSetConnReq
(
STQ
*
pTq
,
char
*
msg
);
int32_t
tqProcessRebReq
(
STQ
*
pTq
,
char
*
msg
);
int32_t
tqProcessRebReq
(
STQ
*
pTq
,
char
*
msg
);
int32_t
tqProcessTaskExec
(
STQ
*
pTq
,
SRpcMsg
*
msg
);
int32_t
tqProcessTaskExec
(
STQ
*
pTq
,
SRpcMsg
*
msg
);
int32_t
tqProcessTaskDeploy
(
STQ
*
pTq
,
char
*
msg
,
int32_t
msgLen
);
int32_t
tqProcessTaskDeploy
(
STQ
*
pTq
,
char
*
msg
,
int32_t
msgLen
);
int32_t
tqProcessStreamTrigger
(
STQ
*
pTq
,
void
*
data
,
int32_t
dataLen
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/dnode/vnode/src/tq/tq.c
浏览文件 @
4e8ebdef
...
@@ -17,11 +17,14 @@
...
@@ -17,11 +17,14 @@
#include "tqInt.h"
#include "tqInt.h"
#include "tqMetaStore.h"
#include "tqMetaStore.h"
void
tqDebugShowSSData
(
SArray
*
dataBlocks
);
int32_t
tqInit
()
{
return
tqPushMgrInit
();
}
int32_t
tqInit
()
{
return
tqPushMgrInit
();
}
void
tqCleanUp
()
{
tqPushMgrCleanUp
();
}
void
tqCleanUp
()
{
tqPushMgrCleanUp
();
}
STQ
*
tqOpen
(
const
char
*
path
,
SWal
*
pWal
,
SMeta
*
pVnodeMeta
,
STqCfg
*
tqConfig
,
SMemAllocatorFactory
*
allocFac
)
{
STQ
*
tqOpen
(
const
char
*
path
,
SVnode
*
pVnode
,
SWal
*
pWal
,
SMeta
*
pVnodeMeta
,
STqCfg
*
tqConfig
,
SMemAllocatorFactory
*
allocFac
)
{
STQ
*
pTq
=
malloc
(
sizeof
(
STQ
));
STQ
*
pTq
=
malloc
(
sizeof
(
STQ
));
if
(
pTq
==
NULL
)
{
if
(
pTq
==
NULL
)
{
terrno
=
TSDB_CODE_TQ_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_TQ_OUT_OF_MEMORY
;
...
@@ -29,6 +32,7 @@ STQ* tqOpen(const char* path, SWal* pWal, SMeta* pVnodeMeta, STqCfg* tqConfig, S
...
@@ -29,6 +32,7 @@ STQ* tqOpen(const char* path, SWal* pWal, SMeta* pVnodeMeta, STqCfg* tqConfig, S
}
}
pTq
->
path
=
strdup
(
path
);
pTq
->
path
=
strdup
(
path
);
pTq
->
tqConfig
=
tqConfig
;
pTq
->
tqConfig
=
tqConfig
;
pTq
->
pVnode
=
pVnode
;
pTq
->
pWal
=
pWal
;
pTq
->
pWal
=
pWal
;
pTq
->
pVnodeMeta
=
pVnodeMeta
;
pTq
->
pVnodeMeta
=
pVnodeMeta
;
#if 0
#if 0
...
@@ -68,46 +72,19 @@ void tqClose(STQ* pTq) {
...
@@ -68,46 +72,19 @@ void tqClose(STQ* pTq) {
// TODO
// TODO
}
}
int
tqPushMsg
(
STQ
*
pTq
,
void
*
msg
,
tmsg_t
msgType
,
int64_t
version
)
{
int
tqPushMsg
(
STQ
*
pTq
,
void
*
msg
,
int32_t
msgLen
,
tmsg_t
msgType
,
int64_t
version
)
{
if
(
msgType
!=
TDMT_VND_SUBMIT
)
return
0
;
if
(
msgType
!=
TDMT_VND_SUBMIT
)
return
0
;
void
*
data
=
malloc
(
msgLen
);
void
*
pIter
=
NULL
;
if
(
data
==
NULL
)
{
while
(
1
)
{
pIter
=
taosHashIterate
(
pTq
->
pStreamTasks
,
pIter
);
if
(
pIter
==
NULL
)
break
;
SStreamTask
*
pTask
=
(
SStreamTask
*
)
pIter
;
if
(
!
pTask
->
pipeSource
)
continue
;
int32_t
workerId
=
0
;
void
*
exec
=
pTask
->
runner
[
workerId
].
executor
;
qSetStreamInput
(
exec
,
msg
,
STREAM_DATA_TYPE_SUBMIT_BLOCK
);
SArray
*
pRes
=
taosArrayInit
(
0
,
sizeof
(
SSDataBlock
));
while
(
1
)
{
SSDataBlock
*
output
;
uint64_t
ts
;
if
(
qExecTask
(
exec
,
&
output
,
&
ts
)
<
0
)
{
ASSERT
(
false
);
}
if
(
output
==
NULL
)
{
break
;
}
taosArrayPush
(
pRes
,
output
);
}
if
(
pTask
->
pipeSink
)
{
// write back
}
else
{
int32_t
tlen
=
sizeof
(
SStreamExecMsgHead
)
+
tEncodeDataBlocks
(
NULL
,
pRes
);
void
*
buf
=
rpcMallocCont
(
tlen
);
if
(
buf
==
NULL
)
{
return
-
1
;
return
-
1
;
}
}
void
*
abuf
=
POINTER_SHIFT
(
buf
,
sizeof
(
SStreamExecMsgHead
));
memcpy
(
data
,
msg
,
msgLen
);
tEncodeDataBlocks
(
abuf
,
pRes
);
SRpcMsg
req
=
{
// serialize
.
msgType
=
TDMT_VND_STREAM_TRIGGER
,
// to next level
.
pCont
=
data
,
}
.
contLen
=
msgLen
,
}
};
tmsgPutToQueue
(
&
pTq
->
pVnode
->
msgCb
,
FETCH_QUEUE
,
&
req
);
#if 0
#if 0
void* pIter = taosHashIterate(pTq->tqPushMgr->pHash, NULL);
void* pIter = taosHashIterate(pTq->tqPushMgr->pHash, NULL);
...
@@ -483,7 +460,9 @@ int32_t tqProcessTaskDeploy(STQ* pTq, char* msg, int32_t msgLen) {
...
@@ -483,7 +460,9 @@ int32_t tqProcessTaskDeploy(STQ* pTq, char* msg, int32_t msgLen) {
}
}
SCoder
decoder
;
SCoder
decoder
;
tCoderInit
(
&
decoder
,
TD_LITTLE_ENDIAN
,
(
uint8_t
*
)
msg
,
msgLen
,
TD_DECODER
);
tCoderInit
(
&
decoder
,
TD_LITTLE_ENDIAN
,
(
uint8_t
*
)
msg
,
msgLen
,
TD_DECODER
);
tDecodeSStreamTask
(
&
decoder
,
pTask
);
if
(
tDecodeSStreamTask
(
&
decoder
,
pTask
)
<
0
)
{
ASSERT
(
0
);
}
tCoderClear
(
&
decoder
);
tCoderClear
(
&
decoder
);
tqExpandTask
(
pTq
,
pTask
,
8
);
tqExpandTask
(
pTq
,
pTask
,
8
);
...
@@ -560,7 +539,11 @@ void tqDebugShowSSData(SArray* dataBlocks) {
...
@@ -560,7 +539,11 @@ void tqDebugShowSSData(SArray* dataBlocks) {
break
;
break
;
case
TSDB_DATA_TYPE_INT
:
case
TSDB_DATA_TYPE_INT
:
case
TSDB_DATA_TYPE_UINT
:
case
TSDB_DATA_TYPE_UINT
:
printf
(
" %15u |"
,
*
(
uint32_t
*
)
var
);
printf
(
" %15d |"
,
*
(
int32_t
*
)
var
);
break
;
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_UBIGINT
:
printf
(
" %15ld |"
,
*
(
int64_t
*
)
var
);
break
;
break
;
}
}
}
}
...
@@ -569,6 +552,62 @@ void tqDebugShowSSData(SArray* dataBlocks) {
...
@@ -569,6 +552,62 @@ void tqDebugShowSSData(SArray* dataBlocks) {
}
}
}
}
int32_t
tqProcessStreamTrigger
(
STQ
*
pTq
,
void
*
data
,
int32_t
dataLen
)
{
void
*
pIter
=
NULL
;
while
(
1
)
{
pIter
=
taosHashIterate
(
pTq
->
pStreamTasks
,
pIter
);
if
(
pIter
==
NULL
)
break
;
SStreamTask
*
pTask
=
(
SStreamTask
*
)
pIter
;
if
(
!
pTask
->
pipeSource
)
continue
;
int32_t
workerId
=
0
;
void
*
exec
=
pTask
->
runner
[
workerId
].
executor
;
qSetStreamInput
(
exec
,
data
,
STREAM_DATA_TYPE_SUBMIT_BLOCK
);
SArray
*
pRes
=
taosArrayInit
(
0
,
sizeof
(
SSDataBlock
));
while
(
1
)
{
SSDataBlock
*
output
;
uint64_t
ts
;
if
(
qExecTask
(
exec
,
&
output
,
&
ts
)
<
0
)
{
ASSERT
(
false
);
}
if
(
output
==
NULL
)
{
break
;
}
taosArrayPush
(
pRes
,
output
);
}
if
(
pTask
->
pipeSink
)
{
// write back
/*printf("reach end\n");*/
tqDebugShowSSData
(
pRes
);
}
else
{
int32_t
tlen
=
sizeof
(
SStreamExecMsgHead
)
+
tEncodeDataBlocks
(
NULL
,
pRes
);
void
*
buf
=
rpcMallocCont
(
tlen
);
if
(
buf
==
NULL
)
{
return
-
1
;
}
void
*
abuf
=
POINTER_SHIFT
(
buf
,
sizeof
(
SStreamExecMsgHead
));
tEncodeDataBlocks
(
abuf
,
pRes
);
tmsg_t
type
;
if
(
pTask
->
nextOpDst
==
STREAM_NEXT_OP_DST__VND
)
{
type
=
TDMT_VND_TASK_EXEC
;
}
else
{
type
=
TDMT_SND_TASK_EXEC
;
}
SRpcMsg
reqMsg
=
{
.
pCont
=
buf
,
.
contLen
=
tlen
,
.
code
=
0
,
.
msgType
=
type
,
};
tmsgSendReq
(
&
pTq
->
pVnode
->
msgCb
,
&
pTask
->
NextOpEp
,
&
reqMsg
);
}
}
return
0
;
}
int32_t
tqProcessTaskExec
(
STQ
*
pTq
,
SRpcMsg
*
msg
)
{
int32_t
tqProcessTaskExec
(
STQ
*
pTq
,
SRpcMsg
*
msg
)
{
SStreamTaskExecReq
*
pReq
=
msg
->
pCont
;
SStreamTaskExecReq
*
pReq
=
msg
->
pCont
;
...
...
source/dnode/vnode/src/tq/tqRead.c
浏览文件 @
4e8ebdef
...
@@ -126,6 +126,36 @@ SArray* tqRetrieveDataBlock(STqReadHandle* pHandle) {
...
@@ -126,6 +126,36 @@ SArray* tqRetrieveDataBlock(STqReadHandle* pHandle) {
if
(
pArray
==
NULL
)
{
if
(
pArray
==
NULL
)
{
return
NULL
;
return
NULL
;
}
}
int32_t
colMeta
=
0
;
int32_t
colNeed
=
0
;
while
(
colMeta
<
pSchemaWrapper
->
nCols
&&
colNeed
<
colNumNeed
)
{
SSchema
*
pColSchema
=
&
pSchemaWrapper
->
pSchema
[
colMeta
];
int16_t
colIdSchema
=
pColSchema
->
colId
;
int16_t
colIdNeed
=
*
(
int16_t
*
)
taosArrayGet
(
pHandle
->
pColIdList
,
colNeed
);
if
(
colIdSchema
<
colIdNeed
)
{
colMeta
++
;
}
else
if
(
colIdSchema
>
colIdNeed
)
{
colNeed
++
;
}
else
{
SColumnInfoData
colInfo
=
{
0
};
int
sz
=
numOfRows
*
pColSchema
->
bytes
;
colInfo
.
info
.
bytes
=
pColSchema
->
bytes
;
colInfo
.
info
.
colId
=
pColSchema
->
colId
;
colInfo
.
info
.
type
=
pColSchema
->
type
;
colInfo
.
pData
=
calloc
(
1
,
sz
);
if
(
colInfo
.
pData
==
NULL
)
{
// TODO free
taosArrayDestroy
(
pArray
);
return
NULL
;
}
blockDataEnsureColumnCapacity
(
&
colInfo
,
numOfRows
);
taosArrayPush
(
pArray
,
&
colInfo
);
colMeta
++
;
colNeed
++
;
}
}
int
j
=
0
;
int
j
=
0
;
for
(
int32_t
i
=
0
;
i
<
colNumNeed
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
colNumNeed
;
i
++
)
{
...
@@ -163,11 +193,23 @@ SArray* tqRetrieveDataBlock(STqReadHandle* pHandle) {
...
@@ -163,11 +193,23 @@ SArray* tqRetrieveDataBlock(STqReadHandle* pHandle) {
while
((
row
=
tGetSubmitBlkNext
(
&
pHandle
->
blkIter
))
!=
NULL
)
{
while
((
row
=
tGetSubmitBlkNext
(
&
pHandle
->
blkIter
))
!=
NULL
)
{
tdSTSRowIterReset
(
&
iter
,
row
);
tdSTSRowIterReset
(
&
iter
,
row
);
// get all wanted col of that block
// get all wanted col of that block
int32_t
colTot
=
taosArrayGetSize
(
pArray
);
for
(
int32_t
i
=
0
;
i
<
colTot
;
i
++
)
{
SColumnInfoData
*
pColData
=
taosArrayGet
(
pArray
,
i
);
SCellVal
sVal
=
{
0
};
if
(
!
tdSTSRowIterNext
(
&
iter
,
pColData
->
info
.
colId
,
pColData
->
info
.
type
,
&
sVal
))
{
break
;
}
memcpy
(
POINTER_SHIFT
(
pColData
->
pData
,
curRow
*
pColData
->
info
.
bytes
),
sVal
.
val
,
pColData
->
info
.
bytes
);
}
#if 0
for (int32_t i = 0; i < colNumNeed; i++) {
for (int32_t i = 0; i < colNumNeed; i++) {
SColumnInfoData* pColData = taosArrayGet(pArray, i);
SColumnInfoData* pColData = taosArrayGet(pArray, i);
STColumn* pCol = schemaColAt(pTschema, i);
STColumn* pCol = schemaColAt(pTschema, i);
// TODO
// TODO
ASSERT
(
pCol
->
colId
==
pColData
->
info
.
colId
);
if(pCol->colId != pColData->info.colId) {
continue;
}
// void* val = tdGetMemRowDataOfColEx(row, pCol->colId, pCol->type, TD_DATA_ROW_HEAD_SIZE + pCol->offset, &kvIdx);
// void* val = tdGetMemRowDataOfColEx(row, pCol->colId, pCol->type, TD_DATA_ROW_HEAD_SIZE + pCol->offset, &kvIdx);
SCellVal sVal = {0};
SCellVal sVal = {0};
if (!tdSTSRowIterNext(&iter, pCol->colId, pCol->type, &sVal)) {
if (!tdSTSRowIterNext(&iter, pCol->colId, pCol->type, &sVal)) {
...
@@ -176,6 +218,7 @@ SArray* tqRetrieveDataBlock(STqReadHandle* pHandle) {
...
@@ -176,6 +218,7 @@ SArray* tqRetrieveDataBlock(STqReadHandle* pHandle) {
}
}
memcpy(POINTER_SHIFT(pColData->pData, curRow * pCol->bytes), sVal.val, pCol->bytes);
memcpy(POINTER_SHIFT(pColData->pData, curRow * pCol->bytes), sVal.val, pCol->bytes);
}
}
#endif
curRow
++
;
curRow
++
;
}
}
return
pArray
;
return
pArray
;
...
...
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
4e8ebdef
...
@@ -403,18 +403,12 @@ static STsdbReadHandle* tsdbQueryTablesImpl(STsdb* tsdb, STsdbQueryCond* pCond,
...
@@ -403,18 +403,12 @@ static STsdbReadHandle* tsdbQueryTablesImpl(STsdb* tsdb, STsdbQueryCond* pCond,
SColumnInfoData
colInfo
=
{{
0
},
0
};
SColumnInfoData
colInfo
=
{{
0
},
0
};
colInfo
.
info
=
pCond
->
colList
[
i
];
colInfo
.
info
=
pCond
->
colList
[
i
];
colInfo
.
pData
=
calloc
(
1
,
EXTRA_BYTES
+
pReadHandle
->
outputCapacity
*
pCond
->
colList
[
i
].
bytes
);
int32_t
code
=
blockDataEnsureColumnCapacity
(
&
colInfo
,
pReadHandle
->
outputCapacity
);
if
(
!
IS_VAR_DATA_TYPE
(
colInfo
.
info
.
type
))
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
colInfo
.
nullbitmap
=
calloc
(
1
,
BitmapLen
(
pReadHandle
->
outputCapacity
));
}
if
(
colInfo
.
pData
==
NULL
||
(
colInfo
.
nullbitmap
==
NULL
&&
(
!
IS_VAR_DATA_TYPE
(
colInfo
.
info
.
type
))))
{
goto
_end
;
goto
_end
;
}
}
taosArrayPush
(
pReadHandle
->
pColumns
,
&
colInfo
);
taosArrayPush
(
pReadHandle
->
pColumns
,
&
colInfo
);
pReadHandle
->
statis
[
i
].
colId
=
colInfo
.
info
.
colId
;
pReadHandle
->
statis
[
i
].
colId
=
colInfo
.
info
.
colId
;
}
}
...
@@ -1418,34 +1412,37 @@ static int32_t doCopyRowsFromFileBlock(STsdbReadHandle* pTsdbReadHandle, int32_t
...
@@ -1418,34 +1412,37 @@ static int32_t doCopyRowsFromFileBlock(STsdbReadHandle* pTsdbReadHandle, int32_t
}
}
if
(
!
isAllRowsNull
(
src
)
&&
pColInfo
->
info
.
colId
==
src
->
colId
)
{
if
(
!
isAllRowsNull
(
src
)
&&
pColInfo
->
info
.
colId
==
src
->
colId
)
{
if
(
pColInfo
->
info
.
type
!=
TSDB_DATA_TYPE_BINARY
&&
pColInfo
->
info
.
type
!=
TSDB_DATA_TYPE_NCHAR
)
{
if
(
!
IS_VAR_DATA_TYPE
(
pColInfo
->
info
.
type
))
{
// todo opt performance
memmove
(
pData
,
(
char
*
)
src
->
pData
+
bytes
*
start
,
bytes
*
num
);
// memmove(pData, (char*)src->pData + bytes * start, bytes * num);
}
else
{
// handle the var-string
for
(
int32_t
k
=
start
;
k
<
num
+
start
;
++
k
)
{
char
*
dst
=
pData
;
SCellVal
sVal
=
{
0
};
if
(
tdGetColDataOfRow
(
&
sVal
,
src
,
k
)
<
0
)
{
TASSERT
(
0
);
}
if
(
sVal
.
valType
==
TD_VTYPE_NULL
)
{
colDataAppend
(
pColInfo
,
k
,
NULL
,
true
);
}
else
{
colDataAppend
(
pColInfo
,
k
,
sVal
.
val
,
false
);
}
}
}
else
{
// handle the var-string
// todo refactor, only copy one-by-one
// todo refactor, only copy one-by-one
for
(
int32_t
k
=
start
;
k
<
num
+
start
;
++
k
)
{
for
(
int32_t
k
=
start
;
k
<
num
+
start
;
++
k
)
{
SCellVal
sVal
=
{
0
};
SCellVal
sVal
=
{
0
};
if
(
tdGetColDataOfRow
(
&
sVal
,
src
,
k
)
<
0
){
if
(
tdGetColDataOfRow
(
&
sVal
,
src
,
k
)
<
0
){
TASSERT
(
0
);
TASSERT
(
0
);
}
}
memcpy
(
dst
,
sVal
.
val
,
varDataTLen
(
sVal
.
val
));
dst
+=
bytes
;
colDataAppend
(
pColInfo
,
k
,
sVal
.
val
,
false
)
;
}
}
}
}
j
++
;
j
++
;
i
++
;
i
++
;
}
else
{
// pColInfo->info.colId < src->colId, it is a NULL data
}
else
{
// pColInfo->info.colId < src->colId, it is a NULL data
if
(
pColInfo
->
info
.
type
==
TSDB_DATA_TYPE_BINARY
||
pColInfo
->
info
.
type
==
TSDB_DATA_TYPE_NCHAR
)
{
for
(
int32_t
k
=
start
;
k
<
num
+
start
;
++
k
)
{
// TODO opt performance
char
*
dst
=
pData
;
colDataAppend
(
pColInfo
,
k
,
NULL
,
true
);
for
(
int32_t
k
=
start
;
k
<
num
+
start
;
++
k
)
{
setVardataNull
(
dst
,
pColInfo
->
info
.
type
);
dst
+=
bytes
;
}
}
else
{
setNullN
(
pData
,
pColInfo
->
info
.
type
,
pColInfo
->
info
.
bytes
,
num
);
}
}
i
++
;
i
++
;
}
}
...
@@ -1453,23 +1450,9 @@ static int32_t doCopyRowsFromFileBlock(STsdbReadHandle* pTsdbReadHandle, int32_t
...
@@ -1453,23 +1450,9 @@ static int32_t doCopyRowsFromFileBlock(STsdbReadHandle* pTsdbReadHandle, int32_t
while
(
i
<
requiredNumOfCols
)
{
// the remain columns are all null data
while
(
i
<
requiredNumOfCols
)
{
// the remain columns are all null data
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pTsdbReadHandle
->
pColumns
,
i
);
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pTsdbReadHandle
->
pColumns
,
i
);
if
(
ASCENDING_TRAVERSE
(
pTsdbReadHandle
->
order
))
{
pData
=
(
char
*
)
pColInfo
->
pData
+
numOfRows
*
pColInfo
->
info
.
bytes
;
}
else
{
pData
=
(
char
*
)
pColInfo
->
pData
+
(
capacity
-
numOfRows
-
num
)
*
pColInfo
->
info
.
bytes
;
}
if
(
pColInfo
->
info
.
type
==
TSDB_DATA_TYPE_BINARY
||
pColInfo
->
info
.
type
==
TSDB_DATA_TYPE_NCHAR
)
{
char
*
dst
=
pData
;
for
(
int32_t
k
=
start
;
k
<
num
+
start
;
++
k
)
{
for
(
int32_t
k
=
start
;
k
<
num
+
start
;
++
k
)
{
setVardataNull
(
dst
,
pColInfo
->
info
.
type
);
colDataAppend
(
pColInfo
,
k
,
NULL
,
true
);
// TODO add a fast version to set a number of consecutive NULL value.
dst
+=
pColInfo
->
info
.
bytes
;
}
}
}
else
{
setNullN
(
pData
,
pColInfo
->
info
.
type
,
pColInfo
->
info
.
bytes
,
num
);
}
i
++
;
i
++
;
}
}
...
...
source/dnode/vnode/src/tsdb/tsdbSma.c
浏览文件 @
4e8ebdef
...
@@ -493,6 +493,15 @@ static int32_t tsdbResetExpiredWindow(STsdb *pTsdb, SSmaStat *pStat, int64_t ind
...
@@ -493,6 +493,15 @@ static int32_t tsdbResetExpiredWindow(STsdb *pTsdb, SSmaStat *pStat, int64_t ind
skey
,
indexUid
);
skey
,
indexUid
);
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
// TODO: use a standalone interface to received state upate notification from stream computing module.
/**
* @brief state
* - When SMA env init in TSDB, its status is TSDB_SMA_STAT_OK.
* - In startup phase of stream computing module, it should notify the SMA env in TSDB to expired if needed(e.g.
* when batch data caculation not finised)
* - When TSDB_SMA_STAT_OK, the stream computing module should also notify that to the SMA env in TSDB.
*/
pItem
->
state
=
TSDB_SMA_STAT_OK
;
}
else
{
}
else
{
// error handling
// error handling
tsdbUnRefSmaStat
(
pTsdb
,
pStat
);
tsdbUnRefSmaStat
(
pTsdb
,
pStat
);
...
@@ -796,6 +805,7 @@ static int32_t tsdbInsertTSmaDataImpl(STsdb *pTsdb, char *msg) {
...
@@ -796,6 +805,7 @@ static int32_t tsdbInsertTSmaDataImpl(STsdb *pTsdb, char *msg) {
if
(
pStat
&&
pStat
->
smaStatItems
)
{
if
(
pStat
&&
pStat
->
smaStatItems
)
{
pItem
=
taosHashGet
(
pStat
->
smaStatItems
,
&
indexUid
,
sizeof
(
indexUid
));
pItem
=
taosHashGet
(
pStat
->
smaStatItems
,
&
indexUid
,
sizeof
(
indexUid
));
}
}
if
((
pItem
==
NULL
)
||
((
pItem
=
*
(
SSmaStatItem
**
)
pItem
)
==
NULL
)
||
tsdbSmaStatIsDropped
(
pItem
))
{
if
((
pItem
==
NULL
)
||
((
pItem
=
*
(
SSmaStatItem
**
)
pItem
)
==
NULL
)
||
tsdbSmaStatIsDropped
(
pItem
))
{
terrno
=
TSDB_CODE_TDB_INVALID_SMA_STAT
;
terrno
=
TSDB_CODE_TDB_INVALID_SMA_STAT
;
tsdbUnRefSmaStat
(
pTsdb
,
pStat
);
tsdbUnRefSmaStat
(
pTsdb
,
pStat
);
...
@@ -864,14 +874,14 @@ static int32_t tsdbDropTSmaDataImpl(STsdb *pTsdb, int64_t indexUid) {
...
@@ -864,14 +874,14 @@ static int32_t tsdbDropTSmaDataImpl(STsdb *pTsdb, int64_t indexUid) {
if
((
pItem
!=
NULL
)
||
((
pItem
=
*
(
SSmaStatItem
**
)
pItem
)
!=
NULL
))
{
if
((
pItem
!=
NULL
)
||
((
pItem
=
*
(
SSmaStatItem
**
)
pItem
)
!=
NULL
))
{
if
(
tsdbSmaStatIsDropped
(
pItem
))
{
if
(
tsdbSmaStatIsDropped
(
pItem
))
{
tsdbDebug
(
"vgId:%d tSma stat is already dropped for %"
PRIi64
,
REPO_ID
(
pTsdb
),
indexUid
);
tsdbDebug
(
"vgId:%d tSma stat is already dropped for %"
PRIi64
,
REPO_ID
(
pTsdb
),
indexUid
);
return
TSDB_CODE_TDB_INVALID_ACTION
;
// TODO: duplicate drop msg
should be intercept
by mnode
return
TSDB_CODE_TDB_INVALID_ACTION
;
// TODO: duplicate drop msg
would be intercepted
by mnode
}
}
tsdbWLockSma
(
pEnv
);
tsdbWLockSma
(
pEnv
);
if
(
tsdbSmaStatIsDropped
(
pItem
))
{
if
(
tsdbSmaStatIsDropped
(
pItem
))
{
tsdbUnLockSma
(
pEnv
);
tsdbUnLockSma
(
pEnv
);
tsdbDebug
(
"vgId:%d tSma stat is already dropped for %"
PRIi64
,
REPO_ID
(
pTsdb
),
indexUid
);
tsdbDebug
(
"vgId:%d tSma stat is already dropped for %"
PRIi64
,
REPO_ID
(
pTsdb
),
indexUid
);
return
TSDB_CODE_TDB_INVALID_ACTION
;
// TODO: duplicate drop msg
should be intercept
by mnode
return
TSDB_CODE_TDB_INVALID_ACTION
;
// TODO: duplicate drop msg
would be intercepted
by mnode
}
}
tsdbSmaStatSetDropped
(
pItem
);
tsdbSmaStatSetDropped
(
pItem
);
tsdbUnLockSma
(
pEnv
);
tsdbUnLockSma
(
pEnv
);
...
@@ -893,6 +903,7 @@ static int32_t tsdbDropTSmaDataImpl(STsdb *pTsdb, int64_t indexUid) {
...
@@ -893,6 +903,7 @@ static int32_t tsdbDropTSmaDataImpl(STsdb *pTsdb, int64_t indexUid) {
}
}
// clear sma data files
// clear sma data files
// TODO:
// TODO:
}
}
static
int32_t
tsdbSetRSmaDataFile
(
STSmaWriteH
*
pSmaH
,
STSmaDataWrapper
*
pData
,
int32_t
fid
)
{
static
int32_t
tsdbSetRSmaDataFile
(
STSmaWriteH
*
pSmaH
,
STSmaDataWrapper
*
pData
,
int32_t
fid
)
{
...
@@ -1091,7 +1102,7 @@ static int32_t tsdbGetTSmaDataImpl(STsdb *pTsdb, STSmaDataWrapper *pData, int64_
...
@@ -1091,7 +1102,7 @@ static int32_t tsdbGetTSmaDataImpl(STsdb *pTsdb, STSmaDataWrapper *pData, int64_
if
(
!
tsdbSmaStatIsOK
(
pItem
,
&
smaStat
))
{
// TODO: multiple check for large scale sma query
if
(
!
tsdbSmaStatIsOK
(
pItem
,
&
smaStat
))
{
// TODO: multiple check for large scale sma query
tsdbUnRefSmaStat
(
pTsdb
,
SMA_ENV_STAT
(
pTsdb
->
pTSmaEnv
));
tsdbUnRefSmaStat
(
pTsdb
,
SMA_ENV_STAT
(
pTsdb
->
pTSmaEnv
));
terrno
=
TSDB_CODE_TDB_INVALID_SMA_STAT
;
terrno
=
TSDB_CODE_TDB_INVALID_SMA_STAT
;
tsdb
Debug
(
"vgId:%d getTSmaDataImpl failed from index %"
PRIi64
" since %s %"
PRIi8
,
REPO_ID
(
pTsdb
),
indexUid
,
tsdb
Warn
(
"vgId:%d getTSmaDataImpl failed from index %"
PRIi64
" since %s %"
PRIi8
,
REPO_ID
(
pTsdb
),
indexUid
,
tstrerror
(
terrno
),
smaStat
);
tstrerror
(
terrno
),
smaStat
);
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
...
...
source/dnode/vnode/src/vnd/vnodeMain.c
浏览文件 @
4e8ebdef
...
@@ -115,7 +115,8 @@ static int vnodeOpenImpl(SVnode *pVnode) {
...
@@ -115,7 +115,8 @@ static int vnodeOpenImpl(SVnode *pVnode) {
// Open tsdb
// Open tsdb
sprintf
(
dir
,
"%s/tsdb"
,
pVnode
->
path
);
sprintf
(
dir
,
"%s/tsdb"
,
pVnode
->
path
);
pVnode
->
pTsdb
=
tsdbOpen
(
dir
,
pVnode
->
vgId
,
&
(
pVnode
->
config
.
tsdbCfg
),
vBufPoolGetMAF
(
pVnode
),
pVnode
->
pMeta
,
pVnode
->
pTfs
);
pVnode
->
pTsdb
=
tsdbOpen
(
dir
,
pVnode
->
vgId
,
&
(
pVnode
->
config
.
tsdbCfg
),
vBufPoolGetMAF
(
pVnode
),
pVnode
->
pMeta
,
pVnode
->
pTfs
);
if
(
pVnode
->
pTsdb
==
NULL
)
{
if
(
pVnode
->
pTsdb
==
NULL
)
{
// TODO: handle error
// TODO: handle error
return
-
1
;
return
-
1
;
...
@@ -131,7 +132,7 @@ static int vnodeOpenImpl(SVnode *pVnode) {
...
@@ -131,7 +132,7 @@ static int vnodeOpenImpl(SVnode *pVnode) {
// Open TQ
// Open TQ
sprintf
(
dir
,
"%s/tq"
,
pVnode
->
path
);
sprintf
(
dir
,
"%s/tq"
,
pVnode
->
path
);
pVnode
->
pTq
=
tqOpen
(
dir
,
pVnode
->
pWal
,
pVnode
->
pMeta
,
&
(
pVnode
->
config
.
tqCfg
),
vBufPoolGetMAF
(
pVnode
));
pVnode
->
pTq
=
tqOpen
(
dir
,
pVnode
,
pVnode
->
pWal
,
pVnode
->
pMeta
,
&
(
pVnode
->
config
.
tqCfg
),
vBufPoolGetMAF
(
pVnode
));
if
(
pVnode
->
pTq
==
NULL
)
{
if
(
pVnode
->
pTq
==
NULL
)
{
// TODO: handle error
// TODO: handle error
return
-
1
;
return
-
1
;
...
...
source/dnode/vnode/src/vnd/vnodeQuery.c
浏览文件 @
4e8ebdef
...
@@ -68,6 +68,8 @@ int vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg) {
...
@@ -68,6 +68,8 @@ int vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg) {
return
tqProcessPollReq
(
pVnode
->
pTq
,
pMsg
);
return
tqProcessPollReq
(
pVnode
->
pTq
,
pMsg
);
case
TDMT_VND_TASK_EXEC
:
case
TDMT_VND_TASK_EXEC
:
return
tqProcessTaskExec
(
pVnode
->
pTq
,
pMsg
);
return
tqProcessTaskExec
(
pVnode
->
pTq
,
pMsg
);
case
TDMT_VND_STREAM_TRIGGER
:
return
tqProcessStreamTrigger
(
pVnode
->
pTq
,
pMsg
->
pCont
,
pMsg
->
contLen
);
case
TDMT_VND_QUERY_HEARTBEAT
:
case
TDMT_VND_QUERY_HEARTBEAT
:
return
qWorkerProcessHbMsg
(
pVnode
,
pVnode
->
pQuery
,
pMsg
);
return
qWorkerProcessHbMsg
(
pVnode
,
pVnode
->
pQuery
,
pMsg
);
default:
default:
...
@@ -163,7 +165,6 @@ static int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg) {
...
@@ -163,7 +165,6 @@ static int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg) {
memcpy
(
POINTER_SHIFT
(
metaRsp
.
pSchemas
,
sizeof
(
SSchema
)
*
pSW
->
nCols
),
pTagSchema
,
sizeof
(
SSchema
)
*
nTagCols
);
memcpy
(
POINTER_SHIFT
(
metaRsp
.
pSchemas
,
sizeof
(
SSchema
)
*
pSW
->
nCols
),
pTagSchema
,
sizeof
(
SSchema
)
*
nTagCols
);
}
}
_exit:
_exit:
rspLen
=
tSerializeSTableMetaRsp
(
NULL
,
0
,
&
metaRsp
);
rspLen
=
tSerializeSTableMetaRsp
(
NULL
,
0
,
&
metaRsp
);
...
@@ -179,7 +180,6 @@ _exit:
...
@@ -179,7 +180,6 @@ _exit:
}
}
tSerializeSTableMetaRsp
(
pRsp
,
rspLen
,
&
metaRsp
);
tSerializeSTableMetaRsp
(
pRsp
,
rspLen
,
&
metaRsp
);
tFreeSTableMetaRsp
(
&
metaRsp
);
tFreeSTableMetaRsp
(
&
metaRsp
);
if
(
pSW
!=
NULL
)
{
if
(
pSW
!=
NULL
)
{
tfree
(
pSW
->
pSchema
);
tfree
(
pSW
->
pSchema
);
...
...
source/dnode/vnode/src/vnd/vnodeWrite.c
浏览文件 @
4e8ebdef
...
@@ -59,7 +59,7 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
...
@@ -59,7 +59,7 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
// todo: change the interface here
// todo: change the interface here
int64_t
ver
;
int64_t
ver
;
taosDecodeFixedI64
(
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
)),
&
ver
);
taosDecodeFixedI64
(
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
)),
&
ver
);
if
(
tqPushMsg
(
pVnode
->
pTq
,
p
tr
,
pMsg
->
msgType
,
ver
)
<
0
)
{
if
(
tqPushMsg
(
pVnode
->
pTq
,
p
Msg
->
pCont
,
pMsg
->
contLen
,
pMsg
->
msgType
,
ver
)
<
0
)
{
// TODO: handle error
// TODO: handle error
}
}
...
...
source/libs/executor/inc/executorimpl.h
浏览文件 @
4e8ebdef
...
@@ -541,10 +541,20 @@ typedef struct SFillOperatorInfo {
...
@@ -541,10 +541,20 @@ typedef struct SFillOperatorInfo {
bool
multigroupResult
;
bool
multigroupResult
;
}
SFillOperatorInfo
;
}
SFillOperatorInfo
;
typedef
struct
SGroupKeys
{
char
*
pData
;
bool
isNull
;
int16_t
type
;
int32_t
bytes
;
}
SGroupKeys
;
typedef
struct
SGroupbyOperatorInfo
{
typedef
struct
SGroupbyOperatorInfo
{
SOptrBasicInfo
binfo
;
SOptrBasicInfo
binfo
;
SArray
*
pGroupCols
;
SArray
*
pGroupCols
;
char
*
prevData
;
// previous group by value
SArray
*
pGroupColVals
;
// current group column values, SArray<SGroupKeys>
bool
isInit
;
// denote if current val is initialized or not
char
*
keyBuf
;
// group by keys for hash
int32_t
groupKeyLen
;
// total group by column width
SGroupResInfo
groupResInfo
;
SGroupResInfo
groupResInfo
;
SAggSupporter
aggSup
;
SAggSupporter
aggSup
;
}
SGroupbyOperatorInfo
;
}
SGroupbyOperatorInfo
;
...
...
source/libs/executor/src/executor.c
浏览文件 @
4e8ebdef
...
@@ -30,7 +30,7 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, int32_t t
...
@@ -30,7 +30,7 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, int32_t t
qError
(
"join not supported for stream block scan, %s"
PRIx64
,
id
);
qError
(
"join not supported for stream block scan, %s"
PRIx64
,
id
);
return
TSDB_CODE_QRY_APP_ERROR
;
return
TSDB_CODE_QRY_APP_ERROR
;
}
}
pOperator
->
status
=
OP_NOT_OPENED
;
return
doSetStreamBlock
(
pOperator
->
pDownstream
[
0
],
input
,
type
,
id
);
return
doSetStreamBlock
(
pOperator
->
pDownstream
[
0
],
input
,
type
,
id
);
}
else
{
}
else
{
SStreamBlockScanInfo
*
pInfo
=
pOperator
->
info
;
SStreamBlockScanInfo
*
pInfo
=
pOperator
->
info
;
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
4e8ebdef
...
@@ -1623,67 +1623,142 @@ static void hashAllIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pRe
...
@@ -1623,67 +1623,142 @@ static void hashAllIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pRe
// updateResultRowInfoActiveIndex(pResultRowInfo, pQueryAttr, pRuntimeEnv->current->lastKey);
// updateResultRowInfoActiveIndex(pResultRowInfo, pQueryAttr, pRuntimeEnv->current->lastKey);
}
}
static
void
doHashGroupbyAgg
(
SOperatorInfo
*
pOperator
,
SGroupbyOperatorInfo
*
pInfo
,
SSDataBlock
*
pBlock
)
{
static
bool
groupKeyCompare
(
SGroupbyOperatorInfo
*
pInfo
,
SSDataBlock
*
pBlock
,
int32_t
rowIndex
,
int32_t
numOfGroupCols
)
{
SExecTaskInfo
*
pTaskInfo
=
pOperator
->
pTaskInfo
;
SColumnDataAgg
*
pColAgg
=
NULL
;
for
(
int32_t
i
=
0
;
i
<
numOfGroupCols
;
++
i
)
{
// TODO multiple group by columns
SColumn
*
pCol
=
taosArrayGet
(
pInfo
->
pGroupCols
,
i
);
SColumn
*
pCol
=
taosArrayGet
(
pInfo
->
pGroupCols
,
0
);
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
pBlock
->
pDataBlock
,
pCol
->
slotId
);
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
pBlock
->
pDataBlock
,
pCol
->
slotId
);
if
(
pBlock
->
pBlockAgg
!=
NULL
)
{
int16_t
bytes
=
pColInfoData
->
info
.
bytes
;
pColAgg
=
&
pBlock
->
pBlockAgg
[
pCol
->
slotId
];
// TODO is agg data matched?
int16_t
type
=
pColInfoData
->
info
.
type
;
if
(
type
==
TSDB_DATA_TYPE_FLOAT
||
type
==
TSDB_DATA_TYPE_DOUBLE
)
{
//qError("QInfo:0x%"PRIx64" group by not supported on double/float columns, abort", GET_TASKID(pRuntimeEnv));
return
;
}
}
STimeWindow
w
=
TSWINDOW_INITIALIZER
;
bool
isNull
=
colDataIsNull
(
pColInfoData
,
pBlock
->
info
.
rows
,
rowIndex
,
pColAgg
)
;
int32_t
num
=
0
;
SGroupKeys
*
pkey
=
taosArrayGet
(
pInfo
->
pGroupColVals
,
i
);
for
(
int32_t
j
=
0
;
j
<
pBlock
->
info
.
rows
;
++
j
)
{
if
(
pkey
->
isNull
&&
isNull
)
{
if
(
colDataIsNull
(
pColInfoData
,
pBlock
->
info
.
rows
,
j
,
NULL
))
{
// TODO
continue
;
continue
;
}
}
char
*
val
=
colDataGetData
(
pColInfoData
,
j
);
if
(
isNull
||
pkey
->
isNull
)
{
return
false
;
}
// Compare with the previous row of this column, and do not set the output buffer again if they are identical.
char
*
val
=
colDataGetData
(
pColInfoData
,
rowIndex
);
if
(
pInfo
->
prevData
==
NULL
)
{
pInfo
->
prevData
=
malloc
(
bytes
);
if
(
IS_VAR_DATA_TYPE
(
pkey
->
type
))
{
memcpy
(
pInfo
->
prevData
,
val
,
bytes
);
int32_t
len
=
varDataLen
(
val
);
num
++
;
if
(
len
==
varDataLen
(
pkey
->
pData
)
&&
memcmp
(
varDataVal
(
pkey
->
pData
),
varDataVal
(
val
),
len
)
==
0
)
{
continue
;
continue
;
}
else
{
return
false
;
}
}
else
{
if
(
memcmp
(
pkey
->
pData
,
val
,
pkey
->
bytes
)
!=
0
)
{
return
false
;
}
}
}
}
if
(
IS_VAR_DATA_TYPE
(
type
))
{
return
true
;
int32_t
len
=
varDataLen
(
val
);
}
if
(
len
==
varDataLen
(
pInfo
->
prevData
)
&&
memcmp
(
varDataVal
(
pInfo
->
prevData
),
varDataVal
(
val
),
len
)
==
0
)
{
num
++
;
static
void
keepGroupKeys
(
SGroupbyOperatorInfo
*
pInfo
,
SSDataBlock
*
pBlock
,
int32_t
rowIndex
,
int32_t
numOfGroupCols
)
{
SColumnDataAgg
*
pColAgg
=
NULL
;
for
(
int32_t
i
=
0
;
i
<
numOfGroupCols
;
++
i
)
{
SColumn
*
pCol
=
taosArrayGet
(
pInfo
->
pGroupCols
,
i
);
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
pBlock
->
pDataBlock
,
pCol
->
slotId
);
if
(
pBlock
->
pBlockAgg
!=
NULL
)
{
pColAgg
=
&
pBlock
->
pBlockAgg
[
pCol
->
slotId
];
// TODO is agg data matched?
}
SGroupKeys
*
pkey
=
taosArrayGet
(
pInfo
->
pGroupColVals
,
i
);
if
(
colDataIsNull
(
pColInfoData
,
pBlock
->
info
.
rows
,
rowIndex
,
pColAgg
))
{
pkey
->
isNull
=
true
;
}
else
{
char
*
val
=
colDataGetData
(
pColInfoData
,
rowIndex
);
if
(
IS_VAR_DATA_TYPE
(
pkey
->
type
))
{
memcpy
(
pkey
->
pData
,
val
,
varDataTLen
(
val
));
}
else
{
memcpy
(
pkey
->
pData
,
val
,
pkey
->
bytes
);
}
}
}
}
static
int32_t
generatedHashKey
(
void
*
pKey
,
int32_t
*
length
,
SArray
*
pGroupColVals
)
{
ASSERT
(
pKey
!=
NULL
);
size_t
numOfGroupCols
=
taosArrayGetSize
(
pGroupColVals
);
char
*
isNull
=
(
char
*
)
pKey
;
char
*
pStart
=
(
char
*
)
pKey
+
sizeof
(
int8_t
)
*
numOfGroupCols
;
for
(
int32_t
i
=
0
;
i
<
numOfGroupCols
;
++
i
)
{
SGroupKeys
*
pkey
=
taosArrayGet
(
pGroupColVals
,
i
);
if
(
pkey
->
isNull
)
{
isNull
[
i
]
=
1
;
continue
;
continue
;
}
}
isNull
[
i
]
=
0
;
if
(
IS_VAR_DATA_TYPE
(
pkey
->
type
))
{
varDataCopy
(
pStart
,
pkey
->
pData
);
pStart
+=
varDataTLen
(
pkey
->
pData
);
ASSERT
(
varDataTLen
(
pkey
->
pData
)
<=
pkey
->
bytes
);
}
else
{
}
else
{
if
(
memcmp
(
pInfo
->
prevData
,
val
,
bytes
)
==
0
)
{
memcpy
(
pStart
,
pkey
->
pData
,
pkey
->
bytes
);
pStart
+=
pkey
->
bytes
;
}
}
*
length
=
(
pStart
-
(
char
*
)
pKey
);
return
0
;
}
static
void
doHashGroupbyAgg
(
SOperatorInfo
*
pOperator
,
SSDataBlock
*
pBlock
)
{
SExecTaskInfo
*
pTaskInfo
=
pOperator
->
pTaskInfo
;
SGroupbyOperatorInfo
*
pInfo
=
pOperator
->
info
;
int32_t
numOfGroupCols
=
taosArrayGetSize
(
pInfo
->
pGroupCols
);
// if (type == TSDB_DATA_TYPE_FLOAT || type == TSDB_DATA_TYPE_DOUBLE) {
//qError("QInfo:0x%"PRIx64" group by not supported on double/float columns, abort", GET_TASKID(pRuntimeEnv));
// return;
// }
int32_t
len
=
0
;
STimeWindow
w
=
TSWINDOW_INITIALIZER
;
int32_t
num
=
0
;
for
(
int32_t
j
=
0
;
j
<
pBlock
->
info
.
rows
;
++
j
)
{
// Compare with the previous row of this column, and do not set the output buffer again if they are identical.
if
(
!
pInfo
->
isInit
)
{
keepGroupKeys
(
pInfo
,
pBlock
,
j
,
numOfGroupCols
);
pInfo
->
isInit
=
true
;
num
++
;
num
++
;
continue
;
continue
;
}
}
bool
equal
=
groupKeyCompare
(
pInfo
,
pBlock
,
j
,
numOfGroupCols
);
if
(
equal
)
{
num
++
;
continue
;
}
}
int32_t
ret
=
setGroupResultOutputBuf_rv
(
&
(
pInfo
->
binfo
),
pOperator
->
numOfOutput
,
pInfo
->
prevData
,
type
,
bytes
,
0
,
/*int32_t ret = */
generatedHashKey
(
pInfo
->
keyBuf
,
&
len
,
pInfo
->
pGroupColVals
);
int32_t
ret
=
setGroupResultOutputBuf_rv
(
&
(
pInfo
->
binfo
),
pOperator
->
numOfOutput
,
pInfo
->
keyBuf
,
TSDB_DATA_TYPE_VARCHAR
,
len
,
0
,
pInfo
->
aggSup
.
pResultBuf
,
pTaskInfo
,
&
pInfo
->
aggSup
);
pInfo
->
aggSup
.
pResultBuf
,
pTaskInfo
,
&
pInfo
->
aggSup
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
// null data, too many state code
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
// null data, too many state code
longjmp
(
pTaskInfo
->
env
,
TSDB_CODE_QRY_APP_ERROR
);
longjmp
(
pTaskInfo
->
env
,
TSDB_CODE_QRY_APP_ERROR
);
}
}
doApplyFunctions
(
pInfo
->
binfo
.
pCtx
,
&
w
,
j
-
num
,
num
,
NULL
,
pBlock
->
info
.
rows
,
pOperator
->
numOfOutput
,
TSDB_ORDER_ASC
);
doApplyFunctions
(
pInfo
->
binfo
.
pCtx
,
&
w
,
j
-
num
,
num
,
NULL
,
pBlock
->
info
.
rows
,
pOperator
->
numOfOutput
,
TSDB_ORDER_ASC
);
keepGroupKeys
(
pInfo
,
pBlock
,
j
,
numOfGroupCols
);
num
=
1
;
num
=
1
;
memcpy
(
pInfo
->
prevData
,
val
,
bytes
);
}
}
if
(
num
>
0
)
{
if
(
num
>
0
)
{
char
*
val
=
((
char
*
)
pColInfoData
->
pData
)
+
bytes
*
(
pBlock
->
info
.
rows
-
num
);
/*int32_t ret = */
generatedHashKey
(
pInfo
->
keyBuf
,
&
len
,
pInfo
->
pGroupColVals
);
memcpy
(
pInfo
->
prevData
,
val
,
bytes
);
int32_t
ret
=
setGroupResultOutputBuf_rv
(
&
(
pInfo
->
binfo
),
pOperator
->
numOfOutput
,
pInfo
->
keyBuf
,
TSDB_DATA_TYPE_VARCHAR
,
len
,
0
,
int32_t
ret
=
setGroupResultOutputBuf_rv
(
&
(
pInfo
->
binfo
),
pOperator
->
numOfOutput
,
pInfo
->
prevData
,
type
,
bytes
,
0
,
pInfo
->
aggSup
.
pResultBuf
,
pTaskInfo
,
&
pInfo
->
aggSup
);
pInfo
->
aggSup
.
pResultBuf
,
pTaskInfo
,
&
pInfo
->
aggSup
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
longjmp
(
pTaskInfo
->
env
,
TSDB_CODE_QRY_APP_ERROR
);
longjmp
(
pTaskInfo
->
env
,
TSDB_CODE_QRY_APP_ERROR
);
...
@@ -1691,8 +1766,6 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SGroupbyOperatorInfo *pIn
...
@@ -1691,8 +1766,6 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SGroupbyOperatorInfo *pIn
doApplyFunctions
(
pInfo
->
binfo
.
pCtx
,
&
w
,
pBlock
->
info
.
rows
-
num
,
num
,
NULL
,
pBlock
->
info
.
rows
,
pOperator
->
numOfOutput
,
TSDB_ORDER_ASC
);
doApplyFunctions
(
pInfo
->
binfo
.
pCtx
,
&
w
,
pBlock
->
info
.
rows
-
num
,
num
,
NULL
,
pBlock
->
info
.
rows
,
pOperator
->
numOfOutput
,
TSDB_ORDER_ASC
);
}
}
tfree
(
pInfo
->
prevData
);
}
}
static
void
doSessionWindowAggImpl
(
SOperatorInfo
*
pOperator
,
SSessionAggOperatorInfo
*
pInfo
,
SSDataBlock
*
pSDataBlock
)
{
static
void
doSessionWindowAggImpl
(
SOperatorInfo
*
pOperator
,
SSessionAggOperatorInfo
*
pInfo
,
SSDataBlock
*
pSDataBlock
)
{
...
@@ -1783,20 +1856,11 @@ static void setResultRowKey(SResultRow* pResultRow, char* pData, int16_t type) {
...
@@ -1783,20 +1856,11 @@ static void setResultRowKey(SResultRow* pResultRow, char* pData, int16_t type) {
static
int32_t
setGroupResultOutputBuf_rv
(
SOptrBasicInfo
*
binfo
,
int32_t
numOfCols
,
char
*
pData
,
int16_t
type
,
int16_t
bytes
,
int32_t
groupId
,
static
int32_t
setGroupResultOutputBuf_rv
(
SOptrBasicInfo
*
binfo
,
int32_t
numOfCols
,
char
*
pData
,
int16_t
type
,
int16_t
bytes
,
int32_t
groupId
,
SDiskbasedBuf
*
pBuf
,
SExecTaskInfo
*
pTaskInfo
,
SAggSupporter
*
pAggSup
)
{
SDiskbasedBuf
*
pBuf
,
SExecTaskInfo
*
pTaskInfo
,
SAggSupporter
*
pAggSup
)
{
int32_t
*
rowCellInfoOffset
=
binfo
->
rowCellInfoOffset
;
SResultRowInfo
*
pResultRowInfo
=
&
binfo
->
resultRowInfo
;
SResultRowInfo
*
pResultRowInfo
=
&
binfo
->
resultRowInfo
;
SqlFunctionCtx
*
pCtx
=
binfo
->
pCtx
;
SqlFunctionCtx
*
pCtx
=
binfo
->
pCtx
;
// not assign result buffer yet, add new result buffer, TODO remove it
SResultRow
*
pResultRow
=
doSetResultOutBufByKey_rv
(
pBuf
,
pResultRowInfo
,
groupId
,
(
char
*
)
pData
,
bytes
,
true
,
groupId
,
char
*
d
=
pData
;
pTaskInfo
,
true
,
pAggSup
);
int16_t
len
=
bytes
;
if
(
IS_VAR_DATA_TYPE
(
type
))
{
d
=
varDataVal
(
pData
);
len
=
varDataLen
(
pData
);
}
int64_t
tid
=
0
;
SResultRow
*
pResultRow
=
doSetResultOutBufByKey_rv
(
pBuf
,
pResultRowInfo
,
groupId
,
(
char
*
)
pData
,
TSDB_KEYSIZE
,
true
,
groupId
,
pTaskInfo
,
true
,
pAggSup
);
assert
(
pResultRow
!=
NULL
);
assert
(
pResultRow
!=
NULL
);
setResultRowKey
(
pResultRow
,
pData
,
type
);
setResultRowKey
(
pResultRow
,
pData
,
type
);
...
@@ -6969,7 +7033,7 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo *pOperator, bool* newgrou
...
@@ -6969,7 +7033,7 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo *pOperator, bool* newgrou
// the pDataBlock are always the same one, no need to call this again
// the pDataBlock are always the same one, no need to call this again
setInputDataBlock
(
pOperator
,
pInfo
->
binfo
.
pCtx
,
pBlock
,
order
);
setInputDataBlock
(
pOperator
,
pInfo
->
binfo
.
pCtx
,
pBlock
,
order
);
// setTagValue(pOperator, pRuntimeEnv->current->pTable, pInfo->binfo.pCtx, pOperator->numOfOutput);
// setTagValue(pOperator, pRuntimeEnv->current->pTable, pInfo->binfo.pCtx, pOperator->numOfOutput);
doHashGroupbyAgg
(
pOperator
,
p
Info
,
p
Block
);
doHashGroupbyAgg
(
pOperator
,
pBlock
);
}
}
pOperator
->
status
=
OP_RES_TO_RETURN
;
pOperator
->
status
=
OP_RES_TO_RETURN
;
...
@@ -7281,7 +7345,9 @@ void destroySFillOperatorInfo(void* param, int32_t numOfOutput) {
...
@@ -7281,7 +7345,9 @@ void destroySFillOperatorInfo(void* param, int32_t numOfOutput) {
void
destroyGroupbyOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
)
{
void
destroyGroupbyOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
)
{
SGroupbyOperatorInfo
*
pInfo
=
(
SGroupbyOperatorInfo
*
)
param
;
SGroupbyOperatorInfo
*
pInfo
=
(
SGroupbyOperatorInfo
*
)
param
;
doDestroyBasicInfo
(
&
pInfo
->
binfo
,
numOfOutput
);
doDestroyBasicInfo
(
&
pInfo
->
binfo
,
numOfOutput
);
tfree
(
pInfo
->
prevData
);
tfree
(
pInfo
->
keyBuf
);
taosArrayDestroy
(
pInfo
->
pGroupCols
);
taosArrayDestroy
(
pInfo
->
pGroupColVals
);
}
}
static
void
destroyProjectOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
)
{
static
void
destroyProjectOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
)
{
...
@@ -7664,6 +7730,39 @@ SOperatorInfo* createAllMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRun
...
@@ -7664,6 +7730,39 @@ SOperatorInfo* createAllMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRun
return
pOperator
;
return
pOperator
;
}
}
static
int32_t
initGroupOptrInfo
(
SGroupbyOperatorInfo
*
pInfo
,
SArray
*
pGroupColList
)
{
pInfo
->
pGroupColVals
=
taosArrayInit
(
4
,
sizeof
(
SGroupKeys
));
if
(
pInfo
->
pGroupColVals
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
int32_t
numOfGroupCols
=
taosArrayGetSize
(
pGroupColList
);
for
(
int32_t
i
=
0
;
i
<
numOfGroupCols
;
++
i
)
{
SColumn
*
pCol
=
taosArrayGet
(
pGroupColList
,
i
);
pInfo
->
groupKeyLen
+=
pCol
->
bytes
;
struct
SGroupKeys
key
=
{
0
};
key
.
bytes
=
pCol
->
bytes
;
key
.
type
=
pCol
->
type
;
key
.
isNull
=
false
;
key
.
pData
=
calloc
(
1
,
pCol
->
bytes
);
if
(
key
.
pData
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
taosArrayPush
(
pInfo
->
pGroupColVals
,
&
key
);
}
int32_t
nullFlagSize
=
sizeof
(
int8_t
)
*
numOfGroupCols
;
pInfo
->
keyBuf
=
calloc
(
1
,
pInfo
->
groupKeyLen
+
nullFlagSize
);
if
(
pInfo
->
keyBuf
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
return
TSDB_CODE_SUCCESS
;
}
SOperatorInfo
*
createGroupOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResultBlock
,
SOperatorInfo
*
createGroupOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResultBlock
,
SArray
*
pGroupColList
,
SExecTaskInfo
*
pTaskInfo
,
const
STableGroupInfo
*
pTableGroupInfo
)
{
SArray
*
pGroupColList
,
SExecTaskInfo
*
pTaskInfo
,
const
STableGroupInfo
*
pTableGroupInfo
)
{
SGroupbyOperatorInfo
*
pInfo
=
calloc
(
1
,
sizeof
(
SGroupbyOperatorInfo
));
SGroupbyOperatorInfo
*
pInfo
=
calloc
(
1
,
sizeof
(
SGroupbyOperatorInfo
));
...
@@ -7674,9 +7773,13 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx
...
@@ -7674,9 +7773,13 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx
pInfo
->
pGroupCols
=
pGroupColList
;
pInfo
->
pGroupCols
=
pGroupColList
;
initAggInfo
(
&
pInfo
->
binfo
,
&
pInfo
->
aggSup
,
pExprInfo
,
numOfCols
,
4096
,
pResultBlock
,
pTaskInfo
->
id
.
str
);
initAggInfo
(
&
pInfo
->
binfo
,
&
pInfo
->
aggSup
,
pExprInfo
,
numOfCols
,
4096
,
pResultBlock
,
pTaskInfo
->
id
.
str
);
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
,
8
);
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
,
8
);
int32_t
code
=
initGroupOptrInfo
(
pInfo
,
pGroupColList
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
pOperator
->
name
=
"GroupbyAggOperator"
;
pOperator
->
name
=
"GroupbyAggOperator"
;
pOperator
->
blockingOptr
=
true
;
pOperator
->
blockingOptr
=
true
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
status
=
OP_NOT_OPENED
;
...
@@ -7688,7 +7791,7 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx
...
@@ -7688,7 +7791,7 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx
pOperator
->
getNextFn
=
hashGroupbyAggregate
;
pOperator
->
getNextFn
=
hashGroupbyAggregate
;
pOperator
->
closeFn
=
destroyGroupbyOperatorInfo
;
pOperator
->
closeFn
=
destroyGroupbyOperatorInfo
;
int32_t
code
=
appendDownstream
(
pOperator
,
&
downstream
,
1
);
code
=
appendDownstream
(
pOperator
,
&
downstream
,
1
);
return
pOperator
;
return
pOperator
;
_error:
_error:
...
@@ -8345,7 +8448,9 @@ SOperatorInfo* doCreateOperatorTreeNode(SPhysiNode* pPhyNode, SExecTaskInfo* pTa
...
@@ -8345,7 +8448,9 @@ SOperatorInfo* doCreateOperatorTreeNode(SPhysiNode* pPhyNode, SExecTaskInfo* pTa
SExprInfo
*
pExprInfo
=
createExprInfo
(
pIntervalPhyNode
->
pFuncs
,
NULL
,
&
num
);
SExprInfo
*
pExprInfo
=
createExprInfo
(
pIntervalPhyNode
->
pFuncs
,
NULL
,
&
num
);
SSDataBlock
*
pResBlock
=
createOutputBuf_rv1
(
pPhyNode
->
pOutputDataBlockDesc
);
SSDataBlock
*
pResBlock
=
createOutputBuf_rv1
(
pPhyNode
->
pOutputDataBlockDesc
);
SInterval
interval
=
{.
interval
=
pIntervalPhyNode
->
interval
,
.
sliding
=
pIntervalPhyNode
->
sliding
,
.
intervalUnit
=
'a'
,
.
slidingUnit
=
'a'
};
SInterval
interval
=
{.
interval
=
pIntervalPhyNode
->
interval
,
.
sliding
=
pIntervalPhyNode
->
sliding
,
.
intervalUnit
=
pIntervalPhyNode
->
intervalUnit
,
.
slidingUnit
=
pIntervalPhyNode
->
slidingUnit
,
.
offset
=
pIntervalPhyNode
->
offset
};
return
createIntervalOperatorInfo
(
op
,
pExprInfo
,
num
,
pResBlock
,
&
interval
,
pTableGroupInfo
,
pTaskInfo
);
return
createIntervalOperatorInfo
(
op
,
pExprInfo
,
num
,
pResBlock
,
&
interval
,
pTableGroupInfo
,
pTaskInfo
);
}
}
}
/*else if (pPhyNode->info.type == OP_MultiTableAggregate) {
}
/*else if (pPhyNode->info.type == OP_MultiTableAggregate) {
...
...
source/libs/sync/inc/syncRaftLog.h
浏览文件 @
4e8ebdef
...
@@ -47,6 +47,8 @@ SyncIndex logStoreGetCommitIndex(SSyncLogStore* pLogStore);
...
@@ -47,6 +47,8 @@ SyncIndex logStoreGetCommitIndex(SSyncLogStore* pLogStore);
SSyncRaftEntry
*
logStoreGetLastEntry
(
SSyncLogStore
*
pLogStore
);
SSyncRaftEntry
*
logStoreGetLastEntry
(
SSyncLogStore
*
pLogStore
);
cJSON
*
logStore2Json
(
SSyncLogStore
*
pLogStore
);
cJSON
*
logStore2Json
(
SSyncLogStore
*
pLogStore
);
char
*
logStore2Str
(
SSyncLogStore
*
pLogStore
);
char
*
logStore2Str
(
SSyncLogStore
*
pLogStore
);
cJSON
*
logStoreSimple2Json
(
SSyncLogStore
*
pLogStore
);
char
*
logStoreSimple2Str
(
SSyncLogStore
*
pLogStore
);
// for debug
// for debug
void
logStorePrint
(
SSyncLogStore
*
pLogStore
);
void
logStorePrint
(
SSyncLogStore
*
pLogStore
);
...
@@ -54,6 +56,11 @@ void logStorePrint2(char* s, SSyncLogStore* pLogStore);
...
@@ -54,6 +56,11 @@ void logStorePrint2(char* s, SSyncLogStore* pLogStore);
void
logStoreLog
(
SSyncLogStore
*
pLogStore
);
void
logStoreLog
(
SSyncLogStore
*
pLogStore
);
void
logStoreLog2
(
char
*
s
,
SSyncLogStore
*
pLogStore
);
void
logStoreLog2
(
char
*
s
,
SSyncLogStore
*
pLogStore
);
void
logStoreSimplePrint
(
SSyncLogStore
*
pLogStore
);
void
logStoreSimplePrint2
(
char
*
s
,
SSyncLogStore
*
pLogStore
);
void
logStoreSimpleLog
(
SSyncLogStore
*
pLogStore
);
void
logStoreSimpleLog2
(
char
*
s
,
SSyncLogStore
*
pLogStore
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/libs/sync/src/syncAppendEntries.c
浏览文件 @
4e8ebdef
...
@@ -120,6 +120,11 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) {
...
@@ -120,6 +120,11 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) {
// reject request
// reject request
if
((
pMsg
->
term
<
ths
->
pRaftStore
->
currentTerm
)
||
if
((
pMsg
->
term
<
ths
->
pRaftStore
->
currentTerm
)
||
((
pMsg
->
term
==
ths
->
pRaftStore
->
currentTerm
)
&&
(
ths
->
state
==
TAOS_SYNC_STATE_FOLLOWER
)
&&
!
logOK
))
{
((
pMsg
->
term
==
ths
->
pRaftStore
->
currentTerm
)
&&
(
ths
->
state
==
TAOS_SYNC_STATE_FOLLOWER
)
&&
!
logOK
))
{
sTrace
(
"syncNodeOnAppendEntriesCb --> reject, pMsg->term:%lu, ths->pRaftStore->currentTerm:%lu, ths->state:%d, "
"logOK:%d"
,
pMsg
->
term
,
ths
->
pRaftStore
->
currentTerm
,
ths
->
state
,
logOK
);
SyncAppendEntriesReply
*
pReply
=
syncAppendEntriesReplyBuild
();
SyncAppendEntriesReply
*
pReply
=
syncAppendEntriesReplyBuild
();
pReply
->
srcId
=
ths
->
myRaftId
;
pReply
->
srcId
=
ths
->
myRaftId
;
pReply
->
destId
=
pMsg
->
srcId
;
pReply
->
destId
=
pMsg
->
srcId
;
...
@@ -137,6 +142,11 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) {
...
@@ -137,6 +142,11 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) {
// return to follower state
// return to follower state
if
(
pMsg
->
term
==
ths
->
pRaftStore
->
currentTerm
&&
ths
->
state
==
TAOS_SYNC_STATE_CANDIDATE
)
{
if
(
pMsg
->
term
==
ths
->
pRaftStore
->
currentTerm
&&
ths
->
state
==
TAOS_SYNC_STATE_CANDIDATE
)
{
sTrace
(
"syncNodeOnAppendEntriesCb --> return to follower, pMsg->term:%lu, ths->pRaftStore->currentTerm:%lu, "
"ths->state:%d, logOK:%d"
,
pMsg
->
term
,
ths
->
pRaftStore
->
currentTerm
,
ths
->
state
,
logOK
);
syncNodeBecomeFollower
(
ths
);
syncNodeBecomeFollower
(
ths
);
// ret or reply?
// ret or reply?
...
@@ -145,29 +155,22 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) {
...
@@ -145,29 +155,22 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) {
// accept request
// accept request
if
(
pMsg
->
term
==
ths
->
pRaftStore
->
currentTerm
&&
ths
->
state
==
TAOS_SYNC_STATE_FOLLOWER
&&
logOK
)
{
if
(
pMsg
->
term
==
ths
->
pRaftStore
->
currentTerm
&&
ths
->
state
==
TAOS_SYNC_STATE_FOLLOWER
&&
logOK
)
{
bool
preMatch
=
false
;
// preIndex = -1, or has preIndex entry in local log
if
(
pMsg
->
prevLogIndex
==
SYNC_INDEX_INVALID
&&
ths
->
pLogStore
->
getLastIndex
(
ths
->
pLogStore
)
==
SYNC_INDEX_INVALID
)
{
preMatch
=
true
;
}
if
(
pMsg
->
prevLogIndex
>=
SYNC_INDEX_BEGIN
&&
pMsg
->
prevLogIndex
<=
ths
->
pLogStore
->
getLastIndex
(
ths
->
pLogStore
))
{
SSyncRaftEntry
*
pPreEntry
=
logStoreGetEntry
(
ths
->
pLogStore
,
pMsg
->
prevLogIndex
);
assert
(
pPreEntry
!=
NULL
);
if
(
pMsg
->
prevLogTerm
==
pPreEntry
->
term
)
{
preMatch
=
true
;
}
syncEntryDestory
(
pPreEntry
);
}
if
(
preMatch
)
{
// must has preIndex in local log
assert
(
pMsg
->
prevLogIndex
<=
ths
->
pLogStore
->
getLastIndex
(
ths
->
pLogStore
));
assert
(
pMsg
->
prevLogIndex
<=
ths
->
pLogStore
->
getLastIndex
(
ths
->
pLogStore
));
// has extra entries (> preIndex) in local log
bool
hasExtraEntries
=
pMsg
->
prevLogIndex
<
ths
->
pLogStore
->
getLastIndex
(
ths
->
pLogStore
);
bool
hasExtraEntries
=
pMsg
->
prevLogIndex
<
ths
->
pLogStore
->
getLastIndex
(
ths
->
pLogStore
);
// has entries in SyncAppendEntries msg
bool
hasAppendEntries
=
pMsg
->
dataLen
>
0
;
bool
hasAppendEntries
=
pMsg
->
dataLen
>
0
;
sTrace
(
"syncNodeOnAppendEntriesCb --> accept, pMsg->term:%lu, ths->pRaftStore->currentTerm:%lu, ths->state:%d, "
"logOK:%d, hasExtraEntries:%d, hasAppendEntries:%d"
,
pMsg
->
term
,
ths
->
pRaftStore
->
currentTerm
,
ths
->
state
,
logOK
,
hasExtraEntries
,
hasAppendEntries
);
if
(
hasExtraEntries
&&
hasAppendEntries
)
{
if
(
hasExtraEntries
&&
hasAppendEntries
)
{
// conflic
t
// not conflict by defaul
t
bool
conflict
=
false
;
bool
conflict
=
false
;
SyncIndex
extraIndex
=
pMsg
->
prevLogIndex
+
1
;
SyncIndex
extraIndex
=
pMsg
->
prevLogIndex
+
1
;
...
@@ -177,8 +180,9 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) {
...
@@ -177,8 +180,9 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) {
SSyncRaftEntry
*
pAppendEntry
=
syncEntryDeserialize
(
pMsg
->
data
,
pMsg
->
dataLen
);
SSyncRaftEntry
*
pAppendEntry
=
syncEntryDeserialize
(
pMsg
->
data
,
pMsg
->
dataLen
);
assert
(
pAppendEntry
!=
NULL
);
assert
(
pAppendEntry
!=
NULL
);
// log not match, conflict
assert
(
extraIndex
==
pAppendEntry
->
index
);
assert
(
extraIndex
==
pAppendEntry
->
index
);
if
(
pExtraEntry
->
term
=
=
pAppendEntry
->
term
)
{
if
(
pExtraEntry
->
term
!
=
pAppendEntry
->
term
)
{
conflict
=
true
;
conflict
=
true
;
}
}
...
@@ -187,6 +191,8 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) {
...
@@ -187,6 +191,8 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) {
SyncIndex
delBegin
=
ths
->
pLogStore
->
getLastIndex
(
ths
->
pLogStore
);
SyncIndex
delBegin
=
ths
->
pLogStore
->
getLastIndex
(
ths
->
pLogStore
);
SyncIndex
delEnd
=
extraIndex
;
SyncIndex
delEnd
=
extraIndex
;
sTrace
(
"syncNodeOnAppendEntriesCb --> conflict:%d, delBegin:%ld, delEnd:%ld"
,
conflict
,
delBegin
,
delEnd
);
// notice! reverse roll back!
// notice! reverse roll back!
for
(
SyncIndex
index
=
delEnd
;
index
>=
delBegin
;
--
index
)
{
for
(
SyncIndex
index
=
delEnd
;
index
>=
delBegin
;
--
index
)
{
if
(
ths
->
pFsm
->
FpRollBackCb
!=
NULL
)
{
if
(
ths
->
pFsm
->
FpRollBackCb
!=
NULL
)
{
...
@@ -195,7 +201,7 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) {
...
@@ -195,7 +201,7 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) {
SRpcMsg
rpcMsg
;
SRpcMsg
rpcMsg
;
syncEntry2OriginalRpc
(
pRollBackEntry
,
&
rpcMsg
);
syncEntry2OriginalRpc
(
pRollBackEntry
,
&
rpcMsg
);
ths
->
pFsm
->
FpRollBackCb
(
ths
->
pFsm
,
&
rpcMsg
,
pRollBackEntry
->
index
,
pRollBackEntry
->
isWeak
,
0
);
ths
->
pFsm
->
FpRollBackCb
(
ths
->
pFsm
,
&
rpcMsg
,
pRollBackEntry
->
index
,
pRollBackEntry
->
isWeak
,
0
,
ths
->
state
);
rpcFreeCont
(
rpcMsg
.
pCont
);
rpcFreeCont
(
rpcMsg
.
pCont
);
syncEntryDestory
(
pRollBackEntry
);
syncEntryDestory
(
pRollBackEntry
);
}
}
...
@@ -212,7 +218,7 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) {
...
@@ -212,7 +218,7 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) {
syncEntry2OriginalRpc
(
pAppendEntry
,
&
rpcMsg
);
syncEntry2OriginalRpc
(
pAppendEntry
,
&
rpcMsg
);
if
(
ths
->
pFsm
!=
NULL
)
{
if
(
ths
->
pFsm
!=
NULL
)
{
if
(
ths
->
pFsm
->
FpPreCommitCb
!=
NULL
)
{
if
(
ths
->
pFsm
->
FpPreCommitCb
!=
NULL
)
{
ths
->
pFsm
->
FpPreCommitCb
(
ths
->
pFsm
,
&
rpcMsg
,
pAppendEntry
->
index
,
pAppendEntry
->
isWeak
,
0
);
ths
->
pFsm
->
FpPreCommitCb
(
ths
->
pFsm
,
&
rpcMsg
,
pAppendEntry
->
index
,
pAppendEntry
->
isWeak
,
2
,
ths
->
state
);
}
}
}
}
rpcFreeCont
(
rpcMsg
.
pCont
);
rpcFreeCont
(
rpcMsg
.
pCont
);
...
@@ -237,7 +243,7 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) {
...
@@ -237,7 +243,7 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) {
syncEntry2OriginalRpc
(
pAppendEntry
,
&
rpcMsg
);
syncEntry2OriginalRpc
(
pAppendEntry
,
&
rpcMsg
);
if
(
ths
->
pFsm
!=
NULL
)
{
if
(
ths
->
pFsm
!=
NULL
)
{
if
(
ths
->
pFsm
->
FpPreCommitCb
!=
NULL
)
{
if
(
ths
->
pFsm
->
FpPreCommitCb
!=
NULL
)
{
ths
->
pFsm
->
FpPreCommitCb
(
ths
->
pFsm
,
&
rpcMsg
,
pAppendEntry
->
index
,
pAppendEntry
->
isWeak
,
0
);
ths
->
pFsm
->
FpPreCommitCb
(
ths
->
pFsm
,
&
rpcMsg
,
pAppendEntry
->
index
,
pAppendEntry
->
isWeak
,
3
,
ths
->
state
);
}
}
}
}
rpcFreeCont
(
rpcMsg
.
pCont
);
rpcFreeCont
(
rpcMsg
.
pCont
);
...
@@ -267,23 +273,8 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) {
...
@@ -267,23 +273,8 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) {
SRpcMsg
rpcMsg
;
SRpcMsg
rpcMsg
;
syncAppendEntriesReply2RpcMsg
(
pReply
,
&
rpcMsg
);
syncAppendEntriesReply2RpcMsg
(
pReply
,
&
rpcMsg
);
syncNodeSendMsgById
(
&
pReply
->
destId
,
ths
,
&
rpcMsg
);
syncNodeSendMsgById
(
&
pReply
->
destId
,
ths
,
&
rpcMsg
);
syncAppendEntriesReplyDestroy
(
pReply
);
syncAppendEntriesReplyDestroy
(
pReply
);
}
else
{
SyncAppendEntriesReply
*
pReply
=
syncAppendEntriesReplyBuild
();
pReply
->
srcId
=
ths
->
myRaftId
;
pReply
->
destId
=
pMsg
->
srcId
;
pReply
->
term
=
ths
->
pRaftStore
->
currentTerm
;
pReply
->
success
=
false
;
pReply
->
matchIndex
=
SYNC_INDEX_INVALID
;
SRpcMsg
rpcMsg
;
syncAppendEntriesReply2RpcMsg
(
pReply
,
&
rpcMsg
);
syncNodeSendMsgById
(
&
pReply
->
destId
,
ths
,
&
rpcMsg
);
syncAppendEntriesReplyDestroy
(
pReply
);
}
// maybe update commit index from leader
// maybe update commit index from leader
if
(
pMsg
->
commitIndex
>
ths
->
commitIndex
)
{
if
(
pMsg
->
commitIndex
>
ths
->
commitIndex
)
{
// has commit entry in local
// has commit entry in local
...
@@ -308,7 +299,7 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) {
...
@@ -308,7 +299,7 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) {
syncEntry2OriginalRpc
(
pEntry
,
&
rpcMsg
);
syncEntry2OriginalRpc
(
pEntry
,
&
rpcMsg
);
if
(
ths
->
pFsm
->
FpCommitCb
!=
NULL
)
{
if
(
ths
->
pFsm
->
FpCommitCb
!=
NULL
)
{
ths
->
pFsm
->
FpCommitCb
(
ths
->
pFsm
,
&
rpcMsg
,
pEntry
->
index
,
pEntry
->
isWeak
,
0
);
ths
->
pFsm
->
FpCommitCb
(
ths
->
pFsm
,
&
rpcMsg
,
pEntry
->
index
,
pEntry
->
isWeak
,
0
,
ths
->
state
);
}
}
rpcFreeCont
(
rpcMsg
.
pCont
);
rpcFreeCont
(
rpcMsg
.
pCont
);
...
...
source/libs/sync/src/syncAppendEntriesReply.c
浏览文件 @
4e8ebdef
...
@@ -48,6 +48,9 @@ int32_t syncNodeOnAppendEntriesReplyCb(SSyncNode* ths, SyncAppendEntriesReply* p
...
@@ -48,6 +48,9 @@ int32_t syncNodeOnAppendEntriesReplyCb(SSyncNode* ths, SyncAppendEntriesReply* p
return
ret
;
return
ret
;
}
}
syncIndexMgrLog2
(
"==syncNodeOnAppendEntriesReplyCb== before pNextIndex"
,
ths
->
pNextIndex
);
syncIndexMgrLog2
(
"==syncNodeOnAppendEntriesReplyCb== before pMatchIndex"
,
ths
->
pMatchIndex
);
// no need this code, because if I receive reply.term, then I must have sent for that term.
// no need this code, because if I receive reply.term, then I must have sent for that term.
// if (pMsg->term > ths->pRaftStore->currentTerm) {
// if (pMsg->term > ths->pRaftStore->currentTerm) {
// syncNodeUpdateTerm(ths, pMsg->term);
// syncNodeUpdateTerm(ths, pMsg->term);
...
@@ -77,5 +80,8 @@ int32_t syncNodeOnAppendEntriesReplyCb(SSyncNode* ths, SyncAppendEntriesReply* p
...
@@ -77,5 +80,8 @@ int32_t syncNodeOnAppendEntriesReplyCb(SSyncNode* ths, SyncAppendEntriesReply* p
syncIndexMgrSetIndex
(
ths
->
pNextIndex
,
&
(
pMsg
->
srcId
),
nextIndex
);
syncIndexMgrSetIndex
(
ths
->
pNextIndex
,
&
(
pMsg
->
srcId
),
nextIndex
);
}
}
syncIndexMgrLog2
(
"==syncNodeOnAppendEntriesReplyCb== after pNextIndex"
,
ths
->
pNextIndex
);
syncIndexMgrLog2
(
"==syncNodeOnAppendEntriesReplyCb== after pMatchIndex"
,
ths
->
pMatchIndex
);
return
ret
;
return
ret
;
}
}
source/libs/sync/src/syncCommit.c
浏览文件 @
4e8ebdef
...
@@ -63,7 +63,14 @@ void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) {
...
@@ -63,7 +63,14 @@ void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) {
if
(
pEntry
->
term
==
pSyncNode
->
pRaftStore
->
currentTerm
)
{
if
(
pEntry
->
term
==
pSyncNode
->
pRaftStore
->
currentTerm
)
{
// update commit index
// update commit index
newCommitIndex
=
index
;
newCommitIndex
=
index
;
sTrace
(
"syncMaybeAdvanceCommitIndex maybe to update, newCommitIndex:%ld commit, pSyncNode->commitIndex:%ld"
,
newCommitIndex
,
pSyncNode
->
commitIndex
);
break
;
break
;
}
else
{
sTrace
(
"syncMaybeAdvanceCommitIndex can not commit due to term not equal, pEntry->term:%lu, "
"pSyncNode->pRaftStore->currentTerm:%lu"
,
pEntry
->
term
,
pSyncNode
->
pRaftStore
->
currentTerm
);
}
}
}
}
}
}
...
@@ -91,7 +98,7 @@ void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) {
...
@@ -91,7 +98,7 @@ void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) {
syncEntry2OriginalRpc
(
pEntry
,
&
rpcMsg
);
syncEntry2OriginalRpc
(
pEntry
,
&
rpcMsg
);
if
(
pSyncNode
->
pFsm
->
FpCommitCb
!=
NULL
)
{
if
(
pSyncNode
->
pFsm
->
FpCommitCb
!=
NULL
)
{
pSyncNode
->
pFsm
->
FpCommitCb
(
pSyncNode
->
pFsm
,
&
rpcMsg
,
pEntry
->
index
,
pEntry
->
isWeak
,
0
);
pSyncNode
->
pFsm
->
FpCommitCb
(
pSyncNode
->
pFsm
,
&
rpcMsg
,
pEntry
->
index
,
pEntry
->
isWeak
,
0
,
pSyncNode
->
state
);
}
}
rpcFreeCont
(
rpcMsg
.
pCont
);
rpcFreeCont
(
rpcMsg
.
pCont
);
...
...
source/libs/sync/src/syncIO.c
浏览文件 @
4e8ebdef
...
@@ -257,13 +257,6 @@ static void *syncIOConsumerFunc(void *param) {
...
@@ -257,13 +257,6 @@ static void *syncIOConsumerFunc(void *param) {
assert
(
pSyncMsg
!=
NULL
);
assert
(
pSyncMsg
!=
NULL
);
io
->
FpOnSyncPing
(
io
->
pSyncNode
,
pSyncMsg
);
io
->
FpOnSyncPing
(
io
->
pSyncNode
,
pSyncMsg
);
syncPingDestroy
(
pSyncMsg
);
syncPingDestroy
(
pSyncMsg
);
/*
pSyncMsg = syncPingBuild(pRpcMsg->contLen);
syncPingFromRpcMsg(pRpcMsg, pSyncMsg);
// memcpy(pSyncMsg, tmpRpcMsg.pCont, tmpRpcMsg.contLen);
io->FpOnSyncPing(io->pSyncNode, pSyncMsg);
syncPingDestroy(pSyncMsg);
*/
}
}
}
else
if
(
pRpcMsg
->
msgType
==
SYNC_PING_REPLY
)
{
}
else
if
(
pRpcMsg
->
msgType
==
SYNC_PING_REPLY
)
{
...
...
source/libs/sync/src/syncMain.c
浏览文件 @
4e8ebdef
...
@@ -104,9 +104,26 @@ int32_t syncReconfig(int64_t rid, const SSyncCfg* pSyncCfg) {
...
@@ -104,9 +104,26 @@ int32_t syncReconfig(int64_t rid, const SSyncCfg* pSyncCfg) {
}
}
int32_t
syncPropose
(
int64_t
rid
,
const
SRpcMsg
*
pMsg
,
bool
isWeak
)
{
int32_t
syncPropose
(
int64_t
rid
,
const
SRpcMsg
*
pMsg
,
bool
isWeak
)
{
int32_t
ret
=
0
;
int32_t
ret
=
syncPropose2
(
rid
,
pMsg
,
isWeak
,
0
);
return
ret
;
}
int32_t
syncForwardToPeer
(
int64_t
rid
,
const
SRpcMsg
*
pMsg
,
bool
isWeak
)
{
int32_t
ret
=
syncPropose
(
rid
,
pMsg
,
isWeak
);
return
ret
;
}
// todo : get pointer from rid
ESyncState
syncGetMyRole
(
int64_t
rid
)
{
SSyncNode
*
pSyncNode
=
(
SSyncNode
*
)
taosAcquireRef
(
tsNodeRefId
,
rid
);
if
(
pSyncNode
==
NULL
)
{
return
TAOS_SYNC_STATE_ERROR
;
}
assert
(
rid
==
pSyncNode
->
rid
);
return
pSyncNode
->
state
;
}
int32_t
syncPropose2
(
int64_t
rid
,
const
SRpcMsg
*
pMsg
,
bool
isWeak
,
uint64_t
seqNum
)
{
int32_t
ret
=
0
;
SSyncNode
*
pSyncNode
=
(
SSyncNode
*
)
taosAcquireRef
(
tsNodeRefId
,
rid
);
SSyncNode
*
pSyncNode
=
(
SSyncNode
*
)
taosAcquireRef
(
tsNodeRefId
,
rid
);
if
(
pSyncNode
==
NULL
)
{
if
(
pSyncNode
==
NULL
)
{
return
-
1
;
return
-
1
;
...
@@ -114,7 +131,7 @@ int32_t syncPropose(int64_t rid, const SRpcMsg* pMsg, bool isWeak) {
...
@@ -114,7 +131,7 @@ int32_t syncPropose(int64_t rid, const SRpcMsg* pMsg, bool isWeak) {
assert
(
rid
==
pSyncNode
->
rid
);
assert
(
rid
==
pSyncNode
->
rid
);
if
(
pSyncNode
->
state
==
TAOS_SYNC_STATE_LEADER
)
{
if
(
pSyncNode
->
state
==
TAOS_SYNC_STATE_LEADER
)
{
SyncClientRequest
*
pSyncMsg
=
syncClientRequestBuild2
(
pMsg
,
0
,
isWeak
);
SyncClientRequest
*
pSyncMsg
=
syncClientRequestBuild2
(
pMsg
,
seqNum
,
isWeak
);
SRpcMsg
rpcMsg
;
SRpcMsg
rpcMsg
;
syncClientRequest2RpcMsg
(
pSyncMsg
,
&
rpcMsg
);
syncClientRequest2RpcMsg
(
pSyncMsg
,
&
rpcMsg
);
pSyncNode
->
FpEqMsg
(
pSyncNode
->
queue
,
&
rpcMsg
);
pSyncNode
->
FpEqMsg
(
pSyncNode
->
queue
,
&
rpcMsg
);
...
@@ -122,7 +139,7 @@ int32_t syncPropose(int64_t rid, const SRpcMsg* pMsg, bool isWeak) {
...
@@ -122,7 +139,7 @@ int32_t syncPropose(int64_t rid, const SRpcMsg* pMsg, bool isWeak) {
ret
=
0
;
ret
=
0
;
}
else
{
}
else
{
sTrace
(
"sync
ForwardToPeer
not leader, %s"
,
syncUtilState2String
(
pSyncNode
->
state
));
sTrace
(
"sync
Propose
not leader, %s"
,
syncUtilState2String
(
pSyncNode
->
state
));
ret
=
-
1
;
// todo : need define err code !!
ret
=
-
1
;
// todo : need define err code !!
}
}
...
@@ -130,19 +147,6 @@ int32_t syncPropose(int64_t rid, const SRpcMsg* pMsg, bool isWeak) {
...
@@ -130,19 +147,6 @@ int32_t syncPropose(int64_t rid, const SRpcMsg* pMsg, bool isWeak) {
return
ret
;
return
ret
;
}
}
int32_t
syncForwardToPeer
(
int64_t
rid
,
const
SRpcMsg
*
pMsg
,
bool
isWeak
)
{
int32_t
ret
=
syncPropose
(
rid
,
pMsg
,
isWeak
);
return
ret
;
}
ESyncState
syncGetMyRole
(
int64_t
rid
)
{
// todo : get pointer from rid
SSyncNode
*
pSyncNode
=
NULL
;
return
pSyncNode
->
state
;
}
void
syncGetNodesRole
(
int64_t
rid
,
SNodesRole
*
pNodeRole
)
{}
// open/close --------------
// open/close --------------
SSyncNode
*
syncNodeOpen
(
const
SSyncInfo
*
pSyncInfo
)
{
SSyncNode
*
syncNodeOpen
(
const
SSyncInfo
*
pSyncInfo
)
{
SSyncNode
*
pSyncNode
=
(
SSyncNode
*
)
malloc
(
sizeof
(
SSyncNode
));
SSyncNode
*
pSyncNode
=
(
SSyncNode
*
)
malloc
(
sizeof
(
SSyncNode
));
...
@@ -848,7 +852,7 @@ static int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg
...
@@ -848,7 +852,7 @@ static int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg
if
(
ths
->
pFsm
!=
NULL
)
{
if
(
ths
->
pFsm
!=
NULL
)
{
if
(
ths
->
pFsm
->
FpPreCommitCb
!=
NULL
)
{
if
(
ths
->
pFsm
->
FpPreCommitCb
!=
NULL
)
{
ths
->
pFsm
->
FpPreCommitCb
(
ths
->
pFsm
,
&
rpcMsg
,
pEntry
->
index
,
pEntry
->
isWeak
,
0
);
ths
->
pFsm
->
FpPreCommitCb
(
ths
->
pFsm
,
&
rpcMsg
,
pEntry
->
index
,
pEntry
->
isWeak
,
0
,
ths
->
state
);
}
}
}
}
rpcFreeCont
(
rpcMsg
.
pCont
);
rpcFreeCont
(
rpcMsg
.
pCont
);
...
@@ -863,7 +867,7 @@ static int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg
...
@@ -863,7 +867,7 @@ static int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg
if
(
ths
->
pFsm
!=
NULL
)
{
if
(
ths
->
pFsm
!=
NULL
)
{
if
(
ths
->
pFsm
->
FpPreCommitCb
!=
NULL
)
{
if
(
ths
->
pFsm
->
FpPreCommitCb
!=
NULL
)
{
ths
->
pFsm
->
FpPreCommitCb
(
ths
->
pFsm
,
&
rpcMsg
,
pEntry
->
index
,
pEntry
->
isWeak
,
-
2
);
ths
->
pFsm
->
FpPreCommitCb
(
ths
->
pFsm
,
&
rpcMsg
,
pEntry
->
index
,
pEntry
->
isWeak
,
1
,
ths
->
state
);
}
}
}
}
rpcFreeCont
(
rpcMsg
.
pCont
);
rpcFreeCont
(
rpcMsg
.
pCont
);
...
...
source/libs/sync/src/syncMessage.c
浏览文件 @
4e8ebdef
...
@@ -834,7 +834,7 @@ cJSON* syncRequestVote2Json(const SyncRequestVote* pMsg) {
...
@@ -834,7 +834,7 @@ cJSON* syncRequestVote2Json(const SyncRequestVote* pMsg) {
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%lu"
,
pMsg
->
term
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%lu"
,
pMsg
->
term
);
cJSON_AddStringToObject
(
pRoot
,
"term"
,
u64buf
);
cJSON_AddStringToObject
(
pRoot
,
"term"
,
u64buf
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%l
u
"
,
pMsg
->
lastLogIndex
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%l
d
"
,
pMsg
->
lastLogIndex
);
cJSON_AddStringToObject
(
pRoot
,
"lastLogIndex"
,
u64buf
);
cJSON_AddStringToObject
(
pRoot
,
"lastLogIndex"
,
u64buf
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%lu"
,
pMsg
->
lastLogTerm
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%lu"
,
pMsg
->
lastLogTerm
);
cJSON_AddStringToObject
(
pRoot
,
"lastLogTerm"
,
u64buf
);
cJSON_AddStringToObject
(
pRoot
,
"lastLogTerm"
,
u64buf
);
...
@@ -1127,14 +1127,14 @@ cJSON* syncAppendEntries2Json(const SyncAppendEntries* pMsg) {
...
@@ -1127,14 +1127,14 @@ cJSON* syncAppendEntries2Json(const SyncAppendEntries* pMsg) {
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%lu"
,
pMsg
->
term
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%lu"
,
pMsg
->
term
);
cJSON_AddStringToObject
(
pRoot
,
"term"
,
u64buf
);
cJSON_AddStringToObject
(
pRoot
,
"term"
,
u64buf
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%l
u
"
,
pMsg
->
prevLogIndex
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%l
d
"
,
pMsg
->
prevLogIndex
);
cJSON_AddStringToObject
(
pRoot
,
"pre
_log_i
ndex"
,
u64buf
);
cJSON_AddStringToObject
(
pRoot
,
"pre
vLogI
ndex"
,
u64buf
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%lu"
,
pMsg
->
prevLogTerm
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%lu"
,
pMsg
->
prevLogTerm
);
cJSON_AddStringToObject
(
pRoot
,
"pre_log_term"
,
u64buf
);
cJSON_AddStringToObject
(
pRoot
,
"pre_log_term"
,
u64buf
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%l
u
"
,
pMsg
->
commitIndex
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%l
d
"
,
pMsg
->
commitIndex
);
cJSON_AddStringToObject
(
pRoot
,
"commit
_i
ndex"
,
u64buf
);
cJSON_AddStringToObject
(
pRoot
,
"commit
I
ndex"
,
u64buf
);
cJSON_AddNumberToObject
(
pRoot
,
"dataLen"
,
pMsg
->
dataLen
);
cJSON_AddNumberToObject
(
pRoot
,
"dataLen"
,
pMsg
->
dataLen
);
char
*
s
;
char
*
s
;
...
@@ -1288,7 +1288,7 @@ cJSON* syncAppendEntriesReply2Json(const SyncAppendEntriesReply* pMsg) {
...
@@ -1288,7 +1288,7 @@ cJSON* syncAppendEntriesReply2Json(const SyncAppendEntriesReply* pMsg) {
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%lu"
,
pMsg
->
term
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%lu"
,
pMsg
->
term
);
cJSON_AddStringToObject
(
pRoot
,
"term"
,
u64buf
);
cJSON_AddStringToObject
(
pRoot
,
"term"
,
u64buf
);
cJSON_AddNumberToObject
(
pRoot
,
"success"
,
pMsg
->
success
);
cJSON_AddNumberToObject
(
pRoot
,
"success"
,
pMsg
->
success
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%l
u
"
,
pMsg
->
matchIndex
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%l
d
"
,
pMsg
->
matchIndex
);
cJSON_AddStringToObject
(
pRoot
,
"matchIndex"
,
u64buf
);
cJSON_AddStringToObject
(
pRoot
,
"matchIndex"
,
u64buf
);
}
}
...
...
source/libs/sync/src/syncRaftLog.c
浏览文件 @
4e8ebdef
...
@@ -165,6 +165,34 @@ char* logStore2Str(SSyncLogStore* pLogStore) {
...
@@ -165,6 +165,34 @@ char* logStore2Str(SSyncLogStore* pLogStore) {
return
serialized
;
return
serialized
;
}
}
cJSON
*
logStoreSimple2Json
(
SSyncLogStore
*
pLogStore
)
{
char
u64buf
[
128
];
SSyncLogStoreData
*
pData
=
(
SSyncLogStoreData
*
)
pLogStore
->
data
;
cJSON
*
pRoot
=
cJSON_CreateObject
();
if
(
pData
!=
NULL
&&
pData
->
pWal
!=
NULL
)
{
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%p"
,
pData
->
pSyncNode
);
cJSON_AddStringToObject
(
pRoot
,
"pSyncNode"
,
u64buf
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%p"
,
pData
->
pWal
);
cJSON_AddStringToObject
(
pRoot
,
"pWal"
,
u64buf
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%ld"
,
logStoreLastIndex
(
pLogStore
));
cJSON_AddStringToObject
(
pRoot
,
"LastIndex"
,
u64buf
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%lu"
,
logStoreLastTerm
(
pLogStore
));
cJSON_AddStringToObject
(
pRoot
,
"LastTerm"
,
u64buf
);
}
cJSON
*
pJson
=
cJSON_CreateObject
();
cJSON_AddItemToObject
(
pJson
,
"SSyncLogStoreSimple"
,
pRoot
);
return
pJson
;
}
char
*
logStoreSimple2Str
(
SSyncLogStore
*
pLogStore
)
{
cJSON
*
pJson
=
logStoreSimple2Json
(
pLogStore
);
char
*
serialized
=
cJSON_Print
(
pJson
);
cJSON_Delete
(
pJson
);
return
serialized
;
}
// for debug -----------------
// for debug -----------------
void
logStorePrint
(
SSyncLogStore
*
pLogStore
)
{
void
logStorePrint
(
SSyncLogStore
*
pLogStore
)
{
char
*
serialized
=
logStore2Str
(
pLogStore
);
char
*
serialized
=
logStore2Str
(
pLogStore
);
...
@@ -191,3 +219,30 @@ void logStoreLog2(char* s, SSyncLogStore* pLogStore) {
...
@@ -191,3 +219,30 @@ void logStoreLog2(char* s, SSyncLogStore* pLogStore) {
sTrace
(
"logStorePrint | len:%lu | %s | %s"
,
strlen
(
serialized
),
s
,
serialized
);
sTrace
(
"logStorePrint | len:%lu | %s | %s"
,
strlen
(
serialized
),
s
,
serialized
);
free
(
serialized
);
free
(
serialized
);
}
}
// for debug -----------------
void
logStoreSimplePrint
(
SSyncLogStore
*
pLogStore
)
{
char
*
serialized
=
logStoreSimple2Str
(
pLogStore
);
printf
(
"logStoreSimplePrint | len:%lu | %s
\n
"
,
strlen
(
serialized
),
serialized
);
fflush
(
NULL
);
free
(
serialized
);
}
void
logStoreSimplePrint2
(
char
*
s
,
SSyncLogStore
*
pLogStore
)
{
char
*
serialized
=
logStoreSimple2Str
(
pLogStore
);
printf
(
"logStoreSimplePrint2 | len:%lu | %s | %s
\n
"
,
strlen
(
serialized
),
s
,
serialized
);
fflush
(
NULL
);
free
(
serialized
);
}
void
logStoreSimpleLog
(
SSyncLogStore
*
pLogStore
)
{
char
*
serialized
=
logStoreSimple2Str
(
pLogStore
);
sTrace
(
"logStoreSimpleLog | len:%lu | %s"
,
strlen
(
serialized
),
serialized
);
free
(
serialized
);
}
void
logStoreSimpleLog2
(
char
*
s
,
SSyncLogStore
*
pLogStore
)
{
char
*
serialized
=
logStoreSimple2Str
(
pLogStore
);
sTrace
(
"logStoreSimpleLog2 | len:%lu | %s | %s"
,
strlen
(
serialized
),
s
,
serialized
);
free
(
serialized
);
}
\ No newline at end of file
source/libs/sync/src/syncReplication.c
浏览文件 @
4e8ebdef
...
@@ -49,6 +49,10 @@
...
@@ -49,6 +49,10 @@
int32_t
syncNodeAppendEntriesPeers
(
SSyncNode
*
pSyncNode
)
{
int32_t
syncNodeAppendEntriesPeers
(
SSyncNode
*
pSyncNode
)
{
assert
(
pSyncNode
->
state
==
TAOS_SYNC_STATE_LEADER
);
assert
(
pSyncNode
->
state
==
TAOS_SYNC_STATE_LEADER
);
syncIndexMgrLog2
(
"==syncNodeAppendEntriesPeers== pNextIndex"
,
pSyncNode
->
pNextIndex
);
syncIndexMgrLog2
(
"==syncNodeAppendEntriesPeers== pMatchIndex"
,
pSyncNode
->
pMatchIndex
);
logStoreSimpleLog2
(
"==syncNodeAppendEntriesPeers=="
,
pSyncNode
->
pLogStore
);
int32_t
ret
=
0
;
int32_t
ret
=
0
;
for
(
int
i
=
0
;
i
<
pSyncNode
->
peersNum
;
++
i
)
{
for
(
int
i
=
0
;
i
<
pSyncNode
->
peersNum
;
++
i
)
{
SRaftId
*
pDestId
=
&
(
pSyncNode
->
peersId
[
i
]);
SRaftId
*
pDestId
=
&
(
pSyncNode
->
peersId
[
i
]);
...
@@ -99,6 +103,8 @@ int32_t syncNodeAppendEntriesPeers(SSyncNode* pSyncNode) {
...
@@ -99,6 +103,8 @@ int32_t syncNodeAppendEntriesPeers(SSyncNode* pSyncNode) {
pMsg
->
prevLogTerm
=
preLogTerm
;
pMsg
->
prevLogTerm
=
preLogTerm
;
pMsg
->
commitIndex
=
pSyncNode
->
commitIndex
;
pMsg
->
commitIndex
=
pSyncNode
->
commitIndex
;
syncAppendEntriesLog2
(
"==syncNodeAppendEntriesPeers=="
,
pMsg
);
// send AppendEntries
// send AppendEntries
syncNodeAppendEntries
(
pSyncNode
,
pDestId
,
pMsg
);
syncNodeAppendEntries
(
pSyncNode
,
pDestId
,
pMsg
);
syncAppendEntriesDestroy
(
pMsg
);
syncAppendEntriesDestroy
(
pMsg
);
...
...
source/libs/sync/test/CMakeLists.txt
浏览文件 @
4e8ebdef
...
@@ -29,10 +29,14 @@ add_executable(syncPingTimerTest2 "")
...
@@ -29,10 +29,14 @@ add_executable(syncPingTimerTest2 "")
add_executable
(
syncPingSelfTest
""
)
add_executable
(
syncPingSelfTest
""
)
add_executable
(
syncElectTest
""
)
add_executable
(
syncElectTest
""
)
add_executable
(
syncElectTest2
""
)
add_executable
(
syncElectTest2
""
)
add_executable
(
syncElectTest3
""
)
add_executable
(
syncEncodeTest
""
)
add_executable
(
syncEncodeTest
""
)
add_executable
(
syncWriteTest
""
)
add_executable
(
syncWriteTest
""
)
add_executable
(
syncReplicateTest
""
)
add_executable
(
syncReplicateTest
""
)
add_executable
(
syncReplicateTest2
""
)
add_executable
(
syncReplicateLoadTest
""
)
add_executable
(
syncRefTest
""
)
add_executable
(
syncRefTest
""
)
add_executable
(
syncLogStoreCheck
""
)
target_sources
(
syncTest
target_sources
(
syncTest
...
@@ -159,6 +163,10 @@ target_sources(syncElectTest2
...
@@ -159,6 +163,10 @@ target_sources(syncElectTest2
PRIVATE
PRIVATE
"syncElectTest2.cpp"
"syncElectTest2.cpp"
)
)
target_sources
(
syncElectTest3
PRIVATE
"syncElectTest3.cpp"
)
target_sources
(
syncEncodeTest
target_sources
(
syncEncodeTest
PRIVATE
PRIVATE
"syncEncodeTest.cpp"
"syncEncodeTest.cpp"
...
@@ -171,10 +179,22 @@ target_sources(syncReplicateTest
...
@@ -171,10 +179,22 @@ target_sources(syncReplicateTest
PRIVATE
PRIVATE
"syncReplicateTest.cpp"
"syncReplicateTest.cpp"
)
)
target_sources
(
syncReplicateTest2
PRIVATE
"syncReplicateTest2.cpp"
)
target_sources
(
syncReplicateLoadTest
PRIVATE
"syncReplicateLoadTest.cpp"
)
target_sources
(
syncRefTest
target_sources
(
syncRefTest
PRIVATE
PRIVATE
"syncRefTest.cpp"
"syncRefTest.cpp"
)
)
target_sources
(
syncLogStoreCheck
PRIVATE
"syncLogStoreCheck.cpp"
)
target_include_directories
(
syncTest
target_include_directories
(
syncTest
...
@@ -332,6 +352,11 @@ target_include_directories(syncElectTest2
...
@@ -332,6 +352,11 @@ target_include_directories(syncElectTest2
"
${
CMAKE_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
)
target_include_directories
(
syncElectTest3
PUBLIC
"
${
CMAKE_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
target_include_directories
(
syncEncodeTest
target_include_directories
(
syncEncodeTest
PUBLIC
PUBLIC
"
${
CMAKE_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_SOURCE_DIR
}
/include/libs/sync"
...
@@ -347,11 +372,26 @@ target_include_directories(syncReplicateTest
...
@@ -347,11 +372,26 @@ target_include_directories(syncReplicateTest
"
${
CMAKE_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
)
target_include_directories
(
syncReplicateTest2
PUBLIC
"
${
CMAKE_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
target_include_directories
(
syncReplicateLoadTest
PUBLIC
"
${
CMAKE_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
target_include_directories
(
syncRefTest
target_include_directories
(
syncRefTest
PUBLIC
PUBLIC
"
${
CMAKE_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
)
target_include_directories
(
syncLogStoreCheck
PUBLIC
"
${
CMAKE_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
target_link_libraries
(
syncTest
target_link_libraries
(
syncTest
...
@@ -478,6 +518,10 @@ target_link_libraries(syncElectTest2
...
@@ -478,6 +518,10 @@ target_link_libraries(syncElectTest2
sync
sync
gtest_main
gtest_main
)
)
target_link_libraries
(
syncElectTest3
sync
gtest_main
)
target_link_libraries
(
syncEncodeTest
target_link_libraries
(
syncEncodeTest
sync
sync
gtest_main
gtest_main
...
@@ -490,10 +534,22 @@ target_link_libraries(syncReplicateTest
...
@@ -490,10 +534,22 @@ target_link_libraries(syncReplicateTest
sync
sync
gtest_main
gtest_main
)
)
target_link_libraries
(
syncReplicateTest2
sync
gtest_main
)
target_link_libraries
(
syncReplicateLoadTest
sync
gtest_main
)
target_link_libraries
(
syncRefTest
target_link_libraries
(
syncRefTest
sync
sync
gtest_main
gtest_main
)
)
target_link_libraries
(
syncLogStoreCheck
sync
gtest_main
)
enable_testing
()
enable_testing
()
...
...
source/libs/sync/test/syncElectTest3.cpp
0 → 100644
浏览文件 @
4e8ebdef
#include <gtest/gtest.h>
#include <stdio.h>
#include "syncEnv.h"
#include "syncIO.h"
#include "syncInt.h"
#include "syncRaftLog.h"
#include "syncRaftStore.h"
#include "syncUtil.h"
#include "tref.h"
void
logTest
()
{
sTrace
(
"--- sync log test: trace"
);
sDebug
(
"--- sync log test: debug"
);
sInfo
(
"--- sync log test: info"
);
sWarn
(
"--- sync log test: warn"
);
sError
(
"--- sync log test: error"
);
sFatal
(
"--- sync log test: fatal"
);
}
uint16_t
ports
[]
=
{
7010
,
7110
,
7210
,
7310
,
7410
};
int32_t
replicaNum
=
3
;
int32_t
myIndex
=
0
;
SRaftId
ids
[
TSDB_MAX_REPLICA
];
SSyncInfo
syncInfo
;
SSyncFSM
*
pFsm
;
SWal
*
pWal
;
int64_t
syncNodeInit
()
{
syncInfo
.
vgId
=
1234
;
syncInfo
.
rpcClient
=
gSyncIO
->
clientRpc
;
syncInfo
.
FpSendMsg
=
syncIOSendMsg
;
syncInfo
.
queue
=
gSyncIO
->
pMsgQ
;
syncInfo
.
FpEqMsg
=
syncIOEqMsg
;
syncInfo
.
pFsm
=
pFsm
;
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"./elect3_test_%d"
,
myIndex
);
int
code
=
walInit
();
assert
(
code
==
0
);
SWalCfg
walCfg
;
memset
(
&
walCfg
,
0
,
sizeof
(
SWalCfg
));
walCfg
.
vgId
=
syncInfo
.
vgId
;
walCfg
.
fsyncPeriod
=
1000
;
walCfg
.
retentionPeriod
=
1000
;
walCfg
.
rollPeriod
=
1000
;
walCfg
.
retentionSize
=
1000
;
walCfg
.
segSize
=
1000
;
walCfg
.
level
=
TAOS_WAL_FSYNC
;
char
tmpdir
[
128
];
snprintf
(
tmpdir
,
sizeof
(
tmpdir
),
"./elect3_test_wal_%d"
,
myIndex
);
pWal
=
walOpen
(
tmpdir
,
&
walCfg
);
assert
(
pWal
!=
NULL
);
syncInfo
.
pWal
=
pWal
;
SSyncCfg
*
pCfg
=
&
syncInfo
.
syncCfg
;
pCfg
->
myIndex
=
myIndex
;
pCfg
->
replicaNum
=
replicaNum
;
for
(
int
i
=
0
;
i
<
replicaNum
;
++
i
)
{
pCfg
->
nodeInfo
[
i
].
nodePort
=
ports
[
i
];
snprintf
(
pCfg
->
nodeInfo
[
i
].
nodeFqdn
,
sizeof
(
pCfg
->
nodeInfo
[
i
].
nodeFqdn
),
"%s"
,
"127.0.0.1"
);
// taosGetFqdn(pCfg->nodeInfo[0].nodeFqdn);
}
int64_t
rid
=
syncStart
(
&
syncInfo
);
assert
(
rid
>
0
);
SSyncNode
*
pSyncNode
=
(
SSyncNode
*
)
syncNodeAcquire
(
rid
);
assert
(
pSyncNode
!=
NULL
);
pSyncNode
->
hbBaseLine
=
500
;
pSyncNode
->
electBaseLine
=
1500
;
gSyncIO
->
FpOnSyncPing
=
pSyncNode
->
FpOnPing
;
gSyncIO
->
FpOnSyncPingReply
=
pSyncNode
->
FpOnPingReply
;
gSyncIO
->
FpOnSyncRequestVote
=
pSyncNode
->
FpOnRequestVote
;
gSyncIO
->
FpOnSyncRequestVoteReply
=
pSyncNode
->
FpOnRequestVoteReply
;
gSyncIO
->
FpOnSyncAppendEntries
=
pSyncNode
->
FpOnAppendEntries
;
gSyncIO
->
FpOnSyncAppendEntriesReply
=
pSyncNode
->
FpOnAppendEntriesReply
;
gSyncIO
->
FpOnSyncPing
=
pSyncNode
->
FpOnPing
;
gSyncIO
->
FpOnSyncPingReply
=
pSyncNode
->
FpOnPingReply
;
gSyncIO
->
FpOnSyncTimeout
=
pSyncNode
->
FpOnTimeout
;
gSyncIO
->
pSyncNode
=
pSyncNode
;
syncNodeRelease
(
pSyncNode
);
return
rid
;
}
void
initRaftId
(
SSyncNode
*
pSyncNode
)
{
for
(
int
i
=
0
;
i
<
replicaNum
;
++
i
)
{
ids
[
i
]
=
pSyncNode
->
replicasId
[
i
];
char
*
s
=
syncUtilRaftId2Str
(
&
ids
[
i
]);
printf
(
"raftId[%d] : %s
\n
"
,
i
,
s
);
free
(
s
);
}
}
int
main
(
int
argc
,
char
**
argv
)
{
// taosInitLog((char *)"syncTest.log", 100000, 10);
tsAsyncLog
=
0
;
sDebugFlag
=
143
+
64
;
myIndex
=
0
;
if
(
argc
>=
2
)
{
myIndex
=
atoi
(
argv
[
1
]);
}
int32_t
ret
=
syncIOStart
((
char
*
)
"127.0.0.1"
,
ports
[
myIndex
]);
assert
(
ret
==
0
);
ret
=
syncInit
();
assert
(
ret
==
0
);
int64_t
rid
=
syncNodeInit
();
assert
(
rid
>
0
);
SSyncNode
*
pSyncNode
=
(
SSyncNode
*
)
syncNodeAcquire
(
rid
);
assert
(
pSyncNode
!=
NULL
);
syncNodePrint2
((
char
*
)
""
,
pSyncNode
);
initRaftId
(
pSyncNode
);
//---------------------------
while
(
1
)
{
sTrace
(
"elect sleep, state: %d, %s, term:%lu electTimerLogicClock:%lu, electTimerLogicClockUser:%lu, electTimerMS:%d"
,
pSyncNode
->
state
,
syncUtilState2String
(
pSyncNode
->
state
),
pSyncNode
->
pRaftStore
->
currentTerm
,
pSyncNode
->
electTimerLogicClock
,
pSyncNode
->
electTimerLogicClockUser
,
pSyncNode
->
electTimerMS
);
taosMsleep
(
1000
);
}
syncNodeRelease
(
pSyncNode
);
return
0
;
}
source/libs/sync/test/syncLogStoreCheck.cpp
0 → 100644
浏览文件 @
4e8ebdef
#include <gtest/gtest.h>
#include <stdio.h>
#include "syncEnv.h"
#include "syncIO.h"
#include "syncInt.h"
#include "syncRaftLog.h"
#include "syncRaftStore.h"
#include "syncUtil.h"
void
logTest
()
{
sTrace
(
"--- sync log test: trace"
);
sDebug
(
"--- sync log test: debug"
);
sInfo
(
"--- sync log test: info"
);
sWarn
(
"--- sync log test: warn"
);
sError
(
"--- sync log test: error"
);
sFatal
(
"--- sync log test: fatal"
);
}
uint16_t
ports
[]
=
{
7010
,
7110
,
7210
,
7310
,
7410
};
int32_t
replicaNum
=
1
;
int32_t
myIndex
=
0
;
SRaftId
ids
[
TSDB_MAX_REPLICA
];
SSyncInfo
syncInfo
;
SSyncFSM
*
pFsm
;
SWal
*
pWal
;
SSyncNode
*
pSyncNode
;
SSyncNode
*
syncNodeInit
(
const
char
*
path
)
{
syncInfo
.
vgId
=
1234
;
syncInfo
.
rpcClient
=
gSyncIO
->
clientRpc
;
syncInfo
.
FpSendMsg
=
syncIOSendMsg
;
syncInfo
.
queue
=
gSyncIO
->
pMsgQ
;
syncInfo
.
FpEqMsg
=
syncIOEqMsg
;
syncInfo
.
pFsm
=
pFsm
;
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"%s"
,
"./log_check"
);
int
code
=
walInit
();
assert
(
code
==
0
);
SWalCfg
walCfg
;
memset
(
&
walCfg
,
0
,
sizeof
(
SWalCfg
));
walCfg
.
vgId
=
syncInfo
.
vgId
;
walCfg
.
fsyncPeriod
=
1000
;
walCfg
.
retentionPeriod
=
1000
;
walCfg
.
rollPeriod
=
1000
;
walCfg
.
retentionSize
=
1000
;
walCfg
.
segSize
=
1000
;
walCfg
.
level
=
TAOS_WAL_FSYNC
;
pWal
=
walOpen
(
path
,
&
walCfg
);
assert
(
pWal
!=
NULL
);
syncInfo
.
pWal
=
pWal
;
SSyncCfg
*
pCfg
=
&
syncInfo
.
syncCfg
;
pCfg
->
myIndex
=
myIndex
;
pCfg
->
replicaNum
=
replicaNum
;
for
(
int
i
=
0
;
i
<
replicaNum
;
++
i
)
{
pCfg
->
nodeInfo
[
i
].
nodePort
=
ports
[
i
];
snprintf
(
pCfg
->
nodeInfo
[
i
].
nodeFqdn
,
sizeof
(
pCfg
->
nodeInfo
[
i
].
nodeFqdn
),
"%s"
,
"127.0.0.1"
);
// taosGetFqdn(pCfg->nodeInfo[0].nodeFqdn);
}
pSyncNode
=
syncNodeOpen
(
&
syncInfo
);
assert
(
pSyncNode
!=
NULL
);
gSyncIO
->
FpOnSyncPing
=
pSyncNode
->
FpOnPing
;
gSyncIO
->
FpOnSyncPingReply
=
pSyncNode
->
FpOnPingReply
;
gSyncIO
->
FpOnSyncRequestVote
=
pSyncNode
->
FpOnRequestVote
;
gSyncIO
->
FpOnSyncRequestVoteReply
=
pSyncNode
->
FpOnRequestVoteReply
;
gSyncIO
->
FpOnSyncAppendEntries
=
pSyncNode
->
FpOnAppendEntries
;
gSyncIO
->
FpOnSyncAppendEntriesReply
=
pSyncNode
->
FpOnAppendEntriesReply
;
gSyncIO
->
FpOnSyncPing
=
pSyncNode
->
FpOnPing
;
gSyncIO
->
FpOnSyncPingReply
=
pSyncNode
->
FpOnPingReply
;
gSyncIO
->
FpOnSyncTimeout
=
pSyncNode
->
FpOnTimeout
;
gSyncIO
->
pSyncNode
=
pSyncNode
;
return
pSyncNode
;
}
SSyncNode
*
logStoreCheck
(
const
char
*
path
)
{
return
syncNodeInit
(
path
);
}
int
main
(
int
argc
,
char
**
argv
)
{
// taosInitLog((char *)"syncTest.log", 100000, 10);
tsAsyncLog
=
0
;
sDebugFlag
=
143
+
64
;
myIndex
=
0
;
if
(
argc
>=
2
)
{
myIndex
=
atoi
(
argv
[
1
]);
}
int32_t
ret
=
syncIOStart
((
char
*
)
"127.0.0.1"
,
ports
[
myIndex
]);
assert
(
ret
==
0
);
ret
=
syncEnvStart
();
assert
(
ret
==
0
);
pSyncNode
=
logStoreCheck
(
argv
[
1
]);
assert
(
pSyncNode
!=
NULL
);
logStorePrint2
((
char
*
)
"logStoreCheck"
,
pSyncNode
->
pLogStore
);
return
0
;
}
source/libs/sync/test/syncReplicateLoadTest.cpp
0 → 100644
浏览文件 @
4e8ebdef
#include <gtest/gtest.h>
#include <stdio.h>
#include "syncEnv.h"
#include "syncIO.h"
#include "syncInt.h"
#include "syncMessage.h"
#include "syncRaftEntry.h"
#include "syncRaftLog.h"
#include "syncRaftStore.h"
#include "syncUtil.h"
void
logTest
()
{
sTrace
(
"--- sync log test: trace"
);
sDebug
(
"--- sync log test: debug"
);
sInfo
(
"--- sync log test: info"
);
sWarn
(
"--- sync log test: warn"
);
sError
(
"--- sync log test: error"
);
sFatal
(
"--- sync log test: fatal"
);
}
uint16_t
ports
[]
=
{
7010
,
7110
,
7210
,
7310
,
7410
};
int32_t
replicaNum
=
3
;
int32_t
myIndex
=
0
;
SRaftId
ids
[
TSDB_MAX_REPLICA
];
SSyncInfo
syncInfo
;
SSyncFSM
*
pFsm
;
SWal
*
pWal
;
void
CommitCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SyncIndex
index
,
bool
isWeak
,
int32_t
code
,
ESyncState
state
)
{
char
logBuf
[
256
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==CommitCb== pFsm:%p, index:%ld, isWeak:%d, code:%d, state:%d %s
\n
"
,
pFsm
,
index
,
isWeak
,
code
,
state
,
syncUtilState2String
(
state
));
syncRpcMsgPrint2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
void
PreCommitCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SyncIndex
index
,
bool
isWeak
,
int32_t
code
,
ESyncState
state
)
{
char
logBuf
[
256
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==PreCommitCb== pFsm:%p, index:%ld, isWeak:%d, code:%d, state:%d %s
\n
"
,
pFsm
,
index
,
isWeak
,
code
,
state
,
syncUtilState2String
(
state
));
syncRpcMsgPrint2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
void
RollBackCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SyncIndex
index
,
bool
isWeak
,
int32_t
code
,
ESyncState
state
)
{
char
logBuf
[
256
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==RollBackCb== pFsm:%p, index:%ld, isWeak:%d, code:%d, state:%d %s
\n
"
,
pFsm
,
index
,
isWeak
,
code
,
state
,
syncUtilState2String
(
state
));
syncRpcMsgPrint2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
void
initFsm
()
{
pFsm
=
(
SSyncFSM
*
)
malloc
(
sizeof
(
SSyncFSM
));
pFsm
->
FpCommitCb
=
CommitCb
;
pFsm
->
FpPreCommitCb
=
PreCommitCb
;
pFsm
->
FpRollBackCb
=
RollBackCb
;
}
int64_t
syncNodeInit
()
{
syncInfo
.
vgId
=
1234
;
syncInfo
.
rpcClient
=
gSyncIO
->
clientRpc
;
syncInfo
.
FpSendMsg
=
syncIOSendMsg
;
syncInfo
.
queue
=
gSyncIO
->
pMsgQ
;
syncInfo
.
FpEqMsg
=
syncIOEqMsg
;
syncInfo
.
pFsm
=
pFsm
;
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"./replicate2_test_%d"
,
myIndex
);
int
code
=
walInit
();
assert
(
code
==
0
);
SWalCfg
walCfg
;
memset
(
&
walCfg
,
0
,
sizeof
(
SWalCfg
));
walCfg
.
vgId
=
syncInfo
.
vgId
;
walCfg
.
fsyncPeriod
=
1000
;
walCfg
.
retentionPeriod
=
1000
;
walCfg
.
rollPeriod
=
1000
;
walCfg
.
retentionSize
=
1000
;
walCfg
.
segSize
=
1000
;
walCfg
.
level
=
TAOS_WAL_FSYNC
;
char
tmpdir
[
128
];
snprintf
(
tmpdir
,
sizeof
(
tmpdir
),
"./replicate2_test_wal_%d"
,
myIndex
);
pWal
=
walOpen
(
tmpdir
,
&
walCfg
);
assert
(
pWal
!=
NULL
);
syncInfo
.
pWal
=
pWal
;
SSyncCfg
*
pCfg
=
&
syncInfo
.
syncCfg
;
pCfg
->
myIndex
=
myIndex
;
pCfg
->
replicaNum
=
replicaNum
;
for
(
int
i
=
0
;
i
<
replicaNum
;
++
i
)
{
pCfg
->
nodeInfo
[
i
].
nodePort
=
ports
[
i
];
snprintf
(
pCfg
->
nodeInfo
[
i
].
nodeFqdn
,
sizeof
(
pCfg
->
nodeInfo
[
i
].
nodeFqdn
),
"%s"
,
"127.0.0.1"
);
// taosGetFqdn(pCfg->nodeInfo[0].nodeFqdn);
}
int64_t
rid
=
syncStart
(
&
syncInfo
);
assert
(
rid
>
0
);
SSyncNode
*
pSyncNode
=
(
SSyncNode
*
)
syncNodeAcquire
(
rid
);
assert
(
pSyncNode
!=
NULL
);
// pSyncNode->hbBaseLine = 500;
// pSyncNode->electBaseLine = 1500;
gSyncIO
->
FpOnSyncPing
=
pSyncNode
->
FpOnPing
;
gSyncIO
->
FpOnSyncPingReply
=
pSyncNode
->
FpOnPingReply
;
gSyncIO
->
FpOnSyncRequestVote
=
pSyncNode
->
FpOnRequestVote
;
gSyncIO
->
FpOnSyncRequestVoteReply
=
pSyncNode
->
FpOnRequestVoteReply
;
gSyncIO
->
FpOnSyncAppendEntries
=
pSyncNode
->
FpOnAppendEntries
;
gSyncIO
->
FpOnSyncAppendEntriesReply
=
pSyncNode
->
FpOnAppendEntriesReply
;
gSyncIO
->
FpOnSyncTimeout
=
pSyncNode
->
FpOnTimeout
;
gSyncIO
->
FpOnSyncClientRequest
=
pSyncNode
->
FpOnClientRequest
;
gSyncIO
->
pSyncNode
=
pSyncNode
;
syncNodeRelease
(
pSyncNode
);
return
rid
;
}
void
initRaftId
(
SSyncNode
*
pSyncNode
)
{
for
(
int
i
=
0
;
i
<
replicaNum
;
++
i
)
{
ids
[
i
]
=
pSyncNode
->
replicasId
[
i
];
char
*
s
=
syncUtilRaftId2Str
(
&
ids
[
i
]);
printf
(
"raftId[%d] : %s
\n
"
,
i
,
s
);
free
(
s
);
}
}
SRpcMsg
*
step0
(
int
i
)
{
SRpcMsg
*
pMsg
=
(
SRpcMsg
*
)
malloc
(
sizeof
(
SRpcMsg
));
memset
(
pMsg
,
0
,
sizeof
(
SRpcMsg
));
pMsg
->
msgType
=
9999
;
pMsg
->
contLen
=
128
;
pMsg
->
pCont
=
malloc
(
pMsg
->
contLen
);
snprintf
((
char
*
)(
pMsg
->
pCont
),
pMsg
->
contLen
,
"value-%u-%d"
,
ports
[
myIndex
],
i
);
return
pMsg
;
}
SyncClientRequest
*
step1
(
const
SRpcMsg
*
pMsg
)
{
SyncClientRequest
*
pRetMsg
=
syncClientRequestBuild2
(
pMsg
,
123
,
true
);
return
pRetMsg
;
}
int
main
(
int
argc
,
char
**
argv
)
{
// taosInitLog((char *)"syncTest.log", 100000, 10);
tsAsyncLog
=
0
;
sDebugFlag
=
143
+
64
;
void
logTest
();
myIndex
=
0
;
if
(
argc
>=
2
)
{
myIndex
=
atoi
(
argv
[
1
]);
}
int32_t
ret
=
syncIOStart
((
char
*
)
"127.0.0.1"
,
ports
[
myIndex
]);
assert
(
ret
==
0
);
initFsm
();
ret
=
syncInit
();
assert
(
ret
==
0
);
int64_t
rid
=
syncNodeInit
();
assert
(
rid
>
0
);
SSyncNode
*
pSyncNode
=
(
SSyncNode
*
)
syncNodeAcquire
(
rid
);
assert
(
pSyncNode
!=
NULL
);
syncNodePrint2
((
char
*
)
""
,
pSyncNode
);
initRaftId
(
pSyncNode
);
// only load ...
while
(
1
)
{
sTrace
(
"replicate sleep, state: %d, %s, term:%lu electTimerLogicClock:%lu, electTimerLogicClockUser:%lu, "
"electTimerMS:%d"
,
pSyncNode
->
state
,
syncUtilState2String
(
pSyncNode
->
state
),
pSyncNode
->
pRaftStore
->
currentTerm
,
pSyncNode
->
electTimerLogicClock
,
pSyncNode
->
electTimerLogicClockUser
,
pSyncNode
->
electTimerMS
);
taosMsleep
(
1000
);
}
return
0
;
}
source/libs/sync/test/syncReplicateTest.cpp
浏览文件 @
4e8ebdef
...
@@ -28,19 +28,29 @@ SSyncFSM * pFsm;
...
@@ -28,19 +28,29 @@ SSyncFSM * pFsm;
SWal
*
pWal
;
SWal
*
pWal
;
SSyncNode
*
gSyncNode
;
SSyncNode
*
gSyncNode
;
void
CommitCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pBuf
,
SyncIndex
index
,
bool
isWeak
,
int32_t
code
)
{
void
CommitCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SyncIndex
index
,
bool
isWeak
,
int32_t
code
,
printf
(
"==CommitCb== pFsm:%p, index:%ld, isWeak:%d, code:%d
\n
"
,
pFsm
,
index
,
isWeak
,
code
);
ESyncState
state
)
{
syncRpcMsgPrint2
((
char
*
)
"==CommitCb=="
,
(
SRpcMsg
*
)
pBuf
);
char
logBuf
[
256
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==CommitCb== pFsm:%p, index:%ld, isWeak:%d, code:%d, state:%d %s
\n
"
,
pFsm
,
index
,
isWeak
,
code
,
state
,
syncUtilState2String
(
state
));
syncRpcMsgPrint2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
}
void
PreCommitCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pBuf
,
SyncIndex
index
,
bool
isWeak
,
int32_t
code
)
{
void
PreCommitCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SyncIndex
index
,
bool
isWeak
,
int32_t
code
,
printf
(
"==PreCommitCb== pFsm:%p, index:%ld, isWeak:%d, code:%d
\n
"
,
pFsm
,
index
,
isWeak
,
code
);
ESyncState
state
)
{
syncRpcMsgPrint2
((
char
*
)
"==PreCommitCb=="
,
(
SRpcMsg
*
)
pBuf
);
char
logBuf
[
256
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==PreCommitCb== pFsm:%p, index:%ld, isWeak:%d, code:%d, state:%d %s
\n
"
,
pFsm
,
index
,
isWeak
,
code
,
state
,
syncUtilState2String
(
state
));
syncRpcMsgPrint2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
}
void
RollBackCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pBuf
,
SyncIndex
index
,
bool
isWeak
,
int32_t
code
)
{
void
RollBackCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SyncIndex
index
,
bool
isWeak
,
int32_t
code
,
printf
(
"==RollBackCb== pFsm:%p, index:%ld, isWeak:%d, code:%d
\n
"
,
pFsm
,
index
,
isWeak
,
code
);
ESyncState
state
)
{
syncRpcMsgPrint2
((
char
*
)
"==RollBackCb=="
,
(
SRpcMsg
*
)
pBuf
);
char
logBuf
[
256
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==RollBackCb== pFsm:%p, index:%ld, isWeak:%d, code:%d, state:%d %s
\n
"
,
pFsm
,
index
,
isWeak
,
code
,
state
,
syncUtilState2String
(
state
));
syncRpcMsgPrint2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
}
void
initFsm
()
{
void
initFsm
()
{
...
...
source/libs/sync/test/syncReplicateTest2.cpp
0 → 100644
浏览文件 @
4e8ebdef
#include <gtest/gtest.h>
#include <stdio.h>
#include "syncEnv.h"
#include "syncIO.h"
#include "syncInt.h"
#include "syncMessage.h"
#include "syncRaftEntry.h"
#include "syncRaftLog.h"
#include "syncRaftStore.h"
#include "syncUtil.h"
void
logTest
()
{
sTrace
(
"--- sync log test: trace"
);
sDebug
(
"--- sync log test: debug"
);
sInfo
(
"--- sync log test: info"
);
sWarn
(
"--- sync log test: warn"
);
sError
(
"--- sync log test: error"
);
sFatal
(
"--- sync log test: fatal"
);
}
uint16_t
ports
[]
=
{
7010
,
7110
,
7210
,
7310
,
7410
};
int32_t
replicaNum
=
3
;
int32_t
myIndex
=
0
;
SRaftId
ids
[
TSDB_MAX_REPLICA
];
SSyncInfo
syncInfo
;
SSyncFSM
*
pFsm
;
SWal
*
pWal
;
void
CommitCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SyncIndex
index
,
bool
isWeak
,
int32_t
code
,
ESyncState
state
)
{
char
logBuf
[
256
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==CommitCb== pFsm:%p, index:%ld, isWeak:%d, code:%d, state:%d %s
\n
"
,
pFsm
,
index
,
isWeak
,
code
,
state
,
syncUtilState2String
(
state
));
syncRpcMsgPrint2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
void
PreCommitCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SyncIndex
index
,
bool
isWeak
,
int32_t
code
,
ESyncState
state
)
{
char
logBuf
[
256
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==PreCommitCb== pFsm:%p, index:%ld, isWeak:%d, code:%d, state:%d %s
\n
"
,
pFsm
,
index
,
isWeak
,
code
,
state
,
syncUtilState2String
(
state
));
syncRpcMsgPrint2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
void
RollBackCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SyncIndex
index
,
bool
isWeak
,
int32_t
code
,
ESyncState
state
)
{
char
logBuf
[
256
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==RollBackCb== pFsm:%p, index:%ld, isWeak:%d, code:%d, state:%d %s
\n
"
,
pFsm
,
index
,
isWeak
,
code
,
state
,
syncUtilState2String
(
state
));
syncRpcMsgPrint2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
void
initFsm
()
{
pFsm
=
(
SSyncFSM
*
)
malloc
(
sizeof
(
SSyncFSM
));
pFsm
->
FpCommitCb
=
CommitCb
;
pFsm
->
FpPreCommitCb
=
PreCommitCb
;
pFsm
->
FpRollBackCb
=
RollBackCb
;
}
int64_t
syncNodeInit
()
{
syncInfo
.
vgId
=
1234
;
syncInfo
.
rpcClient
=
gSyncIO
->
clientRpc
;
syncInfo
.
FpSendMsg
=
syncIOSendMsg
;
syncInfo
.
queue
=
gSyncIO
->
pMsgQ
;
syncInfo
.
FpEqMsg
=
syncIOEqMsg
;
syncInfo
.
pFsm
=
pFsm
;
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"./replicate2_test_%d"
,
myIndex
);
int
code
=
walInit
();
assert
(
code
==
0
);
SWalCfg
walCfg
;
memset
(
&
walCfg
,
0
,
sizeof
(
SWalCfg
));
walCfg
.
vgId
=
syncInfo
.
vgId
;
walCfg
.
fsyncPeriod
=
1000
;
walCfg
.
retentionPeriod
=
1000
;
walCfg
.
rollPeriod
=
1000
;
walCfg
.
retentionSize
=
1000
;
walCfg
.
segSize
=
1000
;
walCfg
.
level
=
TAOS_WAL_FSYNC
;
char
tmpdir
[
128
];
snprintf
(
tmpdir
,
sizeof
(
tmpdir
),
"./replicate2_test_wal_%d"
,
myIndex
);
pWal
=
walOpen
(
tmpdir
,
&
walCfg
);
assert
(
pWal
!=
NULL
);
syncInfo
.
pWal
=
pWal
;
SSyncCfg
*
pCfg
=
&
syncInfo
.
syncCfg
;
pCfg
->
myIndex
=
myIndex
;
pCfg
->
replicaNum
=
replicaNum
;
for
(
int
i
=
0
;
i
<
replicaNum
;
++
i
)
{
pCfg
->
nodeInfo
[
i
].
nodePort
=
ports
[
i
];
snprintf
(
pCfg
->
nodeInfo
[
i
].
nodeFqdn
,
sizeof
(
pCfg
->
nodeInfo
[
i
].
nodeFqdn
),
"%s"
,
"127.0.0.1"
);
// taosGetFqdn(pCfg->nodeInfo[0].nodeFqdn);
}
int64_t
rid
=
syncStart
(
&
syncInfo
);
assert
(
rid
>
0
);
SSyncNode
*
pSyncNode
=
(
SSyncNode
*
)
syncNodeAcquire
(
rid
);
assert
(
pSyncNode
!=
NULL
);
// pSyncNode->hbBaseLine = 500;
// pSyncNode->electBaseLine = 1500;
gSyncIO
->
FpOnSyncPing
=
pSyncNode
->
FpOnPing
;
gSyncIO
->
FpOnSyncPingReply
=
pSyncNode
->
FpOnPingReply
;
gSyncIO
->
FpOnSyncRequestVote
=
pSyncNode
->
FpOnRequestVote
;
gSyncIO
->
FpOnSyncRequestVoteReply
=
pSyncNode
->
FpOnRequestVoteReply
;
gSyncIO
->
FpOnSyncAppendEntries
=
pSyncNode
->
FpOnAppendEntries
;
gSyncIO
->
FpOnSyncAppendEntriesReply
=
pSyncNode
->
FpOnAppendEntriesReply
;
gSyncIO
->
FpOnSyncTimeout
=
pSyncNode
->
FpOnTimeout
;
gSyncIO
->
FpOnSyncClientRequest
=
pSyncNode
->
FpOnClientRequest
;
gSyncIO
->
pSyncNode
=
pSyncNode
;
syncNodeRelease
(
pSyncNode
);
return
rid
;
}
void
initRaftId
(
SSyncNode
*
pSyncNode
)
{
for
(
int
i
=
0
;
i
<
replicaNum
;
++
i
)
{
ids
[
i
]
=
pSyncNode
->
replicasId
[
i
];
char
*
s
=
syncUtilRaftId2Str
(
&
ids
[
i
]);
printf
(
"raftId[%d] : %s
\n
"
,
i
,
s
);
free
(
s
);
}
}
SRpcMsg
*
step0
(
int
i
)
{
SRpcMsg
*
pMsg
=
(
SRpcMsg
*
)
malloc
(
sizeof
(
SRpcMsg
));
memset
(
pMsg
,
0
,
sizeof
(
SRpcMsg
));
pMsg
->
msgType
=
9999
;
pMsg
->
contLen
=
128
;
pMsg
->
pCont
=
malloc
(
pMsg
->
contLen
);
snprintf
((
char
*
)(
pMsg
->
pCont
),
pMsg
->
contLen
,
"value-%u-%d"
,
ports
[
myIndex
],
i
);
return
pMsg
;
}
SyncClientRequest
*
step1
(
const
SRpcMsg
*
pMsg
)
{
SyncClientRequest
*
pRetMsg
=
syncClientRequestBuild2
(
pMsg
,
123
,
true
);
return
pRetMsg
;
}
int
main
(
int
argc
,
char
**
argv
)
{
// taosInitLog((char *)"syncTest.log", 100000, 10);
tsAsyncLog
=
0
;
sDebugFlag
=
143
+
64
;
void
logTest
();
myIndex
=
0
;
if
(
argc
>=
2
)
{
myIndex
=
atoi
(
argv
[
1
]);
}
int32_t
ret
=
syncIOStart
((
char
*
)
"127.0.0.1"
,
ports
[
myIndex
]);
assert
(
ret
==
0
);
initFsm
();
ret
=
syncInit
();
assert
(
ret
==
0
);
int64_t
rid
=
syncNodeInit
();
assert
(
rid
>
0
);
SSyncNode
*
pSyncNode
=
(
SSyncNode
*
)
syncNodeAcquire
(
rid
);
assert
(
pSyncNode
!=
NULL
);
syncNodePrint2
((
char
*
)
""
,
pSyncNode
);
initRaftId
(
pSyncNode
);
for
(
int
i
=
0
;
i
<
30
;
++
i
)
{
// step0
SRpcMsg
*
pMsg0
=
step0
(
i
);
syncRpcMsgPrint2
((
char
*
)
"==step0=="
,
pMsg0
);
syncPropose
(
rid
,
pMsg0
,
true
);
taosMsleep
(
1000
);
free
(
pMsg0
);
sTrace
(
"syncPropose sleep, state: %d, %s, term:%lu electTimerLogicClock:%lu, electTimerLogicClockUser:%lu, "
"electTimerMS:%d"
,
pSyncNode
->
state
,
syncUtilState2String
(
pSyncNode
->
state
),
pSyncNode
->
pRaftStore
->
currentTerm
,
pSyncNode
->
electTimerLogicClock
,
pSyncNode
->
electTimerLogicClockUser
,
pSyncNode
->
electTimerMS
);
}
while
(
1
)
{
sTrace
(
"replicate sleep, state: %d, %s, term:%lu electTimerLogicClock:%lu, electTimerLogicClockUser:%lu, "
"electTimerMS:%d"
,
pSyncNode
->
state
,
syncUtilState2String
(
pSyncNode
->
state
),
pSyncNode
->
pRaftStore
->
currentTerm
,
pSyncNode
->
electTimerLogicClock
,
pSyncNode
->
electTimerLogicClockUser
,
pSyncNode
->
electTimerMS
);
taosMsleep
(
1000
);
}
return
0
;
}
source/libs/sync/test/syncWriteTest.cpp
浏览文件 @
4e8ebdef
...
@@ -28,19 +28,29 @@ SSyncFSM * pFsm;
...
@@ -28,19 +28,29 @@ SSyncFSM * pFsm;
SWal
*
pWal
;
SWal
*
pWal
;
SSyncNode
*
gSyncNode
;
SSyncNode
*
gSyncNode
;
void
CommitCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pBuf
,
SyncIndex
index
,
bool
isWeak
,
int32_t
code
)
{
void
CommitCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SyncIndex
index
,
bool
isWeak
,
int32_t
code
,
printf
(
"==CommitCb== pFsm:%p, index:%ld, isWeak:%d, code:%d
\n
"
,
pFsm
,
index
,
isWeak
,
code
);
ESyncState
state
)
{
syncRpcMsgPrint2
((
char
*
)
"==CommitCb=="
,
(
SRpcMsg
*
)
pBuf
);
char
logBuf
[
256
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==CommitCb== pFsm:%p, index:%ld, isWeak:%d, code:%d, state:%d %s
\n
"
,
pFsm
,
index
,
isWeak
,
code
,
state
,
syncUtilState2String
(
state
));
syncRpcMsgPrint2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
}
void
PreCommitCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pBuf
,
SyncIndex
index
,
bool
isWeak
,
int32_t
code
)
{
void
PreCommitCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SyncIndex
index
,
bool
isWeak
,
int32_t
code
,
printf
(
"==PreCommitCb== pFsm:%p, index:%ld, isWeak:%d, code:%d
\n
"
,
pFsm
,
index
,
isWeak
,
code
);
ESyncState
state
)
{
syncRpcMsgPrint2
((
char
*
)
"==PreCommitCb=="
,
(
SRpcMsg
*
)
pBuf
);
char
logBuf
[
256
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==PreCommitCb== pFsm:%p, index:%ld, isWeak:%d, code:%d, state:%d %s
\n
"
,
pFsm
,
index
,
isWeak
,
code
,
state
,
syncUtilState2String
(
state
));
syncRpcMsgPrint2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
}
void
RollBackCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pBuf
,
SyncIndex
index
,
bool
isWeak
,
int32_t
code
)
{
void
RollBackCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SyncIndex
index
,
bool
isWeak
,
int32_t
code
,
printf
(
"==RollBackCb== pFsm:%p, index:%ld, isWeak:%d, code:%d
\n
"
,
pFsm
,
index
,
isWeak
,
code
);
ESyncState
state
)
{
syncRpcMsgPrint2
((
char
*
)
"==RollBackCb=="
,
(
SRpcMsg
*
)
pBuf
);
char
logBuf
[
256
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==RollBackCb== pFsm:%p, index:%ld, isWeak:%d, code:%d, state:%d %s
\n
"
,
pFsm
,
index
,
isWeak
,
code
,
state
,
syncUtilState2String
(
state
));
syncRpcMsgPrint2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
}
void
initFsm
()
{
void
initFsm
()
{
...
...
source/os/src/osSocket.c
浏览文件 @
4e8ebdef
...
@@ -47,9 +47,6 @@
...
@@ -47,9 +47,6 @@
#endif
#endif
#endif
#endif
typedef
int32_t
SocketFd
;
typedef
SocketFd
EpollFd
;
typedef
struct
TdSocketServer
{
typedef
struct
TdSocketServer
{
#if SOCKET_WITH_LOCK
#if SOCKET_WITH_LOCK
TdThreadRwlock
rwlock
;
TdThreadRwlock
rwlock
;
...
@@ -58,14 +55,6 @@ typedef struct TdSocketServer {
...
@@ -58,14 +55,6 @@ typedef struct TdSocketServer {
SocketFd
fd
;
SocketFd
fd
;
}
*
TdSocketServerPtr
,
TdSocketServer
;
}
*
TdSocketServerPtr
,
TdSocketServer
;
typedef
struct
TdSocket
{
#if SOCKET_WITH_LOCK
TdThreadRwlock
rwlock
;
#endif
int
refId
;
SocketFd
fd
;
}
*
TdSocketPtr
,
TdSocket
;
typedef
struct
TdEpoll
{
typedef
struct
TdEpoll
{
#if SOCKET_WITH_LOCK
#if SOCKET_WITH_LOCK
TdThreadRwlock
rwlock
;
TdThreadRwlock
rwlock
;
...
...
source/util/src/terror.c
浏览文件 @
4e8ebdef
...
@@ -336,6 +336,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TDB_TDB_ENV_OPEN_ERROR, "TDB env open error")
...
@@ -336,6 +336,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TDB_TDB_ENV_OPEN_ERROR, "TDB env open error")
TAOS_DEFINE_ERROR
(
TSDB_CODE_TDB_NO_SMA_INDEX_IN_META
,
"No sma index in meta"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TDB_NO_SMA_INDEX_IN_META
,
"No sma index in meta"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TDB_INVALID_SMA_STAT
,
"Invalid sma state"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TDB_INVALID_SMA_STAT
,
"Invalid sma state"
)
// query
// query
TAOS_DEFINE_ERROR
(
TSDB_CODE_QRY_INVALID_QHANDLE
,
"Invalid handle"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_QRY_INVALID_QHANDLE
,
"Invalid handle"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_QRY_INVALID_MSG
,
"Invalid message"
)
// failed to validate the sql expression msg by vnode
TAOS_DEFINE_ERROR
(
TSDB_CODE_QRY_INVALID_MSG
,
"Invalid message"
)
// failed to validate the sql expression msg by vnode
...
...
tests/script/jenkins/basic.txt
浏览文件 @
4e8ebdef
...
@@ -10,18 +10,20 @@
...
@@ -10,18 +10,20 @@
./test.sh -f tsim/db/basic7.sim
./test.sh -f tsim/db/basic7.sim
./test.sh -f tsim/db/error1.sim
./test.sh -f tsim/db/error1.sim
# ---- table
./test.sh -f tsim/table/basic1.sim
# ---- dnode
# ---- dnode
./test.sh -f tsim/dnode/basic1.sim
./test.sh -f tsim/dnode/basic1.sim
# ---- insert
# ---- insert
./test.sh -f tsim/insert/basic0.sim
./test.sh -f tsim/insert/basic0.sim
./test.sh -f tsim/insert/null.sim
# ---- query
# ---- query
./test.sh -f tsim/query/interval.sim
./test.sh -f tsim/query/interval.sim
# ---- table
./test.sh -f tsim/table/basic1.sim
# ---- tmq
# ---- tmq
./test.sh -f tsim/tmq/basic.sim
./test.sh -f tsim/tmq/basic.sim
#======================b1-end===============
#======================b1-end===============
tests/script/tsim/insert/basic0.sim
浏览文件 @
4e8ebdef
...
@@ -36,14 +36,14 @@ endi
...
@@ -36,14 +36,14 @@ endi
print =============== insert data, mode1: one row one table in sql
print =============== insert data, mode1: one row one table in sql
print =============== insert data, mode1: mulit rows one table in sql
print =============== insert data, mode1: mulit rows one table in sql
print =============== insert data, mode1: one rows mulit table in sql
#
print =============== insert data, mode1: one rows mulit table in sql
print =============== insert data, mode1: mulit rows mulit table in sql
#
print =============== insert data, mode1: mulit rows mulit table in sql
sql insert into ct1 values(now+0s, 10, 2.0, 3.0)
sql insert into ct1 values(now+0s, 10, 2.0, 3.0)
sql insert into ct1 values(now+1s, 11, 2.1, 3.1)(now+2s,
12, 2.2, 3.2)(now+3s, 13, 2.3,
3.3)
sql insert into ct1 values(now+1s, 11, 2.1, 3.1)(now+2s,
-12, -2.2, -3.2)(now+3s, -13, -2.3, -
3.3)
sql insert into ct2 values(now+0s, 10, 2.0, 3.0)
sql insert into ct2 values(now+0s, 10, 2.0, 3.0)
sql insert into ct2 values(now+1s, 11, 2.1, 3.1)(now+2s,
12, 2.2, 3.2)(now+3s, 13, 2.3,
3.3)
sql insert into ct2 values(now+1s, 11, 2.1, 3.1)(now+2s,
-12, -2.2, -3.2)(now+3s, -13, -2.3, -
3.3)
sql insert into ct1 values(now+4s, -14, -2.4, -3.4) ct2 values(now+4s, -14, -2.4, -3.4)
#
sql insert into ct1 values(now+4s, -14, -2.4, -3.4) ct2 values(now+4s, -14, -2.4, -3.4)
sql insert into ct1 values(now+5s, -15, -2.5, -3.5)(now+6s, -16, -2.6, -3.6) ct2 values(now+5s, -15, -2.5, -3.5)(now+6s, -16, -2.6, -3.6)
#
sql insert into ct1 values(now+5s, -15, -2.5, -3.5)(now+6s, -16, -2.6, -3.6) ct2 values(now+5s, -15, -2.5, -3.5)(now+6s, -16, -2.6, -3.6)
sql insert into ct3 values('2021-01-01 00:00:00.000', 10, 2.0, 3.0)
sql insert into ct3 values('2021-01-01 00:00:00.000', 10, 2.0, 3.0)
...
@@ -52,14 +52,11 @@ sql insert into ct3 values('2021-01-01 00:00:00.000', 10, 2.0, 3.0)
...
@@ -52,14 +52,11 @@ sql insert into ct3 values('2021-01-01 00:00:00.000', 10, 2.0, 3.0)
print =============== query data from child table
print =============== query data from child table
sql select * from ct1
sql select * from ct1
print rows: $rows
print rows: $rows
print $data00 $data01
print $data00 $data01 $data02 $data03
print $data10 $data11
print $data10 $data11 $data12 $data13
print $data20 $data21
print $data20 $data21 $data22 $data23
print $data30 $data31
print $data30 $data31 $data32 $data33
print $data40 $data41
if $rows != 4 then
print $data50 $data51
print $data60 $data61
if $rows != 7 then
return -1
return -1
endi
endi
if $data01 != 10 then
if $data01 != 10 then
...
@@ -84,28 +81,29 @@ endi
...
@@ -84,28 +81,29 @@ endi
print =============== select count(*) from child table
print =============== select count(*) from child table
sql select count(*) from ct1
sql select count(*) from ct1
print rows: $rows
print $data00 $data01 $data02 $data03
if $rows != 1 then
if $rows != 1 then
return -1
return -1
endi
endi
if $data00 != 4 then
print $data00 $data01 $data02
if $data00 != 7 then
return -1
return -1
endi
endi
print =============== select count(column) from child table
print =============== select count(column) from child table
sql select count(ts), count(c1), count(c2), count(c3) from ct1
sql select count(ts), count(c1), count(c2), count(c3) from ct1
print rows: $rows
print $data00 $data01 $data02 $data03
print $data00 $data01 $data02 $data03
if $data00 !=
7
then
if $data00 !=
4
then
return -1
return -1
endi
endi
if $data01 !=
7
then
if $data01 !=
4
then
return -1
return -1
endi
endi
if $data02 !=
7
then
if $data02 !=
4
then
return -1
return -1
endi
endi
if $data03 !=
7
then
if $data03 !=
4
then
return -1
return -1
endi
endi
...
@@ -115,17 +113,18 @@ endi
...
@@ -115,17 +113,18 @@ endi
print =============== select min(column) from child table
print =============== select min(column) from child table
sql select min(c1), min(c2), min(c3) from ct1
sql select min(c1), min(c2), min(c3) from ct1
print rows: $rows
print $data00 $data01 $data02 $data03
print $data00 $data01 $data02 $data03
if $rows != 1 then
if $rows != 1 then
return -1
return -1
endi
endi
if $data00 != -1
6
then
if $data00 != -1
3
then
return -1
return -1
endi
endi
if $data01 != -2.
6
0000 then
if $data01 != -2.
3
0000 then
return -1
return -1
endi
endi
if $data02 != -3.
6
00000000 then
if $data02 != -3.
3
00000000 then
return -1
return -1
endi
endi
...
@@ -135,13 +134,13 @@ print $data00 $data01 $data02 $data03
...
@@ -135,13 +134,13 @@ print $data00 $data01 $data02 $data03
if $rows != 1 then
if $rows != 1 then
return -1
return -1
endi
endi
if $data00 != 1
3
then
if $data00 != 1
1
then
return -1
return -1
endi
endi
if $data01 != 2.
3
0000 then
if $data01 != 2.
1
0000 then
return -1
return -1
endi
endi
if $data02 != 3.
3
00000000 then
if $data02 != 3.
1
00000000 then
return -1
return -1
endi
endi
...
@@ -151,49 +150,53 @@ print $data00 $data01 $data02 $data03
...
@@ -151,49 +150,53 @@ print $data00 $data01 $data02 $data03
if $rows != 1 then
if $rows != 1 then
return -1
return -1
endi
endi
if $data00 !=
1
then
if $data00 !=
-4
then
return -1
return -1
endi
endi
if $data01 !=
1.09999990
5 then
if $data01 !=
-0.40000009
5 then
return -1
return -1
endi
endi
if $data02 !=
2.1
00000000 then
if $data02 !=
-0.4
00000000 then
return -1
return -1
endi
endi
print =============== select column, from child table
print =============== select column
without timestamp
, from child table
sql select c1, c2, c3 from ct1
sql select c1, c2, c3 from ct1
print rows: $rows
print $data00 $data01 $data02
print $data00 $data01 $data02
#if $rows != 4 then
print $data10 $data11 $data12
# return -1
print $data20 $data21 $data22
#endi
print $data30 $data31 $data32
#if $data00 != 10 then
if $rows != 4 then
# return -1
return -1
#endi
endi
#if $data01 != 2.00000 then
if $data00 != 10 then
# return -1
return -1
#endi
endi
#if $data02 != 3.000000000 then
if $data01 != 2.00000 then
# return -1
return -1
#endi
endi
#if $data10 != 11 then
if $data02 != 3.000000000 then
# return -1
return -1
#endi
endi
#if $data11 != 2.10000 then
if $data10 != 11 then
# return -1
return -1
#endi
endi
#if $data12 != 3.100000000 then
if $data11 != 2.10000 then
# return -1
return -1
#endi
endi
#if $data30 != 13 then
if $data12 != 3.100000000 then
# return -1
return -1
#endi
endi
#if $data31 != 2.30000 then
if $data30 != -13 then
# return -1
return -1
#endi
endi
#if $data32 != 3.300000000 then
if $data31 != -2.30000 then
# return -1
return -1
#endi
endi
if $data32 != -3.300000000 then
return -1
endi
#===================================================================
#===================================================================
#===================================================================
#===================================================================
...
@@ -202,17 +205,17 @@ print $data00 $data01 $data02
...
@@ -202,17 +205,17 @@ print $data00 $data01 $data02
#if $rows != 4 then
#if $rows != 4 then
# return -1
# return -1
#endi
#endi
#print =============== select count(*) from supter table
#print =============== select count(*) from supter table
#sql select count(*) from stb
#sql select count(*) from stb
#print $data00 $data01 $data02
#if $rows != 1 then
#if $rows != 1 then
# return -1
# return -1
#endi
#endi
#
#if $data00 != 9 then
#print $data00 $data01 $data02
#if $data00 != 8 then
# return -1
# return -1
#endi
#endi
#
#print =============== select count(column) from supter table
#print =============== select count(column) from supter table
#sql select count(ts), count(c1), count(c2), count(c3) from stb
#sql select count(ts), count(c1), count(c2), count(c3) from stb
#print $data00 $data01 $data02 $data03
#print $data00 $data01 $data02 $data03
...
@@ -237,9 +240,31 @@ print =============== stop and restart taosd, then again do query above
...
@@ -237,9 +240,31 @@ print =============== stop and restart taosd, then again do query above
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode1 -s start
system sh/exec.sh -n dnode1 -s start
sleep 2000
$loop_cnt = 0
check_dnode_ready:
$loop_cnt = $loop_cnt + 1
sleep 200
if $loop_cnt == 10 then
print ====> dnode not ready!
return -1
endi
sql show dnodes
print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05
if $data00 != 1 then
return -1
endi
if $data04 != ready then
goto check_dnode_ready
endi
print =============== query data from child table
sql select * from ct1
sql select * from ct1
if $rows != 7 then
print rows: $rows
print $data00 $data01 $data02 $data03
print $data10 $data11 $data12 $data13
print $data20 $data21 $data22 $data23
print $data30 $data31 $data32 $data33
if $rows != 4 then
return -1
return -1
endi
endi
if $data01 != 10 then
if $data01 != 10 then
...
@@ -264,28 +289,29 @@ endi
...
@@ -264,28 +289,29 @@ endi
print =============== select count(*) from child table
print =============== select count(*) from child table
sql select count(*) from ct1
sql select count(*) from ct1
print rows: $rows
print $data00 $data01 $data02 $data03
if $rows != 1 then
if $rows != 1 then
return -1
return -1
endi
endi
if $data00 != 4 then
print $data00 $data01 $data02
if $data00 != 7 then
return -1
return -1
endi
endi
print =============== select count(column) from child table
print =============== select count(column) from child table
sql select count(ts), count(c1), count(c2), count(c3) from ct1
sql select count(ts), count(c1), count(c2), count(c3) from ct1
print rows: $rows
print $data00 $data01 $data02 $data03
print $data00 $data01 $data02 $data03
if $data00 !=
7
then
if $data00 !=
4
then
return -1
return -1
endi
endi
if $data01 !=
7
then
if $data01 !=
4
then
return -1
return -1
endi
endi
if $data02 !=
7
then
if $data02 !=
4
then
return -1
return -1
endi
endi
if $data03 !=
7
then
if $data03 !=
4
then
return -1
return -1
endi
endi
...
@@ -295,17 +321,18 @@ endi
...
@@ -295,17 +321,18 @@ endi
print =============== select min(column) from child table
print =============== select min(column) from child table
sql select min(c1), min(c2), min(c3) from ct1
sql select min(c1), min(c2), min(c3) from ct1
print rows: $rows
print $data00 $data01 $data02 $data03
print $data00 $data01 $data02 $data03
if $rows != 1 then
if $rows != 1 then
return -1
return -1
endi
endi
if $data00 != -1
6
then
if $data00 != -1
3
then
return -1
return -1
endi
endi
if $data01 != -2.
6
0000 then
if $data01 != -2.
3
0000 then
return -1
return -1
endi
endi
if $data02 != -3.
6
00000000 then
if $data02 != -3.
3
00000000 then
return -1
return -1
endi
endi
...
@@ -315,13 +342,13 @@ print $data00 $data01 $data02 $data03
...
@@ -315,13 +342,13 @@ print $data00 $data01 $data02 $data03
if $rows != 1 then
if $rows != 1 then
return -1
return -1
endi
endi
if $data00 != 1
3
then
if $data00 != 1
1
then
return -1
return -1
endi
endi
if $data01 != 2.
3
0000 then
if $data01 != 2.
1
0000 then
return -1
return -1
endi
endi
if $data02 != 3.
3
00000000 then
if $data02 != 3.
1
00000000 then
return -1
return -1
endi
endi
...
@@ -331,14 +358,87 @@ print $data00 $data01 $data02 $data03
...
@@ -331,14 +358,87 @@ print $data00 $data01 $data02 $data03
if $rows != 1 then
if $rows != 1 then
return -1
return -1
endi
endi
if $data00 != 1 then
if $data00 != -4 then
return -1
endi
if $data01 != -0.400000095 then
return -1
endi
if $data02 != -0.400000000 then
return -1
endi
print =============== select column without timestamp, from child table
sql select c1, c2, c3 from ct1
print rows: $rows
print $data00 $data01 $data02
print $data10 $data11 $data12
print $data20 $data21 $data22
print $data30 $data31 $data32
if $rows != 4 then
return -1
return -1
endi
endi
if $data0
1 != 1.099999905
then
if $data0
0 != 10
then
return -1
return -1
endi
endi
if $data0
2 != 2.1000
00000 then
if $data0
1 != 2.
00000 then
return -1
return -1
endi
endi
if $data02 != 3.000000000 then
return -1
endi
if $data10 != 11 then
return -1
endi
if $data11 != 2.10000 then
return -1
endi
if $data12 != 3.100000000 then
return -1
endi
if $data30 != -13 then
return -1
endi
if $data31 != -2.30000 then
return -1
endi
if $data32 != -3.300000000 then
return -1
endi
#===================================================================
#===================================================================
#print =============== query data from stb
#sql select * from stb
#if $rows != 4 then
# return -1
#endi
#print =============== select count(*) from supter table
#sql select count(*) from stb
#print $data00 $data01 $data02
#if $rows != 1 then
# return -1
#endi
#if $data00 != 9 then
# return -1
#endi
#print =============== select count(column) from supter table
#sql select count(ts), count(c1), count(c2), count(c3) from stb
#print $data00 $data01 $data02 $data03
#if $data00 != 8 then
# return -1
#endi
#if $data01 != 8 then
# return -1
#endi
#if $data02 != 8 then
# return -1
#endi
#if $data03 != 8 then
# return -1
#endi
#system sh/exec.sh -n dnode1 -s stop -x SIGINT
#system sh/exec.sh -n dnode1 -s stop -x SIGINT
tests/script/tsim/insert/null.sim
浏览文件 @
4e8ebdef
...
@@ -7,7 +7,7 @@ sql connect
...
@@ -7,7 +7,7 @@ sql connect
print =============== create database
print =============== create database
sql create database d0
sql create database d0
sql show databases
sql show databases
if $rows !=
1
then
if $rows !=
2
then
return -1
return -1
endi
endi
...
@@ -40,7 +40,7 @@ sql insert into ct1 values (now+7s, 14, NULL, 3.5, 95)
...
@@ -40,7 +40,7 @@ sql insert into ct1 values (now+7s, 14, NULL, 3.5, 95)
sql insert into ct1 values (now+8s, 15, 2.5, NULL, 96)
sql insert into ct1 values (now+8s, 15, 2.5, NULL, 96)
sql insert into ct1 values (now+9s, 16, 2.6, 3.6, NULL)
sql insert into ct1 values (now+9s, 16, 2.6, 3.6, NULL)
sql insert into ct1 values (now+10s, NULL, NULL, NULL, NULL)
sql insert into ct1 values (now+10s, NULL, NULL, NULL, NULL)
sql insert into ct1 values (now+11s, -214748364
8
, 2.7, 3.7, 97)
sql insert into ct1 values (now+11s, -214748364
7
, 2.7, 3.7, 97)
#===================================================================
#===================================================================
#===================================================================
#===================================================================
...
@@ -75,7 +75,6 @@ endi
...
@@ -75,7 +75,6 @@ endi
# return -1
# return -1
#endi
#endi
print =============== select count(*) from child table
print =============== select count(*) from child table
sql select count(*) from ct1
sql select count(*) from ct1
print ===> select count(*) from ct1
print ===> select count(*) from ct1
...
@@ -84,9 +83,7 @@ print ===> rows0: $data00 $data01 $data02 $data03 $data04
...
@@ -84,9 +83,7 @@ print ===> rows0: $data00 $data01 $data02 $data03 $data04
if $rows != 1 then
if $rows != 1 then
return -1
return -1
endi
endi
if $data00 != 12 then
print $data00 $data01 $data02
if $data00 != 4 then
return -1
return -1
endi
endi
...
@@ -95,17 +92,16 @@ sql select count(ts), count(c1), count(c2), count(c3) from ct1
...
@@ -95,17 +92,16 @@ sql select count(ts), count(c1), count(c2), count(c3) from ct1
print ===> select count(ts), count(c1), count(c2), count(c3) from ct1
print ===> select count(ts), count(c1), count(c2), count(c3) from ct1
print ===> rows: $rows
print ===> rows: $rows
print ===> rows0: $data00 $data01 $data02 $data03 $data04
print ===> rows0: $data00 $data01 $data02 $data03 $data04
if $data00 != 12 then
if $data00 != 4 then
return -1
return -1
endi
endi
if $data01 !=
4
then
if $data01 !=
8
then
return -1
return -1
endi
endi
if $data02 !=
4
then
if $data02 !=
8
then
return -1
return -1
endi
endi
if $data03 !=
4
then
if $data03 !=
8
then
return -1
return -1
endi
endi
...
@@ -121,7 +117,7 @@ print ===> rows0: $data00 $data01 $data02 $data03 $data04
...
@@ -121,7 +117,7 @@ print ===> rows0: $data00 $data01 $data02 $data03 $data04
if $rows != 1 then
if $rows != 1 then
return -1
return -1
endi
endi
if $data00 !=
10
then
if $data00 !=
-2147483647
then
return -1
return -1
endi
endi
if $data01 != 2.00000 then
if $data01 != 2.00000 then
...
@@ -139,13 +135,13 @@ print ===> rows0: $data00 $data01 $data02 $data03 $data04
...
@@ -139,13 +135,13 @@ print ===> rows0: $data00 $data01 $data02 $data03 $data04
if $rows != 1 then
if $rows != 1 then
return -1
return -1
endi
endi
if $data00 != 1
3
then
if $data00 != 1
6
then
return -1
return -1
endi
endi
if $data01 != 2.
3
0000 then
if $data01 != 2.
7
0000 then
return -1
return -1
endi
endi
if $data02 != 3.
3
00000000 then
if $data02 != 3.
7
00000000 then
return -1
return -1
endi
endi
...
@@ -157,13 +153,13 @@ print ===> rows0: $data00 $data01 $data02 $data03 $data04
...
@@ -157,13 +153,13 @@ print ===> rows0: $data00 $data01 $data02 $data03 $data04
if $rows != 1 then
if $rows != 1 then
return -1
return -1
endi
endi
if $data00 !=
46
then
if $data00 !=
-2147483556
then
return -1
return -1
endi
endi
if $data01 !=
8.599999905
then
if $data01 !=
18.799999952
then
return -1
return -1
endi
endi
if $data02 !=
12.6
00000000 then
if $data02 !=
26.8
00000000 then
return -1
return -1
endi
endi
...
@@ -172,42 +168,48 @@ sql select c1, c2, c3 from ct1
...
@@ -172,42 +168,48 @@ sql select c1, c2, c3 from ct1
print ===> select c1, c2, c3 from ct1
print ===> select c1, c2, c3 from ct1
print ===> rows: $rows
print ===> rows: $rows
print ===> rows0: $data00 $data01 $data02 $data03 $data04
print ===> rows0: $data00 $data01 $data02 $data03 $data04
#if $rows != 4 then
if $rows != 12 then
# return -1
return -1
#endi
endi
#if $data00 != 10 then
if $data00 != 10 then
# return -1
return -1
#endi
endi
#if $data01 != 2.00000 then
if $data01 != 2.00000 then
# return -1
return -1
#endi
endi
#if $data02 != 3.000000000 then
if $data02 != 3.000000000 then
# return -1
return -1
#endi
endi
#if $data10 != 11 then
if $data10 != NULL then
# return -1
return -1
#endi
endi
#if $data11 != 2.10000 then
if $data11 != NULL then
# return -1
return -1
#endi
endi
#if $data12 != 3.100000000 then
if $data12 != NULL then
# return -1
return -1
#endi
endi
#if $data30 != 13 then
if $data30 != 11 then
# return -1
return -1
#endi
endi
#if $data31 != 2.30000 then
if $data31 != NULL then
# return -1
return -1
#endi
endi
#if $data32 != 3.300000000 then
if $data32 != 3.200000000 then
# return -1
return -1
#endi
endi
if $data90 != 16 then
return -1
endi
if $data91 != 2.60000 then
return -1
endi
if $data92 != 3.600000000 then
return -1
endi
#===================================================================
#===================================================================
#===================================================================
#===================================================================
return
#print =============== query data from stb
#print =============== query data from stb
#sql select * from stb
#sql select * from stb
#print ===>
#print ===>
...
@@ -218,19 +220,18 @@ return
...
@@ -218,19 +220,18 @@ return
#endi
#endi
#print =============== select count(*) from supter table
#print =============== select count(*) from supter table
#sql select count(*) from stb
#sql select count(*) from stb
#print $data00 $data01 $data02
#if $rows != 1 then
#if $rows != 1 then
# return -1
# return -1
#endi
#endi
#
#if $data00 != 12 then
#print $data00 $data01 $data02
#if $data00 != 8 then
# return -1
# return -1
#endi
#endi
#
#print =============== select count(column) from supter table
#print =============== select count(column) from supter table
#sql select count(ts), count(c1), count(c2), count(c3) from stb
#sql select count(ts), count(c1), count(c2), count(c3) from stb
#print $data00 $data01 $data02 $data03
#print $data00 $data01 $data02 $data03
#if $data00 !=
8
then
#if $data00 !=
12
then
# return -1
# return -1
#endi
#endi
#if $data01 != 8 then
#if $data01 != 8 then
...
@@ -243,6 +244,7 @@ return
...
@@ -243,6 +244,7 @@ return
# return -1
# return -1
#endi
#endi
return
#===================================================================
#===================================================================
#===================================================================
#===================================================================
...
@@ -251,9 +253,36 @@ print =============== stop and restart taosd, then again do query above
...
@@ -251,9 +253,36 @@ print =============== stop and restart taosd, then again do query above
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode1 -s start
system sh/exec.sh -n dnode1 -s start
sleep 2000
print ===> waiting dnode ready
$loop_cnt = 0
check_dnode_ready:
$loop_cnt = $loop_cnt + 1
sleep 200
if $loop_cnt == 10 then
print ====> dnode not ready!
return -1
endi
sql show dnodes
print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05
if $data00 != 1 then
return -1
endi
if $data04 != ready then
goto check_dnode_ready
endi
#===================================================================
#===================================================================
print =============== query data from child table
sql select * from ct1
sql select * from ct1
if $rows != 4 then # after fix bug, modify 4 to 7
print ===> select * from ct1
print ===> rows: $rows
print ===> rows0: $data00 $data01 $data02 $data03 $data04
print ===> rows1: $data10 $data11 $data12 $data13 $data14
print ===> rows2: $data20 $data21 $data22 $data23 $data24
print ===> rows3: $data30 $data31 $data32 $data33 $data34
print ===> rows4: $data40 $data41 $data42 $data43 $data44
if $rows != 12 then
return -1
return -1
endi
endi
if $data01 != 10 then
if $data01 != 10 then
...
@@ -275,31 +304,33 @@ endi
...
@@ -275,31 +304,33 @@ endi
# return -1
# return -1
#endi
#endi
print =============== select count(*) from child table
print =============== select count(*) from child table
sql select count(*) from ct1
sql select count(*) from ct1
print ===> select count(*) from ct1
print ===> rows: $rows
print ===> rows0: $data00 $data01 $data02 $data03 $data04
if $rows != 1 then
if $rows != 1 then
return -1
return -1
endi
endi
if $data00 != 12 then
print $data00 $data01 $data02
if $data00 != 4 then
return -1
return -1
endi
endi
print =============== select count(column) from child table
print =============== select count(column) from child table
sql select count(ts), count(c1), count(c2), count(c3) from ct1
sql select count(ts), count(c1), count(c2), count(c3) from ct1
print $data00 $data01 $data02 $data03
print ===> select count(ts), count(c1), count(c2), count(c3) from ct1
if $data00 != 4 then
print ===> rows: $rows
print ===> rows0: $data00 $data01 $data02 $data03 $data04
if $data00 != 12 then
return -1
return -1
endi
endi
if $data01 !=
4
then
if $data01 !=
8
then
return -1
return -1
endi
endi
if $data02 !=
4
then
if $data02 !=
8
then
return -1
return -1
endi
endi
if $data03 !=
4
then
if $data03 !=
8
then
return -1
return -1
endi
endi
...
@@ -309,11 +340,13 @@ endi
...
@@ -309,11 +340,13 @@ endi
print =============== select min(column) from child table
print =============== select min(column) from child table
sql select min(c1), min(c2), min(c3) from ct1
sql select min(c1), min(c2), min(c3) from ct1
print $data00 $data01 $data02 $data03
print ===> select min(c1), min(c2), min(c3) from ct1
print ===> rows: $rows
print ===> rows0: $data00 $data01 $data02 $data03 $data04
if $rows != 1 then
if $rows != 1 then
return -1
return -1
endi
endi
if $data00 !=
10
then
if $data00 !=
-2147483647
then
return -1
return -1
endi
endi
if $data01 != 2.00000 then
if $data01 != 2.00000 then
...
@@ -325,34 +358,119 @@ endi
...
@@ -325,34 +358,119 @@ endi
print =============== select max(column) from child table
print =============== select max(column) from child table
sql select max(c1), max(c2), max(c3) from ct1
sql select max(c1), max(c2), max(c3) from ct1
print $data00 $data01 $data02 $data03
print ===> select max(c1), max(c2), max(c3) from ct1
print ===> rows: $rows
print ===> rows0: $data00 $data01 $data02 $data03 $data04
if $rows != 1 then
if $rows != 1 then
return -1
return -1
endi
endi
if $data00 != 1
3
then
if $data00 != 1
6
then
return -1
return -1
endi
endi
if $data01 != 2.
3
0000 then
if $data01 != 2.
7
0000 then
return -1
return -1
endi
endi
if $data02 != 3.
3
00000000 then
if $data02 != 3.
7
00000000 then
return -1
return -1
endi
endi
print =============== select sum(column) from child table
print =============== select sum(column) from child table
sql select sum(c1), sum(c2), sum(c3) from ct1
sql select sum(c1), sum(c2), sum(c3) from ct1
print $data00 $data01 $data02 $data03
print ===> select sum(c1), sum(c2), sum(c3) from ct1
print ===> rows: $rows
print ===> rows0: $data00 $data01 $data02 $data03 $data04
if $rows != 1 then
if $rows != 1 then
return -1
return -1
endi
endi
if $data00 != 46 then
if $data00 != -2147483556 then
return -1
endi
if $data01 != 18.799999952 then
return -1
endi
if $data02 != 26.800000000 then
return -1
endi
print =============== select column, from child table
sql select c1, c2, c3 from ct1
print ===> select c1, c2, c3 from ct1
print ===> rows: $rows
print ===> rows0: $data00 $data01 $data02 $data03 $data04
if $rows != 12 then
return -1
endi
if $data00 != 10 then
return -1
endi
if $data01 != 2.00000 then
return -1
endi
if $data02 != 3.000000000 then
return -1
endi
if $data10 != NULL then
return -1
endi
if $data11 != NULL then
return -1
endi
if $data12 != NULL then
return -1
return -1
endi
endi
if $data
01 != 8.599999905
then
if $data
30 != 11
then
return -1
return -1
endi
endi
if $data
02 != 12.600000000
then
if $data
31 != NULL
then
return -1
return -1
endi
endi
if $data32 != 3.200000000 then
return -1
endi
if $data90 != 16 then
return -1
endi
if $data91 != 2.60000 then
return -1
endi
if $data92 != 3.600000000 then
return -1
endi
#===================================================================
#===================================================================
#print =============== query data from stb
#sql select * from stb
#print ===>
#print ===> rows: $rows
#print ===> rows0: $data00 $data01 $data02 $data03 $data04
#if $rows != 4 then
# return -1
#endi
#print =============== select count(*) from supter table
#sql select count(*) from stb
#print $data00 $data01 $data02
#if $rows != 1 then
# return -1
#endi
#if $data00 != 12 then
# return -1
#endi
#print =============== select count(column) from supter table
#sql select count(ts), count(c1), count(c2), count(c3) from stb
#print $data00 $data01 $data02 $data03
#if $data00 != 12 then
# return -1
#endi
#if $data01 != 8 then
# return -1
#endi
#if $data02 != 8 then
# return -1
#endi
#if $data03 != 8 then
# return -1
#endi
#system sh/exec.sh -n dnode1 -s stop -x SIGINT
#system sh/exec.sh -n dnode1 -s stop -x SIGINT
tests/script/tsim/query/interval-offset.sim
浏览文件 @
4e8ebdef
tests/script/tsim/table/basic1.sim
浏览文件 @
4e8ebdef
...
@@ -3,10 +3,33 @@ system sh/deploy.sh -n dnode1 -i 1
...
@@ -3,10 +3,33 @@ system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
system sh/exec.sh -n dnode1 -s start
sql connect
sql connect
#=========== TD-14042 start
sql create database db1;
sql create database db2;
sql create database db3;
sql use db1;
sql create table st1 (ts timestamp, i int) tags (j int);
sql create table tb1 using st1 tags(1);
sql use db2;
sql create table st2 (ts timestamp, i int) tags (j int);
sql create table tb2 using st2 tags(1);
sql use db3;
sql create table st3 (ts timestamp, i int) tags (j int);
sql create table tb3 using st3 tags(1);
sql show tables
if $rows != 1 then
return -1
endi
#=========== TD-14042 end
print =============== create database
print =============== create database
sql create database d1
sql create database d1
sql show databases
sql show databases
if $rows !=
2
then
if $rows !=
5
then
return -1
return -1
endi
endi
...
@@ -186,10 +209,26 @@ if $rows != 21 then
...
@@ -186,10 +209,26 @@ if $rows != 21 then
return -1
return -1
endi
endi
#system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode1 -s stop -x SIGINT
#system sh/exec.sh -n dnode1 -s start
system sh/exec.sh -n dnode1 -s start
$loop_cnt = 0
check_dnode_ready:
$loop_cnt = $loop_cnt + 1
sleep 200
if $loop_cnt == 10 then
print ====> dnode not ready!
return -1
endi
sql show dnodes
print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05
if $data00 != 1 then
return -1
endi
if $data04 != ready then
goto check_dnode_ready
endi
sleep 2000
print =============== query data
print =============== query data
sql select * from c1
sql select * from c1
if $rows != 3 then
if $rows != 3 then
...
...
tests/script/tsim/testCaseSuite.sim
浏览文件 @
4e8ebdef
run tsim/user/basic1.sim
run tsim/db/basic1.sim
run tsim/db/basic1.sim
run tsim/db/basic6.sim
run tsim/db/basic6.sim
run tsim/db/basic7.sim
run tsim/db/basic7.sim
...
@@ -7,12 +9,14 @@ run tsim/db/error1.sim
...
@@ -7,12 +9,14 @@ run tsim/db/error1.sim
run tsim/dnode/basic1.sim
run tsim/dnode/basic1.sim
run tsim/insert/basic0.sim
run tsim/insert/basic0.sim
run tsim/insert/basic1.sim
#run tsim/insert/basic1.sim # TD-14246
run tsim/insert/null.sim
#run tsim/insert/backquote.sim # TD-14261
#run tsim/insert/null.sim
run tsim/query/interval-offset.sim
run tsim/query/interval.sim
run tsim/query/interval.sim
#run tsim/query/interval-offset.sim # TD-14266
run tsim/table/basic1.sim
run tsim/table/basic1.sim
run tsim/user/basic1.sim
run tsim/tmq/basic.sim
tools/CMakeLists.txt
浏览文件 @
4e8ebdef
...
@@ -4,6 +4,7 @@ IF (TD_TAOS_TOOLS)
...
@@ -4,6 +4,7 @@ IF (TD_TAOS_TOOLS)
INCLUDE_DIRECTORIES
(
${
CMAKE_SOURCE_DIR
}
/include/common
)
INCLUDE_DIRECTORIES
(
${
CMAKE_SOURCE_DIR
}
/include/common
)
INCLUDE_DIRECTORIES
(
${
CMAKE_SOURCE_DIR
}
/include/util
)
INCLUDE_DIRECTORIES
(
${
CMAKE_SOURCE_DIR
}
/include/util
)
INCLUDE_DIRECTORIES
(
${
CMAKE_SOURCE_DIR
}
/include/os
)
INCLUDE_DIRECTORIES
(
${
CMAKE_SOURCE_DIR
}
/include/os
)
INCLUDE_DIRECTORIES
(
${
CMAKE_SOURCE_DIR
}
/include/libs/transport
)
ADD_SUBDIRECTORY
(
taos-tools
)
ADD_SUBDIRECTORY
(
taos-tools
)
ENDIF
()
ENDIF
()
...
...
tools/shell/CMakeLists.txt
浏览文件 @
4e8ebdef
...
@@ -4,9 +4,7 @@ add_executable(shell ${SHELL_SRC})
...
@@ -4,9 +4,7 @@ add_executable(shell ${SHELL_SRC})
target_link_libraries
(
target_link_libraries
(
shell
shell
PUBLIC taos
PUBLIC taos
PUBLIC util
PRIVATE os common transport util
PUBLIC common
PUBLIC os
)
)
target_include_directories
(
target_include_directories
(
shell
shell
...
...
tools/shell/inc/syncMsg.h
0 → 100644
浏览文件 @
4e8ebdef
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TDENGINE_SYNC_MSG_H
#define TDENGINE_SYNC_MSG_H
#ifdef __cplusplus
extern
"C"
{
#endif
#include "tsync.h"
typedef
enum
{
TAOS_SMSG_START
=
0
,
TAOS_SMSG_SYNC_DATA
=
1
,
TAOS_SMSG_SYNC_DATA_RSP
=
2
,
TAOS_SMSG_SYNC_FWD
=
3
,
TAOS_SMSG_SYNC_FWD_RSP
=
4
,
TAOS_SMSG_SYNC_REQ
=
5
,
TAOS_SMSG_SYNC_REQ_RSP
=
6
,
TAOS_SMSG_SYNC_MUST
=
7
,
TAOS_SMSG_SYNC_MUST_RSP
=
8
,
TAOS_SMSG_STATUS
=
9
,
TAOS_SMSG_STATUS_RSP
=
10
,
TAOS_SMSG_SETUP
=
11
,
TAOS_SMSG_SETUP_RSP
=
12
,
TAOS_SMSG_SYNC_FILE
=
13
,
TAOS_SMSG_SYNC_FILE_RSP
=
14
,
TAOS_SMSG_TEST
=
15
,
TAOS_SMSG_END
=
16
}
ESyncMsgType
;
typedef
enum
{
SYNC_STATUS_BROADCAST
,
SYNC_STATUS_BROADCAST_RSP
,
SYNC_STATUS_SETUP_CONN
,
SYNC_STATUS_SETUP_CONN_RSP
,
SYNC_STATUS_EXCHANGE_DATA
,
SYNC_STATUS_EXCHANGE_DATA_RSP
,
SYNC_STATUS_CHECK_ROLE
,
SYNC_STATUS_CHECK_ROLE_RSP
}
ESyncStatusType
;
#pragma pack(push, 1)
typedef
struct
{
int8_t
type
;
// msg type
int8_t
protocol
;
// protocol version
uint16_t
signature
;
// fixed value
int32_t
code
;
//
int32_t
cId
;
// cluster Id
int32_t
vgId
;
// vg ID
int32_t
len
;
// content length, does not include head
uint32_t
cksum
;
}
SSyncHead
;
typedef
struct
{
SSyncHead
head
;
uint16_t
port
;
uint16_t
tranId
;
int32_t
sourceId
;
// only for arbitrator
char
fqdn
[
TSDB_FQDN_LEN
];
}
SSyncMsg
;
typedef
struct
{
SSyncHead
head
;
int8_t
sync
;
int8_t
reserved
;
uint16_t
tranId
;
int8_t
reserverd
[
4
];
}
SSyncRsp
;
typedef
struct
{
int8_t
role
;
uint64_t
version
;
}
SPeerStatus
;
typedef
struct
{
SSyncHead
head
;
int8_t
role
;
int8_t
ack
;
int8_t
type
;
int8_t
reserved
[
3
];
uint16_t
tranId
;
uint64_t
version
;
SPeerStatus
peersStatus
[
TAOS_SYNC_MAX_REPLICA
];
}
SPeersStatus
;
typedef
struct
{
SSyncHead
head
;
uint64_t
fversion
;
}
SFileVersion
;
typedef
struct
{
SSyncHead
head
;
int8_t
ack
;
}
SFileAck
;
typedef
struct
{
SSyncHead
head
;
uint64_t
version
;
int32_t
code
;
}
SFwdRsp
;
#pragma pack(pop)
#define SYNC_PROTOCOL_VERSION 1
#define SYNC_SIGNATURE ((uint16_t)(0xCDEF))
extern
char
*
statusType
[];
uint16_t
syncGenTranId
();
int32_t
syncCheckHead
(
SSyncHead
*
pHead
);
void
syncBuildSyncFwdMsg
(
SSyncHead
*
pHead
,
int32_t
vgId
,
int32_t
len
);
void
syncBuildSyncFwdRsp
(
SFwdRsp
*
pMsg
,
int32_t
vgId
,
uint64_t
version
,
int32_t
code
);
void
syncBuildSyncReqMsg
(
SSyncMsg
*
pMsg
,
int32_t
vgId
);
void
syncBuildSyncDataMsg
(
SSyncMsg
*
pMsg
,
int32_t
vgId
);
void
syncBuildSyncSetupMsg
(
SSyncMsg
*
pMsg
,
int32_t
vgId
);
void
syncBuildPeersStatus
(
SPeersStatus
*
pMsg
,
int32_t
vgId
);
void
syncBuildSyncTestMsg
(
SSyncMsg
*
pMsg
,
int32_t
vgId
);
void
syncBuildFileAck
(
SFileAck
*
pMsg
,
int32_t
vgId
);
void
syncBuildFileVersion
(
SFileVersion
*
pMsg
,
int32_t
vgId
);
#ifdef __cplusplus
}
#endif
#endif // TDENGINE_VNODEPEER_H
tools/shell/inc/tsync.h
0 → 100644
浏览文件 @
4e8ebdef
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TDENGINE_SYNC_H
#define TDENGINE_SYNC_H
#ifdef __cplusplus
extern
"C"
{
#endif
#define TAOS_SYNC_MAX_REPLICA 5
#define TAOS_SYNC_MAX_INDEX 0x7FFFFFFF
typedef
enum
{
TAOS_SYNC_ROLE_OFFLINE
=
0
,
TAOS_SYNC_ROLE_UNSYNCED
=
1
,
TAOS_SYNC_ROLE_SYNCING
=
2
,
TAOS_SYNC_ROLE_SLAVE
=
3
,
TAOS_SYNC_ROLE_MASTER
=
4
}
ESyncRole
;
typedef
enum
{
TAOS_SYNC_STATUS_INIT
=
0
,
TAOS_SYNC_STATUS_START
=
1
,
TAOS_SYNC_STATUS_FILE
=
2
,
TAOS_SYNC_STATUS_CACHE
=
3
}
ESyncStatus
;
typedef
struct
{
uint32_t
nodeId
;
// node ID assigned by TDengine
uint16_t
nodePort
;
// node sync Port
char
nodeFqdn
[
TSDB_FQDN_LEN
];
// node FQDN
}
SNodeInfo
;
typedef
struct
{
int8_t
quorum
;
// number of confirms required, >=1
int8_t
replica
;
// number of replications, >=1
SNodeInfo
nodeInfo
[
TAOS_SYNC_MAX_REPLICA
];
}
SSyncCfg
;
typedef
struct
{
int32_t
selfIndex
;
uint32_t
nodeId
[
TAOS_SYNC_MAX_REPLICA
];
int32_t
role
[
TAOS_SYNC_MAX_REPLICA
];
}
SNodesRole
;
// get the wal file from index or after
// return value, -1: error, 1:more wal files, 0:last WAL. if name[0]==0, no WAL file
typedef
int32_t
(
*
FGetWalInfo
)(
int32_t
vgId
,
char
*
fileName
,
int64_t
*
fileId
);
// when a forward pkt is received, call this to handle data
typedef
int32_t
(
*
FWriteToCache
)(
int32_t
vgId
,
void
*
pHead
,
int32_t
qtype
,
void
*
pMsg
);
// when forward is confirmed by peer, master call this API to notify app
typedef
void
(
*
FConfirmForward
)(
int32_t
vgId
,
void
*
mhandle
,
int32_t
code
);
// when role is changed, call this to notify app
typedef
void
(
*
FNotifyRole
)(
int32_t
vgId
,
int8_t
role
);
// if a number of retrieving data failed, call this to start flow control
typedef
void
(
*
FNotifyFlowCtrl
)(
int32_t
vgId
,
int32_t
level
);
// when data file is synced successfully, notity app
typedef
void
(
*
FStartSyncFile
)(
int32_t
vgId
);
typedef
void
(
*
FStopSyncFile
)(
int32_t
vgId
,
uint64_t
fversion
);
// get file version
typedef
int32_t
(
*
FGetVersion
)(
int32_t
vgId
,
uint64_t
*
fver
,
uint64_t
*
vver
);
typedef
int32_t
(
*
FSendFile
)(
void
*
tsdb
,
SOCKET
socketFd
);
typedef
int32_t
(
*
FRecvFile
)(
void
*
tsdb
,
SOCKET
socketFd
);
typedef
struct
{
int32_t
vgId
;
// vgroup ID
uint64_t
version
;
// initial version
SSyncCfg
syncCfg
;
// configuration from mgmt
char
path
[
TSDB_FILENAME_LEN
];
// path to the file
void
*
pTsdb
;
FGetWalInfo
getWalInfoFp
;
FWriteToCache
writeToCacheFp
;
FConfirmForward
confirmForward
;
FNotifyRole
notifyRoleFp
;
FNotifyFlowCtrl
notifyFlowCtrlFp
;
FStartSyncFile
startSyncFileFp
;
FStopSyncFile
stopSyncFileFp
;
FGetVersion
getVersionFp
;
FSendFile
sendFileFp
;
FRecvFile
recvFileFp
;
}
SSyncInfo
;
typedef
void
*
tsync_h
;
int32_t
syncInit
();
void
syncCleanUp
();
int64_t
syncStart
(
const
SSyncInfo
*
);
void
syncStop
(
int64_t
rid
);
int32_t
syncReconfig
(
int64_t
rid
,
const
SSyncCfg
*
);
int32_t
syncForwardToPeer
(
int64_t
rid
,
void
*
pHead
,
void
*
mhandle
,
int32_t
qtype
,
bool
force
);
void
syncConfirmForward
(
int64_t
rid
,
uint64_t
version
,
int32_t
code
,
bool
force
);
void
syncRecover
(
int64_t
rid
);
// recover from other nodes:
int32_t
syncGetNodesRole
(
int64_t
rid
,
SNodesRole
*
);
extern
char
*
syncRole
[];
//global configurable parameters
extern
int32_t
sDebugFlag
;
extern
char
tsArbitrator
[];
extern
uint16_t
tsSyncPort
;
#ifdef __cplusplus
}
#endif
#endif // TDENGINE_SYNC_H
tools/shell/src/shellMain.c
浏览文件 @
4e8ebdef
...
@@ -32,6 +32,8 @@
...
@@ -32,6 +32,8 @@
int
indicator
=
1
;
int
indicator
=
1
;
void
insertChar
(
Command
*
cmd
,
char
*
c
,
int
size
);
void
insertChar
(
Command
*
cmd
,
char
*
c
,
int
size
);
void
taosNetTest
(
char
*
role
,
char
*
host
,
int32_t
port
,
int32_t
pkgLen
,
int32_t
pkgNum
,
char
*
pkgType
);
const
char
*
argp_program_version
=
version
;
const
char
*
argp_program_version
=
version
;
const
char
*
argp_program_bug_address
=
"<support@taosdata.com>"
;
const
char
*
argp_program_bug_address
=
"<support@taosdata.com>"
;
static
char
doc
[]
=
""
;
static
char
doc
[]
=
""
;
...
@@ -59,7 +61,8 @@ static struct argp_option options[] = {
...
@@ -59,7 +61,8 @@ static struct argp_option options[] = {
{
"netrole"
,
'n'
,
"NETROLE"
,
0
,
"Net role when network connectivity test, default is startup, options: client|server|rpc|startup|sync|speen|fqdn."
},
{
"netrole"
,
'n'
,
"NETROLE"
,
0
,
"Net role when network connectivity test, default is startup, options: client|server|rpc|startup|sync|speen|fqdn."
},
{
"pktlen"
,
'l'
,
"PKTLEN"
,
0
,
"Packet length used for net test, default is 1000 bytes."
},
{
"pktlen"
,
'l'
,
"PKTLEN"
,
0
,
"Packet length used for net test, default is 1000 bytes."
},
{
"pktnum"
,
'N'
,
"PKTNUM"
,
0
,
"Packet numbers used for net test, default is 100."
},
{
"pktnum"
,
'N'
,
"PKTNUM"
,
0
,
"Packet numbers used for net test, default is 100."
},
{
"pkttype"
,
'S'
,
"PKTTYPE"
,
0
,
"Packet type used for net test, default is TCP."
},
// Shuduo: 3.0 does not support UDP any more
// {"pkttype", 'S', "PKTTYPE", 0, "Packet type used for net test, default is TCP."},
{
0
}};
{
0
}};
static
error_t
parse_opt
(
int
key
,
char
*
arg
,
struct
argp_state
*
state
)
{
static
error_t
parse_opt
(
int
key
,
char
*
arg
,
struct
argp_state
*
state
)
{
...
@@ -629,16 +632,25 @@ int main(int argc, char *argv[]) {
...
@@ -629,16 +632,25 @@ int main(int argc, char *argv[]) {
taosDumpGlobalCfg();
taosDumpGlobalCfg();
exit(0);
exit(0);
}
}
#endif
if
(
args
.
netTestRole
&&
args
.
netTestRole
[
0
]
!=
0
)
{
if
(
args
.
netTestRole
&&
args
.
netTestRole
[
0
]
!=
0
)
{
if (taos_init()) {
TAOS
*
con
=
NULL
;
if
(
args
.
auth
==
NULL
)
{
con
=
taos_connect
(
args
.
host
,
args
.
user
,
args
.
password
,
args
.
database
,
args
.
port
);
}
else
{
con
=
taos_connect_auth
(
args
.
host
,
args
.
user
,
args
.
auth
,
args
.
database
,
args
.
port
);
}
/* if (taos_init()) {
printf("Failed to init taos");
printf("Failed to init taos");
exit(EXIT_FAILURE);
exit(EXIT_FAILURE);
}
}
*/
taosNetTest
(
args
.
netTestRole
,
args
.
host
,
args
.
port
,
args
.
pktLen
,
args
.
pktNum
,
args
.
pktType
);
taosNetTest
(
args
.
netTestRole
,
args
.
host
,
args
.
port
,
args
.
pktLen
,
args
.
pktNum
,
args
.
pktType
);
taos_close
(
con
);
exit
(
0
);
exit
(
0
);
}
}
#endif
/* Initialize the shell */
/* Initialize the shell */
TAOS
*
con
=
shellInit
(
&
args
);
TAOS
*
con
=
shellInit
(
&
args
);
...
...
tools/shell/src/
backup/
tnettest.c
→
tools/shell/src/tnettest.c
浏览文件 @
4e8ebdef
...
@@ -14,18 +14,20 @@
...
@@ -14,18 +14,20 @@
*/
*/
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#define ALLOW_FORBID_FUNC
#include "os.h"
#include "os.h"
#include "taosdef.h"
#include "taosdef.h"
#include "tmsg.h"
#include "tmsg.h"
#include "taoserror.h"
#include "taoserror.h"
#include "tlog.h"
#include "tlog.h"
#include "tglobal.h"
#include "tglobal.h"
#include "tsocket.h"
#include "trpc.h"
#include "trpc.h"
#include "rpcHead.h"
#include "rpcHead.h"
#include "tchecksum.h"
#include "tchecksum.h"
#include "syncMsg.h"
#include "syncMsg.h"
#include "osSocket.h"
#define MAX_PKG_LEN (64 * 1000)
#define MAX_PKG_LEN (64 * 1000)
#define MAX_SPEED_PKG_LEN (1024 * 1024 * 1024)
#define MAX_SPEED_PKG_LEN (1024 * 1024 * 1024)
#define MIN_SPEED_PKG_LEN 1024
#define MIN_SPEED_PKG_LEN 1024
...
@@ -33,7 +35,7 @@
...
@@ -33,7 +35,7 @@
#define MIN_SPEED_PKG_NUM 1
#define MIN_SPEED_PKG_NUM 1
#define BUFFER_SIZE (MAX_PKG_LEN + 1024)
#define BUFFER_SIZE (MAX_PKG_LEN + 1024)
extern
int
32_t
tsRpcMaxUdpSize
;
extern
int
tsRpcMaxUdpSize
;
typedef
struct
{
typedef
struct
{
char
*
hostFqdn
;
char
*
hostFqdn
;
...
@@ -71,15 +73,23 @@ static void *taosNetBindUdpPort(void *sarg) {
...
@@ -71,15 +73,23 @@ static void *taosNetBindUdpPort(void *sarg) {
return
NULL
;
return
NULL
;
}
}
if
(
taosSetSockOpt
(
serverSocket
,
SOL_SOCKET
,
SO_SNDBUF
,
(
void
*
)
&
bufSize
,
sizeof
(
bufSize
))
!=
0
)
{
TdSocketPtr
pSocket
=
(
TdSocketPtr
)
malloc
(
sizeof
(
TdSocket
));
if
(
pSocket
==
NULL
)
{
taosCloseSocketNoCheck1
(
serverSocket
);
return
NULL
;
}
pSocket
->
fd
=
serverSocket
;
pSocket
->
refId
=
0
;
if
(
taosSetSockOpt
(
pSocket
,
SOL_SOCKET
,
SO_SNDBUF
,
(
void
*
)
&
bufSize
,
sizeof
(
bufSize
))
!=
0
)
{
uError
(
"failed to set the send buffer size for UDP socket
\n
"
);
uError
(
"failed to set the send buffer size for UDP socket
\n
"
);
taosCloseSocket
(
server
Socket
);
taosCloseSocket
(
&
p
Socket
);
return
NULL
;
return
NULL
;
}
}
if
(
taosSetSockOpt
(
server
Socket
,
SOL_SOCKET
,
SO_RCVBUF
,
(
void
*
)
&
bufSize
,
sizeof
(
bufSize
))
!=
0
)
{
if
(
taosSetSockOpt
(
p
Socket
,
SOL_SOCKET
,
SO_RCVBUF
,
(
void
*
)
&
bufSize
,
sizeof
(
bufSize
))
!=
0
)
{
uError
(
"failed to set the receive buffer size for UDP socket
\n
"
);
uError
(
"failed to set the receive buffer size for UDP socket
\n
"
);
taosCloseSocket
(
server
Socket
);
taosCloseSocket
(
&
p
Socket
);
return
NULL
;
return
NULL
;
}
}
...
@@ -98,13 +108,13 @@ static void *taosNetBindUdpPort(void *sarg) {
...
@@ -98,13 +108,13 @@ static void *taosNetBindUdpPort(void *sarg) {
uInfo
(
"UDP: recv:%d bytes from %s at %d"
,
iDataNum
,
taosInetNtoa
(
clientAddr
.
sin_addr
),
port
);
uInfo
(
"UDP: recv:%d bytes from %s at %d"
,
iDataNum
,
taosInetNtoa
(
clientAddr
.
sin_addr
),
port
);
if
(
iDataNum
>
0
)
{
if
(
iDataNum
>
0
)
{
iDataNum
=
taosSendto
(
server
Socket
,
buffer
,
iDataNum
,
0
,
(
struct
sockaddr
*
)
&
clientAddr
,
(
int32_t
)
sin_size
);
iDataNum
=
taosSendto
(
p
Socket
,
buffer
,
iDataNum
,
0
,
(
struct
sockaddr
*
)
&
clientAddr
,
(
int32_t
)
sin_size
);
}
}
uInfo
(
"UDP: send:%d bytes to %s at %d"
,
iDataNum
,
taosInetNtoa
(
clientAddr
.
sin_addr
),
port
);
uInfo
(
"UDP: send:%d bytes to %s at %d"
,
iDataNum
,
taosInetNtoa
(
clientAddr
.
sin_addr
),
port
);
}
}
taosCloseSocket
(
server
Socket
);
taosCloseSocket
(
&
p
Socket
);
return
NULL
;
return
NULL
;
}
}
...
@@ -132,25 +142,35 @@ static void *taosNetBindTcpPort(void *sarg) {
...
@@ -132,25 +142,35 @@ static void *taosNetBindTcpPort(void *sarg) {
server_addr
.
sin_addr
.
s_addr
=
htonl
(
INADDR_ANY
);
server_addr
.
sin_addr
.
s_addr
=
htonl
(
INADDR_ANY
);
int32_t
reuse
=
1
;
int32_t
reuse
=
1
;
if
(
taosSetSockOpt
(
serverSocket
,
SOL_SOCKET
,
SO_REUSEADDR
,
(
void
*
)
&
reuse
,
sizeof
(
reuse
))
<
0
)
{
TdSocketPtr
pSocket
=
(
TdSocketPtr
)
malloc
(
sizeof
(
TdSocket
));
if
(
pSocket
==
NULL
)
{
taosCloseSocketNoCheck1
(
serverSocket
);
return
NULL
;
}
pSocket
->
fd
=
serverSocket
;
pSocket
->
refId
=
0
;
if
(
taosSetSockOpt
(
pSocket
,
SOL_SOCKET
,
SO_REUSEADDR
,
(
void
*
)
&
reuse
,
sizeof
(
reuse
))
<
0
)
{
uError
(
"setsockopt SO_REUSEADDR failed: %d (%s)"
,
errno
,
strerror
(
errno
));
uError
(
"setsockopt SO_REUSEADDR failed: %d (%s)"
,
errno
,
strerror
(
errno
));
taosCloseSocket
(
server
Socket
);
taosCloseSocket
(
&
p
Socket
);
return
NULL
;
return
NULL
;
}
}
if
(
bind
(
serverSocket
,
(
struct
sockaddr
*
)
&
server_addr
,
sizeof
(
server_addr
))
<
0
)
{
if
(
bind
(
serverSocket
,
(
struct
sockaddr
*
)
&
server_addr
,
sizeof
(
server_addr
))
<
0
)
{
uError
(
"failed to bind TCP port:%d since %s"
,
port
,
strerror
(
errno
));
uError
(
"failed to bind TCP port:%d since %s"
,
port
,
strerror
(
errno
));
taosCloseSocket
(
&
pSocket
);
return
NULL
;
return
NULL
;
}
}
if
(
taosKeepTcpAlive
(
server
Socket
)
<
0
)
{
if
(
taosKeepTcpAlive
(
p
Socket
)
<
0
)
{
uError
(
"failed to set tcp server keep-alive option since %s"
,
strerror
(
errno
));
uError
(
"failed to set tcp server keep-alive option since %s"
,
strerror
(
errno
));
taosCloseSocket
(
server
Socket
);
taosCloseSocket
(
&
p
Socket
);
return
NULL
;
return
NULL
;
}
}
if
(
listen
(
serverSocket
,
10
)
<
0
)
{
if
(
listen
(
serverSocket
,
10
)
<
0
)
{
uError
(
"failed to listen TCP port:%d since %s"
,
port
,
strerror
(
errno
));
uError
(
"failed to listen TCP port:%d since %s"
,
port
,
strerror
(
errno
));
taosCloseSocket
(
&
pSocket
);
return
NULL
;
return
NULL
;
}
}
...
@@ -163,26 +183,26 @@ static void *taosNetBindTcpPort(void *sarg) {
...
@@ -163,26 +183,26 @@ static void *taosNetBindTcpPort(void *sarg) {
continue
;
continue
;
}
}
int32_t
ret
=
taosReadMsg
(
clien
t
,
buffer
,
pinfo
->
pktLen
);
int32_t
ret
=
taosReadMsg
(
pSocke
t
,
buffer
,
pinfo
->
pktLen
);
if
(
ret
<
0
||
ret
!=
pinfo
->
pktLen
)
{
if
(
ret
<
0
||
ret
!=
pinfo
->
pktLen
)
{
uError
(
"TCP: failed to read %d bytes at port:%d since %s"
,
pinfo
->
pktLen
,
port
,
strerror
(
errno
));
uError
(
"TCP: failed to read %d bytes at port:%d since %s"
,
pinfo
->
pktLen
,
port
,
strerror
(
errno
));
taosCloseSocket
(
server
Socket
);
taosCloseSocket
(
&
p
Socket
);
return
NULL
;
return
NULL
;
}
}
uInfo
(
"TCP: read:%d bytes from %s at %d"
,
pinfo
->
pktLen
,
taosInetNtoa
(
clientAddr
.
sin_addr
),
port
);
uInfo
(
"TCP: read:%d bytes from %s at %d"
,
pinfo
->
pktLen
,
taosInetNtoa
(
clientAddr
.
sin_addr
),
port
);
ret
=
taosWriteMsg
(
clien
t
,
buffer
,
pinfo
->
pktLen
);
ret
=
taosWriteMsg
(
pSocke
t
,
buffer
,
pinfo
->
pktLen
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
uError
(
"TCP: failed to write %d bytes at %d since %s"
,
pinfo
->
pktLen
,
port
,
strerror
(
errno
));
uError
(
"TCP: failed to write %d bytes at %d since %s"
,
pinfo
->
pktLen
,
port
,
strerror
(
errno
));
taosCloseSocket
(
server
Socket
);
taosCloseSocket
(
&
p
Socket
);
return
NULL
;
return
NULL
;
}
}
uInfo
(
"TCP: write:%d bytes to %s at %d"
,
pinfo
->
pktLen
,
taosInetNtoa
(
clientAddr
.
sin_addr
),
port
);
uInfo
(
"TCP: write:%d bytes to %s at %d"
,
pinfo
->
pktLen
,
taosInetNtoa
(
clientAddr
.
sin_addr
),
port
);
}
}
taosCloseSocket
(
server
Socket
);
taosCloseSocket
(
&
p
Socket
);
return
NULL
;
return
NULL
;
}
}
...
@@ -196,9 +216,17 @@ static int32_t taosNetCheckTcpPort(STestInfo *info) {
...
@@ -196,9 +216,17 @@ static int32_t taosNetCheckTcpPort(STestInfo *info) {
}
}
int32_t
reuse
=
1
;
int32_t
reuse
=
1
;
if
(
taosSetSockOpt
(
clientSocket
,
SOL_SOCKET
,
SO_REUSEADDR
,
(
void
*
)
&
reuse
,
sizeof
(
reuse
))
<
0
)
{
TdSocketPtr
pSocket
=
(
TdSocketPtr
)
malloc
(
sizeof
(
TdSocket
));
if
(
pSocket
==
NULL
)
{
taosCloseSocketNoCheck1
(
clientSocket
);
return
-
1
;
}
pSocket
->
fd
=
clientSocket
;
pSocket
->
refId
=
0
;
if
(
taosSetSockOpt
(
pSocket
,
SOL_SOCKET
,
SO_REUSEADDR
,
(
void
*
)
&
reuse
,
sizeof
(
reuse
))
<
0
)
{
uError
(
"setsockopt SO_REUSEADDR failed: %d (%s)"
,
errno
,
strerror
(
errno
));
uError
(
"setsockopt SO_REUSEADDR failed: %d (%s)"
,
errno
,
strerror
(
errno
));
taosCloseSocket
(
client
Socket
);
taosCloseSocket
(
&
p
Socket
);
return
-
1
;
return
-
1
;
}
}
...
@@ -210,27 +238,30 @@ static int32_t taosNetCheckTcpPort(STestInfo *info) {
...
@@ -210,27 +238,30 @@ static int32_t taosNetCheckTcpPort(STestInfo *info) {
if
(
connect
(
clientSocket
,
(
struct
sockaddr
*
)
&
serverAddr
,
sizeof
(
serverAddr
))
<
0
)
{
if
(
connect
(
clientSocket
,
(
struct
sockaddr
*
)
&
serverAddr
,
sizeof
(
serverAddr
))
<
0
)
{
uError
(
"TCP: failed to connect port %s:%d since %s"
,
taosIpStr
(
info
->
hostIp
),
info
->
port
,
strerror
(
errno
));
uError
(
"TCP: failed to connect port %s:%d since %s"
,
taosIpStr
(
info
->
hostIp
),
info
->
port
,
strerror
(
errno
));
taosCloseSocket
(
&
pSocket
);
return
-
1
;
return
-
1
;
}
}
taosKeepTcpAlive
(
client
Socket
);
taosKeepTcpAlive
(
p
Socket
);
sprintf
(
buffer
,
"client send TCP pkg to %s:%d, content: 1122334455"
,
taosIpStr
(
info
->
hostIp
),
info
->
port
);
sprintf
(
buffer
,
"client send TCP pkg to %s:%d, content: 1122334455"
,
taosIpStr
(
info
->
hostIp
),
info
->
port
);
sprintf
(
buffer
+
info
->
pktLen
-
16
,
"1122334455667788"
);
sprintf
(
buffer
+
info
->
pktLen
-
16
,
"1122334455667788"
);
int32_t
ret
=
taosWriteMsg
(
client
Socket
,
buffer
,
info
->
pktLen
);
int32_t
ret
=
taosWriteMsg
(
p
Socket
,
buffer
,
info
->
pktLen
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
uError
(
"TCP: failed to write msg to %s:%d since %s"
,
taosIpStr
(
info
->
hostIp
),
info
->
port
,
strerror
(
errno
));
uError
(
"TCP: failed to write msg to %s:%d since %s"
,
taosIpStr
(
info
->
hostIp
),
info
->
port
,
strerror
(
errno
));
taosCloseSocket
(
&
pSocket
);
return
-
1
;
return
-
1
;
}
}
ret
=
taosReadMsg
(
client
Socket
,
buffer
,
info
->
pktLen
);
ret
=
taosReadMsg
(
p
Socket
,
buffer
,
info
->
pktLen
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
uError
(
"TCP: failed to read msg from %s:%d since %s"
,
taosIpStr
(
info
->
hostIp
),
info
->
port
,
strerror
(
errno
));
uError
(
"TCP: failed to read msg from %s:%d since %s"
,
taosIpStr
(
info
->
hostIp
),
info
->
port
,
strerror
(
errno
));
taosCloseSocket
(
&
pSocket
);
return
-
1
;
return
-
1
;
}
}
taosCloseSocket
(
client
Socket
);
taosCloseSocket
(
&
p
Socket
);
return
0
;
return
0
;
}
}
...
@@ -247,13 +278,23 @@ static int32_t taosNetCheckUdpPort(STestInfo *info) {
...
@@ -247,13 +278,23 @@ static int32_t taosNetCheckUdpPort(STestInfo *info) {
return
-
1
;
return
-
1
;
}
}
if
(
taosSetSockOpt
(
clientSocket
,
SOL_SOCKET
,
SO_SNDBUF
,
(
void
*
)
&
bufSize
,
sizeof
(
bufSize
))
!=
0
)
{
TdSocketPtr
pSocket
=
(
TdSocketPtr
)
malloc
(
sizeof
(
TdSocket
));
if
(
pSocket
==
NULL
)
{
taosCloseSocketNoCheck1
(
clientSocket
);
return
-
1
;
}
pSocket
->
fd
=
clientSocket
;
pSocket
->
refId
=
0
;
if
(
taosSetSockOpt
(
pSocket
,
SOL_SOCKET
,
SO_SNDBUF
,
(
void
*
)
&
bufSize
,
sizeof
(
bufSize
))
!=
0
)
{
uError
(
"failed to set the send buffer size for UDP socket
\n
"
);
uError
(
"failed to set the send buffer size for UDP socket
\n
"
);
taosCloseSocket
(
&
pSocket
);
return
-
1
;
return
-
1
;
}
}
if
(
taosSetSockOpt
(
client
Socket
,
SOL_SOCKET
,
SO_RCVBUF
,
(
void
*
)
&
bufSize
,
sizeof
(
bufSize
))
!=
0
)
{
if
(
taosSetSockOpt
(
p
Socket
,
SOL_SOCKET
,
SO_RCVBUF
,
(
void
*
)
&
bufSize
,
sizeof
(
bufSize
))
!=
0
)
{
uError
(
"failed to set the receive buffer size for UDP socket
\n
"
);
uError
(
"failed to set the receive buffer size for UDP socket
\n
"
);
taosCloseSocket
(
&
pSocket
);
return
-
1
;
return
-
1
;
}
}
...
@@ -268,9 +309,10 @@ static int32_t taosNetCheckUdpPort(STestInfo *info) {
...
@@ -268,9 +309,10 @@ static int32_t taosNetCheckUdpPort(STestInfo *info) {
socklen_t
sin_size
=
sizeof
(
*
(
struct
sockaddr
*
)
&
serverAddr
);
socklen_t
sin_size
=
sizeof
(
*
(
struct
sockaddr
*
)
&
serverAddr
);
iDataNum
=
taosSendto
(
client
Socket
,
buffer
,
info
->
pktLen
,
0
,
(
struct
sockaddr
*
)
&
serverAddr
,
(
int32_t
)
sin_size
);
iDataNum
=
taosSendto
(
p
Socket
,
buffer
,
info
->
pktLen
,
0
,
(
struct
sockaddr
*
)
&
serverAddr
,
(
int32_t
)
sin_size
);
if
(
iDataNum
<
0
||
iDataNum
!=
info
->
pktLen
)
{
if
(
iDataNum
<
0
||
iDataNum
!=
info
->
pktLen
)
{
uError
(
"UDP: failed to perform sendto func since %s"
,
strerror
(
errno
));
uError
(
"UDP: failed to perform sendto func since %s"
,
strerror
(
errno
));
taosCloseSocket
(
&
pSocket
);
return
-
1
;
return
-
1
;
}
}
...
@@ -280,10 +322,11 @@ static int32_t taosNetCheckUdpPort(STestInfo *info) {
...
@@ -280,10 +322,11 @@ static int32_t taosNetCheckUdpPort(STestInfo *info) {
if
(
iDataNum
<
0
||
iDataNum
!=
info
->
pktLen
)
{
if
(
iDataNum
<
0
||
iDataNum
!=
info
->
pktLen
)
{
uError
(
"UDP: received ack:%d bytes(expect:%d) from port:%d since %s"
,
iDataNum
,
info
->
pktLen
,
info
->
port
,
strerror
(
errno
));
uError
(
"UDP: received ack:%d bytes(expect:%d) from port:%d since %s"
,
iDataNum
,
info
->
pktLen
,
info
->
port
,
strerror
(
errno
));
taosCloseSocket
(
&
pSocket
);
return
-
1
;
return
-
1
;
}
}
taosCloseSocket
(
client
Socket
);
taosCloseSocket
(
&
p
Socket
);
return
0
;
return
0
;
}
}
...
@@ -339,7 +382,7 @@ void *taosNetInitRpc(char *secretEncrypt, char spi) {
...
@@ -339,7 +382,7 @@ void *taosNetInitRpc(char *secretEncrypt, char spi) {
}
}
static
int32_t
taosNetCheckRpc
(
const
char
*
serverFqdn
,
uint16_t
port
,
uint16_t
pktLen
,
char
spi
,
SStartupReq
*
pStep
)
{
static
int32_t
taosNetCheckRpc
(
const
char
*
serverFqdn
,
uint16_t
port
,
uint16_t
pktLen
,
char
spi
,
SStartupReq
*
pStep
)
{
S
Rpc
EpSet
epSet
;
SEpSet
epSet
;
SRpcMsg
reqMsg
;
SRpcMsg
reqMsg
;
SRpcMsg
rspMsg
;
SRpcMsg
rspMsg
;
void
*
pRpcConn
;
void
*
pRpcConn
;
...
@@ -352,11 +395,10 @@ static int32_t taosNetCheckRpc(const char* serverFqdn, uint16_t port, uint16_t p
...
@@ -352,11 +395,10 @@ static int32_t taosNetCheckRpc(const char* serverFqdn, uint16_t port, uint16_t p
return
TSDB_CODE_RPC_NETWORK_UNAVAIL
;
return
TSDB_CODE_RPC_NETWORK_UNAVAIL
;
}
}
memset
(
&
epSet
,
0
,
sizeof
(
SRpcEpSet
));
memset
(
&
epSet
,
0
,
sizeof
(
SEpSet
));
epSet
.
inUse
=
0
;
strcpy
(
epSet
.
eps
[
0
].
fqdn
,
serverFqdn
);
epSet
.
eps
[
0
].
port
=
port
;
epSet
.
numOfEps
=
1
;
epSet
.
numOfEps
=
1
;
epSet
.
port
[
0
]
=
port
;
strcpy
(
epSet
.
fqdn
[
0
],
serverFqdn
);
reqMsg
.
msgType
=
TDMT_DND_NETWORK_TEST
;
reqMsg
.
msgType
=
TDMT_DND_NETWORK_TEST
;
reqMsg
.
pCont
=
rpcMallocCont
(
pktLen
);
reqMsg
.
pCont
=
rpcMallocCont
(
pktLen
);
...
@@ -425,8 +467,8 @@ static void taosNetCheckSync(char *host, int32_t port) {
...
@@ -425,8 +467,8 @@ static void taosNetCheckSync(char *host, int32_t port) {
return
;
return
;
}
}
SOCKET
connFd
=
taosOpenTcpClientSocket
(
ip
,
(
uint16_t
)
port
,
0
);
TdSocketPtr
pSocket
=
taosOpenTcpClientSocket
(
ip
,
(
uint16_t
)
port
,
0
);
if
(
connFd
<
0
)
{
if
(
pSocket
==
NULL
)
{
uError
(
"failed to create socket while test port:%d since %s"
,
port
,
strerror
(
errno
));
uError
(
"failed to create socket while test port:%d since %s"
,
port
,
strerror
(
errno
));
return
;
return
;
}
}
...
@@ -443,17 +485,17 @@ static void taosNetCheckSync(char *host, int32_t port) {
...
@@ -443,17 +485,17 @@ static void taosNetCheckSync(char *host, int32_t port) {
pHead
->
len
=
sizeof
(
SSyncMsg
)
-
sizeof
(
SSyncHead
);
pHead
->
len
=
sizeof
(
SSyncMsg
)
-
sizeof
(
SSyncHead
);
taosCalcChecksumAppend
(
0
,
(
uint8_t
*
)
pHead
,
sizeof
(
SSyncHead
));
taosCalcChecksumAppend
(
0
,
(
uint8_t
*
)
pHead
,
sizeof
(
SSyncHead
));
if
(
taosWriteMsg
(
connFd
,
&
msg
,
sizeof
(
SSyncMsg
))
!=
sizeof
(
SSyncMsg
))
{
if
(
taosWriteMsg
(
pSocket
,
&
msg
,
sizeof
(
SSyncMsg
))
!=
sizeof
(
SSyncMsg
))
{
uError
(
"failed to test port:%d while send msg since %s"
,
port
,
strerror
(
errno
));
uError
(
"failed to test port:%d while send msg since %s"
,
port
,
strerror
(
errno
));
return
;
return
;
}
}
if
(
taosReadMsg
(
connFd
,
&
msg
,
sizeof
(
SSyncMsg
))
!=
sizeof
(
SSyncMsg
))
{
if
(
taosReadMsg
(
pSocket
,
&
msg
,
sizeof
(
SSyncMsg
))
!=
sizeof
(
SSyncMsg
))
{
uError
(
"failed to test port:%d while recv msg since %s"
,
port
,
strerror
(
errno
));
uError
(
"failed to test port:%d while recv msg since %s"
,
port
,
strerror
(
errno
));
}
}
uInfo
(
"successed to test TCP port:%d"
,
port
);
uInfo
(
"successed to test TCP port:%d"
,
port
);
taosCloseSocket
(
connFd
);
taosCloseSocket
(
&
pSocket
);
}
}
static
void
taosNetTestRpc
(
char
*
host
,
int32_t
startPort
,
int32_t
pkgLen
)
{
static
void
taosNetTestRpc
(
char
*
host
,
int32_t
startPort
,
int32_t
pkgLen
)
{
...
@@ -494,7 +536,6 @@ static void taosNetTestRpc(char *host, int32_t startPort, int32_t pkgLen) {
...
@@ -494,7 +536,6 @@ static void taosNetTestRpc(char *host, int32_t startPort, int32_t pkgLen) {
}
}
taosNetCheckSync
(
host
,
startPort
+
TSDB_PORT_SYNC
);
taosNetCheckSync
(
host
,
startPort
+
TSDB_PORT_SYNC
);
taosNetCheckSync
(
host
,
startPort
+
TSDB_PORT_ARBITRATOR
);
}
}
static
void
taosNetTestClient
(
char
*
host
,
int32_t
startPort
,
int32_t
pkgLen
)
{
static
void
taosNetTestClient
(
char
*
host
,
int32_t
startPort
,
int32_t
pkgLen
)
{
...
@@ -578,7 +619,7 @@ static void taosNetCheckSpeed(char *host, int32_t port, int32_t pkgLen,
...
@@ -578,7 +619,7 @@ static void taosNetCheckSpeed(char *host, int32_t port, int32_t pkgLen,
}
}
tsCompressMsgSize
=
-
1
;
tsCompressMsgSize
=
-
1
;
S
Rpc
EpSet
epSet
;
SEpSet
epSet
;
SRpcMsg
reqMsg
;
SRpcMsg
reqMsg
;
SRpcMsg
rspMsg
;
SRpcMsg
rspMsg
;
void
*
pRpcConn
;
void
*
pRpcConn
;
...
@@ -596,11 +637,10 @@ static void taosNetCheckSpeed(char *host, int32_t port, int32_t pkgLen,
...
@@ -596,11 +637,10 @@ static void taosNetCheckSpeed(char *host, int32_t port, int32_t pkgLen,
for
(
int32_t
i
=
1
;
i
<=
pkgNum
;
i
++
)
{
for
(
int32_t
i
=
1
;
i
<=
pkgNum
;
i
++
)
{
uint64_t
startTime
=
taosGetTimestampUs
();
uint64_t
startTime
=
taosGetTimestampUs
();
memset
(
&
epSet
,
0
,
sizeof
(
SRpcEpSet
));
memset
(
&
epSet
,
0
,
sizeof
(
SEpSet
));
epSet
.
inUse
=
0
;
strcpy
(
epSet
.
eps
[
0
].
fqdn
,
host
);
epSet
.
eps
[
0
].
port
=
port
;
epSet
.
numOfEps
=
1
;
epSet
.
numOfEps
=
1
;
epSet
.
port
[
0
]
=
port
;
strcpy
(
epSet
.
fqdn
[
0
],
host
);
reqMsg
.
msgType
=
TDMT_DND_NETWORK_TEST
;
reqMsg
.
msgType
=
TDMT_DND_NETWORK_TEST
;
reqMsg
.
pCont
=
rpcMallocCont
(
pkgLen
);
reqMsg
.
pCont
=
rpcMallocCont
(
pkgLen
);
...
@@ -641,7 +681,7 @@ static void taosNetCheckSpeed(char *host, int32_t port, int32_t pkgLen,
...
@@ -641,7 +681,7 @@ static void taosNetCheckSpeed(char *host, int32_t port, int32_t pkgLen,
void
taosNetTest
(
char
*
role
,
char
*
host
,
int32_t
port
,
int32_t
pkgLen
,
void
taosNetTest
(
char
*
role
,
char
*
host
,
int32_t
port
,
int32_t
pkgLen
,
int32_t
pkgNum
,
char
*
pkgType
)
{
int32_t
pkgNum
,
char
*
pkgType
)
{
ts
c
Embedded
=
1
;
ts
Log
Embedded
=
1
;
if
(
host
==
NULL
)
host
=
tsLocalFqdn
;
if
(
host
==
NULL
)
host
=
tsLocalFqdn
;
if
(
port
==
0
)
port
=
tsServerPort
;
if
(
port
==
0
)
port
=
tsServerPort
;
if
(
0
==
strcmp
(
"speed"
,
role
)){
if
(
0
==
strcmp
(
"speed"
,
role
)){
...
@@ -659,14 +699,14 @@ void taosNetTest(char *role, char *host, int32_t port, int32_t pkgLen,
...
@@ -659,14 +699,14 @@ void taosNetTest(char *role, char *host, int32_t port, int32_t pkgLen,
}
else
if
(
0
==
strcmp
(
"server"
,
role
))
{
}
else
if
(
0
==
strcmp
(
"server"
,
role
))
{
taosNetTestServer
(
host
,
port
,
pkgLen
);
taosNetTestServer
(
host
,
port
,
pkgLen
);
}
else
if
(
0
==
strcmp
(
"rpc"
,
role
))
{
}
else
if
(
0
==
strcmp
(
"rpc"
,
role
))
{
ts
c
Embedded
=
0
;
ts
Log
Embedded
=
0
;
taosNetTestRpc
(
host
,
port
,
pkgLen
);
taosNetTestRpc
(
host
,
port
,
pkgLen
);
}
else
if
(
0
==
strcmp
(
"sync"
,
role
))
{
}
else
if
(
0
==
strcmp
(
"sync"
,
role
))
{
taosNetCheckSync
(
host
,
port
);
taosNetCheckSync
(
host
,
port
);
}
else
if
(
0
==
strcmp
(
"startup"
,
role
))
{
}
else
if
(
0
==
strcmp
(
"startup"
,
role
))
{
taosNetTestStartup
(
host
,
port
);
taosNetTestStartup
(
host
,
port
);
}
else
if
(
0
==
strcmp
(
"speed"
,
role
))
{
}
else
if
(
0
==
strcmp
(
"speed"
,
role
))
{
ts
c
Embedded
=
0
;
ts
Log
Embedded
=
0
;
char
type
[
10
]
=
{
0
};
char
type
[
10
]
=
{
0
};
taosNetCheckSpeed
(
host
,
port
,
pkgLen
,
pkgNum
,
strtolower
(
type
,
pkgType
));
taosNetCheckSpeed
(
host
,
port
,
pkgLen
,
pkgNum
,
strtolower
(
type
,
pkgType
));
}
else
if
(
0
==
strcmp
(
"fqdn"
,
role
))
{
}
else
if
(
0
==
strcmp
(
"fqdn"
,
role
))
{
...
@@ -675,5 +715,5 @@ void taosNetTest(char *role, char *host, int32_t port, int32_t pkgLen,
...
@@ -675,5 +715,5 @@ void taosNetTest(char *role, char *host, int32_t port, int32_t pkgLen,
taosNetTestStartup
(
host
,
port
);
taosNetTestStartup
(
host
,
port
);
}
}
ts
c
Embedded
=
0
;
ts
Log
Embedded
=
0
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录