Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
43d154a6
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
43d154a6
编写于
1月 27, 2021
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-2861
上级
65cc4d90
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
69 addition
and
4 deletion
+69
-4
src/sync/inc/syncMsg.h
src/sync/inc/syncMsg.h
+3
-1
src/sync/src/syncMain.c
src/sync/src/syncMain.c
+19
-0
src/sync/src/syncMsg.c
src/sync/src/syncMsg.c
+1
-0
src/util/CMakeLists.txt
src/util/CMakeLists.txt
+1
-0
src/util/src/tnettest.c
src/util/src/tnettest.c
+45
-3
未找到文件。
src/sync/inc/syncMsg.h
浏览文件 @
43d154a6
...
@@ -37,7 +37,8 @@ typedef enum {
...
@@ -37,7 +37,8 @@ typedef enum {
TAOS_SMSG_SETUP_RSP
=
12
,
TAOS_SMSG_SETUP_RSP
=
12
,
TAOS_SMSG_SYNC_FILE
=
13
,
TAOS_SMSG_SYNC_FILE
=
13
,
TAOS_SMSG_SYNC_FILE_RSP
=
14
,
TAOS_SMSG_SYNC_FILE_RSP
=
14
,
TAOS_SMSG_END
=
15
,
TAOS_SMSG_TEST
=
15
,
TAOS_SMSG_END
=
16
}
ESyncMsgType
;
}
ESyncMsgType
;
typedef
enum
{
typedef
enum
{
...
@@ -132,6 +133,7 @@ void syncBuildSyncReqMsg(SSyncMsg *pMsg, int32_t vgId);
...
@@ -132,6 +133,7 @@ void syncBuildSyncReqMsg(SSyncMsg *pMsg, int32_t vgId);
void
syncBuildSyncDataMsg
(
SSyncMsg
*
pMsg
,
int32_t
vgId
);
void
syncBuildSyncDataMsg
(
SSyncMsg
*
pMsg
,
int32_t
vgId
);
void
syncBuildSyncSetupMsg
(
SSyncMsg
*
pMsg
,
int32_t
vgId
);
void
syncBuildSyncSetupMsg
(
SSyncMsg
*
pMsg
,
int32_t
vgId
);
void
syncBuildPeersStatus
(
SPeersStatus
*
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
syncBuildFileAck
(
SFileAck
*
pMsg
,
int32_t
vgId
);
void
syncBuildFileInfo
(
SFileInfo
*
pMsg
,
int32_t
vgId
);
void
syncBuildFileInfo
(
SFileInfo
*
pMsg
,
int32_t
vgId
);
...
...
src/sync/src/syncMain.c
浏览文件 @
43d154a6
...
@@ -1179,6 +1179,20 @@ static void syncCreateRestoreDataThread(SSyncPeer *pPeer) {
...
@@ -1179,6 +1179,20 @@ static void syncCreateRestoreDataThread(SSyncPeer *pPeer) {
}
}
}
}
static
void
syncProcessTestMsg
(
SSyncMsg
*
pMsg
,
SOCKET
connFd
)
{
sInfo
(
"recv sync test msg"
);
SSyncMsg
rsp
;
syncBuildSyncTestMsg
(
&
rsp
,
-
1
);
if
(
taosWriteMsg
(
connFd
,
&
rsp
,
sizeof
(
SSyncMsg
))
!=
sizeof
(
SSyncMsg
))
{
sInfo
(
"failed to send sync test rsp since %s"
,
strerror
(
errno
));
}
sInfo
(
"send sync test rsp"
);
taosMsleep
(
1000
);
taosCloseSocket
(
connFd
);
}
static
void
syncProcessIncommingConnection
(
SOCKET
connFd
,
uint32_t
sourceIp
)
{
static
void
syncProcessIncommingConnection
(
SOCKET
connFd
,
uint32_t
sourceIp
)
{
char
ipstr
[
24
];
char
ipstr
[
24
];
int32_t
i
;
int32_t
i
;
...
@@ -1200,6 +1214,11 @@ static void syncProcessIncommingConnection(SOCKET connFd, uint32_t sourceIp) {
...
@@ -1200,6 +1214,11 @@ static void syncProcessIncommingConnection(SOCKET connFd, uint32_t sourceIp) {
return
;
return
;
}
}
if
(
msg
.
head
.
type
==
TAOS_SMSG_TEST
)
{
syncProcessTestMsg
(
&
msg
,
connFd
);
return
;
}
int32_t
vgId
=
msg
.
head
.
vgId
;
int32_t
vgId
=
msg
.
head
.
vgId
;
SSyncNode
**
ppNode
=
taosHashGet
(
tsVgIdHash
,
&
vgId
,
sizeof
(
int32_t
));
SSyncNode
**
ppNode
=
taosHashGet
(
tsVgIdHash
,
&
vgId
,
sizeof
(
int32_t
));
if
(
ppNode
==
NULL
||
*
ppNode
==
NULL
)
{
if
(
ppNode
==
NULL
||
*
ppNode
==
NULL
)
{
...
...
src/sync/src/syncMsg.c
浏览文件 @
43d154a6
...
@@ -86,6 +86,7 @@ static void syncBuildMsg(SSyncMsg *pMsg, int32_t vgId, ESyncMsgType type) {
...
@@ -86,6 +86,7 @@ static void syncBuildMsg(SSyncMsg *pMsg, int32_t vgId, ESyncMsgType type) {
void
syncBuildSyncReqMsg
(
SSyncMsg
*
pMsg
,
int32_t
vgId
)
{
syncBuildMsg
(
pMsg
,
vgId
,
TAOS_SMSG_SYNC_REQ
);
}
void
syncBuildSyncReqMsg
(
SSyncMsg
*
pMsg
,
int32_t
vgId
)
{
syncBuildMsg
(
pMsg
,
vgId
,
TAOS_SMSG_SYNC_REQ
);
}
void
syncBuildSyncDataMsg
(
SSyncMsg
*
pMsg
,
int32_t
vgId
)
{
syncBuildMsg
(
pMsg
,
vgId
,
TAOS_SMSG_SYNC_DATA
);
}
void
syncBuildSyncDataMsg
(
SSyncMsg
*
pMsg
,
int32_t
vgId
)
{
syncBuildMsg
(
pMsg
,
vgId
,
TAOS_SMSG_SYNC_DATA
);
}
void
syncBuildSyncSetupMsg
(
SSyncMsg
*
pMsg
,
int32_t
vgId
)
{
syncBuildMsg
(
pMsg
,
vgId
,
TAOS_SMSG_SETUP
);
}
void
syncBuildSyncSetupMsg
(
SSyncMsg
*
pMsg
,
int32_t
vgId
)
{
syncBuildMsg
(
pMsg
,
vgId
,
TAOS_SMSG_SETUP
);
}
void
syncBuildSyncTestMsg
(
SSyncMsg
*
pMsg
,
int32_t
vgId
)
{
syncBuildMsg
(
pMsg
,
vgId
,
TAOS_SMSG_TEST
);
}
void
syncBuildPeersStatus
(
SPeersStatus
*
pMsg
,
int32_t
vgId
)
{
void
syncBuildPeersStatus
(
SPeersStatus
*
pMsg
,
int32_t
vgId
)
{
pMsg
->
head
.
type
=
TAOS_SMSG_STATUS
;
pMsg
->
head
.
type
=
TAOS_SMSG_STATUS
;
...
...
src/util/CMakeLists.txt
浏览文件 @
43d154a6
...
@@ -2,6 +2,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.5)
...
@@ -2,6 +2,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.5)
PROJECT
(
TDengine
)
PROJECT
(
TDengine
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/rpc/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/rpc/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/sync/inc
)
AUX_SOURCE_DIRECTORY
(
src SRC
)
AUX_SOURCE_DIRECTORY
(
src SRC
)
ADD_LIBRARY
(
tutil
${
SRC
}
)
ADD_LIBRARY
(
tutil
${
SRC
}
)
TARGET_LINK_LIBRARIES
(
tutil pthread osdetail lz4 z
)
TARGET_LINK_LIBRARIES
(
tutil pthread osdetail lz4 z
)
...
...
src/util/src/tnettest.c
浏览文件 @
43d154a6
...
@@ -23,6 +23,8 @@
...
@@ -23,6 +23,8 @@
#include "tsocket.h"
#include "tsocket.h"
#include "trpc.h"
#include "trpc.h"
#include "rpcHead.h"
#include "rpcHead.h"
#include "tchecksum.h"
#include "syncMsg.h"
#define MAX_PKG_LEN (64 * 1000)
#define MAX_PKG_LEN (64 * 1000)
#define BUFFER_SIZE (MAX_PKG_LEN + 1024)
#define BUFFER_SIZE (MAX_PKG_LEN + 1024)
...
@@ -408,13 +410,51 @@ static void taosNetTestStartup(char *host, int32_t port) {
...
@@ -408,13 +410,51 @@ static void taosNetTestStartup(char *host, int32_t port) {
free
(
pStep
);
free
(
pStep
);
}
}
static
void
taosNetCheckSync
(
char
*
host
,
int32_t
port
)
{
uint32_t
ip
=
taosGetIpv4FromFqdn
(
host
);
if
(
ip
==
0xffffffff
)
{
uError
(
"failed to get IP address from %s since %s"
,
host
,
strerror
(
errno
));
return
;
}
SOCKET
connFd
=
taosOpenTcpClientSocket
(
ip
,
(
uint16_t
)
port
,
0
);
if
(
connFd
<
0
)
{
uError
(
"failed to create socket while test port:%d since %s"
,
port
,
strerror
(
errno
));
return
;
}
SSyncMsg
msg
;
memset
(
&
msg
,
0
,
sizeof
(
SSyncMsg
));
SSyncHead
*
pHead
=
&
msg
.
head
;
pHead
->
type
=
TAOS_SMSG_TEST
;
pHead
->
protocol
=
SYNC_PROTOCOL_VERSION
;
pHead
->
signature
=
SYNC_SIGNATURE
;
pHead
->
code
=
0
;
pHead
->
cId
=
0
;
pHead
->
vgId
=
-
1
;
pHead
->
len
=
sizeof
(
SSyncMsg
)
-
sizeof
(
SSyncHead
);
taosCalcChecksumAppend
(
0
,
(
uint8_t
*
)
pHead
,
sizeof
(
SSyncHead
));
if
(
taosWriteMsg
(
connFd
,
&
msg
,
sizeof
(
SSyncMsg
))
!=
sizeof
(
SSyncMsg
))
{
uError
(
"failed to test port:%d while send msg since %s"
,
port
,
strerror
(
errno
));
return
;
}
if
(
taosReadMsg
(
connFd
,
&
msg
,
sizeof
(
SSyncMsg
))
!=
sizeof
(
SSyncMsg
))
{
uError
(
"failed to test port:%d while recv msg since %s"
,
port
,
strerror
(
errno
));
}
uInfo
(
"successed to test TCP port:%d"
,
port
);
taosCloseSocket
(
connFd
);
}
static
void
taosNetTestRpc
(
char
*
host
,
int32_t
startPort
,
int32_t
pkgLen
)
{
static
void
taosNetTestRpc
(
char
*
host
,
int32_t
startPort
,
int32_t
pkgLen
)
{
int32_t
endPort
=
startPort
+
9
;
int32_t
endPort
=
startPort
+
TSDB_PORT_SYNC
;
char
spi
=
0
;
char
spi
=
0
;
uInfo
(
"check rpc, host:%s startPort:%d endPort:%d pkgLen:%d
\n
"
,
host
,
startPort
,
endPort
,
pkgLen
);
uInfo
(
"check rpc, host:%s startPort:%d endPort:%d pkgLen:%d
\n
"
,
host
,
startPort
,
endPort
,
pkgLen
);
for
(
uint16_t
port
=
startPort
;
port
<
=
endPort
;
port
++
)
{
for
(
uint16_t
port
=
startPort
;
port
<
endPort
;
port
++
)
{
int32_t
sendpkgLen
;
int32_t
sendpkgLen
;
if
(
pkgLen
<=
tsRpcMaxUdpSize
)
{
if
(
pkgLen
<=
tsRpcMaxUdpSize
)
{
sendpkgLen
=
tsRpcMaxUdpSize
+
1000
;
sendpkgLen
=
tsRpcMaxUdpSize
+
1000
;
...
@@ -442,6 +482,8 @@ static void taosNetTestRpc(char *host, int32_t startPort, int32_t pkgLen) {
...
@@ -442,6 +482,8 @@ static void taosNetTestRpc(char *host, int32_t startPort, int32_t pkgLen) {
uInfo
(
"successed to test UDP port:%d"
,
port
);
uInfo
(
"successed to test UDP port:%d"
,
port
);
}
}
}
}
taosNetCheckSync
(
host
,
endPort
);
}
}
static
void
taosNetTestClient
(
char
*
host
,
int32_t
startPort
,
int32_t
pkgLen
)
{
static
void
taosNetTestClient
(
char
*
host
,
int32_t
startPort
,
int32_t
pkgLen
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录